If a witness signature was created when a non-witness UTXO is used, convert the non-witness UTXO to a witness one.
Port of #14196 to master.
275 | @@ -276,6 +276,13 @@ bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& t 276 | // Verify that a witness signature was produced in case one was required. 277 | if (require_witness_sig && !sigdata.witness) return false; 278 | input.FromSignatureData(sigdata); 279 | +
Travis is complaining about whitespace here.
Fixed
ACK
utACK 52d9adcdfbf545cb9a9facb482cb3673578abfa0. I'll test this soon.
276 | @@ -277,6 +277,13 @@ bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& t 277 | if (require_witness_sig && !sigdata.witness) return false; 278 | input.FromSignatureData(sigdata); 279 | 280 | + if (sigdata.witness) { 281 | + // Convert the non-witness utxo to witness 282 | + if (input.witness_utxo.IsNull() && input.non_witness_utxo) { 283 | + input.witness_utxo = input.non_witness_utxo->vout[tx.vin[index].prevout.n];
IIUC this could be
assert(!utxo.IsNull());
input.witness_utxo = utxo;
Indeed. Done.
Here is a test that fails before and succeeds after this PR: https://github.com/sipa/bitcoin/commit/ce238f2aff3253cdde88d0f9b995b7e0016cb52b
If a witness signature was created when a non-witness UTXO is used,
convert the non-witness UTXO to a witness one.
<!--e57a25ab6845829454e8d69fc972939a-->Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ACK 862d159d635c1de219d94e030b186a745fe28eb9
5 | @@ -6,7 +6,7 @@ 6 | """ 7 | 8 | from test_framework.test_framework import BitcoinTestFramework 9 | -from test_framework.util import assert_equal, assert_raises_rpc_error, find_output 10 | +from test_framework.util import assert_equal, assert_raises_rpc_error, find_output, disconnect_nodes, connect_nodes_bi, sync_blocks
nit, nit, nit, sort.
utACK 862d159.
<!--32850dd3fdea838b4049e64f46995ea2-->
| Coverage | Change (pull 14197) | Reference (master) |
|---|---|---|
| Lines | +0.0163 % | 87.0361 % |
| Functions | +0.1081 % | 84.1130 % |
| Branches | -0.0057 % | 51.5451 % |
utACK 862d159d635c1de219d94e030b186a745fe28eb9