From 8ea675368dd99934d010eef7741728a5a2b28dc9 Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:50:41 -0500 Subject: [PATCH 1/7] Merge bitcoin/bitcoin#27069: net: add `Ensure{any}Banman` * Merge bitcoin/bitcoin#27069: net: add `Ensure{any}Banman` 2d955ff006b8949017fe617c35cfc1cfe117db6e net: add `Ensure{any}Banman` (brunoerg) Pull request description: This PR adds `Ensure{any}Banman` functions to avoid code repetition and make it cleaner. Same approach as done with argsman, chainman, connman and others. ACKs for top commit: davidgumberg: ACK [2d955ff](https://github.com/bitcoin/bitcoin/commit/2d955ff006b8949017fe617c35cfc1cfe117db6e) Tree-SHA512: 0beb7125312168a3df130c1793a1412ab423ef0f46023bfe2a121630c79df7e55d3d143fcf053bd09e2d96e9385a7a04594635da3e5c6be0c5d3a9cafbe3b631 * Apply suggestions from code review --------- Co-authored-by: merge-script <90386131+bitcoin-core-merge-script@users.noreply.github.com> --- src/rpc/net.cpp | 34 +++++++++++----------------------- src/rpc/server_util.cpp | 14 ++++++++++++++ src/rpc/server_util.h | 3 +++ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 95cdfdf6cb114..d2c05168ffc16 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -741,9 +741,7 @@ static RPCHelpMan setban() throw std::runtime_error(help.ToString()); } const NodeContext& node = EnsureAnyNodeContext(request.context); - if (!node.banman) { - throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded"); - } + BanMan& banman = EnsureBanman(node); CSubNet subNet; CNetAddr netAddr; @@ -766,7 +764,7 @@ static RPCHelpMan setban() if (strCommand == "add") { - if (isSubnet ? node.banman->IsBanned(subNet) : node.banman->IsBanned(netAddr)) { + if (isSubnet ? banman.IsBanned(subNet) : banman.IsBanned(netAddr)) { throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned"); } @@ -779,12 +777,12 @@ static RPCHelpMan setban() absolute = true; if (isSubnet) { - node.banman->Ban(subNet, banTime, absolute); + banman.Ban(subNet, banTime, absolute); if (node.connman) { node.connman->DisconnectNode(subNet); } } else { - node.banman->Ban(netAddr, banTime, absolute); + banman.Ban(netAddr, banTime, absolute); if (node.connman) { node.connman->DisconnectNode(netAddr); } @@ -792,7 +790,7 @@ static RPCHelpMan setban() } else if(strCommand == "remove") { - if (!( isSubnet ? node.banman->Unban(subNet) : node.banman->Unban(netAddr) )) { + if (!( isSubnet ? banman.Unban(subNet) : banman.Unban(netAddr) )) { throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Unban failed. Requested address/subnet was not previously manually banned."); } } @@ -823,14 +821,10 @@ static RPCHelpMan listbanned() }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { - - const NodeContext& node = EnsureAnyNodeContext(request.context); - if(!node.banman) { - throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded"); - } + BanMan& banman = EnsureAnyBanman(request.context); banmap_t banMap; - node.banman->GetBanned(banMap); + banman.GetBanned(banMap); const int64_t current_time{GetTime()}; UniValue bannedAddresses(UniValue::VARR); @@ -864,12 +858,9 @@ static RPCHelpMan clearbanned() }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { - const NodeContext& node = EnsureAnyNodeContext(request.context); - if (!node.banman) { - throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded"); - } + BanMan& banman = EnsureAnyBanman(request.context); - node.banman->ClearBanned(); + banman.ClearBanned(); return NullUniValue; }, @@ -888,12 +879,9 @@ static RPCHelpMan cleardiscouraged() }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { - const NodeContext& node = EnsureAnyNodeContext(request.context); - if (!node.banman) { - throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded"); - } + BanMan& banman = EnsureAnyBanman(request.context); - node.banman->ClearDiscouraged(); + banman.ClearDiscouraged(); return NullUniValue; }, diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp index feaa859b52fca..2739e1db88c77 100644 --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -56,6 +56,20 @@ CTxMemPool& EnsureAnyMemPool(const CoreContext& context) return EnsureMemPool(EnsureAnyNodeContext(context)); } + +BanMan& EnsureBanman(const NodeContext& node) +{ + if (!node.banman) { + throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded"); + } + return *node.banman; +} + +BanMan& EnsureAnyBanman(const CoreContext& context) +{ + return EnsureBanman(EnsureAnyNodeContext(context)); +} + ArgsManager& EnsureArgsman(const NodeContext& node) { if (!node.args) { diff --git a/src/rpc/server_util.h b/src/rpc/server_util.h index 79ad619ece01f..81e330817f7c8 100644 --- a/src/rpc/server_util.h +++ b/src/rpc/server_util.h @@ -13,6 +13,7 @@ class CConnman; class CTxMemPool; class ChainstateManager; class PeerManager; +class BanMan; struct LLMQContext; namespace node { struct NodeContext; @@ -21,6 +22,8 @@ struct NodeContext; node::NodeContext& EnsureAnyNodeContext(const CoreContext& context); CTxMemPool& EnsureMemPool(const node::NodeContext& node); CTxMemPool& EnsureAnyMemPool(const CoreContext& context); +BanMan& EnsureBanman(const node::NodeContext& node); +BanMan& EnsureAnyBanman(const CoreContext& context); ArgsManager& EnsureArgsman(const node::NodeContext& node); ArgsManager& EnsureAnyArgsman(const CoreContext& context); ChainstateManager& EnsureChainman(const node::NodeContext& node); From b79770c7cdbeb684676a5f736c42bb097ac33c45 Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:21:26 -0500 Subject: [PATCH 2/7] Merge bitcoin/bitcoin#26992: refactor: Remove unused CDataStream SerializeMany constructor Co-authored-by: Claude Code --- src/llmq/quorums.cpp | 3 ++- src/streams.h | 7 ------- src/test/serialize_tests.cpp | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 2f05b9d6c814f..6c1dc379bd4e7 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -741,7 +741,8 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& connman, const break; } request.SetError(nError); - CDataStream ssResponse(SER_NETWORK, pfrom.GetCommonVersion(), request, body); + CDataStream ssResponse{SER_NETWORK, pfrom.GetCommonVersion()}; + ssResponse << request << body; connman.PushMessage(&pfrom, CNetMsgMaker(pfrom.GetCommonVersion()).Make(NetMsgType::QDATA, ssResponse)); return ret; }; diff --git a/src/streams.h b/src/streams.h index dca09ac17f71c..22972ffb25e8d 100644 --- a/src/streams.h +++ b/src/streams.h @@ -362,13 +362,6 @@ class CDataStream : public DataStream nType{nTypeIn}, nVersion{nVersionIn} {} - template - CDataStream(int nTypeIn, int nVersionIn, Args&&... args) - : nType{nTypeIn}, - nVersion{nVersionIn} - { - ::SerializeMany(*this, std::forward(args)...); - } void SetType(int n) { nType = n; } int GetType() const { return nType; } diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 8ef4942529704..d0b6cc774ccf5 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -289,7 +289,8 @@ BOOST_AUTO_TEST_CASE(class_methods) BOOST_CHECK(methodtest2 == methodtest3); BOOST_CHECK(methodtest3 == methodtest4); - CDataStream ss2(SER_DISK, PROTOCOL_VERSION, intval, boolval, stringval, charstrval, txval); + CDataStream ss2{SER_DISK, PROTOCOL_VERSION}; + ss2 << intval << boolval << stringval << charstrval << txval; ss2 >> methodtest3; BOOST_CHECK(methodtest3 == methodtest4); { From 5e10d4e8100b21d37b5bf724c4e9aa38c4544326 Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:30:16 -0500 Subject: [PATCH 3/7] Merge bitcoin-core/gui#695: Fix misleading RPC console wallet message 576f7b86147447215566f0b15ef0b56cd1282929 Fix misleading RPC console wallet message (John Moffett) Pull request description: ## Misleading message from RPCConsole window ## In certain circumstances, the GUI console will display the message 'Executing command without any wallet' when it is, in fact, using the currently loaded wallet. For instance: ![scr3](https://user-images.githubusercontent.com/116917595/211404066-d49a6cbf-d3c3-4e89-8720-3583c6acf521.gif) In RPC calls, if no wallet is explicitly selected and there is exactly one wallet loaded, the [default](https://github.com/bitcoin-core/gui/blob/39363a4b945114f5e4718f75098f3036e8fe6a1d/src/wallet/rpc/util.cpp#L71-L93) is to act on that loaded wallet. The GUI console acts that way in reality, but sometimes erroneously reports that it's not acting on any particular wallet. The root issue is due to the logic that prevents changing the selected wallet if the RPCConsole is visible: https://github.com/bitcoin-core/gui/blob/39363a4b945114f5e4718f75098f3036e8fe6a1d/src/qt/rpcconsole.cpp#L783-L786 This PR removes that unnecessary logic. This does have some ramifications. Prior to this PR, if a user opened the console window without any wallets loaded, then opened two or more wallets, the RPC console would select "None" of the wallets and any wallet-specific RPCs would fail. However, the behavior was different if the user hadn't had the console window open. In that case, if they opened the RPC Console window _after_ loading at least the first wallet, it would select the first-loaded wallet. This context-dependent behavior is (IMO) undesirable, and this PR changes it to be consistent. ACKs for top commit: hebasto: ACK 576f7b86147447215566f0b15ef0b56cd1282929, tested on Ubuntu 22.04 (Qt 5.15.3). Tree-SHA512: 627da186025ba4f4e8df7fdd1b10363f923c4ecc50f023bbf2aece6e2593da65c45147c933effaca9040f813a6e46f034fc2d1ee2fb0f401000a3a6221a0e36e Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> --- src/qt/rpcconsole.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index a44190ff71b1e..8fc2c69d9124c 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -826,10 +826,8 @@ void RPCConsole::addWallet(WalletModel * const walletModel) // use name for text and wallet model for internal data object (to allow to move to a wallet id later) ui->WalletSelector->addItem(walletModel->getDisplayName(), QVariant::fromValue(walletModel)); if (ui->WalletSelector->count() == 2) { - if (!isVisible()) { - // First wallet added, set to default so long as the window isn't presently visible (and potentially in use) - ui->WalletSelector->setCurrentIndex(1); - } + // First wallet added, set to default to match wallet RPC behavior + ui->WalletSelector->setCurrentIndex(1); // The only loaded wallet ui->btn_rescan1->setEnabled(true); ui->btn_rescan2->setEnabled(true); From 5e6e706b9911e024e07aa80584f6395dd578d225 Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:31:50 -0500 Subject: [PATCH 4/7] Merge bitcoin/bitcoin#26935: refactor: Fix clang-tidy readability-const-return-type violations fa451d4 Fix clang-tidy readability-const-return-type violations (MarcoFalke) Pull request description: This comes up during review, so instead of wasting review cycles on this, just enforce it via CI ACKs for top commit: stickies-v: utACK fa451d4 hebasto: ACK fa451d4. --- src/.clang-tidy | 1 + src/arith_uint256.h | 28 ++++++++++++++-------------- src/bench/gcs_filter.cpp | 2 +- src/qt/optionsmodel.cpp | 4 ++-- src/script/descriptor.cpp | 6 +++--- src/script/descriptor.h | 6 +++--- src/test/fuzz/util.h | 2 +- src/test/versionbits_tests.cpp | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 2 +- src/util/fees.cpp | 2 +- src/util/fees.h | 2 +- src/util/system.cpp | 4 ++-- src/util/system.h | 4 ++-- src/validationinterface.cpp | 2 +- src/wallet/rpc/transactions.cpp | 2 +- src/wallet/scriptpubkeyman.cpp | 4 ++-- src/wallet/scriptpubkeyman.h | 6 +++--- src/wallet/test/wallet_tests.cpp | 2 +- src/wallet/wallet.h | 3 ++- src/wallet/wallettool.cpp | 2 +- 21 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/.clang-tidy b/src/.clang-tidy index 8a2755db01c07..3d8b242963ff1 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -2,6 +2,7 @@ Checks: ' -*, bugprone-argument-comment, modernize-use-nullptr, +readability-const-return-type, readability-redundant-declaration, readability-redundant-string-init, ' diff --git a/src/arith_uint256.h b/src/arith_uint256.h index b7b3b3a2852ab..4950bda3d550c 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -58,7 +58,7 @@ class base_uint explicit base_uint(const std::string& str); - const base_uint operator~() const + base_uint operator~() const { base_uint ret; for (int i = 0; i < WIDTH; i++) @@ -66,7 +66,7 @@ class base_uint return ret; } - const base_uint operator-() const + base_uint operator-() const { base_uint ret; for (int i = 0; i < WIDTH; i++) @@ -171,7 +171,7 @@ class base_uint return *this; } - const base_uint operator++(int) + base_uint operator++(int) { // postfix operator const base_uint ret = *this; @@ -188,7 +188,7 @@ class base_uint return *this; } - const base_uint operator--(int) + base_uint operator--(int) { // postfix operator const base_uint ret = *this; @@ -199,16 +199,16 @@ class base_uint int CompareTo(const base_uint& b) const; bool EqualTo(uint64_t b) const; - friend inline const base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; } - friend inline const base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; } - friend inline const base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; } - friend inline const base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; } - friend inline const base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; } - friend inline const base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; } - friend inline const base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; } - friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; } - friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; } - friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; } + friend inline base_uint operator+(const base_uint& a, const base_uint& b) { return base_uint(a) += b; } + friend inline base_uint operator-(const base_uint& a, const base_uint& b) { return base_uint(a) -= b; } + friend inline base_uint operator*(const base_uint& a, const base_uint& b) { return base_uint(a) *= b; } + friend inline base_uint operator/(const base_uint& a, const base_uint& b) { return base_uint(a) /= b; } + friend inline base_uint operator|(const base_uint& a, const base_uint& b) { return base_uint(a) |= b; } + friend inline base_uint operator&(const base_uint& a, const base_uint& b) { return base_uint(a) &= b; } + friend inline base_uint operator^(const base_uint& a, const base_uint& b) { return base_uint(a) ^= b; } + friend inline base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; } + friend inline base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; } + friend inline base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; } friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; } friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; } friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; } diff --git a/src/bench/gcs_filter.cpp b/src/bench/gcs_filter.cpp index 7f08cbec681b9..c9bccbc502338 100644 --- a/src/bench/gcs_filter.cpp +++ b/src/bench/gcs_filter.cpp @@ -5,7 +5,7 @@ #include #include -static const GCSFilter::ElementSet GenerateGCSTestElements() +static GCSFilter::ElementSet GenerateGCSTestElements() { GCSFilter::ElementSet elements; diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index a4d61ad7a6ffc..0ed490752d403 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -33,7 +33,7 @@ const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1"; -static const QString GetDefaultProxyAddress(); +static QString GetDefaultProxyAddress(); OptionsModel::OptionsModel(QObject *parent, bool resetSettings) : QAbstractListModel(parent) @@ -405,7 +405,7 @@ static void SetProxySetting(QSettings &settings, const QString &name, const Prox settings.setValue(name, QString{ip_port.ip + QLatin1Char(':') + ip_port.port}); } -static const QString GetDefaultProxyAddress() +static QString GetDefaultProxyAddress() { return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT); } diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 2993de8cd4aee..c6d2c5a82a15a 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -1253,17 +1253,17 @@ DescriptorCache DescriptorCache::MergeAndDiff(const DescriptorCache& other) return diff; } -const ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const +ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const { return m_parent_xpubs; } -const std::unordered_map DescriptorCache::GetCachedDerivedExtPubKeys() const +std::unordered_map DescriptorCache::GetCachedDerivedExtPubKeys() const { return m_derived_xpubs; } -const ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const +ExtPubKeyMap DescriptorCache::GetCachedLastHardenedExtPubKeys() const { return m_last_hardened_xpubs; } diff --git a/src/script/descriptor.h b/src/script/descriptor.h index 2e7568eafadef..505c44537b062 100644 --- a/src/script/descriptor.h +++ b/src/script/descriptor.h @@ -66,11 +66,11 @@ class DescriptorCache { bool GetCachedLastHardenedExtPubKey(uint32_t key_exp_pos, CExtPubKey& xpub) const; /** Retrieve all cached parent xpubs */ - const ExtPubKeyMap GetCachedParentExtPubKeys() const; + ExtPubKeyMap GetCachedParentExtPubKeys() const; /** Retrieve all cached derived xpubs */ - const std::unordered_map GetCachedDerivedExtPubKeys() const; + std::unordered_map GetCachedDerivedExtPubKeys() const; /** Retrieve all cached last hardened xpubs */ - const ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const; + ExtPubKeyMap GetCachedLastHardenedExtPubKeys() const; /** Combine another DescriptorCache into this one. * Returns a cache containing the items from the other cache unknown to current cache diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 499a17b23fece..0df12081c3a5f 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -115,7 +115,7 @@ void CallOneOf(FuzzedDataProvider& fuzzed_data_provider, Callables... callables) template auto& PickValue(FuzzedDataProvider& fuzzed_data_provider, Collection& col) { - const auto sz = col.size(); + auto sz{col.size()}; assert(sz >= 1); auto it = col.begin(); std::advance(it, fuzzed_data_provider.ConsumeIntegralInRange(0, sz - 1)); diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp index fbb92e9cc0357..b6d6b32717754 100644 --- a/src/test/versionbits_tests.cpp +++ b/src/test/versionbits_tests.cpp @@ -15,7 +15,7 @@ /* Define a virtual block time, one block per 10 minutes after Nov 14 2014, 0:55:36am */ static int32_t TestTime(int nHeight) { return 1415926536 + 600 * nHeight; } -static const std::string StateName(ThresholdState state) +static std::string StateName(ThresholdState state) { switch (state) { case ThresholdState::DEFINED: return "DEFINED"; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index e90128f7df5a1..32f91fc65c06c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1739,7 +1739,7 @@ void CTxMemPool::SetIsLoaded(bool loaded) } -const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept { switch (r) { case MemPoolRemovalReason::EXPIRY: return "expiry"; diff --git a/src/txmempool.h b/src/txmempool.h index 4a97b9b90ffab..25eedd282b9a1 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -356,7 +356,7 @@ enum class MemPoolRemovalReason { MANUAL //!< Removed manually }; -const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; /** * CTxMemPool stores valid-according-to-the-current-best-chain transactions diff --git a/src/util/fees.cpp b/src/util/fees.cpp index cbefe18dbb918..8ada02ce5429f 100644 --- a/src/util/fees.cpp +++ b/src/util/fees.cpp @@ -49,7 +49,7 @@ std::string FeeModes(const std::string& delimiter) return Join(FeeModeMap(), delimiter, [&](const std::pair& i) { return i.first; }); } -const std::string InvalidEstimateModeErrorMessage() +std::string InvalidEstimateModeErrorMessage() { return "Invalid estimate_mode parameter, must be one of: \"" + FeeModes("\", \"") + "\""; } diff --git a/src/util/fees.h b/src/util/fees.h index 9ef2389d3e706..10ba1e4f85734 100644 --- a/src/util/fees.h +++ b/src/util/fees.h @@ -13,6 +13,6 @@ enum class FeeReason; bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode); std::string StringForFeeReason(FeeReason reason); std::string FeeModes(const std::string& delimiter); -const std::string InvalidEstimateModeErrorMessage(); +std::string InvalidEstimateModeErrorMessage(); #endif // BITCOIN_UTIL_FEES_H diff --git a/src/util/system.cpp b/src/util/system.cpp index 7cc212a53d51a..9c54e82fb849a 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -268,7 +268,7 @@ static std::optional InterpretValue(const KeyInfo& key, con ArgsManager::ArgsManager() {} ArgsManager::~ArgsManager() {} -const std::set ArgsManager::GetUnsuitableSectionOnlyArgs() const +std::set ArgsManager::GetUnsuitableSectionOnlyArgs() const { std::set unsuitables; @@ -288,7 +288,7 @@ const std::set ArgsManager::GetUnsuitableSectionOnlyArgs() const return unsuitables; } -const std::list ArgsManager::GetUnrecognizedSections() const +std::list ArgsManager::GetUnrecognizedSections() const { // Section names to be recognized in the config file. static const std::set available_sections{ diff --git a/src/util/system.h b/src/util/system.h index 7b9a39c3cd2c9..7bf10098315c6 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -265,12 +265,12 @@ class ArgsManager * on the command line or in a network-specific section in the * config file. */ - const std::set GetUnsuitableSectionOnlyArgs() const; + std::set GetUnsuitableSectionOnlyArgs() const; /** * Log warnings for unrecognized section names in the config file. */ - const std::list GetUnrecognizedSections() const; + std::list GetUnrecognizedSections() const; struct Command { /** The command (if one has been registered with AddCommand), or empty */ diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index ffdcafaa64d0d..e3594469a0c95 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -16,7 +16,7 @@ #include #include -const std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; +std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept; //! The MainSignalsInstance manages a list of shared_ptr //! callbacks. diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index 254498425d555..e75923cd5e502 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -416,7 +416,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM } } -static const std::vector TransactionDescriptionString() +static std::vector TransactionDescriptionString() { return {{RPCResult::Type::NUM, "confirmations", "The number of blockchain confirmations for the transaction. Available for 'send' and\n" "'receive' category of transactions. Negative confirmations indicate the\n" diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index d14772e35994d..d8ef16cab882b 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2459,12 +2459,12 @@ void DescriptorScriptPubKeyMan::WriteDescriptor() } } -const WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor() const +WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor() const { return m_wallet_descriptor; } -const std::vector DescriptorScriptPubKeyMan::GetScriptPubKeys() const +std::vector DescriptorScriptPubKeyMan::GetScriptPubKeys() const { LOCK(cs_desc_man); std::vector script_pub_keys; diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 6f35bbe0f3a60..6b936e833e2c6 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -34,7 +34,7 @@ class WalletStorage { public: virtual ~WalletStorage() = default; - virtual const std::string GetDisplayName() const = 0; + virtual std::string GetDisplayName() const = 0; virtual WalletDatabase& GetDatabase() const = 0; virtual bool IsWalletFlagSet(uint64_t) const = 0; virtual void UnsetBlankWalletFlag(WalletBatch&) = 0; @@ -609,8 +609,8 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan void AddDescriptorKey(const CKey& key, const CPubKey &pubkey); void WriteDescriptor(); - const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); - const std::vector GetScriptPubKeys() const; + WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); + std::vector GetScriptPubKeys() const; bool GetDescriptorString(std::string& out, const bool priv) const; bool GetMnemonicString(SecureString& mnemonic_out, SecureString& mnemonic_passphrase_out) const; diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index bd73767e74058..6612a1179b575 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -54,7 +54,7 @@ static_assert(WALLET_INCREMENTAL_RELAY_FEE >= DEFAULT_INCREMENTAL_RELAY_FEE, "wa BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup) -static const std::shared_ptr TestLoadWallet(WalletContext& context) +static std::shared_ptr TestLoadWallet(WalletContext& context) { DatabaseOptions options; options.create_flags = WALLET_FLAG_DESCRIPTORS; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 10a363c62fb72..0e89400962a21 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -960,7 +960,8 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati bool IsLegacy() const; /** Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet has no name */ - const std::string GetDisplayName() const override { + std::string GetDisplayName() const override + { std::string wallet_name = GetName().length() == 0 ? "default wallet" : GetName(); return strprintf("[%s]", wallet_name); }; diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index 184837a697306..b6e16fa0c4b21 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -57,7 +57,7 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag wallet_instance->TopUpKeyPool(); } -static const std::shared_ptr MakeWallet(const std::string& name, const fs::path& path, const ArgsManager& args, DatabaseOptions options) +static std::shared_ptr MakeWallet(const std::string& name, const fs::path& path, const ArgsManager& args, DatabaseOptions options) { DatabaseStatus status; bilingual_str error; From e7d44c5a9932e1b679a640073605d2162e184be0 Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 11:33:53 -0500 Subject: [PATCH 5/7] Merge bitcoin/bitcoin#26974: refactor: rpc: set TxToJSON default verbosity to SHOW_DETAILS a24e633339c45eaca28fc7af0488956332ac300c refactor: rpc: set TxToJSON default verbosity to SHOW_DETAILS (stickies-v) Pull request description: and are only to be called when we want to decode the transaction (i.e. its details) into JSON. If is , 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 equals . With this change, the assumptions and intent become more explicit. ACKs for top commit: w0xlt: ACK https://github.com/bitcoin/bitcoin/pull/26974/commits/a24e633339c45eaca28fc7af0488956332ac300c Tree-SHA512: b97235adae49b972bdbe10aca1438643fb35ec66a4e57166b1975b3015bc5a06a711feebe4453a8fefe71781e484b21ef80847d8e8a33694a3abcc863accd4d7 Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> --- src/core_write.cpp | 2 ++ src/rpc/blockchain.cpp | 2 +- src/rpc/rawtransaction.cpp | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core_write.cpp b/src/core_write.cpp index f57f28f5aca9b..6e0bb5cf55d14 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -180,6 +180,8 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex, bool i void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo, TxVerbosity verbosity, const CSpentIndexTxInfo* ptxSpentInfo) { + CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS); + uint256 txid = tx.GetHash(); entry.pushKV("txid", txid.GetHex()); // Transaction version is actually unsigned in consensus checks, just signed in memory, diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index dd08f585103b8..49ba132252fd8 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -81,7 +81,7 @@ static Mutex cs_blockchange; static std::condition_variable cond_blockchange; static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange); -extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry); +extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS); /* Calculate the difficulty for a given block index. */ diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 0ad984c98faaa..50d1c626c2c3d 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -66,10 +66,10 @@ using node::GetTransaction; using node::NodeContext; using node::PSBTAnalysis; -void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry) +void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS) { + CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS); LOCK(::cs_main); - // Call into TxToUniv() in bitcoin-common to decode the transaction hex. // // Blockchain contextual information (confirmations and blocktime) is not @@ -102,7 +102,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool txSpentInfoPtr = &txSpentInfo; } - TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, /*serialize_flags=*/0, /*txundo=*/nullptr, TxVerbosity::SHOW_DETAILS, txSpentInfoPtr); + TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, /*serialize_flags=*/0, /*txundo=*/nullptr, verbosity, txSpentInfoPtr); bool chainLock = false; if (!hashBlock.IsNull()) { From 67a651a20f250a5a67148e77d1c8d5106007085a Mon Sep 17 00:00:00 2001 From: PastaBot <156604295+DashCoreAutoGuix@users.noreply.github.com> Date: Tue, 22 Jul 2025 21:09:21 -0500 Subject: [PATCH 6/7] Merge bitcoin/bitcoin#26829: init: Remove unnecessary sensitive flag from rpcbind b9d567454159f062ce84353f5821d6e6daf433bd init: Remove sensitive flag from rpcbind (Andrew Chow) Pull request description: `-rpcbind` is currently flagged as a sensitive option which means that its value will be masked when the command line args are written to the debug.log file. However this is not useful as if `rpcbind` is actually activated, the bound IP addresses will be written to the log anyways. The test `feature_config_args.py` did not catch this contradiction as the test node was not started with `rpcallowip` and so `rpcbind` was not acted upon. This also brings `rpcbind` inline with `bind` as that is not flagged as sensitive either. ACKs for top commit: Sjors: re-utACK b9d567454159f062ce84353f5821d6e6daf433bd willcl-ark: ACK b9d5674 theStack: ACK b9d567454159f062ce84353f5821d6e6daf433bd Tree-SHA512: 50ab5ad2e18ae70649deb1ac429d404b5f5c41f32a4943b2041480580152df22e72d4aae493379d0b23fcb649ab342376a82119760fbf6dfdcda659ffd3e244a Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> --- src/init.cpp | 2 +- test/functional/feature_config_args.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 5dab028704b15..f748a4e93416d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -758,7 +758,7 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-rest", strprintf("Accept public REST requests (default: %u)", DEFAULT_REST_ENABLE), ArgsManager::ALLOW_ANY, OptionsCategory::RPC); argsman.AddArg("-rpcallowip=", "Allow JSON-RPC connections from specified source. Valid values for are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0), a network/CIDR (e.g. 1.2.3.4/24), all ipv4 (0.0.0.0/0), or all ipv6 (::/0). This option can be specified multiple times", ArgsManager::ALLOW_ANY, OptionsCategory::RPC); argsman.AddArg("-rpcauth=", "Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The field comes in the format: :$. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=/rpcpassword= pair of arguments. This option can be specified multiple times", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC); - argsman.AddArg("-rpcbind=[:port]", "Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY | ArgsManager::SENSITIVE, OptionsCategory::RPC); + argsman.AddArg("-rpcbind=[:port]", "Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::RPC); argsman.AddArg("-rpccookiefile=", "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)", ArgsManager::ALLOW_ANY, OptionsCategory::RPC); argsman.AddArg("-rpcexternaluser=", "List of comma-separated usernames for JSON-RPC external connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC); argsman.AddArg("-rpcexternalworkqueue=", strprintf("Set the depth of the work queue to service external RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC); diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index a3b51207dec57..d8975d9f8944a 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -122,7 +122,6 @@ def test_args_log(self): expected_msgs=[ 'Command-line arg: addnode="some.node"', 'Command-line arg: rpcauth=****', - 'Command-line arg: rpcbind=****', 'Command-line arg: rpcpassword=****', 'Command-line arg: rpcuser=****', 'Command-line arg: torpassword=****', @@ -131,14 +130,17 @@ def test_args_log(self): ], unexpected_msgs=[ 'alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0', - '127.1.1.1', 'secret-rpcuser', 'secret-torpassword', + 'Command-line arg: rpcbind=****', + 'Command-line arg: rpcallowip=****', ]): self.start_node(0, extra_args=[ '-addnode=some.node', '-rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0', '-rpcbind=127.1.1.1', + '-rpcbind=127.0.0.1', + "-rpcallowip=127.0.0.1", '-rpcpassword=', '-rpcuser=secret-rpcuser', '-torpassword=secret-torpassword', From bf272801c264cab823a86c24c89edc4ae4a8a6cb Mon Sep 17 00:00:00 2001 From: pasta Date: Thu, 24 Jul 2025 12:00:08 -0500 Subject: [PATCH 7/7] fix: compilation errors in bitcoin#27069 backport Add missing banman.h include for EnsureBanman functions and fix SetupDescriptorScriptPubKeyMans call with required parameters. Fixes compilation failures introduced in 1c0a3d0 (Merge bitcoin/bitcoin#27069: net: add Ensure{any}Banman). --- src/rpc/server_util.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp index 2739e1db88c77..60d24077736e9 100644 --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include