Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Python Bitcoin Library

Bitcoin and other Crypto currencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.

https://travis-ci.org/1200wd/bitcoinlib.svg?branch=master https://img.shields.io/pypi/v/bitcoinlib.svg https://readthedocs.org/projects/bitcoinlib/badge/?version=latest

Documentation

Read the full documentation at: http://bitcoinlib.readthedocs.io/

Disclaimer

This library is still in development, please use at your own risk and test sufficiently before using it in a production environment. Support for Dash is just for read only wallet, not for creating or sending transactions.

Features

Wallet

The bitcoin library contains a wallet implementation using sqlalchemy and sqllite3 to import, create and manage keys in a Hierarchical Deterministic Way.

Example: Create wallet and generate new key to receive bitcoins

>>> from bitcoinlib.wallets import HDWallet
>>> w = HDWallet.create('Wallet1')
>>> w
<HDWallet (id=1, name=Wallet1, network=bitcoin)>
>>> key1 = w.new_key()
>>> key1
<HDWalletKey (name=Key 0, wif=xprvA4B..etc..6HZKGW7Kozc, path=m/44'/0'/0'/0/0)>
>>> key1.address
'1Fo7STj6LdRhUuD1AiEsHpH65pXzraGJ9j'

When your wallet received a payment and has unspent transaction outputs, you can send bitcoins easily. If successful a transaction ID is returned

>>> w.send_to('12ooWd8Xag7hsgP9PBPnmyGe36VeUrpMSH', 100000)
'b7feea5e7c79d4f6f343b5ca28fa2a1fcacfe9a2b7f44f3d2fd8d6c2d82c4078'

Mnemonic Keys

Allows you to use easy to remember passphrases consisting of a number of words to store private keys (BIP0039). You can password protect this passphrase (BIP0038), and use the HD Wallet structure to generate a almost infinite number of new private keys and bitcoin addresses (BIP0043 and BIP0044).

Example: Generate a list of words passphrase and derive a private key seed

>>> from bitcoinlib.mnemonic import Mnemonic
>>> words = Mnemonic().generate()
>>> words
protect dumb smart toddler journey spawn same dry season ecology scissors more
>>> Mnemonic().to_seed(words)
..very long and ugly byte string which can be used as private key

Service providers

Communicates with pools of bitcoin service providers to retreive transaction, address, blockchain information. To push a transaction to the network. To determine optimal service fee for a transaction. Or to update your wallet’s balance.

Example: Get estimated transaction fee in sathosis per Kb for confirmation within 5 blocks

>>> from bitcoinlib.services.services import Service
>>> Service().estimatefee(5)
138964

Implements the following Bitcoin Improvement Proposals

  • Hierarchical Deterministic Wallets (BIP0032)

  • Passphrase-protected private key (BIP0038)

  • Mnemonic code for generating deterministic keys (BIP0039)

  • Purpose Field for Deterministic Wallets (BIP0043)

  • Multi-Account Hierarchy for Deterministic Wallets (BIP0044)

Installation

Install with pip

pip install bitcoinlib

Package dependencies

Required Python Packages, are automatically installed upon installing bitcoinlib:

  • ecdsa

  • pbkdf2

  • pycrypto

  • scrypt

  • sqlalchemy

  • requests

  • enum34 (for older python installations)

Python development packages

sudo apt install python-dev python3-dev

To install OpenSSL development package on Debian, Ubuntu or their derivatives

sudo apt install libssl-dev

To install OpenSSL development package on Fedora, CentOS or RHEL

sudo yum install openssl-devel

References

Release files for bitcoinlib 0.3.33a0

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

Source distribution (sdist)

Source distribution for bitcoinlib 0.3.33a0
File Size Uploaded
bitcoinlib-0.3.33a0.tar.gz 282.3 kB Details

Release files / bitcoinlib-0.3.33a0.tar.gz

Download URL bitcoinlib-0.3.33a0.tar.gz
Size 282.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fb339e96ef7243d6aee9c82562bfcc5ac78d67e20a421bf0ffe694930d8070f9
BLAKE2b-256 checksum
How to use checksums
7ce76be564a34162d41dcae89640981a8da82d0d5bbf284253777ef4de1cbb3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.14

2 release files

0.6.13

2 release files

0.6.12

2 release files

0.6.10

2 release files

0.6.9

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

3 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.19

1 release file

0.4.17

1 release file

0.4.16

1 release file

0.4.15

1 release file

0.4.14

2 release files

0.4.13

2 release files

0.4.12

2 release files

0.4.11

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.37

1 release file

0.3.36

1 release file

0.3.34

1 release file

This release

0.3.33a0 This release

1 release file

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