Skip to main content

An easy-to-use and fully featured bitcoin library written in pure python (no dependencies).

Project description

buidl Bitcoin Library

Python

buidl is a python3 bitcoin library with 0 dependencies. It is easy-to-read, has extensive test coverage, simple to install on airgapped computers (just copy over this directory).

buidl has extensive feature support for the bitcoin blockchain:

  • Trust-minimized - easy-to-read cryptography implemented in straightforward/way with no third-party dependencies
  • Performant - optional secp256k1 library bindings offers a ~100x speedup, see performance section below
  • Wallet tools for various script types (p2pkh, p2sh, p2sh-wrapped-p2wsh, p2wsh and p2tr (coming soon) ), compressed/uncompressed pubkeys, address encodings, HD support (BIP32, BIP39, BIP44, seedpicker, etc), PSBT generation/decoding/validation, etc
  • Extensive multisig support/tooling for output descriptors, receive address validation, change address detection, fee verification, blinding xpubs, PSBTs, BCUR v0 (v1 coming soon), airgap signing, etc
  • SPV proofs and compact block filters (Neutrino) - build powerful trust-minimized apps without scanning the whole blockchain
  • P2P gossip network - connect directly to the bitcoin network
  • Footgun protection - from elegantly structured OOP classes to RFC6979 deterministic k-values, buidl is designed to be usable for non-cryptographers
  • 0 altcoins - for maximum readability/focus. The only other supported coins are bitcoin's testnet and signet, which intentionally have no value.

This repository comes with zero guarantees, use at your own risk.

Installation

Online

$ pip3 install buidl --upgrade

Offline

Download this repo and then run:

$ python3 setup.py install

(alternatively, because buidl has no dependencies you can just cd into this root directory and call buidl without installation)

Multiwallet

multiwallet is a stateless CLI multisig PSBT wallet. Since buidl has no dependencies, you can run multiwallet by just cding to the root directory of this project:

$ python3 multiwallet.py
Welcome to multiwallet...

If you have installed buidl, you can run multiwallet.py from any directory:

$ multiwallet.py
Welcome to multiwallet...

For more information on installing multiwallet, see multiwallet.md or check out this demo.

singlesweep.py works the same way for sweeping out of paper wallets, but is intentionally undocumented.

Tests

Run tests with pytest:

$ git clone https://github.com/buidl-bitcoin/buidl-python.git && cd buidl-python
$ pytest -v

(these will be 1-2 orders of magnitue faster with libsec bindings, see performance section below)

Run black:

$ black . --diff --check

Run flake8:

$ flake8 .

Performance

You can speed this library up ~100x by using C-bindings to bitcoin core's libsecp256k1 library.

libsecp256k1 Dependency Installation

Easy (MacOS only)

Use brew to install libsecp256k1:

$ brew tap buidl-bitcoin/homebrew-libsecp256k1
$ brew install pkg-config libffi libsecp256k1

Hard (Linux/Mac)

Compile libsecp256k1 from scratch with experimental modules enabled to make Schnorr signatures work:

$ git clone https://github.com/bitcoin-core/secp256k1
$ cd secp256k1
$ ./autogen.sh
$ ./configure --enable-module-extrakeys --enable-module-schnorrsig --enable-experimental
$ make
$ sudo make install

buidl Installation

$ git clone git@github.com:buidl-bitcoin/buidl-python.git && cd buidl-python && python3 -m pip install -r requirements-libsec.txt && python3 -m pip install --editable . && cd buidl && python3 libsec_build.py && cd .. && python3 -c "from buidl import *; print('success') if is_libsec_enabled() else print('LIBSEC INSTALL FAIL')"

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

buidl-0.2.34.tar.gz (232.1 kB view details)

Uploaded Source

Built Distributions

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

buidl-0.2.34-py3.9.egg (524.6 kB view details)

Uploaded Egg

buidl-0.2.34-py3-none-any.whl (245.2 kB view details)

Uploaded Python 3

File details

Details for the file buidl-0.2.34.tar.gz.

File metadata

  • Download URL: buidl-0.2.34.tar.gz
  • Upload date:
  • Size: 232.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for buidl-0.2.34.tar.gz
Algorithm Hash digest
SHA256 2eaec6c9491cdbeaf76ca361c9bbc2a907a36441041f31f666a5a2fbd4ea33cc
MD5 a199cd698ec9f4d65758d3c00ca63b3b
BLAKE2b-256 9bd54a275d1bfe7ab0786b26e1ae60d6b3995010d5c58ab206e2f3e23db99b73

See more details on using hashes here.

File details

Details for the file buidl-0.2.34-py3.9.egg.

File metadata

  • Download URL: buidl-0.2.34-py3.9.egg
  • Upload date:
  • Size: 524.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for buidl-0.2.34-py3.9.egg
Algorithm Hash digest
SHA256 02457af79ee0fc06a4189bbda89821ac48f40529520c42960569df4c730b2098
MD5 2b648bddb3eb2536a736cb3276384f8a
BLAKE2b-256 1b5cc10bc6d30f597843f905042f9a07180ddaefd16487b318e83792047c41e9

See more details on using hashes here.

File details

Details for the file buidl-0.2.34-py3-none-any.whl.

File metadata

  • Download URL: buidl-0.2.34-py3-none-any.whl
  • Upload date:
  • Size: 245.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for buidl-0.2.34-py3-none-any.whl
Algorithm Hash digest
SHA256 a8f70a232b8367a752bd3ea1f5fe2b60de062ebc6c998fac6304081895acde74
MD5 5a8d8475ad9d5962aba5ce57af7a836e
BLAKE2b-256 f709fa8575ed3a01286b34ff1da520a4b0b2e37b23db3bcbcb2ad28a986cea4a

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