From 88e2a6ae89a224f53422ec33734b3243f64d63c0 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Tue, 17 Mar 2026 00:44:57 -0300 Subject: [PATCH] rpc: expand getaddressinfo embedded with explicit fields Replace the ELISION entry inside getaddressinfo's embedded object with explicit fields using ElideGroup(). Factor the embedded field list into a helper so the nested layout can be reused without duplicating the full structure inline. --- src/wallet/rpc/addresses.cpp | 58 ++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index ed966d89441..8feae478632 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -365,6 +365,52 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio return ret; } +// NOLINTNEXTLINE(misc-no-recursion) +static std::vector GetAddressInfoEmbeddedFields(bool include_nested) +{ + auto fields = std::vector{ + {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the embedded script."}, + {RPCResult::Type::STR_HEX, "scriptPubKey", /*optional=*/true, "The hex-encoded output script generated by the address."}, + {RPCResult::Type::BOOL, "isscript", /*optional=*/true, "If the key is a script."}, + {RPCResult::Type::BOOL, "iswitness", /*optional=*/true, "If the address is a witness address."}, + {RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program."}, + {RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program."}, + {RPCResult::Type::STR, "script", /*optional=*/true, + "The output script type. Only if isscript is true and the redeemscript is known. Possible\n" + "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n" + "witness_v0_scripthash, witness_unknown."}, + {RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The redeemscript for the p2sh address."}, + {RPCResult::Type::ARR, "pubkeys", /*optional=*/true, + "Array of pubkeys associated with the known redeemscript (only if script is multisig).", + { + {RPCResult::Type::STR, "pubkey", ""}, + }}, + {RPCResult::Type::NUM, "sigsrequired", /*optional=*/true, + "The number of signatures required to spend multisig output (only if script is multisig)."}, + {RPCResult::Type::STR_HEX, "pubkey", /*optional=*/true, + "The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."}, + }; + + if (include_nested) { + fields.emplace_back( + RPCResult::Type::OBJ, + "embedded", + /*optional=*/true, + "Information about the address embedded in P2SH or P2WSH, if relevant and known.", + GetAddressInfoEmbeddedFields(/*include_nested=*/false) + ); + } + + fields.emplace_back( + RPCResult::Type::BOOL, + "iscompressed", + /*optional=*/true, + "If the pubkey is compressed." + ); + + return fields; +} + RPCMethod getaddressinfo() { return RPCMethod{ @@ -399,11 +445,13 @@ RPCMethod getaddressinfo() }}, {RPCResult::Type::NUM, "sigsrequired", /*optional=*/true, "The number of signatures required to spend multisig output (only if script is multisig)."}, {RPCResult::Type::STR_HEX, "pubkey", /*optional=*/true, "The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."}, - {RPCResult::Type::OBJ, "embedded", /*optional=*/true, "Information about the address embedded in P2SH or P2WSH, if relevant and known.", - { - {RPCResult::Type::ELISION, "", "Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n" - "and relation to the wallet (ismine)."}, - }}, + {RPCResult::Type::OBJ, "embedded", /*optional=*/true, + "Information about the address embedded in P2SH or P2WSH, if relevant and known.", + ElideGroup( + GetAddressInfoEmbeddedFields(/*include_nested=*/true), + "Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n" + "and relation to the wallet (ismine)." + )}, {RPCResult::Type::BOOL, "iscompressed", /*optional=*/true, "If the pubkey is compressed."}, {RPCResult::Type::NUM_TIME, "timestamp", /*optional=*/true, "The creation time of the key, if available, expressed in " + UNIX_EPOCH_TIME + "."}, {RPCResult::Type::STR, "hdkeypath", /*optional=*/true, "The HD keypath, if the key is HD and available."},