From faf0c2d942c8de7868a3fd3afc7fc9ea700c91d4 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 13 Jan 2025 21:39:03 +0100 Subject: [PATCH 1/2] refactor: Avoid copies by using const references or by move-construction --- src/external_signer.cpp | 5 +++-- src/external_signer.h | 4 ++-- src/netbase.h | 3 ++- src/psbt.cpp | 2 +- src/psbt.h | 2 +- src/test/argsman_tests.cpp | 4 ++-- src/wallet/rpc/util.cpp | 2 +- src/wallet/rpc/util.h | 2 +- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/external_signer.cpp b/src/external_signer.cpp index 33129199775..84d98a19906 100644 --- a/src/external_signer.cpp +++ b/src/external_signer.cpp @@ -15,14 +15,15 @@ #include #include -ExternalSigner::ExternalSigner(const std::string& command, const std::string chain, const std::string& fingerprint, const std::string name): m_command(command), m_chain(chain), m_fingerprint(fingerprint), m_name(name) {} +ExternalSigner::ExternalSigner(std::string command, std::string chain, std::string fingerprint, std::string name) + : m_command{std::move(command)}, m_chain{std::move(chain)}, m_fingerprint{std::move(fingerprint)}, m_name{std::move(name)} {} std::string ExternalSigner::NetworkArg() const { return " --chain " + m_chain; } -bool ExternalSigner::Enumerate(const std::string& command, std::vector& signers, const std::string chain) +bool ExternalSigner::Enumerate(const std::string& command, std::vector& signers, const std::string& chain) { // Call enumerate const UniValue result = RunCommandParseJSON(command + " enumerate"); diff --git a/src/external_signer.h b/src/external_signer.h index 318b3bc062c..5d23cef461f 100644 --- a/src/external_signer.h +++ b/src/external_signer.h @@ -31,7 +31,7 @@ public: //! @param[in] fingerprint master key fingerprint of the signer //! @param[in] chain "main", "test", "regtest" or "signet" //! @param[in] name device name - ExternalSigner(const std::string& command, const std::string chain, const std::string& fingerprint, const std::string name); + ExternalSigner(std::string command, std::string chain, std::string fingerprint, std::string name); //! Master key fingerprint of the signer std::string m_fingerprint; @@ -44,7 +44,7 @@ public: //! @param[in,out] signers vector to which new signers (with a unique master key fingerprint) are added //! @param chain "main", "test", "regtest" or "signet" //! @returns success - static bool Enumerate(const std::string& command, std::vector& signers, const std::string chain); + static bool Enumerate(const std::string& command, std::vector& signers, const std::string& chain); //! Display address on the device. Calls ` displayaddress --desc `. //! @param[in] descriptor Descriptor specifying which address to display. diff --git a/src/netbase.h b/src/netbase.h index d3c263f9e8a..174eae43e29 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -60,7 +60,8 @@ class Proxy public: Proxy() : m_is_unix_socket(false), m_tor_stream_isolation(false) {} explicit Proxy(const CService& _proxy, bool tor_stream_isolation = false) : proxy(_proxy), m_is_unix_socket(false), m_tor_stream_isolation(tor_stream_isolation) {} - explicit Proxy(const std::string path, bool tor_stream_isolation = false) : m_unix_socket_path(path), m_is_unix_socket(true), m_tor_stream_isolation(tor_stream_isolation) {} + explicit Proxy(std::string path, bool tor_stream_isolation = false) + : m_unix_socket_path(std::move(path)), m_is_unix_socket(true), m_tor_stream_isolation(tor_stream_isolation) {} CService proxy; std::string m_unix_socket_path; diff --git a/src/psbt.cpp b/src/psbt.cpp index 9339bf7c092..a1eafbc001d 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -322,7 +322,7 @@ bool PSBTInputSigned(const PSBTInput& input) return !input.final_script_sig.empty() || !input.final_script_witness.IsNull(); } -bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, unsigned int input_index, const PrecomputedTransactionData* txdata) +bool PSBTInputSignedAndVerified(const PartiallySignedTransaction& psbt, unsigned int input_index, const PrecomputedTransactionData* txdata) { CTxOut utxo; assert(input_index < psbt.inputs.size()); diff --git a/src/psbt.h b/src/psbt.h index 9d7fc05b791..1a426a2eeb3 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -1413,7 +1413,7 @@ PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction& bool PSBTInputSigned(const PSBTInput& input); /** Checks whether a PSBTInput is already signed by doing script verification using final fields. */ -bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, unsigned int input_index, const PrecomputedTransactionData* txdata); +bool PSBTInputSignedAndVerified(const PartiallySignedTransaction& psbt, unsigned int input_index, const PrecomputedTransactionData* txdata); /** Signs a PSBTInput, verifying that all provided data matches what is being signed. * diff --git a/src/test/argsman_tests.cpp b/src/test/argsman_tests.cpp index 5236d5db21c..e91ae5e96f3 100644 --- a/src/test/argsman_tests.cpp +++ b/src/test/argsman_tests.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(util_datadir) struct TestArgsManager : public ArgsManager { TestArgsManager() { m_network_only_args.clear(); } - void ReadConfigString(const std::string str_config) + void ReadConfigString(const std::string& str_config) { std::istringstream streamConfig(str_config); { @@ -63,7 +63,7 @@ struct TestArgsManager : public ArgsManager std::string error; BOOST_REQUIRE(ReadConfigStream(streamConfig, "", error)); } - void SetNetworkOnlyArg(const std::string arg) + void SetNetworkOnlyArg(const std::string& arg) { LOCK(cs_args); m_network_only_args.insert(arg); diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp index d68e6c65269..a699b226150 100644 --- a/src/wallet/rpc/util.cpp +++ b/src/wallet/rpc/util.cpp @@ -124,7 +124,7 @@ void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, entry.pushKV("parent_descs", std::move(parent_descs)); } -void HandleWalletError(const std::shared_ptr wallet, DatabaseStatus& status, bilingual_str& error) +void HandleWalletError(const std::shared_ptr& wallet, DatabaseStatus& status, bilingual_str& error) { if (!wallet) { // Map bad format to not found, since bad format is returned when the diff --git a/src/wallet/rpc/util.h b/src/wallet/rpc/util.h index d649721431a..89729218d1a 100644 --- a/src/wallet/rpc/util.h +++ b/src/wallet/rpc/util.h @@ -54,7 +54,7 @@ std::string LabelFromValue(const UniValue& value); //! Fetch parent descriptors of this scriptPubKey. void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry); -void HandleWalletError(const std::shared_ptr wallet, DatabaseStatus& status, bilingual_str& error); +void HandleWalletError(const std::shared_ptr& wallet, DatabaseStatus& status, bilingual_str& error); void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); } // namespace wallet diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 56c676c189f..abbb6c1267d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2534,7 +2534,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize) return res; } -util::Result CWallet::GetNewDestination(const OutputType type, const std::string label) +util::Result CWallet::GetNewDestination(const OutputType type, const std::string& label) { LOCK(cs_wallet); auto spk_man = GetScriptPubKeyMan(type, /*internal=*/false); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 24d6b07d356..d23c1a943ec 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -783,7 +783,7 @@ public: */ void MarkDestinationsDirty(const std::set& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - util::Result GetNewDestination(const OutputType type, const std::string label); + util::Result GetNewDestination(const OutputType type, const std::string& label); util::Result GetNewChangeDestination(const OutputType type); bool IsMine(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); From fa64d8424b8de49e219bffb842a33d484fb03212 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 10 Jul 2025 12:49:36 +0200 Subject: [PATCH 2/2] refactor: Enforce readability-avoid-const-params-in-decls --- src/.clang-tidy | 1 + src/addrman.h | 2 +- src/addrman_impl.h | 4 ++-- src/chainparams.h | 4 ++-- src/chainparamsbase.h | 4 ++-- src/common/bloom.h | 4 ++-- src/common/messages.h | 2 +- src/common/signmessage.h | 2 +- src/core_io.h | 4 ++-- src/crypto/hex_base.h | 6 +++--- src/deploymentinfo.h | 2 +- src/external_signer.h | 2 +- src/interfaces/mining.h | 2 +- src/interfaces/wallet.h | 4 ++-- src/kernel/bitcoinkernel.h | 4 ++-- src/net.h | 4 ++-- src/net_processing.cpp | 2 +- src/net_processing.h | 2 +- src/netaddress.h | 2 +- src/node/blockstorage.h | 2 +- src/node/miner.h | 2 +- src/node/transaction.h | 2 +- src/policy/fees/block_policy_estimator.h | 2 +- src/pow.h | 2 +- src/qt/addresstablemodel.h | 2 +- src/qt/networkstyle.h | 4 ++-- src/qt/rpcconsole.h | 8 ++++---- src/random.h | 2 +- src/rpc/blockchain.h | 4 ++-- src/rpc/rawtransaction_util.h | 2 +- src/rpc/util.h | 8 ++++---- src/script/miniscript.h | 2 +- src/script/script_error.h | 2 +- src/script/sigcache.h | 2 +- src/test/fuzz/util.h | 6 +++--- src/test/util/setup_common.h | 8 ++++---- src/test/validation_block_tests.cpp | 2 +- src/txmempool.h | 4 ++-- src/util/moneystr.h | 2 +- src/wallet/coinselection.h | 10 +++++----- src/wallet/crypter.h | 2 +- src/wallet/scriptpubkeyman.h | 6 +++--- src/wallet/spend.h | 2 +- src/wallet/test/init_test_fixture.h | 2 +- src/wallet/test/util.h | 2 +- src/wallet/test/wallet_test_fixture.h | 2 +- src/wallet/wallet.h | 10 +++++----- src/wallet/walletdb.h | 4 ++-- 48 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/.clang-tidy b/src/.clang-tidy index 011536498e1..a4378cea308 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -24,6 +24,7 @@ performance-*, -performance-no-int-to-ptr, -performance-noexcept-move-constructor, -performance-unnecessary-value-param, +readability-avoid-const-params-in-decls, readability-const-return-type, readability-container-contains, readability-redundant-declaration, diff --git a/src/addrman.h b/src/addrman.h index 3a3230143c1..8368e30b7b7 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -172,7 +172,7 @@ public: * * @return A vector of randomly selected addresses from vRandom. */ - std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network, const bool filtered = true) const; + std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network, bool filtered = true) const; /** * Returns an information-location pair for all addresses in the selected addrman table. diff --git a/src/addrman_impl.h b/src/addrman_impl.h index f825d20b032..c1716f891d6 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -135,7 +135,7 @@ public: std::pair Select(bool new_only, const std::unordered_set& networks) const EXCLUSIVE_LOCKS_REQUIRED(!cs); - std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network, const bool filtered = true) const + std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network, bool filtered = true) const EXCLUSIVE_LOCKS_REQUIRED(!cs); std::vector> GetEntries(bool from_tried) const @@ -267,7 +267,7 @@ private: * */ nid_type GetEntry(bool use_tried, size_t bucket, size_t position) const EXCLUSIVE_LOCKS_REQUIRED(cs); - std::vector GetAddr_(size_t max_addresses, size_t max_pct, std::optional network, const bool filtered = true) const EXCLUSIVE_LOCKS_REQUIRED(cs); + std::vector GetAddr_(size_t max_addresses, size_t max_pct, std::optional network, bool filtered = true) const EXCLUSIVE_LOCKS_REQUIRED(cs); std::vector> GetEntries_(bool from_tried) const EXCLUSIVE_LOCKS_REQUIRED(cs); diff --git a/src/chainparams.h b/src/chainparams.h index 571e9e177b2..732949e82f6 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -15,7 +15,7 @@ class ArgsManager; /** * Creates and returns a std::unique_ptr of the chosen chain. */ -std::unique_ptr CreateChainParams(const ArgsManager& args, const ChainType chain); +std::unique_ptr CreateChainParams(const ArgsManager& args, ChainType chain); /** * Return the currently selected parameters. This won't change after app @@ -26,6 +26,6 @@ const CChainParams &Params(); /** * Sets the params returned by Params() to those for the given chain type. */ -void SelectParams(const ChainType chain); +void SelectParams(ChainType chain); #endif // BITCOIN_CHAINPARAMS_H diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 37e69b3285f..1407f196f3b 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -35,7 +35,7 @@ private: /** * Creates and returns a std::unique_ptr of the chosen chain. */ -std::unique_ptr CreateBaseChainParams(const ChainType chain); +std::unique_ptr CreateBaseChainParams(ChainType chain); /** *Set the arguments for chainparams @@ -49,7 +49,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman); const CBaseChainParams& BaseParams(); /** Sets the params returned by Params() to those for the given chain. */ -void SelectBaseParams(const ChainType chain); +void SelectBaseParams(ChainType chain); /** List of possible chain / network names */ #define LIST_CHAIN_NAMES "main, test, testnet4, signet, regtest" diff --git a/src/common/bloom.h b/src/common/bloom.h index bff96a23a37..97007e1ff51 100644 --- a/src/common/bloom.h +++ b/src/common/bloom.h @@ -61,7 +61,7 @@ public: * It should generally always be a random value (and is largely only exposed for unit testing) * nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK) */ - CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn); + CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn); CBloomFilter() : nHashFuncs(0), nTweak(0), nFlags(0) {} SERIALIZE_METHODS(CBloomFilter, obj) { READWRITE(obj.vData, obj.nHashFuncs, obj.nTweak, obj.nFlags); } @@ -108,7 +108,7 @@ public: class CRollingBloomFilter { public: - CRollingBloomFilter(const unsigned int nElements, const double nFPRate); + CRollingBloomFilter(unsigned int nElements, double nFPRate); void insert(std::span vKey); bool contains(std::span vKey) const; diff --git a/src/common/messages.h b/src/common/messages.h index 4cabdc79f4d..60fdaa18625 100644 --- a/src/common/messages.h +++ b/src/common/messages.h @@ -31,7 +31,7 @@ std::string FeeModeInfo(std::pair& mode); std::string FeeModesDetail(std::string default_info); std::string InvalidEstimateModeErrorMessage(); bilingual_str PSBTErrorString(PSBTError error); -bilingual_str TransactionErrorString(const node::TransactionError error); +bilingual_str TransactionErrorString(node::TransactionError error); bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind); bilingual_str InvalidPortErrMsg(const std::string& optname, const std::string& strPort); bilingual_str AmountHighWarn(const std::string& optname); diff --git a/src/common/signmessage.h b/src/common/signmessage.h index 4533875a757..c2152f35336 100644 --- a/src/common/signmessage.h +++ b/src/common/signmessage.h @@ -72,6 +72,6 @@ bool MessageSign( */ uint256 MessageHash(const std::string& message); -std::string SigningResultString(const SigningResult res); +std::string SigningResultString(SigningResult res); #endif // BITCOIN_COMMON_SIGNMESSAGE_H diff --git a/src/core_io.h b/src/core_io.h index f768590ca2d..113a961f500 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -34,7 +34,7 @@ enum class TxVerbosity { // core_read.cpp CScript ParseScript(const std::string& s); -std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false); +std::string ScriptToAsmStr(const CScript& script, bool fAttemptSighashDecode = false); [[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true); [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk); bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header); @@ -42,7 +42,7 @@ bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header); [[nodiscard]] util::Result SighashFromStr(const std::string& sighash); // core_write.cpp -UniValue ValueFromAmount(const CAmount amount); +UniValue ValueFromAmount(CAmount amount); std::string FormatScript(const CScript& script); std::string EncodeHexTx(const CTransaction& tx); std::string SighashToStr(unsigned char sighash_type); diff --git a/src/crypto/hex_base.h b/src/crypto/hex_base.h index 9975f7f6137..286720af021 100644 --- a/src/crypto/hex_base.h +++ b/src/crypto/hex_base.h @@ -15,9 +15,9 @@ /** * Convert a span of bytes to a lower-case hexadecimal string. */ -std::string HexStr(const std::span s); -inline std::string HexStr(const std::span s) { return HexStr(MakeUCharSpan(s)); } -inline std::string HexStr(const std::span s) { return HexStr(MakeUCharSpan(s)); } +std::string HexStr(std::span s); +inline std::string HexStr(std::span s) { return HexStr(MakeUCharSpan(s)); } +inline std::string HexStr(std::span s) { return HexStr(MakeUCharSpan(s)); } signed char HexDigit(char c); diff --git a/src/deploymentinfo.h b/src/deploymentinfo.h index 875505c1465..dc3ef723f17 100644 --- a/src/deploymentinfo.h +++ b/src/deploymentinfo.h @@ -30,6 +30,6 @@ inline std::string DeploymentName(Consensus::DeploymentPos pos) return VersionBitsDeploymentInfo[pos].name; } -std::optional GetBuriedDeployment(const std::string_view deployment_name); +std::optional GetBuriedDeployment(std::string_view deployment_name); #endif // BITCOIN_DEPLOYMENTINFO_H diff --git a/src/external_signer.h b/src/external_signer.h index 5d23cef461f..1b36d49622e 100644 --- a/src/external_signer.h +++ b/src/external_signer.h @@ -55,7 +55,7 @@ public: //! Calls ` getdescriptors --account ` //! @param[in] account which BIP32 account to use (e.g. `m/44'/0'/account'`) //! @returns see doc/external-signer.md - UniValue GetDescriptors(const int account); + UniValue GetDescriptors(int account); //! Sign PartiallySignedTransaction on the device. //! Calls ` signtransaction` and passes the PSBT via stdin. diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h index 07ec5f9c3e0..993f70bd7aa 100644 --- a/src/interfaces/mining.h +++ b/src/interfaces/mining.h @@ -105,7 +105,7 @@ public: * On testnet this will additionally return a template with difficulty 1 if * the tip is more than 20 minutes old. */ - virtual std::unique_ptr waitNext(const node::BlockWaitOptions options = {}) = 0; + virtual std::unique_ptr waitNext(node::BlockWaitOptions options = {}) = 0; /** * Interrupts the current wait for the next block template. diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 3ca0738c879..40c612a4c51 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -95,7 +95,7 @@ public: virtual std::string getWalletName() = 0; // Get a new address. - virtual util::Result getNewDestination(const OutputType type, const std::string& label) = 0; + virtual util::Result getNewDestination(OutputType type, const std::string& label) = 0; //! Get public key. virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0; @@ -130,7 +130,7 @@ public: virtual util::Result displayAddress(const CTxDestination& dest) = 0; //! Lock coin. - virtual bool lockCoin(const COutPoint& output, const bool write_to_db) = 0; + virtual bool lockCoin(const COutPoint& output, bool write_to_db) = 0; //! Unlock coin. virtual bool unlockCoin(const COutPoint& output) = 0; diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index 0ee41adcc52..53a760cd2ff 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -760,7 +760,7 @@ BITCOINKERNEL_API void btck_logging_disable(); * * @param[in] options Sets formatting options of the log messages. */ -BITCOINKERNEL_API void btck_logging_set_options(const btck_LoggingOptions options); +BITCOINKERNEL_API void btck_logging_set_options(btck_LoggingOptions options); /** * @brief Set the log level of the global internal logger. This does not @@ -835,7 +835,7 @@ BITCOINKERNEL_API void btck_logging_connection_destroy(btck_LoggingConnection* l * @return An allocated chain parameters opaque struct. */ BITCOINKERNEL_API btck_ChainParameters* BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_parameters_create( - const btck_ChainType chain_type); + btck_ChainType chain_type); /** * Copy the chain parameters. diff --git a/src/net.h b/src/net.h index e7047c5bff2..2fa7c2deaa9 100644 --- a/src/net.h +++ b/src/net.h @@ -421,7 +421,7 @@ private: size_t m_bytes_sent GUARDED_BY(m_send_mutex) {0}; public: - explicit V1Transport(const NodeId node_id) noexcept; + explicit V1Transport(NodeId node_id) noexcept; bool ReceivedMessageComplete() const override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex) { @@ -1294,7 +1294,7 @@ public: * @param[in] network Select only addresses of this network (nullopt = all). * @param[in] filtered Select only addresses that are considered high quality (false = all). */ - std::vector GetAddressesUnsafe(size_t max_addresses, size_t max_pct, std::optional network, const bool filtered = true) const; + std::vector GetAddressesUnsafe(size_t max_addresses, size_t max_pct, std::optional network, bool filtered = true) const; /** * Return addresses from the per-requestor cache. If no cache entry exists, it is populated with * randomly selected addresses. This function can be used in untrusted contexts. diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 84c0ba9c41b..8939156b9a8 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -552,7 +552,7 @@ public: }; void UnitTestMisbehaving(NodeId peer_id) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) { Misbehaving(*Assert(GetPeerRef(peer_id)), ""); }; void ProcessMessage(CNode& pfrom, const std::string& msg_type, DataStream& vRecv, - const std::chrono::microseconds time_received, const std::atomic& interruptMsgProc) override + std::chrono::microseconds time_received, const std::atomic& interruptMsgProc) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_most_recent_block_mutex, !m_headers_presync_mutex, g_msgproc_mutex, !m_tx_download_mutex); void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) override; ServiceFlags GetDesirableServiceFlags(ServiceFlags services) const override; diff --git a/src/net_processing.h b/src/net_processing.h index 09f348c86bd..4b221c5d979 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -149,7 +149,7 @@ public: /** Process a single message from a peer. Public for fuzz testing */ virtual void ProcessMessage(CNode& pfrom, const std::string& msg_type, DataStream& vRecv, - const std::chrono::microseconds time_received, const std::atomic& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex) = 0; + std::chrono::microseconds time_received, const std::atomic& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex) = 0; /** This function is used for testing the stale tip eviction logic, see denialofservice_tests.cpp */ virtual void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) = 0; diff --git a/src/netaddress.h b/src/netaddress.h index c65568098e6..2191da54b76 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -206,7 +206,7 @@ public: std::vector GetAddrBytes() const; int GetReachabilityFrom(const CNetAddr& paddrPartner) const; - explicit CNetAddr(const struct in6_addr& pipv6Addr, const uint32_t scope = 0); + explicit CNetAddr(const struct in6_addr& pipv6Addr, uint32_t scope = 0); bool GetIn6Addr(struct in6_addr* pipv6Addr) const; friend bool operator==(const CNetAddr& a, const CNetAddr& b); diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 3fb6cc3e5bf..d8b716e98b1 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -370,7 +370,7 @@ public: CBlockIndex* InsertBlockIndex(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main); //! Mark one block file as pruned (modify associated database entries) - void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + void PruneOneBlockFile(int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main); CBlockIndex* LookupBlockIndex(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main); const CBlockIndex* LookupBlockIndex(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); diff --git a/src/node/miner.h b/src/node/miner.h index f4bebb51d33..0c268f1826d 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -128,7 +128,7 @@ private: * accounts for the BIP94 timewarp rule, so does not necessarily reflect the * consensus limit. */ -int64_t GetMinimumTime(const CBlockIndex* pindexPrev, const int64_t difficulty_adjustment_interval); +int64_t GetMinimumTime(const CBlockIndex* pindexPrev, int64_t difficulty_adjustment_interval); int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev); diff --git a/src/node/transaction.h b/src/node/transaction.h index e2f237ec383..d27057a4a93 100644 --- a/src/node/transaction.h +++ b/src/node/transaction.h @@ -70,7 +70,7 @@ static const CAmount DEFAULT_MAX_BURN_AMOUNT{0}; * @param[out] hashBlock The block hash, if the tx was found via -txindex or block_index * @returns The tx if found, otherwise nullptr */ -CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, const BlockManager& blockman, uint256& hashBlock); +CTransactionRef GetTransaction(const CBlockIndex* block_index, const CTxMemPool* mempool, const Txid& hash, const BlockManager& blockman, uint256& hashBlock); } // namespace node #endif // BITCOIN_NODE_TRANSACTION_H diff --git a/src/policy/fees/block_policy_estimator.h b/src/policy/fees/block_policy_estimator.h index ec432dcbf53..505eed0867d 100644 --- a/src/policy/fees/block_policy_estimator.h +++ b/src/policy/fees/block_policy_estimator.h @@ -200,7 +200,7 @@ private: const fs::path m_estimation_filepath; public: /** Create new BlockPolicyEstimator and initialize stats tracking classes with default values */ - CBlockPolicyEstimator(const fs::path& estimation_filepath, const bool read_stale_estimates); + CBlockPolicyEstimator(const fs::path& estimation_filepath, bool read_stale_estimates); virtual ~CBlockPolicyEstimator(); /** Process all the transactions that have been included in a block */ diff --git a/src/pow.h b/src/pow.h index 7ee1bddd3c3..26004c46187 100644 --- a/src/pow.h +++ b/src/pow.h @@ -24,7 +24,7 @@ class arith_uint256; * @return the proof-of-work target or nullopt if the nBits value * is invalid (due to overflow or exceeding pow_limit) */ -std::optional DeriveTarget(unsigned int nBits, const uint256 pow_limit); +std::optional DeriveTarget(unsigned int nBits, uint256 pow_limit); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&); unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&); diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h index 4bfacc56854..127378ed2f4 100644 --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -70,7 +70,7 @@ public: /* Add an address to the model. Returns the added address on success, and an empty string otherwise. */ - QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type); + QString addRow(const QString& type, const QString& label, const QString& address, OutputType address_type); /** Look up label for address in address book, if not found return empty string. */ QString labelForAddress(const QString &address) const; diff --git a/src/qt/networkstyle.h b/src/qt/networkstyle.h index ac103ee7327..2c6cc821478 100644 --- a/src/qt/networkstyle.h +++ b/src/qt/networkstyle.h @@ -16,7 +16,7 @@ class NetworkStyle { public: /** Get style associated with provided network id, or 0 if not known */ - static const NetworkStyle* instantiate(const ChainType networkId); + static const NetworkStyle* instantiate(ChainType networkId); const QString &getAppName() const { return appName; } const QIcon &getAppIcon() const { return appIcon; } @@ -24,7 +24,7 @@ public: const QString &getTitleAddText() const { return titleAddText; } private: - NetworkStyle(const QString &appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *titleAddText); + NetworkStyle(const QString& appName, int iconColorHueShift, int iconColorSaturationReduction, const char* titleAddText); QString appName; QIcon appIcon; diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 53dccd7dacf..bbd469cd3dd 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -48,7 +48,7 @@ public: explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent); ~RPCConsole(); - static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const QString& wallet_name = {}); + static bool RPCParseCommandLine(interfaces::Node* node, std::string& strResult, const std::string& strCommand, bool fExecute, std::string* pstrFilteredOut = nullptr, const QString& wallet_name = {}); static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const QString& wallet_name = {}) { return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, wallet_name); } @@ -56,8 +56,8 @@ public: void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0); #ifdef ENABLE_WALLET - void addWallet(WalletModel* const walletModel); - void removeWallet(WalletModel* const walletModel); + void addWallet(WalletModel* walletModel); + void removeWallet(WalletModel* walletModel); #endif // ENABLE_WALLET enum MessageClass { @@ -138,7 +138,7 @@ public Q_SLOTS: void setTabFocus(enum TabTypes tabType); #ifdef ENABLE_WALLET /** Set the current (ie - active) wallet */ - void setCurrentWallet(WalletModel* const wallet_model); + void setCurrentWallet(WalletModel* wallet_model); #endif // ENABLE_WALLET private: diff --git a/src/random.h b/src/random.h index 330c10a36b8..f0c0dcee816 100644 --- a/src/random.h +++ b/src/random.h @@ -95,7 +95,7 @@ void RandAddPeriodic() noexcept; * * Thread-safe. */ -void RandAddEvent(const uint32_t event_info) noexcept; +void RandAddEvent(uint32_t event_info) noexcept; /* =========================== BASE RANDOMNESS GENERATION FUNCTIONS =========================== diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 0e42bed9479..d14a43b22d0 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -36,10 +36,10 @@ static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; double GetDifficulty(const CBlockIndex& blockindex); /** Block description to JSON */ -UniValue blockToJSON(node::BlockManager& blockman, const CBlock& block, const CBlockIndex& tip, const CBlockIndex& blockindex, TxVerbosity verbosity, const uint256 pow_limit) LOCKS_EXCLUDED(cs_main); +UniValue blockToJSON(node::BlockManager& blockman, const CBlock& block, const CBlockIndex& tip, const CBlockIndex& blockindex, TxVerbosity verbosity, uint256 pow_limit) LOCKS_EXCLUDED(cs_main); /** Block header to JSON */ -UniValue blockheaderToJSON(const CBlockIndex& tip, const CBlockIndex& blockindex, const uint256 pow_limit) LOCKS_EXCLUDED(cs_main); +UniValue blockheaderToJSON(const CBlockIndex& tip, const CBlockIndex& blockindex, uint256 pow_limit) LOCKS_EXCLUDED(cs_main); /** Used by getblockstats to get feerates at different percentiles by weight */ void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector>& scores, int64_t total_weight); diff --git a/src/rpc/rawtransaction_util.h b/src/rpc/rawtransaction_util.h index 65e65c37892..7bd051220a7 100644 --- a/src/rpc/rawtransaction_util.h +++ b/src/rpc/rawtransaction_util.h @@ -54,7 +54,7 @@ std::vector> ParseOutputs(const UniValue& out void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in); /** Create a transaction from univalue parameters */ -CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional rbf, const uint32_t version); +CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional rbf, uint32_t version); /** Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet **/ std::vector DecodeTxDoc(const std::string& txid_field_doc, bool wallet); diff --git a/src/rpc/util.h b/src/rpc/util.h index f82ccbf832e..37530876d73 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -136,7 +136,7 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg std::string HelpExampleRpcNamed(const std::string& methodname, const RPCArgList& args); CPubKey HexToPubKey(const std::string& hex_in); -CTxDestination AddAndGetMultisigDestination(const int required, const std::vector& pubkeys, OutputType type, FlatSigningProvider& keystore, CScript& script_out); +CTxDestination AddAndGetMultisigDestination(int required, const std::vector& pubkeys, OutputType type, FlatSigningProvider& keystore, CScript& script_out); UniValue DescribeAddress(const CTxDestination& dest); @@ -154,7 +154,7 @@ UniValue JSONRPCTransactionError(node::TransactionError terr, const std::string& std::pair ParseDescriptorRange(const UniValue& value); /** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */ -std::vector EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider, const bool expand_priv = false); +std::vector EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider, bool expand_priv = false); /** * Serializing JSON objects depends on the outer type. Only arrays and @@ -372,7 +372,7 @@ struct RPCResult { : RPCResult{type, std::move(m_key_name), /*optional=*/false, std::move(description), std::move(inner), skip_type_check} {} /** Append the sections of the result. */ - void ToSections(Sections& sections, OuterType outer_type = OuterType::NONE, const int current_indent = 0) const; + void ToSections(Sections& sections, OuterType outer_type = OuterType::NONE, int current_indent = 0) const; /** Return the type string of the result when it is in an object (dict). */ std::string ToStringObj() const; /** Return the description string, including the result type. */ @@ -527,6 +527,6 @@ std::vector ScriptPubKeyDoc(); * * @return the target */ -uint256 GetTarget(const CBlockIndex& blockindex, const uint256 pow_limit); +uint256 GetTarget(const CBlockIndex& blockindex, uint256 pow_limit); #endif // BITCOIN_RPC_UTIL_H diff --git a/src/script/miniscript.h b/src/script/miniscript.h index c71203ed260..955ede236fe 100644 --- a/src/script/miniscript.h +++ b/src/script/miniscript.h @@ -1761,7 +1761,7 @@ enum class ParseContext { CLOSE_BRACKET, }; -int FindNextChar(std::span in, const char m); +int FindNextChar(std::span in, char m); /** Parse a key string ending at the end of the fragment's text representation. */ template diff --git a/src/script/script_error.h b/src/script/script_error.h index 198d037c2a9..58ac7db5393 100644 --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -88,6 +88,6 @@ typedef enum ScriptError_t #define SCRIPT_ERR_LAST SCRIPT_ERR_ERROR_COUNT -std::string ScriptErrorString(const ScriptError error); +std::string ScriptErrorString(ScriptError error); #endif // BITCOIN_SCRIPT_SCRIPT_ERROR_H diff --git a/src/script/sigcache.h b/src/script/sigcache.h index ca4b44910e6..fb3880966d4 100644 --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -55,7 +55,7 @@ public: void ComputeEntrySchnorr(uint256& entry, const uint256 &hash, std::span sig, const XOnlyPubKey& pubkey) const; - bool Get(const uint256& entry, const bool erase); + bool Get(const uint256& entry, bool erase); void Set(const uint256& entry); }; diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 0575b157ea8..a7b1bfd54ed 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -146,11 +146,11 @@ template [[nodiscard]] int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional& min = std::nullopt, const std::optional& max = std::nullopt) noexcept; -[[nodiscard]] CMutableTransaction ConsumeTransaction(FuzzedDataProvider& fuzzed_data_provider, const std::optional>& prevout_txids, const int max_num_in = 10, const int max_num_out = 10) noexcept; +[[nodiscard]] CMutableTransaction ConsumeTransaction(FuzzedDataProvider& fuzzed_data_provider, const std::optional>& prevout_txids, int max_num_in = 10, int max_num_out = 10) noexcept; -[[nodiscard]] CScriptWitness ConsumeScriptWitness(FuzzedDataProvider& fuzzed_data_provider, const size_t max_stack_elem_size = 32) noexcept; +[[nodiscard]] CScriptWitness ConsumeScriptWitness(FuzzedDataProvider& fuzzed_data_provider, size_t max_stack_elem_size = 32) noexcept; -[[nodiscard]] CScript ConsumeScript(FuzzedDataProvider& fuzzed_data_provider, const bool maybe_p2wsh = false) noexcept; +[[nodiscard]] CScript ConsumeScript(FuzzedDataProvider& fuzzed_data_provider, bool maybe_p2wsh = false) noexcept; [[nodiscard]] uint32_t ConsumeSequence(FuzzedDataProvider& fuzzed_data_provider) noexcept; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index fdb0951eee3..05851e41e32 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -73,7 +73,7 @@ struct BasicTestingSetup { m_rng.Reseed(GetRandHash()); } - explicit BasicTestingSetup(const ChainType chainType = ChainType::MAIN, TestOpts = {}); + explicit BasicTestingSetup(ChainType chainType = ChainType::MAIN, TestOpts = {}); ~BasicTestingSetup(); fs::path m_path_root; @@ -109,7 +109,7 @@ struct ChainTestingSetup : public BasicTestingSetup { bool m_block_tree_db_in_memory{true}; std::function m_make_chainman{}; - explicit ChainTestingSetup(const ChainType chainType = ChainType::MAIN, TestOpts = {}); + explicit ChainTestingSetup(ChainType chainType = ChainType::MAIN, TestOpts = {}); ~ChainTestingSetup(); // Supplies a chainstate, if one is needed @@ -120,7 +120,7 @@ struct ChainTestingSetup : public BasicTestingSetup { */ struct TestingSetup : public ChainTestingSetup { explicit TestingSetup( - const ChainType chainType = ChainType::MAIN, + ChainType chainType = ChainType::MAIN, TestOpts = {}); }; @@ -145,7 +145,7 @@ class CScript; */ struct TestChain100Setup : public TestingSetup { TestChain100Setup( - const ChainType chain_type = ChainType::REGTEST, + ChainType chain_type = ChainType::REGTEST, TestOpts = {}); /** diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 9f574be86ef..ec2a4c9c1a8 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -28,7 +28,7 @@ struct MinerTestingSetup : public RegTestingSetup { std::shared_ptr GoodBlock(const uint256& prev_hash); std::shared_ptr BadBlock(const uint256& prev_hash); std::shared_ptr FinalizeBlock(std::shared_ptr pblock); - void BuildChain(const uint256& root, int height, const unsigned int invalid_rate, const unsigned int branch_rate, const unsigned int max_size, std::vector>& blocks); + void BuildChain(const uint256& root, int height, unsigned int invalid_rate, unsigned int branch_rate, unsigned int max_size, std::vector>& blocks); }; } // namespace validation_block_tests diff --git a/src/txmempool.h b/src/txmempool.h index 166a024823b..bef711d4c71 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -553,7 +553,7 @@ public: bool CheckPolicyLimits(const CTransactionRef& tx); /** Removes a transaction from the unbroadcast set */ - void RemoveUnbroadcastTx(const Txid& txid, const bool unchecked = false); + void RemoveUnbroadcastTx(const Txid& txid, bool unchecked = false); /** Returns transactions in unbroadcast set */ std::set GetUnbroadcastTxs() const @@ -662,7 +662,7 @@ public: using TxHandle = CTxMemPool::txiter; - TxHandle StageAddition(const CTransactionRef& tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp); + TxHandle StageAddition(const CTransactionRef& tx, CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp); void StageRemoval(CTxMemPool::txiter it); diff --git a/src/util/moneystr.h b/src/util/moneystr.h index ecadf646913..ae30bd5f280 100644 --- a/src/util/moneystr.h +++ b/src/util/moneystr.h @@ -17,7 +17,7 @@ /* Do not use these functions to represent or parse monetary amounts to or from * JSON but use AmountFromValue and ValueFromAmount for that. */ -std::string FormatMoney(const CAmount n); +std::string FormatMoney(CAmount n); /** Parse an amount denoted in full coins. E.g. "0.0034" supplied on the command line. **/ std::optional ParseMoney(const std::string& str); diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 79fee40dc1d..0f67d4e36ad 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -306,7 +306,7 @@ typedef std::map FilteredOutputGroups * @param[in] payment_value Average payment value of the transaction output(s). * @param[in] change_fee Fee for creating a change output. */ -[[nodiscard]] CAmount GenerateChangeTarget(const CAmount payment_value, const CAmount change_fee, FastRandomContext& rng); +[[nodiscard]] CAmount GenerateChangeTarget(CAmount payment_value, CAmount change_fee, FastRandomContext& rng); enum class SelectionAlgorithm : uint8_t { @@ -317,7 +317,7 @@ enum class SelectionAlgorithm : uint8_t MANUAL = 4, }; -std::string GetAlgorithmName(const SelectionAlgorithm algo); +std::string GetAlgorithmName(SelectionAlgorithm algo); struct SelectionResult { @@ -371,7 +371,7 @@ public: void AddInputs(const std::set>& inputs, bool subtract_fee_outputs); /** How much individual inputs overestimated the bump fees for shared ancestries */ - void SetBumpFeeDiscount(const CAmount discount); + void SetBumpFeeDiscount(CAmount discount); /** Calculates and stores the waste for this result given the cost of change * and the opportunity cost of spending these inputs now vs in the future. @@ -385,7 +385,7 @@ public: * used if there is change, in which case it must be non-negative. * @param[in] change_fee The fee for creating a change output */ - void RecalculateWaste(const CAmount min_viable_change, const CAmount change_cost, const CAmount change_fee); + void RecalculateWaste(CAmount min_viable_change, CAmount change_cost, CAmount change_fee); [[nodiscard]] CAmount GetWaste() const; /** Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries */ @@ -432,7 +432,7 @@ public: * @returns Amount for change output, 0 when there is no change. * */ - CAmount GetChange(const CAmount min_viable_change, const CAmount change_fee) const; + CAmount GetChange(CAmount min_viable_change, CAmount change_fee) const; CAmount GetTarget() const { return m_target; } diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index 0737e561e33..90871245e57 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -79,7 +79,7 @@ private: int BytesToKeySHA512AES(std::span salt, const SecureString& key_data, int count, unsigned char* key, unsigned char* iv) const; public: - bool SetKeyFromPassphrase(const SecureString& key_data, std::span salt, const unsigned int rounds, const unsigned int derivation_method); + bool SetKeyFromPassphrase(const SecureString& key_data, std::span salt, unsigned int rounds, unsigned int derivation_method); bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext) const; bool Decrypt(std::span ciphertext, CKeyingMaterial& plaintext) const; bool SetKey(const CKeyingMaterial& new_key, std::span new_iv); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index fcb107a4762..00dd6eed4d1 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -337,13 +337,13 @@ public: mutable RecursiveMutex cs_desc_man; - util::Result GetNewDestination(const OutputType type) override; + util::Result GetNewDestination(OutputType type) override; bool IsMine(const CScript& script) const override; bool CheckDecryptionKey(const CKeyingMaterial& master_key) override; bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override; - util::Result GetReservedDestination(const OutputType type, bool internal, int64_t& index) override; + util::Result GetReservedDestination(OutputType type, bool internal, int64_t& index) override; void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) override; // Tops up the descriptor cache and m_map_script_pub_keys. The cache is stored in the wallet file @@ -402,7 +402,7 @@ public: std::unordered_set GetScriptPubKeys(int32_t minimum_index) const; int32_t GetEndRange() const; - [[nodiscard]] bool GetDescriptorString(std::string& out, const bool priv) const; + [[nodiscard]] bool GetDescriptorString(std::string& out, bool priv) const; void UpgradeDescriptorCache(); }; diff --git a/src/wallet/spend.h b/src/wallet/spend.h index a22499f3cd6..b10317f49a0 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -23,7 +23,7 @@ namespace wallet { /** Get the marginal bytes if spending the specified output from this transaction. * Use CoinControl to determine whether to expect signature grinding when calculating the size of the input spend. */ int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, const CCoinControl* coin_control); -int CalculateMaximumSignedInputSize(const CTxOut& txout, const COutPoint outpoint, const SigningProvider* pwallet, bool can_grind_r, const CCoinControl* coin_control); +int CalculateMaximumSignedInputSize(const CTxOut& txout, COutPoint outpoint, const SigningProvider* pwallet, bool can_grind_r, const CCoinControl* coin_control); struct TxSize { int64_t vsize{-1}; int64_t weight{-1}; diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h index b435527a835..a9e38db0b10 100644 --- a/src/wallet/test/init_test_fixture.h +++ b/src/wallet/test/init_test_fixture.h @@ -14,7 +14,7 @@ namespace wallet { struct InitWalletDirTestingSetup: public BasicTestingSetup { - explicit InitWalletDirTestingSetup(const ChainType chain_type = ChainType::MAIN); + explicit InitWalletDirTestingSetup(ChainType chain_type = ChainType::MAIN); ~InitWalletDirTestingSetup(); void SetWalletDir(const fs::path& walletdir_path); diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index ecedbd90807..33f36eb62d9 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -117,7 +117,7 @@ public: std::unique_ptr CreateMockableWalletDatabase(MockableData records = {}); MockableDatabase& GetMockableDatabase(CWallet& wallet); -DescriptorScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, const bool success); +DescriptorScriptPubKeyMan* CreateDescriptor(CWallet& keystore, const std::string& desc_str, bool success); } // namespace wallet #endif // BITCOIN_WALLET_TEST_UTIL_H diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index b268463a173..8c5b6661f7a 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -20,7 +20,7 @@ namespace wallet { /** Testing setup and teardown for wallet. */ struct WalletTestingSetup : public TestingSetup { - explicit WalletTestingSetup(const ChainType chainType = ChainType::MAIN); + explicit WalletTestingSetup(ChainType chainType = ChainType::MAIN); ~WalletTestingSetup(); std::unique_ptr m_wallet_loader; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d23c1a943ec..a36fc121470 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -444,7 +444,7 @@ private: * block locator and m_last_block_processed, and registering for * notifications about new blocks and transactions. */ - static bool AttachChain(const std::shared_ptr& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector& warnings); + static bool AttachChain(const std::shared_ptr& wallet, interfaces::Chain& chain, bool rescan_required, bilingual_str& error, std::vector& warnings); static NodeClock::time_point GetDefaultNextResend(); @@ -648,7 +648,7 @@ public: //! USER_ABORT. uint256 last_failed_block; }; - ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional max_height, const WalletRescanReserver& reserver, bool fUpdate, const bool save_progress); + ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional max_height, const WalletRescanReserver& reserver, bool fUpdate, bool save_progress); void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) override; /** Set the next time this wallet should resend transactions to 12-36 hours from now, ~1 day on average. */ void SetNextResend() { m_next_resend = GetDefaultNextResend(); } @@ -768,7 +768,7 @@ public: /** * Retrieve all the known labels in the address book */ - std::set ListAddrBookLabels(const std::optional purpose) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + std::set ListAddrBookLabels(std::optional purpose) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); /** * Walk-through the address book entries. @@ -783,8 +783,8 @@ public: */ void MarkDestinationsDirty(const std::set& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - util::Result GetNewDestination(const OutputType type, const std::string& label); - util::Result GetNewChangeDestination(const OutputType type); + util::Result GetNewDestination(OutputType type, const std::string& label); + util::Result GetNewChangeDestination(OutputType type); bool IsMine(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool IsMine(const CScript& script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index a867a28b970..c4466bfaef3 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -227,7 +227,7 @@ public: bool WriteTx(const CWalletTx& wtx); bool EraseTx(Txid hash); - bool WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey, const bool overwrite); + bool WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey, bool overwrite); bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata &keyMeta); bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector& vchCryptedSecret, const CKeyMetadata &keyMeta); bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey); @@ -268,7 +268,7 @@ public: //! Delete records of the given types bool EraseRecords(const std::unordered_set& types); - bool WriteWalletFlags(const uint64_t flags); + bool WriteWalletFlags(uint64_t flags); //! Begin a new transaction bool TxnBegin(); //! Commit current transaction