Repository navigation
Description
Summary
payjoin::send::v2::SenderBuilder::new panics with
unimplemented!("V2 SenderBuilder only supports v2 URLs") when given a URI
whose pj= endpoint is v1-only (a plain HTTPS URL with no BIP 77 fragment,
as produced by any BIP 78 receiver such as BTCPay Server).
The panic is reachable with untrusted input. A v1 payjoin URI parses
successfully and passes check_pj_supported(), so nothing upstream of the
builder rejects it. Payjoin URIs are routinely scanned from QR codes, which
means any v2-only sender integration can be made to panic by paying a
BIP 78 receiver.
payjoin-ffi forwards URIs to this constructor unchecked, so the panic
crosses the FFI boundary. Through uniffi it surfaces as an opaque internal
panic exception in the host language (or a process abort in panic=abort
builds), with no way for bindings users to handle it as a typed error.
Since the FFI also exposes no v1 sender flow, bindings users currently have
no way to pay a v1-only receiver at all: the FFI V1Context and
RequestV1Context types exist but nothing can produce them.
Reproduction
Confirmed in the wild: Bull Bitcoin Mobile 6.13.0 fails at payjoin sender creation when payjoin
is enabled and the destination is a v1 payjoin URI. The panic is caught
by uniffi and rethrown as a generic internal error, so the send attempt
fails with an unactionable message.
History
e59c1031(2024-08-05, released in 0.20.0):extract_v2gained a v1
fallback, "Make backwards-compatible v2 to v1 sends possible."- 0.21.0: the unified sender exposed both
extract_v1()and
extract_v2(). The payjoin-ffi 0.21.0 changelog documented this as
"v1 support is now only available through the V2 backwards-compatible
APIs," which was accurate at the time. 659740d6(2025-08-05, Refactor sender to validate PjParam by version #901, released in 0.25.0): the v1 request path
(create_v1_post_request) was removed from the v2 sender and from the
FFI in the same commit, and the v1 match arm becameunimplemented!.
The changelog recorded this only as "Refactor sender to validate PjParam
by version," so the loss of v2-to-v1 sending and the new panic path went
unannounced. The receiver-side backwards compatibility (v2 receiver
serving v1 senders) is unaffected and still works.
Activity
DanGould commentedon Sep 8, 2026
Seems like the path is to replace the v1 match arm that integrates
unimplemented!to throw an error and then update payjoin.org/donate to use the pluginvbrekher commentedon Sep 9, 2026
I’d like to take this. I’ll focus on replacing the v1
unimplemented!path with a typed error at the FFI boundary and add a regression test so v1-only Payjoin URIs fail cleanly instead of panicking.xstoicunicornx commentedon Sep 15, 2026
Given that the current suggested method of resolving this issue is a breaking change to v1.0 I thought it couldn't hurt to list out potential alternatives and the tradeoffs as far as I see them.
Resultfromnew(...). This is the current proposal and the most straightforward but does require a breaking change.from_parts(...). This would fix the issue for bull bitcoin and would not require a breaking changes. However, even though we don't currently have any live payjoin implementation in Rust, any v2 only payjoin implementor would also have this same issue withnew(...)so this option really only feels like a half measure.new(...)for deprecation. Two variants:a. Only recommend using
from_parts(...)b. Replace with a
new_fallible(...)method.Of these two variants I lean toward 3a just because I don't know what kind of value a fallible constructor really provides. Having a constructor be fallible when only using v2 payjoin also just feels somewhat silly (and doesn't provide any extra utility when also using v1 payjoin). Additionally, it would be clearer to callers exactly what payjoin version flow they are stepping into. Our cli implementation also takes the route of using
from_parts(...)over thenew(...)method.Let me know if there are other options that I missed or if there are other tradeoffs I didn't properly account for.
benalleng commentedon Sep 15, 2026
Seconded that 3a seems to be the most ideal approach when thinking of a post 1.0 API. Do we want to simply deprecate
new()for removal later on or deprecate it before updating its behavior at the next major change?DanGould commentedon Sep 16, 2026
Agree
#[deprecated(since="1.0.1", note="please usefrom_partsinstead")]. Removal makes sense, if we DON'T remove it between versions then a new method ought to be renamed so unexpected errors aren't produced.Deprecate v2 SenderBuilder::new, fix FFI v1 panic
Deprecate v2 SenderBuilder::new, fix FFI v1 panic
Deprecate v2 SenderBuilder::new, fix FFI v1 panic