Skip to content

Commit a804f3c

Browse files
committed
wallet: extract and reuse RPC argument format definition for outputs
1 parent 635f190 commit a804f3c

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/wallet/rpc/spend.cpp

+23-25
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,26 @@ RPCHelpMan signrawtransactionwithwallet()
957957
};
958958
}
959959

960+
// Definition of allowed formats of specifying transaction outputs in
961+
// `send` and `walletcreatefundedpsbt` RPCs.
962+
static std::vector<RPCArg> OutputsDoc()
963+
{
964+
return
965+
{
966+
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
967+
{
968+
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the bitcoin address,\n"
969+
"the value (float or string) is the amount in " + CURRENCY_UNIT + ""},
970+
},
971+
},
972+
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
973+
{
974+
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
975+
},
976+
},
977+
};
978+
}
979+
960980
static RPCHelpMan bumpfee_helper(std::string method_name)
961981
{
962982
const bool want_psbt = method_name == "psbtbumpfee";
@@ -1145,18 +1165,7 @@ RPCHelpMan send()
11451165
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The outputs (key-value pairs), where none of the keys are duplicated.\n"
11461166
"That is, each address can only appear once and there can only be one 'data' object.\n"
11471167
"For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
1148-
{
1149-
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
1150-
{
1151-
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + ""},
1152-
},
1153-
},
1154-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
1155-
{
1156-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
1157-
},
1158-
},
1159-
},
1168+
OutputsDoc(),
11601169
RPCArgOptions{.skip_type_check = true}},
11611170
{"conf_target", RPCArg::Type::NUM, RPCArg::DefaultHint{"wallet -txconfirmtarget"}, "Confirmation target in blocks"},
11621171
{"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"unset"}, "The fee estimate mode, must be one of (case insensitive):\n"
@@ -1607,19 +1616,8 @@ RPCHelpMan walletcreatefundedpsbt()
16071616
"That is, each address can only appear once and there can only be one 'data' object.\n"
16081617
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
16091618
"accepted as second parameter.",
1610-
{
1611-
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
1612-
{
1613-
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + ""},
1614-
},
1615-
},
1616-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
1617-
{
1618-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
1619-
},
1620-
},
1621-
},
1622-
RPCArgOptions{.skip_type_check = true}},
1619+
OutputsDoc(),
1620+
RPCArgOptions{.skip_type_check = true}},
16231621
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
16241622
{"options", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "",
16251623
Cat<std::vector<RPCArg>>(

0 commit comments

Comments
 (0)