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
Failure to contribute inputs should result in reciverer fallingback #1213
Any thoughts on whether the fallback would be handled by the receiver or the sender?
Alternative 1: Receiver Broadcasts the Fallback
Receiver broadcasts the fallback transaction.
Receiver sends an indication of the fallback to the sender.
Receiver marks the session complete.
Sender receives the update, handles it, and marks the session as complete in the persister.
Alternative 2: Receiver Indicates Payjoin Failure to Sender; Sender Broadcasts Fallback
Receiver sends an indication of the fallback to the sender; this can be the fallback transaction AS the "proposal," or a different payload which specifically indicates the fallback.
Receiver directly moves to the Receiver<Monitor> state, which will handle fallback transaction monitoring.
Sender broadcasts the transaction and marks the session complete.
Receiver detects that the fallback transaction has been broadcast, and marks the session complete.
I'm thinking which one makes sense from a motivation perspective. The sender wants the privacy, but in Alternative 1, the receiver can broadcast the transaction without the approval of the sender. Note sure if an additional flag indicating if the sender is willing to not use the fallback transaction would be ideal, unnecessary, or if there are better alternatives... IMO, sender broadcasting seems like the better alternative.
The receiver can broadcast the transaction without the approval of the sender
The receiver does not need the approval of the sender. Nor is there a coordination between them to figure out when or who is going to broadcast the fallback. Either party can broadcast depending on the application and user preferences.
Note sure if an additional flag indicating if the sender is willing to not use the fallback transaction would be ideal,
By virtue of using a bip77 Pj client the sender is opt'ing into using the fallback.
Re: alternative two. IIRC this is exactly what our error to monitoring state machine does today. We reply with an error and then monitor. If the error is requires the receiver to fallback perhaps that warrants another typestate which exposes the fallback and then progresses to monitoring. In this case I dont see why the receiver should wait for the sender to fallback. If the reciever is expecting more inputs they can wait, otherwise they should just fallback. Another point, the sender doesnt need an error reply to know the fallback is broadcasted. Assuming most applications are monitoring for incoming/outgoing txs. Maybe that assumption is too weak and we need some monitoring on the sender side. This decision will be informed by doing more integrations.
I'd like to take this one. I traced the check this issue came from — it's
the is_empty() guard in payjoin-cli (v2/mod.rs:917, with a v1 twin at v1.rs:413), which duplicates the library's own emptiness check in select_first_candidate (common/mod.rs:324, InternalCoinSelectionError::Empty).
The CLI has to front-run it because try_preserving_privacy only returns
an opaque CoinSelectionError.
Most of the fallback infrastructure already exists in the v2 receiver: PendingFallback holds the fallback tx, HasReplyableError already does
the "reply to the sender with an error, then transition to PendingFallback (or Closed(Aborted) when there's no fallback)" dance,
and SessionOutcome::FallbackBroadcasted / SessionStatus::PendingFallback
are wired through session status. What's missing is routing an
input-contribution failure into that path.
Following your last comment, my plan is:
When the receiver can't contribute inputs and isn't expecting more,
drive it into a state that exposes the fallback tx and proceeds to Monitor, instead of bubbling an opaque error. Receiver-driven, no
sender approval needed — the sender learns via monitoring, matching
how HasReplyableError already behaves.
Propagate the specific internal reason so integrators can drop their
duplicate guards — after which the is_empty() checks in payjoin-cli
can be removed.
Two things to confirm before I start:
Reuse the HasReplyableError → PendingFallback machinery, or add a
dedicated fallback typestate as you hinted?
For (2), surface the reason as a non-fatal value on the transition
rather than a hard Err?
master has a generic impl<S: HasFallbackTx> Receiver ::cancel() (receive/v2/mod.rs, added in "Merge Cancel Failure variants in receiver") that emits SessionEvent::Cancelled and moves to Receiver. SinceWantsInputs: HasFallbackTx, the receiver can already fall back from WantsInputs — there's no new library method or event to add, and the reuse-vs-new-event question I raised is moot (cancel() already commits Cancelled).
So the remaining work is exactly what you originally pointed at — the CLI:
v2: on input-contribution failure, route through the existing cancel() → PendingFallback instead of hard-erroring, then let payjoin-cli cancel broadcast the fallback.
v1: drop the duplicate is_empty() guard; try_preserving_privacy's error already returns to the sender, who broadcasts the original (sender-side fallback).
Both duplicate is_empty() guards (v2/mod.rs, v1.rs) go away, which addresses the "so we don't have a duplicate check" part.
PR incoming with an e2e test covering the empty-wallet fallback path.
Activity
arminsabouri commentedon Dec 4, 2025
Related to #1164
mehmetefeumit commentedon Dec 14, 2025
Any thoughts on whether the fallback would be handled by the receiver or the sender?
Alternative 1: Receiver Broadcasts the Fallback
Alternative 2: Receiver Indicates Payjoin Failure to Sender; Sender Broadcasts Fallback
Receiver<Monitor>state, which will handle fallback transaction monitoring.I'm thinking which one makes sense from a motivation perspective. The sender wants the privacy, but in Alternative 1, the receiver can broadcast the transaction without the approval of the sender. Note sure if an additional flag indicating if the sender is willing to not use the fallback transaction would be ideal, unnecessary, or if there are better alternatives... IMO, sender broadcasting seems like the better alternative.
arminsabouri commentedon Dec 15, 2025
Thanks for laying out some options
The receiver does not need the approval of the sender. Nor is there a coordination between them to figure out when or who is going to broadcast the fallback. Either party can broadcast depending on the application and user preferences.
By virtue of using a bip77 Pj client the sender is opt'ing into using the fallback.
Re: alternative two. IIRC this is exactly what our error to monitoring state machine does today. We reply with an error and then monitor. If the error is requires the receiver to fallback perhaps that warrants another typestate which exposes the fallback and then progresses to monitoring. In this case I dont see why the receiver should wait for the sender to fallback. If the reciever is expecting more inputs they can wait, otherwise they should just fallback. Another point, the sender doesnt need an error reply to know the fallback is broadcasted. Assuming most applications are monitoring for incoming/outgoing txs. Maybe that assumption is too weak and we need some monitoring on the sender side. This decision will be informed by doing more integrations.
Also related work: #1164
Jolah1 commentedon Jul 24, 2026
I'd like to take this one. I traced the check this issue came from — it's
the
is_empty()guard in payjoin-cli (v2/mod.rs:917, with a v1 twin atv1.rs:413), which duplicates the library's own emptiness check inselect_first_candidate(common/mod.rs:324,InternalCoinSelectionError::Empty).The CLI has to front-run it because
try_preserving_privacyonly returnsan opaque
CoinSelectionError.Most of the fallback infrastructure already exists in the v2 receiver:
PendingFallbackholds the fallback tx,HasReplyableErroralready doesthe "reply to the sender with an error, then transition to
PendingFallback(orClosed(Aborted)when there's no fallback)" dance,and
SessionOutcome::FallbackBroadcasted/SessionStatus::PendingFallbackare wired through session status. What's missing is routing an
input-contribution failure into that path.
Following your last comment, my plan is:
drive it into a state that exposes the fallback tx and proceeds to
Monitor, instead of bubbling an opaque error. Receiver-driven, nosender approval needed — the sender learns via monitoring, matching
how
HasReplyableErroralready behaves.duplicate guards — after which the
is_empty()checks in payjoin-clican be removed.
Two things to confirm before I start:
HasReplyableError→PendingFallbackmachinery, or add adedicated fallback typestate as you hinted?
rather than a hard
Err?Jolah1 commentedon Jul 27, 2026
Update after tracing the current state of master:
master has a generic impl<S: HasFallbackTx> Receiver ::cancel() (receive/v2/mod.rs, added in "Merge Cancel Failure variants in receiver") that emits SessionEvent::Cancelled and moves to Receiver. SinceWantsInputs: HasFallbackTx, the receiver can already fall back from WantsInputs — there's no new library method or event to add, and the reuse-vs-new-event question I raised is moot (cancel() already commits Cancelled).
So the remaining work is exactly what you originally pointed at — the CLI:
Both duplicate is_empty() guards (v2/mod.rs, v1.rs) go away, which addresses the "so we don't have a duplicate check" part.
PR incoming with an e2e test covering the empty-wallet fallback path.
Fall back when receiver cannot contribute inputs
Fall back when receiver cannot contribute inputs