Skip to content

Commit

Permalink
Merge pull request LtbLightning#28 from LtbLightning/fix-bdk-integration
Browse files Browse the repository at this point in the history
Fix bdk integration
  • Loading branch information
BitcoinZavior authored Jun 16, 2024
2 parents bfd3bb0 + 8d5498c commit 399046f
Show file tree
Hide file tree
Showing 25 changed files with 1,093 additions and 1,244 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ uniffi = { version = "0.27.1", features = ["bindgen-tests"] }
bdk = { version = "0.29.0", features = ["all-keys", "use-esplora-ureq", "keys-bip39"] }
bitcoincore-rpc = "0.18.0"
[dependencies]
#https://github.com/payjoin/rust-payjoin/commit/e7037b23b0f29beda39f5e161d3d7924d2060dd4
payjoin = { git= "https://github.com/payjoin/rust-payjoin", rev = "e7037b23b0f29beda39f5e161d3d7924d2060dd4", features = ["send", "receive", "base64", "v2"] }
#https://github.com/payjoin/rust-payjoin/commit/457a0dd5cb212ddd9ea169b7fa3842bfc3d5f373
payjoin = { git= "https://github.com/payjoin/rust-payjoin", rev = "457a0dd5cb212ddd9ea169b7fa3842bfc3d5f373", features = ["send", "receive", "base64", "v2"] }
uniffi = { version = "0.27.1" }
thiserror = "1.0.47"
ohttp = { version = "0.5.1" }
url = "2.5.0"
base64 = "0.22.1"
hex = "0.4.3"


[[bin]]
Expand All @@ -40,3 +41,4 @@ strip = true

[features]
default = ["uniffi/cli"]
uniffi=[]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ rpc_port = "18443"
```

Now, run the integration tests:
The integration tests illustrates and verify integration using bitcoin core and with bitcoin dev kit(bdk).


```shell

Expand Down
3 changes: 2 additions & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__/

*.swp
*.whl
build/
build/
venv
36 changes: 16 additions & 20 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Payjoin

