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()) { 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. 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(