diff --git a/src/.clang-tidy b/src/.clang-tidy
index da53a588c2e..011536498e1 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -25,6 +25,7 @@ performance-*,
-performance-noexcept-move-constructor,
-performance-unnecessary-value-param,
readability-const-return-type,
+readability-container-contains,
readability-redundant-declaration,
readability-redundant-string-init,
'
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 93d31ee6054..918d0af95d1 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -124,7 +124,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
{
strHTML += "" + tr("Source") + ": " + tr("Generated") + "
";
}
- else if (wtx.value_map.count("from") && !wtx.value_map["from"].empty())
+ else if (wtx.value_map.contains("from") && !wtx.value_map["from"].empty())
{
// Online transaction
strHTML += "" + tr("From") + ": " + GUIUtil::HtmlEscape(wtx.value_map["from"]) + "
";
@@ -157,7 +157,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
//
// To
//
- if (wtx.value_map.count("to") && !wtx.value_map["to"].empty())
+ if (wtx.value_map.contains("to") && !wtx.value_map["to"].empty())
{
// Online transaction
std::string strAddress = wtx.value_map["to"];
@@ -212,7 +212,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
if (toSelf && all_from_me)
continue;
- if (!wtx.value_map.count("to") || wtx.value_map["to"].empty())
+ if (!wtx.value_map.contains("to") || wtx.value_map["to"].empty())
{
// Offline transaction
CTxDestination address;
@@ -273,9 +273,9 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
//
// Message
//
- if (wtx.value_map.count("message") && !wtx.value_map["message"].empty())
+ if (wtx.value_map.contains("message") && !wtx.value_map["message"].empty())
strHTML += "
" + tr("Message") + ":
" + GUIUtil::HtmlEscape(wtx.value_map["message"], true) + "
";
- if (wtx.value_map.count("comment") && !wtx.value_map["comment"].empty())
+ if (wtx.value_map.contains("comment") && !wtx.value_map["comment"].empty())
strHTML += "
" + tr("Comment") + ":
" + GUIUtil::HtmlEscape(wtx.value_map["comment"], true) + "
";
strHTML += "" + tr("Transaction ID") + ": " + rec->getTxHash() + "
";
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index e710f5909cb..e6c0363911c 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -846,12 +846,12 @@ static RPCHelpMan getblocktemplate()
const Consensus::Params& consensusParams = chainman.GetParams().GetConsensus();
// GBT must be called with 'signet' set in the rules for signet chains
- if (consensusParams.signet_blocks && setClientRules.count("signet") != 1) {
+ if (consensusParams.signet_blocks && !setClientRules.contains("signet")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the signet rule set (call with {\"rules\": [\"segwit\", \"signet\"]})");
}
// GBT must be called with 'segwit' set in the rules
- if (setClientRules.count("segwit") != 1) {
+ if (!setClientRules.contains("segwit")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the segwit rule set (call with {\"rules\": [\"segwit\"]})");
}
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 6274e368497..89fc6a11c89 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -60,7 +60,7 @@ script_verify_flags ParseScriptFlags(std::string strFlags)
std::vector words = SplitString(strFlags, ',');
for (const std::string& word : words)
{
- if (!mapFlagNames.count(word)) {
+ if (!mapFlagNames.contains(word)) {
BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
continue;
}
@@ -90,7 +90,7 @@ bool CheckTxScripts(const CTransaction& tx, const std::map&
ScriptError err = expect_valid ? SCRIPT_ERR_UNKNOWN_ERROR : SCRIPT_ERR_OK;
for (unsigned int i = 0; i < tx.vin.size() && tx_valid; ++i) {
const CTxIn input = tx.vin[i];
- const CAmount amount = map_prevout_values.count(input.prevout) ? map_prevout_values.at(input.prevout) : 0;
+ const CAmount amount = map_prevout_values.contains(input.prevout) ? map_prevout_values.at(input.prevout) : 0;
try {
tx_valid = VerifyScript(input.scriptSig, map_prevout_scriptPubKeys.at(input.prevout),
&input.scriptWitness, flags, TransactionSignatureChecker(&tx, i, amount, txdata, MissingDataBehavior::ASSERT_FAIL), &err);
diff --git a/src/wallet/test/fuzz/scriptpubkeyman.cpp b/src/wallet/test/fuzz/scriptpubkeyman.cpp
index 3edf2265c6e..ea1431a7cf0 100644
--- a/src/wallet/test/fuzz/scriptpubkeyman.cpp
+++ b/src/wallet/test/fuzz/scriptpubkeyman.cpp
@@ -125,7 +125,7 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm)
[&] {
const CScript script{ConsumeScript(fuzzed_data_provider)};
if (spk_manager->IsMine(script)) {
- assert(spk_manager->GetScriptPubKeys().count(script));
+ assert(spk_manager->GetScriptPubKeys().contains(script));
}
},
[&] {