diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index 8feae478632..02d59a79188 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -366,9 +366,9 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio } // NOLINTNEXTLINE(misc-no-recursion) -static std::vector GetAddressInfoEmbeddedFields(bool include_nested) +static std::vector GetAddressInfoBaseFields() { - auto fields = std::vector{ + return { {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."}, @@ -389,25 +389,25 @@ static std::vector GetAddressInfoEmbeddedFields(bool include_nested) "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::BOOL, "iscompressed", /*optional=*/true, "If the pubkey is compressed."}, }; +} + +static std::vector GetAddressInfoEmbeddedFields(bool include_nested) +{ + auto fields = GetAddressInfoBaseFields(); if (include_nested) { + auto nested = GetAddressInfoBaseFields(); 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) + std::move(nested) ); } - fields.emplace_back( - RPCResult::Type::BOOL, - "iscompressed", - /*optional=*/true, - "If the pubkey is compressed." - ); - return fields; }