Welcome to the Python language bindings for the [Payjoin Dev Kit](https://payjoindevkit.org/)! Let's get you up and running with some smooth transactions and a sprinkle of fun.
The Python language bindings for the [Payjoin Dev Kit](https://payjoindevkit.org/).

## Install from PyPI

Grab the latest release with a simple:
Install the latest release using

```shell
pip install payjoin
```

## Running Unit Tests
Follow these steps to clone the repository and run the unit tests:
## Run the unit tests

```shell

Expand All @@ -28,33 +27,34 @@ python setup.py bdist_wheel --verbose
# Force reinstall payjoin
pip install ./dist/payjoin-<version>.whl --force-reinstall

# Run unit tests
#Run unit tests
python -m unittest --verbose test/payjoin_unit_test.py

```

## Running the Integration Test
## Run the integration test

Before diving into the integration test, you'll need to set up Bitcoin Core on the regtest network. If you don't have Bitcoin Core installed locally, check out [this installation guide](https://learn.saylor.org/mod/page/view.php?id=36347). Alternatively, you can use `Nigiri Bitcoin`, a tool designed to streamline the process of running local instances of Bitcoin and Liquid networks for development and testing. Follow the instructions [here](https://github.com/vulpemventures/nigiri) to install it on your machine.
Before running the integration test, we need to set up the Bitcoin core properly in the regtest network. If you don't
have Bitcoin Core locally, please refer to this [page](https://learn.saylor.org/mod/page/view.php?id=36347). Or you can
install `Nigiri Bitcoin`, which is a tool designed to simplify the process of running local instances of Bitcoin and
Liquid networks for development and testing purposes. You can refer to
this [link](https://github.com/vulpemventures/nigiri), to install it on your local machine.

Once Nigiri Bitcoin is up and running, replace the following snippet in `payjoin_integration_test.py` with your `Nigiri Bitcoin` Core credentials:
Once the nigiri bitcoin starts running, please replace following snippet in `payjoin_integration_test.py`, with you
nigiri bitcoin core credentials.

```
rpc_user = "bitcoin"
rpc_password = "bitcoin"
```

By default, these credentials are:
NB: The default credentials would be the following

```
rpc_user = "admin1"
rpc_password = "123"
rpc_host = "localhost"
rpc_port = "18443"
```
Now, proceed with the integration test:

```shell

Expand All @@ -71,12 +71,11 @@ python setup.py bdist_wheel --verbose
# Force reinstall payjoin
pip install ./dist/payjoin-<version>.whl --force-reinstall

# Run the integration test
#Run the integration test
python -m unittest --verbose test/payjoin_integration_test.py

```

## Building the Package
## Build the package

```shell
# Install dependencies
Expand All @@ -87,7 +86,4 @@ bash ./scripts/generate_macos.sh

# Build the wheel
python setup.py --verbose bdist_wheel

```
We hope everything worked smoothly! Now go forth test, and may your test results be as reliable as the Bitcoin blockchain itself!
₿🔒🤝
```
8 changes: 4 additions & 4 deletions python/scripts/generate_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ python3 --version
pip install --user -r requirements.txt

LIBNAME=libpayjoin_ffi.so
LINUX_TARGET=x86_64-unknown-linux-gnu


echo "Generating payjoin_ffi.py..."
cd ../
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/ --no-format
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/


echo "Generating native binaries..."
rustup target add $LINUX_TARGET
cargo build --profile release-smaller --target $LINUX_TARGET
rustup target add x86_64-unknown-linux-gnu
cargo build --profile release-smaller --target x86_64-unknown-linux-gnu --features uniffi

echo "Copying linux payjoin_ffi.so"
cp target/$LINUX_TARGET/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME
Expand Down
4 changes: 2 additions & 2 deletions python/scripts/generate_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ LIBNAME=libpayjoin_ffi.dylib

echo "Generating payjoin_ffi.py..."
cd ../
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/ --no-format
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/


echo "Generating native binaries..."
rustup target add aarch64-apple-darwin x86_64-apple-darwin

cargo build --profile release-smaller --target aarch64-apple-darwin
cargo build --profile release-smaller --target aarch64-apple-darwin --features uniffi
echo "Done building aarch64-apple-darwin"

cargo build --profile release-smaller --target x86_64-apple-darwin
Expand Down
7 changes: 3 additions & 4 deletions python/scripts/generate_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ python3 --version
pip install --user -r requirements.txt

LIBNAME=payjoin_ffi.dll
WINDOWS_TARGET=x86_64-pc-windows-gnu

echo "Generating payjoin_ffi.py..."
cd ../
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/ --no-format
cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/


echo "Generating native binaries..."
rustup target add $WINDOWS_TARGET
cargo build --profile release-smaller --target $WINDOWS_TARGET
rustup target add x86_64-pc-windows-gnu
cargo build --profile release-smaller --target x86_64-pc-windows-gnu --features uniffi

echo "Copying windows payjoin_ffi.dll"
cp target/$WINDOWS_TARGET/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME
Expand Down
4 changes: 2 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
description="The Python language bindings for the Payjoin Dev Kit",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
include_package_data = True,
include_package_data=True,
zip_safe=False,
packages=["payjoin"],
package_dir={"payjoin": "./src/payjoin"},
version='0.1.0.dev',
version='0.13.dev.0',
license="MIT or Apache 2.0",
has_ext_modules=lambda: True,
)
Binary file modified python/src/payjoin/libpayjoin_ffi.dylib
Binary file not shown.
Binary file modified python/src/payjoin/libpayjoin_ffi.so
Binary file not shown.
Binary file modified python/src/payjoin/payjoin_ffi.dll
Binary file not shown.
Loading

0 comments on commit 399046f

Please sign in to comment.