Skip to content

Commit 555f9dd

Browse files
committed
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`
1 parent 0c432cb commit 555f9dd

File tree

1 file changed

+68
-64
lines changed

1 file changed

+68
-64
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 68 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,73 @@ const RPCResult decodepsbt_inputs{
807807
}
808808
};
809809

810+
const RPCResult decodepsbt_outputs{
811+
RPCResult::Type::ARR, "outputs", "",
812+
{
813+
{RPCResult::Type::OBJ, "", "",
814+
{
815+
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
816+
{
817+
{RPCResult::Type::STR, "asm", "The asm"},
818+
{RPCResult::Type::STR_HEX, "hex", "The hex"},
819+
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
820+
}},
821+
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
822+
{
823+
{RPCResult::Type::STR, "asm", "The asm"},
824+
{RPCResult::Type::STR_HEX, "hex", "The hex"},
825+
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
826+
}},
827+
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
828+
{
829+
{RPCResult::Type::OBJ, "", "",
830+
{
831+
{RPCResult::Type::STR, "pubkey", "The public key this path corresponds to"},
832+
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
833+
{RPCResult::Type::STR, "path", "The path"},
834+
}},
835+
}},
836+
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
837+
{RPCResult::Type::ARR, "taproot_tree", /*optional=*/ true, "The tuples that make up the Taproot tree, in depth first search order",
838+
{
839+
{RPCResult::Type::OBJ, "tuple", /*optional=*/ true, "A single leaf script in the taproot tree",
840+
{
841+
{RPCResult::Type::NUM, "depth", "The depth of this element in the tree"},
842+
{RPCResult::Type::NUM, "leaf_ver", "The version of this leaf"},
843+
{RPCResult::Type::STR, "script", "The hex-encoded script itself"},
844+
}},
845+
}},
846+
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
847+
{
848+
{RPCResult::Type::OBJ, "", "",
849+
{
850+
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
851+
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
852+
{RPCResult::Type::STR, "path", "The path"},
853+
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
854+
{
855+
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
856+
}},
857+
}},
858+
}},
859+
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/true, "The unknown output fields",
860+
{
861+
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
862+
}},
863+
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The output proprietary map",
864+
{
865+
{RPCResult::Type::OBJ, "", "",
866+
{
867+
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
868+
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
869+
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
870+
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
871+
}},
872+
}},
873+
}},
874+
}
875+
};
876+
810877
static RPCHelpMan decodepsbt()
811878
{
812879
return RPCHelpMan{
@@ -847,70 +914,7 @@ static RPCHelpMan decodepsbt()
847914
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
848915
}},
849916
decodepsbt_inputs,
850-
{RPCResult::Type::ARR, "outputs", "",
851-
{
852-
{RPCResult::Type::OBJ, "", "",
853-
{
854-
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
855-
{
856-
{RPCResult::Type::STR, "asm", "The asm"},
857-
{RPCResult::Type::STR_HEX, "hex", "The hex"},
858-
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
859-
}},
860-
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
861-
{
862-
{RPCResult::Type::STR, "asm", "The asm"},
863-
{RPCResult::Type::STR_HEX, "hex", "The hex"},
864-
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
865-
}},
866-
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
867-
{
868-
{RPCResult::Type::OBJ, "", "",
869-
{
870-
{RPCResult::Type::STR, "pubkey", "The public key this path corresponds to"},
871-
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
872-
{RPCResult::Type::STR, "path", "The path"},
873-
}},
874-
}},
875-
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
876-
{RPCResult::Type::ARR, "taproot_tree", /*optional=*/ true, "The tuples that make up the Taproot tree, in depth first search order",
877-
{
878-
{RPCResult::Type::OBJ, "tuple", /*optional=*/ true, "A single leaf script in the taproot tree",
879-
{
880-
{RPCResult::Type::NUM, "depth", "The depth of this element in the tree"},
881-
{RPCResult::Type::NUM, "leaf_ver", "The version of this leaf"},
882-
{RPCResult::Type::STR, "script", "The hex-encoded script itself"},
883-
}},
884-
}},
885-
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
886-
{
887-
{RPCResult::Type::OBJ, "", "",
888-
{
889-
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
890-
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
891-
{RPCResult::Type::STR, "path", "The path"},
892-
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
893-
{
894-
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
895-
}},
896-
}},
897-
}},
898-
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/true, "The unknown output fields",
899-
{
900-
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
901-
}},
902-
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The output proprietary map",
903-
{
904-
{RPCResult::Type::OBJ, "", "",
905-
{
906-
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
907-
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
908-
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
909-
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
910-
}},
911-
}},
912-
}},
913-
}},
917+
decodepsbt_outputs,
914918
{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The transaction fee paid if all UTXOs slots in the PSBT have been filled."},
915919
}
916920
},

0 commit comments

Comments
 (0)