Add MVP Python package structure

This commit is contained in:
thunderbiscuit 2021-12-07 10:25:42 -05:00
parent 45cdd6911a
commit 5e376db385
No known key found for this signature in database
GPG Key ID: 88253696EB836462
7 changed files with 1953 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ bdkpython.egg-info/
__pycache__/
libbdkffi.dylib
.idea/
.DS_Store

View File

@ -7,21 +7,25 @@ Install the latest release using
```shell
pip install bdkpython
```
<br/>
## Run the tests
```shell
python -m tox
```
<br/>
## Build the package
```shell
python -m build
```
<br/>
## Install locally
```shell
pip install ./dist/bdkpython-0.0.1-py3-none-any.whl
```
<br/>
## Known issues
Note that until the fix is merged upstream in [uniffi-rs](https://github.com/mozilla/uniffi-rs), the `loadIndirect()` function in the `bdk.py` module must be replaced with the following:

13
setup.py Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='bdkpython',
version='0.0.1',
packages=find_packages(where="src"),
package_dir={"": "src"},
package_data={"bdkpython": ["*.dylib"]},
include_package_data=True,
zip_safe=False,
)

View File

@ -0,0 +1 @@
from bdkpython.bdk import *

1891
src/bdkpython/bdk.py Normal file

File diff suppressed because it is too large Load Diff

33
tests/test_bdk.py Normal file
View File

@ -0,0 +1,33 @@
import bdkpython as bdk
# taken from bdk test suite @ https://github.com/bitcoindevkit/bdk/blob/master/src/descriptor/template.rs#L676
descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/0h/0h/0/*)"
config = bdk.DatabaseConfig.MEMORY("")
client = bdk.BlockchainConfig.ELECTRUM(
bdk.ElectrumConfig(
"ssl://electrum.blockstream.info:60002",
None,
5,
None,
100
)
)
def test_address_BIP84_testnet():
wallet = bdk.OfflineWallet(descriptor, bdk.Network.TESTNET, config)
address = wallet.get_new_address()
assert address == "tb1qkmvk2nadgplmd57ztld8nf8v2yxkzmdvvztyse"
# def test_wallet_balance():
# wallet = bdk.OnlineWallet(
# descriptor=descriptor,
# change_descriptor=descriptor,
# network=bdk.Network.TESTNET,
# database_config=config,
# blockchain_config=client
# )
# wallet.sync()
# balance = wallet.get_balance()
# assert balance > 0

10
tox.ini Normal file
View File

@ -0,0 +1,10 @@
[tox]
envlist =
py39
[testenv]
deps =
pytest
bdk
commands =
pytest --verbose --override-ini console_output_style=count