Skip to content

Expose typed InputPair constructors in payjoin-ffi #1955

Closed

Description

@DanGould

payjoin has typed constructors for receiver inputs: InputPair::new_p2pkh, new_p2wpkh, new_p2tr_keyspend and new_p2tr_scriptpath_spend. payjoin-ffi only exposes InputPair::new(txin, psbtin, expected_weight), so binding users build the PSBT input by hand and have to know when to supply the input weight themselves.

Taproot receivers get this wrong thus far. An unsigned P2TR input has no witness, so new can't tell a key path spend from a script path spend and fails with "weight prediction not supported" unless the caller passes a weight. The BTCPay plugin passes none, so a store with a Taproot hot wallet fails every payjoin when it tries to contribute an input: https://github.com/ValeraFinebits/btcpayserver-payjoin-plugin/blob/4836e393e1c75b64e13d1b73cbf899aa748936b6/BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverWalletAdapter.cs#L79-L89. I faced this problem when testing it live.

Bull Bitcoin and Cake call the same generic constructor and fill in the fields themselves, passing no weight. That works for their native segwit coins, but a Taproot coin would fail the same way as BTCPayServer Async payjoin plugin:

#583 closed with a note that these constructors should be exposed in FFI so new can eventually be deprecated but that hasn't been done yet.

Proposed: expose the four typed constructors in payjoin-ffi, add a binding test that contributes a Taproot key path coin, and move the integration tests to the typed constructors. This is additive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions