A Python interface to the libdogecoin C library, maintained by the Dogecoin Foundation. Provides wrappers for all user-facing address and transaction functions via a CFFI extension that links the static library at build time — no shared .so/.dll dependency at runtime.
| Platform | Wheel tag |
|---|---|
| Linux x86_64 | manylinux2014_x86_64 |
| Linux i686 | manylinux2014_i686 |
| Linux aarch64 | manylinux2014_aarch64 |
| Linux armv7l | manylinux2014_armv7l |
| macOS x86_64 | macosx_10_9_x86_64 |
| macOS arm64 | macosx_11_0_arm64 |
| Windows x86_64 | win_amd64 |
| Windows i686 | win32 |
pip install libdogecoin
from libdogecoin import w_context_start, w_context_stop, w_generate_priv_pub_key_pair
w_context_start()
privkey, address = w_generate_priv_pub_key_pair()
print(privkey, address)
w_context_stop()All functions are prefixed with w_ to distinguish the Python wrappers from the underlying C symbols.
Start the secp256k1 context. Must be called before any key or address operation.
Stop the secp256k1 context.
Generate a WIF private key and matching p2pkh address.
Parameters:
chain_code— 0 for mainnet, 1 for testnetas_bytes— if True, return raw bytes instead of strings
Returns: (privkey, p2pkh_pubkey)
Generate an HD master private key and matching p2pkh address.
Parameters:
chain_code— 0 for mainnet, 1 for testnetas_bytes— if True, return raw bytes instead of strings
Returns: (master_privkey, master_p2pkh_pubkey)
Derive a child p2pkh address from an HD master private key.
Parameters:
wif_privkey_master— HD master private key (WIF-encoded string)as_bytes— if True, return raw bytes
Returns: child_p2pkh_pubkey
Verify that a WIF private key and p2pkh address form a valid pair.
Parameters:
wif_privkey— WIF-encoded private keyp2pkh_pubkey— p2pkh address derived fromwif_privkeychain_code— 0 for mainnet, 1 for testnet
Returns: True if valid, False otherwise
Verify that an HD master key pair is valid and consistent.
Parameters:
wif_privkey_master— WIF-encoded HD master private keyp2pkh_pubkey_master— p2pkh address derived from the master keychain_code— 0 for mainnet, 1 for testnet
Returns: True if valid, False otherwise
Validate that a string is a well-formed Dogecoin p2pkh address.
Parameters:
p2pkh_pubkey— p2pkh address string
Returns: True if valid, False otherwise
Create a new empty working transaction.
Returns: tx_index — integer index of the new transaction
Add a UTXO input to a working transaction.
Parameters:
tx_index— index of the working transactionhex_utxo_txid— transaction id of the UTXO to spendvout— output index within that transaction
Returns: 1 on success, 0 on failure
Add an output to a working transaction.
Parameters:
tx_index— index of the working transactiondestination_address— recipient p2pkh addressamount— amount of Dogecoin to send (string or number)
Returns: 1 on success, 0 on failure
w_finalize_transaction(tx_index, destination_address, subtracted_fee, out_dogeamount_for_verification, changeaddress)
Finalise a working transaction, deducting the fee and routing change back to the sender.
Parameters:
tx_index— index of the working transactiondestination_address— primary recipient addresssubtracted_fee— fee to deduct (string or number)out_dogeamount_for_verification— total amount being sent including feechangeaddress— sender's address to receive change
Returns: raw hex string of the transaction, or 0 on failure
Return the serialised hex of a working transaction.
Parameters:
tx_index— index of the working transaction
Returns: hex string, or 0 if not found
Discard a working transaction.
Parameters:
tx_index— index of the working transaction
Sign one input of a raw transaction in place.
Parameters:
tx_index— input index to sign (0-based)incoming_raw_tx— serialised hex of the transactionscript_hex— scriptPubKey hex of the input being signedsig_hash_type— signature hash type (typically 1)privkey— WIF-encoded signing key
Returns: hex string of the (partially) signed transaction, or 0 on failure
Sign all inputs of a working transaction.
Parameters:
tx_index— index of the working transactionscript_pubkey— scriptPubKey hex associated with the inputsprivkey— WIF-encoded signing key
Returns: 1 if all inputs were signed, 0 otherwise
Store a pre-built raw transaction in the session table.
Parameters:
incoming_raw_tx— serialised hex string (max 100 KB)
Returns: index of the stored transaction, or 0 if too large
Clear all working transactions from the session table.
Derive a HD extended key at a given account/change/index path.
Parameters:
masterkey— HD master private key (WIF-encoded)account— BIP44 account numberischange— 0 for external chain, 1 for internal/changeaddressindex— address indexoutprivkey— if True, return the extended private key; otherwise the extended public key
Returns: extended public key (xpub) string, or extended private key (xprv) when outprivkey=True
Derive a HD extended key at an explicit BIP32 derivation path.
Parameters:
masterkey— HD master private key (WIF-encoded)derived_path— BIP32 path string (e.g."m/44'/3'/0'/0/0")outprivkey— if True, return the extended private key; otherwise the extended public key
Returns: extended public key (xpub) or extended private key (xprv) string
Generate a cryptographically random BIP39 English mnemonic phrase.
Parameters:
size— entropy bit length as a string:"128","160","192","224", or"256"
Returns: mnemonic phrase string (12–24 words), or None on failure
Generate a BIP39 English mnemonic from caller-supplied hex entropy.
Parameters:
entropy— hex-encoded entropy stringsize— entropy bit length as a string (same values as above)
Returns: mnemonic phrase string, or None on failure
Derive a 64-byte BIP32 master seed from a BIP39 mnemonic.
Parameters:
mnemonic— BIP39 mnemonic phrasepassphrase— optional BIP39 passphrase (default"")
Returns: bytes of length 64, or None on failure
w_get_derived_hd_address_from_mnemonic(account, index, change_level, mnemonic, passphrase="", chain_code=0)
Derive a spendable p2pkh address directly from a BIP39 mnemonic phrase.
Parameters:
account— BIP44 account numberindex— address indexchange_level—"0"for external (receiving),"1"for internal (change)mnemonic— BIP39 mnemonic phrasepassphrase— optional BIP39 passphrasechain_code— 0 for mainnet, 1 for testnet
Returns: p2pkh address string, or None on failure
Sign an arbitrary message with a WIF private key.
Parameters:
privkey— WIF-encoded private keymessage— message string to sign
Returns: base64-encoded signature string, or None on failure
Verify a signed message against a p2pkh address.
Parameters:
signature— base64-encoded signature (fromw_sign_message)message— the original message stringaddress— the p2pkh address corresponding to the signing key
Returns: True if valid, False otherwise
Return a text-art QR code string for a p2pkh address.
Returns: multi-line string, or None on failure
Print a QR code for a p2pkh address to stdout.
Write a QR code as a PNG file.
Returns: 1 on success, 0 on failure
Write a QR code as a JPEG file.
Returns: 1 on success, 0 on failure
Return the list of libdogecoin C function names present in this wheel's build.
Returns: list[str]
from libdogecoin import available
print(available())
# ['dogecoin_ecc_start', 'dogecoin_ecc_stop', 'generatePrivPubKeypair', ...]Return True if the address has a testnet base58 prefix.
Return True if the address has a mainnet base58 prefix.
Derive a p2pkh address from a compressed public key (hex string).
Returns: p2pkh address string, or None on failure
Derive the compressed public key (hex) from a WIF-encoded private key.
Returns: pubkey hex string, or None on failure
Generate a new private key.
Returns: (wif_privkey, privkey_hex) tuple, or None on failure
Convert a p2pkh address to its pubkey hash hex string (library-allocated).
Returns: pubkey hash hex string, or None on failure
Derive the pubkey hash hex string from a WIF private key (library-allocated).
Returns: pubkey hash hex string, or None on failure
Convert a p2pkh address to its pubkey hash (scripthash) hex string.
Returns: pubkey hash hex string, or None on failure
Convert a pubkey hash hex string back to a p2pkh address.
Returns: p2pkh address string, or None on failure
WIF-encode a raw private key given as a 64-character hex string.
Returns: WIF-encoded private key string
Decode a WIF-encoded private key to its 64-character hex representation.
Returns: privkey hex string, or None on failure
Derive an HD master private key from a 64-byte BIP32 seed.
Parameters:
seed_bytes— 64 bytes (e.g. fromw_dogecoin_seed_from_mnemonic)is_testnet— False for mainnet, True for testnet
Returns: HD master key string (xprv-style), or None on failure
Extract the extended public key (xpub) from an extended private key.
Returns: xpub string, or None on failure
Derive an extended private key from another extended key by BIP32 path.
Returns: derived extended key string, or None on failure
Derive an extended public key from an extended public key by BIP32 path.
Returns: derived extended public key string, or None on failure
Generate a new random HD master private key.
Returns: HD master key string (xprv-style), or None on failure
Derive an extended key from a master key by explicit BIP32 path string.
Returns: derived extended key string, or None on failure
Derive a WIF private key or p2pkh address from an HD master key by path.
Parameters:
masterkey— HD master private keyderived_path— BIP32 derivation path string (e.g."m/44'/3'/0'/0/0")outprivkey— if True return the WIF private key; otherwise return the p2pkh address
Returns: string result (library-allocated), or None on failure
w_derive_bip44_extended_key(masterkey, account, change_level, address_index, path=None, is_testnet=False)
Derive a BIP44 extended private key.
Parameters:
masterkey— HD master private keyaccount— BIP44 account number, orNonechange_level—"0"for external chain,"1"for internal/changeaddress_index— address index, orNonepath— explicit key path override string, orNone
Returns: (extended_key, keypath) tuple, or None on failure
w_derive_bip44_extended_public_key(masterkey, account, change_level, address_index, path=None, is_testnet=False)
Derive a BIP44 extended public key.
Parameters: same as w_derive_bip44_extended_key
Returns: (extended_pubkey, keypath) tuple, or None on failure
Convert a koinu integer (1 DOGE = 100000000 koinu) to a decimal coin string.
Returns: decimal string (e.g. "1.00000000"), or None on failure
Convert a decimal coin string (e.g. "1.5") to koinu integer.
Returns: koinu value as int
Sign a specific input of a working transaction by vout index.
Returns: 1 on success, 0 on failure
Requires a C compiler, autoconf, automake, and libtool (for the source-build fallback).
pip install cffi requests build
python fetch.py --host=x86_64-pc-linux-gnu # populates lib/ and include/
python -m build -wfetch.py probes the libdogecoin GitHub releases for a pre-built binary for the requested host triplet and falls back to an autotools source build if none is available.