Skip to main content

libdogecoin

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.

Supported platforms

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
Windows x86_64 win_amd64
Windows i686 win32

Installation

pip install libdogecoin

Quick start

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()

API

All functions are prefixed with w_ to distinguish the Python wrappers from the underlying C symbols.


w_context_start()

Start the secp256k1 context. Must be called before any key or address operation.


w_context_stop()

Stop the secp256k1 context.


w_generate_priv_pub_key_pair(chain_code=0, as_bytes=False)

Generate a WIF private key and matching p2pkh address.

Parameters:

  • chain_code — 0 for mainnet, 1 for testnet
  • as_bytes — if True, return raw bytes instead of strings

Returns: (privkey, p2pkh_pubkey)


w_generate_hd_master_pub_key_pair(chain_code=0, as_bytes=False)

Generate an HD master private key and matching p2pkh address.

Parameters:

  • chain_code — 0 for mainnet, 1 for testnet
  • as_bytes — if True, return raw bytes instead of strings

Returns: (master_privkey, master_p2pkh_pubkey)


w_generate_derived_hd_pub_key(wif_privkey_master, as_bytes=False)

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


w_verify_priv_pub_keypair(wif_privkey, p2pkh_pubkey, chain_code=0)

Verify that a WIF private key and p2pkh address form a valid pair.

Parameters:

  • wif_privkey — WIF-encoded private key
  • p2pkh_pubkey — p2pkh address derived from wif_privkey
  • chain_code — 0 for mainnet, 1 for testnet

Returns: True if valid, False otherwise


w_verify_master_priv_pub_keypair(wif_privkey_master, p2pkh_pubkey_master, chain_code=0)

Verify that an HD master key pair is valid and consistent.

Parameters:

  • wif_privkey_master — WIF-encoded HD master private key
  • p2pkh_pubkey_master — p2pkh address derived from the master key
  • chain_code — 0 for mainnet, 1 for testnet

Returns: True if valid, False otherwise


w_verify_p2pkh_address(p2pkh_pubkey)

Validate that a string is a well-formed Dogecoin p2pkh address.

Parameters:

  • p2pkh_pubkey — p2pkh address string

Returns: True if valid, False otherwise


w_start_transaction()

Create a new empty working transaction.

Returns: tx_index — integer index of the new transaction


w_add_utxo(tx_index, hex_utxo_txid, vout)

Add a UTXO input to a working transaction.

Parameters:

  • tx_index — index of the working transaction
  • hex_utxo_txid — transaction id of the UTXO to spend
  • vout — output index within that transaction

Returns: 1 on success, 0 on failure


w_add_output(tx_index, destination_address, amount)

Add an output to a working transaction.

Parameters:

  • tx_index — index of the working transaction
  • destination_address — recipient p2pkh address
  • amount — 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 transaction
  • destination_address — primary recipient address
  • subtracted_fee — fee to deduct (string or number)
  • out_dogeamount_for_verification — total amount being sent including fee
  • changeaddress — sender's address to receive change

Returns: raw hex string of the transaction, or 0 on failure


w_get_raw_transaction(tx_index)

Return the serialised hex of a working transaction.

Parameters:

  • tx_index — index of the working transaction

Returns: hex string, or 0 if not found


w_clear_transaction(tx_index)

Discard a working transaction.

Parameters:

  • tx_index — index of the working transaction

w_sign_raw_transaction(tx_index, incoming_raw_tx, script_hex, sig_hash_type, privkey)

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 transaction
  • script_hex — scriptPubKey hex of the input being signed
  • sig_hash_type — signature hash type (typically 1)
  • privkey — WIF-encoded signing key

Returns: hex string of the (partially) signed transaction, or 0 on failure


w_sign_transaction(tx_index, script_pubkey, privkey)

Sign all inputs of a working transaction.

Parameters:

  • tx_index — index of the working transaction
  • script_pubkey — scriptPubKey hex associated with the inputs
  • privkey — WIF-encoded signing key

Returns: 1 if all inputs were signed, 0 otherwise


w_store_raw_transaction(incoming_raw_tx)

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


w_remove_all()

Clear all working transactions from the session table.


w_get_derived_hd_address(masterkey, account, ischange, addressindex, outprivkey=False)

Derive a HD extended key at a given account/change/index path.

Parameters:

  • masterkey — HD master private key (WIF-encoded)
  • account — BIP44 account number
  • ischange — 0 for external chain, 1 for internal/change
  • addressindex — address index
  • outprivkey — 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


w_get_derived_hd_address_by_path(masterkey, derived_path, outprivkey=False)

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


w_generate_random_english_mnemonic(size)

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


w_generate_english_mnemonic(entropy, size)

Generate a BIP39 English mnemonic from caller-supplied hex entropy.

Parameters:

  • entropy — hex-encoded entropy string
  • size — entropy bit length as a string (same values as above)

Returns: mnemonic phrase string, or None on failure


