Skip to content

Commit 1ff254e

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#26974: refactor: rpc: set TxToJSON default verbosity to SHOW_DETAILS
a24e633 refactor: rpc: set TxToJSON default verbosity to SHOW_DETAILS (stickies-v) Pull request description: `TxToJSON()` and `TxToUniv()` are only to be called when we want to decode the transaction (i.e. its details) into JSON. If `TxVerbosity` is `SHOW_TXID`, the function should not have been (and currently is not) called in the first place. There is no behaviour change, current logic simply assumes anything less than `TxVerbosity::SHOW_DETAILS_AND_PREVOUT` equals `TxVerbosity::SHOW_DETAILS`. With this change, the assumptions and intent become more explicit. ACKs for top commit: w0xlt: ACK bitcoin/bitcoin@a24e633 Tree-SHA512: b97235adae49b972bdbe10aca1438643fb35ec66a4e57166b1975b3015bc5a06a711feebe4453a8fefe71781e484b21ef80847d8e8a33694a3abcc863accd4d7
2 parents 2b211b4 + a24e633 commit 1ff254e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core_write.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex, bool i
170170

171171
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo, TxVerbosity verbosity)
172172
{
173+
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
174+
173175
entry.pushKV("txid", tx.GetHash().GetHex());
174176
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
175177
// Transaction version is actually unsigned in consensus checks, just signed in memory,

src/rpc/rawtransaction.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ using node::PSBTAnalysis;
5454
using node::ReadBlockFromDisk;
5555
using node::UndoReadFromDisk;
5656

57-
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, Chainstate& active_chainstate, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_TXID)
57+
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry,
58+
Chainstate& active_chainstate, const CTxUndo* txundo = nullptr,
59+
TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS)
5860
{
61+
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
5962
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
6063
//
6164
// Blockchain contextual information (confirmations and blocktime) is not

0 commit comments

Comments
 (0)