Skip to main content

Python interface for the libdogecoin C library

Project description

libdogecoin

A simple Python interface to interact with the libdogecoin C library written by the Dogecoin Foundation. This module contains wrappers for all user-facing address and transaction functions. For more information on usage of these wrappers, please refer to the bindings doc in the Dogecoin Foundation libdogecoin repo.

Installation

To begin using the libdogecoin module, simply install libdogecoin using pip3:

pip3 install libdogecoin

Libdogecoin is now ready to be imported within your python script!

API

All functions are prefixed with the letter "w" in order to differentiate between the Python wrapper functions and the redeclarations of the original C functions as required by Cython.


w_context_start()

Start the secp256k1 context necessary for key pair generation. Must be started before calling any functions dealing with private or public keys.


w_context_stop()

Stop the current instance of the secp256k1 context. It is advised to wait until the session is completely over before stopping the context.


w_generate_priv_pub_key_pair(chain_code=0)

Generate a valid private key paired with the corresponding p2pkh address.

Parameters:

  • chain_code -- 0 for mainnet pair, 1 for testnet pair

Returns:

  • privkey -- the generated private key of the pair as byte string
  • p2pkh_pubkey -- the generated public key of the pair as byte string

w_generate_hd_master_pub_key_pair(chain_code=0)

Generate a master private and public key pair for use in hierarchical deterministic wallets. Public key can be used for child key derivation using w_generate_derived_hd_pub_key().

Parameters:

  • chain_code -- 0 for mainnet pair, 1 for testnet pair

Returns:

  • master_privkey -- the generated HD master private key of the pair as a byte string
  • master_p2pkh_pubkey -- the generated HD master public key of the pair as a byte string

w_generate_derived_hd_pub_key(wif_privkey_master)

Given a HD master public key, derive a child key from it.

Parameters:

  • wif_privkey_master -- HD master private key as wif-encoded string

Returns:

  • child_p2pkh_pubkey -- the resulting child public key derived from the provided HD master private key

w_verify_priv_pub_keypair(wif_privkey, p2pkh_pubkey, chain_code=0)

Given a key private/public key pair, verify that the keys are valid and are associated with each other.

Parameters:

  • wif_privkey -- string containing wif-encoded private key
  • p2pkh_pubkey -- string containing address derived from wif_privkey
  • chain_code -- 0 for mainnet, 1 for testnet

Returns:

  • res -- 1 if the key pair is valid, 0 otherwise

w_verify_master_priv_pub_keypair(wif_privkey_master, p2pkh_pubkey_master, chain_code=0)

Given a keypair from generate_hd_master_pub_key_pair, verify that the keys are valid and are associated with each other.

Parameters:

  • wif_privkey_master -- string containing wif-encoded private master key
  • p2pkh_pubkey_master -- string containing address derived from wif_privkey
  • chain_code -- 0 for mainnet, 1 for testnet

Returns:

  • res -- 1 if the master key pair is valid, 0 otherwise

w_verify_p2pkh_address(p2pkh_pubkey)

Given a p2pkh address, confirm address is in correct Dogecoin format.

Parameters:

  • p2pkh_pubkey -- string containing basic p2pkh address

Returns:

  • res -- 1 if the address is valid, 0 otherwise.

w_start_transaction()

Create a new, empty dogecoin transaction.

Returns:

  • res -- the index of the newly created transaction in the session hash table

w_add_utxo(tx_index, hex_utxo_txid, vout)

Given the index of a working transaction, add another input to it.

Parameters:

  • tx_index -- the index of the working transaction to update
  • hex_utxo_txid -- the transaction id of the utxo to be spent
  • vout -- the number of outputs associated with the specified utxo

Returns:

  • res -- 1 if the input was added successfully, 0 otherwise.

w_add_output(tx_index, destination_address, amount)

Given the index of a working transaction, add another output to it.

Parameters:

  • tx_index -- the index of the working transaction to update
  • destination_address -- the address of the output being added
  • amount -- the amount of dogecoin to send to the specified address

Returns:

  • res -- 1 if the input was added successfully, 0 otherwise.

w_finalize_transaction(tx_index, destination_address, subtracted_fee, out_dogeamount_for_verification, changeaddress)

Given the index of a working transaction, prepares it for signing by specifying the recipient and fee to subtract, directing extra change back to the sender.

Parameters:

  • tx_index -- the index of the working transaction
  • destination address -- the address to send coins to
  • subtracted_fee -- the amount of dogecoin to assign as a fee
  • out_dogeamount_for_verification -- the total amount of dogecoin being sent (fee included)
  • changeaddress -- the address of the sender to receive their change

Returns:

  • res -- the hex string representation of the transaction if successfully finalized, 0 otherwise

