Skip to main content

The Python language bindings for the bitcoindevkit

Project description

bdkpython

The Python language bindings for the bitcoindevkit.

Install the package

pip install bdkpython

Simple examples

Generate a testnet address

import bdkpython as bdk


descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/1h/0h/0/*)"
config = bdk.DatabaseConfig.MEMORY("")

wallet = bdk.OfflineWallet(descriptor, bdk.Network.TESTNET, config)
address = wallet.get_new_address()
print(f"New BIP84 testnet address: {address}")

Sync a wallet using Electrum

import bdkpython as bdk

descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/1h/0h/0/*)"
config = bdk.DatabaseConfig.MEMORY("")
client = bdk.BlockchainConfig.ELECTRUM(
             bdk.ElectrumConfig(
                 "ssl://electrum.blockstream.info:60002",
                 None,
                 5,
                 None,
                 100
             )   
         )

wallet = bdk.OnlineWallet(
             descriptor=descriptor,
             change_descriptor=descriptor,
             network=bdk.Network.TESTNET,
             database_config=config,
             blockchain_config=client
         )

class LogProgress(bdk.BdkProgress):
    def update(self, progress, update):
        pass
        
wallet.sync(progress_update=LogProgress(), max_address_param=20)
balance = wallet.get_balance()
print(f"Wallet balance is: {balance}")

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

bdkpython-0.0.3.tar.gz (2.8 MB view hashes)

Uploaded Source

Built Distribution

bdkpython-0.0.3-py3-none-any.whl (2.8 MB view hashes)

Uploaded Python 3

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