Skip to content

Commit 0c432cb

Browse files
committed
rpc, refactor: Add decodepsbt_inputs
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 01d95a3 commit 0c432cb

File tree

1 file changed

+128
-124
lines changed

1 file changed

+128
-124
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 128 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,133 @@ static RPCHelpMan signrawtransactionwithkey()
680680
};
681681
}
682682

683+
const RPCResult decodepsbt_inputs{
684+
RPCResult::Type::ARR, "inputs", "",
685+
{
686+
{RPCResult::Type::OBJ, "", "",
687+
{
688+
{RPCResult::Type::OBJ, "non_witness_utxo", /*optional=*/true, "Decoded network transaction for non-witness UTXOs",
689+
{
690+
{RPCResult::Type::ELISION, "",""},
691+
}},
692+
{RPCResult::Type::OBJ, "witness_utxo", /*optional=*/true, "Transaction output for witness UTXOs",
693+
{
694+
{RPCResult::Type::NUM, "amount", "The value in " + CURRENCY_UNIT},
695+
{RPCResult::Type::OBJ, "scriptPubKey", "",
696+
{
697+
{RPCResult::Type::STR, "asm", "The asm"},
698+
{RPCResult::Type::STR, "desc", "Inferred descriptor for the output"},
699+
{RPCResult::Type::STR_HEX, "hex", "The hex"},
700+
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
701+
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
702+
}},
703+
}},
704+
{RPCResult::Type::OBJ_DYN, "partial_signatures", /*optional=*/true, "",
705+
{
706+
{RPCResult::Type::STR, "pubkey", "The public key and signature that corresponds to it."},
707+
}},
708+
{RPCResult::Type::STR, "sighash", /*optional=*/true, "The sighash type to be used"},
709+
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
710+
{
711+
{RPCResult::Type::STR, "asm", "The asm"},
712+
{RPCResult::Type::STR_HEX, "hex", "The hex"},
713+
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
714+
}},
715+
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
716+
{
717+
{RPCResult::Type::STR, "asm", "The asm"},
718+
{RPCResult::Type::STR_HEX, "hex", "The hex"},
719+
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
720+
}},
721+
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
722+
{
723+
{RPCResult::Type::OBJ, "", "",
724+
{
725+
{RPCResult::Type::STR, "pubkey", "The public key with the derivation path as the value."},
726+
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
727+
{RPCResult::Type::STR, "path", "The path"},
728+
}},
729+
}},
730+
{RPCResult::Type::OBJ, "final_scriptSig", /*optional=*/true, "",
731+
{
732+
{RPCResult::Type::STR, "asm", "The asm"},
733+
{RPCResult::Type::STR, "hex", "The hex"},
734+
}},
735+
{RPCResult::Type::ARR, "final_scriptwitness", /*optional=*/true, "",
736+
{
737+
{RPCResult::Type::STR_HEX, "", "hex-encoded witness data (if any)"},
738+
}},
739+
{RPCResult::Type::OBJ_DYN, "ripemd160_preimages", /*optional=*/ true, "",
740+
{
741+
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
742+
}},
743+
{RPCResult::Type::OBJ_DYN, "sha256_preimages", /*optional=*/ true, "",
744+
{
745+
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
746+
}},
747+
{RPCResult::Type::OBJ_DYN, "hash160_preimages", /*optional=*/ true, "",
748+
{
749+
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
750+
}},
751+
{RPCResult::Type::OBJ_DYN, "hash256_preimages", /*optional=*/ true, "",
752+
{
753+
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
754+
}},
755+
{RPCResult::Type::STR_HEX, "taproot_key_path_sig", /*optional=*/ true, "hex-encoded signature for the Taproot key path spend"},
756+
{RPCResult::Type::ARR, "taproot_script_path_sigs", /*optional=*/ true, "",
757+
{
758+
{RPCResult::Type::OBJ, "signature", /*optional=*/ true, "The signature for the pubkey and leaf hash combination",
759+
{
760+
{RPCResult::Type::STR, "pubkey", "The x-only pubkey for this signature"},
761+
{RPCResult::Type::STR, "leaf_hash", "The leaf hash for this signature"},
762+
{RPCResult::Type::STR, "sig", "The signature itself"},
763+
}},
764+
}},
765+
{RPCResult::Type::ARR, "taproot_scripts", /*optional=*/ true, "",
766+
{
767+
{RPCResult::Type::OBJ, "", "",
768+
{
769+
{RPCResult::Type::STR_HEX, "script", "A leaf script"},
770+
{RPCResult::Type::NUM, "leaf_ver", "The version number for the leaf script"},
771+
{RPCResult::Type::ARR, "control_blocks", "The control blocks for this script",
772+
{
773+
{RPCResult::Type::STR_HEX, "control_block", "A hex-encoded control block for this script"},
774+
}},
775+
}},
776+
}},
777+
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
778+
{
779+
{RPCResult::Type::OBJ, "", "",
780+
{
781+
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
782+
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
783+
{RPCResult::Type::STR, "path", "The path"},
784+
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
785+
{
786+
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
787+
}},
788+
}},
789+
}},
790+
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
791+
{RPCResult::Type::STR_HEX, "taproot_merkle_root", /*optional=*/ true, "The hex-encoded Taproot merkle root"},
792+
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/ true, "The unknown input fields",
793+
{
794+
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
795+
}},
796+
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The input proprietary map",
797+
{
798+
{RPCResult::Type::OBJ, "", "",
799+
{
800+
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
801+
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
802+
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
803+
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
804+
}},
805+
}},
806+
}},
807+
}
808+
};
809+
683810
static RPCHelpMan decodepsbt()
684811
{
685812
return RPCHelpMan{
@@ -719,130 +846,7 @@ static RPCHelpMan decodepsbt()
719846
{
720847
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
721848
}},
722-
{RPCResult::Type::ARR, "inputs", "",
723-
{
724-
{RPCResult::Type::OBJ, "", "",
725-
{
726-
{RPCResult::Type::OBJ, "non_witness_utxo", /*optional=*/true, "Decoded network transaction for non-witness UTXOs",
727-
{
728-
{RPCResult::Type::ELISION, "",""},
729-
}},
730-
{RPCResult::Type::OBJ, "witness_utxo", /*optional=*/true, "Transaction output for witness UTXOs",
731-
{
732-
{RPCResult::Type::NUM, "amount", "The value in " + CURRENCY_UNIT},
733-
{RPCResult::Type::OBJ, "scriptPubKey", "",
734-
{
735-
{RPCResult::Type::STR, "asm", "The asm"},
736-
{RPCResult::Type::STR, "desc", "Inferred descriptor for the output"},
737-
{RPCResult::Type::STR_HEX, "hex", "The hex"},
738-
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
739-
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
740-
}},
741-
}},
742-
{RPCResult::Type::OBJ_DYN, "partial_signatures", /*optional=*/true, "",
743-
{
744-
{RPCResult::Type::STR, "pubkey", "The public key and signature that corresponds to it."},
745-
}},
746-
{RPCResult::Type::STR, "sighash", /*optional=*/true, "The sighash type to be used"},
747-
{RPCResult::Type::OBJ, "redeem_script", /*optional=*/true, "",
748-
{
749-
{RPCResult::Type::STR, "asm", "The asm"},
750-
{RPCResult::Type::STR_HEX, "hex", "The hex"},
751-
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
752-
}},
753-
{RPCResult::Type::OBJ, "witness_script", /*optional=*/true, "",
754-
{
755-
{RPCResult::Type::STR, "asm", "The asm"},
756-
{RPCResult::Type::STR_HEX, "hex", "The hex"},
757-
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
758-
}},
759-
{RPCResult::Type::ARR, "bip32_derivs", /*optional=*/true, "",
760-
{
761-
{RPCResult::Type::OBJ, "", "",
762-
{
763-
{RPCResult::Type::STR, "pubkey", "The public key with the derivation path as the value."},
764-
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
765-
{RPCResult::Type::STR, "path", "The path"},
766-
}},
767-
}},
768-
{RPCResult::Type::OBJ, "final_scriptSig", /*optional=*/true, "",
769-
{
770-
{RPCResult::Type::STR, "asm", "The asm"},
771-
{RPCResult::Type::STR, "hex", "The hex"},
772-
}},
773-
{RPCResult::Type::ARR, "final_scriptwitness", /*optional=*/true, "",
774-
{
775-
{RPCResult::Type::STR_HEX, "", "hex-encoded witness data (if any)"},
776-
}},
777-
{RPCResult::Type::OBJ_DYN, "ripemd160_preimages", /*optional=*/ true, "",
778-
{
779-
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
780-
}},
781-
{RPCResult::Type::OBJ_DYN, "sha256_preimages", /*optional=*/ true, "",
782-
{
783-
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
784-
}},
785-
{RPCResult::Type::OBJ_DYN, "hash160_preimages", /*optional=*/ true, "",
786-
{
787-
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
788-
}},
789-
{RPCResult::Type::OBJ_DYN, "hash256_preimages", /*optional=*/ true, "",
790-
{
791-
{RPCResult::Type::STR, "hash", "The hash and preimage that corresponds to it."},
792-
}},
793-
{RPCResult::Type::STR_HEX, "taproot_key_path_sig", /*optional=*/ true, "hex-encoded signature for the Taproot key path spend"},
794-
{RPCResult::Type::ARR, "taproot_script_path_sigs", /*optional=*/ true, "",
795-
{
796-
{RPCResult::Type::OBJ, "signature", /*optional=*/ true, "The signature for the pubkey and leaf hash combination",
797-
{
798-
{RPCResult::Type::STR, "pubkey", "The x-only pubkey for this signature"},
799-
{RPCResult::Type::STR, "leaf_hash", "The leaf hash for this signature"},
800-
{RPCResult::Type::STR, "sig", "The signature itself"},
801-
}},
802-
}},
803-
{RPCResult::Type::ARR, "taproot_scripts", /*optional=*/ true, "",
804-
{
805-
{RPCResult::Type::OBJ, "", "",
806-
{
807-
{RPCResult::Type::STR_HEX, "script", "A leaf script"},
808-
{RPCResult::Type::NUM, "leaf_ver", "The version number for the leaf script"},
809-
{RPCResult::Type::ARR, "control_blocks", "The control blocks for this script",
810-
{
811-
{RPCResult::Type::STR_HEX, "control_block", "A hex-encoded control block for this script"},
812-
}},
813-
}},
814-
}},
815-
{RPCResult::Type::ARR, "taproot_bip32_derivs", /*optional=*/ true, "",
816-
{
817-
{RPCResult::Type::OBJ, "", "",
818-
{
819-
{RPCResult::Type::STR, "pubkey", "The x-only public key this path corresponds to"},
820-
{RPCResult::Type::STR, "master_fingerprint", "The fingerprint of the master key"},
821-
{RPCResult::Type::STR, "path", "The path"},
822-
{RPCResult::Type::ARR, "leaf_hashes", "The hashes of the leaves this pubkey appears in",
823-
{
824-
{RPCResult::Type::STR_HEX, "hash", "The hash of a leaf this pubkey appears in"},
825-
}},
826-
}},
827-
}},
828-
{RPCResult::Type::STR_HEX, "taproot_internal_key", /*optional=*/ true, "The hex-encoded Taproot x-only internal key"},
829-
{RPCResult::Type::STR_HEX, "taproot_merkle_root", /*optional=*/ true, "The hex-encoded Taproot merkle root"},
830-
{RPCResult::Type::OBJ_DYN, "unknown", /*optional=*/ true, "The unknown input fields",
831-
{
832-
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
833-
}},
834-
{RPCResult::Type::ARR, "proprietary", /*optional=*/true, "The input proprietary map",
835-
{
836-
{RPCResult::Type::OBJ, "", "",
837-
{
838-
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
839-
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
840-
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
841-
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
842-
}},
843-
}},
844-
}},
845-
}},
849+
decodepsbt_inputs,
846850
{RPCResult::Type::ARR, "outputs", "",
847851
{
848852
{RPCResult::Type::OBJ, "", "",

0 commit comments

Comments
 (0)