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 be educational. The code is easy to read and properly documented explaining in detail all the thorny aspects of the implementation.

Currently, only a module that provides access to private/public keys and addresses is available.

Installation

$ pip install python-bitcoin-utils

Example usage

>>> from bitcoinutils.keys import PrivateKey, PublicKey
>>> from bitcoinutils.setup import setup, get_network
>>> setup('mainnet')
'mainnet'
>>> p = PrivateKey()
>>> p.to_wif()
'KzT6YYySK8Ex2gd9FMzCgh6mzvjZTnVxqCj1hthPPbbCcssetKES'
>>> pubkey = p.get_public_key()
>>> pubkey.to_hex()
'027bf63dee798c197fad5ca05c45904a7c055e035c5f7c6e7aac8d615722f095c5'
>>> pubkey.to_hex(False)
'047bf63dee798c197fad5ca05c45904a7c055e035c5f7c6e7aac8d615722f095c5904ec20ead4e1992f76f6acf1f1e422708a81550fa5fd698b6cad981a3fcc34a'
>>> a = pubkey.get_address()
>>> a.to_hash160()
'efb37b3bc9c9510242be7f8230c0dec1df6cd220'
>>> a.to_address()
'1NrRWS5m4yySU5RdZxnu85tNEcsFaGfVZc'
>>> s = p.sign_message('test')
>>> s
'H3YyRNVNwyiuM9gk2P1fyR8OghhHoK4EKc1iXywNwdgQeYujAiOwhHHKBjtuAa22TGza1sNq3NXX+kZ1/41zAso='
>>> PublicKey.verify_message(a.to_address(), s, 'test')
True

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.0.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

bitcoin_utils-0.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitcoin-utils-0.0.1.tar.gz
  • Upload date:
  • Size: 8.1 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.0.1.tar.gz
Algorithm Hash digest
SHA256 4c78d1e368f9b35424a362edd91f83a18700ba482ffd5c645cc2d06a2409752c
MD5 4ce8f56b6b800e678f9572f75e6ccb38
BLAKE2b-256 07dcb3b4b6d407ebd22e1627fcd2efaa0c95aef3b5b00efc6daa90b0ac31b182

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitcoin_utils-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8734c5b2bbd2a70bd60c22b4899771adb33d962887a13ca8453fb8539812e1db
MD5 549ec00fe74c5997c019a4afe3eb95f5
BLAKE2b-256 4af2307c6cf0be0e865bb743cfe6a876634c922946369f5b1b9a894602f20861

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