Dogecoin
Dogecoin
secp256k1
- legacy P2PKH
- Formats
- 1
- Coin type
- 3'
- Key 1
- DFpN6QqFfU…L9cZLE
Access
- Load
blockchains.dogecoin()() - Import
@agntn/keys/blockchains/dogecoin - Walkkeyspace in the browser
Load it
import { useBlockchain, blockchains } from "@agntn/keys";
const dogeChain = useBlockchain(await blockchains.dogecoin()());
const testnet = useBlockchain(await blockchains.dogecoin({ network: "testnet" })());
Mainnet and testnet only, anything else throws in the constructor. Regtest in Dogecoin Core borrows Bitcoin's testnet bytes, so it's left out.
The address
Dogecoin grew out of Litecoin's code, which grew out of Bitcoin's, and the address never moved far from home. RIPEMD160(SHA256(pubkey)), a version byte in front, base58check. The version bytes come from Dogecoin Core v1.14.9 chainparams.cpp.
| Network | P2PKH | P2SH |
|---|---|---|
| mainnet | 0x1e, starts with D | 0x16, starts with 9 or A |
| testnet | 0x71, starts with n | 0xc4, starts with 2 |
const privateKey = "0000000000000000000000000000000000000000000000000000000000000001";
const publicKey = dogeChain.getKeyPublic(privateKey);
dogeChain.getAddress(publicKey); // DFpN6QqFfUm3gKNaxN6tNcab1FArL9cZLE
testnet.getAddress(publicKey); // nesRpRaAbTDmZHwmzBkLd2AtF7Z9L9z5S2
legacy is the only type it writes. Dogecoin never activated SegWit, so there's no bech32, and the library's p2sh type is P2SH wrapping a P2WPKH program. On a chain without SegWit that script is spendable by anyone who sees it. So "p2sh", "segwit" and the rest throw a RangeError instead of handing you that address.
Validation
dogeChain.validateAddress("DFpN6QqFfUm3gKNaxN6tNcab1FArL9cZLE"); // true
dogeChain.validateAddress("A7HRQk3GFCW2QasvdZxXuYj8kkQK5QrYLs"); // true, P2SH
dogeChain.validateAddress("1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"); // false, Bitcoin's version byte
P2PKH and P2SH under the driver's own version bytes. P2SH passes because multisig wallets really pay to it, the library just never writes one. A testnet address fails on mainnet and the other way round. The vectors in the tests come from the node's own key_tests.cpp and base58_keys_valid.json.
Mnemonics
BIP32 on m/44'/3'/account'/change/index, coin type 3 from SLIP-0044.
const mnemonic =
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
dogeChain.deriveHDWallet(mnemonic, { path: "m/44'/3'/0'/0/0" }).address;
// DBus3bamQjgJULBJtYXpEzDWQRwF5iwxgC, the same address Ledger Live derives
The purpose level doesn't pick a format, there's only one. m/84' still gives you a D address, and an explicit "p2sh" still throws.
WIF
import { decode } from "@agntn/keys/wif";
decode("QP5rQxpaP8HHPEdCEqxTjiHGWRvsyPvzZJeJ9BCxpfT13FN9VesQ", { chain: "dogecoin" });
// { privateKey: '0e01…370a', chain: 'dogecoin', network: 'mainnet', compressed: true }
Version 0x9e on mainnet, so compressed keys start with Q and uncompressed ones with 6. That's the string dumpprivkey gives you. Testnet is 0xf1, not Bitcoin's, so unlike Litecoin and Dash a Dogecoin testnet key doesn't pass as a Bitcoin one.
Signing
Dogecoin Core signs under "\x19Dogecoin Signed Message:\n", then does what Bitcoin does: compact size lengths, double SHA-256, secp256k1. So a Bitcoin signature doesn't verify here, and the other way round. The Dogecoin vectors in bitcoinjs-message match byte for byte once you drop their header byte. { recovered: true } keeps it and gives their base64 whole, the uncompressed one too with compressed: false.
Where it lives
src/blockchains/dogecoin.ts has the version bytes and the preamble. It extends AbstractBitcoinP2PKHBlockchain in src/utils/bitcoin.ts, which Bitcoin SV, Dash and Dogecoin share: base58 P2PKH under one version byte per network, on top of the keys and signed messages of the Bitcoin base.