aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/rawtransaction.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-03-31 11:19:26 +0200
committerMarcoFalke <falke.marco@gmail.com>2022-03-31 11:19:31 +0200
commit1a54c060b3b30220ec40a4b3cc4a0eb43586e982 (patch)
treeabaf76f2e3044a08107ef18cc1a5fd0a8bc042d2 /src/rpc/rawtransaction.cpp
parentc8ac7e6a651333494269c19a55fce2307534825e (diff)
parent71038a151e3136c22449e1a5cb1f386e8474c32d (diff)
downloadbitcoin-1a54c060b3b30220ec40a4b3cc4a0eb43586e982.tar.xz
Merge bitcoin/bitcoin#24716: rpc: Fix documentation assertion for `getrawtransaction`
71038a151e3136c22449e1a5cb1f386e8474c32d 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 #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 71038a151e3136c22449e1a5cb1f386e8474c32d Tree-SHA512: 962236130455d805190ff9a5c971e4e25c17db35614a90ce340264ec953b0ad7fb814eb33ae430b5073955a8a350f72bdd67ba93e35f9c70e5175b836a767a35
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
-rw-r--r--src/rpc/rawtransaction.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 921925525c..52ef22100d 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -138,6 +138,7 @@ static RPCHelpMan getrawtransaction()
RPCResult::Type::STR, "data", "The serialized, hex-encoded data for 'txid'"
},
RPCResult{"if verbose is set to true",
+ // When updating this documentation, update `decoderawtransaction` in the same way.
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::BOOL, "in_active_chain", /*optional=*/true, "Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
@@ -153,31 +154,32 @@ static RPCHelpMan getrawtransaction()
{
{RPCResult::Type::OBJ, "", "",
{
- {RPCResult::Type::STR_HEX, "txid", "The transaction id"},
- {RPCResult::Type::NUM, "vout", "The output number"},
- {RPCResult::Type::OBJ, "scriptSig", "The script",
+ {RPCResult::Type::STR_HEX, "coinbase", /*optional=*/true, "The coinbase value (only if coinbase transaction)"},
+ {RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id (if not coinbase transaction)"},
+ {RPCResult::Type::NUM, "vout", /*optional=*/true, "The output number (if not coinbase transaction)"},
+ {RPCResult::Type::OBJ, "scriptSig", /*optional=*/true, "The script (if not coinbase transaction)",
{
{RPCResult::Type::STR, "asm", "asm"},
{RPCResult::Type::STR_HEX, "hex", "hex"},
}},
- {RPCResult::Type::NUM, "sequence", "The script sequence number"},
{RPCResult::Type::ARR, "txinwitness", /*optional=*/true, "",
{
{RPCResult::Type::STR_HEX, "hex", "hex-encoded witness data (if any)"},
}},
+ {RPCResult::Type::NUM, "sequence", "The script sequence number"},
}},
}},
{RPCResult::Type::ARR, "vout", "",
{
{RPCResult::Type::OBJ, "", "",
{
- {RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
+ {RPCResult::Type::STR_AMOUNT, "value", "The value in " + CURRENCY_UNIT},
{RPCResult::Type::NUM, "n", "index"},
{RPCResult::Type::OBJ, "scriptPubKey", "",
{
{RPCResult::Type::STR, "asm", "the asm"},
{RPCResult::Type::STR, "desc", "Inferred descriptor for the output"},
- {RPCResult::Type::STR, "hex", "the hex"},
+ {RPCResult::Type::STR_HEX, "hex", "the hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
}},
@@ -321,21 +323,22 @@ static RPCHelpMan decoderawtransaction()
RPCResult{
RPCResult::Type::OBJ, "", "",
{
+ // When updating this documentation, update `getrawtransaction` in the same way.
{RPCResult::Type::STR_HEX, "txid", "The transaction id"},
{RPCResult::Type::STR_HEX, "hash", "The transaction hash (differs from txid for witness transactions)"},
- {RPCResult::Type::NUM, "size", "The transaction size"},
+ {RPCResult::Type::NUM, "size", "The serialized transaction size"},
{RPCResult::Type::NUM, "vsize", "The virtual transaction size (differs from size for witness transactions)"},
- {RPCResult::Type::NUM, "weight", "The transaction's weight (between vsize*4 - 3 and vsize*4)"},
+ {RPCResult::Type::NUM, "weight", "The transaction's weight (between vsize*4-3 and vsize*4)"},
{RPCResult::Type::NUM, "version", "The version"},
{RPCResult::Type::NUM_TIME, "locktime", "The lock time"},
{RPCResult::Type::ARR, "vin", "",
{
{RPCResult::Type::OBJ, "", "",
{
- {RPCResult::Type::STR_HEX, "coinbase", /*optional=*/true, ""},
- {RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id"},
- {RPCResult::Type::NUM, "vout", /*optional=*/true, "The output number"},
- {RPCResult::Type::OBJ, "scriptSig", /*optional=*/true, "The script",
+ {RPCResult::Type::STR_HEX, "coinbase", /*optional=*/true, "The coinbase value (only if coinbase transaction)"},
+ {RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id (if not coinbase transaction)"},
+ {RPCResult::Type::NUM, "vout", /*optional=*/true, "The output number (if not coinbase transaction)"},
+ {RPCResult::Type::OBJ, "scriptSig", /*optional=*/true, "The script (if not coinbase transaction)",
{
{RPCResult::Type::STR, "asm", "asm"},
{RPCResult::Type::STR_HEX, "hex", "hex"},
@@ -351,7 +354,7 @@ static RPCHelpMan decoderawtransaction()
{
{RPCResult::Type::OBJ, "", "",
{
- {RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
+ {RPCResult::Type::STR_AMOUNT, "value", "The value in " + CURRENCY_UNIT},
{RPCResult::Type::NUM, "n", "index"},
{RPCResult::Type::OBJ, "scriptPubKey", "",
{