diff --git a/configure.ac b/configure.ac index 9fc705f2ab..a2f9f5212f 100755 --- a/configure.ac +++ b/configure.ac @@ -167,7 +167,7 @@ AC_ARG_ENABLE([natpmp-default], AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[do not compile tests (default is to compile)]), [use_tests=$enableval], - [use_tests=no]) + [use_tests=yes]) AC_ARG_ENABLE(gui-tests, AS_HELP_STRING([--disable-gui-tests],[do not compile GUI tests (default is to compile if GUI and tests enabled)]), @@ -343,7 +343,7 @@ AC_ARG_ENABLE([werror], AC_ARG_ENABLE([external-signer], [AS_HELP_STRING([--enable-external-signer],[compile external signer support (default is no, requires Boost::Process)])], [use_external_signer=$enableval], - [use_external_signer=no]) + [use_external_signer=yes]) AC_LANG_PUSH([C++]) @@ -387,7 +387,7 @@ if test "x$enable_debug" = xyes; then [[$CXXFLAG_WERROR]]) AX_CHECK_PREPROC_FLAG([-DDEBUG],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG"]],,[[$CXXFLAG_WERROR]]) - AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-ftrapv],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"],,[[$CXXFLAG_WERROR]]) fi @@ -453,12 +453,12 @@ if test "x$CXXFLAGS_overridden" = "xno"; then dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here. AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wshadow-all],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-all"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wswitch],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wswitch"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wunused],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]]) @@ -468,7 +468,28 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]], [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) + AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=const],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-attribute=const"],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=pure],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-attribute=pure"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=noreturn],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-attribute=noreturn"],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_COMPILE_FLAG([-Wsuggest-final-methods],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-final-methods"],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_COMPILE_FLAG([-Wsuggest-final-types],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-final-types"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wnon-virtual-dtor],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wnon-virtual-dtor"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Warray-bounds],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Warray-bounds"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wdisabled-optimization],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdisabled-optimization"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wuninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wuninitialized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Winit-self],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Winit-self"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wmissing-include-dirs],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wmissing-include-dirs"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wunsafe-loop-optimizations],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunsafe-loop-optimizations"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wvector-operation-performance],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvector-operation-performance"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Winvalid-pch],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Winvalid-pch"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wcast-align],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wcast-align"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wnormalized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wnormalized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wpacked],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wpacked"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wpointer-arith],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wpointer-arith"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wdouble-promotion],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdouble-promotion"],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_COMPILE_FLAG([-Wconversion],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconversion"],,[[$CXXFLAG_WERROR]]) + dnl AX_CHECK_COMPILE_FLAG([-Wuseless-cast],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wuseless-cast"],,[[$CXXFLAG_WERROR]]) if test x$suppress_external_warnings != xno ; then AX_CHECK_COMPILE_FLAG([-Wdocumentation],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdocumentation"],,[[$CXXFLAG_WERROR]]) @@ -477,13 +498,12 @@ if test "x$CXXFLAGS_overridden" = "xno"; then dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all dnl unknown options if any other warning is produced. Test the -Wfoo case, and dnl set the -Wno-foo case if it works. - AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"],,[[$CXXFLAG_WERROR]]) fi + dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CXXFLAGS="$CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) diff --git a/contrib/testgen/base58.py b/contrib/testgen/base58.py index 08203b8e0b..11bacd7124 100644 --- a/contrib/testgen/base58.py +++ b/contrib/testgen/base58.py @@ -107,7 +107,7 @@ def get_bcaddress_version(strAddress): if __name__ == '__main__': # Test case (from http://gitorious.org/BGL/python-base58.git) - assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') is 0 + assert get_bcaddress_version('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC') == 0 _ohai = 'o hai'.encode('ascii') _tmp = b58encode(_ohai) assert _tmp == 'DYB3oMS' diff --git a/src/BGL-cli.cpp b/src/BGL-cli.cpp index cdc451284a..97405071e3 100644 --- a/src/BGL-cli.cpp +++ b/src/BGL-cli.cpp @@ -244,7 +244,7 @@ class AddrinfoRequestHandler : public BaseRequestHandler } public: - UniValue PrepareRequest(const std::string& method, const std::vector& args) override + UniValue PrepareRequest([[maybe_unused]] const std::string& method, const std::vector& args) override { if (!args.empty()) { throw std::runtime_error("-addrinfo takes no arguments"); @@ -294,7 +294,7 @@ class GetinfoRequestHandler: public BaseRequestHandler const int ID_BALANCES = 3; /** Create a simulated `getinfo` request. */ - UniValue PrepareRequest(const std::string& method, const std::vector& args) override + UniValue PrepareRequest([[maybe_unused]] const std::string& method, const std::vector& args) override { if (!args.empty()) { throw std::runtime_error("-getinfo takes no arguments"); @@ -424,7 +424,7 @@ class NetinfoRequestHandler : public BaseRequestHandler static constexpr int ID_PEERINFO = 0; static constexpr int ID_NETWORKINFO = 1; - UniValue PrepareRequest(const std::string& method, const std::vector& args) override + UniValue PrepareRequest([[maybe_unused]] const std::string& method, const std::vector& args) override { if (!args.empty()) { uint8_t n{0}; @@ -627,7 +627,7 @@ class NetinfoRequestHandler : public BaseRequestHandler class GenerateToAddressRequestHandler : public BaseRequestHandler { public: - UniValue PrepareRequest(const std::string& method, const std::vector& args) override + UniValue PrepareRequest([[maybe_unused]] const std::string& method, const std::vector& args) override { address_str = args.at(1); UniValue params{RPCConvertValues("generatetoaddress", args)}; diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp index 6f6b4e3bfa..84b0080ff3 100644 --- a/src/bench/base58.cpp +++ b/src/bench/base58.cpp @@ -42,7 +42,7 @@ static void Base58CheckEncode(benchmark::Bench& bench) static void Base58Decode(benchmark::Bench& bench) { - const char* addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"; + const char* addr = "58sbDbzKTt1eVuXLeTJ8FqyWYed9wmP2pD"; std::vector vch; bench.batch(strlen(addr)).unit("byte").run([&] { (void) DecodeBase58(addr, vch, 64); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 8e704b7efa..3b2d76856d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -348,8 +348,9 @@ class SigNetParams : public CChainParams { genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); -// assert(consensus.hashGenesisBlock == uint256S("0x00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6")); -// assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); + + assert(consensus.hashGenesisBlock == uint256S("031d49b33598a1cb9559ae12feba7279cd944cd44b1862497aa38453751771fc")); + assert(genesis.hashMerkleRoot == uint256S("bb46c1c31b5660dd5fcd12aa9730dba0912952e4db9112331965fcdb32be74f5")); vFixedSeeds.clear(); diff --git a/src/coins.cpp b/src/coins.cpp index d52851cadd..9acaa06f5f 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -9,10 +9,10 @@ #include #include -bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; } +bool CCoinsView::GetCoin([[maybe_unused]] const COutPoint &outpoint, [[maybe_unused]] Coin &coin) const { return false; } uint256 CCoinsView::GetBestBlock() const { return uint256(); } std::vector CCoinsView::GetHeadBlocks() const { return std::vector(); } -bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; } +bool CCoinsView::BatchWrite([[maybe_unused]] CCoinsMap &mapCoins, [[maybe_unused]] const uint256 &hashBlock) { return false; } CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; } bool CCoinsView::HaveCoin(const COutPoint &outpoint) const diff --git a/src/compat.h b/src/compat.h index 748f3766e1..e9d372cb78 100644 --- a/src/compat.h +++ b/src/compat.h @@ -101,7 +101,7 @@ typedef char* sockopt_arg_type; #define USE_POLL #endif -bool static inline IsSelectableSocket(const SOCKET& s) { +bool static inline IsSelectableSocket([[maybe_unused]] const SOCKET& s) { #if defined(USE_POLL) || defined(WIN32) return true; #else @@ -119,4 +119,4 @@ bool static inline IsSelectableSocket(const SOCKET& s) { #define MSG_DONTWAIT 0 #endif -#endif // BGL_COMPAT_H \ No newline at end of file +#endif // BGL_COMPAT_H diff --git a/src/core_memusage.h b/src/core_memusage.h index 56c5826bf2..0c83ad8020 100644 --- a/src/core_memusage.h +++ b/src/core_memusage.h @@ -13,7 +13,7 @@ static inline size_t RecursiveDynamicUsage(const CScript& script) { return memusage::DynamicUsage(script); } -static inline size_t RecursiveDynamicUsage(const COutPoint& out) { +static inline size_t RecursiveDynamicUsage([[maybe_unused]] const COutPoint& out) { return 0; } diff --git a/src/core_write.cpp b/src/core_write.cpp index 835643b6fd..d4d740e7db 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -189,7 +189,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, } } -void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo) +void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex, int serialize_flags, [[maybe_unused]] const CTxUndo* txundo) { entry.pushKV("txid", tx.GetHash().GetHex()); entry.pushKV("hash", tx.GetWitnessHash().GetHex()); diff --git a/src/crypto/chacha_poly_aead.cpp b/src/crypto/chacha_poly_aead.cpp index 0582a60c4f..3e59337367 100644 --- a/src/crypto/chacha_poly_aead.cpp +++ b/src/crypto/chacha_poly_aead.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #ifndef HAVE_TIMINGSAFE_BCMP diff --git a/src/crypto/muhash.cpp b/src/crypto/muhash.cpp index 928ec33f6d..b645c648a2 100644 --- a/src/crypto/muhash.cpp +++ b/src/crypto/muhash.cpp @@ -9,7 +9,6 @@ #include #include -#include #include namespace { diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp index 29a4ad906f..d1d6492f96 100644 --- a/src/crypto/ripemd160.cpp +++ b/src/crypto/ripemd160.cpp @@ -32,7 +32,7 @@ void inline Initialize(uint32_t* s) uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32 - i)); } -void inline Round(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t f, uint32_t x, uint32_t k, int r) +void inline Round(uint32_t& a, [[maybe_unused]] uint32_t b, uint32_t& c, [[maybe_unused]] uint32_t d, uint32_t e, uint32_t f, uint32_t x, uint32_t k, int r) { a = rol(a + f + x + k, r) + e; c = rol(c, 10); diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index 1fb9bb2b72..6264c7f239 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -15,7 +15,7 @@ namespace namespace sha1 { /** One round of SHA-1. */ -void inline Round(uint32_t a, uint32_t& b, uint32_t c, uint32_t d, uint32_t& e, uint32_t f, uint32_t k, uint32_t w) +void inline Round(uint32_t a, uint32_t& b, [[maybe_unused]] uint32_t c, [[maybe_unused]] uint32_t d, uint32_t& e, uint32_t f, uint32_t k, uint32_t w) { e += ((a << 5) | (a >> 27)) + f + k + w; b = (b << 30) | (b >> 2); diff --git a/src/hash.cpp b/src/hash.cpp index 15964c5454..2cdc137cd2 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -47,8 +47,10 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span vData switch (vDataToHash.size() & 3) { case 3: k1 ^= tail[2] << 16; + [[fallthrough]]; case 2: k1 ^= tail[1] << 8; + [[fallthrough]]; case 1: k1 ^= tail[0]; k1 *= c1; diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 7df73ec261..7b54ca7cd3 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -30,7 +30,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; /** Simple one-shot callback timer to be used by the RPC mechanism to e.g. * re-lock the wallet. */ -class HTTPRPCTimer : public RPCTimerBase +class HTTPRPCTimer final : public RPCTimerBase { public: HTTPRPCTimer(struct event_base* eventBase, std::function& func, int64_t millis) : @@ -45,7 +45,7 @@ class HTTPRPCTimer : public RPCTimerBase HTTPEvent ev; }; -class HTTPRPCTimerInterface : public RPCTimerInterface +class HTTPRPCTimerInterface final : public RPCTimerInterface { public: explicit HTTPRPCTimerInterface(struct event_base* _base) : base(_base) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 05de61c59f..d5c5dc7b43 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -211,7 +211,7 @@ std::string RequestMethodString(HTTPRequest::RequestMethod m) } /** HTTP request callback */ -static void http_request_cb(struct evhttp_request* req, void* arg) +static void http_request_cb(struct evhttp_request* req, [[maybe_unused]] void* arg) { // Disable reading to work around a libevent bug, fixed in 2.2.0. if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) { diff --git a/src/index/base.h b/src/index/base.h index 25af3813c9..ac78322d1a 100644 --- a/src/index/base.h +++ b/src/index/base.h @@ -87,7 +87,7 @@ class BaseIndex : public CValidationInterface virtual bool Init(); /// Write update index entries for a newly connected block. - virtual bool WriteBlock(const CBlock& block, const CBlockIndex* pindex) { return true; } + virtual bool WriteBlock([[maybe_unused]] const CBlock& block, [[maybe_unused]] const CBlockIndex* pindex) { return true; } /// Virtual method called internally by Commit that can be overridden to atomically /// commit more index state. diff --git a/src/init/BGLd.cpp b/src/init/BGLd.cpp index 0d19d15853..b073515c4e 100644 --- a/src/init/BGLd.cpp +++ b/src/init/BGLd.cpp @@ -22,7 +22,7 @@ class BGLdInit : public interfaces::Init } // namespace init namespace interfaces { -std::unique_ptr MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status) +std::unique_ptr MakeNodeInit(NodeContext& node, [[maybe_unused]] int argc, [[maybe_unused]] char* argv[], [[maybe_unused]] int& exit_status) { return std::make_unique(node); } diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 2d9cf8e469..5b81298c55 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -234,12 +234,12 @@ class Chain { public: virtual ~Notifications() {} - virtual void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) {} - virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {} - virtual void blockConnected(const CBlock& block, int height) {} - virtual void blockDisconnected(const CBlock& block, int height) {} + virtual void transactionAddedToMempool([[maybe_unused]] const CTransactionRef& tx, [[maybe_unused]] uint64_t mempool_sequence) {} + virtual void transactionRemovedFromMempool([[maybe_unused]] const CTransactionRef& tx, [[maybe_unused]] MemPoolRemovalReason reason, [[maybe_unused]] uint64_t mempool_sequence) {} + virtual void blockConnected([[maybe_unused]] const CBlock& block, [[maybe_unused]] int height) {} + virtual void blockDisconnected([[maybe_unused]] const CBlock& block, [[maybe_unused]] int height) {} virtual void updatedBlockTip() {} - virtual void chainStateFlushed(const CBlockLocator& locator) {} + virtual void chainStateFlushed([[maybe_unused]] const CBlockLocator& locator) {} }; //! Register handler for notifications. diff --git a/src/interfaces/init.cpp b/src/interfaces/init.cpp index a3c949e616..6f7c1f25ea 100644 --- a/src/interfaces/init.cpp +++ b/src/interfaces/init.cpp @@ -11,7 +11,7 @@ namespace interfaces { std::unique_ptr Init::makeNode() { return {}; } std::unique_ptr Init::makeChain() { return {}; } -std::unique_ptr Init::makeWalletClient(Chain& chain) { return {}; } +std::unique_ptr Init::makeWalletClient([[maybe_unused]] Chain& chain) { return {}; } std::unique_ptr Init::makeEcho() { return {}; } Ipc* Init::ipc() { return nullptr; } } // namespace interfaces diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 602e233807..f15695ffb4 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -222,7 +222,7 @@ class Node //! Get and set internal node context. Useful for testing, but not //! accessible across processes. virtual NodeContext* context() { return nullptr; } - virtual void setContext(NodeContext* context) { } + virtual void setContext([[maybe_unused]] NodeContext* context) {} }; //! Return implementation of Node interface. diff --git a/src/key.h b/src/key.h index 163c17b4cd..e63f13ede0 100644 --- a/src/key.h +++ b/src/key.h @@ -85,7 +85,7 @@ class CKey } //! Simple read-only vector-like interface. - unsigned int size() const { return (fValid ? keydata.size() : 0); } + size_t size() const { return (fValid ? keydata.size() : 0); } const unsigned char* begin() const { return keydata.data(); } const unsigned char* end() const { return keydata.data() + size(); } diff --git a/src/key_io.cpp b/src/key_io.cpp index 1f1b7c5e32..75867f5015 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -65,7 +65,7 @@ class DestinationEncoder return bech32::Encode(bech32::Encoding::BECH32M, m_params.Bech32HRP(), data); } - std::string operator()(const CNoDestination& no) const { return {}; } + std::string operator()([[maybe_unused]] const CNoDestination& no) const { return {}; } }; CTxDestination DecodeDestination(const std::string& str, const CChainParams& params, std::string& error_str) diff --git a/src/leveldb/db/c.cc b/src/leveldb/db/c.cc index 3a492f9ac5..5997a70f9a 100644 --- a/src/leveldb/db/c.cc +++ b/src/leveldb/db/c.cc @@ -94,8 +94,8 @@ struct leveldb_comparator_t : public Comparator { const char* Name() const override { return (*name_)(state_); } // No-ops since the C binding does not support key shortening methods. - void FindShortestSeparator(std::string*, const Slice&) const override {} - void FindShortSuccessor(std::string* key) const override {} + void FindShortestSeparator([[maybe_unused]] std::string*, [[maybe_unused]] const Slice&) const override {} + void FindShortSuccessor([[maybe_unused]] std::string* key) const override {} void* state_; void (*destructor_)(void*); diff --git a/src/leveldb/db/db_impl.cc b/src/leveldb/db/db_impl.cc index 65e31724bc..d0fe654bf7 100644 --- a/src/leveldb/db/db_impl.cc +++ b/src/leveldb/db/db_impl.cc @@ -1058,7 +1058,7 @@ struct IterState { : mu(mutex), version(version), mem(mem), imm(imm) {} }; -static void CleanupIteratorState(void* arg1, void* arg2) { +static void CleanupIteratorState(void* arg1, [[maybe_unused]] void* arg2) { IterState* state = reinterpret_cast(arg1); state->mu->Lock(); state->mem->Unref(); diff --git a/src/leveldb/db/table_cache.cc b/src/leveldb/db/table_cache.cc index 73f05fd7b1..197bfcd407 100644 --- a/src/leveldb/db/table_cache.cc +++ b/src/leveldb/db/table_cache.cc @@ -16,7 +16,7 @@ struct TableAndFile { Table* table; }; -static void DeleteEntry(const Slice& key, void* value) { +static void DeleteEntry([[maybe_unused]] const Slice& key, void* value) { TableAndFile* tf = reinterpret_cast(value); delete tf->table; delete tf->file; diff --git a/src/leveldb/db/version_set.cc b/src/leveldb/db/version_set.cc index cd07346ea8..2aa27fa35e 100644 --- a/src/leveldb/db/version_set.cc +++ b/src/leveldb/db/version_set.cc @@ -39,7 +39,7 @@ static int64_t ExpandedCompactionByteSizeLimit(const Options* options) { return 25 * TargetFileSize(options); } -static double MaxBytesForLevel(const Options* options, int level) { +static double MaxBytesForLevel([[maybe_unused]] const Options* options, int level) { // Note: the result for level zero is not really used since we set // the level-0 compaction threshold based on number of files. @@ -52,7 +52,7 @@ static double MaxBytesForLevel(const Options* options, int level) { return result; } -static uint64_t MaxFileSizeForLevel(const Options* options, int level) { +static uint64_t MaxFileSizeForLevel(const Options* options, [[maybe_unused]] int level) { // We could vary per level to reduce number of files? return TargetFileSize(options); } @@ -863,7 +863,7 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { Status VersionSet::Recover(bool* save_manifest) { struct LogReporter : public log::Reader::Reporter { Status* status; - void Corruption(size_t bytes, const Status& s) override { + void Corruption([[maybe_unused]] size_t bytes, const Status& s) override { if (this->status->ok()) *this->status = s; } }; diff --git a/src/leveldb/helpers/memenv/memenv.cc b/src/leveldb/helpers/memenv/memenv.cc index 47e4481f7c..e6d7d97102 100644 --- a/src/leveldb/helpers/memenv/memenv.cc +++ b/src/leveldb/helpers/memenv/memenv.cc @@ -219,7 +219,7 @@ class WritableFileImpl : public WritableFile { class NoOpLogger : public Logger { public: - void Logv(const char* format, va_list ap) override {} + void Logv([[maybe_unused]] const char* format, [[maybe_unused]] va_list ap) override {} }; class InMemoryEnv : public EnvWrapper { @@ -332,9 +332,9 @@ class InMemoryEnv : public EnvWrapper { return Status::OK(); } - Status CreateDir(const std::string& dirname) override { return Status::OK(); } + Status CreateDir([[maybe_unused]] const std::string& dirname) override { return Status::OK(); } - Status DeleteDir(const std::string& dirname) override { return Status::OK(); } + Status DeleteDir([[maybe_unused]] const std::string& dirname) override { return Status::OK(); } Status GetFileSize(const std::string& fname, uint64_t* file_size) override { MutexLock lock(&mutex_); @@ -359,7 +359,7 @@ class InMemoryEnv : public EnvWrapper { return Status::OK(); } - Status LockFile(const std::string& fname, FileLock** lock) override { + Status LockFile([[maybe_unused]] const std::string& fname, FileLock** lock) override { *lock = new FileLock; return Status::OK(); } @@ -374,7 +374,7 @@ class InMemoryEnv : public EnvWrapper { return Status::OK(); } - Status NewLogger(const std::string& fname, Logger** result) override { + Status NewLogger([[maybe_unused]] const std::string& fname, Logger** result) override { *result = new NoOpLogger; return Status::OK(); } diff --git a/src/leveldb/table/iterator.cc b/src/leveldb/table/iterator.cc index dfef083d4d..394d0ce2c3 100644 --- a/src/leveldb/table/iterator.cc +++ b/src/leveldb/table/iterator.cc @@ -46,7 +46,7 @@ class EmptyIterator : public Iterator { ~EmptyIterator() override = default; bool Valid() const override { return false; } - void Seek(const Slice& target) override {} + void Seek([[maybe_unused]] const Slice& target) override {} void SeekToFirst() override {} void SeekToLast() override {} void Next() override { assert(false); } diff --git a/src/leveldb/table/table.cc b/src/leveldb/table/table.cc index b07bc88c7e..f2f7d222a9 100644 --- a/src/leveldb/table/table.cc +++ b/src/leveldb/table/table.cc @@ -135,11 +135,11 @@ void Table::ReadFilter(const Slice& filter_handle_value) { Table::~Table() { delete rep_; } -static void DeleteBlock(void* arg, void* ignored) { +static void DeleteBlock(void* arg, [[maybe_unused]] void* ignored) { delete reinterpret_cast(arg); } -static void DeleteCachedBlock(const Slice& key, void* value) { +static void DeleteCachedBlock([[maybe_unused]] const Slice& key, void* value) { Block* block = reinterpret_cast(value); delete block; } diff --git a/src/leveldb/util/env.cc b/src/leveldb/util/env.cc index d2f0aef326..4af8e5c218 100644 --- a/src/leveldb/util/env.cc +++ b/src/leveldb/util/env.cc @@ -8,7 +8,7 @@ namespace leveldb { Env::~Env() = default; -Status Env::NewAppendableFile(const std::string& fname, WritableFile** result) { +Status Env::NewAppendableFile(const std::string& fname, [[maybe_unused]] WritableFile** result) { return Status::NotSupported("NewAppendableFile", fname); } diff --git a/src/leveldb/util/env_posix.cc b/src/leveldb/util/env_posix.cc index 9f5863a0f3..b0f6080403 100644 --- a/src/leveldb/util/env_posix.cc +++ b/src/leveldb/util/env_posix.cc @@ -233,7 +233,7 @@ class PosixMmapReadableFile final : public RandomAccessFile { } Status Read(uint64_t offset, size_t n, Slice* result, - char* scratch) const override { + [[maybe_unused]] char* scratch) const override { if (offset + n > length_) { *result = Slice(); return PosixError(filename_, EINVAL); diff --git a/src/leveldb/util/hash.cc b/src/leveldb/util/hash.cc index dd47c110ee..d7f28e8b68 100644 --- a/src/leveldb/util/hash.cc +++ b/src/leveldb/util/hash.cc @@ -8,15 +8,6 @@ #include "util/coding.h" -// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through -// between switch labels. The real definition should be provided externally. -// This one is a fallback version for unsupported compilers. -#ifndef FALLTHROUGH_INTENDED -#define FALLTHROUGH_INTENDED \ - do { \ - } while (0) -#endif - namespace leveldb { uint32_t Hash(const char* data, size_t n, uint32_t seed) { @@ -39,10 +30,10 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) { switch (limit - data) { case 3: h += static_cast(data[2]) << 16; - FALLTHROUGH_INTENDED; + [[fallthrough]]; case 2: h += static_cast(data[1]) << 8; - FALLTHROUGH_INTENDED; + [[fallthrough]]; case 1: h += static_cast(data[0]); h *= m; diff --git a/src/mapport.cpp b/src/mapport.cpp index f269d6635d..568cac5f7c 100644 --- a/src/mapport.cpp +++ b/src/mapport.cpp @@ -321,7 +321,7 @@ void StopMapPort() } #else // #if defined(USE_NATPMP) || defined(USE_UPNP) -void StartMapPort(bool use_upnp, bool use_natpmp) +void StartMapPort([[maybe_unused]] bool use_upnp, [[maybe_unused]] bool use_natpmp) { // Intentionally left blank. } diff --git a/src/memusage.h b/src/memusage.h index 1c561e8c93..d10ddc3c5a 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -26,18 +26,18 @@ namespace memusage static size_t MallocUsage(size_t alloc); /** Dynamic memory usage for built-in types is zero. */ -static inline size_t DynamicUsage(const int8_t& v) { return 0; } -static inline size_t DynamicUsage(const uint8_t& v) { return 0; } -static inline size_t DynamicUsage(const int16_t& v) { return 0; } -static inline size_t DynamicUsage(const uint16_t& v) { return 0; } -static inline size_t DynamicUsage(const int32_t& v) { return 0; } -static inline size_t DynamicUsage(const uint32_t& v) { return 0; } -static inline size_t DynamicUsage(const int64_t& v) { return 0; } -static inline size_t DynamicUsage(const uint64_t& v) { return 0; } -static inline size_t DynamicUsage(const float& v) { return 0; } -static inline size_t DynamicUsage(const double& v) { return 0; } -template static inline size_t DynamicUsage(X * const &v) { return 0; } -template static inline size_t DynamicUsage(const X * const &v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const int8_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const uint8_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const int16_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const uint16_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const int32_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const uint32_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const int64_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const uint64_t& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const float& v) { return 0; } +static inline size_t DynamicUsage([[maybe_unused]] const double& v) { return 0; } +template static inline size_t DynamicUsage([[maybe_unused]] X * const &v) { return 0; } +template static inline size_t DynamicUsage([[maybe_unused]] const X * const &v) { return 0; } /** Compute the memory used for dynamically allocated but owned data structures. * For generic data types, this is *not* recursive. DynamicUsage(vector >) @@ -102,7 +102,7 @@ static inline size_t DynamicUsage(const std::set& s) } template -static inline size_t IncrementalDynamicUsage(const std::set& s) +static inline size_t IncrementalDynamicUsage([[maybe_unused]] const std::set& s) { return MallocUsage(sizeof(stl_tree_node)); } diff --git a/src/net.cpp b/src/net.cpp index 5a0c8782a6..2da9c2c324 100755 --- a/src/net.cpp +++ b/src/net.cpp @@ -885,7 +885,7 @@ static bool CompareNodeBlockRelayOnlyTime(const NodeEvictionCandidate &a, const template static void EraseLastKElements( std::vector& elements, Comparator comparator, size_t k, - std::function predicate = [](const NodeEvictionCandidate& n) { return true; }) + std::function predicate = []([[maybe_unused]] const NodeEvictionCandidate& n) { return true; }) { std::sort(elements.begin(), elements.end(), comparator); size_t eraseSize = std::min(k, elements.size()); diff --git a/src/net.h b/src/net.h index cb21961a40..4ed935f623 100644 --- a/src/net.h +++ b/src/net.h @@ -387,7 +387,7 @@ class TransportSerializer { virtual ~TransportSerializer() {} }; -class V1TransportSerializer : public TransportSerializer { +class V1TransportSerializer final : public TransportSerializer { public: void prepareForTransport(CSerializedNetMsg& msg, std::vector& header) override; }; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index fefd310f12..f20d471e01 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1304,7 +1304,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn * block, remember the recently confirmed transactions, and delete tracked * announcements for them. Also save the time of the last tip update. */ -void PeerManagerImpl::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex) +void PeerManagerImpl::BlockConnected(const std::shared_ptr& pblock, [[maybe_unused]] const CBlockIndex* pindex) { m_orphanage.EraseForBlock(*pblock); m_last_tip_update = GetTime(); @@ -1327,7 +1327,7 @@ void PeerManagerImpl::BlockConnected(const std::shared_ptr& pblock } } -void PeerManagerImpl::BlockDisconnected(const std::shared_ptr &block, const CBlockIndex* pindex) +void PeerManagerImpl::BlockDisconnected([[maybe_unused]] const std::shared_ptr &block, [[maybe_unused]] const CBlockIndex* pindex) { // To avoid relay problems with transactions that were previously // confirmed, clear our filter of recently confirmed transactions whenever @@ -4324,7 +4324,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) if (pto->vAddrToSend.capacity() > 40) pto->vAddrToSend.shrink_to_fit(); } - + // Start block sync if (pindexBestHeader == nullptr) pindexBestHeader = m_chainman.ActiveChain().Tip(); diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp index f2878ff8b9..26afc2aee9 100644 --- a/src/node/coinstats.cpp +++ b/src/node/coinstats.cpp @@ -65,7 +65,7 @@ static void ApplyHash(CHashWriterKeccak& ss, const uint256& hash, const std::map } } -static void ApplyHash(std::nullptr_t, const uint256& hash, const std::map& outputs) {} +static void ApplyHash([[maybe_unused]] std::nullptr_t, [[maybe_unused]] const uint256& hash, [[maybe_unused]] const std::map& outputs) {} static void ApplyHash(MuHash3072& muhash, const uint256& hash, const std::map& outputs) { @@ -76,7 +76,7 @@ static void ApplyHash(MuHash3072& muhash, const uint256& hash, const std::map& outputs) +static void ApplyStats(CCoinsStats& stats, [[maybe_unused]] const uint256& hash, const std::map& outputs) { assert(!outputs.empty()); stats.nTransactions++; @@ -167,10 +167,10 @@ static void PrepareHash(CHashWriterKeccak& ss, const CCoinsStats& stats) ss << stats.hashBlock; } // MuHash does not need the prepare step -static void PrepareHash(MuHash3072& muhash, CCoinsStats& stats) {} -static void PrepareHash(std::nullptr_t, CCoinsStats& stats) {} +static void PrepareHash([[maybe_unused]] MuHash3072& muhash, [[maybe_unused]] CCoinsStats& stats) {} +static void PrepareHash([[maybe_unused]] std::nullptr_t, [[maybe_unused]] CCoinsStats& stats) {} -static void FinalizeHash(CHashWriterKeccak& ss, CCoinsStats& stats) +static void FinalizeHash([[maybe_unused]] CHashWriterKeccak& ss, [[maybe_unused]] CCoinsStats& stats) { stats.hashSerialized = ss.GetHash(); } @@ -180,4 +180,4 @@ static void FinalizeHash(MuHash3072& muhash, CCoinsStats& stats) muhash.Finalize(out); stats.hashSerialized = out; } -static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {} +static void FinalizeHash([[maybe_unused]] std::nullptr_t, [[maybe_unused]] CCoinsStats& stats) {} diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index b865691a1f..79e7efb84a 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -360,7 +360,7 @@ class NotificationsProxy : public CValidationInterface { m_notifications->blockDisconnected(*block, index->nHeight); } - void UpdatedBlockTip(const CBlockIndex* index, const CBlockIndex* fork_index, bool is_ibd) override + void UpdatedBlockTip([[maybe_unused]] const CBlockIndex* index, [[maybe_unused]] const CBlockIndex* fork_index, [[maybe_unused]] bool is_ibd) override { m_notifications->updatedBlockTip(); } diff --git a/src/noui.cpp b/src/noui.cpp index 6fe5c5638c..0b248dbaea 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -63,13 +63,13 @@ void noui_connect() noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage); } -bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, const std::string& caption, unsigned int style) +bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, const std::string& caption, [[maybe_unused]] unsigned int style) { LogPrintf("%s: %s\n", caption, message.original); return false; } -bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style) +bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, [[maybe_unused]] unsigned int style) { LogPrintf("%s: %s\n", caption, message); return false; diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index f1a7462b9d..f3a0751693 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -364,7 +364,7 @@ void TxConfirmStats::Write(CAutoFile& fileout) const fileout << failAvg; } -void TxConfirmStats::Read(CAutoFile& filein, int nFileVersion, size_t numBuckets) +void TxConfirmStats::Read(CAutoFile& filein, [[maybe_unused]] int nFileVersion, size_t numBuckets) { // Read data file and do some very basic sanity checking // buckets and bucketMap are not updated yet, so don't access them diff --git a/src/policy/settings.h b/src/policy/settings.h index ead3c1c0df..4d8deae266 100644 --- a/src/policy/settings.h +++ b/src/policy/settings.h @@ -10,8 +10,6 @@ #include -#include - class CFeeRate; class CTransaction; diff --git a/src/pow.cpp b/src/pow.cpp index 9c6ceb9bf7..d0eb1ea23c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -4,9 +4,6 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include - -#include - #include #include #include diff --git a/src/random.h b/src/random.h index c7045f7f05..5e6596fa9d 100644 --- a/src/random.h +++ b/src/random.h @@ -126,7 +126,7 @@ class FastRandomContext int bytebuf_size; uint64_t bitbuf; - int bitbuf_size; + uint64_t bitbuf_size; void RandomSeed(); @@ -169,7 +169,7 @@ class FastRandomContext } /** Generate a random (bits)-bit integer. */ - uint64_t randbits(int bits) noexcept + uint64_t randbits(uint64_t bits) noexcept { if (bits == 0) { return 0; @@ -191,7 +191,7 @@ class FastRandomContext { assert(range); --range; - int bits = CountBits(range); + uint64_t bits = CountBits(range); while (true) { uint64_t ret = randbits(bits); if (ret <= range) return ret; @@ -202,7 +202,7 @@ class FastRandomContext std::vector randbytes(size_t len); /** Generate a random 32-bit integer. */ - uint32_t rand32() noexcept { return randbits(32); } + uint32_t rand32() noexcept { return static_cast(randbits(32)); } /** generate a random uint256. */ uint256 rand256() noexcept; diff --git a/src/randomenv.cpp b/src/randomenv.cpp index a7014b5502..05839b60d2 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -62,7 +62,7 @@ extern char** environ; namespace { -void RandAddSeedPerfmon(CSHA512& hasher) +void RandAddSeedPerfmon([[maybe_unused]] CSHA512& hasher) { #ifdef WIN32 // Seed with the entire set of perfmon data diff --git a/src/rest.cpp b/src/rest.cpp index d41f374c49..5f985313d3 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -495,13 +495,15 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std:: } switch (rf) { - case RetFormat::HEX: { + case RetFormat::HEX: + { // convert hex to bin, continue then with bin part std::vector strRequestV = ParseHex(strRequestMutable); strRequestMutable.assign(strRequestV.begin(), strRequestV.end()); + [[fallthrough]]; } - case RetFormat::BINARY: { + case RetFormat::BINARY: try { //deserialize only if user sent a request if (strRequestMutable.size() > 0) @@ -519,17 +521,15 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std:: return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); } break; - } - case RetFormat::JSON: { + case RetFormat::JSON: if (!fInputParsed) return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); break; - } - default: { + + default: return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")"); } - } // limit max outpoints if (vOutPoints.size() > MAX_GETUTXOS_OUTPOINTS) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index af3c815610..eab25db75e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -237,7 +237,7 @@ static RPCHelpMan getblockcount() HelpExampleCli("getblockcount", "") + HelpExampleRpc("getblockcount", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -257,7 +257,7 @@ static RPCHelpMan getbestblockhash() HelpExampleCli("getbestblockhash", "") + HelpExampleRpc("getbestblockhash", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -294,7 +294,7 @@ static RPCHelpMan waitfornewblock() HelpExampleCli("waitfornewblock", "1000") + HelpExampleRpc("waitfornewblock", "1000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { int timeout = 0; if (!request.params[0].isNull()) @@ -337,7 +337,7 @@ static RPCHelpMan waitforblock() HelpExampleCli("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\" 1000") + HelpExampleRpc("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { int timeout = 0; @@ -384,7 +384,7 @@ static RPCHelpMan waitforblockheight() HelpExampleCli("waitforblockheight", "100 1000") + HelpExampleRpc("waitforblockheight", "100, 1000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { int timeout = 0; @@ -420,7 +420,7 @@ static RPCHelpMan syncwithvalidationinterfacequeue() HelpExampleCli("syncwithvalidationinterfacequeue","") + HelpExampleRpc("syncwithvalidationinterfacequeue","") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { SyncWithValidationInterfaceQueue(); return NullUniValue; @@ -439,7 +439,7 @@ static RPCHelpMan getdifficulty() HelpExampleCli("getdifficulty", "") + HelpExampleRpc("getdifficulty", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -614,7 +614,7 @@ static RPCHelpMan getrawmempool() HelpExampleCli("getrawmempool", "true") + HelpExampleRpc("getrawmempool", "true") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { bool fVerbose = false; if (!request.params[0].isNull()) @@ -652,7 +652,7 @@ static RPCHelpMan getmempoolancestors() HelpExampleCli("getmempoolancestors", "\"mytxid\"") + HelpExampleRpc("getmempoolancestors", "\"mytxid\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { bool fVerbose = false; if (!request.params[1].isNull()) @@ -716,7 +716,7 @@ static RPCHelpMan getmempooldescendants() HelpExampleCli("getmempooldescendants", "\"mytxid\"") + HelpExampleRpc("getmempooldescendants", "\"mytxid\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { bool fVerbose = false; if (!request.params[1].isNull()) @@ -772,7 +772,7 @@ static RPCHelpMan getmempoolentry() HelpExampleCli("getmempoolentry", "\"mytxid\"") + HelpExampleRpc("getmempoolentry", "\"mytxid\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 hash = ParseHashV(request.params[0], "parameter 1"); @@ -805,7 +805,7 @@ static RPCHelpMan getblockhash() HelpExampleCli("getblockhash", "1000") + HelpExampleRpc("getblockhash", "1000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -857,7 +857,7 @@ static RPCHelpMan getblockheader() HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 hash(ParseHashV(request.params[0], "hash")); @@ -977,7 +977,7 @@ static RPCHelpMan getblock() HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 hash(ParseHashV(request.params[0], "blockhash")); @@ -1032,7 +1032,7 @@ static RPCHelpMan pruneblockchain() HelpExampleCli("pruneblockchain", "1000") + HelpExampleRpc("pruneblockchain", "1000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { if (!fPruneMode) throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode."); @@ -1140,7 +1140,7 @@ static RPCHelpMan gettxoutsetinfo() HelpExampleRpc("gettxoutsetinfo", R"("none", 1000)") + HelpExampleRpc("gettxoutsetinfo", R"("none", "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09")") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { UniValue ret(UniValue::VOBJ); @@ -1264,7 +1264,7 @@ static RPCHelpMan gettxout() "\nAs a JSON-RPC call\n" + HelpExampleRpc("gettxout", "\"txid\", 1") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); ChainstateManager& chainman = EnsureChainman(node); @@ -1329,7 +1329,7 @@ static RPCHelpMan verifychain() HelpExampleCli("verifychain", "") + HelpExampleRpc("verifychain", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const int check_level(request.params[0].isNull() ? DEFAULT_CHECKLEVEL : request.params[0].get_int()); const int check_depth{request.params[1].isNull() ? DEFAULT_CHECKBLOCKS : request.params[1].get_int()}; @@ -1463,7 +1463,7 @@ RPCHelpMan getblockchaininfo() HelpExampleCli("getblockchaininfo", "") + HelpExampleRpc("getblockchaininfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -1558,7 +1558,7 @@ static RPCHelpMan getchaintips() HelpExampleCli("getchaintips", "") + HelpExampleRpc("getchaintips", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -1671,7 +1671,7 @@ static RPCHelpMan getmempoolinfo() HelpExampleCli("getmempoolinfo", "") + HelpExampleRpc("getmempoolinfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { return MempoolInfoToJSON(EnsureAnyMemPool(request.context)); }, @@ -1692,7 +1692,7 @@ static RPCHelpMan preciousblock() HelpExampleCli("preciousblock", "\"blockhash\"") + HelpExampleRpc("preciousblock", "\"blockhash\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 hash(ParseHashV(request.params[0], "blockhash")); CBlockIndex* pblockindex; @@ -1730,7 +1730,7 @@ static RPCHelpMan invalidateblock() HelpExampleCli("invalidateblock", "\"blockhash\"") + HelpExampleRpc("invalidateblock", "\"blockhash\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 hash(ParseHashV(request.params[0], "blockhash")); BlockValidationState state; @@ -1772,7 +1772,7 @@ static RPCHelpMan reconsiderblock() HelpExampleCli("reconsiderblock", "\"blockhash\"") + HelpExampleRpc("reconsiderblock", "\"blockhash\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); uint256 hash(ParseHashV(request.params[0], "blockhash")); @@ -1823,7 +1823,7 @@ static RPCHelpMan getchaintxstats() HelpExampleCli("getchaintxstats", "") + HelpExampleRpc("getchaintxstats", "2016") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); const CBlockIndex* pindex; @@ -1935,7 +1935,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, } template -static inline bool SetHasKeys(const std::set& set) {return false;} +static inline bool SetHasKeys([[maybe_unused]] const std::set& set) {return false;} template static inline bool SetHasKeys(const std::set& set, const Tk& key, const Args&... args) { @@ -2005,7 +2005,7 @@ static RPCHelpMan getblockstats() HelpExampleRpc("getblockstats", R"("00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", ["minfeerate","avgfeerate"])") + HelpExampleRpc("getblockstats", R"(1000, ["minfeerate","avgfeerate"])") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -2194,7 +2194,7 @@ static RPCHelpMan savemempool() HelpExampleCli("savemempool", "") + HelpExampleRpc("savemempool", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const CTxMemPool& mempool = EnsureAnyMemPool(request.context); @@ -2330,7 +2330,7 @@ static RPCHelpMan scantxoutset() }}, }, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}); @@ -2448,7 +2448,7 @@ static RPCHelpMan getblockfilter() HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"") + HelpExampleRpc("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\", \"basic\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint256 block_hash = ParseHashV(request.params[0], "blockhash"); std::string filtertype_name = "basic"; @@ -2538,7 +2538,7 @@ static RPCHelpMan dumptxoutset() RPCExamples{ HelpExampleCli("dumptxoutset", "utxo.dat") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const fs::path path = fsbridge::AbsPathJoin(GetDataDir(), request.params[0].get_str()); // Write to a temporary path and then move into `path` on completion diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 815005cdfe..0e41aac6c0 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -99,7 +99,7 @@ static RPCHelpMan getnetworkhashps() HelpExampleCli("getnetworkhashps", "") + HelpExampleRpc("getnetworkhashps", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { ChainstateManager& chainman = EnsureAnyChainman(request.context); LOCK(cs_main); @@ -225,7 +225,7 @@ static RPCHelpMan generatetodescriptor() }, RPCExamples{ "\nGenerate 11 blocks to mydesc\n" + HelpExampleCli("generatetodescriptor", "11 \"mydesc\"")}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const int num_blocks{request.params[0].get_int()}; const uint64_t max_tries{request.params[2].isNull() ? DEFAULT_MAX_TRIES : request.params[2].get_int()}; @@ -247,7 +247,7 @@ static RPCHelpMan generatetodescriptor() static RPCHelpMan generate() { - return RPCHelpMan{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { + return RPCHelpMan{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { throw JSONRPCError(RPC_METHOD_NOT_FOUND, self.ToString()); }}; } @@ -272,7 +272,7 @@ static RPCHelpMan generatetoaddress() + "If you are using the " PACKAGE_NAME " wallet, you can get a new address to send the newly generated BGL to with:\n" + HelpExampleCli("getnewaddress", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const int num_blocks{request.params[0].get_int()}; const uint64_t max_tries{request.params[2].isNull() ? DEFAULT_MAX_TRIES : request.params[2].get_int()}; @@ -317,7 +317,7 @@ static RPCHelpMan generateblock() "\nGenerate a block to myaddress, with txs rawtx and mempool_txid\n" + HelpExampleCli("generateblock", R"("myaddress" '["rawtx", "mempool_txid"]')") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const auto address_or_descriptor = request.params[0].get_str(); CScript coinbase_script; @@ -426,7 +426,7 @@ static RPCHelpMan getmininginfo() HelpExampleCli("getmininginfo", "") + HelpExampleRpc("getmininginfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CTxMemPool& mempool = EnsureMemPool(node); @@ -469,7 +469,7 @@ static RPCHelpMan prioritisetransaction() HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000") + HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { LOCK(cs_main); @@ -599,7 +599,7 @@ static RPCHelpMan getblocktemplate() HelpExampleCli("getblocktemplate", "'{\"rules\": [\"segwit\"]}'") + HelpExampleRpc("getblocktemplate", "{\"rules\": [\"segwit\"]}") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); ChainstateManager& chainman = EnsureChainman(node); @@ -853,6 +853,7 @@ static RPCHelpMan getblocktemplate() // Ensure bit is set in block version pblock->nVersion |= VersionBitsMask(consensusParams, pos); // FALL THROUGH to get vbavailable set... + [[fallthrough]]; case ThresholdState::STARTED: { const struct VBDeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos]; @@ -969,7 +970,7 @@ static RPCHelpMan submitblock() HelpExampleCli("submitblock", "\"mydata\"") + HelpExampleRpc("submitblock", "\"mydata\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr blockptr = std::make_shared(); CBlock& block = *blockptr; @@ -1034,7 +1035,7 @@ static RPCHelpMan submitheader() HelpExampleCli("submitheader", "\"aabbcc\"") + HelpExampleRpc("submitheader", "\"aabbcc\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { CBlockHeader h; if (!DecodeHexBlockHeader(h, request.params[0].get_str())) { @@ -1093,7 +1094,7 @@ static RPCHelpMan estimatesmartfee() RPCExamples{ HelpExampleCli("estimatesmartfee", "6") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR}); RPCTypeCheckArgument(request.params[0], UniValue::VNUM); @@ -1181,7 +1182,7 @@ static RPCHelpMan estimaterawfee() RPCExamples{ HelpExampleCli("estimaterawfee", "6 0.9") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true); RPCTypeCheckArgument(request.params[0], UniValue::VNUM); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 333edf2751..abd83ac61d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -55,7 +55,7 @@ static RPCHelpMan validateaddress() HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") + HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::string error_msg; CTxDestination dest = DecodeDestination(request.params[0].get_str(), error_msg); @@ -109,7 +109,7 @@ static RPCHelpMan createmultisig() "\nAs a JSON-RPC call\n" + HelpExampleRpc("createmultisig", "2, \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { int required = request.params[0].get_int(); @@ -171,7 +171,7 @@ static RPCHelpMan getdescriptorinfo() "Analyse a descriptor\n" + HelpExampleCli("getdescriptorinfo", "\"wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR}); @@ -219,7 +219,7 @@ static RPCHelpMan deriveaddresses() "First three native segwit receive addresses\n" + HelpExampleCli("deriveaddresses", "\"wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#cjjspncu\" \"[0,2]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType()}); // Range argument is checked later const std::string desc_str = request.params[0].get_str(); @@ -297,7 +297,7 @@ static RPCHelpMan verifymessage() "\nAs a JSON-RPC call\n" + HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { LOCK(cs_main); @@ -343,7 +343,7 @@ static RPCHelpMan signmessagewithprivkey() "\nAs a JSON-RPC call\n" + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::string strPrivkey = request.params[0].get_str(); std::string strMessage = request.params[1].get_str(); @@ -374,7 +374,7 @@ static RPCHelpMan setmocktime() }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { if (!Params().IsMockableChain()) { throw std::runtime_error("setmocktime is for regression testing (-regtest mode) only"); @@ -414,7 +414,7 @@ static RPCHelpMan mockscheduler() }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { if (!Params().IsMockableChain()) { throw std::runtime_error("mockscheduler is for regression testing (-regtest mode) only"); @@ -505,7 +505,7 @@ static RPCHelpMan getmemoryinfo() HelpExampleCli("getmemoryinfo", "") + HelpExampleRpc("getmemoryinfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str(); if (mode == "stats") { @@ -576,7 +576,7 @@ static RPCHelpMan logging() HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { uint32_t original_log_categories = LogInstance().GetCategoryMask(); if (request.params[0].isArray()) { @@ -633,7 +633,7 @@ static RPCHelpMan echo(const std::string& name) }, RPCResult{RPCResult::Type::ANY, "", "Returns whatever was passed in"}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { if (request.params[9].isStr()) { CHECK_NONFATAL(request.params[9].get_str() != "trigger_internal_bug"); @@ -657,7 +657,7 @@ static RPCHelpMan echoipc() RPCResult{RPCResult::Type::STR, "echo", "The echoed string."}, RPCExamples{HelpExampleCli("echo", "\"Hello world\"") + HelpExampleRpc("echo", "\"Hello world\"")}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::unique_ptr echo; if (interfaces::Ipc* ipc = Assert(EnsureAnyNodeContext(request.context).init)->ipc()) { // Spawn a new bitcoin-node process and call makeEcho to get a @@ -720,7 +720,7 @@ static RPCHelpMan getindexinfo() + HelpExampleCli("getindexinfo", "txindex") + HelpExampleRpc("getindexinfo", "txindex") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { UniValue result(UniValue::VOBJ); const std::string index_name = request.params[0].isNull() ? "" : request.params[0].get_str(); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index cdecde0134..d94cdcdb45 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -67,7 +67,7 @@ static RPCHelpMan getconnectioncount() HelpExampleCli("getconnectioncount", "") + HelpExampleRpc("getconnectioncount", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CConnman& connman = EnsureConnman(node); @@ -89,7 +89,7 @@ static RPCHelpMan ping() HelpExampleCli("ping", "") + HelpExampleRpc("ping", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); PeerManager& peerman = EnsurePeerman(node); @@ -176,7 +176,7 @@ static RPCHelpMan getpeerinfo() HelpExampleCli("getpeerinfo", "") + HelpExampleRpc("getpeerinfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CConnman& connman = EnsureConnman(node); @@ -397,7 +397,7 @@ static RPCHelpMan disconnectnode() + HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") + HelpExampleRpc("disconnectnode", "\"\", 1") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); CConnman& connman = EnsureConnman(node); @@ -456,7 +456,7 @@ static RPCHelpMan getaddednodeinfo() HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"") + HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CConnman& connman = EnsureConnman(node); @@ -526,7 +526,7 @@ static RPCHelpMan getnettotals() HelpExampleCli("getnettotals", "") + HelpExampleRpc("getnettotals", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CConnman& connman = EnsureConnman(node); @@ -619,7 +619,7 @@ static RPCHelpMan getnetworkinfo() HelpExampleCli("getnetworkinfo", "") + HelpExampleRpc("getnetworkinfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { LOCK(cs_main); UniValue obj(UniValue::VOBJ); @@ -768,7 +768,7 @@ static RPCHelpMan listbanned() HelpExampleCli("listbanned", "") + HelpExampleRpc("listbanned", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); if(!node.banman) { @@ -808,7 +808,7 @@ static RPCHelpMan clearbanned() HelpExampleCli("clearbanned", "") + HelpExampleRpc("clearbanned", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); if (!node.banman) { @@ -831,7 +831,7 @@ static RPCHelpMan setnetworkactive() }, RPCResult{RPCResult::Type::BOOL, "", "The value that was passed in"}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); CConnman& connman = EnsureConnman(node); @@ -867,7 +867,7 @@ static RPCHelpMan getnodeaddresses() HelpExampleCli("getnodeaddresses", "8") + HelpExampleRpc("getnodeaddresses", "8") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); const CConnman& connman = EnsureConnman(node); @@ -911,7 +911,7 @@ static RPCHelpMan addpeeraddress() HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 8333") + HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 8333") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { NodeContext& node = EnsureAnyNodeContext(request.context); if (!node.addrman) { diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index d4c935d4a7..096e045cdc 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -156,7 +156,7 @@ static RPCHelpMan getrawtransaction() + HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"") + HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { const NodeContext& node = EnsureAnyNodeContext(request.context); ChainstateManager& chainman = EnsureChainman(node); @@ -243,7 +243,7 @@ static RPCHelpMan gettxoutproof() RPCResult::Type::STR, "data", "A string that is a serialized, hex-encoded data for the proof." }, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::set setTxids; UniValue txids = request.params[0].get_array(); @@ -339,7 +339,7 @@ static RPCHelpMan verifytxoutproof() } }, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); CMerkleBlock merkleBlock; @@ -422,7 +422,7 @@ static RPCHelpMan createrawtransaction() + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"") + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, { UniValue::VARR, @@ -511,7 +511,7 @@ static RPCHelpMan decoderawtransaction() HelpExampleCli("decoderawtransaction", "\"hexstring\"") + HelpExampleRpc("decoderawtransaction", "\"hexstring\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); @@ -580,7 +580,7 @@ static RPCHelpMan decodescript() HelpExampleCli("decodescript", "\"hexstring\"") + HelpExampleRpc("decodescript", "\"hexstring\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR}); @@ -656,7 +656,7 @@ static RPCHelpMan combinerawtransaction() RPCExamples{ HelpExampleCli("combinerawtransaction", R"('["myhex1", "myhex2", "myhex3"]')") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { UniValue txs = request.params[0].get_array(); @@ -783,7 +783,7 @@ static RPCHelpMan signrawtransactionwithkey() HelpExampleCli("signrawtransactionwithkey", "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") + HelpExampleRpc("signrawtransactionwithkey", "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true); @@ -849,7 +849,7 @@ static RPCHelpMan sendrawtransaction() "\nAs a JSON-RPC call\n" + HelpExampleRpc("sendrawtransaction", "\"signedhex\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, { UniValue::VSTR, @@ -925,7 +925,7 @@ static RPCHelpMan testmempoolaccept() "\nAs a JSON-RPC call\n" + HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, { UniValue::VARR, @@ -1106,7 +1106,7 @@ static RPCHelpMan decodepsbt() RPCExamples{ HelpExampleCli("decodepsbt", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR}); @@ -1321,7 +1321,7 @@ static RPCHelpMan combinepsbt() RPCExamples{ HelpExampleCli("combinepsbt", R"('["mybase64_1", "mybase64_2", "mybase64_3"]')") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VARR}, true); @@ -1376,7 +1376,7 @@ static RPCHelpMan finalizepsbt() RPCExamples{ HelpExampleCli("finalizepsbt", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}, true); @@ -1456,7 +1456,7 @@ static RPCHelpMan createpsbt() RPCExamples{ HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, { @@ -1518,7 +1518,7 @@ static RPCHelpMan converttopsbt() "\nConvert the transaction to a PSBT\n" + HelpExampleCli("converttopsbt", "\"rawtransaction\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}, true); @@ -1581,7 +1581,7 @@ static RPCHelpMan utxoupdatepsbt() RPCExamples { HelpExampleCli("utxoupdatepsbt", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}, true); @@ -1671,7 +1671,7 @@ static RPCHelpMan joinpsbts() RPCExamples { HelpExampleCli("joinpsbts", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VARR}, true); @@ -1792,7 +1792,7 @@ static RPCHelpMan analyzepsbt() RPCExamples { HelpExampleCli("analyzepsbt", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, {UniValue::VSTR}); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index cf80b08b96..19cc30f65b 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -142,7 +142,7 @@ static RPCHelpMan help() RPCResult{RPCResult::Type::ANY, "", ""}, }, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue { std::string strCommand; if (jsonRequest.params.size() > 0) { @@ -171,7 +171,7 @@ static RPCHelpMan stop() }, RPCResult{RPCResult::Type::STR, "", "A string with the content '" + RESULT + "'"}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& jsonRequest) -> UniValue { // Event loop will exit after current HTTP requests have been handled, so // this reply will get back to the client. @@ -196,7 +196,7 @@ static RPCHelpMan uptime() HelpExampleCli("uptime", "") + HelpExampleRpc("uptime", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { return GetTime() - GetStartupTime(); } @@ -225,7 +225,7 @@ static RPCHelpMan getrpcinfo() RPCExamples{ HelpExampleCli("getrpcinfo", "") + HelpExampleRpc("getrpcinfo", "")}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { LOCK(g_rpc_server_info.mutex); UniValue active_commands(UniValue::VARR); diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 181d6a28bf..e0c30721e8 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -260,12 +260,12 @@ class DescribeAddressVisitor public: explicit DescribeAddressVisitor() {} - UniValue operator()(const CNoDestination& dest) const + UniValue operator()([[maybe_unused]] const CNoDestination& dest) const { return UniValue(UniValue::VOBJ); } - UniValue operator()(const PKHash& keyID) const + UniValue operator()([[maybe_unused]] const PKHash& keyID) const { UniValue obj(UniValue::VOBJ); obj.pushKV("isscript", false); @@ -273,7 +273,7 @@ class DescribeAddressVisitor return obj; } - UniValue operator()(const ScriptHash& scriptID) const + UniValue operator()([[maybe_unused]] const ScriptHash& scriptID) const { UniValue obj(UniValue::VOBJ); obj.pushKV("isscript", true); diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index a2f984b58a..8fc56bd702 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -244,7 +244,7 @@ class ConstPubkeyProvider final : public PubkeyProvider public: ConstPubkeyProvider(uint32_t exp_index, const CPubKey& pubkey) : PubkeyProvider(exp_index), m_pubkey(pubkey) {} - bool GetPubKey(int pos, const SigningProvider& arg, CPubKey& key, KeyOriginInfo& info, const DescriptorCache* read_cache = nullptr, DescriptorCache* write_cache = nullptr) override + bool GetPubKey([[maybe_unused]] int pos, [[maybe_unused]] const SigningProvider& arg, CPubKey& key, KeyOriginInfo& info, [[maybe_unused]] const DescriptorCache* read_cache = nullptr, [[maybe_unused]] DescriptorCache* write_cache = nullptr) override { key = m_pubkey; info.path.clear(); @@ -268,7 +268,7 @@ class ConstPubkeyProvider final : public PubkeyProvider ret = ToString(); return true; } - bool GetPrivKey(int pos, const SigningProvider& arg, CKey& key) const override + bool GetPrivKey([[maybe_unused]] int pos, const SigningProvider& arg, CKey& key) const override { return arg.GetKey(m_pubkey.GetID(), key); } diff --git a/src/script/interpreter.h b/src/script/interpreter.h index ce138ccac5..8ee1a2ea9b 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -224,22 +224,22 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn class BaseSignatureChecker { public: - virtual bool CheckECDSASignature(const std::vector& scriptSig, const std::vector& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const + virtual bool CheckECDSASignature([[maybe_unused]] const std::vector& scriptSig, [[maybe_unused]] const std::vector& vchPubKey, [[maybe_unused]] const CScript& scriptCode, [[maybe_unused]] SigVersion sigversion) const { return false; } - virtual bool CheckSchnorrSignature(Span sig, Span pubkey, SigVersion sigversion, const ScriptExecutionData& execdata, ScriptError* serror = nullptr) const + virtual bool CheckSchnorrSignature([[maybe_unused]] Span sig, [[maybe_unused]] Span pubkey, [[maybe_unused]] SigVersion sigversion, [[maybe_unused]] const ScriptExecutionData& execdata, [[maybe_unused]] ScriptError* serror = nullptr) const { return false; } - virtual bool CheckLockTime(const CScriptNum& nLockTime) const + virtual bool CheckLockTime([[maybe_unused]] const CScriptNum& nLockTime) const { return false; } - virtual bool CheckSequence(const CScriptNum& nSequence) const + virtual bool CheckSequence([[maybe_unused]] const CScriptNum& nSequence) const { return false; } diff --git a/src/script/script.h b/src/script/script.h index ef45c657c0..45c7ae2baf 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -328,7 +328,7 @@ class CScriptNum return std::numeric_limits::max(); else if (m_value < std::numeric_limits::min()) return std::numeric_limits::min(); - return m_value; + return static_cast(m_value); } std::vector getvch() const diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 7a91354a48..1d6dfd5615 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -404,7 +404,7 @@ class DummySignatureChecker final : public BaseSignatureChecker { public: DummySignatureChecker() {} - bool CheckECDSASignature(const std::vector& scriptSig, const std::vector& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override { return true; } + bool CheckECDSASignature([[maybe_unused]] const std::vector& scriptSig, [[maybe_unused]] const std::vector& vchPubKey, [[maybe_unused]] const CScript& scriptCode, [[maybe_unused]] SigVersion sigversion) const override { return true; } }; const DummySignatureChecker DUMMY_CHECKER; @@ -415,7 +415,7 @@ class DummySignatureCreator final : public BaseSignatureCreator { public: DummySignatureCreator(char r_len, char s_len) : m_r_len(r_len), m_s_len(s_len) {} const BaseSignatureChecker& Checker() const override { return DUMMY_CHECKER; } - bool CreateSig(const SigningProvider& provider, std::vector& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override + bool CreateSig([[maybe_unused]] const SigningProvider& provider, std::vector& vchSig, [[maybe_unused]] const CKeyID& keyid, [[maybe_unused]] const CScript& scriptCode, [[maybe_unused]] SigVersion sigversion) const override { // Create a dummy signature that is a valid DER-encoding vchSig.assign(m_r_len + m_s_len + 7, '\000'); diff --git a/src/script/signingprovider.h b/src/script/signingprovider.h index 8d68e8161b..028aeb5590 100644 --- a/src/script/signingprovider.h +++ b/src/script/signingprovider.h @@ -19,12 +19,12 @@ class SigningProvider { public: virtual ~SigningProvider() {} - virtual bool GetCScript(const CScriptID &scriptid, CScript& script) const { return false; } - virtual bool HaveCScript(const CScriptID &scriptid) const { return false; } - virtual bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const { return false; } - virtual bool GetKey(const CKeyID &address, CKey& key) const { return false; } - virtual bool HaveKey(const CKeyID &address) const { return false; } - virtual bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const { return false; } + virtual bool GetCScript([[maybe_unused]] const CScriptID &scriptid, [[maybe_unused]] CScript& script) const { return false; } + virtual bool HaveCScript([[maybe_unused]] const CScriptID &scriptid) const { return false; } + virtual bool GetPubKey([[maybe_unused]] const CKeyID &address, [[maybe_unused]] CPubKey& pubkey) const { return false; } + virtual bool GetKey([[maybe_unused]] const CKeyID &address, [[maybe_unused]] CKey& key) const { return false; } + virtual bool HaveKey([[maybe_unused]] const CKeyID &address) const { return false; } + virtual bool GetKeyOrigin([[maybe_unused]] const CKeyID& keyid, [[maybe_unused]] KeyOriginInfo& info) const { return false; } }; extern const SigningProvider& DUMMY_SIGNING_PROVIDER; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index a60efb0c6a..701c08c184 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -266,7 +266,7 @@ namespace { class CScriptVisitor { public: - CScript operator()(const CNoDestination& dest) const + CScript operator()([[maybe_unused]] const CNoDestination& dest) const { return CScript(); } diff --git a/src/script/standard.h b/src/script/standard.h index 2238b8d48f..2476881229 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -133,8 +133,8 @@ enum class TxoutType { class CNoDestination { public: - friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; } - friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; } + friend bool operator==([[maybe_unused]] const CNoDestination &a, [[maybe_unused]] const CNoDestination &b) { return true; } + friend bool operator<([[maybe_unused]] const CNoDestination &a, [[maybe_unused]] const CNoDestination &b) { return true; } }; struct PKHash : public BaseHash diff --git a/src/serialize.h b/src/serialize.h index 89d2676f0f..34835a4088 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -174,8 +174,8 @@ template const X& ReadWriteAsHelper(const X& x) { return x; } #define READWRITE(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) #define READWRITEAS(type, obj) (::SerReadWriteMany(s, ser_action, ReadWriteAsHelper(obj))) -#define SER_READ(obj, code) ::SerRead(s, ser_action, obj, [&](Stream& s, typename std::remove_const::type& obj) { code; }) -#define SER_WRITE(obj, code) ::SerWrite(s, ser_action, obj, [&](Stream& s, const Type& obj) { code; }) +#define SER_READ(obj, code) ::SerRead(s, ser_action, obj, [&]([[maybe_unused]] Stream& s, typename std::remove_const::type& obj) { code; }) +#define SER_WRITE(obj, code) ::SerWrite(s, ser_action, obj, [&]([[maybe_unused]] Stream& s, const Type& obj) { code; }) /** * Implement the Ser and Unser methods needed for implementing a formatter (see Using below). @@ -1018,7 +1018,7 @@ class CSizeComputer public: explicit CSizeComputer(int nVersionIn) : nSize(0), nVersion(nVersionIn) {} - void write(const char *psz, size_t _nSize) + void write([[maybe_unused]] const char *psz, size_t _nSize) { this->nSize += _nSize; } @@ -1044,7 +1044,7 @@ class CSizeComputer }; template -void SerializeMany(Stream& s) +void SerializeMany([[maybe_unused]] Stream& s) { } @@ -1056,7 +1056,7 @@ void SerializeMany(Stream& s, const Arg& arg, const Args&... args) } template -inline void UnserializeMany(Stream& s) +inline void UnserializeMany([[maybe_unused]] Stream& s) { } @@ -1068,36 +1068,36 @@ inline void UnserializeMany(Stream& s, Arg&& arg, Args&&... args) } template -inline void SerReadWriteMany(Stream& s, CSerActionSerialize ser_action, const Args&... args) +inline void SerReadWriteMany(Stream& s, [[maybe_unused]] CSerActionSerialize ser_action, const Args&... args) { ::SerializeMany(s, args...); } template -inline void SerReadWriteMany(Stream& s, CSerActionUnserialize ser_action, Args&&... args) +inline void SerReadWriteMany(Stream& s, [[maybe_unused]] CSerActionUnserialize ser_action, Args&&... args) { ::UnserializeMany(s, args...); } template -inline void SerRead(Stream& s, CSerActionSerialize ser_action, Type&&, Fn&&) +inline void SerRead([[maybe_unused]] Stream& s, [[maybe_unused]] CSerActionSerialize ser_action, [[maybe_unused]] Type&&, Fn&&) { } template -inline void SerRead(Stream& s, CSerActionUnserialize ser_action, Type&& obj, Fn&& fn) +inline void SerRead(Stream& s, [[maybe_unused]] CSerActionUnserialize ser_action, Type&& obj, Fn&& fn) { fn(s, std::forward(obj)); } template -inline void SerWrite(Stream& s, CSerActionSerialize ser_action, Type&& obj, Fn&& fn) +inline void SerWrite(Stream& s, [[maybe_unused]] CSerActionSerialize ser_action, Type&& obj, Fn&& fn) { fn(s, std::forward(obj)); } template -inline void SerWrite(Stream& s, CSerActionUnserialize ser_action, Type&&, Fn&&) +inline void SerWrite([[maybe_unused]] Stream& s, [[maybe_unused]] CSerActionUnserialize ser_action, [[maybe_unused]] Type&&, Fn&&) { } diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h index 7e8ff817a2..35c1f524aa 100644 --- a/src/support/allocators/secure.h +++ b/src/support/allocators/secure.h @@ -38,7 +38,7 @@ struct secure_allocator : public std::allocator { typedef secure_allocator<_Other> other; }; - T* allocate(std::size_t n, const void* hint = 0) + T* allocate(std::size_t n, [[maybe_unused]] const void* hint = 0) { T* allocation = static_cast(LockedPoolManager::Instance().alloc(sizeof(T) * n)); if (!allocation) { diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index 1cdfd70635..d64bf4050e 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -183,7 +183,7 @@ class LockedPool std::unique_ptr allocator; /** Create an arena from locked pages */ - class LockedPageArena: public Arena + class LockedPageArena final : public Arena { public: LockedPageArena(LockedPageAllocator *alloc_in, void *base_in, size_t size, size_t align); diff --git a/src/sync.h b/src/sync.h index fdcd956025..f7893e5edd 100644 --- a/src/sync.h +++ b/src/sync.h @@ -66,14 +66,14 @@ bool LockStackEmpty(); */ extern bool g_debug_lockorder_abort; #else -inline void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {} +inline void EnterCritical([[maybe_unused]] const char* pszName, [[maybe_unused]] const char* pszFile, [[maybe_unused]] int nLine, [[maybe_unused]] void* cs, [[maybe_unused]] bool fTry = false) {} inline void LeaveCritical() {} -inline void CheckLastCritical(void* cs, std::string& lockname, const char* guardname, const char* file, int line) {} +inline void CheckLastCritical([[maybe_unused]] void* cs, [[maybe_unused]] std::string& lockname, [[maybe_unused]] const char* guardname, [[maybe_unused]] const char* file, [[maybe_unused]] int line) {} template -inline void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, MutexType* cs) EXCLUSIVE_LOCKS_REQUIRED(cs) {} +inline void AssertLockHeldInternal([[maybe_unused]] const char* pszName, [[maybe_unused]] const char* pszFile, [[maybe_unused]] int nLine, [[maybe_unused]] MutexType* cs) EXCLUSIVE_LOCKS_REQUIRED(cs) {} template -void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLine, MutexType* cs) LOCKS_EXCLUDED(cs) {} -inline void DeleteLock(void* cs) {} +void AssertLockNotHeldInternal([[maybe_unused]] const char* pszName, [[maybe_unused]] const char* pszFile, [[maybe_unused]] int nLine, [[maybe_unused]] MutexType* cs) LOCKS_EXCLUDED(cs) {} +inline void DeleteLock([[maybe_unused]] void* cs) {} inline bool LockStackEmpty() { return true; } #endif #define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs) diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index dd760fe999..a090cb340b 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -16,7 +16,7 @@ using namespace std::literals; -extern UniValue read_json(const std::string& jsondata); +UniValue read_json(const std::string& jsondata); BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup) diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 4dc15c1ad7..737dd5af0e 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -4,7 +4,6 @@ #include -#include #include #include #include diff --git a/src/test/data/base58_encode_decode.json b/src/test/data/base58_encode_decode.json index 251fb167da..86c37f5176 100644 --- a/src/test/data/base58_encode_decode.json +++ b/src/test/data/base58_encode_decode.json @@ -1,16 +1,16 @@ [ - ["", ""], - ["61", "2g"], - ["626262", "a3gV"], - ["636363", "aPEr"], - ["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], - ["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], - ["516b6fcd0f", "ABnLTmg"], - ["bf4f89001e670274dd", "3SEo3LWLoPntC"], - ["572e4794", "3EFU7m"], - ["ecac89cad93923c02321", "EJDM8drfXA6uyA"], - ["10c8511e", "Rt5zm"], - ["00000000000000000000", "1111111111"], - ["000111d38e5fc9071ffcd20b4a763cc9ae4f252bb4e48fd66a835e252ada93ff480d6dd43dc62a641155a5", "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"], - ["000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY"] - ] \ No newline at end of file +["", ""], +["61", "2g"], +["626262", "a3gV"], +["636363", "aPEr"], +["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], +["0aeb15231dfceb60925886b67d065299925915aeb172c06647", "5Pp2xoZZFXwSdcbsjj57BSxerwyUxe3ZJn"], +["516b6fcd0f", "ABnLTmg"], +["bf4f89001e670274dd", "3SEo3LWLoPntC"], +["572e4794", "3EFU7m"], +["ecac89cad93923c02321", "EJDM8drfXA6uyA"], +["10c8511e", "Rt5zm"], +["00000000000000000000", "1111111111"], +["000111d38e5fc9071ffcd20b4a763cc9ae4f252bb4e48fd66a835e252ada93ff480d6dd43dc62a641155a5", "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"], +["000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "1cWB5HCBdLjAuqGGReWE3R3CguuwSjw6RHn39s2yuDRTS5NsBgNiFpWgAnEx6VQi8csexkgYw3mdYrMHr8x9i7aEwP8kZ7vccXWqKDvGv3u1GxFKPuAkn8JCPPGDMf3vMMnbzm6Nh9zh1gcNsMvH3ZNLmP5fSG6DGbbi2tuwMWPthr4boWwCxf7ewSgNQeacyozhKDDQQ1qL5fQFUW52QKUZDZ5fw3KXNQJMcNTcaB723LchjeKun7MuGW5qyCBZYzA1KjofN1gYBV3NqyhQJ3Ns746GNuf9N2pQPmHz4xpnSrrfCvy6TVVz5d4PdrjeshsWQwpZsZGzvbdAdN8MKV5QsBDY"] +] diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index ff49d0d356..abe65f132e 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 1f5d2d8859..9466dd81b1 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -28,6 +27,8 @@ static const std::string addr2C = "5DoksNxE71AHAcZPacDu7bhYyR2abomBK7"; static const std::string strAddressBad = "1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF"; +static const std::string addr_bitcoin = "1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"; // valid BTC address, not valid BGL address + BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup) @@ -69,6 +70,15 @@ BOOST_AUTO_TEST_CASE(key_test1) BOOST_CHECK(!key2C.VerifyPubKey(pubkey2)); BOOST_CHECK(key2C.VerifyPubKey(pubkey2C)); + // check the addresses are valid - if they aren't, it can give misleading failures later + BOOST_CHECK(IsValidDestination(DecodeDestination(addr1))); + BOOST_CHECK(IsValidDestination(DecodeDestination(addr2))); + BOOST_CHECK(IsValidDestination(DecodeDestination(addr1C))); + BOOST_CHECK(IsValidDestination(DecodeDestination(addr2C))); + + // bitcoin addresses (prefix 0) should NOT be valid + BOOST_CHECK(!IsValidDestination(DecodeDestination(addr_bitcoin))); + CTxDestination dest1 = DecodeDestination(addr1); CTxDestination dest2 = CTxDestination(PKHash(pubkey1)); BOOST_CHECK(dest1 == dest2); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 9ba004cc38..3df5d5c35d 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) // Note that by default, these tests run with size accounting enabled. const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN); const CChainParams& chainparams = *chainParams; - CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; + CScript scriptPubKey = CScript() << ParseHex("04489d8efd89b673459f3ebbe435956c90255d31408dec347e01649c067267a16347c653e7b721d2aacd8290d3c29665280b52605aab9ee7fecd9db31237467411") << OP_CHECKSIG; std::unique_ptr pblocktemplate; CMutableTransaction tx; CScript script; diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 8de7be7fd7..e98c7e79de 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(util_ParseHex) std::vector result; std::vector expected(ParseHex_expected, ParseHex_expected + sizeof(ParseHex_expected)); // Basic test vector - result = ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"); + result = ParseHex("04489d8efd89b673459f3ebbe435956c90255d31408dec347e01649c067267a16347c653e7b721d2aacd8290d3c29665280b52605aab9ee7fecd9db31237467411"); BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end()); // Spaces between bytes must be supported @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(util_HexStr) { BOOST_CHECK_EQUAL( HexStr(ParseHex_expected), - "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"); + "04489d8efd89b673459f3ebbe435956c90255d31408dec347e01649c067267a16347c653e7b721d2aacd8290d3c29665280b52605aab9ee7fecd9db31237467411"); BOOST_CHECK_EQUAL( HexStr(Span( diff --git a/src/tinyformat.h b/src/tinyformat.h index d2f1a84e9d..f6505a22fb 100644 --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -797,27 +797,27 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& positionalMode break; case 'X': out.setf(std::ios::uppercase); - // Falls through + [[fallthrough]]; case 'x': case 'p': out.setf(std::ios::hex, std::ios::basefield); intConversion = true; break; case 'E': out.setf(std::ios::uppercase); - // Falls through + [[fallthrough]]; case 'e': out.setf(std::ios::scientific, std::ios::floatfield); out.setf(std::ios::dec, std::ios::basefield); break; case 'F': out.setf(std::ios::uppercase); - // Falls through + [[fallthrough]]; case 'f': out.setf(std::ios::fixed, std::ios::floatfield); break; case 'A': out.setf(std::ios::uppercase); - // Falls through + [[fallthrough]]; case 'a': # ifdef _MSC_VER // Workaround https://developercommunity.visualstudio.com/content/problem/520472/hexfloat-stream-output-does-not-ignore-precision-a.html @@ -829,7 +829,7 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& positionalMode break; case 'G': out.setf(std::ios::uppercase); - // Falls through + [[fallthrough]]; case 'g': out.setf(std::ios::dec, std::ios::basefield); // As in boost::format, let stream decide float format. diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 6666e49a2b..7814d3f680 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -112,7 +112,7 @@ void TorControlConnection::readcb(struct bufferevent *bev, void *ctx) } } -void TorControlConnection::eventcb(struct bufferevent *bev, short what, void *ctx) +void TorControlConnection::eventcb([[maybe_unused]] struct bufferevent *bev, short what, void *ctx) { TorControlConnection *self = static_cast(ctx); if (what & BEV_EVENT_CONNECTED) { @@ -325,7 +325,7 @@ TorController::~TorController() } } -void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlReply& reply) +void TorController::add_onion_cb([[maybe_unused]] TorControlConnection& _conn, const TorControlReply& reply) { if (reply.code == 250) { LogPrint(BCLog::TOR, "tor: ADD_ONION successful\n"); @@ -531,7 +531,7 @@ void TorController::connected_cb(TorControlConnection& _conn) LogPrintf("tor: Error sending initial protocolinfo command\n"); } -void TorController::disconnected_cb(TorControlConnection& _conn) +void TorController::disconnected_cb([[maybe_unused]] TorControlConnection& _conn) { // Stop advertising service when disconnected if (service.IsValid()) @@ -543,7 +543,7 @@ void TorController::disconnected_cb(TorControlConnection& _conn) LogPrint(BCLog::TOR, "tor: Not connected to Tor control port %s, trying to reconnect\n", m_tor_control_center); // Single-shot timer for reconnect. Use exponential backoff. - struct timeval time = MillisToTimeval(int64_t(reconnect_timeout * 1000.0)); + struct timeval time = MillisToTimeval(static_cast(reconnect_timeout * 1000.0f)); if (reconnect_ev) event_add(reconnect_ev, &time); reconnect_timeout *= RECONNECT_TIMEOUT_EXP; @@ -565,7 +565,7 @@ fs::path TorController::GetPrivateKeyFile() return GetDataDir() / "onion_v3_private_key"; } -void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg) +void TorController::reconnect_cb([[maybe_unused]] evutil_socket_t fd, [[maybe_unused]] short what, void *arg) { TorController *self = static_cast(arg); self->Reconnect(); diff --git a/src/validation.cpp b/src/validation.cpp index 9eeb9fe0d5..cac4dcf7eb 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -948,7 +948,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) return true; } -bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws, PrecomputedTransactionData& txdata) +bool MemPoolAccept::PolicyScriptChecks([[maybe_unused]] const ATMPArgs& args, Workspace& ws, PrecomputedTransactionData& txdata) { const CTransaction& tx = *ws.m_ptx; TxValidationState& state = ws.m_state; @@ -1708,9 +1708,10 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker public: explicit WarningBitsConditionChecker(int bitIn) : bit(bitIn) {} + virtual ~WarningBitsConditionChecker() = default; - int64_t BeginTime(const Consensus::Params& params) const override { return 0; } - int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits::max(); } + int64_t BeginTime([[maybe_unused]] const Consensus::Params& params) const override { return 0; } + int64_t EndTime([[maybe_unused]] const Consensus::Params& params) const override { return std::numeric_limits::max(); } int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; } int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; } diff --git a/src/validationinterface.h b/src/validationinterface.h index 81ade443fb..c71c1762db 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -81,7 +81,7 @@ class CValidationInterface { * Protected destructor so that instances can only be deleted by derived classes. * If that restriction is no longer desired, this should be made public and virtual. */ - ~CValidationInterface() = default; + virtual ~CValidationInterface() = default; /** * Notifies listeners when the block chain tip advances. * @@ -91,13 +91,13 @@ class CValidationInterface { * * Called on a background thread. */ - virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {} + virtual void UpdatedBlockTip([[maybe_unused]] const CBlockIndex *pindexNew, [[maybe_unused]] const CBlockIndex *pindexFork, [[maybe_unused]] bool fInitialDownload) {} /** * Notifies listeners of a transaction having been added to mempool. * * Called on a background thread. */ - virtual void TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) {} + virtual void TransactionAddedToMempool([[maybe_unused]] const CTransactionRef& tx, [[maybe_unused]] uint64_t mempool_sequence) {} /** * Notifies listeners of a transaction leaving mempool. @@ -131,20 +131,20 @@ class CValidationInterface { * * Called on a background thread. */ - virtual void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {} + virtual void TransactionRemovedFromMempool([[maybe_unused]] const CTransactionRef& tx, [[maybe_unused]] MemPoolRemovalReason reason, [[maybe_unused]] uint64_t mempool_sequence) {} /** * Notifies listeners of a block being connected. * Provides a vector of transactions evicted from the mempool as a result. * * Called on a background thread. */ - virtual void BlockConnected(const std::shared_ptr &block, const CBlockIndex *pindex) {} + virtual void BlockConnected([[maybe_unused]] const std::shared_ptr &block, [[maybe_unused]] const CBlockIndex *pindex) {} /** * Notifies listeners of a block being disconnected * * Called on a background thread. */ - virtual void BlockDisconnected(const std::shared_ptr &block, const CBlockIndex* pindex) {} + virtual void BlockDisconnected([[maybe_unused]] const std::shared_ptr &block, [[maybe_unused]] const CBlockIndex* pindex) {} /** * Notifies listeners of the new active block chain on-disk. * @@ -161,18 +161,18 @@ class CValidationInterface { * * Called on a background thread. */ - virtual void ChainStateFlushed(const CBlockLocator &locator) {} + virtual void ChainStateFlushed([[maybe_unused]] const CBlockLocator &locator) {} /** * Notifies listeners of a block validation result. * If the provided BlockValidationState IsValid, the provided block * is guaranteed to be the current best block at the time the * callback was generated (not necessarily now) */ - virtual void BlockChecked(const CBlock&, const BlockValidationState&) {} + virtual void BlockChecked([[maybe_unused]] const CBlock&, [[maybe_unused]] const BlockValidationState&) {} /** * Notifies listeners that a block which builds directly on our current tip * has been received and connected to the headers tree, though not validated yet */ - virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr& block) {}; + virtual void NewPoWValidBlock([[maybe_unused]] const CBlockIndex *pindex, [[maybe_unused]] const std::shared_ptr& block) {}; friend class CMainSignals; }; diff --git a/src/versionbits.h b/src/versionbits.h index 225ec2ff7f..7377e0ff89 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -57,10 +57,12 @@ class AbstractThresholdConditionChecker { virtual bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const =0; virtual int64_t BeginTime(const Consensus::Params& params) const =0; virtual int64_t EndTime(const Consensus::Params& params) const =0; - virtual int MinActivationHeight(const Consensus::Params& params) const { return 0; } + virtual int MinActivationHeight([[maybe_unused]] const Consensus::Params& params) const { return 0; } virtual int Period(const Consensus::Params& params) const =0; virtual int Threshold(const Consensus::Params& params) const =0; + virtual ~AbstractThresholdConditionChecker() = default; + public: /** Returns the numerical statistics of an in-progress BIP9 softfork in the current period */ BIP9Stats GetStateStatisticsFor(const CBlockIndex* pindex, const Consensus::Params& params) const; diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index bc8c25734c..604bbc2249 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -91,7 +91,7 @@ class BerkeleyBatch; /** An instance of this class represents one database. * For BerkeleyDB this is just a (env, strFile) tuple. **/ -class BerkeleyDatabase : public WalletDatabase +class BerkeleyDatabase final : public WalletDatabase { public: BerkeleyDatabase() = delete; @@ -165,7 +165,7 @@ class BerkeleyDatabase : public WalletDatabase }; /** RAII class that provides access to a Berkeley database */ -class BerkeleyBatch : public DatabaseBatch +class BerkeleyBatch final : public DatabaseBatch { /** RAII class that automatically cleanses its data on destruction */ class SafeDbt final diff --git a/src/wallet/db.h b/src/wallet/db.h index 6d80dd1187..678818118a 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -155,20 +155,20 @@ class WalletDatabase }; /** RAII class that provides access to a DummyDatabase. Never fails. */ -class DummyBatch : public DatabaseBatch +class DummyBatch final : public DatabaseBatch { private: - bool ReadKey(CDataStream&& key, CDataStream& value) override { return true; } - bool WriteKey(CDataStream&& key, CDataStream&& value, bool overwrite=true) override { return true; } - bool EraseKey(CDataStream&& key) override { return true; } - bool HasKey(CDataStream&& key) override { return true; } + bool ReadKey([[maybe_unused]] CDataStream&& key, [[maybe_unused]] CDataStream& value) override { return true; } + bool WriteKey([[maybe_unused]] CDataStream&& key, [[maybe_unused]] CDataStream&& value, [[maybe_unused]] bool overwrite=true) override { return true; } + bool EraseKey([[maybe_unused]] CDataStream&& key) override { return true; } + bool HasKey([[maybe_unused]] CDataStream&& key) override { return true; } public: void Flush() override {} void Close() override {} bool StartCursor() override { return true; } - bool ReadAtCursor(CDataStream& ssKey, CDataStream& ssValue, bool& complete) override { return true; } + bool ReadAtCursor([[maybe_unused]] CDataStream& ssKey, [[maybe_unused]] CDataStream& ssValue, [[maybe_unused]] bool& complete) override { return true; } void CloseCursor() override {} bool TxnBegin() override { return true; } bool TxnCommit() override { return true; } @@ -177,14 +177,14 @@ class DummyBatch : public DatabaseBatch /** A dummy WalletDatabase that does nothing and never fails. Only used by unit tests. **/ -class DummyDatabase : public WalletDatabase +class DummyDatabase final : public WalletDatabase { public: void Open() override {}; void AddRef() override {} void RemoveRef() override {} - bool Rewrite(const char* pszSkip=nullptr) override { return true; } - bool Backup(const std::string& strDest) const override { return true; } + bool Rewrite([[maybe_unused]] const char* pszSkip=nullptr) override { return true; } + bool Backup([[maybe_unused]] const std::string& strDest) const override { return true; } void Close() override {} void Flush() override {} bool PeriodicFlush() override { return true; } @@ -192,7 +192,7 @@ class DummyDatabase : public WalletDatabase void ReloadDbEnv() override {} std::string Filename() override { return "dummy"; } std::string Format() override { return "dummy"; } - std::unique_ptr MakeBatch(bool flush_on_close = true) override { return std::make_unique(); } + std::unique_ptr MakeBatch([[maybe_unused]] bool flush_on_close = true) override { return std::make_unique(); } }; enum class DatabaseFormat { diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 4119facba9..09c911af26 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -116,7 +116,7 @@ RPCHelpMan importprivkey() "\nAs a JSON-RPC call\n" + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -207,7 +207,7 @@ RPCHelpMan abortrescan() "\nAs a JSON-RPC call\n" + HelpExampleRpc("abortrescan", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -245,7 +245,7 @@ RPCHelpMan importaddress() "\nAs a JSON-RPC call\n" + HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -330,7 +330,7 @@ RPCHelpMan importprunedfunds() }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -391,7 +391,7 @@ RPCHelpMan removeprunedfunds() "\nAs a JSON-RPC call\n" + HelpExampleRpc("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -438,7 +438,7 @@ RPCHelpMan importpubkey() "\nAs a JSON-RPC call\n" + HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -519,7 +519,7 @@ RPCHelpMan importwallet() "\nImport using the json rpc call\n" + HelpExampleRpc("importwallet", "\"test\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -675,7 +675,7 @@ RPCHelpMan dumpprivkey() + HelpExampleCli("importprivkey", "\"mykey\"") + HelpExampleRpc("dumpprivkey", "\"myaddress\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -725,7 +725,7 @@ RPCHelpMan dumpwallet() HelpExampleCli("dumpwallet", "\"test\"") + HelpExampleRpc("dumpwallet", "\"test\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1326,7 +1326,7 @@ RPCHelpMan importmulti() "{ \"scriptPubKey\": { \"address\": \"\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") + HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(mainRequest); if (!pwallet) return NullUniValue; @@ -1630,7 +1630,7 @@ RPCHelpMan importdescriptors() "{ \"desc\": \"\", \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") + HelpExampleCli("importdescriptors", "'[{ \"desc\": \"\", \"timestamp\":1455191478, \"active\": true, \"range\": [0,100], \"label\": \"\" }]'") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(main_request); if (!pwallet) return NullUniValue; @@ -1757,7 +1757,7 @@ RPCHelpMan listdescriptors() RPCExamples{ HelpExampleCli("listdescriptors", "") + HelpExampleRpc("listdescriptors", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const wallet = GetWalletForJSONRPCRequest(request); if (!wallet) return NullUniValue; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 68da832e59..bb416309bd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -247,7 +247,7 @@ static RPCHelpMan getnewaddress() HelpExampleCli("getnewaddress", "") + HelpExampleRpc("getnewaddress", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -296,7 +296,7 @@ static RPCHelpMan getrawchangeaddress() HelpExampleCli("getrawchangeaddress", "") + HelpExampleRpc("getrawchangeaddress", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -338,7 +338,7 @@ static RPCHelpMan setlabel() HelpExampleCli("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\" \"tabby\"") + HelpExampleRpc("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\", \"tabby\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -475,7 +475,7 @@ static RPCHelpMan sendtoaddress() + HelpExampleCli("-named sendtoaddress", "address=\"" + EXAMPLE_ADDRESS[0] + "\" amount=0.5 fee_rate=25") + HelpExampleCli("-named sendtoaddress", "address=\"" + EXAMPLE_ADDRESS[0] + "\" amount=0.5 fee_rate=25 subtractfeefromamount=false replaceable=true avoid_reuse=true comment=\"2 pizzas\" comment_to=\"jeremy\" verbose=true") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -553,7 +553,7 @@ static RPCHelpMan listaddressgroupings() HelpExampleCli("listaddressgroupings", "") + HelpExampleRpc("listaddressgroupings", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -610,7 +610,7 @@ static RPCHelpMan signmessage() "\nAs a JSON-RPC call\n" + HelpExampleRpc("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -712,7 +712,7 @@ static RPCHelpMan getreceivedbyaddress() "\nAs a JSON-RPC call\n" + HelpExampleRpc("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\", 6") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -750,7 +750,7 @@ static RPCHelpMan getreceivedbylabel() "\nAs a JSON-RPC call\n" + HelpExampleRpc("getreceivedbylabel", "\"tabby\", 6") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -790,7 +790,7 @@ static RPCHelpMan getbalance() "\nAs a JSON-RPC call\n" + HelpExampleRpc("getbalance", "\"*\", 6") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -829,7 +829,7 @@ static RPCHelpMan getunconfirmedbalance() {}, RPCResult{RPCResult::Type::NUM, "", "The balance"}, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -899,7 +899,7 @@ static RPCHelpMan sendmany() "\nAs a JSON-RPC call\n" + HelpExampleRpc("sendmany", "\"\", {\"" + EXAMPLE_ADDRESS[0] + "\":0.01,\"" + EXAMPLE_ADDRESS[1] + "\":0.02}, 6, \"testing\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -972,7 +972,7 @@ static RPCHelpMan addmultisigaddress() "\nAs a JSON-RPC call\n" + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1213,7 +1213,7 @@ static RPCHelpMan listreceivedbyaddress() + HelpExampleRpc("listreceivedbyaddress", "6, true, true") + HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"" + EXAMPLE_ADDRESS[0] + "\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1255,7 +1255,7 @@ static RPCHelpMan listreceivedbylabel() + HelpExampleCli("listreceivedbylabel", "6 true") + HelpExampleRpc("listreceivedbylabel", "6, true, true") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1435,7 +1435,7 @@ static RPCHelpMan listtransactions() "\nAs a JSON-RPC call\n" + HelpExampleRpc("listtransactions", "\"*\", 20, 100") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1486,10 +1486,10 @@ static RPCHelpMan listtransactions() // ret is newest to oldest - if (nFrom > (int)ret.size()) - nFrom = ret.size(); - if ((nFrom + nCount) > (int)ret.size()) - nCount = ret.size() - nFrom; + if (nFrom > static_cast(ret.size())) + nFrom = static_cast(ret.size()); + if ((nFrom + nCount) > static_cast(ret.size())) + nCount = static_cast(ret.size()) - nFrom; const std::vector& txs = ret.getValues(); UniValue result{UniValue::VARR}; @@ -1552,7 +1552,7 @@ static RPCHelpMan listsinceblock() + HelpExampleCli("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6") + HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1693,7 +1693,7 @@ static RPCHelpMan gettransaction() + HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true") + HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1766,7 +1766,7 @@ static RPCHelpMan abandontransaction() HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1804,7 +1804,7 @@ static RPCHelpMan backupwallet() HelpExampleCli("backupwallet", "\"backup.dat\"") + HelpExampleRpc("backupwallet", "\"backup.dat\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1839,7 +1839,7 @@ static RPCHelpMan keypoolrefill() HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -1892,7 +1892,7 @@ static RPCHelpMan walletpassphrase() "\nAs a JSON-RPC call\n" + HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const wallet = GetWalletForJSONRPCRequest(request); if (!wallet) return NullUniValue; @@ -1980,7 +1980,7 @@ static RPCHelpMan walletpassphrasechange() HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"") + HelpExampleRpc("walletpassphrasechange", "\"old one\", \"new one\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2033,7 +2033,7 @@ static RPCHelpMan walletlock() "\nAs a JSON-RPC call\n" + HelpExampleRpc("walletlock", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2077,7 +2077,7 @@ static RPCHelpMan encryptwallet() "\nAs a JSON-RPC call\n" + HelpExampleRpc("encryptwallet", "\"my pass phrase\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2150,7 +2150,7 @@ static RPCHelpMan lockunspent() "\nAs a JSON-RPC call\n" + HelpExampleRpc("lockunspent", "false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2264,7 +2264,7 @@ static RPCHelpMan listlockunspent() "\nAs a JSON-RPC call\n" + HelpExampleRpc("listlockunspent", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2304,7 +2304,7 @@ static RPCHelpMan settxfee() HelpExampleCli("settxfee", "0.00001") + HelpExampleRpc("settxfee", "0.00001") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2357,7 +2357,7 @@ static RPCHelpMan getbalances() RPCExamples{ HelpExampleCli("getbalances", "") + HelpExampleRpc("getbalances", "")}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const rpc_wallet = GetWalletForJSONRPCRequest(request); if (!rpc_wallet) return NullUniValue; @@ -2433,7 +2433,7 @@ static RPCHelpMan getwalletinfo() HelpExampleCli("getwalletinfo", "") + HelpExampleRpc("getwalletinfo", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2513,7 +2513,7 @@ static RPCHelpMan listwalletdir() HelpExampleCli("listwalletdir", "") + HelpExampleRpc("listwalletdir", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { UniValue wallets(UniValue::VARR); for (const auto& path : ListDatabases(GetWalletDir())) { @@ -2545,7 +2545,7 @@ static RPCHelpMan listwallets() HelpExampleCli("listwallets", "") + HelpExampleRpc("listwallets", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { UniValue obj(UniValue::VARR); @@ -2580,7 +2580,7 @@ static RPCHelpMan loadwallet() HelpExampleCli("loadwallet", "\"test.dat\"") + HelpExampleRpc("loadwallet", "\"test.dat\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { WalletContext& context = EnsureWalletContext(request.context); const std::string name(request.params[0].get_str()); @@ -2644,7 +2644,7 @@ static RPCHelpMan setwalletflag() HelpExampleCli("setwalletflag", "avoid_reuse") + HelpExampleRpc("setwalletflag", "\"avoid_reuse\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -2714,7 +2714,7 @@ static RPCHelpMan createwallet() + HelpExampleCliNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}}) + HelpExampleRpcNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}}) }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { WalletContext& context = EnsureWalletContext(request.context); uint64_t flags = 0; @@ -2798,7 +2798,7 @@ static RPCHelpMan unloadwallet() HelpExampleCli("unloadwallet", "wallet_name") + HelpExampleRpc("unloadwallet", "wallet_name") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::string wallet_name; if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) { @@ -2889,7 +2889,7 @@ static RPCHelpMan listunspent() + HelpExampleCli("listunspent", "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") + HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3263,7 +3263,7 @@ static RPCHelpMan fundrawtransaction() "\nSend the transaction\n" + HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3348,7 +3348,7 @@ RPCHelpMan signrawtransactionwithwallet() HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + HelpExampleRpc("signrawtransactionwithwallet", "\"myhex\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3447,7 +3447,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name) "\nBump the fee, get the new transaction\'s" + std::string(want_psbt ? "psbt" : "txid") + "\n" + HelpExampleCli(method_name, "") }, - [want_psbt](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [want_psbt]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3586,7 +3586,7 @@ static RPCHelpMan rescanblockchain() HelpExampleCli("rescanblockchain", "100000 120000") + HelpExampleRpc("rescanblockchain", "100000, 120000") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3687,7 +3687,7 @@ class DescribeWalletAddressVisitor explicit DescribeWalletAddressVisitor(const SigningProvider* _provider) : provider(_provider) {} - UniValue operator()(const CNoDestination& dest) const { return UniValue(UniValue::VOBJ); } + UniValue operator()([[maybe_unused]] const CNoDestination& dest) const { return UniValue(UniValue::VOBJ); } UniValue operator()(const PKHash& pkhash) const { @@ -3735,7 +3735,7 @@ class DescribeWalletAddressVisitor return obj; } - UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); } + UniValue operator()([[maybe_unused]] const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); } }; static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestination& dest) @@ -3815,7 +3815,7 @@ RPCHelpMan getaddressinfo() HelpExampleCli("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"") + HelpExampleRpc("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3917,7 +3917,7 @@ static RPCHelpMan getaddressesbylabel() HelpExampleCli("getaddressesbylabel", "\"tabby\"") + HelpExampleRpc("getaddressesbylabel", "\"tabby\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -3978,7 +3978,7 @@ static RPCHelpMan listlabels() "\nAs a JSON-RPC call\n" + HelpExampleRpc("listlabels", "receive") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -4096,7 +4096,7 @@ static RPCHelpMan send() "Create a transaction that should confirm the next block, with a specific input, and return result without adding to wallet or broadcasting to the network\n" + HelpExampleCli("send", "'{\"" + EXAMPLE_ADDRESS[0] + "\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { RPCTypeCheck(request.params, { UniValueType(), // outputs (ARR or OBJ, checked later) @@ -4232,7 +4232,7 @@ static RPCHelpMan sethdseed() + HelpExampleCli("sethdseed", "true \"wifkey\"") + HelpExampleRpc("sethdseed", "true, \"wifkey\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -4309,7 +4309,7 @@ static RPCHelpMan walletprocesspsbt() RPCExamples{ HelpExampleCli("walletprocesspsbt", "\"psbt\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -4423,7 +4423,7 @@ static RPCHelpMan walletcreatefundedpsbt() "\nCreate a transaction with no inputs\n" + HelpExampleCli("walletcreatefundedpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -4498,7 +4498,7 @@ static RPCHelpMan upgradewallet() HelpExampleCli("upgradewallet", "169900") + HelpExampleRpc("upgradewallet", "169900") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const pwallet = GetWalletForJSONRPCRequest(request); if (!pwallet) return NullUniValue; @@ -4555,7 +4555,7 @@ static RPCHelpMan walletdisplayaddress() } }, RPCExamples{""}, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::shared_ptr const wallet = GetWalletForJSONRPCRequest(request); if (!wallet) return NullUniValue; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 149549410c..39f1a41d3c 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -551,7 +551,7 @@ int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const return nTimeFirstKey; } -std::unique_ptr LegacyScriptPubKeyMan::GetSolvingProvider(const CScript& script) const +std::unique_ptr LegacyScriptPubKeyMan::GetSolvingProvider([[maybe_unused]] const CScript& script) const { return std::make_unique(*this); } @@ -1597,7 +1597,7 @@ std::set LegacyScriptPubKeyMan::GetKeys() const return set_address; } -void LegacyScriptPubKeyMan::SetInternal(bool internal) {} +void LegacyScriptPubKeyMan::SetInternal([[maybe_unused]] bool internal) {} bool DescriptorScriptPubKeyMan::GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { @@ -1707,7 +1707,7 @@ bool DescriptorScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, Walle return true; } -bool DescriptorScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) +bool DescriptorScriptPubKeyMan::GetReservedDestination(const OutputType type, [[maybe_unused]] bool internal, CTxDestination& address, int64_t& index, [[maybe_unused]] CKeyPool& keypool) { LOCK(cs_desc_man); std::string error; @@ -1716,7 +1716,7 @@ bool DescriptorScriptPubKeyMan::GetReservedDestination(const OutputType type, bo return result; } -void DescriptorScriptPubKeyMan::ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) +void DescriptorScriptPubKeyMan::ReturnDestination(int64_t index, [[maybe_unused]] bool internal, [[maybe_unused]] const CTxDestination& addr) { LOCK(cs_desc_man); // Only return when the index was the most recent @@ -1952,7 +1952,7 @@ bool DescriptorScriptPubKeyMan::IsHDEnabled() const return m_wallet_descriptor.descriptor->IsRange(); } -bool DescriptorScriptPubKeyMan::CanGetAddresses(bool internal) const +bool DescriptorScriptPubKeyMan::CanGetAddresses([[maybe_unused]] bool internal) const { // We can only give out addresses from descriptors that are single type (not combo), ranged, // and either have cached keys or can generate more keys (ignoring encryption) @@ -2046,7 +2046,7 @@ std::unique_ptr DescriptorScriptPubKeyMan::GetSolvingProvider(c return GetSigningProvider(script, false); } -bool DescriptorScriptPubKeyMan::CanProvide(const CScript& script, SignatureData& sigdata) +bool DescriptorScriptPubKeyMan::CanProvide(const CScript& script, [[maybe_unused]] SignatureData& sigdata) { return IsMine(script); } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 74a042e01e..de45f2a56c 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -174,40 +174,40 @@ class ScriptPubKeyMan public: explicit ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {} virtual ~ScriptPubKeyMan() {}; - virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { return false; } - virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; } + virtual bool GetNewDestination([[maybe_unused]] const OutputType type, [[maybe_unused]] CTxDestination& dest, [[maybe_unused]] std::string& error) { return false; } + virtual isminetype IsMine([[maybe_unused]] const CScript& script) const { return ISMINE_NO; } //! Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the keys handled by it. - virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) { return false; } - virtual bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { return false; } + virtual bool CheckDecryptionKey([[maybe_unused]] const CKeyingMaterial& master_key, [[maybe_unused]] bool accept_no_keys = false) { return false; } + virtual bool Encrypt([[maybe_unused]] const CKeyingMaterial& master_key, [[maybe_unused]] WalletBatch* batch) { return false; } - virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination& address, int64_t& index, CKeyPool& keypool) { return false; } - virtual void KeepDestination(int64_t index, const OutputType& type) {} - virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) {} + virtual bool GetReservedDestination([[maybe_unused]] const OutputType type, [[maybe_unused]] bool internal, [[maybe_unused]] CTxDestination& address, [[maybe_unused]] int64_t& index, [[maybe_unused]] CKeyPool& keypool) { return false; } + virtual void KeepDestination([[maybe_unused]] int64_t index, [[maybe_unused]] const OutputType& type) {} + virtual void ReturnDestination([[maybe_unused]] int64_t index, [[maybe_unused]] bool internal, [[maybe_unused]] const CTxDestination& addr) {} /** Fills internal address pool. Use within ScriptPubKeyMan implementations should be used sparingly and only * when something from the address pool is removed, excluding GetNewDestination and GetReservedDestination. * External wallet code is primarily responsible for topping up prior to fetching new addresses */ - virtual bool TopUp(unsigned int size = 0) { return false; } + virtual bool TopUp([[maybe_unused]] unsigned int size = 0) { return false; } //! Mark unused addresses as being used - virtual void MarkUnusedAddresses(const CScript& script) {} + virtual void MarkUnusedAddresses([[maybe_unused]] const CScript& script) {} /** Sets up the key generation stuff, i.e. generates new HD seeds and sets them as active. * Returns false if already setup or setup fails, true if setup is successful * Set force=true to make it re-setup if already setup, used for upgrades */ - virtual bool SetupGeneration(bool force = false) { return false; } + virtual bool SetupGeneration([[maybe_unused]] bool force = false) { return false; } /* Returns true if HD is enabled */ virtual bool IsHDEnabled() const { return false; } /* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */ - virtual bool CanGetAddresses(bool internal = false) const { return false; } + virtual bool CanGetAddresses([[maybe_unused]] bool internal = false) const { return false; } /** Upgrades the wallet to the specified version */ - virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return false; } + virtual bool Upgrade([[maybe_unused]] int prev_version, [[maybe_unused]] int new_version, [[maybe_unused]] bilingual_str& error) { return false; } virtual bool HavePrivateKeys() const { return false; } @@ -221,25 +221,25 @@ class ScriptPubKeyMan virtual int64_t GetTimeFirstKey() const { return 0; } - virtual std::unique_ptr GetMetadata(const CTxDestination& dest) const { return nullptr; } + virtual std::unique_ptr GetMetadata([[maybe_unused]] const CTxDestination& dest) const { return nullptr; } - virtual std::unique_ptr GetSolvingProvider(const CScript& script) const { return nullptr; } + virtual std::unique_ptr GetSolvingProvider([[maybe_unused]] const CScript& script) const { return nullptr; } /** Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that, combined with * sigdata, can produce solving data. */ - virtual bool CanProvide(const CScript& script, SignatureData& sigdata) { return false; } + virtual bool CanProvide([[maybe_unused]] const CScript& script, [[maybe_unused]] SignatureData& sigdata) { return false; } /** Creates new signatures and adds them to the transaction. Returns whether all inputs were signed */ - virtual bool SignTransaction(CMutableTransaction& tx, const std::map& coins, int sighash, std::map& input_errors) const { return false; } + virtual bool SignTransaction([[maybe_unused]] CMutableTransaction& tx, [[maybe_unused]] const std::map& coins, [[maybe_unused]] int sighash, [[maybe_unused]] std::map& input_errors) const { return false; } /** Sign a message with the given script */ - virtual SigningResult SignMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) const { return SigningResult::SIGNING_FAILED; }; + virtual SigningResult SignMessage([[maybe_unused]] const std::string& message, [[maybe_unused]] const PKHash& pkhash, [[maybe_unused]] std::string& str_sig) const { return SigningResult::SIGNING_FAILED; }; /** Adds script and derivation path information to a PSBT, and optionally signs it. */ - virtual TransactionError FillPSBT(PartiallySignedTransaction& psbt, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr) const { return TransactionError::INVALID_PSBT; } + virtual TransactionError FillPSBT([[maybe_unused]] PartiallySignedTransaction& psbt, [[maybe_unused]] int sighash_type = 1 /* SIGHASH_ALL */, [[maybe_unused]] bool sign = true, [[maybe_unused]] bool bip32derivs = false, [[maybe_unused]] int* n_signed = nullptr) const { return TransactionError::INVALID_PSBT; } virtual uint256 GetID() const { return uint256(); } - virtual void SetInternal(bool internal) {} + virtual void SetInternal([[maybe_unused]] bool internal) {} /** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */ template @@ -254,7 +254,7 @@ class ScriptPubKeyMan boost::signals2::signal NotifyCanGetAddressesChanged; }; -class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProvider +class LegacyScriptPubKeyMan final : public ScriptPubKeyMan, public FillableSigningProvider { private: //! keeps track of whether Unlock has run a thorough check before @@ -509,8 +509,8 @@ class LegacySigningProvider : public SigningProvider bool GetCScript(const CScriptID &scriptid, CScript& script) const override { return m_spk_man.GetCScript(scriptid, script); } bool HaveCScript(const CScriptID &scriptid) const override { return m_spk_man.HaveCScript(scriptid); } bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const override { return m_spk_man.GetPubKey(address, pubkey); } - bool GetKey(const CKeyID &address, CKey& key) const override { return false; } - bool HaveKey(const CKeyID &address) const override { return false; } + bool GetKey([[maybe_unused]] const CKeyID &address, [[maybe_unused]] CKey& key) const override { return false; } + bool HaveKey([[maybe_unused]] const CKeyID &address) const override { return false; } bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override { return m_spk_man.GetKeyOrigin(keyid, info); } }; diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp index a9b98c06dd..d6edbb077e 100644 --- a/src/wallet/sqlite.cpp +++ b/src/wallet/sqlite.cpp @@ -250,7 +250,7 @@ void SQLiteDatabase::Open() } } -bool SQLiteDatabase::Rewrite(const char* skip) +bool SQLiteDatabase::Rewrite([[maybe_unused]] const char* skip) { // Rewrite the database using the VACUUM command: https://sqlite.org/lang_vacuum.html int ret = sqlite3_exec(m_db, "VACUUM", nullptr, nullptr, nullptr); @@ -293,7 +293,7 @@ void SQLiteDatabase::Close() m_db = nullptr; } -std::unique_ptr SQLiteDatabase::MakeBatch(bool flush_on_close) +std::unique_ptr SQLiteDatabase::MakeBatch([[maybe_unused]] bool flush_on_close) { // We ignore flush_on_close because we don't do manual flushing for SQLite return std::make_unique(*this); diff --git a/src/wallet/sqlite.h b/src/wallet/sqlite.h index 5352163f8a..6e5a56734c 100644 --- a/src/wallet/sqlite.h +++ b/src/wallet/sqlite.h @@ -13,7 +13,7 @@ struct bilingual_str; class SQLiteDatabase; /** RAII class that provides access to a WalletDatabase */ -class SQLiteBatch : public DatabaseBatch +class SQLiteBatch final : public DatabaseBatch { private: SQLiteDatabase& m_database; @@ -52,7 +52,7 @@ class SQLiteBatch : public DatabaseBatch /** An instance of this class represents one SQLite3 database. **/ -class SQLiteDatabase : public WalletDatabase +class SQLiteDatabase final : public WalletDatabase { private: const bool m_mock{false}; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 58ec74666d..009933a715 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1190,7 +1190,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, CWalletTx::Confirmatio MarkInputsDirty(ptx); } -void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) { +void CWallet::transactionAddedToMempool(const CTransactionRef& tx, [[maybe_unused]] uint64_t mempool_sequence) { LOCK(cs_wallet); SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0}); @@ -1200,7 +1200,7 @@ void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t memp } } -void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) { +void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, [[maybe_unused]] uint64_t mempool_sequence) { LOCK(cs_wallet); auto it = mapWallet.find(tx->GetHash()); if (it != mapWallet.end()) { @@ -3162,7 +3162,7 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve // Add tx to wallet, because if it has change it's also ours, // otherwise just for transaction history. - AddToWallet(tx, {}, [&](CWalletTx& wtx, bool new_tx) { + AddToWallet(tx, {}, [&](CWalletTx& wtx, [[maybe_unused]] bool new_tx) { CHECK_NONFATAL(wtx.mapValue.empty()); CHECK_NONFATAL(wtx.vOrderForm.empty()); wtx.mapValue = std::move(mapValue); @@ -3588,7 +3588,7 @@ void ReserveDestination::ReturnDestination() } -bool CWallet::DisplayAddress(const CTxDestination& dest) +bool CWallet::DisplayAddress([[maybe_unused]] const CTxDestination& dest) { #ifdef ENABLE_EXTERNAL_SIGNER CScript scriptPubKey = GetScriptForDestination(dest); diff --git a/src/zmq/zmqabstractnotifier.cpp b/src/zmq/zmqabstractnotifier.cpp index 90aefb0018..27b858af05 100644 --- a/src/zmq/zmqabstractnotifier.cpp +++ b/src/zmq/zmqabstractnotifier.cpp @@ -13,32 +13,32 @@ CZMQAbstractNotifier::~CZMQAbstractNotifier() assert(!psocket); } -bool CZMQAbstractNotifier::NotifyBlock(const CBlockIndex * /*CBlockIndex*/) +bool CZMQAbstractNotifier::NotifyBlock([[maybe_unused]] const CBlockIndex * /*CBlockIndex*/) { return true; } -bool CZMQAbstractNotifier::NotifyTransaction(const CTransaction &/*transaction*/) +bool CZMQAbstractNotifier::NotifyTransaction([[maybe_unused]] const CTransaction &/*transaction*/) { return true; } -bool CZMQAbstractNotifier::NotifyBlockConnect(const CBlockIndex * /*CBlockIndex*/) +bool CZMQAbstractNotifier::NotifyBlockConnect([[maybe_unused]] const CBlockIndex * /*CBlockIndex*/) { return true; } -bool CZMQAbstractNotifier::NotifyBlockDisconnect(const CBlockIndex * /*CBlockIndex*/) +bool CZMQAbstractNotifier::NotifyBlockDisconnect([[maybe_unused]] const CBlockIndex * /*CBlockIndex*/) { return true; } -bool CZMQAbstractNotifier::NotifyTransactionAcceptance(const CTransaction &/*transaction*/, uint64_t mempool_sequence) +bool CZMQAbstractNotifier::NotifyTransactionAcceptance([[maybe_unused]] const CTransaction &/*transaction*/, [[maybe_unused]] uint64_t mempool_sequence) { return true; } -bool CZMQAbstractNotifier::NotifyTransactionRemoval(const CTransaction &/*transaction*/, uint64_t mempool_sequence) +bool CZMQAbstractNotifier::NotifyTransactionRemoval([[maybe_unused]] const CTransaction &/*transaction*/, [[maybe_unused]] uint64_t mempool_sequence) { return true; } diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 86f47d71f3..5ee648ceae 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -148,7 +148,7 @@ void CZMQNotificationInterface::TransactionAddedToMempool(const CTransactionRef& }); } -void CZMQNotificationInterface::TransactionRemovedFromMempool(const CTransactionRef& ptx, MemPoolRemovalReason reason, uint64_t mempool_sequence) +void CZMQNotificationInterface::TransactionRemovedFromMempool(const CTransactionRef& ptx, [[maybe_unused]] MemPoolRemovalReason reason, uint64_t mempool_sequence) { // Called for all non-block inclusion reasons const CTransaction& tx = *ptx; diff --git a/src/zmq/zmqrpc.cpp b/src/zmq/zmqrpc.cpp index 81859f924f..cd3018fc2b 100644 --- a/src/zmq/zmqrpc.cpp +++ b/src/zmq/zmqrpc.cpp @@ -33,7 +33,7 @@ static RPCHelpMan getzmqnotifications() HelpExampleCli("getzmqnotifications", "") + HelpExampleRpc("getzmqnotifications", "") }, - [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue + [&]([[maybe_unused]] const RPCHelpMan& self, [[maybe_unused]] const JSONRPCRequest& request) -> UniValue { UniValue result(UniValue::VARR); if (g_zmq_notification_interface != nullptr) {