Diff-minimise

This commit is contained in:
Luke Dashjr 2022-04-14 00:40:49 +00:00
parent 858f9cb93a
commit c16bbb6909
2 changed files with 18 additions and 19 deletions

View File

@ -642,17 +642,16 @@ const RPCResult getblock_vin{
} }
}; };
static RPCHelpMan getblock() static RPCHelpMan getblock()
{ {
return RPCHelpMan{"getblock", return RPCHelpMan{"getblock",
"\nIf verbosity is 0, returns a string that is serialized, hex-encoded data about block <hash>.\n" "\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
"If verbosity is 1, returns a JSON object with information about block <hash>.\n" "If verbosity is 1, returns an Object with information about block <hash>.\n"
"If verbosity is 2, returns a JSON object with information about block <hash> and information about each transaction.\n" "If verbosity is 2, returns an Object with information about block <hash> and information about each transaction.\n"
"If verbosity is 3, returns a JSON 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, 2 for a JSON object with transaction data, and 3 for a JSON object with transaction data including prevout information for inputs", {"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",
RPCArgOptions{.skip_type_check = true}}, RPCArgOptions{.skip_type_check = true}},
}, },
{ {
@ -663,10 +662,15 @@ static RPCHelpMan getblock()
{ {
{RPCResult::Type::STR_HEX, "hash", "the block hash (same as provided)"}, {RPCResult::Type::STR_HEX, "hash", "the block hash (same as provided)"},
{RPCResult::Type::NUM, "confirmations", "The number of confirmations, or -1 if the block is not on the main chain"}, {RPCResult::Type::NUM, "confirmations", "The number of confirmations, or -1 if the block is not on the main chain"},
{RPCResult::Type::NUM, "size", "The block size"},
{RPCResult::Type::NUM, "strippedsize", "The block size excluding witness data"},
{RPCResult::Type::NUM, "weight", "The block weight as defined in BIP 141"},
{RPCResult::Type::NUM, "height", "The block height or index"}, {RPCResult::Type::NUM, "height", "The block height or index"},
{RPCResult::Type::NUM, "version", "The block version"}, {RPCResult::Type::NUM, "version", "The block version"},
{RPCResult::Type::STR_HEX, "versionHex", "The block version formatted in hexadecimal"}, {RPCResult::Type::STR_HEX, "versionHex", "The block version formatted in hexadecimal"},
{RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"}, {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"},
{RPCResult::Type::ARR, "tx", "The transaction ids",
{{RPCResult::Type::STR_HEX, "", "The transaction id"}}},
{RPCResult::Type::NUM_TIME, "time", "The block time expressed in " + UNIX_EPOCH_TIME}, {RPCResult::Type::NUM_TIME, "time", "The block time expressed in " + UNIX_EPOCH_TIME},
{RPCResult::Type::NUM_TIME, "mediantime", "The median block time expressed in " + UNIX_EPOCH_TIME}, {RPCResult::Type::NUM_TIME, "mediantime", "The median block time expressed in " + UNIX_EPOCH_TIME},
{RPCResult::Type::NUM, "nonce", "The nonce"}, {RPCResult::Type::NUM, "nonce", "The nonce"},
@ -676,11 +680,6 @@ static RPCHelpMan getblock()
{RPCResult::Type::NUM, "nTx", "The number of transactions in the block"}, {RPCResult::Type::NUM, "nTx", "The number of transactions in the block"},
{RPCResult::Type::STR_HEX, "previousblockhash", /*optional=*/true, "The hash of the previous block (if available)"}, {RPCResult::Type::STR_HEX, "previousblockhash", /*optional=*/true, "The hash of the previous block (if available)"},
{RPCResult::Type::STR_HEX, "nextblockhash", /*optional=*/true, "The hash of the next block (if available)"}, {RPCResult::Type::STR_HEX, "nextblockhash", /*optional=*/true, "The hash of the next block (if available)"},
{RPCResult::Type::NUM, "strippedsize", "The block size, excluding witness data"},
{RPCResult::Type::NUM, "size", "The block size"},
{RPCResult::Type::NUM, "weight", "The block weight as defined in BIP 141"},
{RPCResult::Type::ARR, "tx", "The transaction ids",
{{RPCResult::Type::STR_HEX, "", "The transaction id"}}},
}}, }},
RPCResult{"for verbosity = 2", RPCResult{"for verbosity = 2",
RPCResult::Type::OBJ, "", "", RPCResult::Type::OBJ, "", "",

View File

@ -54,8 +54,8 @@ using node::PSBTAnalysis;
using node::ReadBlockFromDisk; using node::ReadBlockFromDisk;
using node::UndoReadFromDisk; using node::UndoReadFromDisk;
static void TxToJSON(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry,
const Chainstate& active_chainstate, const CTxUndo* txundo = nullptr, Chainstate& active_chainstate, const CTxUndo* txundo = nullptr,
TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS) TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS)
{ {
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS); CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
@ -67,7 +67,7 @@ static void TxToJSON(const CTransaction& tx, const uint256& hashBlock, UniValue&
TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, RPCSerializationFlags(), txundo, verbosity); TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, RPCSerializationFlags(), txundo, verbosity);
if (!hashBlock.IsNull()) { if (!hashBlock.IsNull()) {
LOCK(::cs_main); LOCK(cs_main);
entry.pushKV("blockhash", hashBlock.GetHex()); entry.pushKV("blockhash", hashBlock.GetHex());
const CBlockIndex* pindex = active_chainstate.m_blockman.LookupBlockIndex(hashBlock); const CBlockIndex* pindex = active_chainstate.m_blockman.LookupBlockIndex(hashBlock);
@ -76,9 +76,9 @@ static void TxToJSON(const CTransaction& tx, const uint256& hashBlock, UniValue&
entry.pushKV("confirmations", 1 + active_chainstate.m_chain.Height() - pindex->nHeight); entry.pushKV("confirmations", 1 + active_chainstate.m_chain.Height() - pindex->nHeight);
entry.pushKV("time", pindex->GetBlockTime()); entry.pushKV("time", pindex->GetBlockTime());
entry.pushKV("blocktime", pindex->GetBlockTime()); entry.pushKV("blocktime", pindex->GetBlockTime());
} else {
entry.pushKV("confirmations", 0);
} }
else
entry.pushKV("confirmations", 0);
} }
} }
} }
@ -202,7 +202,7 @@ static RPCHelpMan getrawtransaction()
{ {
{RPCResult::Type::BOOL, "in_active_chain", /*optional=*/true, "Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"}, {RPCResult::Type::BOOL, "in_active_chain", /*optional=*/true, "Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
{RPCResult::Type::STR_HEX, "blockhash", /*optional=*/true, "the block hash"}, {RPCResult::Type::STR_HEX, "blockhash", /*optional=*/true, "the block hash"},
{RPCResult::Type::NUM, "confirmations", /*optional=*/true, "The number of confirmations"}, {RPCResult::Type::NUM, "confirmations", /*optional=*/true, "The confirmations"},
{RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME}, {RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME},
{RPCResult::Type::NUM, "time", /*optional=*/true, "Same as \"blocktime\""}, {RPCResult::Type::NUM, "time", /*optional=*/true, "Same as \"blocktime\""},
{RPCResult::Type::STR_HEX, "hex", "The serialized, hex-encoded data for 'txid'"}, {RPCResult::Type::STR_HEX, "hex", "The serialized, hex-encoded data for 'txid'"},
@ -431,10 +431,10 @@ static RPCHelpMan decodescript()
"Result of a witness script public key wrapping this redeem script (not returned for types that should not be wrapped)", "Result of a witness script public key wrapping this redeem script (not returned for types that should not be wrapped)",
{ {
{RPCResult::Type::STR, "asm", "String representation of the script public key"}, {RPCResult::Type::STR, "asm", "String representation of the script public key"},
{RPCResult::Type::STR, "desc", "Inferred descriptor for the script"},
{RPCResult::Type::STR_HEX, "hex", "Hex string of the script public key"}, {RPCResult::Type::STR_HEX, "hex", "Hex string of the script public key"},
{RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"}, {RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"},
{RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"}, {RPCResult::Type::STR, "desc", "Inferred descriptor for the script"},
{RPCResult::Type::STR, "type", "The type of the script public key (one of: " + GetAllOutputTypes() + ")"},
{RPCResult::Type::STR, "p2sh-segwit", "address of the P2SH script wrapping this witness redeem script"}, {RPCResult::Type::STR, "p2sh-segwit", "address of the P2SH script wrapping this witness redeem script"},
}}, }},
}, },