Skip to content

Commit 6396e6a

Browse files
authored
Refine Repo README and payjoin lib.rs (#1248)
2 parents 013615b + 1032df9 commit 6396e6a

File tree

3 files changed

+71
-89
lines changed

3 files changed

+71
-89
lines changed

README.md

Lines changed: 23 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<a href="https://github.com/payjoin/rust-payjoin/actions/workflows/rust.yml"><img alt="CI Status" src="https://github.com/payjoin/rust-payjoin/actions/workflows/rust.yml/badge.svg"></a>
1414
<a href="https://coveralls.io/github/payjoin/rust-payjoin?branch=master"><img src="https://coveralls.io/repos/github/payjoin/rust-payjoin/badge.svg?branch=master"/></a>
1515
<a href="https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/"><img alt="Rustc Version 1.85.0+" src="https://img.shields.io/badge/rustc-1.85.0%2B-lightgrey.svg"/></a>
16+
<a href="https://discord.gg/6rJD9R684h"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
1617
</p>
1718

1819
<h4>
@@ -22,90 +23,51 @@
2223

2324
## About
2425

25-
### `payjoin`
26+
`payjoin/rust-payjoin` contains multiple crates implementing Payjoin as defined in [BIP 77: Async Payjoin](https://github.com/bitcoin/bips/blob/master/bip-0077.mediawiki) and [BIP 78: Simple Payjoin](https://github.com/bitcoin/bips/blob/master/bip-0078.md), and associated OHTTP Relay and Payjoin Directory infrastructure.
2627

27-
The Payjoin Dev Kit `payjoin` library implements both [BIP 78 Payjoin V1](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki) and [BIP 77 Payjoin V2](https://github.com/bitcoin/bips/blob/master/bip-0077.md).
28+
Find the description of each crate below.
2829

29-
### `payjoin-cli`
30+
### [`payjoin`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin)
3031

31-
The [`payjoin-cli`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-cli) crate performs no-frills Payjoin as a reference implementation using Bitcoin Core wallet.
32+
The main Payjoin Dev Kit library which provides tools for implementing both Async and Simple Payjoin. `payjoin` implements Payjoin session persistence support and IO utilities for interacting with OHTTP relays in Async Payjoin integrations.
3233

33-
### `payjoin-directory`
34+
**Disclaimer: This crate has not been reviewed by independent Rust and Bitcoin security professionals (yet). Use at your own risk.**
3435

35-
The [`payjoin-directory`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-directory) crate implements the Payjoin Directory store-and-forward server required for Payjoin V2's asynchronous operation.
36+
### [`payjoin-cli`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-cli)
3637

37-
### `payjoin-test-utils`
38+
A CLI tool which performs no-frills Payjoin. It is a reference implementation of the Payjoin Dev Kit which uses a Bitcoin Core wallet.
3839

39-
The [`payjoin-test-utils`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-test-utils) crate provides commonly used testing fixtures such as a local OHTTP relay and payjoin directory, bitcoind node and wallets, and official test vectors.
40+
### [`ohttp-relay`](https://github.com/payjoin/rust-payjoin/tree/master/ohttp-relay)
4041

41-
### `payjoin-ffi`
42+
A Rust implementation of an Oblivious HTTP (OHTTP) relay resource.
4243

43-
The [`payjoin-ffi`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-ffi) crate provides language bindings that expose the Rust-based Payjoin implementation to various programming languages.
44+
**Disclaimer: Both this crate and the [IETF paper](https://ietf-wg-ohai.github.io/oblivious-http/draft-ietf-ohai-ohttp.html) are undergoing active revision. Use at your own risk.**
4445

45-
### Disclaimer ⚠️ WIP
46+
### [`payjoin-directory`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-directory)
4647

47-
**Use at your own risk. This crate has not yet been reviewed by independent Rust and Bitcoin security professionals.**
48+
A reference implementation for a Payjoin Directory which stores and forwards HTTP client messages between the sender and the receiver to allow for Async Payjoin transactions. Async Payjoin clients make requests to the directory using [Oblivious HTTP (OHTTP)](https://www.ietf.org/rfc/rfc9458.html) which prevents the directory from being able to link payjoins to specific client IP addresses.
4849

49-
While I don't think there is a _huge_ risk running it, be careful relying on its security for now!
50+
### [`payjoin-test-utils`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-test-utils)
5051

51-
Seeking review of the code that verifies there is no overpayment. Contributions are welcome!
52+
The test utilities library which provides commonly used testing fixtures such as a local OHTTP relay and Payjoin directory, bitcoind node and wallets, and official test vectors.
5253

53-
### Development status
54+
### [`payjoin-ffi`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-ffi)
5455

55-
#### Sender (V1 beta, V2 alpha)
56+
The language bindings which expose the Rust-based Payjoin implementation to various programming languages.
5657

57-
- [x] Basic logic
58-
- [x] Most checks implemented
59-
- [x] Documentation
60-
- [x] Unit test with official test vectors passes
61-
- [x] Many unit tests
62-
- [x] Fee contribution support
63-
- [x] Example client using bitcoind
64-
- [x] Tested and works with BTCPayServer
65-
- [x] Tested and works with JoinMarket
66-
- [x] Minimum fee rate enforcement
67-
- [ ] Independent review
68-
- [x] Independent testing
58+
Currently supported languages:
6959

70-
#### Receiver (V1 beta, V2 alpha)
71-
72-
- [x] Basic logic
73-
- [x] Most checks implemented
74-
- [x] Documentation
75-
- [x] Unit test with official test vectors passes
76-
- [x] Many unit tests
77-
- [x] Fee contribution support
78-
- [x] Example server using bitcoind
79-
- [x] Tested and works with BTCPayServer
80-
- [x] Tested and works with WasabiWallet
81-
- [x] Tested and works with Blue Wallet
82-
- [x] Tested and works with Sparrow
83-
- [x] Tested and works with JoinMarket
84-
- [x] Minimum fee rate enforcement
85-
- [ ] Discount support
86-
- [ ] Independent review
87-
- [ ] Independent testing
88-
89-
#### Code quality
90-
91-
- [x] Idiomatic Rust code
92-
- [x] Newtypes
93-
- [x] Panic-free error handling
94-
- [x] No `unsafe` code or well-tested/analyzed/proven/... `unsafe` code
95-
- [x] Warning-free
96-
- [x] CI
97-
- [x] Integration tests
98-
- [ ] Fuzzing
99-
- [x] Coverage measurement
100-
- [x] Mutation testing
60+
- Dart
61+
- Javascript
62+
- Python
10163

10264
## Minimum Supported Rust Version (MSRV)
10365

104-
The `payjoin` library and `payjoin-cli` should always compile with any combination of features on Rust **1.85.0**.
66+
All crates in this repository should always compile with any combination of features on Rust **1.85.0**.
10567

10668
## Contributing
10769

108-
See [`CONTRIBUTING.md`](.github/CONTRIBUTING.md)
70+
See [`CONTRIBUTING.md`](.github/CONTRIBUTING.md).
10971

11072
## License
11173

payjoin/src/core/receive/v2/mod.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,15 @@ impl ReceiverBuilder {
346346
pub struct Initialized {}
347347

348348
impl Receiver<Initialized> {
349-
/// construct an OHTTP Encapsulated HTTP GET request for the Original PSBT
349+
/// Create an OHTTP encapsulated HTTP GET request to poll for the Original PSBT
350+
/// from the Payjoin Directory.
351+
///
352+
/// After the receiver extracts the Payjoin URI with [`Receiver<Initialized>::pj_uri`] and sends it
353+
/// to the sender, they should poll the Payjoin Directory in the PJ URI for the sender's
354+
/// Original PSBT.
355+
///
356+
/// Requests created with this function are OHTTP encapsulated for the configured directory and
357+
/// addressed to the `ohttp_relay` parameter.
350358
pub fn create_poll_request(
351359
&self,
352360
ohttp_relay: impl IntoUrl,
@@ -360,8 +368,14 @@ impl Receiver<Initialized> {
360368
Ok((req, ohttp_ctx))
361369
}
362370

363-
/// The response can either be an UncheckedOriginalPayload or an ACCEPTED message
364-
/// indicating no UncheckedOriginalPayload is available yet.
371+
/// Process the response to the Original PSBT poll from the Payjoin Directory.
372+
///
373+
/// The response can either be an [`UncheckedOriginalPayload`] or an ACCEPTED message
374+
/// indicating no [`UncheckedOriginalPayload`] is available yet.
375+
///
376+
/// If the response contains the Original PSBT from the sender, transition to the next
377+
/// typestate. If the response is an ACCEPTED message from the directory which indicates that
378+
/// no payload is available yet, continue to poll.
365379
pub fn process_response(
366380
self,
367381
body: &[u8],

payjoin/src/lib.rs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
2-
3-
//! # Payjoin implementation in Rust
4-
//!
5-
//! Supercharge payment batching to save you fees and preserve your privacy.
6-
//!
7-
//! This library implements both [BIP 78 Payjoin V1](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki) and [BIP 77 Payjoin V2](https://github.com/bitcoin/bips/blob/master/bip-0077.md).
8-
//!
9-
//! Only the latest BIP 77 Payjoin V2 is enabled by default. To use BIP 78 Payjoin V1, enable the `v1` feature.
10-
//!
11-
//! The library API is organized by protocol version and operation type:
12-
//! - Sending Payjoins: [`send::v1`] and [`send::v2`] modules
13-
//! - Receiving Payjoins: [`receive::v1`] and [`receive::v2`] modules
14-
//!
15-
//! The library is perfectly IO-agnostic — in fact, it does no IO by default without the `io` feature.
16-
//!
17-
//! Types relevant to a Payjoin Directory as defined in BIP 77 are available in the [`directory`] module enabled by
18-
//! the `directory` feature.
19-
//!
20-
//! ## Example Usage
21-
//!
22-
//! See [payjoin-cli](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-cli) for a complete example of sending and receiving payjoins using both protocol versions.
23-
//!
24-
//! ## Disclaimer ⚠️ WIP
25-
//!
26-
//! **Use at your own risk. This crate has not yet been reviewed by independent Rust and Bitcoin security professionals.**
2+
#![cfg_attr(
3+
docsrs,
4+
doc(
5+
html_logo_url = "https://raw.githubusercontent.com/payjoin/rust-payjoin/master/static/monad.svg"
6+
)
7+
)]
8+
//! # Rust Payjoin Library
9+
//!
10+
//! The main Payjoin Dev Kit (PDK) library which implements Async Payjoin. The library implements
11+
//! Payjoin session persistence support and IO utilities for interacting with OHTTP relays to make
12+
//! integration plug-and-play.
13+
//!
14+
//! Both sender and receiver construct design follow [The Typestate Pattern in Rust](https://cliffle.com/blog/rust-typestate/),
15+
//! where higher-level [`Sender`] and [`Receiver`] structs are transitioned through
16+
//! consecutive states which represent a specific step they can be on over the course of a Payjoin
17+
//! session. See the documentation of state implementations for more information.
18+
//!
19+
//! ## Cargo Features
20+
//! - `v2`: all constructs for [BIP 77: Async Payjoin](https://github.com/bitcoin/bips/blob/master/bip-0077.md)
21+
//! send and receive operations. Note that IO for fetching OHTTP keys from the Payjoin directory is not enabled here,
22+
//! and requires you to bring your own implementation and HTTP client unless you choose to use ours
23+
//! with the `io` feature.
24+
//! - `v1`: all constructs for [BIP 78: Simple Payjoin](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki)
25+
//! send and receive operations.
26+
//! - `io`: helper functions for fetching and parsing OHTTP keys.
27+
//! - `directory`: type for identifying Payjoin Directory entries as defined in BIP 77.
28+
//!
29+
//! Only the `v2` feature is enabled by default.
30+
//!
31+
//! [`Sender`]: crate::send::v2::Sender
32+
//! [`Receiver`]: crate::receive::v2::Receiver
2733
2834
#[cfg(not(any(feature = "directory", feature = "v1", feature = "v2")))]
2935
compile_error!("At least one of the features ['directory', 'v1', 'v2'] must be enabled");

0 commit comments

Comments
 (0)