From a5b4e2fdfff137961e70c1d94d5606acf34ddf60 Mon Sep 17 00:00:00 2001 From: DanGould Date: Mon, 1 Jun 2026 16:18:45 +0800 Subject: [PATCH 1/2] docs(v2): Clarify create_post_request branches The doc-comment claimed an OHTTP-encapsulated POST request, but the function branches on the sender's reply key: v2 senders get an HPKE-encrypted POST to the sender's reply mailbox, while v1 (BIP 78-compat) senders get a cleartext PUT to the receiver's own mailbox. Document both paths. Note: the function is not renamed because the POST/PUT distinction only applies to the OHTTP-encapsulated request. The request to the OHTTP Relay is still POST, only the inner message is distinguished. Refs #1487. Companion to a bitcoin/bips spec patch aligning BIP 77 Backwards Compatibility with the implemented behavior. --- payjoin/src/core/receive/v2/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/payjoin/src/core/receive/v2/mod.rs b/payjoin/src/core/receive/v2/mod.rs index 2c3f1bd5b..b22658d0a 100644 --- a/payjoin/src/core/receive/v2/mod.rs +++ b/payjoin/src/core/receive/v2/mod.rs @@ -1137,7 +1137,20 @@ impl Receiver { /// The Payjoin Proposal PSBT. pub fn psbt(&self) -> &Psbt { &self.psbt_context.payjoin_psbt } - /// Construct an OHTTP Encapsulated HTTP POST request for the Proposal PSBT + /// Construct an OHTTP-encapsulated HTTP request carrying the Proposal PSBT. + /// + /// The inner HTTP method, body encoding, and target mailbox depend on + /// whether the original sender used Payjoin v2 (BIP 77) or Payjoin v1 + /// (BIP 78), as recorded in the session context: + /// + /// - v2 sender (reply key present): POST an HPKE-encrypted `PjV2MsgB` + /// payload to the sender's reply mailbox. + /// - v1 sender (no reply key): PUT the base64-encoded PSBT as cleartext + /// UTF-8 bytes to the receiver's own mailbox, per the + /// [BIP 77](https://github.com/bitcoin/bips/blob/master/bip-0077.md) + /// Backwards compatibility section. + /// + /// Both paths are then OHTTP-encapsulated to the directory's OHTTP Gateway. pub fn create_post_request( &self, ohttp_relay: impl IntoUrl, From 5d70e3f6258a786456a4a7e9c924eee3a781fad9 Mon Sep 17 00:00:00 2001 From: DanGould Date: Mon, 1 Jun 2026 16:57:15 +0800 Subject: [PATCH 2/2] docs(ffi): Clarify create_post_request branches Mirror the doc-comment fix on the core method so the FFI binding exposes the same v2-vs-v1 branching semantics across the C#, Python, Dart, and JavaScript surfaces. Refs #1487. --- payjoin-ffi/src/receive/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/payjoin-ffi/src/receive/mod.rs b/payjoin-ffi/src/receive/mod.rs index 47d9833f0..d2eba6686 100644 --- a/payjoin-ffi/src/receive/mod.rs +++ b/payjoin-ffi/src/receive/mod.rs @@ -1239,7 +1239,20 @@ impl PayjoinProposal { .to_string() } - /// Construct an OHTTP Encapsulated HTTP POST request for the Proposal PSBT + /// Construct an OHTTP-encapsulated HTTP request carrying the Proposal PSBT. + /// + /// The inner HTTP method, body encoding, and target mailbox depend on + /// whether the original sender used Payjoin v2 (BIP 77) or Payjoin v1 + /// (BIP 78), as recorded in the session context: + /// + /// - v2 sender (reply key present): POST an HPKE-encrypted `PjV2MsgB` + /// payload to the sender's reply mailbox. + /// - v1 sender (no reply key): PUT the base64-encoded PSBT as cleartext + /// UTF-8 bytes to the receiver's own mailbox, per the + /// [BIP 77](https://github.com/bitcoin/bips/blob/master/bip-0077.md) + /// Backwards compatibility section. + /// + /// Both paths are then OHTTP-encapsulated to the directory's OHTTP Gateway. pub fn create_post_request( &self, ohttp_relay: String,