mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-13 00:57:24 +02:00
rpc: Run type check on decodepsbt result
For RPCResults, the type may be ELISION, which is confusing and brittle:
* The elision should only affect the help output, not the type.
* The type should be the real type, so that type checks can be run on
it.
Fix this issue by introducing a new print_elision option and using it
in decodepsbt.
This change will ensure that RPCResult::MatchesType is properly run.
Also, this clarifies the RPC output minimally:
```diff
--- a/decodepsbt
+++ b/decodepsbt
@@ -35,7 +35,7 @@ Result:
"inputs" : [ (json array)
{ (json object)
"non_witness_utxo" : { (json object, optional) Decoded network transaction for non-witness UTXOs
- ...
+ ... The layout is the same as the output of decoderawtransaction.
},
"witness_utxo" : { (json object, optional) Transaction output for witness UTXOs
"amount" : n, (numeric) The value in BTC
```
This commit is contained in:
@@ -781,9 +781,8 @@ const RPCResult decodepsbt_inputs{
|
||||
{RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{RPCResult::Type::OBJ, "non_witness_utxo", /*optional=*/true, "Decoded network transaction for non-witness UTXOs",
|
||||
{
|
||||
{RPCResult::Type::ELISION, "",""},
|
||||
}},
|
||||
TxDoc({.elision_description="The layout is the same as the output of decoderawtransaction."})
|
||||
},
|
||||
{RPCResult::Type::OBJ, "witness_utxo", /*optional=*/true, "Transaction output for witness UTXOs",
|
||||
{
|
||||
{RPCResult::Type::NUM, "amount", "The value in " + CURRENCY_UNIT},
|
||||
@@ -1023,9 +1022,8 @@ static RPCHelpMan decodepsbt()
|
||||
RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{RPCResult::Type::OBJ, "tx", "The decoded network-serialized unsigned transaction.",
|
||||
{
|
||||
{RPCResult::Type::ELISION, "", "The layout is the same as the output of decoderawtransaction."},
|
||||
}},
|
||||
TxDoc({.elision_description="The layout is the same as the output of decoderawtransaction."})
|
||||
},
|
||||
{RPCResult::Type::ARR, "global_xpubs", "",
|
||||
{
|
||||
{RPCResult::Type::OBJ, "", "",
|
||||
|
||||
Reference in New Issue
Block a user