-
Notifications
You must be signed in to change notification settings - Fork 77
Expose fail() and cancel() on Receiver session #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
e4008b1 to
c373ec1
Compare
Pull Request Test Coverage Report for Build 18177469540Details
💛 - Coveralls |
This gives implementers the ability to manually fail or cancel a receiver Payjoin session. A user might cancel a session for any reason, or the wallet might fail it if e.g. it detects a double-spend or cannot proceed past a transient error.
c373ec1 to
7c56df0
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeAck
payjoin/src/core/receive/v2/mod.rs
Outdated
| /// | ||
| /// This method allows implementations to terminate the payjoin session when | ||
| /// the user decides to cancel the operation interactively. | ||
| pub fn cancel<P>(self, persister: &P) -> Result<(), P::InternalStorageError> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think cancel is simpler than just calling close() on the persister?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is that cancel() (and fail()) ensures that a Closed event is added to the log before closing.
payjoin/src/core/receive/v2/mod.rs
Outdated
| /// This method allows implementations to terminate the payjoin session when | ||
| /// they encounter errors that cannot be resolved, such as insufficient | ||
| /// funds or a double-spend detection. | ||
| pub fn fail<P>(self, persister: &P) -> Result<(), P::InternalStorageError> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we push a generic failure error reply? Otherwise the sender will be hanging until expiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good point, we do need a way to communicate this (and probably cancel() too) back to the sender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started down an approach where they transition to HasReplyableError to enforce responding to the sender. However there is an outstanding issue in that it needs to differentiate between Cancel and Failure outcomes when replaying the event log, so I think GotReplyableError would need to carry this information somehow.
I'm not sure if we actually need to reply in case of Cancel, assuming the receiver would broadcast the fallback tx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancel sounds like the unavailable wellKnownError to me, even if broadcast is sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason I can think of for a receiver to do this would be if the receiver wanted to refuse a naive tx.
A better solution for this example would be having the receiver use req-pj
So for now letting it expire is fine.
|
I wanted to pose a question as to why we really need to have these 2 seperate instead of just having application devs use |
This gives implementers the ability to manually fail or cancel a receiver Payjoin session. A user might cancel a session for any reason, or the wallet might fail it if e.g. it detects a double-spend or cannot proceed past a transient error.
Note that the unit tests for closed sessions will need to be reworked once #1132 is merged, since the
expected_receiver_stateshould be an error.I used Claude sonnet 4.5 (it's quite good) to write the generic methods and unit tests.
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.