w_get_raw_transaction(tx_index)

Given the index of a working transaction, returns the serialized object in hex format.

Parameters:

  • tx_index -- the index of the working transaction

Returns:

  • res -- the hex string representation of the transaction at index tx_index if it exists, 0 otherwise

w_clear_transaction(tx_index)

Discard a working transaction.

Parameters:

  • tx_index -- the index of the working transaction

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

Sign a finalized raw transaction using the specified private key.

Parameters:

  • tx_index -- the index of the working transaction to sign
  • incoming_raw_tx -- the serialized string of the transaction to sign
  • script_hex -- the hex of the script to be signed
  • sig_hash_type -- the type of signature hash to be used
  • amount -- the amount of dogecoin in the transaction being signed
  • privkey -- the private key to sign with

Returns:

  • res -- the hex string representation of the signed transaction if successfully signed, 0 otherwise.

w_sign_transaction(tx_index, amounts, script_pubkey, privkey)

Sign all the inputs of a working transaction using the specified private key and public key script.

Parameters:

  • tx_index -- the index of the working transaction to sign
  • amounts -- an array of the input amounts in the specified transaction
  • script_pubkey -- the pubkey script associated with the private key
  • privkey -- the private key used to sign the specified transaction

Returns:

  • res -- the hex string representation of the signed transaction if successfully signed, 0 otherwise.

w_store_raw_transaction(incoming_raw_tx)

Stores a raw transaction at the next available index in the hash table.

Parameters:

  • incoming_raw_tx -- the serialized string of the transaction to store.

Returns:

  • res -- 1 if the transaction was stored successfully, 0 otherwise.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libdogecoin-0.1.0.post1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distributions

libdogecoin-0.1.0.post1-cp311-cp311-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

libdogecoin-0.1.0.post1-cp311-cp311-win32.whl (1.2 MB view details)

Uploaded CPython 3.11 Windows x86

libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

libdogecoin-0.1.0.post1-cp310-cp310-macosx_10_15_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

File details

Details for the file libdogecoin-0.1.0.post1.tar.gz.

File metadata

  • Download URL: libdogecoin-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for libdogecoin-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 235188362456d0266a813f0fec0c4c66819fe44259627833c4d30d10d5c5c3eb
MD5 9fc4eb29dc404983c27e5b5c672bb096
BLAKE2b-256 df28085339f60f3e519a4880477c0cad842273682f7ce6ad7ea30c10f026b5f5

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9230276431193f9440349e32fd319f0c4ac5fce09ae32b7571e29422cd810207
MD5 fdf7170c5ff9a035fd5f6bfc68c4041a
BLAKE2b-256 1eec86978cdd16ab5a82091511da55038a9c609c1ff5615b8f3b43348edcdb2f

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 1c2b58e7437d9d42c02a3088212016eea87e059a56a27ca45a533bf3783fbaff
MD5 53ebea69b4415c5f0b0aa587a2419c07
BLAKE2b-256 f91a732cd18ca57a2fb6c91161311198ebef71e7c7ea7934a125808f16be8cdf

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fade439559d6abc2cb7aa114072e8b8c615e82d070216a8a6510d0337f6f1f5
MD5 1415075b79ce74f276550d6fd82ad3ea
BLAKE2b-256 1ea9d4013a99941e6d488cd953414afe050f820995fc71a83c3be2341c8a086a

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bce183c3e2624175a38a2ad2b458e1222e664d3005b62c2baac9dfc37480677a
MD5 80a4cfec26f899f98d14abdeffe00285
BLAKE2b-256 ce16c3e743b870436aca6b910c014bc6c4f325e8e0824811b3a9a91e377e9b8d

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ef263feded2195e598ed63465ced3d3d75e88097392d519bb682089cefa9c6b2
MD5 835e9dec9c6a8b8f95ff42aaaf69d623
BLAKE2b-256 edf54a9f7d0dbd71e1e3440c5de394e4bb00eac475ddd46f729a62653f38c724

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 05efa36643fcba8fa13a7bc110ddd7732ddb1db920b416400a2d5872ec73f20f
MD5 e82bae500e9a672c61677f355549f01b
BLAKE2b-256 b1beaa447c8ea661b1e4cc14fdb7b93cd18e3d886a53f32022b37cef86fc87ec

See more details on using hashes here.

File details

Details for the file libdogecoin-0.1.0.post1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for libdogecoin-0.1.0.post1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d70594cd77e0492a6c56353d3b8d7b93a69e5c40adfeb10219fd0b0e705f9280
MD5 6561370148e341f5a7bd4f625de595ca
BLAKE2b-256 15d1d6a4c61670c2c54dc0c464de4bfe5f4a294738a77355146598918cb2bfc4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page