16 releases (breaking)

0.15.0 Mar 19, 2024
0.13.0 Jan 4, 2024
0.12.0 Dec 14, 2023
0.11.0 Nov 29, 2023
0.5.0-alpha Dec 29, 2022

#761 in Magic Beans

Download history 305/week @ 2024-01-01 187/week @ 2024-01-08 119/week @ 2024-01-15 217/week @ 2024-01-22 100/week @ 2024-01-29 267/week @ 2024-02-05 187/week @ 2024-02-12 552/week @ 2024-02-19 162/week @ 2024-02-26 207/week @ 2024-03-04 65/week @ 2024-03-11 397/week @ 2024-03-18 193/week @ 2024-03-25 676/week @ 2024-04-01 244/week @ 2024-04-08 126/week @ 2024-04-15

1,253 downloads per month
Used in 4 crates (3 directly)

MITNFA license

190KB
3.5K SLoC

Payjoin implementation in Rust

About

This is a library and a client binary for bitcoind implementing BIP78 Payjoin.

The library is perfectly IO-agnostic—in fact, it does no IO. The primary goal of such design is to be easy to unit test. While not there yet, it already has infinitely more tests than the Payjoin PR against Electrum. :P

It doesn't care whether you use async, blocking, tokio, sync-std hyper, actix or whatever. There are already too many frameworks in Rust so it's best avoiding directly introducing them into library code. The library currently only contains sender implementation and a partial receiver.

The payjoin-cli binary performs no-frills Payjoin using Bitcoin Core wallet. The payjoin crate also supports other wallet software like LND.

Disclaimer ⚠️ WIP

Use at your own risk. this crate has not yet been reviewed by independent Rust and Bitcoin security professionals.

While I don't think there is a huge risk running it, don't rely on its security for now!

Seeking review of the code that verifies there is no overpayment. Contributions are welcome!

Development status

Sender (beta)

  • Basic logic
  • Most checks implemented
  • Documentation
  • Unit test with official test vectors passes
  • Many unit tests
  • Fee contribution support
  • Example client using bitcoind
  • Tested and works with BTCPayServer
  • Tested and works with JoinMarket
  • Minimum fee rate enforcement
  • Independent review
  • Independent testing

Receiver (beta)

  • Basic logic
  • Most checks implemented
  • Documentation
  • Unit test with official test vectors passes
  • Many unit tests
  • Fee contribution support
  • Example server using bitcoind
  • Tested and works with BTCPayServer
  • Tested and works with WasabiWallet
  • Tested and works with Blue Wallet
  • Tested and works with Sparrow
  • Minimum fee rate enforcement
  • Discount support
  • Independent review
  • Independent testing

Code quality

  • Idiomatic Rust code
  • Newtypes
  • Panic-free error handling
  • No unsafe code or well-tested/analyzed/proven/... unsafe code
  • Warning-free
  • CI
  • Integration tests
  • Fuzzing
  • Coverage measurement

Minimum Supported Rust Version (MSRV)

The payjoin library and payjoin-cli should always compile with any combination of features on Rust 1.63.0.

To build and test with the MSRV you will need to pin the below dependency versions:

payjoin

cargo update -p regex --precise 1.9.6
cargo update -p which --precise 4.4.0

payjoin-cli

cargo update -p clap_lex --precise 0.3.0
cargo update -p regex --precise 1.9.6
cargo update -p which --precise 4.4.0
cargo update -p time@0.3.34 --precise 0.3.20

License

MIT

Dependencies

~10MB
~170K SLoC