0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

rpc, refactor: Add decodepsbt_outputs

This change eliminates memory usage spike when compiling with Visual
Studio 2022 (at least in Cirrus CI environment).

Easy to review using
`git diff --color-moved-ws=allow-indentation-change --color-moved=dimmed-zebra`
This commit is contained in:
Hennadii Stepanov 2022-07-01 01:21:04 +02:00
parent 0c432cbbfa
commit 555f9dd5d3
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -807,6 +807,73 @@ const RPCResult decodepsbt_inputs{
}
};
const RPCResult decodepsbt_outputs{
RPCResult::Type::ARR, "outputs", "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
{
{RPCResult::Type::STR, "asm", "The asm"},
{RPCResult::Type::STR_HEX, "hex", "The hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
}},
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
{
{RPCResult::Type::STR, "asm", "The asm"},
{RPCResult::Type::STR_HEX, "hex", "The hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
}},
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "pubkey", "The public key this path corresponds to"},
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
{RPCResult::Type::STR, "path", "The path"},
}},
}},
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
{RPCResult::Type::ARR, "taproot_tree", /*optional=*/ true, "The tuples that make up the Taproot tree, in depth first search order",
{
{RPCResult::Type::OBJ, "tuple", /*optional=*/ true, "A single leaf script in the taproot tree",
{
{RPCResult::Type::NUM, "depth", "The depth of this element in the tree"},
{RPCResult::Type::NUM, "leaf_ver", "The version of this leaf"},
{RPCResult::Type::STR, "script", "The hex-encoded script itself"},
}},
}},
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
{RPCResult::Type::STR, "path", "The path"},
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
{
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
}},
}},
}},
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/true, "The unknown output fields",
{
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
}},
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The output proprietary map",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
}},
}},
}},
}
};
static RPCHelpMan decodepsbt()
{
return RPCHelpMan{
@ -847,70 +914,7 @@ static RPCHelpMan decodepsbt()
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
}},
decodepsbt_inputs,
{RPCResult::Type::ARR, "outputs", "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
{
{RPCResult::Type::STR, "asm", "The asm"},
{RPCResult::Type::STR_HEX, "hex", "The hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
}},
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
{
{RPCResult::Type::STR, "asm", "The asm"},
{RPCResult::Type::STR_HEX, "hex", "The hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
}},
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "pubkey", "The public key this path corresponds to"},
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
{RPCResult::Type::STR, "path", "The path"},
}},
}},
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
{RPCResult::Type::ARR, "taproot_tree", /*optional=*/ true, "The tuples that make up the Taproot tree, in depth first search order",
{
{RPCResult::Type::OBJ, "tuple", /*optional=*/ true, "A single leaf script in the taproot tree",
{
{RPCResult::Type::NUM, "depth", "The depth of this element in the tree"},
{RPCResult::Type::NUM, "leaf_ver", "The version of this leaf"},
{RPCResult::Type::STR, "script", "The hex-encoded script itself"},
}},
}},
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
{RPCResult::Type::STR, "path", "The path"},
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
{
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
}},
}},
}},
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/true, "The unknown output fields",
{
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
}},
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The output proprietary map",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
}},
}},
}},
}},
decodepsbt_outputs,
{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The transaction fee paid if all UTXOs slots in the PSBT have been filled."},
}
},