Skip to content

Sender Pending Fallback state#1557

Merged
spacebear21 merged 2 commits into
payjoin:masterfrom
arminsabouri:sender-cancel-state
May 20, 2026
Merged

Sender Pending Fallback state#1557
spacebear21 merged 2 commits into
payjoin:masterfrom
arminsabouri:sender-cancel-state

Conversation

@arminsabouri
Copy link
Copy Markdown
Collaborator

@arminsabouri arminsabouri commented May 14, 2026

Implementing @spacebear21 's idea from #1542 (comment)
for just the sender.

Recevier side is implemented here: #1558

Pull Request Checklist

Please confirm the following before requesting review:

Claude made the updates to the payjoin-cli

@arminsabouri arminsabouri force-pushed the sender-cancel-state branch 2 times, most recently from 7cf2e7c to d3dac67 Compare May 15, 2026 15:31
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 15, 2026

Coverage Report for CI Build 26187598484

Coverage decreased (-0.1%) to 85.14%

Details

  • Coverage decreased (-0.1%) from the base build.
  • Patch coverage: 28 uncovered changes across 3 files (23 of 51 lines covered, 45.1%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
payjoin/src/core/send/v2/mod.rs 42 18 42.86%
payjoin-cli/src/app/v2/mod.rs 4 1 25.0%
payjoin-cli/src/app/v1.rs 1 0 0.0%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
payjoin-cli/src/app/v1.rs 1 69.33%

Coverage Stats

Coverage Status
Relevant Lines: 13701
Covered Lines: 11665
Line Coverage: 85.14%
Coverage Strength: 394.85 hits per line

💛 - Coveralls

@arminsabouri arminsabouri force-pushed the sender-cancel-state branch from d3dac67 to cefae94 Compare May 15, 2026 16:21
@arminsabouri arminsabouri force-pushed the sender-cancel-state branch 4 times, most recently from 38ef7b3 to 402848a Compare May 18, 2026 15:58
@DanGould
Copy link
Copy Markdown
Contributor

concept ACK just like #1558

@arminsabouri arminsabouri changed the title Sender cancel state Sender Pending Fallback state May 19, 2026
@arminsabouri arminsabouri force-pushed the sender-cancel-state branch from 402848a to b6040c7 Compare May 19, 2026 17:36
@arminsabouri arminsabouri marked this pull request as ready for review May 19, 2026 17:37
Comment thread payjoin/src/core/send/v2/mod.rs Outdated
/// Indicates that the fallback transaction has been broadcast and the session is complete.
pub fn broadcasted(
&self,
) -> MaybeSuccessTransition<SessionEvent, (), std::convert::Infallible> {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

std::convert::Infallible bc this method can never fail due to a API error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TerminalTransition is more appropriate

@arminsabouri arminsabouri force-pushed the sender-cancel-state branch from b6040c7 to c57d338 Compare May 19, 2026 17:55
Copy link
Copy Markdown
Collaborator

@xstoicunicornx xstoicunicornx left a comment

Choose a reason for hiding this comment

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

utACK c57d338

Somewhat strongly held nit: changing from SessionOutcome::Cancel to SessionOutcome::Aborted makes it more confusing/less intuitive. It gives two different terms that refer to the same state transition path. Was there a reason you felt that SessionOutcome::Aborted was better? I do think Cancelled is better than Cancel though.

Other than my nits and the comment that seems like it can be removed, implementation looks good and all tests pass.

Comment thread payjoin-ffi/src/send/error.rs Outdated
Comment thread payjoin-ffi/src/send/mod.rs Outdated
Comment thread payjoin-ffi/javascript/test/unit.test.ts
Copy link
Copy Markdown
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.

Approach ACK, I have a couple of naming questions and a CLI ergonomics question (both also relevant for the receiver PR).

Comment thread payjoin/src/core/send/v2/mod.rs Outdated
Comment thread payjoin/src/core/send/v2/session.rs Outdated
/// Payjoin was cancelled by the user
Cancel,
/// Payjoin was aborted by the user
Aborted,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@xstoicunicornx I think this rename originated from my suggestion here to collapse the Cancel and Failure outcomes into one variant? The idea was that we can tell whether it was a failure or a cancel by looking at the session event log and seeing whether a Cancelled event occurred, vs. a Failed event. Then we wouldn't need the distinction at the SessionOutcome level.

@arminsabouri is this your understanding as well? Is the goal here with the rename to implement the rest of that idea in a follow-up?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah that was the idea. I am going to revert the naming change. I think this is best left as a follow up after this PR and maybe #1558

Comment thread payjoin-cli/src/app/v2/mod.rs Outdated
Ok(())
}

async fn cancel_sender(&self, session_id: SessionId) -> Result<()> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since the cancel and fallback commands are so similar, I wonder if it would be more ergonomic to combine them into a single cancel command, which could either prompt the user for whether to broadcast the fallback, or default to fallback=true with an optional parameter to not broadcast.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ack. If fallback=false, we can print the serialized tx. But cancel should ultimately close the session

Comment thread payjoin-cli/src/app/v2/mod.rs Outdated
@arminsabouri arminsabouri force-pushed the sender-cancel-state branch from c57d338 to c338544 Compare May 20, 2026 19:04
If application manually cancels the assumption is they will not attempt
to resume that session again. The session is marked closed. The cancel
type leaves the session open and
the session can only be closed once the user confirms they broadcasted
the fallback tx -- or took an equivalent action.
Unifying them removes the two-command workflow: `cancel`
now cancels the session and broadcasts the fallback transaction 
by default. Pass `--no-broadcast` to print the raw transaction hex instead for
manual broadcast.
@arminsabouri arminsabouri force-pushed the sender-cancel-state branch from c338544 to 3bb4625 Compare May 20, 2026 20:19
Copy link
Copy Markdown
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.

utACK 3bb4625

@spacebear21 spacebear21 merged commit b58af3f into payjoin:master May 20, 2026
23 checks passed
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.

5 participants