Skip to content

Commit 6bcbc72

Browse files
MarcoFalkeknst
authored andcommitted
Merge bitcoin#24716: rpc: Fix documentation assertion for getrawtransaction
71038a1 rpc: Fix documentation assertion for `getrawtransaction` (laanwj) Pull request description: When `getrawtransaction` is successfully used on a coinbase transaction, there is an assertion error. This is very unlikely but happens in the `interface_usdt_utxocache.py` test in bitcoin#24358. This does the following: - Add missing "coinbase" documentation. - Synchronize documentation between `getrawtransaction` and `decoderawtransaction`, the two users of `TxToUniv` that have detailed documentation. `decodepsbt` and `getblock` also uses it but fortunately elides this block. - Change "vout[].amount" to `STR_AMOUNT` for consistency. - Add maintainer comment to keep the two places synchronized. It might be possible to get smarter with deduplication, but there are some extra fields that prevent the obvious way. ACKs for top commit: jonatack: ACK 71038a1 Tree-SHA512: 962236130455d805190ff9a5c971e4e25c17db35614a90ce340264ec953b0ad7fb814eb33ae430b5073955a8a350f72bdd67ba93e35f9c70e5175b836a767a35
1 parent c4a9d82 commit 6bcbc72

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static RPCHelpMan getrawtransaction()
187187
RPCResult::Type::STR, "data", "The serialized, hex-encoded data for 'txid'"
188188
},
189189
RPCResult{"if verbose is set to true",
190+
// When updating this documentation, update `decoderawtransaction` in the same way.
190191
RPCResult::Type::OBJ, "", "",
191192
{
192193
{RPCResult::Type::BOOL, "in_active_chain", /* optional */ true, "Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
@@ -199,9 +200,11 @@ static RPCHelpMan getrawtransaction()
199200
{
200201
{RPCResult::Type::OBJ, "", "",
201202
{
202-
{RPCResult::Type::STR_HEX, "txid", "The transaction id"},
203-
{RPCResult::Type::NUM, "vout", "The output number"},
204-
{RPCResult::Type::OBJ, "scriptSig", "The script",
203+
{RPCResult::Type::STR_HEX, "coinbase", /*optional=*/true, "The coinbase value (only if coinbase transaction)"},
204+
{RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id (if not coinbase transaction)"},
205+
{RPCResult::Type::NUM, "vout", /*optional=*/true, "The output number (if not coinbase transaction)"},
206+
{RPCResult::Type::OBJ, "scriptSig", /*optional=*/true, "The script (if not coinbase transaction)",
207+
{
205208
{
206209
{RPCResult::Type::STR, "asm", "asm"},
207210
{RPCResult::Type::STR_HEX, "hex", "hex"},
@@ -213,13 +216,13 @@ static RPCHelpMan getrawtransaction()
213216
{
214217
{RPCResult::Type::OBJ, "", "",
215218
{
216-
{RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
219+
{RPCResult::Type::STR_AMOUNT, "value", "The value in " + CURRENCY_UNIT},
217220
{RPCResult::Type::NUM, "n", "index"},
218221
{RPCResult::Type::OBJ, "scriptPubKey", "",
219222
{
220223
{RPCResult::Type::STR, "asm", "the asm"},
221224
{RPCResult::Type::STR, "desc", "Inferred descriptor for the output"},
222-
{RPCResult::Type::STR, "hex", "the hex"},
225+
{RPCResult::Type::STR_HEX, "hex", "the hex"},
223226
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
224227
{RPCResult::Type::STR, "address", /* optional */ true, "The Dash address (only if a well-defined address exists)"},
225228
}},
@@ -742,19 +745,20 @@ static RPCHelpMan decoderawtransaction()
742745
RPCResult{
743746
RPCResult::Type::OBJ, "", "",
744747
{
748+
// When updating this documentation, update `getrawtransaction` in the same way.
745749
{RPCResult::Type::STR_HEX, "txid", "The transaction id"},
746-
{RPCResult::Type::NUM, "size", "The transaction size"},
750+
{RPCResult::Type::NUM, "size", "The serialized transaction size"},
747751
{RPCResult::Type::NUM, "version", "The version"},
748752
{RPCResult::Type::NUM, "type", "The type"},
749753
{RPCResult::Type::NUM_TIME, "locktime", "The lock time"},
750754
{RPCResult::Type::ARR, "vin", "",
751755
{
752756
{RPCResult::Type::OBJ, "", "",
753757
{
754-
{RPCResult::Type::STR_HEX, "coinbase", /* optional */ true, ""},
755-
{RPCResult::Type::STR_HEX, "txid", /* optional */ true, "The transaction id"},
756-
{RPCResult::Type::NUM, "vout", /* optional */ true, "The output number"},
757-
{RPCResult::Type::OBJ, "scriptSig", /* optional */ true, "The script",
758+
{RPCResult::Type::STR_HEX, "coinbase", /*optional=*/true, "The coinbase value (only if coinbase transaction)"},
759+
{RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id (if not coinbase transaction)"},
760+
{RPCResult::Type::NUM, "vout", /*optional=*/true, "The output number (if not coinbase transaction)"},
761+
{RPCResult::Type::OBJ, "scriptSig", /*optional=*/true, "The script (if not coinbase transaction)",
758762
{
759763
{RPCResult::Type::STR, "asm", "asm"},
760764
{RPCResult::Type::STR_HEX, "hex", "hex"},
@@ -766,7 +770,7 @@ static RPCHelpMan decoderawtransaction()
766770
{
767771
{RPCResult::Type::OBJ, "", "",
768772
{
769-
{RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
773+
{RPCResult::Type::STR_AMOUNT, "value", "The value in " + CURRENCY_UNIT},
770774
{RPCResult::Type::NUM, "n", "index"},
771775
{RPCResult::Type::OBJ, "scriptPubKey", "",
772776
{

0 commit comments

Comments
 (0)