diff options
author | Glenn Willen <gwillen@nerdnet.org> | 2018-10-26 15:31:41 -0700 |
---|---|---|
committer | Glenn Willen <gwillen@nerdnet.org> | 2018-11-01 12:14:21 -0700 |
commit | 565500508aa5df0011109ebf375ba71b693fc7de (patch) | |
tree | e87abd87ce2a1362e91e99b3cf56b8e0eb066669 /test/functional | |
parent | 0f5bda2bd941686620ef0eb90bd7ed973cc7ef73 (diff) |
Refactor PSBTInput signing to enforce invariant
Refactor the process of PSBTInput signing to enforce the invariant that
a PSBTInput always has _either_ a witness_utxo or a non_witness_utxo,
never both.
This simplifies the logic of SignPSBTInput slightly, since it no longer
has to deal with the "both" case. When calling it, we now give it, in
order of preference: (1) whichever of the utxo fields was already
present in the PSBT we received, or (2) if neither, the
non_witness_utxo field, which is just a copy of the input transaction,
which we get from the wallet.
SignPSBTInput no longer has to remove one of the two fields; instead, it
will check if we have a witness signature, and if so, it will replace
the non_witness_utxo with the witness_utxo (which is smaller, as it is
just a copy of the output being spent.)
Add PSBTInput::IsSane checks in two more places, which checks for
both utxo fields being present; we will now give an RPC error early on
if we are supplied such a malformed PSBT to fill in.
Also add a check to FillPSBT, to avoid touching any input that is
already signed. (This is now redundant, since we should no longer
potentially harm an already-signed input, but it's harmless.)
fixes #14473
Diffstat (limited to 'test/functional')
0 files changed, 0 insertions, 0 deletions