Skip to content

Commit 36dc5bb

Browse files
committed
doc: Extract CreateTxDoc in rawtransaction
For the fields: inputs, outputs, locktime, replaceable
1 parent c9d7d0a commit 36dc5bb

File tree

1 file changed

+39
-66
lines changed

1 file changed

+39
-66
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 39 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,43 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
6969
}
7070
}
7171

72+
static std::vector<RPCArg> CreateTxDoc()
73+
{
74+
return {
75+
{"inputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The inputs",
76+
{
77+
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
78+
{
79+
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
80+
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
81+
{"sequence", RPCArg::Type::NUM, RPCArg::DefaultHint{"depends on the value of the 'replaceable' and 'locktime' arguments"}, "The sequence number"},
82+
},
83+
},
84+
},
85+
},
86+
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The outputs (key-value pairs), where none of the keys are duplicated.\n"
87+
"That is, each address can only appear once and there can only be one 'data' object.\n"
88+
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
89+
" accepted as second parameter.",
90+
{
91+
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
92+
{
93+
{"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},
94+
},
95+
},
96+
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
97+
{
98+
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
99+
},
100+
},
101+
},
102+
},
103+
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
104+
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{false}, "Marks this transaction as BIP125-replaceable.\n"
105+
"Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
106+
};
107+
}
108+
72109
static RPCHelpMan getrawtransaction()
73110
{
74111
return RPCHelpMan{
@@ -375,39 +412,7 @@ static RPCHelpMan createrawtransaction()
375412
"Returns hex-encoded raw transaction.\n"
376413
"Note that the transaction's inputs are not signed, and\n"
377414
"it is not stored in the wallet or transmitted to the network.\n",
378-
{
379-
{"inputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The inputs",
380-
{
381-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
382-
{
383-
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
384-
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
385-
{"sequence", RPCArg::Type::NUM, RPCArg::DefaultHint{"depends on the value of the 'replaceable' and 'locktime' arguments"}, "The sequence number"},
386-
},
387-
},
388-
},
389-
},
390-
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The outputs (key-value pairs), where none of the keys are duplicated.\n"
391-
"That is, each address can only appear once and there can only be one 'data' object.\n"
392-
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
393-
" accepted as second parameter.",
394-
{
395-
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
396-
{
397-
{"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},
398-
},
399-
},
400-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
401-
{
402-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
403-
},
404-
},
405-
},
406-
},
407-
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
408-
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{false}, "Marks this transaction as BIP125-replaceable.\n"
409-
" Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
410-
},
415+
CreateTxDoc(),
411416
RPCResult{
412417
RPCResult::Type::STR_HEX, "transaction", "hex string of the transaction"
413418
},
@@ -1435,39 +1440,7 @@ static RPCHelpMan createpsbt()
14351440
return RPCHelpMan{"createpsbt",
14361441
"\nCreates a transaction in the Partially Signed Transaction format.\n"
14371442
"Implements the Creator role.\n",
1438-
{
1439-
{"inputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The json objects",
1440-
{
1441-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
1442-
{
1443-
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
1444-
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
1445-
{"sequence", RPCArg::Type::NUM, RPCArg::DefaultHint{"depends on the value of the 'replaceable' and 'locktime' arguments"}, "The sequence number"},
1446-
},
1447-
},
1448-
},
1449-
},
1450-
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "The outputs (key-value pairs), where none of the keys are duplicated.\n"
1451-
"That is, each address can only appear once and there can only be one 'data' object.\n"
1452-
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
1453-
" accepted as second parameter.",
1454-
{
1455-
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
1456-
{
1457-
{"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},
1458-
},
1459-
},
1460-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
1461-
{
1462-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
1463-
},
1464-
},
1465-
},
1466-
},
1467-
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
1468-
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{false}, "Marks this transaction as BIP125 replaceable.\n"
1469-
" Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
1470-
},
1443+
CreateTxDoc(),
14711444
RPCResult{
14721445
RPCResult::Type::STR, "", "The resulting raw transaction (base64-encoded string)"
14731446
},

0 commit comments

Comments
 (0)