LtbLightning / payjoin-ffi

Other
11 stars 8 forks source link

Payjoin Language Bindings

Welcome! This repository creates libraries for various programming languages, all using the Rust-based Payjoin as the core implementation of BIP178, sourced from the Payjoin Dev Kit.

Our mission is to provide developers with cross-language libraries that seamlessly integrate with different platform languages. By offering support for multiple languages, we aim to enhance the accessibility and usability of Payjoin, empowering developers to incorporate this privacy-enhancing feature into their applications, no matter their preferred programming language.

With a commitment to collaboration and interoperability, this repository strives to foster a more inclusive and diverse ecosystem around Payjoin and BIP178, contributing to the wider adoption of privacy-focused practices within the Bitcoin community. Join us in our mission to build a more private and secure future for Bitcoin transactions through Payjoin and BIP178!

Current Status: This project is in the pre-alpha stage and currently in the design phase. The first language bindings available will be for Python, followed by Swift and Kotlin. Our ultimate goal is to provide Payjoin implementations for Android, iOS, Java, React, Python Native, Flutter, C#, and Golang.

Supported Target Languages and Platforms

Each supported language and the platform(s) it's packaged for has its own directory. The Rust code in this project is in the src directory and is a wrapper around the [Payjoin Dev Kit] to expose its APIs uniformly using the [mozilla/uniffi-rs] bindings generator for each supported target language.

The directories below include instructions for using, building, and publishing the native language bindings for [Payjoin Dev Kit] supported by this project.

Language Platform Published Package Building Documentation API Docs
Python linux, macOS, Windows payjoin Readme payjoin

Minimum Supported Rust Version (MSRV)

This library should compile with any combination of features with Rust 1.78.0.

Using the Libraries

Python

pip install payjoin

Running the Integration Test

First, we need to set up bitcoin core and esplora locally in the regtest network. If you don't have these, please refer to this page. Alternatively, you can install Nigiri Bitcoin, a tool designed to simplify the process of running local instances of Bitcoin and Liquid networks for development and testing purposes. Follow the instructions here to install it on your machine.

Once Nigiri Bitcoin is up and running, you need to mine a few blocks. Refer to this link on how to mine blocks.

Before running the integration tests, replace the following snippet in tests/bdk_integration_test.rs and tests/bitcoin_core_integration_test.rs with your Nigiri Bitcoin Core credentials:

static RPC_USER: &str = "admin1";
static RPC_PASSWORD: &str = "123";
static RPC_HOST: &str = "localhost";
static RPC_PORT: &str = "18443";

NB: The default nigiri credentials would be the following

rpc_user = "admin1"
rpc_password = "123"
rpc_host = "localhost"
rpc_port = "18443"

Now, run the integration tests:

The integration tests illustrates and verify integration using bitcoin core and with bitcoin dev kit(bdk).


# Run the integration test
cargo test --package payjoin_ffi --test bitcoin_core_integration_test v1_to_v1_full_cycle
cargo test --package payjoin_ffi --test bdk_integration_test v1_to_v1_full_cycle
cargo test  --package payjoin_ffi --test bdk_integration_test v2_to_v2_full_cycle --features enable-danger-local-https

References

Payjoin Dev Kit

mozilla/uniffi-rs

Release Status and Disclaimer

This project is in active development and currently in its Alpha stage. Please proceed with caution, particularly when using real funds. We encourage thorough review, testing, and contributions to help improve its stability and security before considering production use.