Compare commits

..

20 Commits

Author SHA1 Message Date
thunderbiscuit
790d08c4c9 Fix library naming and bump Python version to 0.28.3 2023-04-25 10:22:09 -04:00
thunderbiscuit
ffd5a96ee0 Add library build task to Android test CI workflow 2023-04-24 16:09:45 -04:00
thunderbiscuit
fd02fc2a02 Remove support for Python 3.6 and 3.7 2023-04-24 16:09:15 -04:00
thunderbiscuit
5c560c6013 Use ubuntu-20.04 image for all Linux CI runs 2023-04-24 16:08:54 -04:00
thunderbiscuit
9d1b2de29b Add workflow dispatch to all test workflows 2023-04-24 16:08:32 -04:00
thunderbiscuit
3e3c0bf22f Pin Rust version in CI workflows to 1.67 2023-04-24 16:08:16 -04:00
thunderbiscuit
9b919e5ceb Update libraries to official release versions 2023-04-18 12:31:15 -04:00
thunderbiscuit
b8b60dda87 Prepare language bindings libraries for 0.28 release 2023-04-17 14:34:03 -04:00
Steve Myers
a50e19e7e0 Update bdk to 0.28 2023-04-13 10:22:53 -04:00
Steve Myers
fab9ae8ae5 Add PartiallySignedTransaction.json_serialize() function 2023-04-13 09:21:22 -04:00
thunderbiscuit
478b12c489 Add API docs for fromScript method on Address 2023-04-13 08:50:08 -04:00
andreasgriffin
63b85b9100 Add from_script method to Address type 2023-04-13 08:50:03 -04:00
Steve Myers
0e6b472793 Merge bitcoindevkit/bdk-ffi#335: Use version 21 of the Android NDK in the CI test, build, and publish workflows
beb75dd552 Use version 21 of the Android NDK in the CI test, build, and publish workflows (thunderbiscuit)

Pull request description:

  This PR reverts an update to our Android CI workflows.

  For info on why this is needed, see issues #242 and #243.

ACKs for top commit:
  notmandatory:
    ACK beb75dd552

Tree-SHA512: dfee0b1f335318b86fa490fa85e7ef5d7a032e01a78db64a186c5d75e9e77e8f0e2af58ee5407d4fe38a0aa3aabbc7b06b23189aef0dfaad1d246a354452870d
2023-04-12 21:38:07 -05:00
thunderbiscuit
beb75dd552 Use version 21 of the Android NDK in the CI test, build, and publish workflows 2023-04-05 11:10:21 -04:00
thunderbiscuit
5ee8698e0a Add Kotlin API docs for new AddressInfo type 2023-03-28 19:51:15 -04:00
thunderbiscuit
ac600a1312 Clean up type aliases and use more explicit variable names 2023-03-28 19:47:38 -04:00
thunderbiscuit
f26031db80 Update tests for new AddressInfo type 2023-03-28 15:05:42 -04:00
thunderbiscuit
e7e1a6057e Use Address type in address field on AddressInfo 2023-03-28 13:29:06 -04:00
thunderbiscuit
2b7c104f11 Clean up of docs regarding removed cli tool 2023-03-27 13:39:28 -04:00
thunderbiscuit
6bab5a159d Remove bdk-ffi-bindgen tool section in root readme 2023-03-24 12:56:06 -04:00
28 changed files with 384 additions and 251 deletions

View File

