Skip to content

Expose PSBT AddInput/AddOutput via RPC #19608

@JeremyRand

Description

@JeremyRand

Is your feature request related to a problem? Please describe.

Alice creates a PSBT via the RPC API, and signs all inputs with SIGHASH_SINGLE | SIGHASH_ANYONECANPAY. She then sends the signed PSBT to Bob, who wants to add some more inputs and outputs via the RPC API without losing Alice's signatures, so that he can broadcast the resulting transaction without asking Alice to re-sign. Unfortunately, the PSBT RPC API doesn't seem to provide any way of appending new inputs/outputs to an existing PSBT; it only allows creating a new PSBT (via createpsbt) with the full set of inputs/outputs, which has the side effect of losing the existing signatures.

Describe the solution you'd like

It would be useful for the PSBT RPC API to expose the AddInput and AddOutput methods of PartiallySignedTransaction. These would allow adding new inputs/outputs without affecting whatever signature data might already be present in the existing inputs. Something like this:

bitcoin-cli addoutputpsbt 'existingpsbt' '{"data":"00010203"}'

Describe alternatives you've considered

I considered adapting combinepsbt to copy signatures between two transactions with different TXID's if the signatures are valid in both transactions given the SIGHASH flags, but this seems rather unwieldy.

It might be desirable to support adding multiple outputs (or inputs) in one RPC call, by making the 2nd argument an array of objects instead of an object. Or this might just complicate things unnecessarily. I don't feel particularly strongly about this.

Additional context

N/A.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions