Skip to content

Allow cancel on closed sessions to reprint fallback tx#1673

Merged
benalleng merged 3 commits into
payjoin:masterfrom
benalleng:cancel-semantics
Jun 24, 2026
Merged

Allow cancel on closed sessions to reprint fallback tx#1673
benalleng merged 3 commits into
payjoin:masterfrom
benalleng:cancel-semantics

Conversation

@benalleng

@benalleng benalleng commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #1605

This adds the ability to run cancel on already closed sessions to re-print the fallback tx to be broadcast. This addresses a failure state where a closed session could not access its fallback tx if it was not automatically broadcast.

Coded with help from GLM-5.2

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls

coveralls commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28129265564

Coverage increased (+0.1%) to 85.517%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 4 uncovered changes across 2 files (22 of 26 lines covered, 84.62%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
payjoin-cli/src/app/v2/mod.rs 8 6 75.0%
payjoin-cli/src/db/v2.rs 18 16 88.89%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15128
Covered Lines: 12937
Line Coverage: 85.52%
Coverage Strength: 361.72 hits per line

💛 - Coveralls

@benalleng benalleng marked this pull request as ready for review June 23, 2026 23:34
@benalleng benalleng changed the title Cancel semantics Allow cancel on closed sessions to reprint fallback tx Jun 23, 2026
@benalleng benalleng requested a review from spacebear21 June 23, 2026 23:35
Comment thread payjoin-cli/src/db/v2.rs
Comment on lines +294 to +314
/// Look up a sender session by ID regardless of active/inactive state.
pub(crate) fn find_send_session(&self, session_id: &SessionId) -> Result<bool> {
let conn = self.get_connection()?;
let exists: bool = conn.query_row(
"SELECT EXISTS(SELECT 1 FROM send_sessions WHERE session_id = ?1)",
params![session_id.0],
|row| row.get(0),
)?;
Ok(exists)
}

/// Look up a receiver session by ID regardless of active/inactive state.
pub(crate) fn find_recv_session(&self, session_id: &SessionId) -> Result<bool> {
let conn = self.get_connection()?;
let exists: bool = conn.query_row(
"SELECT EXISTS(SELECT 1 FROM receive_sessions WHERE session_id = ?1)",
params![session_id.0],
|row| row.get(0),
)?;
Ok(exists)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: find_* reads like it returns the session (find usually yields Option<T>), but this returns bool. wdyt? would *_exists match the return type better?

Comment thread payjoin-cli/src/db/v2.rs Outdated
}

/// Look up a sender session by ID regardless of active/inactive state.
pub(crate) fn find_send_session(&self, session_id: &SessionId) -> Result<bool> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

worth a test pinning down the regression: create a session, close it, assert find_send_session returns true (the old get_send_session_ids would've returned empty for a closed session)

@bc1cindy

Copy link
Copy Markdown
Contributor

concept ACK

@benalleng benalleng force-pushed the cancel-semantics branch 2 times, most recently from c830d3e to ad792ea Compare June 24, 2026 17:04

@spacebear21 spacebear21 left a comment

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.

utACK but I have one small change request on the e2e test if it's trivial enough to add.

Comment thread payjoin-cli/tests/e2e.rs
Print the fallback tx hex from SessionHistory::fallback_tx() in the
Closed(Aborted) arm of cancel_sender_session and cancel_receiver_session.

@spacebear21 spacebear21 left a comment

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.

reACK

@benalleng benalleng merged commit d4f0d8a into payjoin:master Jun 24, 2026
13 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.

Does the payjoin-cli cancel have the correct semantics?

4 participants