mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-05-17 23:56:39 +00:00
Merge bitcoin/bitcoin#23320: rpc: Add RPC help for getblock verbosity level 3
059f88b6a97b7a3ae1f033885e40ac01f91e6d60 Add RPC help for getblock verbosity level 3 (Kiminuo)
1bdd5f63229ebf28c24a8656f486ed8a6c8b3787 Address review comments from #22918 (Kiminuo)
Pull request description:
This is a follow-up PR to #22918 which addresses review comments (first commit). The second commit adds missing RPC help for verbosity level 3.
ACKs for top commit:
pg156:
ACK 059f88b6a9
laanwj:
re-ACK 059f88b6a97b7a3ae1f033885e40ac01f91e6d60
Tree-SHA512: f27d53ac34b93a304ef5668701ed2b5c986a926bc8ad0df4de89695fc9e1df26acb008611451319ea897658acd9c56c6a0555d60359960c9cd28238ebefa2d50
This commit is contained in:
commit
66be456d93
@ -97,7 +97,7 @@ Updated RPCs
|
|||||||
`gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`,
|
`gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`,
|
||||||
`/rest/block` no longer return the `addresses` and `reqSigs` fields, which
|
`/rest/block` no longer return the `addresses` and `reqSigs` fields, which
|
||||||
were previously deprecated in 22.0. (#22650)
|
were previously deprecated in 22.0. (#22650)
|
||||||
- The `getblock` RPC command now supports verbose level 3 containing transaction inputs
|
- The `getblock` RPC command now supports verbosity level 3 containing transaction inputs'
|
||||||
`prevout` information. The existing `/rest/block/` REST endpoint is modified to contain
|
`prevout` information. The existing `/rest/block/` REST endpoint is modified to contain
|
||||||
this information too. Every `vin` field will contain an additional `prevout` subfield
|
this information too. Every `vin` field will contain an additional `prevout` subfield
|
||||||
describing the spent output. `prevout` contains the following keys:
|
describing the spent output. `prevout` contains the following keys:
|
||||||
|
@ -208,14 +208,10 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
|
|||||||
const CTxOut& prev_txout = prev_coin.out;
|
const CTxOut& prev_txout = prev_coin.out;
|
||||||
|
|
||||||
amt_total_in += prev_txout.nValue;
|
amt_total_in += prev_txout.nValue;
|
||||||
switch (verbosity) {
|
|
||||||
case TxVerbosity::SHOW_TXID:
|
|
||||||
case TxVerbosity::SHOW_DETAILS:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TxVerbosity::SHOW_DETAILS_AND_PREVOUT:
|
if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) {
|
||||||
UniValue o_script_pub_key(UniValue::VOBJ);
|
UniValue o_script_pub_key(UniValue::VOBJ);
|
||||||
ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /* includeHex */ true);
|
ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*include_hex=*/ true);
|
||||||
|
|
||||||
UniValue p(UniValue::VOBJ);
|
UniValue p(UniValue::VOBJ);
|
||||||
p.pushKV("generated", bool(prev_coin.fCoinBase));
|
p.pushKV("generated", bool(prev_coin.fCoinBase));
|
||||||
@ -223,7 +219,6 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
|
|||||||
p.pushKV("value", ValueFromAmount(prev_txout.nValue));
|
p.pushKV("value", ValueFromAmount(prev_txout.nValue));
|
||||||
p.pushKV("scriptPubKey", o_script_pub_key);
|
p.pushKV("scriptPubKey", o_script_pub_key);
|
||||||
in.pushKV("prevout", p);
|
in.pushKV("prevout", p);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.pushKV("sequence", (int64_t)txin.nSequence);
|
in.pushKV("sequence", (int64_t)txin.nSequence);
|
||||||
|
@ -185,6 +185,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
|
|||||||
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
|
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity);
|
||||||
txs.push_back(objTx);
|
txs.push_back(objTx);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.pushKV("tx", txs);
|
result.pushKV("tx", txs);
|
||||||
@ -967,7 +968,7 @@ static RPCHelpMan getblock()
|
|||||||
"If verbosity is 3, returns an Object with information about block <hash> and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain).\n",
|
"If verbosity is 3, returns an Object with information about block <hash> and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain).\n",
|
||||||
{
|
{
|
||||||
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
|
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
|
||||||
{"verbosity|verbose", RPCArg::Type::NUM, RPCArg::Default{1}, "0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"},
|
{"verbosity|verbose", RPCArg::Type::NUM, RPCArg::Default{1}, "0 for hex-encoded data, 1 for a JSON object, 2 for JSON object with transaction data, and 3 for JSON object with transaction data including prevout information for inputs"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RPCResult{"for verbosity = 0",
|
RPCResult{"for verbosity = 0",
|
||||||
@ -1009,6 +1010,37 @@ static RPCHelpMan getblock()
|
|||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
|
RPCResult{"for verbosity = 3",
|
||||||
|
RPCResult::Type::OBJ, "", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::ELISION, "", "Same output as verbosity = 2"},
|
||||||
|
{RPCResult::Type::ARR, "tx", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::OBJ, "", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::ARR, "vin", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::OBJ, "", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::ELISION, "", "The same output as verbosity = 2"},
|
||||||
|
{RPCResult::Type::OBJ, "prevout", "(Only if undo information is available)",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::BOOL, "generated", "Coinbase or not"},
|
||||||
|
{RPCResult::Type::NUM, "height", "The height of the prevout"},
|
||||||
|
{RPCResult::Type::NUM, "value", "The value in " + CURRENCY_UNIT},
|
||||||
|
{RPCResult::Type::OBJ, "scriptPubKey", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::STR, "asm", "The asm"},
|
||||||
|
{RPCResult::Type::STR, "hex", "The hex"},
|
||||||
|
{RPCResult::Type::STR, "address", /* optional */ true, "The Bitcoin address (only if a well-defined address exists)"},
|
||||||
|
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
RPCExamples{
|
RPCExamples{
|
||||||
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
|
HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user