libdohj is a comprehensive Java library for Dogecoin development, built on top of bitcoinj. It provides full Dogecoin network support including address generation, peer connectivity, AuxPoW (merged mining), and blockchain operations.
- Dogecoin Address Generation - Generate P2PKH addresses with proper "D" prefix
- Network Connectivity - Connect to Dogecoin mainnet and testnet peers
- AuxPoW Support - Auxiliary Proof of Work for merged mining with Litecoin
- Merkle Branch Validation - Complete Merkle tree validation for AuxPoW
- Block & Transaction Handling - Full blockchain operations
- SegWit Support - Native SegWit address generation with "doge" prefix
- AltcoinSerializer - Custom serialization for Dogecoin protocol
- AltcoinBlock - Enhanced block class with Dogecoin features
- Network Parameters - Proper Dogecoin mainnet/testnet configuration
- Address Headers - Correct address prefixes (30 for mainnet, 113 for testnet)
- Packet Magic - Dogecoin-specific magic bytes (0xc0c0c0c0)
- Java 8+ (Java 7 for core modules)
- Gradle 3.4+ - for building the project
- Maven/Gradle - for dependency management
dependencies {
implementation 'org.dogecoin:libdohj:1.0.0'
}
<dependency>
<groupId>org.dogecoin</groupId>
<artifactId>libdohj</artifactId>
<version>1.0.0</version>
</dependency>
git clone https://github.com/qlpqlp/libdohj.git
cd libdohj
./gradlew build
import org.libdohj.params.DogecoinMainNetParams;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.base.LegacyAddress;
// Create a new key pair
ECKey key = new ECKey();
DogecoinMainNetParams params = DogecoinMainNetParams.get();
// Generate Dogecoin address (starts with "D")
LegacyAddress address = LegacyAddress.fromPubKeyHash(params, key.getPubKeyHash());
System.out.println("Private Key (WIF): " + key.getPrivateKeyEncoded(params));
System.out.println("Public Key: " + key.getPublicKeyAsHex());
System.out.println("Dogecoin Address: " + address.toString());
// Output: DMWrCGEYtFqX39ttqHLwDHzDjtUyyqUe3L
import org.libdohj.params.DogecoinMainNetParams;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.store.MemoryBlockStore;
// Set up Dogecoin mainnet
DogecoinMainNetParams params = DogecoinMainNetParams.get();
PeerGroup peerGroup = new PeerGroup(params, new BlockChain(params, new MemoryBlockStore()));
// Discover peers
DnsDiscovery discovery = new DnsDiscovery(params);
List<InetSocketAddress> peers = discovery.getPeers(10, Duration.ofSeconds(10));
System.out.println("Discovered " + peers.size() + " Dogecoin peers:");
peers.forEach(peer -> System.out.println(" - " + peer));
// Connect to peers
peerGroup.start();
peers.forEach(peer -> peerGroup.addAddress(new PeerAddress(peer)));
import org.libdohj.params.DogecoinTestNet3Params;
// Generate testnet address (starts with "n" or "2")
DogecoinTestNet3Params testnetParams = DogecoinTestNet3Params.get();
ECKey key = new ECKey();
LegacyAddress testnetAddress = LegacyAddress.fromPubKeyHash(testnetParams, key.getPubKeyHash());
System.out.println("Testnet Address: " + testnetAddress.toString());
// Output: nZLYTKhCpjyuGEi4c9JVU9RVPxZeN4xPgy
import org.bitcoinj.core.AuxPoW;
import org.bitcoinj.core.AltcoinBlock;
// Create AuxPoW for merged mining
AuxPoW auxPoW = new AuxPoW(/* parameters */);
// Validate AuxPoW structure
boolean isValid = auxPoW.checkProofOfWork(/* hash, target */);
// Use with AltcoinBlock
AltcoinBlock block = new AltcoinBlock(params, /* block data */);
import org.libdohj.params.DogecoinMainNetParams;
import org.libdohj.params.DogecoinTestNet3Params;
// Mainnet parameters
DogecoinMainNetParams mainnet = DogecoinMainNetParams.get();
System.out.println("Mainnet Port: " + mainnet.getPort()); // 22556
System.out.println("Address Header: " + mainnet.getAddressHeader()); // 30
System.out.println("P2SH Header: " + mainnet.getP2SHHeader()); // 22
System.out.println("Packet Magic: 0x" + Integer.toHexString(mainnet.getPacketMagic())); // 0xc0c0c0c0
System.out.println("SegWit HRP: " + mainnet.getSegwitAddressHrp()); // doge
// Testnet parameters
DogecoinTestNet3Params testnet = DogecoinTestNet3Params.get();
System.out.println("Testnet Port: " + testnet.getPort()); // 44556
System.out.println("Address Header: " + testnet.getAddressHeader()); // 113
System.out.println("P2SH Header: " + testnet.getP2SHHeader()); // 196
System.out.println("Packet Magic: 0x" + Integer.toHexString(testnet.getPacketMagic())); // 0xfcc1b7dc
System.out.println("SegWit HRP: " + testnet.getSegwitAddressHrp()); // tdge
# Clone the repository
git clone https://github.com/qlpqlp/libdohj.git
cd libdohj
# Build the project
./gradlew clean build
# Generate documentation
./gradlew javadoc
# Run tests
./gradlew test
- IntelliJ IDEA:
File | New | Project from Existing Sources
β Selectbuild.gradle
- Eclipse: Import as Gradle project
- VS Code: Open folder and install Java extension pack
Run the comprehensive test suite:
# Run all tests
./gradlew test
# Run specific tests
./gradlew test --tests "*DogecoinAddressTest*"
./gradlew test --tests "*DogecoinPeerConnectionTest*"
./gradlew test --tests "*AuxPoWTest*"
- Network Parameters:
org.libdohj.params.DogecoinMainNetParams
,org.libdohj.params.DogecoinTestNet3Params
- Address Generation:
org.bitcoinj.base.LegacyAddress
- Peer Discovery:
org.bitcoinj.net.discovery.DnsDiscovery
- AuxPoW:
org.bitcoinj.core.AuxPoW
- Altcoin Blocks:
org.bitcoinj.core.AltcoinBlock
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Built on top of bitcoinj by Mike Hearn
- Inspired by the Dogecoin community
- Special thanks to all contributors
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Dogecoin Community: r/dogecoin
Much wow! Such library! Very Dogecoin! ππ«