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:
MarcoFalke
2026-03-11 11:55:41 +01:00
parent fa4d5891b9
commit fadf901fd4
5 changed files with 42 additions and 16 deletions

View File

@@ -294,6 +294,15 @@ struct RPCArg {
struct RPCResultOptions {
bool skip_type_check{false};
/// Whether to treat this as elided in the human-readable description, and
/// possibly supply a description for the elision. Normally, there will be
/// one string on any of the elided results, for example `Same output as
/// verbosity = 1`, and all other elided strings will be empty.
///
/// - If nullopt: normal display.
/// - If empty string: suppress from help.
/// - If non-empty: show "..." with this description.
std::optional<std::string> print_elision{std::nullopt};
};
// NOLINTNEXTLINE(misc-no-recursion)
struct RPCResult {