Skip to main content

Bitcoin cryptocurrency Library writen in Python.

Allows you to create a fully functional Bitcoin wallet with a single line of code. Use this library to create and manage transactions, addresses/keys, wallets, mnemonic password phrases and blocks with simple and straightforward Python code.

You can use this library at a high level and create and manage wallets from the command line or at a low level and create your own custom made transactions, scripts, keys or wallets.

The BitcoinLib connects to various service providers automatically to update wallets, transaction and blockchain information. You can also connect to a local Bitcoin or Bcoin node.

Unittests PyPi RTD Coveralls

Install

Install required packages on Ubuntu or related Linux systems:

$ sudo apt install build-essential python3-dev libgmp3-dev

Then install using pip

$ pip install bitcoinlib

Check out the more detailed installation instructions to read how to install on other systems or for troubleshooting.

If you are using docker you can check some Dockerfiles to create images in the docker directory.

Documentation

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

Example

The bitcoin library contains a wallet implementation using SQLAlchemy and SQLite3 to import, create and manage keys in a Hierarchical Deterministic way.

Example: Create wallet and generate new address (key) to receive bitcoins

>>> from bitcoinlib.wallets import Wallet
>>> w = Wallet.create('Wallet1')
>>> w.get_key().address
'bc1qk25wwkvz3am9smmm3372xct5s7cwf0hmnq8szj'

Now send a small transaction to your wallet and use the scan() method to update transactions and UTXO’s

>>> w.scan()
>>> w.info()  # Shows wallet information, keys, transactions and UTXO's

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

>>> t = w.send_to('bc1qemtr8ywkzg483g8m34ukz2l4pl3730776vzq54', '0.001 BTC', offline=False)
'b7feea5e7c79d4f6f343b5ca28fa2a1fcacfe9a2b7f44f3d2fd8d6c2d82c4078'
>>> t.info  # Shows transaction information and send results

More examples

You can find many more examples in the documentation for instance about the Wallet.create() method.

There are many working examples on how to create wallets, specific transactions, encrypted databases, parse the blockchain, connect to specific service providers in the examples directory in the source code of this library.

Some more specific examples can be found on the Coineva website.

Contact

If you have any questions, encounter a problem or want to share an idea, please use Github Discussions

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)

  • Structure for Deterministic P2SH Multisignature Wallets (BIP0045)

  • Bech32/base32 address format for native v0-16 witness outputs (BIP0173)

  • Native and P2SH nested Segregated Witness transactions (BIP0141 and BIP0143)

  • Bech32m format for v1+ witness addresses (BIP0350)

  • and many more…

Future / Roadmap

  • Fully support timelocks

  • Support Taproot and Schnorr signatures

  • Support advanced scripts

  • Support for Trezor wallet or other hardware wallets

  • Allow to scan full blockchain

  • Integrate simple SPV client

Disclaimer

This library is still in development, please use at your own risk and test sufficiently before using it in a production environment.

Release files for bitcoinlib 0.7.0

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.7.0
File Size Uploaded
bitcoinlib-0.7.0.tar.gz 4.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for bitcoinlib 0.7.0
File Interpreter ABI Platform
bitcoinlib-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 MB

Release files / bitcoinlib-0.7.0.tar.gz

Download URL bitcoinlib-0.7.0.tar.gz
Size 4.2 MB
Tags Source
SHA-256 checksum
How to use checksums
a2b0092223a31e54b46efe6fab5128484921632d7d24aea0f00d1653485ff68e
BLAKE2b-256 checksum
How to use checksums
9b7732764418700630cfd6d599e088e442b2d0db866709b2cc0c0dbbacb7dd26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release files / bitcoinlib-0.7.0-py3-none-any.whl

Download URL bitcoinlib-0.7.0-py3-none-any.whl
Size 4.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ec826633018bd080f526b98d80494da1beeb42cc87faf64c0041d86a054afc94
BLAKE2b-256 checksum
How to use checksums
48eab906ee64f0b17b327f1586b814c267e8f053acfaacb06fbeb9aaedd5ca0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

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

This release

0.7.0 This release

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

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