35
35
#include < util/bip32.h>
36
36
#include < util/strencodings.h>
37
37
#include < util/string.h>
38
+ #include < util/vector.h>
38
39
#include < validation.h>
39
40
#include < validationinterface.h>
40
41
@@ -77,6 +78,54 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
77
78
}
78
79
}
79
80
81
+ static std::vector<RPCResult> DecodeTxDoc (const std::string& txid_field_doc)
82
+ {
83
+ return {
84
+ {RPCResult::Type::STR_HEX, " txid" , txid_field_doc},
85
+ {RPCResult::Type::STR_HEX, " hash" , " The transaction hash (differs from txid for witness transactions)" },
86
+ {RPCResult::Type::NUM, " size" , " The serialized transaction size" },
87
+ {RPCResult::Type::NUM, " vsize" , " The virtual transaction size (differs from size for witness transactions)" },
88
+ {RPCResult::Type::NUM, " weight" , " The transaction's weight (between vsize*4-3 and vsize*4)" },
89
+ {RPCResult::Type::NUM, " version" , " The version" },
90
+ {RPCResult::Type::NUM_TIME, " locktime" , " The lock time" },
91
+ {RPCResult::Type::ARR, " vin" , " " ,
92
+ {
93
+ {RPCResult::Type::OBJ, " " , " " ,
94
+ {
95
+ {RPCResult::Type::STR_HEX, " coinbase" , /* optional=*/ true , " The coinbase value (only if coinbase transaction)" },
96
+ {RPCResult::Type::STR_HEX, " txid" , /* optional=*/ true , " The transaction id (if not coinbase transaction)" },
97
+ {RPCResult::Type::NUM, " vout" , /* optional=*/ true , " The output number (if not coinbase transaction)" },
98
+ {RPCResult::Type::OBJ, " scriptSig" , /* optional=*/ true , " The script (if not coinbase transaction)" ,
99
+ {
100
+ {RPCResult::Type::STR, " asm" , " asm" },
101
+ {RPCResult::Type::STR_HEX, " hex" , " hex" },
102
+ }},
103
+ {RPCResult::Type::ARR, " txinwitness" , /* optional=*/ true , " " ,
104
+ {
105
+ {RPCResult::Type::STR_HEX, " hex" , " hex-encoded witness data (if any)" },
106
+ }},
107
+ {RPCResult::Type::NUM, " sequence" , " The script sequence number" },
108
+ }},
109
+ }},
110
+ {RPCResult::Type::ARR, " vout" , " " ,
111
+ {
112
+ {RPCResult::Type::OBJ, " " , " " ,
113
+ {
114
+ {RPCResult::Type::STR_AMOUNT, " value" , " The value in " + CURRENCY_UNIT},
115
+ {RPCResult::Type::NUM, " n" , " index" },
116
+ {RPCResult::Type::OBJ, " scriptPubKey" , " " ,
117
+ {
118
+ {RPCResult::Type::STR, " asm" , " the asm" },
119
+ {RPCResult::Type::STR, " desc" , " Inferred descriptor for the output" },
120
+ {RPCResult::Type::STR_HEX, " hex" , " the hex" },
121
+ {RPCResult::Type::STR, " type" , " The type, eg 'pubkeyhash'" },
122
+ {RPCResult::Type::STR, " address" , /* optional=*/ true , " The Bitcoin address (only if a well-defined address exists)" },
123
+ }},
124
+ }},
125
+ }},
126
+ };
127
+ }
128
+
80
129
static std::vector<RPCArg> CreateTxDoc ()
81
130
{
82
131
return {
@@ -118,7 +167,7 @@ static RPCHelpMan getrawtransaction()
118
167
{
119
168
return RPCHelpMan{
120
169
" getrawtransaction" ,
121
- " \n Return the raw transaction data.\n "
170
+ " Return the raw transaction data.\n "
122
171
123
172
" \n By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n "
124
173
" and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n "
@@ -127,7 +176,7 @@ static RPCHelpMan getrawtransaction()
127
176
" \n Hint: Use gettransaction for wallet transactions.\n "
128
177
129
178
" \n If verbose is 'true', returns an Object with information about 'txid'.\n "
130
- " If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n " ,
179
+ " If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'." ,
131
180
{
132
181
{" txid" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The transaction id" },
133
182
{" verbose" , RPCArg::Type::BOOL, RPCArg::Default{false }, " If false, return a string, otherwise return a json object" },
@@ -138,58 +187,17 @@ static RPCHelpMan getrawtransaction()
138
187
RPCResult::Type::STR, " data" , " The serialized, hex-encoded data for 'txid'"
139
188
},
140
189
RPCResult{" if verbose is set to true" ,
141
- // When updating this documentation, update `decoderawtransaction` in the same way.
142
190
RPCResult::Type::OBJ, " " , " " ,
191
+ Cat<std::vector<RPCResult>>(
143
192
{
144
193
{RPCResult::Type::BOOL, " in_active_chain" , /* optional=*/ true , " Whether specified block is in the active chain or not (only present with explicit \" blockhash\" argument)" },
145
- {RPCResult::Type::STR_HEX, " hex" , " The serialized, hex-encoded data for 'txid'" },
146
- {RPCResult::Type::STR_HEX, " txid" , " The transaction id (same as provided)" },
147
- {RPCResult::Type::STR_HEX, " hash" , " The transaction hash (differs from txid for witness transactions)" },
148
- {RPCResult::Type::NUM, " size" , " The serialized transaction size" },
149
- {RPCResult::Type::NUM, " vsize" , " The virtual transaction size (differs from size for witness transactions)" },
150
- {RPCResult::Type::NUM, " weight" , " The transaction's weight (between vsize*4-3 and vsize*4)" },
151
- {RPCResult::Type::NUM, " version" , " The version" },
152
- {RPCResult::Type::NUM_TIME, " locktime" , " The lock time" },
153
- {RPCResult::Type::ARR, " vin" , " " ,
154
- {
155
- {RPCResult::Type::OBJ, " " , " " ,
156
- {
157
- {RPCResult::Type::STR_HEX, " coinbase" , /* optional=*/ true , " The coinbase value (only if coinbase transaction)" },
158
- {RPCResult::Type::STR_HEX, " txid" , /* optional=*/ true , " The transaction id (if not coinbase transaction)" },
159
- {RPCResult::Type::NUM, " vout" , /* optional=*/ true , " The output number (if not coinbase transaction)" },
160
- {RPCResult::Type::OBJ, " scriptSig" , /* optional=*/ true , " The script (if not coinbase transaction)" ,
161
- {
162
- {RPCResult::Type::STR, " asm" , " asm" },
163
- {RPCResult::Type::STR_HEX, " hex" , " hex" },
164
- }},
165
- {RPCResult::Type::ARR, " txinwitness" , /* optional=*/ true , " " ,
166
- {
167
- {RPCResult::Type::STR_HEX, " hex" , " hex-encoded witness data (if any)" },
168
- }},
169
- {RPCResult::Type::NUM, " sequence" , " The script sequence number" },
170
- }},
171
- }},
172
- {RPCResult::Type::ARR, " vout" , " " ,
173
- {
174
- {RPCResult::Type::OBJ, " " , " " ,
175
- {
176
- {RPCResult::Type::STR_AMOUNT, " value" , " The value in " + CURRENCY_UNIT},
177
- {RPCResult::Type::NUM, " n" , " index" },
178
- {RPCResult::Type::OBJ, " scriptPubKey" , " " ,
179
- {
180
- {RPCResult::Type::STR, " asm" , " the asm" },
181
- {RPCResult::Type::STR, " desc" , " Inferred descriptor for the output" },
182
- {RPCResult::Type::STR_HEX, " hex" , " the hex" },
183
- {RPCResult::Type::STR, " type" , " The type, eg 'pubkeyhash'" },
184
- {RPCResult::Type::STR, " address" , /* optional=*/ true , " The Bitcoin address (only if a well-defined address exists)" },
185
- }},
186
- }},
187
- }},
188
194
{RPCResult::Type::STR_HEX, " blockhash" , /* optional=*/ true , " the block hash" },
189
195
{RPCResult::Type::NUM, " confirmations" , /* optional=*/ true , " The confirmations" },
190
196
{RPCResult::Type::NUM_TIME, " blocktime" , /* optional=*/ true , " The block time expressed in " + UNIX_EPOCH_TIME},
191
197
{RPCResult::Type::NUM, " time" , /* optional=*/ true , " Same as \" blocktime\" " },
192
- }
198
+ {RPCResult::Type::STR_HEX, " hex" , " The serialized, hex-encoded data for 'txid'" },
199
+ },
200
+ DecodeTxDoc (/* txid_field_doc=*/ " The transaction id (same as provided)" )),
193
201
},
194
202
},
195
203
RPCExamples{
@@ -309,7 +317,7 @@ static RPCHelpMan createrawtransaction()
309
317
static RPCHelpMan decoderawtransaction ()
310
318
{
311
319
return RPCHelpMan{" decoderawtransaction" ,
312
- " \n Return a JSON object representing the serialized, hex-encoded transaction.\n " ,
320
+ " Return a JSON object representing the serialized, hex-encoded transaction." ,
313
321
{
314
322
{" hexstring" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The transaction hex string" },
315
323
{" iswitness" , RPCArg::Type::BOOL, RPCArg::DefaultHint{" depends on heuristic tests" }, " Whether the transaction hex is a serialized witness transaction.\n "
@@ -322,51 +330,7 @@ static RPCHelpMan decoderawtransaction()
322
330
},
323
331
RPCResult{
324
332
RPCResult::Type::OBJ, " " , " " ,
325
- {
326
- // When updating this documentation, update `getrawtransaction` in the same way.
327
- {RPCResult::Type::STR_HEX, " txid" , " The transaction id" },
328
- {RPCResult::Type::STR_HEX, " hash" , " The transaction hash (differs from txid for witness transactions)" },
329
- {RPCResult::Type::NUM, " size" , " The serialized transaction size" },
330
- {RPCResult::Type::NUM, " vsize" , " The virtual transaction size (differs from size for witness transactions)" },
331
- {RPCResult::Type::NUM, " weight" , " The transaction's weight (between vsize*4-3 and vsize*4)" },
332
- {RPCResult::Type::NUM, " version" , " The version" },
333
- {RPCResult::Type::NUM_TIME, " locktime" , " The lock time" },
334
- {RPCResult::Type::ARR, " vin" , " " ,
335
- {
336
- {RPCResult::Type::OBJ, " " , " " ,
337
- {
338
- {RPCResult::Type::STR_HEX, " coinbase" , /* optional=*/ true , " The coinbase value (only if coinbase transaction)" },
339
- {RPCResult::Type::STR_HEX, " txid" , /* optional=*/ true , " The transaction id (if not coinbase transaction)" },
340
- {RPCResult::Type::NUM, " vout" , /* optional=*/ true , " The output number (if not coinbase transaction)" },
341
- {RPCResult::Type::OBJ, " scriptSig" , /* optional=*/ true , " The script (if not coinbase transaction)" ,
342
- {
343
- {RPCResult::Type::STR, " asm" , " asm" },
344
- {RPCResult::Type::STR_HEX, " hex" , " hex" },
345
- }},
346
- {RPCResult::Type::ARR, " txinwitness" , /* optional=*/ true , " " ,
347
- {
348
- {RPCResult::Type::STR_HEX, " hex" , " hex-encoded witness data (if any)" },
349
- }},
350
- {RPCResult::Type::NUM, " sequence" , " The script sequence number" },
351
- }},
352
- }},
353
- {RPCResult::Type::ARR, " vout" , " " ,
354
- {
355
- {RPCResult::Type::OBJ, " " , " " ,
356
- {
357
- {RPCResult::Type::STR_AMOUNT, " value" , " The value in " + CURRENCY_UNIT},
358
- {RPCResult::Type::NUM, " n" , " index" },
359
- {RPCResult::Type::OBJ, " scriptPubKey" , " " ,
360
- {
361
- {RPCResult::Type::STR, " asm" , " the asm" },
362
- {RPCResult::Type::STR, " desc" , " Inferred descriptor for the output" },
363
- {RPCResult::Type::STR_HEX, " hex" , " the hex" },
364
- {RPCResult::Type::STR, " type" , " The type, eg 'pubkeyhash'" },
365
- {RPCResult::Type::STR, " address" , /* optional=*/ true , " The Bitcoin address (only if a well-defined address exists)" },
366
- }},
367
- }},
368
- }},
369
- }
333
+ DecodeTxDoc (/* txid_field_doc=*/ " The transaction id" ),
370
334
},
371
335
RPCExamples{
372
336
HelpExampleCli (" decoderawtransaction" , " \" hexstring\" " )
0 commit comments