psbt: always put a non_witness_utxo and don't remove it

Offline signers will always need a non_witness_utxo so make sure it is
there.

Github-Pull: #19215
Rebased-From: 4600479058
This commit is contained in:
Andrew Chow
2020-06-04 23:43:43 -04:00
committed by fanquake
parent ed5ec30804
commit 3228b59b17
5 changed files with 11 additions and 8 deletions

View File

@@ -136,8 +136,8 @@ void PSBTInput::Merge(const PSBTInput& input)
{
if (!non_witness_utxo && input.non_witness_utxo) non_witness_utxo = input.non_witness_utxo;
if (witness_utxo.IsNull() && !input.witness_utxo.IsNull()) {
// TODO: For segwit v1, we will want to clear out the non-witness utxo when setting a witness one. For v0 and non-segwit, this is not safe
witness_utxo = input.witness_utxo;
non_witness_utxo = nullptr; // Clear out any non-witness utxo when we set a witness one.
}
partial_sigs.insert(input.partial_sigs.begin(), input.partial_sigs.end());
@@ -263,10 +263,11 @@ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction&
if (require_witness_sig && !sigdata.witness) return false;
input.FromSignatureData(sigdata);
// If we have a witness signature, use the smaller witness UTXO.
// If we have a witness signature, put a witness UTXO.
// TODO: For segwit v1, we should remove the non_witness_utxo
if (sigdata.witness) {
input.witness_utxo = utxo;
input.non_witness_utxo = nullptr;
// input.non_witness_utxo = nullptr;
}
// Fill in the missing info