You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose the fallback transaction on every receiver state that has one #1949
Receivers doing cut-through or consolidation need the original transaction while in WantsOutputs and later states, for example to find their own output and replace it. #1878 ran into this.
Every one of those states already holds the fallback, and there's already an impl<S: HasFallbackTx> Receiver<S> block. But fallback_tx() sits on a sealed trait, so code outside the crate can't call it. The workaround is to keep a separate copy of the original transaction and pass it around next to the session, which breaks the usual match over ReceiveSession.
The fix is to add a public fallback_tx() to impl<S: HasFallbackTx> Receiver<S>. It's additive.
The generic impl doesn't carry over to payjoin-ffi, so each state type there needs its own fallback_tx(). A macro can generate them. Today only ReceiverPendingFallback and ReceiverSessionHistory have it.
Before settling the API, check how Shepherd and Satsigner do cut-through with the current interface and note it here.
I'm not convinced that we want to expose the fallback transaction on every receiver state that has one. Currently, the only way for a receiver to access the fallback transaction is to explicitly call cancel() - which is available on every receiver state. The resulting PendingFallback typestate is intentionally the only way to obtain fallback_tx in the typestate machine, with explicit instructions on how to broadcast it and close the session. By exposing fallback_tx raw on every typestate I think we introduce a footgun where a user might simply broadcast the fallback_tx and leave their session in an ambiguous state. For #1878 I think the fix is to expose specific accessors as I mentioned there, instead of the entire fallback_tx which is unreliable anyway.
Sidenote: while I was doing local review of fallback_tx my bot noticed that there is an unintended escape hatch: The sealed FallbackTx::fallback_tx() method leaks through the public HasFallbackTx bound. A downstream crate can compile this:
A direct call on a concrete Receiver<Monitor> fails because the trait is not in scope, but the generic wrapper works since bounds bring supertrait methods into scope. Rustdoc hides it because the trait lives in a private module.
I don't disagree that this is a footgun, I guess my concern is mainly around other footguns that may exist in workflows that we haven't necessarily accounted for. For example the current LDK node creates a session shell struct that also caches the fallback tx specifically so that it can have access to fallback tx at any time. Generally speaking for receivers who may have asynchronous wallet checks/signing could probably benefit from being able to access the fallback tx at any time (since processing of the payjoin may not be instant and they may want to keep an eye out for the fallback).
I acknowledge that these are pretty weak and vague arguments. I just lean towards eliminating reasons for implementers to create bespoke implementations of payjoin functionality as being a higher priority than avoiding non-vulnerability related footguns. At the end of the day, implementers not appropriately closing out their payjoin sessions seems like a very low impact footgun which the implementers themselves should be incentivized to avoid (as is wastes their own resources).
I do agree with deprecating extract_tx_to_schedule_broadcast overall though. Just disagree that fallback_tx should be not be accessible.
Looking further into why LDK node is caching the fallback tx, these two scenarios are what is actually used for:
The Aborted path. handle_closed_session(Aborted) passes None and falls back to the cache, because LDK throws away the SessionHistory from replay (bc1cindy flagged this). If they kept it, history.fallback_tx() would serve. Their cancel path already uses it.
Logs that fail to replay. If the event log can't be decoded, there's no Receiver and no SessionHistory. Only the Expired error carries the fallback. This is the one case where the cache is actually needed.
So the cache is never used to recognize transactions. It's only used to broadcast when the library can't hand over a receiver. fallback_tx() on every typestate wouldn't help here, because the failing case has no typestate at all. What would help is every ReplayError that has the original payload carrying the fallback, as Expired already does.
As we discussed yesterday, I think I am comfortable with forcing callers into the PendingFallback typestate in order to access the fallback tx as there shouldn't be a need for callers to access the fallback tx outside of that flow.
Activity
spacebear21 commentedon Oct 19, 2026
I'm not convinced that we want to expose the fallback transaction on every receiver state that has one. Currently, the only way for a receiver to access the fallback transaction is to explicitly call
cancel()- which is available on every receiver state. The resulting PendingFallback typestate is intentionally the only way to obtainfallback_txin the typestate machine, with explicit instructions on how to broadcast it and close the session. By exposingfallback_txraw on every typestate I think we introduce a footgun where a user might simply broadcast the fallback_tx and leave their session in an ambiguous state. For #1878 I think the fix is to expose specific accessors as I mentioned there, instead of the entire fallback_tx which is unreliable anyway.Sidenote: while I was doing local review of fallback_tx my bot noticed that there is an unintended escape hatch: The sealed FallbackTx::fallback_tx() method leaks through the public HasFallbackTx bound. A downstream crate can compile this:
A direct call on a concrete
Receiver<Monitor>fails because the trait is not in scope, but the generic wrapper works since bounds bring supertrait methods into scope. Rustdoc hides it because the trait lives in a private module.The fix is to narrow the trait to
pub(crate).xstoicunicornx commentedon Oct 19, 2026
I don't disagree that this is a footgun, I guess my concern is mainly around other footguns that may exist in workflows that we haven't necessarily accounted for. For example the current LDK node creates a session shell struct that also caches the fallback tx specifically so that it can have access to fallback tx at any time. Generally speaking for receivers who may have asynchronous wallet checks/signing could probably benefit from being able to access the fallback tx at any time (since processing of the payjoin may not be instant and they may want to keep an eye out for the fallback).
I acknowledge that these are pretty weak and vague arguments. I just lean towards eliminating reasons for implementers to create bespoke implementations of payjoin functionality as being a higher priority than avoiding non-vulnerability related footguns. At the end of the day, implementers not appropriately closing out their payjoin sessions seems like a very low impact footgun which the implementers themselves should be incentivized to avoid (as is wastes their own resources).
I do agree with deprecating
extract_tx_to_schedule_broadcastoverall though. Just disagree thatfallback_txshould be not be accessible.spacebear21 commentedon Oct 20, 2026
Looking further into why LDK node is caching the fallback tx, these two scenarios are what is actually used for:
Abortedpath.handle_closed_session(Aborted)passesNoneand falls back to the cache, because LDK throws away theSessionHistoryfrom replay (bc1cindy flagged this). If they kept it,history.fallback_tx()would serve. Their cancel path already uses it.So the cache is never used to recognize transactions. It's only used to broadcast when the library can't hand over a receiver.
fallback_tx()on every typestate wouldn't help here, because the failing case has no typestate at all. What would help is everyReplayErrorthat has the original payload carrying the fallback, as Expired already does.xstoicunicornx commentedon Oct 21, 2026
As we discussed yesterday, I think I am comfortable with forcing callers into the
PendingFallbacktypestate in order to access the fallback tx as there shouldn't be a need for callers to access the fallback tx outside of that flow.