mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge #19215: psbt: Include and allow both non_witness_utxo and witness_utxo for segwit inputs
84d295e513tests: Check that segwit inputs in psbt have both UTXO types (Andrew Chow)4600479058psbt: always put a non_witness_utxo and don't remove it (Andrew Chow)5279d8bc07psbt: Allow both non_witness_utxo and witness_utxo (Andrew Chow)72f6bec1darpc: show both UTXOs in decodepsbt (Andrew Chow) Pull request description: Due to recent changes to hardware wallets, the full previous transaction will need to be provided for segwit inputs. Since some software may be checking for the existence of a `witness_utxo` to determine whether to produce a segwit signature, we keep that field to ease the transition. Because all of the sanity checks implemented by the `IsSane` functions were related to having mixed segwit and non-segwit data in a PSBT, those functions are removed as those checks are no longer proper. Some tests are updated/removed to accommodate this and a simple test added to check that both UTXOs are being added to segwit inputs. As discussed in the wallet IRC meeting, our own signer will not require `non_witness_utxo` for segwit inputs. ACKs for top commit: Sjors: utACK84d295e513(didn't retest compared to 836d6fc, but fortunately HWI's CI tracks our master branch, with a bunch of hardware wallet simulators) ryanofsky: Code review re-ACK84d295e513. No changes since last review, but now I understand the context better. I think it would good to improve the comments as suggested https://github.com/bitcoin/bitcoin/pull/19215#discussion_r447889473 and maybe refer to meshcollider: utACK84d295e513Tree-SHA512: ccc1fd3c16ac3859f5aca4fa489bd40f68be0b81bbdc4dd51188bbf28827a8642dc8b605a37318e5f16cf40f1c4910052dace2f27eca21bb58435f02a443e940
This commit is contained in:
@@ -1104,6 +1104,7 @@ UniValue decodepsbt(const JSONRPCRequest& request)
|
||||
const PSBTInput& input = psbtx.inputs[i];
|
||||
UniValue in(UniValue::VOBJ);
|
||||
// UTXOs
|
||||
bool have_a_utxo = false;
|
||||
if (!input.witness_utxo.IsNull()) {
|
||||
const CTxOut& txout = input.witness_utxo;
|
||||
|
||||
@@ -1121,7 +1122,9 @@ UniValue decodepsbt(const JSONRPCRequest& request)
|
||||
ScriptToUniv(txout.scriptPubKey, o, true);
|
||||
out.pushKV("scriptPubKey", o);
|
||||
in.pushKV("witness_utxo", out);
|
||||
} else if (input.non_witness_utxo) {
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (input.non_witness_utxo) {
|
||||
UniValue non_wit(UniValue::VOBJ);
|
||||
TxToUniv(*input.non_witness_utxo, uint256(), non_wit, false);
|
||||
in.pushKV("non_witness_utxo", non_wit);
|
||||
@@ -1132,7 +1135,9 @@ UniValue decodepsbt(const JSONRPCRequest& request)
|
||||
// Hack to just not show fee later
|
||||
have_all_utxos = false;
|
||||
}
|
||||
} else {
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (!have_a_utxo) {
|
||||
have_all_utxos = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user