From e36eacd86837135b30c308e3dd85facf740bdf58 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 24 Dec 2020 15:32:02 +0100 Subject: [PATCH] Merge #18772: rpc: calculate fees in getblock using BlockUndo data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e test: RPC: getblock fee calculations (Elliott Jin) bf7d6e31b1062ab5f90e14e83c56309f499fa2e9 RPC: getblock: tx fee calculation for verbosity 2 via Undo data (Elliott Jin) Pull request description: This change is progress towards #18771 . It adapts the fee calculation part of #16083 and addresses some feedback. The additional "verbosity level 3" features are planned for a future PR. **Original PR description:** > Using block undo data (like in #14802) we can now show fee information for each transaction in a block without the need for additional -txindex and/or a ton of costly lookups. For a start we'll add transaction fee information to getblock verbosity level 2. This comes at a negligible speed penalty (<1%). ACKs for top commit: luke-jr: tACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e fjahr: tACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e MarcoFalke: review ACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e 🗜 Tree-SHA512: be1fe4b866946a8dc36427f7dc72a20e10860e320a28fa49bc85bd2a93a0d699768179be29fa52e18b2ed8505d3ec272e586753ef2239b4230e0aefd233acaa2 --- src/core_io.h | 3 ++- src/core_write.cpp | 32 +++++++++++++++++++--- src/rpc/blockchain.cpp | 18 ++++++++----- test/functional/rpc_blockchain.py | 44 +++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/core_io.h b/src/core_io.h index 696f69e933..e1824e89cd 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -18,6 +18,7 @@ class CTransaction; struct CMutableTransaction; class uint256; class UniValue; +class CTxUndo; struct CSpentIndexTxInfo; @@ -46,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); +void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, const CSpentIndexTxInfo* ptxSpentInfo = nullptr, const CTxUndo* txundo = nullptr); #endif // BITCOIN_CORE_IO_H diff --git a/src/core_write.cpp b/src/core_write.cpp index 14e33c5645..176db4f6d9 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -11,7 +11,9 @@ #include