Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copied from [bdk-ffi](https://github.com/bitcoindevkit/bdk-ffi/blob/master/.github/workflows/test-python.yaml)
name: Build and Test Python
on:
pull_request:
paths:
- payjoin-ffi/python/**

jobs:
build-wheels-and-test:
name: "Build and test wheels with Redis"
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
defaults:
run:
working-directory: payjoin-ffi/python
strategy:
matrix:
include:
- python: "3.9"
- python: "3.10"
- python: "3.11"
- python: "3.12"
- python: "3.13"
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Install Rust 1.78.0"
uses: actions-rs/toolchain@v1
with:
toolchain: 1.78.0

- name: "Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: "Install build dependencies"
run: |
sudo apt update
sudo apt install -y build-essential python3-dev

- name: "Use cache"
uses: Swatinem/rust-cache@v2

- name: "Generate payjoin-ffi.py and binaries"
run: |
PYBIN=$(dirname $(which python))
PYBIN="$PYBIN" bash ./scripts/generate_linux.sh

- name: "Build wheel"
run: python setup.py bdist_wheel --verbose

- name: "Install wheel"
run: pip install ./dist/*.whl

- name: "Run tests"
env:
REDIS_URL: redis://localhost:6379
run: python -m unittest -v

build-macos:
name: "Build and test macOS"
runs-on: macos-13
defaults:
run:
working-directory: payjoin-ffi/python
strategy:
matrix:
python:
- "3.12"
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
submodules: true

- name: "Install Rust 1.78.0"
uses: actions-rs/toolchain@v1
with:
toolchain: 1.78.0

- name: "Install Python"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Setup Docker on macOS
uses: douglascamata/setup-docker-macos-action@v1.0.0

- name: "Install Redis"
run: |
brew update
brew install redis

- name: "Start Redis"
run: |
redis-server --daemonize yes
for i in {1..10}; do
if redis-cli ping | grep -q PONG; then
echo "Redis is ready"
break
fi
echo "Waiting for Redis..."
sleep 1
done

- name: "Use cache"
uses: Swatinem/rust-cache@v2

- name: "Generate payjoin-ffi.py and binaries"
run: bash ./scripts/generate_macos.sh

- name: "Build wheel"
run: python3 setup.py bdist_wheel --verbose

- name: "Install wheel"
run: pip3 install ./dist/*.whl

- name: "Run tests"
env:
REDIS_URL: redis://localhost:6379
run: python3 -m unittest -v
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = ["payjoin", "payjoin-cli", "payjoin-directory", "payjoin-test-utils"]
resolver = "2"
exclude = ["payjoin-ffi"]

[patch.crates-io.payjoin]
path = "payjoin"
Expand Down
2 changes: 1 addition & 1 deletion contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

DEPS="recent minimal"
CRATES="payjoin payjoin-cli payjoin-directory"
CRATES="payjoin payjoin-cli payjoin-directory payjoin-ffi"

for dep in $DEPS; do
cargo --version
Expand Down
2 changes: 1 addition & 1 deletion contrib/test_local.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

CRATES="payjoin payjoin-cli payjoin-directory"
CRATES="payjoin payjoin-cli payjoin-directory payjoin-ffi"

cargo --version
rustc --version
Expand Down
19 changes: 19 additions & 0 deletions payjoin-ffi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Cargo
# will have compiled files and executables
target/


# These are backup files generated by rustfmt
**/*.rs.bk
.vscode/settings.json
.idea

# Python related
__pycache__


/python/.vscode/
/python/payjoin.egg-info/
/python/.venv/
/python/.env
.DS_Store
84 changes: 84 additions & 0 deletions payjoin-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## [0.23.0]

- Update to payjoin-0.23.0
- Expose many error variants
([#58](https://github.com/LtbLightning/payjoin-ffi/pull/58))
([#71](https://github.com/LtbLightning/payjoin-ffi/pull/71))
- Bind payjoin-test-utils ([#82](https://github.com/LtbLightning/payjoin-ffi/pull/82))
- Depend on bitcoin-ffi @ 6b1d1315dff8696b5ffeb3e5669f308ade227749
- Rename to payjoin-ffi from payjoin_ffi to match bitcoin-ffi

## [0.22.1]
- Expose label and message params on Uri. ([#44](https://github.com/LtbLightning/payjoin-ffi/pull/44))

## [0.22.0]
- Update `payjoin` to `0.22.0`. (Serialize reply_key with Sender [#41](https://github.com/LtbLightning/payjoin-ffi/pull/41))

## [0.21.2]
- Add `pj_endpoint` method to `PjUri` types. ([#40](https://github.com/LtbLightning/payjoin-ffi/pull/40))

## [0.21.1]
- Add `to_json` and `from_json` methods to `Sender` and `Receiver` UniFFI types. ([#39](https://github.com/LtbLightning/payjoin-ffi/pull/39))

## [0.21.0]
This release updates the bindings libraries to `payjoin` version `0.21.0`.
#### APIs changed
- Major overhaul to attempt a stable BIP 77 protocol implementation.
- v1 support is now only available through the V2 backwards-compatible APIs.
- see [payjoin-0.21.0 changelog](https://github.com/payjoin/rust-payjoin/blob/master/payjoin/CHANGELOG.md#0210) for more details.
- Separate `payjoin_ffi` and `payjoin_ffi::uni` UniFFI types into two layers.

## [0.20.0]
#### APIs added
- Make backwards-compatible `v2` to `v1` sends possible.
#### APIs changed
- Removed `contribute_non_nitness_input` from `v1` & `v2`.
- Allow receivers to make `payjoins` out of sweep transactions ([#259](https://github.com/payjoin/rust-payjoin/pull/259)).
- Encode &ohttp= and &exp= parameters in the &pj= URL as a fragment instead of as URI params ([#298](https://github.com/payjoin/rust-payjoin/pull/298))

## [0.18.0]
This release updates the bindings libraries to `payjoin` version `0.18.0`.
#### APIs changed
- Upgrade `receive/v2` type state machine to resume multiple `payjoins` simultaneously ([#283](https://github.com/payjoin/rust-payjoin/pull/283))
- Refactor output substitution with new fallable `try_substitute_outputs` ([#277](https://github.com/payjoin/rust-payjoin/pull/277))
- Replaced `Enroller` with `SessionInitializer`.
- Replaced `Enrolled` with `ActiveSession`.
- Replaced `fallback_target()` with `pj_url`.
#### APIs added
- Exposed `PjUriBuilder` and `PjUri`.
- Exposed `pjUrl_builder()` in `ActiveSession`.
- Exposed `check_pj_supported()` in `PjUri`.
- Exposed `fetch_ohttp_keys()` to fetch the `ohttp` keys from the specified `payjoin` directory.

## [0.13.0]
### Features & Modules
#### Send module
- ##### V1
- `RequestBuilder` exposes `from_psbt_and_uri`, `build_with_additional_fee`, `build_recommended`, `build_non_incentivizing`, `always_disable_output_substitution`.
- `RequestContext` exposes `extract_contextV1` & `extract_contextV2`.
- `ContextV1` exposes `process_response`.
- ##### V2
- `ContextV2` exposes `process_response`.
#### Receive module
- ##### V1
- `UncheckedProposal` exposes `from_request`, `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability`, `build_non_incentivizing`,
`assume_interactive_receiver` &`always_disable_output_substitution`.
- `MaybeInputsOwned` exposes `check_inputs_not_owned`.
- `MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`.
- `MaybeInputsSeen` exposes `check_no_inputs_seen_before`.
- `OutputsUnknown` exposes `identify_receiver_outputs`.
- `ProvisionalProposal` exposes `substitute_output_address`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` &
`finalize_proposal`.
- `PayjoinProposal` exposes `is_output_substitution_disabled`, `owned_vouts`, `psbt` & `utxos_to_be_locked`.
- ##### V2
- `Enroller` exposes `from_directory_config`, `process_response` & `extract_request`.
- `Enrolled` exposes `extract_request`, `process_response` & `fall_back_target`.
- `V2UncheckedProposal` exposes `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability` & `assume_interactive_receiver`.
- `V2MaybeInputsOwned` exposes `check_inputs_not_owned`.
- `V2MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`.
- `V2MaybeInputsSeen` exposes `check_no_inputs_seen_before`.
- `V2OutputsUnknown` exposes `identify_receiver_outputs`.
- `V2ProvisionalProposal` exposes `substitute_output_address`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` &
`finalize_proposal`.
- `V2PayjoinProposal` exposes `deserialize_res`, `extract_v1_req`, `extract_v2_req`, `is_output_substitution_disabled`, `owned_vouts`, `psbt` &
`utxos_to_be_locked`.
60 changes: 60 additions & 0 deletions payjoin-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
name = "payjoin-ffi"
version = "0.23.0"
edition = "2021"
license = "MIT OR Apache-2.0"
exclude = ["tests"]

[features]
_test-utils = ["payjoin-test-utils", "tokio", "bitcoind"]
_danger-local-https = ["payjoin/_danger-local-https"]
uniffi = ["uniffi/cli", "bitcoin-ffi/default"]

[lib]
name = "payjoin_ffi"
crate-type = ["lib", "staticlib", "cdylib"]

[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[build-dependencies]
uniffi = { version = "0.29.1", features = ["build"] }

[dependencies]
base64 = "0.22.1"
bitcoind = { version = "0.36.0", features = ["0_21_2"], optional = true }
bitcoin-ffi = { git = "https://github.com/benalleng/bitcoin-ffi.git", rev = "8e3a23b" }
hex = "0.4.3"
lazy_static = "1.5.0"
ohttp = { package = "bitcoin-ohttp", version = "0.6.0" }
payjoin = { version = "0.23.0", features = ["v1", "v2", "io"] }
payjoin-test-utils = { version = "0.0.0", optional = true }
serde = { version = "1.0.200", features = ["derive"] }
serde_json = "1.0.128"
thiserror = "1.0.58"
tokio = { version = "1.38.0", features = ["full"], optional = true }
uniffi = { version = "0.29.1", optional = true }
url = "2.5.0"

[dev-dependencies]
bdk = { version = "0.29.0", features = ["all-keys", "use-esplora-ureq", "keys-bip39", "rpc"] }
bitcoincore-rpc = "0.19.0"
http = "1"
ohttp-relay = "0.0.8"
rcgen = { version = "0.11" }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
rustls = "0.22.2"
testcontainers = "0.15.0"
testcontainers-modules = { version = "0.1.3", features = ["redis"] }
uniffi = { version = "0.29.1", features = ["bindgen-tests"] }

[profile.release-smaller]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
strip = true

[patch.crates-io.payjoin]
path = "../payjoin"
Loading
Loading