Skip to main content

Bitcoin utility functions

Project description

This is a bitcoin library that provides tools/utilities to interact with the Bitcoin network. One of the primary goals of the library is to explain the low-level details of Bitcoin. The code is easy to read and properly documented explaining in detail all the thorny aspects of the implementation. It is a low-level library which assumes some high-level understanding of how Bitcoin works. In the future this might change.

This is a very early version of the library (v0.1.0) and currently, it only supports private/public keys, addresses and creation of P2PKH and P2SH transactions (with all SIGHASH types). More functionality will be added continuously and the documentation will be improved as the work progresses.

The API documentation can be build with Sphinx but is also available as a PDF for convenience. One can currently use the library for experimenting and learning the inner workings of Bitcoin. It is not meant for production yet and parts of the API might be updated with new versions.

Installation

$ pip install bitcoin-utils

Examples

Keys and Addresses

https://github.com/karask/python-bitcoin-utils/blob/master/examples/keys_addresses.py - creates a private key which we use to derive a public key and in turn an address. We also use the private key to sign a message and then verify it using the public key.

Create P2PKH Transaction

https://github.com/karask/python-bitcoin-utils/blob/master/examples/p2pkh_transaction.py - creates a simple transaction with one input and two outputs.

Create P2PKH Transaction with different SIGHASHes

https://github.com/karask/python-bitcoin-utils/blob/master/examples/multi_input_sighash_transaction.py - creates a 2-input 2-output transaction with different signature types.

Create P2SH Address

https://github.com/karask/python-bitcoin-utils/blob/master/examples/init_p2sh_transaction.py - creates a P2SH address that corresponds to a P2PK redeem script and sends some funds to it.

Create (spent) a P2SH Transaction

https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2sh_transaction.py - creates a transaction that spends a P2SH output.

Please explore the code base or the API documentation (BitcoinUtilities.pdf) for supported functionality and other options.

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

bitcoin-utils-0.1.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitcoin_utils-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file bitcoin-utils-0.1.0.tar.gz.

File metadata

  • Download URL: bitcoin-utils-0.1.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for bitcoin-utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd5d8a17e0deb77e24a4cc47b7b2045e9728f6948550078c451fb29dc22b7367
MD5 9331c1187abcd31ce8f31f0a3f4c2844
BLAKE2b-256 da92503bf459f66574171c69c4eabd33eab6c4484f7d6043d6d9a31fa4e53875

See more details on using hashes here.

File details

Details for the file bitcoin_utils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitcoin_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.5.2

File hashes

Hashes for bitcoin_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e16f1621e09333b5268be0eabbab0608d308547398dbfec844bba6f71536db1f
MD5 40a216f59916715f7eae14062074d44e
BLAKE2b-256 0a1af2b17960f721f2b37e16feb4f6c3de0e687f838e68cbdb88aab7891dcdf3

See more details on using hashes here.

Supported by

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