2021-12-07 10:25:42 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2022-02-15 16:47:34 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
from setuptools import setup
|
|
|
|
from setuptools_rust import Binding, RustExtension
|
2021-12-07 10:25:42 -05:00
|
|
|
|
2021-12-07 14:56:15 -05:00
|
|
|
LONG_DESCRIPTION = """# bdkpython
|
2022-06-23 15:21:48 -04:00
|
|
|
The Python language bindings for the [Bitcoin Dev Kit](https://github.com/bitcoindevkit).
|
2021-12-07 14:56:15 -05:00
|
|
|
|
|
|
|
## Install the package
|
|
|
|
```shell
|
|
|
|
pip install bdkpython
|
|
|
|
```
|
|
|
|
|
2022-02-16 21:31:39 -05:00
|
|
|
## Simple example
|
2021-12-07 14:56:15 -05:00
|
|
|
```python
|
|
|
|
import bdkpython as bdk
|
|
|
|
|
|
|
|
|
2022-05-11 16:02:49 -04:00
|
|
|
descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/0h/0h/0/*)"
|
|
|
|
db_config = bdk.DatabaseConfig.MEMORY()
|
|
|
|
blockchain_config = bdk.BlockchainConfig.ELECTRUM(
|
|
|
|
bdk.ElectrumConfig(
|
|
|
|
"ssl://electrum.blockstream.info:60002",
|
|
|
|
None,
|
|
|
|
5,
|
|
|
|
None,
|
|
|
|
100
|
|
|
|
)
|
|
|
|
)
|
|
|
|
blockchain = bdk.Blockchain(blockchain_config)
|
2021-12-07 14:56:15 -05:00
|
|
|
|
2022-02-16 21:31:39 -05:00
|
|
|
wallet = bdk.Wallet(
|
2021-12-07 14:56:15 -05:00
|
|
|
descriptor=descriptor,
|
2022-05-11 16:02:49 -04:00
|
|
|
change_descriptor=None,
|
2021-12-07 14:56:15 -05:00
|
|
|
network=bdk.Network.TESTNET,
|
2022-05-11 16:02:49 -04:00
|
|
|
database_config=db_config,
|
2021-12-07 14:56:15 -05:00
|
|
|
)
|
|
|
|
|
2022-02-16 21:31:39 -05:00
|
|
|
# print new receive address
|
2022-06-23 15:21:48 -04:00
|
|
|
address_info = wallet.get_address(bdk.AddressIndex.LAST_UNUSED)
|
|
|
|
address = address_info.address
|
|
|
|
index = address_info.index
|
|
|
|
print(f"New BIP84 testnet address: {address} at index {index}")
|
2022-02-16 21:31:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
# print wallet balance
|
2022-05-11 16:02:49 -04:00
|
|
|
wallet.sync(blockchain, None)
|
2021-12-07 14:56:15 -05:00
|
|
|
balance = wallet.get_balance()
|
|
|
|
print(f"Wallet balance is: {balance}")
|
|
|
|
"""
|
|
|
|
|
2022-02-15 16:47:34 +01:00
|
|
|
rust_ext = RustExtension(
|
2022-08-05 10:31:24 -04:00
|
|
|
target="bdkpython.bdkffi",
|
2022-02-15 16:47:34 +01:00
|
|
|
path="./bdk-ffi/Cargo.toml",
|
|
|
|
binding=Binding.NoBinding,
|
|
|
|
)
|
|
|
|
|
2021-12-07 10:25:42 -05:00
|
|
|
setup(
|
2022-05-06 15:24:41 -04:00
|
|
|
name='bdkpython',
|
2022-08-07 15:48:59 -04:00
|
|
|
version='0.3.0.dev0',
|
2022-08-05 10:31:24 -04:00
|
|
|
description="The Python language bindings for the Bitcoin Development Kit",
|
2021-12-07 14:56:15 -05:00
|
|
|
long_description=LONG_DESCRIPTION,
|
|
|
|
long_description_content_type='text/markdown',
|
2022-02-15 16:47:34 +01:00
|
|
|
rust_extensions=[rust_ext],
|
|
|
|
zip_safe=False,
|
|
|
|
packages=['bdkpython'],
|
2022-05-06 15:24:41 -04:00
|
|
|
package_dir={'bdkpython': './src/bdkpython'},
|
|
|
|
url="https://github.com/bitcoindevkit/bdk-python",
|
2021-12-07 14:56:15 -05:00
|
|
|
author="Alekos Filini <alekos.filini@gmail.com>, Steve Myers <steve@notmandatory.org>",
|
|
|
|
license="MIT or Apache 2.0",
|
2021-12-07 10:25:42 -05:00
|
|
|
)
|