Skip to content

v2 receiver should disable output substitution #843

Closed

Description

@nothingmuch

BIP 77 specifies that it must be disabled in the URI for a v1 compatible receiver, because the directory acts as an unsecured payjoin server from the standpoint of BIP 78 senders, who do not use end to end encryption.

Prior to #466, pjos=0 was set matching the spec:

Self { address, amount: None, message: None, label: None, pj, pjos: false }

However, it appears that in #466 the corresponding field was renamed disable_output_substitution, and was later renamed back to output_substitution in the PayjoinExtras struct, but the value of false was retained, and this incorrect behavior has apparently survived a few refactorings... While I'm reasonably confident this is indeed just a bug, I didn't get to the bottom of how this confusion was introduced, so it's possible I missed something, so @DanGould can you please confirm this wasn't intentional? I kind of got lost what with the same boolean blindness that motivated the change to an enum in the first place looking at the history and it seems simpler to ask.

See also bitcoin/bips#1887

Activity

  1. spacebear21 commented on Jul 2, 2025

    @spacebear21
    Collaborator

    So it looks like there are actually multiple bugs in the implementation:

    • v2 receivers should always specify pjos=0 in the bitcoin URI. Currently this is elided by default (implicitly enables output substitution).
    • v2 senders should effectively ignore the receiver pjos parameter, since everything is e2e authenticated so there is no theft risk, and we want to allow tx cut-through/etc. Currently v2 senders use the v1 SenderBuilder which respects the receiver pjos preference
      • I also think BIP77 should be updated to explicitly state that the pjos should only be respected by v1 senders. A v2 sender may still disallow output substitution by specifying the disableoutputsubstitution query param.
    • v2 receivers should only heed the sender's output substitution preference and ignore the pjos BIP21 param. This may already be the case but we should double check.

    Our v2 receiver did ensure that it would not substitute outputs for a v1 sender, so there's a small win at least!

  2. nothingmuch commented on Jul 2, 2025

    @nothingmuch
    ContributorAuthor

    So it looks like there are actually multiple bugs in the implementation:

    Agreed

    • I also think BIP77 should be updated to explicitly state that the pjos should only be respected by v1 senders. A v2 sender may still disallow output substitution by specifying the disableoutputsubstitution query param.
    • v2 receivers should only heed the sender's output substitution preference and ignore the pjos BIP21 param. This may already be the case but we should double check.

    What do you mean ignore the pjos BIP21 param? they don't parse it, so i don't think there's anything to ignore?

    The unsecured payment server argument makes sense for the pjos parameter in the URI.

    However, there may be reasons for both sender and receiver to want to disable, for example needing the payment address to be fixed (e.g. for record keeping or scripting reasons).

    Although the new mechanism only accounts for transmitting sender's preferences to the recveiver, the receiver doesn't need to transmit their preference to the sender, they can just substitute or not on their turn. The explicit signalling is only really needed for the unsecured server scenario, ensuring that the sender does not sign a malicious txn.

    So i think for the receiver's API we can bikeshed the code so the field name has sender or something for the receiver's struct, and clarify in the spec that the receiver's choice WRT substituting or not is just up to wallets?

  3. spacebear21 commented on Jul 2, 2025

    @spacebear21
    Collaborator

    What do you mean ignore the pjos BIP21 param? they don't parse it, so i don't think there's anything to ignore?

    I misspoke here, I wasn't sure if the receiver remembered their own signaled preference, but I see they just apply the sender's params.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions