From ec0803a0f5269487cab3d17b7eeb41ea98f400a2 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:47:57 +0000 Subject: [PATCH] refactor: align `TxToUniv` argument list with upstream In bitcoin#20286, a new `TxToUniv` will be defined and in order to minimize upstream deviation caused by having to change function calls to account for `const CSpentIndexTxInfo*` being placed _before_ `const CTxUndo*` (requiring us to therefore specify `nullptr` as those calls do not expect spend information) instead of letting the default value remain. To allow for that, their ordering will be swapped. To prevent a confusion with the last two arguments between the `core_io` definition and the `rpc/blockchain` definition, let's do the inversion here too before the backport. --- src/core_io.h | 2 +- src/core_write.cpp | 2 +- src/rpc/blockchain.cpp | 2 +- src/rpc/rawtransaction.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core_io.h b/src/core_io.h index 1d19461e53..170f927428 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -47,6 +47,6 @@ std::string EncodeHexTx(const CTransaction& tx); std::string SighashToStr(unsigned char sighash_type); void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); void ScriptToUniv(const CScript& script, UniValue& out, bool include_address); -void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, const CSpentIndexTxInfo* ptxSpentInfo = nullptr, const CTxUndo* txundo = nullptr); +void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, const CTxUndo* txundo = nullptr, const CSpentIndexTxInfo* ptxSpentInfo = nullptr); #endif // BITCOIN_CORE_IO_H diff --git a/src/core_write.cpp b/src/core_write.cpp index c27b0c0f58..e921643f72 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -192,7 +192,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, out.pushKV("addresses", a); } -void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, const CSpentIndexTxInfo* ptxSpentInfo, const CTxUndo* txundo) +void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, const CTxUndo* txundo, const CSpentIndexTxInfo* ptxSpentInfo) { uint256 txid = tx.GetHash(); entry.pushKV("txid", txid.GetHex()); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 49b39817f1..6749f8ac4b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -226,7 +226,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn // coinbase transaction (i == 0) doesn't have undo data const CTxUndo* txundo = (have_undo && i) ? &blockUndo.vtxundo.at(i - 1) : nullptr; UniValue objTx(UniValue::VOBJ); - TxToUniv(*tx, uint256(), objTx, true, nullptr, txundo); + TxToUniv(*tx, uint256(), objTx, true, txundo); bool fLocked = isman.IsLocked(tx->GetHash()); objTx.pushKV("instantlock", fLocked || result["chainlock"].get_bool()); objTx.pushKV("instantlock_internal", fLocked); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 3222098339..c70fca08e9 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -84,7 +84,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, CTxMemPool& mempo } } - TxToUniv(tx, uint256(), entry, true, &txSpentInfo); + TxToUniv(tx, uint256(), entry, true, /* txundo = */ nullptr, &txSpentInfo); bool chainLock = false; if (!hashBlock.IsNull()) {