@@ -6,78 +6,79 @@ labels: 'release'
assignees: ''
---
## Create a new patch release
### _Main Workflow_
# Creating a new patch release
## Bumping BDK Rust Version
1. - [ ] Open a PR with an update to `Cargo.toml` to the new bdk release candidate and ensure all CI workflows run correctly. Fix errors if necessary.
2. - [ ] Once the new bdk release is out, update the PR to replace the release candidate with the full release and merge.
3. - [ ] Update the Android, JVM, Python, and Swift libraries as per the ["**_Sub-Workflows_**" section below](#Sub-Workflows). Open a single PR on master for all of these changes called `Prepare language bindings libraries for 0.X release`
18. - [ ] Create a new branch off of `master` called `release/version`
19. - [ ] Checkout that branch and open a PR to update the Android, JVM, and Python libraries' versions
- [ ] Update bdk-android version from `SNAPSHOT` version to release version
- [ ] Update bdk-jvm version from `SNAPSHOT` version to release version
- [ ] Update bdk-python version from `.dev` version to release version
20. - [ ] Merge the PR updating all of the languages to their release versions
21. - [ ] Create the tag and make sure to add the changelog info to the tag (works better if you prepare the tag message on the side in a text editor) and push it to GitHub.
### Specific Libraries' Workflows
#### _Android_
3. - [ ] Update the API docs to reflect the changes in the API
4. - [ ] Delete the `target` directory in bdk-ffi and all previous artifacts to make sure you're building the library from scratch.
5. - [ ] Build the library and run the tests, and adjust if necessary.
```sh
# start an emulator prior to running the tests
cd ./bdk-android/
./gradlew buildAndroidLib
./gradlew connectedAndroidTest
```
6. - [ ] Update the readme if necessary
#### _JVM_
7. - [ ] Update the API docs to reflect the changes in the API
8. - [ ] Delete the `target` directory in bdk-ffi and all previous artifacts to make sure you're building the library from scratch
9. - [ ] Build the library and run the tests, and adjust if necessary
```sh
cd ./bdk-jvm/
./gradlew buildJvmLib
./gradlew test
```
10. - [ ] Update the readme if necessary
#### _Swift_
11. - [ ] Run the tests and adjust if necessary
```sh
./bdk-swift/build-local-swift.sh
cd ./bdk-swift/
swift test
```
12. - [ ] Update the readme if necessary
#### _Python_
13. - [ ] Delete the `.tox`, `dist`, `build`, and `bdkpython.egg-info` and rust `target` directories to make sure you are building the library from scratch without any caches
14. - [ ] Build the library
```shell
cd ./bdk-python/
pip3 install --requirement requirements.txt
bash ./generate.sh
python3 setup.py --verbose bdist_wheel
```
15. - [ ] Run the tests and adjust if necessary
```shell
pip3 install ./dist/bdkpython-<yourversion>-py3-none-any.whl --force-reinstall
python -m unittest --verbose tests/test_bdk.py
```
16. - [ ] Update the readme and `setup.py` if necessary
### Release Workflow
17. - [ ] Update the Android, JVM, Python, and Swift libraries as per the _Specific Libraries' Workflows_ section above. Open a single PR on master for all of these changes called `Prepare language bindings libraries for 0.X release`
- [ ] Create a new branch off of `master` called `release/version`
18. - [ ] Checkout that branch and open a PR to update the Android, JVM, and Python libraries' versions
- [ ] Update bdk-android version from `SNAPSHOT` version to release version
- [ ] Update bdk-jvm version from `SNAPSHOT` version to release version
- [ ] Update bdk-python version from `.dev` version to release version
19. - [ ] Merge the PR updating all of the languages to their release versions
20. - [ ] Create the tag and make sure to add the changelog info to the tag (works better if you prepare the tag message on the side in a text editor) and push it to GitHub.
```sh
git tag v0.6.0 --sign --edit
git push upstream v0.6.0
```
22. - [ ] Make release on GitHub (set as pre-release and generate auto release notes between the previous tag and the new one)
23. - [ ] Trigger manual releases for all 4 libraries (for Swift, simply add the version number in the text field when running the workflow manually. Note that the version number must not contain the `v`, i.e. `0.26.0`)
24. - [ ] Bump the versions on master from `0.9.0-SNAPSHOT` to `0.10.0-SNAPSHOT`, `0.6.0.dev0` to `0.7.0.dev0`
25. - [ ] Build and publish API docs for JVM, Android, and Java on the website
21. - [ ] Make release on GitHub (set as pre-release and generate auto release notes between the previous tag and the new one)
22. - [ ] Trigger manual releases for all 4 libraries (for Swift, simply add the version number in the text field when running the workflow manually. Note that the version number must not contain the `v`, i.e. `0.26.0`)
23. - [ ] Bump the versions on master from `0.9.0-SNAPSHOT` to `0.10.0-SNAPSHOT`, `0.6.0.dev0` to `0.7.0.dev0`
24. - [ ] Build and publish API docs for JVM, Android, and Java on the website
```bash!
./gradlew dokkaHtml # bdk-jvm (Dokka)
./gradlew dokkaJavadoc # bdk-jvm (java-style documentation)
./gradlew dokkaHtml # bdk-android (Dokka)
```
26. - [ ] Tweet about the library
27. - [ ] Post in the announcement channel
### _Sub Workflows_
#### _Android_
4. - [ ] Update the API docs to reflect the changes in the API
5. - [ ] Delete the `target` directory in bdk-ffi and all previous artifacts to make sure you're building the library from scratch
6. - [ ] Build the library and run the tests, and adjust if necessary.
```sh
# start an emulator prior to running the tests
cd bdk-android
./gradlew buildAndroidLib
./gradlew connectedAndroidTest
```
7. - [ ] Update the readme if necessary
#### _JVM_
8. - [ ] Update the API docs to reflect the changes in the API
9. - [ ] Delete the `target` directory in bdk-ffi and all previous artifacts to make sure you're building the library from scratch
10. - [ ] Build the library and run the tests, and adjust if necessary
```sh
cd bdk-jvm
./gradlew buildJvmLib
./gradlew test
```
11. - [ ] Update the readme if necessary
#### _Swift_
12. - [ ] Run the tests and adjust if necessary
```sh
./bdk-swift/build-local-swift.sh
cd bdk-swift
swift test
```
13. - [ ] Update the readme if necessary
#### _Python_
14. - [ ] Delete the `.tox`, `dist`, `build`, and `bdkpython.egg-info` and rust `target` directories to make sure you are building the library from scratch without any caches
15. - [ ] Build the library
```shell
pip3 install --requirement requirements.txt
bash ./generate.sh
python3 setup.py --verbose bdist_wheel
```
16. - [ ] Run the tests and adjust if necessary
```shell
pip3 install ./dist/bdkpython-<yourversion>-py3-none-any.whl
python -m unittest --verbose tests/test_bdk.py
```
17. - [ ] Update the readme and `setup.py` if necessary
25. - [ ] Tweet about the library
26. - [ ] Post in the announcement channel

View File

@@ -1,10 +1,24 @@
name: Publish bdk-android to Maven Central
on: [workflow_dispatch]
# The default Android NDK on the ubuntu-22.04 image is 25.2.9519653
# We replace the default environment variable ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/25.2.9519653
# with an older version of the NDK (21.4.7075529) using the fix proposed here: https://github.com/actions/runner-images/issues/5930
# For information on why this is needed at the moment see issues #242 and #243, and PR #282
env:
ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/21.4.7075529
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: "Install Android NDK 21.4.7075529"
run: |
ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
echo "y" | $SDKMANAGER "ndk;21.4.7075529"
- name: "Check out PR branch"
uses: actions/checkout@v2
@@ -23,6 +37,9 @@ jobs:
distribution: temurin
java-version: 11
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: "Install Rust Android targets"
run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi

View File

@@ -24,6 +24,9 @@ jobs:
distribution: temurin
java-version: 11
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: Install aarch64 Rust target
run: rustup target add aarch64-apple-darwin
@@ -43,7 +46,7 @@ jobs:
build-jvm-full-library:
name: Create full bdk-jvm library
needs: [build-jvm-macOS-M1-native-lib]
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- name: Checkout publishing branch
uses: actions/checkout@v2
@@ -68,6 +71,9 @@ jobs:
distribution: temurin
java-version: 11
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: Build bdk-jvm library
run: |
cd bdk-jvm

View File

@@ -9,7 +9,7 @@ on: [workflow_dispatch]
jobs:
build-manylinux2014-x86_64-wheel:
name: "Build Manylinux 2014 x86_64 wheel"
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
defaults:
run:
working-directory: bdk-python
@@ -21,13 +21,9 @@ jobs:
strategy:
matrix:
python: # Update this list whenever the docker image is updated (check /opt/python/)
- cp36-cp36m
- cp37-cp37m
- cp38-cp38
- cp39-cp39
- cp310-cp310
- pp37-pypy37_pp73
- pp38-pypy38_pp73
steps:
- name: "Checkout"
uses: actions/checkout@v2
@@ -37,6 +33,9 @@ jobs:
with:
toolchain: stable
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: "Install requirements"
run: ${PYBIN}/pip install -r requirements.txt
@@ -44,7 +43,9 @@ jobs:
run: bash generate.sh
- name: "Build wheel"
run: ${PYBIN}/python setup.py bdist_wheel --verbose
# Specifying the plat-name argument is necessary to build a wheel with the correct name,
# see issue #350 for more information
run: ${PYBIN}/python setup.py bdist_wheel --plat-name manylinux_2_17_x86_64 --verbose
- uses: actions/upload-artifact@v2
with:
@@ -60,10 +61,9 @@ jobs:
strategy:
matrix:
python:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- "3.8"
- "3.9"
- "3.10"
steps:
- name: "Checkout"
uses: actions/checkout@v2
@@ -83,7 +83,9 @@ jobs:
- name: "Build wheel"
env:
ARCHFLAGS: "-arch x86_64 -arch arm64"
run: python3 setup.py bdist_wheel --verbose
# Specifying the plat-name argument is necessary to build a wheel with the correct name,
# see issue #350 for more information
run: python3 setup.py bdist_wheel --plat-name macosx_12_0_universal2 --verbose
- uses: actions/upload-artifact@v2
with:
@@ -91,7 +93,7 @@ jobs:
path: /Users/runner/work/bdk-ffi/bdk-ffi/bdk-python/dist/*.whl
build-windows-wheel:
name: "Build windows wheel"
name: "Build Windows wheel"
runs-on: windows-2022
defaults:
run:
@@ -99,10 +101,9 @@ jobs:
strategy:
matrix:
python:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- "3.8"
- "3.9"
- "3.10"
steps:
- name: "Checkout"
uses: actions/checkout@v2
@@ -128,7 +129,7 @@ jobs:
publish-pypi:
name: "Publish on PyPI"
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
defaults:
run:
working-directory: bdk-python

View File

@@ -1,5 +1,6 @@
name: Test Android
on:
workflow_dispatch:
push:
paths:
- "bdk-ffi/**"
@@ -9,10 +10,24 @@ on:
- "bdk-ffi/**"
- "bdk-android/**"
# The default Android NDK on the ubuntu-22.04 image is 25.2.9519653
# We replace the default environment variable ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/25.2.9519653
# with an older version of the NDK (21.4.7075529) using the fix proposed here: https://github.com/actions/runner-images/issues/5930
# For information on why this is needed at the moment see issues #242 and #243, and PR #282
env:
ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/21.4.7075529
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: "Install Android NDK 21.4.7075529"
run: |
ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
echo "y" | $SDKMANAGER "ndk;21.4.7075529"
- name: "Check out PR branch"
uses: actions/checkout@v2
@@ -31,10 +46,20 @@ jobs:
distribution: temurin
java-version: 11
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: "Install Rust Android targets"
run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi
- name: "Run Android tests"
- name: "Build Android library"
run: |
cd bdk-android
./gradlew test --console=rich
./gradlew buildAndroidLib
# There are currently no unit tests for bdk-android and the integration tests require the macOS image
# which is not working with the older NDK version we are using, so for now we just make sure that the library builds.
# - name: "Run Android unit tests"
# run: |
# cd bdk-android
# ./gradlew test --console=rich

View File

@@ -1,5 +1,6 @@
name: Test Kotlin/JVM
on:
workflow_dispatch:
push:
paths:
- "bdk-ffi/**"
@@ -31,6 +32,9 @@ jobs:
distribution: temurin
java-version: 11
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: Run JVM tests
run: |
cd bdk-jvm

View File

@@ -1,5 +1,6 @@
name: Test Python
on:
workflow_dispatch:
push:
paths:
- "bdk-ffi/**"
@@ -17,7 +18,7 @@ on:
jobs:
build-manylinux2014-x86_64-wheel:
name: "Build and test Manylinux 2014 x86_64 wheels"
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
defaults:
run:
working-directory: bdk-python
@@ -29,10 +30,8 @@ jobs:
strategy:
matrix:
python:
# - cp36-cp36m
# - cp37-cp37m
# - cp38-cp38
# - cp39-cp39
- cp38-cp38
- cp39-cp39
- cp310-cp310
steps:
- name: "Checkout"
@@ -43,6 +42,9 @@ jobs:
with:
toolchain: stable
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: "Install requirements"
run: ${PYBIN}/pip install -r requirements.txt
@@ -56,7 +58,9 @@ jobs:
run: ${PYBIN}/pip install ./dist/*.whl
- name: "Run tests"
run: ${PYBIN}/python -m unittest tests/test_bdk.py --verbose
# Specifying the plat-name argument is necessary to build a wheel with the correct name,
# see issue #350 for more information
run: ${PYBIN}/python -m unittest tests/test_bdk.py --plat-name manylinux_2_17_x86_64 --verbose
- name: "Upload artifact test"
uses: actions/upload-artifact@v2
@@ -73,10 +77,9 @@ jobs:
strategy:
matrix:
python:
# - '3.7'
# - '3.8'
# - '3.9'
- '3.10'
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -113,10 +116,9 @@ jobs:
strategy:
matrix:
python:
# - '3.7'
# - '3.8'
# - '3.9'
- '3.10'
- "3.8"
- "3.9"
- "3.10"
steps:
- name: "Checkout"
uses: actions/checkout@v2
@@ -135,12 +137,11 @@ jobs:
- name: "Build wheel"
run: python setup.py bdist_wheel --verbose
# TODO: On Windows the pip install ./dist/*.whl step fails with the following error:
# Run pip install ./dist/*.whl
# WARNING: Requirement './dist/*.whl' looks like a filename, but the file does not exist
# ERROR: *.whl is not a valid wheel filename.*.whl is not a valid wheel name
# So we skip the installing and the tests and simply test that the wheel builds
# TODO: On Windows the pip install ./dist/*.whl step fails with the following error:
# Run pip install ./dist/*.whl
# WARNING: Requirement './dist/*.whl' looks like a filename, but the file does not exist
# ERROR: *.whl is not a valid wheel filename.*.whl is not a valid wheel name
# So we skip the installing and the tests and simply test that the wheel builds
# - name: Install wheel
# run: pip install ./dist/*.whl
# - name: Run tests

View File

@@ -1,5 +1,6 @@
name: Test Swift
on:
workflow_dispatch:
push:
paths:
- "bdk-ffi/**"
@@ -16,6 +17,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: "Set default Rust version to 1.67.0"
run: rustup default 1.67.0
- name: Install Rust targets
run: |
rustup install nightly-x86_64-apple-darwin

138
Cargo.lock generated
View File

@@ -78,13 +78,13 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
[[package]]
name = "async-trait"
version = "0.1.67"
version = "0.1.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4"
checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.8",
"syn 2.0.14",
]
[[package]]
@@ -121,9 +121,9 @@ dependencies = [
[[package]]
name = "bdk"
version = "0.27.1"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51c878ac60a45c41523ff790df555ccb1fbfd634a667220104dcae3e64d7ed9f"
checksum = "e9b650f45ae7dc8558544448253f3e1ae443433637ccd9f9d14d2089ff913480"
dependencies = [
"ahash",
"async-trait",
@@ -147,7 +147,7 @@ dependencies = [
[[package]]
name = "bdk-ffi"
version = "0.27.1"
version = "0.28.0"
dependencies = [
"assert_matches",
"bdk",
@@ -182,12 +182,11 @@ dependencies = [
[[package]]
name = "bip39"
version = "1.2.0"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28"
checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f"
dependencies = [
"bitcoin_hashes",
"rand_core 0.4.2",
"serde",
"unicode-normalization",
]
@@ -282,9 +281,9 @@ dependencies = [
[[package]]
name = "cargo_metadata"
version = "0.15.3"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a1ec454bc3eead8719cb56e15dbbfecdbc14e4b3a3ae4936cc6e31f5fc0d07"
checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"
dependencies = [
"camino",
"cargo-platform",
@@ -396,9 +395,9 @@ dependencies = [
[[package]]
name = "esplora-client"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bbba572d03ca4d628b653f01e60ba6947c67df65ee8910c79daaf252897924"
checksum = "847e59bd6ee1c3f2bdf217118ee3640b97a1b1d8becb55771e67e533b87da66f"
dependencies = [
"bitcoin",
"log",
@@ -464,9 +463,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.8"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
dependencies = [
"cfg-if",
"libc",
@@ -525,20 +524,19 @@ dependencies = [
[[package]]
name = "idna"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de910d521f7cc3135c4de8db1cb910e0b5ed1dc6f57c381cd07e8e661ce10094"
checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "indexmap"
version = "1.9.2"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown",
@@ -582,9 +580,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.140"
version = "0.2.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
[[package]]
name = "libsqlite3-sys"
@@ -616,18 +614,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "matches"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.5.0"
@@ -727,7 +713,7 @@ dependencies = [
"instant",
"libc",
"redox_syscall",
"smallvec 1.10.0",
"smallvec",
"winapi",
]
@@ -793,9 +779,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.53"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73"
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
dependencies = [
"unicode-ident",
]
@@ -817,7 +803,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core 0.6.4",
"rand_core",
]
[[package]]
@@ -827,15 +813,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.4",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.6.4"
@@ -880,7 +860,7 @@ dependencies = [
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec 1.10.0",
"smallvec",
]
[[package]]
@@ -969,29 +949,29 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.158"
version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9"
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.158"
version = "1.0.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad"
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.8",
"syn 2.0.14",
]
[[package]]
name = "serde_json"
version = "1.0.94"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
dependencies = [
"itoa",
"ryu",
@@ -1020,15 +1000,6 @@ dependencies = [
"parking_lot",
]
[[package]]
name = "smallvec"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0"
dependencies = [
"maybe-uninit",
]
[[package]]
name = "smallvec"
version = "1.10.0"
@@ -1077,9 +1048,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.8"
version = "2.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9"
checksum = "fcf316d5356ed6847742d036f8a39c3b8435cac10bd528a4bd461928a6ab34d5"
dependencies = [
"proc-macro2",
"quote",
@@ -1118,14 +1089,29 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.8",
"syn 2.0.14",
]
[[package]]
name = "tokio"
version = "1.26.0"
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
dependencies = [
"autocfg",
"pin-project-lite",
@@ -1135,13 +1121,13 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "1.8.2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.14",
]
[[package]]
@@ -1176,11 +1162,11 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
[[package]]
name = "unicode-normalization"
version = "0.1.9"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf"
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [
"smallvec 0.6.14",
"tinyvec",
]
[[package]]
@@ -1331,9 +1317,9 @@ dependencies = [
[[package]]
name = "url"
version = "2.3.0"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22fe195a4f217c25b25cb5058ced57059824a678474874038dc88d211bf508d3"
checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [
"form_urlencoded",
"idna",

View File

@@ -8,8 +8,7 @@
</p>
The workspace in this repository creates the `libbdkffi` multi-language library for the Rust-based
[bdk] library from the [Bitcoin Dev Kit] project. The `bdk-ffi-bindgen` package builds a tool for
generating the actual language binding code used to access the `libbdkffi` library.
[bdk] library from the [Bitcoin Dev Kit] project.
Each supported language and the platform(s) it's packaged for has its own directory. The Rust code in this project is in the bdk-ffi directory and is a wrapper around the [bdk] library to expose its APIs in a uniform way using the [mozilla/uniffi-rs] bindings generator for each supported target language.
@@ -23,13 +22,6 @@ The below directories (a separate repository in the case of bdk-swift) include i
| Swift | iOS, macOS | [bdk-swift (GitHub)] | [Readme bdk-swift] | |
| Python | linux, macOS, Windows | [bdk-python (PyPI)] | [Readme bdk-python] | |
## Language bindings generator tool
Use the `bdk-ffi-bindgen` tool to generate language binding code for the above supported languages.
To run `bdk-ffi-bindgen` and see the available options use the command:
```shell
cargo run -p bdk-ffi-bindgen -- --help
```
## Contributing
### Adding new structs and functions

View File

@@ -24,12 +24,14 @@ enum class Network {
*
* @property index Child index of this address.
* @property address Address.
* @property keychain Type of keychain.
*
* @sample org.bitcoindevkit.addressInfoSample
*/
data class AddressInfo (
var index: UInt,
var address: String
var address: Address,
var keychain: KeychainKind
)
/**
@@ -367,6 +369,9 @@ class PartiallySignedTransaction(psbtBase64: String) {
* In accordance with BIP 174 this function is commutative i.e., `A.combine(B) == B.combine(A)`
*/
fun combine(other: PartiallySignedTransaction): PartiallySignedTransaction
/** Serialize the PSBT data structure as a String of JSON. */
fun jsonSerialize(): String
}
/**
@@ -829,6 +834,9 @@ class Script(rawOutputScript: List<UByte>)
* @param address The address in string format.
*/
class Address(address: String) {
/** Construct an [`Address`] from an output script. */
fun fromScript(script: Script, network: Network): Address {}
/** Return the Payload */
fun payload(): Payload
@@ -846,6 +854,9 @@ class Address(address: String) {
* Quoting BIP 173 "inside QR codes uppercase SHOULD be used, as those permit the use of alphanumeric mode, which is 45% more compact than the normal byte mode."
*/
fun toQrUri(): String
/** Return the address as a string. */
fun asString(): String
}}
/**

View File

@@ -87,7 +87,7 @@ fun addressInfoSample() {
val newAddress: AddressInfo = wallet.getAddress(AddressIndex.New)
println("New address at index ${newAddress.index} is ${newAddress.address}")
println("New address at index ${newAddress.index} is ${newAddress.address.asString()}")
}
fun blockchainSample() {

View File

@@ -19,8 +19,8 @@ import org.bitcoindevkit.*
// ...
val externalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
val internalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)"
val externalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", Network.TESTNET)
val internalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)", Network.TESTNET)
val databaseConfig = DatabaseConfig.Memory

View File

@@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=0.28.0-SNAPSHOT
libraryVersion=0.28.0

View File

@@ -54,7 +54,7 @@ class AndroidLibTest {
@Test
fun memoryWalletNewAddress() {
val wallet = Wallet(descriptor, null, Network.TESTNET, databaseConfig)
val address = wallet.getAddress(AddressIndex.New).address
val address = wallet.getAddress(AddressIndex.New).address.asString()
assertEquals("tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", address)
}

View File

@@ -1,6 +1,6 @@
[package]
name = "bdk-ffi"
version = "0.27.1"
version = "0.28.0"
authors = ["Steve Myers <steve@notmandatory.org>", "Sudarsan Balaji <sudarsan.balaji@artfuldev.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
@@ -19,7 +19,7 @@ path = "uniffi-bindgen.rs"
default = ["uniffi/cli"]
[dependencies]
bdk = { version = "0.27.1", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] }
bdk = { version = "0.28", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] }
uniffi = { version = "0.23.0" }
[build-dependencies]

View File

@@ -50,7 +50,8 @@ enum BdkError {
dictionary AddressInfo {
u32 index;
string address;
Address address;
KeychainKind keychain;
};
[Enum]
@@ -306,6 +307,8 @@ interface PartiallySignedTransaction {
u64? fee_amount();
FeeRate? fee_rate();
string json_serialize();
};
dictionary TxBuilderResult {
@@ -445,6 +448,9 @@ interface Address {
[Throws=BdkError]
constructor(string address);
[Name=from_script, Throws=BdkError]
constructor(Script script, Network network);
Payload payload();
Network network();
@@ -452,6 +458,8 @@ interface Address {
Script script_pubkey();
string to_qr_uri();
string as_string();
};
[Enum]

View File

@@ -30,9 +30,11 @@ use bdk::keys::bip39::WordCount;
use bdk::wallet::AddressIndex as BdkAddressIndex;
use bdk::wallet::AddressInfo as BdkAddressInfo;
use bdk::LocalUtxo as BdkLocalUtxo;
use bdk::TransactionDetails as BdkTransactionDetails;
use bdk::{Balance as BdkBalance, BlockTime, Error as BdkError, FeeRate, KeychainKind};
use std::convert::From;
use std::fmt;
use std::fmt::Debug;
use std::io::Cursor;
use std::str::FromStr;
use std::sync::Arc;
@@ -47,17 +49,20 @@ pub struct ScriptAmount {
/// A derived address and the index it was found at.
pub struct AddressInfo {
/// Child index of this address
/// Child index of this address.
pub index: u32,
/// Address
pub address: String,
/// Address.
pub address: Arc<Address>,
/// Type of keychain.
pub keychain: KeychainKind,
}
impl From<BdkAddressInfo> for AddressInfo {
fn from(x: bdk::wallet::AddressInfo) -> Self {
fn from(address_info: BdkAddressInfo) -> Self {
AddressInfo {
index: x.index,
address: x.address.to_string(),
index: address_info.index,
address: Arc::new(Address::from(address_info.address)),
keychain: address_info.keychain,
}
}
}
@@ -90,8 +95,8 @@ pub enum AddressIndex {
}
impl From<AddressIndex> for BdkAddressIndex {
fn from(x: AddressIndex) -> Self {
match x {
fn from(address_index: AddressIndex) -> Self {
match address_index {
AddressIndex::New => BdkAddressIndex::New,
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
AddressIndex::Peek { index } => BdkAddressIndex::Peek(index),
@@ -122,8 +127,8 @@ pub struct TransactionDetails {
pub confirmation_time: Option<BlockTime>,
}
impl From<bdk::TransactionDetails> for TransactionDetails {
fn from(tx_details: bdk::TransactionDetails) -> Self {
impl From<BdkTransactionDetails> for TransactionDetails {
fn from(tx_details: BdkTransactionDetails) -> Self {
let optional_tx: Option<Arc<Transaction>> =
tx_details.transaction.map(|tx| Arc::new(tx.into()));
@@ -148,10 +153,10 @@ pub struct OutPoint {
}
impl From<&OutPoint> for BdkOutPoint {
fn from(x: &OutPoint) -> Self {
fn from(outpoint: &OutPoint) -> Self {
BdkOutPoint {
txid: Txid::from_str(&x.txid).unwrap(),
vout: x.vout,
txid: Txid::from_str(&outpoint.txid).unwrap(),
vout: outpoint.vout,
}
}
}
@@ -194,11 +199,11 @@ pub struct TxOut {
}
impl From<&BdkTxOut> for TxOut {
fn from(x: &BdkTxOut) -> Self {
fn from(tx_out: &BdkTxOut) -> Self {
TxOut {
value: x.value,
value: tx_out.value,
script_pubkey: Arc::new(Script {
script: x.script_pubkey.clone(),
script: tx_out.script_pubkey.clone(),
}),
}
}
@@ -248,7 +253,7 @@ impl BdkProgress for ProgressHolder {
}
}
impl fmt::Debug for ProgressHolder {
impl Debug for ProgressHolder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ProgressHolder").finish_non_exhaustive()
}
@@ -263,17 +268,17 @@ pub struct TxIn {
}
impl From<&BdkTxIn> for TxIn {
fn from(x: &BdkTxIn) -> Self {
fn from(tx_in: &BdkTxIn) -> Self {
TxIn {
previous_output: OutPoint {
txid: x.previous_output.txid.to_string(),
vout: x.previous_output.vout,
txid: tx_in.previous_output.txid.to_string(),
vout: tx_in.previous_output.vout,
},
script_sig: Arc::new(Script {
script: x.script_sig.clone(),
script: tx_in.script_sig.clone(),
}),
sequence: x.sequence.0,
witness: x.witness.to_vec(),
sequence: tx_in.sequence.0,
witness: tx_in.witness.to_vec(),
}
}
}
@@ -340,14 +345,15 @@ impl Transaction {
}
}
impl From<bdk::bitcoin::Transaction> for Transaction {
fn from(tx: bdk::bitcoin::Transaction) -> Self {
impl From<BdkTransaction> for Transaction {
fn from(tx: BdkTransaction) -> Self {
Transaction { internal: tx }
}
}
/// A Bitcoin address.
struct Address {
#[derive(Debug, PartialEq, Eq)]
pub struct Address {
address: BdkAddress,
}
@@ -358,6 +364,13 @@ impl Address {
.map_err(|e| BdkError::Generic(e.to_string()))
}
/// alternative constructor
fn from_script(script: Arc<Script>, network: Network) -> Result<Self, BdkError> {
BdkAddress::from_script(&script.script, network)
.map(|a| Address { address: a })
.map_err(|e| BdkError::Generic(e.to_string()))
}
fn payload(&self) -> Payload {
match &self.address.payload.clone() {
BdkPayload::PubkeyHash(pubkey_hash) => Payload::PubkeyHash {
@@ -386,6 +399,16 @@ impl Address {
fn to_qr_uri(&self) -> String {
self.address.to_qr_uri()
}
fn as_string(&self) -> String {
self.address.to_string()
}
}
impl From<BdkAddress> for Address {
fn from(address: BdkAddress) -> Self {
Address { address }
}
}
/// The method used to produce an address.

View File

@@ -1,6 +1,8 @@
use bdk::bitcoin::hashes::hex::ToHex;
use bdk::bitcoin::util::psbt::PartiallySignedTransaction as BdkPartiallySignedTransaction;
use bdk::bitcoincore_rpc::jsonrpc::serde_json;
use bdk::psbt::PsbtUtils;
use std::ops::Deref;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
@@ -66,6 +68,12 @@ impl PartiallySignedTransaction {
pub(crate) fn fee_rate(&self) -> Option<Arc<FeeRate>> {
self.internal.lock().unwrap().fee_rate().map(Arc::new)
}
/// Serialize the PSBT data structure as a String of JSON.
pub(crate) fn json_serialize(&self) -> String {
let psbt = self.internal.lock().unwrap();
serde_json::to_string(psbt.deref()).unwrap()
}
}
// The goal of these tests to to ensure `bdk-ffi` intermediate code correctly calls `bdk` APIs.

View File

@@ -655,7 +655,8 @@ mod test {
wallet
.get_address(AddressIndex::Peek { index: 2 })
.unwrap()
.address,
.address
.as_string(),
"bcrt1q5g0mq6dkmwzvxscqwgc932jhgcxuqqkjv09tkj"
);
@@ -663,25 +664,38 @@ mod test {
wallet
.get_address(AddressIndex::Peek { index: 1 })
.unwrap()
.address,
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
// new index still 0
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1qqjn9gky9mkrm3c28e5e87t5akd3twg6xezp0tv"
);
// new index now 1
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
// new index now 2
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1q5g0mq6dkmwzvxscqwgc932jhgcxuqqkjv09tkj"
);
@@ -690,7 +704,8 @@ mod test {
wallet
.get_address(AddressIndex::Peek { index: 1 })
.unwrap()
.address,
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
@@ -699,13 +714,18 @@ mod test {
wallet
.get_address(AddressIndex::Reset { index: 0 })
.unwrap()
.address,
.address
.as_string(),
"bcrt1qqjn9gky9mkrm3c28e5e87t5akd3twg6xezp0tv"
);
// new index 1 again
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
}
@@ -729,12 +749,20 @@ mod test {
.unwrap();
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1qqjn9gky9mkrm3c28e5e87t5akd3twg6xezp0tv"
);
assert_eq!(
wallet.get_address(AddressIndex::New).unwrap().address,
wallet
.get_address(AddressIndex::New)
.unwrap()
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
@@ -742,7 +770,8 @@ mod test {
wallet
.get_address(AddressIndex::LastUnused)
.unwrap()
.address,
.address
.as_string(),
"bcrt1q0xs7dau8af22rspp4klya4f7lhggcnqfun2y3a"
);
@@ -750,7 +779,8 @@ mod test {
wallet
.get_internal_address(AddressIndex::New)
.unwrap()
.address,
.address
.as_string(),
"bcrt1qpmz73cyx00r4a5dea469j40ax6d6kqyd67nnpj"
);
@@ -758,7 +788,8 @@ mod test {
wallet
.get_internal_address(AddressIndex::New)
.unwrap()
.address,
.address
.as_string(),
"bcrt1qaux734vuhykww9632v8cmdnk7z2mw5lsf74v6k"
);
@@ -766,7 +797,8 @@ mod test {
wallet
.get_internal_address(AddressIndex::LastUnused)
.unwrap()
.address,
.address
.as_string(),
"bcrt1qaux734vuhykww9632v8cmdnk7z2mw5lsf74v6k"
);
}

View File

@@ -6,10 +6,5 @@ class TestBdk(unittest.TestCase):
def test_some_enum(self):
network = Network.TESTNET
def test_some_dict(self):
a = AddressInfo(index=42, address="testaddress")
self.assertEqual(42, a.index)
self.assertEqual("testaddress", a.address)
if __name__=='__main__':
unittest.main()

View File

@@ -19,8 +19,8 @@ import org.bitcoindevkit.*
// ...
val externalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
val internalDescriptor = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)"
val externalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", Network.TESTNET)
val internalDescriptor = Descriptor("wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)", Network.TESTNET)
val databaseConfig = DatabaseConfig.Memory

View File

@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536m
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=0.28.0-SNAPSHOT
libraryVersion=0.28.0

View File

@@ -46,7 +46,7 @@ class JvmLibTest {
@Test
fun memoryWalletNewAddress() {
val wallet = Wallet(descriptor, null, Network.TESTNET, databaseConfig)
val address = wallet.getAddress(AddressIndex.New).address
val address = wallet.getAddress(AddressIndex.New).address.asString()
assertEquals("tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", address)
}

View File

@@ -51,7 +51,7 @@ print(f"Wallet balance is: {balance.total}")
setup(
name="bdkpython",
version="0.28.0.dev0",
version="0.28.3",
description="The Python language bindings for the Bitcoin Development Kit",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
@@ -62,4 +62,8 @@ setup(
url="https://github.com/bitcoindevkit/bdk-ffi",
author="Alekos Filini <alekos.filini@gmail.com>, Steve Myers <steve@notmandatory.org>",
license="MIT or Apache 2.0",
# This is required to ensure the library name includes the python version, abi, and platform tags
# See issue #350 for more information
has_ext_modules=lambda: True,
)

View File

View File

@@ -27,7 +27,7 @@ class TestSimpleBip84Wallet(unittest.TestCase):
database_config=db_config
)
address_info = wallet.get_address(bdk.AddressIndex.LAST_UNUSED())
address = address_info.address
address = address_info.address.as_string()
# print(f"New address is {address}")
assert address == "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", f"Wrong address {address}, should be tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e"
@@ -43,6 +43,21 @@ class TestSimpleBip84Wallet(unittest.TestCase):
# print(f"Balance is {balance.total} sat")
assert balance.total > 0, "Balance is 0, send testnet coins to tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e"
def test_output_address_from_script_pubkey(self):
wallet = bdk.Wallet(
descriptor=descriptor,
change_descriptor=None,
network=bdk.Network.TESTNET,
database_config=db_config,
)
wallet.sync(blockchain, None)
first_tx = list(wallet.list_transactions(True))[0]
assert first_tx.txid == '35d3de8dd429ec4c9684168c1fbb9a4fb6db6f2ce89be214a024657a73ef4908'
output1, output2 = list(first_tx.transaction.output())
assert bdk.Address.from_script(output1.script_pubkey, bdk.Network.TESTNET).as_string() == 'tb1qw6ly2te8k9vy2mwj3g6gx82hj7hc8f5q3vry8t'
assert bdk.Address.from_script(output2.script_pubkey, bdk.Network.TESTNET).as_string() == 'tb1qzsvpnmme78yl60j7ldh9aqvhvxr4mz7mjpmh22'
if __name__ == '__main__':
unittest.main()

View File

@@ -10,6 +10,6 @@ final class BitcoinDevKitTests: XCTestCase {
let databaseConfig = DatabaseConfig.memory
let wallet = try Wallet.init(descriptor: desc, changeDescriptor: nil, network: Network.regtest, databaseConfig: databaseConfig)
let addressInfo = try wallet.getAddress(addressIndex: AddressIndex.new)
XCTAssertEqual(addressInfo.address, "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
XCTAssertEqual(addressInfo.address.asString(), "bcrt1qzg4mckdh50nwdm9hkzq06528rsu73hjxytqkxs")
}
}