Skip to content

FFI sender doesn' support v1 payjoin URIs #1849

Closed
0 of 1 issue completed
Closed

Description

@spacebear21

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.

Image

History

  • e59c1031 (2024-08-05, released in 0.20.0): extract_v2 gained 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 became unimplemented!.
    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.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    bug
    on Aug 27, 2026
  2. DanGould commented on Sep 8, 2026

    @DanGould
    Member

    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 plugin

  3. vbrekher commented on Sep 9, 2026

    @vbrekher

    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.

  4. xstoicunicornx commented on Sep 15, 2026

    @xstoicunicornx
    Collaborator

    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.

    1. Breaking change - return Result from new(...). This is the current proposal and the most straightforward but does require a breaking change.
    2. Only fix FFI - update FFI bindings to use 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 with new(...) so this option really only feels like a half measure.
    3. Deprecation - mark 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 the new(...) method.

    Let me know if there are other options that I missed or if there are other tradeoffs I didn't properly account for.

  5. benalleng commented on Sep 15, 2026

    @benalleng
    Collaborator

    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?

  6. DanGould commented on Sep 16, 2026

    @DanGould
    Member

    Agree #[deprecated(since="1.0.1", note="please use from_parts instead")]. 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.

  7. added 2 commits that reference this issue on Sep 17, 2026
    031cf66
    44bc40d
  8. added a commit that references this issue on Sep 28, 2026
    7263464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugffi

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions