Update library to new bdk-ffi API version to 0.6.0

This commit is contained in:
thunderbiscuit 2022-05-06 15:24:41 -04:00
parent 2ebd4979b0
commit 45216c7563
No known key found for this signature in database
GPG Key ID: 88253696EB836462
4 changed files with 20 additions and 10 deletions

View File

@ -20,13 +20,13 @@ python -m tox
## Build the package ## Build the package
```shell ```shell
# Install dependecies # Install dependecies
pip install -r requirements.txt pip install --requirement requirements.txt
# Generate the bindings first # Generate the bindings first
bash generate.sh bash generate.sh
# Build the wheel # Build the wheel
python3 setup.py -v bdist_wheel python3 setup.py --verbose bdist_wheel
``` ```
<br/> <br/>

View File

@ -6,4 +6,5 @@ SCRIPT_DIR=$(dirname "$(realpath $0)")
PY_SRC="${SCRIPT_DIR}/src/bdkpython/" PY_SRC="${SCRIPT_DIR}/src/bdkpython/"
echo "Generating bdk.py..." echo "Generating bdk.py..."
GENERATE_PYTHON_BINDINGS_OUT="$PY_SRC" GENERATE_PYTHON_BINDINGS_FIXUP_LIB_PATH=bdkffi cargo run --manifest-path ./bdk-ffi/Cargo.toml --release --bin generate --features generate-python # GENERATE_PYTHON_BINDINGS_OUT="$PY_SRC" GENERATE_PYTHON_BINDINGS_FIXUP_LIB_PATH=bdkffi cargo run --manifest-path ./bdk-ffi/Cargo.toml --release --bin generate --features generate-python
BDKFFI_BINDGEN_PYTHON_FIXUP_PATH=bdkffi cargo run --manifest-path ./bdk-ffi/Cargo.toml --package bdk-ffi-bindgen -- --language python --udl-file ./bdk-ffi/src/bdk.udl --out-dir ./src/bdkpython/

View File

@ -60,16 +60,16 @@ rust_ext = RustExtension(
) )
setup( setup(
name = 'bdkpython', name='bdkpython',
version = '0.0.5', version='0.0.6.dev0',
description="The Python language bindings for the bitcoindevkit", description="The Python language bindings for the bitcoindevkit",
long_description=LONG_DESCRIPTION, long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
rust_extensions=[rust_ext], rust_extensions=[rust_ext],
zip_safe=False, zip_safe=False,
packages=['bdkpython'], packages=['bdkpython'],
package_dir={ 'bdkpython': './src/bdkpython' }, package_dir={'bdkpython': './src/bdkpython'},
url="https://github.com/thunderbiscuit/bdk-python", url="https://github.com/bitcoindevkit/bdk-python",
author="Alekos Filini <alekos.filini@gmail.com>, Steve Myers <steve@notmandatory.org>", author="Alekos Filini <alekos.filini@gmail.com>, Steve Myers <steve@notmandatory.org>",
license="MIT or Apache 2.0", license="MIT or Apache 2.0",
) )

View File

@ -3,7 +3,7 @@ import bdkpython as bdk
# taken from bdk test suite @ https://github.com/bitcoindevkit/bdk/blob/master/src/descriptor/template.rs#L676 # taken from bdk test suite @ https://github.com/bitcoindevkit/bdk/blob/master/src/descriptor/template.rs#L676
descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/0h/0h/0/*)" descriptor = "wpkh(tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy/84h/0h/0h/0/*)"
config = bdk.DatabaseConfig.MEMORY("") db_config = bdk.DatabaseConfig.MEMORY()
client = bdk.BlockchainConfig.ELECTRUM( client = bdk.BlockchainConfig.ELECTRUM(
bdk.ElectrumConfig( bdk.ElectrumConfig(
"ssl://electrum.blockstream.info:60002", "ssl://electrum.blockstream.info:60002",
@ -15,11 +15,20 @@ client = bdk.BlockchainConfig.ELECTRUM(
) )
def test_address_BIP84_testnet(): def test_address_bip84_testnet():
wallet = bdk.OfflineWallet(descriptor, bdk.Network.TESTNET, config) wallet = bdk.Wallet(
descriptor=descriptor,
change_descriptor=None,
network=bdk.Network.TESTNET,
database_config=db_config
)
address = wallet.get_new_address() address = wallet.get_new_address()
print(f"New address is {address}")
assert address == "tb1qkmvk2nadgplmd57ztld8nf8v2yxkzmdvvztyse" assert address == "tb1qkmvk2nadgplmd57ztld8nf8v2yxkzmdvvztyse"
test_address_bip84_testnet()
# def test_wallet_balance(): # def test_wallet_balance():
# wallet = bdk.OnlineWallet( # wallet = bdk.OnlineWallet(
# descriptor=descriptor, # descriptor=descriptor,