diff options
-rwxr-xr-x | ci/test/06_script_b.sh | 1 | ||||
-rw-r--r-- | src/.clang-tidy | 7 | ||||
-rw-r--r-- | src/node/mempool_args.cpp | 1 | ||||
-rw-r--r-- | src/rpc/blockchain.cpp | 2 | ||||
-rw-r--r-- | src/script/descriptor.cpp | 6 | ||||
-rw-r--r-- | src/test/fuzz/txorphan.cpp | 1 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 6 | ||||
-rw-r--r-- | src/threadinterrupt.h | 1 | ||||
-rw-r--r-- | src/univalue/include/univalue.h | 8 | ||||
-rw-r--r-- | src/univalue/lib/univalue.cpp | 20 | ||||
-rw-r--r-- | src/util/bip32.cpp | 2 | ||||
-rw-r--r-- | src/util/message.cpp | 1 | ||||
-rw-r--r-- | src/util/strencodings.cpp | 1 | ||||
-rw-r--r-- | src/util/string.cpp | 3 | ||||
-rw-r--r-- | src/util/string.h | 1 | ||||
-rw-r--r-- | src/wallet/spend.cpp | 2 | ||||
-rwxr-xr-x | test/functional/rpc_fundrawtransaction.py | 4 | ||||
-rwxr-xr-x | test/functional/wallet_basic.py | 10 | ||||
-rwxr-xr-x | test/functional/wallet_bumpfee.py | 2 | ||||
-rwxr-xr-x | test/functional/wallet_groups.py | 2 |
20 files changed, 39 insertions, 42 deletions
diff --git a/ci/test/06_script_b.sh b/ci/test/06_script_b.sh index f1b0c1ac15..5bdb392ba3 100755 --- a/ci/test/06_script_b.sh +++ b/ci/test/06_script_b.sh @@ -65,6 +65,7 @@ if [ "${RUN_TIDY}" = "true" ]; then " src/util/serfloat.cpp"\ " src/util/spanparsing.cpp"\ " src/util/strencodings.cpp"\ + " src/util/string.cpp"\ " src/util/syserror.cpp"\ " src/util/url.cpp"\ " -p . ${MAKEJOBS} -- -Xiwyu --cxx17ns -Xiwyu --mapping_file=${BASE_BUILD_DIR}/bitcoin-$HOST/contrib/devtools/iwyu/bitcoin.core.imp" diff --git a/src/.clang-tidy b/src/.clang-tidy index f59f80f8ce..9d78ccc959 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -1,21 +1,28 @@ Checks: ' -*, bugprone-argument-comment, +bugprone-use-after-move, misc-unused-using-decls, modernize-use-default-member-init, modernize-use-nullptr, performance-for-range-copy, +performance-move-const-arg, performance-unnecessary-copy-initialization, readability-redundant-declaration, readability-redundant-string-init, ' WarningsAsErrors: ' bugprone-argument-comment, +bugprone-use-after-move, misc-unused-using-decls, modernize-use-default-member-init, modernize-use-nullptr, performance-for-range-copy, +performance-move-const-arg, performance-unnecessary-copy-initialization, readability-redundant-declaration, readability-redundant-string-init, ' +CheckOptions: + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: false diff --git a/src/node/mempool_args.cpp b/src/node/mempool_args.cpp index cb2466804a..8c929e5e0d 100644 --- a/src/node/mempool_args.cpp +++ b/src/node/mempool_args.cpp @@ -12,6 +12,7 @@ #include <logging.h> #include <policy/feerate.h> #include <policy/policy.h> +#include <script/standard.h> #include <tinyformat.h> #include <util/error.h> #include <util/moneystr.h> diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 8f116a05ef..f57915e805 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2129,7 +2129,7 @@ static RPCHelpMan scantxoutset() for (const UniValue& scanobject : request.params[1].get_array().getValues()) { FlatSigningProvider provider; auto scripts = EvalDescriptorStringOrObject(scanobject, provider); - for (const auto& script : scripts) { + for (CScript& script : scripts) { std::string inferred = InferDescriptor(script, provider)->ToString(); needles.emplace(script); descriptors.emplace(std::move(script), std::move(inferred)); diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 434e106dad..93f6ec243c 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -572,7 +572,7 @@ public: if (pos++) ret += ","; std::string tmp; if (!scriptarg->ToStringHelper(arg, tmp, type, cache)) return false; - ret += std::move(tmp); + ret += tmp; } return true; } @@ -596,7 +596,7 @@ public: tmp = pubkey->ToString(); break; } - ret += std::move(tmp); + ret += tmp; } std::string subscript; if (!ToStringSubScriptHelper(arg, subscript, type, cache)) return false; @@ -912,7 +912,7 @@ protected: } std::string tmp; if (!m_subdescriptor_args[pos]->ToStringHelper(arg, tmp, type, cache)) return false; - ret += std::move(tmp); + ret += tmp; while (!path.empty() && path.back()) { if (path.size() > 1) ret += '}'; path.pop_back(); diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp index 7580651371..943f3f5fdf 100644 --- a/src/test/fuzz/txorphan.cpp +++ b/src/test/fuzz/txorphan.cpp @@ -19,7 +19,6 @@ #include <util/check.h> #include <util/time.h> -#include <algorithm> #include <cstdint> #include <memory> #include <set> diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 61ceca9837..0f9f332dc6 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -2511,13 +2511,13 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) auto v2 = Vector(std::move(t2)); BOOST_CHECK_EQUAL(v2.size(), 1U); - BOOST_CHECK(v2[0].origin == &t2); + BOOST_CHECK(v2[0].origin == &t2); // NOLINT(*-use-after-move) BOOST_CHECK_EQUAL(v2[0].copies, 0); auto v3 = Vector(t1, std::move(t2)); BOOST_CHECK_EQUAL(v3.size(), 2U); BOOST_CHECK(v3[0].origin == &t1); - BOOST_CHECK(v3[1].origin == &t2); + BOOST_CHECK(v3[1].origin == &t2); // NOLINT(*-use-after-move) BOOST_CHECK_EQUAL(v3[0].copies, 1); BOOST_CHECK_EQUAL(v3[1].copies, 0); @@ -2525,7 +2525,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector) BOOST_CHECK_EQUAL(v4.size(), 3U); BOOST_CHECK(v4[0].origin == &t1); BOOST_CHECK(v4[1].origin == &t2); - BOOST_CHECK(v4[2].origin == &t3); + BOOST_CHECK(v4[2].origin == &t3); // NOLINT(*-use-after-move) BOOST_CHECK_EQUAL(v4[0].copies, 1); BOOST_CHECK_EQUAL(v4[1].copies, 1); BOOST_CHECK_EQUAL(v4[2].copies, 0); diff --git a/src/threadinterrupt.h b/src/threadinterrupt.h index 363aab39ce..979bc2ee3e 100644 --- a/src/threadinterrupt.h +++ b/src/threadinterrupt.h @@ -6,6 +6,7 @@ #define BITCOIN_THREADINTERRUPT_H #include <sync.h> +#include <threadsafety.h> #include <atomic> #include <chrono> diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index 8ba6fd5425..ccaf56a271 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -80,14 +80,14 @@ public: bool isArray() const { return (typ == VARR); } bool isObject() const { return (typ == VOBJ); } - void push_back(const UniValue& val); + void push_back(UniValue val); void push_backV(const std::vector<UniValue>& vec); template <class It> void push_backV(It first, It last); - void __pushKV(const std::string& key, const UniValue& val); - void pushKV(const std::string& key, const UniValue& val); - void pushKVs(const UniValue& obj); + void __pushKV(std::string key, UniValue val); + void pushKV(std::string key, UniValue val); + void pushKVs(UniValue obj); std::string write(unsigned int prettyIndent = 0, unsigned int indentLevel = 0) const; diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp index 55e777b8ae..12a434dd0e 100644 --- a/src/univalue/lib/univalue.cpp +++ b/src/univalue/lib/univalue.cpp @@ -101,11 +101,11 @@ void UniValue::setObject() typ = VOBJ; } -void UniValue::push_back(const UniValue& val_) +void UniValue::push_back(UniValue val) { checkType(VARR); - values.push_back(val_); + values.push_back(std::move(val)); } void UniValue::push_backV(const std::vector<UniValue>& vec) @@ -115,32 +115,32 @@ void UniValue::push_backV(const std::vector<UniValue>& vec) values.insert(values.end(), vec.begin(), vec.end()); } -void UniValue::__pushKV(const std::string& key, const UniValue& val_) +void UniValue::__pushKV(std::string key, UniValue val) { checkType(VOBJ); - keys.push_back(key); - values.push_back(val_); + keys.push_back(std::move(key)); + values.push_back(std::move(val)); } -void UniValue::pushKV(const std::string& key, const UniValue& val_) +void UniValue::pushKV(std::string key, UniValue val) { checkType(VOBJ); size_t idx; if (findKey(key, idx)) - values[idx] = val_; + values[idx] = std::move(val); else - __pushKV(key, val_); + __pushKV(std::move(key), std::move(val)); } -void UniValue::pushKVs(const UniValue& obj) +void UniValue::pushKVs(UniValue obj) { checkType(VOBJ); obj.checkType(VOBJ); for (size_t i = 0; i < obj.keys.size(); i++) - __pushKV(obj.keys[i], obj.values.at(i)); + __pushKV(std::move(obj.keys.at(i)), std::move(obj.values.at(i))); } void UniValue::getObjMap(std::map<std::string,UniValue>& kv) const diff --git a/src/util/bip32.cpp b/src/util/bip32.cpp index 39e43eeb31..796af4a544 100644 --- a/src/util/bip32.cpp +++ b/src/util/bip32.cpp @@ -6,12 +6,10 @@ #include <util/bip32.h> #include <util/strencodings.h> -#include <algorithm> #include <cstdint> #include <cstdio> #include <sstream> - bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypath) { std::stringstream ss(keypath_str); diff --git a/src/util/message.cpp b/src/util/message.cpp index 028251a5a8..7d6f3403f4 100644 --- a/src/util/message.cpp +++ b/src/util/message.cpp @@ -8,7 +8,6 @@ #include <key_io.h> #include <pubkey.h> #include <script/standard.h> -#include <serialize.h> #include <uint256.h> #include <util/message.h> #include <util/strencodings.h> diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 303e19beec..b5ac151374 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -6,7 +6,6 @@ #include <span.h> #include <util/strencodings.h> -#include <algorithm> #include <array> #include <cassert> #include <cstring> diff --git a/src/util/string.cpp b/src/util/string.cpp index db6dbe4135..e994c85f1c 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -6,10 +6,9 @@ #include <regex> #include <string> -#include <utility> void ReplaceAll(std::string& in_out, const std::string& search, const std::string& substitute) { if (search.empty()) return; - in_out = std::regex_replace(in_out, std::regex(std::move(search)), substitute); + in_out = std::regex_replace(in_out, std::regex(search), substitute); } diff --git a/src/util/string.h b/src/util/string.h index 0bcf7d760f..9b4c9a7e28 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -7,7 +7,6 @@ #include <util/spanparsing.h> -#include <algorithm> #include <array> #include <cstdint> #include <cstring> diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 92cf771358..d84310c323 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -353,7 +353,7 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet) std::map<CTxDestination, std::vector<COutput>> result; - for (const COutput& coin : AvailableCoinsListUnspent(wallet).All()) { + for (COutput& coin : AvailableCoinsListUnspent(wallet).All()) { CTxDestination address; if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable)) && ExtractDestination(FindNonChangeParentOutput(wallet, coin.outpoint).scriptPubKey, address)) { diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 5a870de6c7..2c33617750 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -635,7 +635,7 @@ class RawTransactionsTest(BitcoinTestFramework): self.log.info("Test fundrawtxn fee with many inputs") # Empty node1, send some small coins from node0 to node1. - self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) + self.nodes[1].sendall(recipients=[self.nodes[0].getnewaddress()]) self.generate(self.nodes[1], 1) for _ in range(20): @@ -661,7 +661,7 @@ class RawTransactionsTest(BitcoinTestFramework): self.log.info("Test fundrawtxn sign+send with many inputs") # Again, empty node1, send some small coins from node0 to node1. - self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) + self.nodes[1].sendall(recipients=[self.nodes[0].getnewaddress()]) self.generate(self.nodes[1], 1) for _ in range(20): diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index ed603a2857..5d3d78c2dc 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -585,15 +585,9 @@ class WalletTest(BitcoinTestFramework): # ==Check that wallet prefers to use coins that don't exceed mempool limits ===== - # Get all non-zero utxos together + # Get all non-zero utxos together and split into two chains chain_addrs = [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()] - singletxid = self.nodes[0].sendtoaddress(chain_addrs[0], self.nodes[0].getbalance(), "", "", True) - self.generate(self.nodes[0], 1, sync_fun=self.no_op) - node0_balance = self.nodes[0].getbalance() - # Split into two chains - rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')}) - signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx) - singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0) + self.nodes[0].sendall(recipients=chain_addrs) self.generate(self.nodes[0], 1, sync_fun=self.no_op) # Make a long chain of unconfirmed payments without hitting mempool limit diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index bd3943d66b..f4ae697292 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -624,7 +624,7 @@ def test_no_more_inputs_fails(self, rbf_node, dest_address): # feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient self.generatetoaddress(rbf_node, 1, dest_address) # spend all funds, no change output - rbfid = rbf_node.sendtoaddress(rbf_node.getnewaddress(), rbf_node.getbalance(), "", "", True) + rbfid = rbf_node.sendall(recipients=[rbf_node.getnewaddress()])['txid'] assert_raises_rpc_error(-4, "Unable to create transaction. Insufficient funds", rbf_node.bumpfee, rbfid) self.clear_mempool() diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py index 866c411dba..9f0f694a3e 100755 --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -154,7 +154,7 @@ class WalletGroupTest(BitcoinTestFramework): assert_equal(2, len(tx6["vout"])) # Empty out node2's wallet - self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=self.nodes[2].getbalance(), subtractfeefromamount=True) + self.nodes[2].sendall(recipients=[self.nodes[0].getnewaddress()]) self.sync_all() self.generate(self.nodes[0], 1) |