I don’t think output descriptors should be used to describe redeem scripts and witness scripts.
Fix this by excluding them when it doesn’t make sense.
This should only affect the decodepsbt
RPC.
I don’t think output descriptors should be used to describe redeem scripts and witness scripts.
Fix this by excluding them when it doesn’t make sense.
This should only affect the decodepsbt
RPC.
ACK faf37c217a408114224f91b7ada3fb6ff29b0c0a
This change adds a “desc” field that was missing from the “witness_utxo” decodepsbt inputs help and IIUC removes undocumented “desc” descriptor fields from the decodepsbt inputs and outputs “redeem_script” and “witness_script” result objects.
Code review:
ScriptPubKeyToUniv()
is declared with include_address = true
by default
0src/core_io.h:56:void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
and is invoked once in decodepsbt in the witness inputs code
0 // inputs
1 CAmount total_in = 0;
2 bool have_all_utxos = true;
3 UniValue inputs(UniValue::VARR);
4 for (unsigned int i = 0; i < psbtx.inputs.size(); ++i) {
5 const PSBTInput& input = psbtx.inputs[i];
6 UniValue in(UniValue::VOBJ);
7 // UTXOs
8 bool have_a_utxo = false;
9 CTxOut txout;
10 if (!input.witness_utxo.IsNull()) {
11 txout = input.witness_utxo;
12
13 UniValue o(UniValue::VOBJ);
14 ScriptPubKeyToUniv(txout.scriptPubKey, o, /* include_hex */ true);
15
16 UniValue out(UniValue::VOBJ);
17 out.pushKV("amount", ValueFromAmount(txout.nValue));
18 out.pushKV("scriptPubKey", o);
19
20 in.pushKV("witness_utxo", out);
21
22 have_a_utxo = true;
23 }
relevant updated decodepsbt help
0 "inputs" : [ (json array)
1 { (json object)
2 "non_witness_utxo" : { (json object, optional) Decoded network transaction for non-witness UTXOs
3 ...
4 },
5 "witness_utxo" : { (json object, optional) Transaction output for witness UTXOs
6 "amount" : n, (numeric) The value in BTC
7 "scriptPubKey" : { (json object)
8 "asm" : "str", (string) The asm
9 "desc" : "str", (string) Inferred descriptor for the output
10 "hex" : "hex", (string) The hex
11 "type" : "str", (string) The type, eg 'pubkeyhash'
12 "address" : "str" (string, optional) The Bitcoin address (only if a well-defined address exists)
13 }
OTOH ScriptToUniv()
is the only caller to invoke ScriptPubKeyToUniv()
with include_address = false
, and outside of a fuzz test is only called in decodepsbt inputs and outputs “redeem_script” and “witness_script” result code and so with this pull the descriptor will be excluded
0void ScriptToUniv(const CScript& script, UniValue& out)
1{
2 ScriptPubKeyToUniv(script, out, /* include_hex */ true, /* include_address */ false);
3}