Skip to content

Sender closed variant#1129

Merged
spacebear21 merged 2 commits intopayjoin:masterfrom
benalleng:sender-closed-variant
Oct 1, 2025
Merged

Sender closed variant#1129
spacebear21 merged 2 commits intopayjoin:masterfrom
benalleng:sender-closed-variant

Conversation

@benalleng
Copy link
Collaborator

By adding a Closed state for sender SessionEvents we can consolidate
the failed, succeded, and canceled states into one enum to keep
eveyrting more concise and clear.

The Session outcomes are as follows, ReceivedProposalPsbt(bitcoin::psbt) which
represents the success state, FailedSession(String) wich represntes
the failure state and accepts an error string, and Cancel which
represents a manual cancel.

Addresses some of #1119

Pull Request Checklist

Please confirm the following before requesting review:

@benalleng benalleng requested a review from spacebear21 October 1, 2025 17:59
@benalleng benalleng force-pushed the sender-closed-variant branch from 60b9209 to 88d1d1e Compare October 1, 2025 18:07
@coveralls
Copy link
Collaborator

coveralls commented Oct 1, 2025

Pull Request Test Coverage Report for Build 18175422394

Details

  • 55 of 68 (80.88%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.004%) to 84.565%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/send/v2/session.rs 53 56 94.64%
payjoin/src/core/send/v2/mod.rs 2 12 16.67%
Files with Coverage Reduction New Missed Lines %
payjoin/src/core/send/error.rs 4 39.0%
Totals Coverage Status
Change from base Build 18174515746: 0.004%
Covered Lines: 8700
Relevant Lines: 10288

💛 - Coveralls

@benalleng benalleng force-pushed the sender-closed-variant branch from 88d1d1e to 9da6ee4 Compare October 1, 2025 18:10
@benalleng benalleng mentioned this pull request Oct 1, 2025
3 tasks
Copy link
Collaborator

@arminsabouri arminsabouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach Ack. Two small nits

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ReceivedProposalPsbt is a distinct event from a successful session closure. We might need to expose a function allowing implementers to mark a send session as closed successfully if monitoring won't be part of the sender state machinery?

Comment on lines 115 to 130
/// Closed successful or failed session
Closed(SessionOutcome),
}

/// Represents all possible outcomes for a closed Payjoin session
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub enum SessionOutcome {
/// Payjoin completed successfully
ReceivedProposalPsbt(bitcoin::Psbt),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ReceivedProposalPsbt should be a distinct SessionEvent from SessionOutcome::Success: we could receive the proposal psbt but the fallback transaction still got broadcasted in the meantime. That would result in a SessionEvent::ReceivedProposalPsbt and SessionEvent::Failure

Copy link
Collaborator Author

@benalleng benalleng Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be a different Closed Outcome or remain an active Event?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We concluded that ReceivedProposalPsbt should not yet be treated as a Closed Event as a fallback could come in the meantime and thus the transaction would ultimately be successful but the payjoin would still be considered a failure.

@benalleng benalleng force-pushed the sender-closed-variant branch 3 times, most recently from aed391c to c63224d Compare October 1, 2025 20:03
By adding a Closed state for sender `SessionEvent`s we can consolidate
the failed, succeded, and canceled states into one enum to keep
eveyrting more concise and clear.

The Session outcomes are as follows, `ReceivedProposalPsbt(bitcoin::psbt)` which
represents the success state, `FailedSession(String)` wich represntes
the failure state and accepts an error string, and `Cancel` which
represents a manual cancel.
Adds a SessionStatus enum and accessor to get the current status of the
Sender, this differs slightly from the receiver as it does not caluclate
expired statuses at the moment.
@benalleng benalleng force-pushed the sender-closed-variant branch from c63224d to 9666b08 Compare October 1, 2025 20:57
@benalleng benalleng requested a review from spacebear21 October 1, 2025 21:11
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 9666b08

@spacebear21 spacebear21 merged commit ef1c15a into payjoin:master Oct 1, 2025
10 checks passed
@zealsham zealsham mentioned this pull request Oct 1, 2025
2 tasks
@benalleng benalleng deleted the sender-closed-variant branch October 6, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants