From 21275f829f6c39b31fe6b9e9f0c07921eef016a6 Mon Sep 17 00:00:00 2001 From: xstoicunicornx Date: Mon, 9 Nov 2026 22:38:27 +0000 Subject: [PATCH 1/3] Stop telling --no-broadcast users to broadcast `cancel --no-broadcast` printed "Broadcast the original transaction manually", while a failed broadcast now points users at --no-broadcast to close a session whose fallback is already on chain. Following that hint led to an instruction to broadcast a transaction that may already be confirmed or have spent inputs. Say the session closed without broadcasting, and to broadcast the printed fallback only if it isn't on chain and its inputs are unspent. The sender and receiver now print the same message. --- payjoin-cli/changelog.d/cancel-no-broadcast-message.md | 3 +++ payjoin-cli/src/app/v2/mod.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 payjoin-cli/changelog.d/cancel-no-broadcast-message.md diff --git a/payjoin-cli/changelog.d/cancel-no-broadcast-message.md b/payjoin-cli/changelog.d/cancel-no-broadcast-message.md new file mode 100644 index 000000000..b7a269d9b --- /dev/null +++ b/payjoin-cli/changelog.d/cancel-no-broadcast-message.md @@ -0,0 +1,3 @@ +- `cancel --no-broadcast` now says the session closed without broadcasting + the fallback transaction, and to broadcast it only if it isn't already on + chain and its inputs are unspent. diff --git a/payjoin-cli/src/app/v2/mod.rs b/payjoin-cli/src/app/v2/mod.rs index 810a234fe..de107a542 100644 --- a/payjoin-cli/src/app/v2/mod.rs +++ b/payjoin-cli/src/app/v2/mod.rs @@ -718,7 +718,9 @@ impl App { }; if no_broadcast { - persister.print("Session cancelled. Broadcast the original transaction manually:"); + persister.print( + "Session closed without broadcasting the fallback. If it isn't already on chain and its inputs are unspent, broadcast it yourself:", + ); println!("{}", serialize_hex(pending.fallback_tx())); } else { if let Err(e) = self.wallet().broadcast_tx(pending.fallback_tx()) { @@ -813,7 +815,9 @@ impl App { }; if no_broadcast { - persister.print("Session cancelled. Broadcast the fallback transaction manually:"); + persister.print( + "Session closed without broadcasting the fallback. If it isn't already on chain and its inputs are unspent, broadcast it yourself:", + ); println!("{}", serialize_hex(pending.fallback_tx())); } else { if let Err(e) = self.wallet().broadcast_tx(pending.fallback_tx()) { From 66ae3cabf5590bdb65b4400b005cdd9b8e9697c5 Mon Sep 17 00:00:00 2001 From: xstoicunicornx Date: Mon, 9 Nov 2026 22:38:27 +0000 Subject: [PATCH 2/3] Document what closing a receiver session records The outcome a receiver records on close says whether the receiver completed its side of the Payjoin protocol and sent the Payjoin proposal, not which transaction resolved the session. A session that posted its proposal records PayjoinProposalSent even if the fallback resolved it, and the ResolvedBy classification is not persisted. Callers could otherwise expect a closed session to remember whether the Payjoin or the fallback settled it. State this in the close docs of ReceiveSession, Receiver and the FFI close_session. --- payjoin-ffi/src/receive/mod.rs | 7 +++++++ payjoin/src/core/receive/v2/mod.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/payjoin-ffi/src/receive/mod.rs b/payjoin-ffi/src/receive/mod.rs index a602cd977..36ce33433 100644 --- a/payjoin-ffi/src/receive/mod.rs +++ b/payjoin-ffi/src/receive/mod.rs @@ -229,6 +229,13 @@ macro_rules! impl_resolution_for_receiver { /// [`classify_tx`](Self::classify_tx) once its transaction has /// enough confirmations. /// + /// The recorded [`ReceiverSessionOutcome`] says whether the receiver + /// completed its side of the Payjoin protocol and sent the Payjoin + /// proposal, not which transaction resolved the session. It is + /// `PayjoinProposalSent` if the proposal was posted or the Payjoin + /// resolved the session, and `Aborted` otherwise. The session does + /// not persist the [`ResolvedBy`] classification. + /// /// Returns a [`CloseTransition`] that, once persisted, closes the /// receiver session. pub fn close_session(&self, resolution: Arc) -> CloseTransition { diff --git a/payjoin/src/core/receive/v2/mod.rs b/payjoin/src/core/receive/v2/mod.rs index f9f258375..9103be3e4 100644 --- a/payjoin/src/core/receive/v2/mod.rs +++ b/payjoin/src/core/receive/v2/mod.rs @@ -221,6 +221,12 @@ impl ReceiveSession { /// Call this with the [`Resolution`] returned by [`classify_tx`](Self::classify_tx) once its /// transaction has enough confirmations. /// + /// The recorded [`SessionOutcome`] says whether the receiver completed its side of the Payjoin + /// protocol and sent the Payjoin proposal, not which transaction resolved the session. It is + /// [`SessionOutcome::PayjoinProposalSent`] if the proposal was posted or the Payjoin resolved + /// the session, and [`SessionOutcome::Aborted`] otherwise. The session does not persist the + /// [`ResolvedBy`] classification. + /// /// Returns a [`MaybeTerminalSuccessTransition`] that, once successfully persisted, closes the /// receiver session. pub fn close( @@ -685,6 +691,12 @@ impl Receiver { /// Call this with the [`Resolution`] returned by [`classify_tx`](Self::classify_tx) once its /// transaction has enough confirmations. /// + /// The recorded [`SessionOutcome`] says whether the receiver completed its side of the Payjoin + /// protocol and sent the Payjoin proposal, not which transaction resolved the session. It is + /// [`SessionOutcome::PayjoinProposalSent`] if the proposal was posted or the Payjoin resolved + /// the session, and [`SessionOutcome::Aborted`] otherwise. The session does not persist the + /// [`ResolvedBy`] classification. + /// /// Returns a [`MaybeTerminalSuccessTransition`] that, once successfully persisted, closes the /// receiver session. pub fn close( From 014e0e3f5dcaf95d59a506d74ecab267b5a556d3 Mon Sep 17 00:00:00 2001 From: xstoicunicornx Date: Mon, 9 Nov 2026 23:23:00 +0000 Subject: [PATCH 3/3] Add FFI migration notes for check_for_transaction payjoin-ffi removed Monitor.check_for_transaction outright, and the classify-tx fragment only names the replacement. Apps moving to classify_tx and close_session also need to know what changed in behavior. The recorded outcome no longer carries the txid or which transaction settled. Classification ignores confirmations. A Resolution does not survive a restart. Malformed bytes raise TransactionParseError. The bindings have no separate migration guide, and payjoin-ffi/CHANGELOG.md is their release notes, so list these in a changelog fragment. --- .../changelog.d/check-for-transaction-migration.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 payjoin-ffi/changelog.d/check-for-transaction-migration.md diff --git a/payjoin-ffi/changelog.d/check-for-transaction-migration.md b/payjoin-ffi/changelog.d/check-for-transaction-migration.md new file mode 100644 index 000000000..7fcb46ec0 --- /dev/null +++ b/payjoin-ffi/changelog.d/check-for-transaction-migration.md @@ -0,0 +1,13 @@ +- To migrate from `Monitor.check_for_transaction`: + - `close_session` on a `Monitor` records `PayjoinProposalSent` whichever + transaction resolved the session, where `check_for_transaction` recorded + `Success(txid)` or `FallbackBroadcasted`. Store `resolved_by` and the + txid yourself if the app needs them. + - `classify_tx` also classifies unconfirmed transactions. Call + `close_session` only once the transaction reaches the wallet's + confirmation depth. + - Non-SegWit senders no longer need special handling. + - A `Resolution` can't be persisted, so classify the transaction again + after a restart. + - `classify_tx` raises `TransactionParseError` for bytes that don't decode + as a transaction.