⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@zealsham
Copy link
Collaborator

@zealsham zealsham commented Oct 16, 2025

As a refrence implementation , payjoin-cli needs to demonstrate proper fallback transaction handling in the case of payjon failure. From what i see , both sender and receiver can broadcast the fall back transaction , This pr starts by handling the sender side of things and would eventually progress to the receiver .

This is still a work in progress

this addresses #1156 .

  • handle v1 sender broadcasting fallback
  • handle v2 sender broadcasting fallback
  • handle v2 receiver broadcasting fallback
  • check that transaction is broadcastable before broadasting
Pull Request Checklist

Please confirm the following before requesting review:

@coveralls
Copy link
Collaborator

coveralls commented Oct 16, 2025

Pull Request Test Coverage Report for Build 21247767675

Details

  • 26 of 64 (40.63%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 82.798%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2/mod.rs 26 64 40.63%
Files with Coverage Reduction New Missed Lines %
payjoin-cli/src/app/v2/mod.rs 1 52.14%
Totals Coverage Status
Change from base Build 21219518385: 0.03%
Covered Lines: 10185
Relevant Lines: 12301

💛 - Coveralls

@zealsham zealsham marked this pull request as draft October 16, 2025 11:59
@arminsabouri arminsabouri mentioned this pull request Oct 28, 2025
2 tasks
@zealsham
Copy link
Collaborator Author

zealsham commented Nov 6, 2025

@arminsabouri i implemented error downcast method for v2 in this PR, the downside of this method is having to repeat the same block of code for the the different state of the senders session. I only did it for the "pooling proposal" phase of the sender session, i'll have to do it for the rest of the phases but just want to know your input on this before i head that direction.

i'm also simutaneously working on the "session outcome" based solution with the draft PR from you .

As a refrence implementation , payjoin-cli needs to demonstrate
proper fallback transaction handling in the case of payjon failure.
From what i see , both sender and receiver can broadcast the fall
back transaction , This pr starts by handling the sender side
of things and would eventually progress to the receiver .

this addresses payjoin#1156

fix unneccesary check

handle fallback for propsal failing

handle fallback for propsal failing

handle fallback for propsal failing

fix format issue

handle fallback for propsal failing
@zealsham zealsham marked this pull request as ready for review January 22, 2026 12:16
@zealsham zealsham changed the title WIP:Demonstrate failure handling with fallback TX broadcast Demonstrate failure handling with fallback TX broadcast Jan 22, 2026
self.process_pj_response(psbt)?;
Ok(())
}
Err(e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure we should be falling back on any Error. We should be doing something similar to what you did below and only fallback on a FatalError -- an irrecoverable protocol deviation.

Err(e) => {
// Check if it's a PersistedError with an API error
if let Some(persisted_error) = e.downcast_ref::<PersistedError<
EncapsulationError,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why downcast specifically to a EncapsulationError? Are there not other Fatal error types?
Regardless, if we want to go this route, we should explore the changes neccecary in the API to make this more ergonomic. and idiomatic
e.is_fatal() or e.should_fallback().

Alternatively we could explore integrating this change into the typestate it self. I.e the error statemachine scrutinizes the error type and decides what to do. Leaving the developer entirely out of it.

If we want to developer to decide how to react then we should explore including Outcome in close() #1181

I would like to talk through the options a bit more before commiting to this route. Let me know your thoughts @zealsham

cc @spacebear21

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think the developer should ultimately decide what to do if a fatal error occurs. from the BIP

At any point, either party may choose to broadcast the fallback transaction described by the Original PSBT instead of proceeding

I believe some implementers might want the sender doing that or the receiver doing that, exposing outcome in close() handles that properly, automatically broadcasting fallback TX doesn't seem like what most devs will want.

Also i'll have to go through #1181 again , as i've lost most of the context.

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.

3 participants