Skip to content

Receiver input selection ignores script type, so a type mismatch partitions the payjoin #1722

Open

Description

@bc1cindy

should the lib make input contribution script-type-aware? i.e. extend the existing privacy-preserving selection (which already covers amount) to also prefer a receiver UTXO whose script type matches the sender's inputs (match-when-available), and surface a mismatch when the receiver holds no matching type so the caller can decide?

this keeps convergence in the shared lib instead of each integration reimplementing it, and the lib already has both the sender's PSBT (its input types) and the receiver's candidates at this point.

open design questions

  • extend try_preserving_privacy, or a separate select variant / policy flag?
  • on no matching type: match-when-available only, flag, or abort? (leave the last call to the caller?)
  • structural limit: Single-type wallets can't always converge on this axis. Liana's wsh() descriptor reveals its timelock witnessScript on every spend, so it's always distinctive. Its tr() descriptor is better: under the Simple Inheritance template (single-sig primary as the taproot internal key), normal spends are key-path and thus indistinguishable from any single-sig P2TR keyspend, they already converge with taproot senders; only recovery (script-path) spends reveal the tapscript. (This is a general taproot property for any single-sig-primary wallet, not Liana-specific.) So the lib can match into the taproot set when the receiver spends key-path, and can only signal, not fix, the wsh() / script-path cases.

is this something the lib should own?

ref: #1597 (comment)

Activity

  1. xstoicunicornx commented on Jul 20, 2026

    @xstoicunicornx
    Collaborator

    I don't have any answers for the open design questions, just have an additional question: should/could we also try to match on output types?

  2. DanGould commented on Jul 22, 2026

    @DanGould
    Member

    From a design perspective I'd like to align with the BIP, where script was intentionally removed as one of limitless fingerprints that can't really be spec enforced by counterparties. Rather the choice was to have the core state machine concerned just with network & agreement and leave wallet details / coin selection up to a higher layer. I think try_preserving_privacy and script selection like you describe make more sense in a higher level feature gated module or crate offered as part of payjoin dev kit, focusing on these type privacy-preserving heuristics beyond payjoin coordination itself but maintained to be ergonomic with the payjoin crate state machine

  3. bc1cindy commented on Jul 22, 2026

    @bc1cindy
    ContributorAuthor

    makes sense

    i'd shape it as a selection interface: the wallet implements a hook (receiver candidates + sender context in → selection + signals out, e.g. ScriptTypeMismatch), with try_preserving_privacy as the explicitly best-effort default, extended with match-when-available on script type (and output types as another signal). mismatches surface as signals, the integration decides.

    i'd lean separate crate over feature-gated mod, so the interface can iterate at 0.x without touching payjoin 1.0 semver. the only pre-1.0 action becomes removing try_preserving_privacy from core. what do you think?

  4. DanGould commented on Jul 23, 2026

    @DanGould
    Member

    concept ack of the shape & reason to be an independent crate for semver iteration

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