w_dogecoin_seed_from_mnemonic(mnemonic, passphrase="")

Derive a 64-byte BIP32 master seed from a BIP39 mnemonic.

Parameters:

  • mnemonic — BIP39 mnemonic phrase
  • passphrase — 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 number
  • index — address index
  • change_level — "0" for external (receiving), "1" for internal (change)
  • mnemonic — BIP39 mnemonic phrase
  • passphrase — optional BIP39 passphrase
  • chain_code — 0 for mainnet, 1 for testnet

Returns: p2pkh address string, or None on failure


w_sign_message(privkey, message)

Sign an arbitrary message with a WIF private key.

Parameters:

  • privkey — WIF-encoded private key
  • message — message string to sign

Returns: base64-encoded signature string, or None on failure


w_verify_message(signature, message, address)

Verify a signed message against a p2pkh address.

Parameters:

  • signature — base64-encoded signature (from w_sign_message)
  • message — the original message string
  • address — the p2pkh address corresponding to the signing key

Returns: True if valid, False otherwise


w_qrgen_p2pkh_to_qr_string(p2pkh)

Return a text-art QR code string for a p2pkh address.

Returns: multi-line string, or None on failure


w_qrgen_p2pkh_consoleprint_to_qr(p2pkh)

Print a QR code for a p2pkh address to stdout.


w_qrgen_string_to_qr_pngfile(filename, data, size_multiplier=4)

Write a QR code as a PNG file.

Returns: 1 on success, 0 on failure


w_qrgen_string_to_qr_jpgfile(filename, data, size_multiplier=4)

Write a QR code as a JPEG file.

Returns: 1 on success, 0 on failure


available()

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', ...]

Building from source

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 -w

fetch.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.

Metadata

Release files for libdogecoin 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libdogecoin 0.1.2
File Size Uploaded
libdogecoin-0.1.2.tar.gz 20.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for libdogecoin 0.1.2
File
libdogecoin-0.1.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
libdogecoin-0.1.2-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARMv7l Details
libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
libdogecoin-0.1.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-32, Linux glibc 2.12+ x86-32 Details
libdogecoin-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details

Total release size: 10.4 MB

Release files / libdogecoin-0.1.2.tar.gz

Download URL libdogecoin-0.1.2.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
729c41e9f683054f355f3795fc19c11c2a5a4b4ae503bc1516cc83279cca9582
BLAKE2b-256 checksum
How to use checksums
90c3fc8ad78411d760056fbe8231bd8492ea2d83aa131e264467c16c3417f68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-win_amd64.whl

Download URL libdogecoin-0.1.2-cp310-cp310-win_amd64.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
4e2f38fda89f70e008394e801ec3b4001cf02f1c5d938a85db6fc565dd30ad2a
BLAKE2b-256 checksum
How to use checksums
802f04fe2f03b044379294922ef3b9b300f2f64115d062944e38ba289cdfd636
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-win32.whl

Download URL libdogecoin-0.1.2-cp310-cp310-win32.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
8a4b6ece49d06e9845d1a1ec04f68cc0c676c46720de129481316a5a77803881
BLAKE2b-256 checksum
How to use checksums
be10991635aeab408f38950027dab64a55d6dc19a968d8f7c51bafa01fe736a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0062a9b15423faa0bbd738d798ab204e11766e2626ef6b9efbc214e41c080ccb
BLAKE2b-256 checksum
How to use checksums
41b7a359e061c070b89c0eb8779035395abbbeaa1a7ebac43ee230d8473eb740
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ ARMv7l
SHA-256 checksum
How to use checksums
ac6ca86268782a71529cd32e7da6fd0d291b66b7cd53a5f998dd830637235d51
BLAKE2b-256 checksum
How to use checksums
68a92376c9e825a69b445ce6d29ddff537d6512db56d8e2e8f7a3b34ad4ca138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL libdogecoin-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
c7cb79afbe6c72e5775c07f77fbfc2631b348a7527ea085140807529b35678bd
BLAKE2b-256 checksum
How to use checksums
f03fbf353e888b40de0b2fd479462bf919d45890e9f07eb28561b2d86c47d9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl

Download URL libdogecoin-0.1.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.12+ x86-32 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
c42d98c1e644ca1a55967375e87eb0b025533eda088405ef50335124f1e59b2e
BLAKE2b-256 checksum
How to use checksums
f1fc2755f44a764ff0633d99f396139ec8e74a20b167362c13c59db3f652068f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / libdogecoin-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl

Download URL libdogecoin-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl
Size 1.4 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
628f43cb5ab2e78767e7db6f56bc216c0b988037e3dcaca8231c38b31d0aae80
BLAKE2b-256 checksum
How to use checksums
78bc0eb9165a645ee9c3c43c86a763ee0893f4115fb28ca6917c98254017b487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

0.1.4

9 release files

0.1.3

9 release files

This release

0.1.2 This release

8 release files

0.1.1

8 release files

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page