rpc: factor getaddressinfo embedded field docs

Keep the repeated embedded address documentation in one helper so the OpenRPC metadata and help text stay consistent without duplicating the same field list.
This commit is contained in:
will
2026-03-19 13:35:14 +00:00
committed by willcl-ark
parent 1fb6b60560
commit ef0676f400

View File

@@ -366,9 +366,9 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio
}
// NOLINTNEXTLINE(misc-no-recursion)
static std::vector<RPCResult> GetAddressInfoEmbeddedFields(bool include_nested)
static std::vector<RPCResult> GetAddressInfoBaseFields()
{
auto fields = std::vector<RPCResult>{
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<RPCResult> 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<RPCResult> 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;
}