Skip to content

Conversation

@benalleng
Copy link

I feel like adding this new error_erply method is not exactly the approach we want removing on e pbu method for another, should I just make a Display method instead?

Pull Request Checklist

Please confirm the following before requesting review:

spacebear21 and others added 9 commits September 23, 2025 18:43
The FIXME comment says this should return a terminal error, but as far
as I can tell the only way that method fails is if the receiver's fee
contributions would exceed their specified `max_effective_fee`. By
making this a transient error we allow a receiver to try applying fee
contributions again with a different feerate.
This session event holds the JSON representation of the error reply to
the sender that should be attempted by the receiver, as specified in
BIP78.

Co-authored-by: spacebear <git@spacebear.dev>
This enforces proper handling within the receiver state machine, such
that they must attempt replying to the sender with an error response
before the session can be considered closed.

Co-authored-by: DanGould <d@ngould.dev>
`TerminalFailure` was never a real state in the receiver state machine.
Instead, a SessionEvent::Closed simply results in an empty `()` next
state.
Only a subset of fatal errors should result in immediate closure of a
receiver session. In many cases an attempt should first be made to
respond to the sender with an error as specified in BIP78.

Instead of scrutinizing various error types to determine whether it
should be replyable or not, the callsite can simply provide the
appropriate SessionEvent::HasReplyableError(JsonReply) for replyable
errors, or SessionEvent::Closed(Failure) for non-replyable ones.
Previously extract_err_req was exposed as a public method on
SessionHistory, and process_err_res as a pure function, for implementers
to manually process error responses.

Now this can and should be done via the HasReplyableError typestate, so
these functions are no longer needed.
@spacebear21 spacebear21 force-pushed the handle-error-typestate branch from fa845c8 to ca5da9c Compare September 30, 2025 01:30
@benalleng benalleng closed this Sep 30, 2025
@benalleng benalleng deleted the handle-error-typestate 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.

3 participants