diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2024-10-09 15:10:35 +0200 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2024-11-15 17:16:54 +0100 |
commit | fa3e074304780549b1e7972217930e34fa55f59a (patch) | |
tree | 99dade1c659723a250a7a299be2ed337639689dd | |
parent | fa72646f2b197810a324cb0544d9a1fac37d3f9c (diff) |
refactor: Tidy fixups
Requested by clang-tidy:
src/wallet/salvage.cpp:119:18: error: use emplace_back instead of push_back [modernize-use-emplace,-warnings-as-errors]
119 | warnings.push_back(Untranslated("Salvage: Database salvage found errors, all data may not be recoverable."));
| ^~~~~~~~~~
| emplace_back(
-rw-r--r-- | src/wallet/feebumper.cpp | 24 | ||||
-rw-r--r-- | src/wallet/salvage.cpp | 6 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 3184d0f3b0..68ad58d284 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -24,24 +24,24 @@ namespace wallet { static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, bool require_mine, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) { if (wallet.HasWalletSpend(wtx.tx)) { - errors.push_back(Untranslated("Transaction has descendants in the wallet")); + errors.emplace_back(Untranslated("Transaction has descendants in the wallet")); return feebumper::Result::INVALID_PARAMETER; } { if (wallet.chain().hasDescendantsInMempool(wtx.GetHash())) { - errors.push_back(Untranslated("Transaction has descendants in the mempool")); + errors.emplace_back(Untranslated("Transaction has descendants in the mempool")); return feebumper::Result::INVALID_PARAMETER; } } if (wallet.GetTxDepthInMainChain(wtx) != 0) { - errors.push_back(Untranslated("Transaction has been mined, or is conflicted with a mined transaction")); + errors.emplace_back(Untranslated("Transaction has been mined, or is conflicted with a mined transaction")); return feebumper::Result::WALLET_ERROR; } if (!SignalsOptInRBF(*wtx.tx)) { - errors.push_back(Untranslated("Transaction is not BIP 125 replaceable")); + errors.emplace_back(Untranslated("Transaction is not BIP 125 replaceable")); return feebumper::Result::WALLET_ERROR; } @@ -55,7 +55,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet // if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee) isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE; if (!AllInputsMine(wallet, *wtx.tx, filter)) { - errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet")); + errors.emplace_back(Untranslated("Transaction contains inputs that don't belong to this wallet")); return feebumper::Result::WALLET_ERROR; } } @@ -167,7 +167,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo { // For now, cannot specify both new outputs to use and an output index to send change if (!outputs.empty() && original_change_index.has_value()) { - errors.push_back(Untranslated("The options 'outputs' and 'original_change_index' are incompatible. You can only either specify a new set of outputs, or designate a change output to be recycled.")); + errors.emplace_back(Untranslated("The options 'outputs' and 'original_change_index' are incompatible. You can only either specify a new set of outputs, or designate a change output to be recycled.")); return Result::INVALID_PARAMETER; } @@ -178,14 +178,14 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo errors.clear(); auto it = wallet.mapWallet.find(txid); if (it == wallet.mapWallet.end()) { - errors.push_back(Untranslated("Invalid or non-wallet transaction id")); + errors.emplace_back(Untranslated("Invalid or non-wallet transaction id")); return Result::INVALID_ADDRESS_OR_KEY; } const CWalletTx& wtx = it->second; // Make sure that original_change_index is valid if (original_change_index.has_value() && original_change_index.value() >= wtx.tx->vout.size()) { - errors.push_back(Untranslated("Change position is out of range")); + errors.emplace_back(Untranslated("Change position is out of range")); return Result::INVALID_PARAMETER; } @@ -201,7 +201,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo for (const CTxIn& txin : wtx.tx->vin) { const Coin& coin = coins.at(txin.prevout); if (coin.out.IsNull()) { - errors.push_back(Untranslated(strprintf("%s:%u is already spent", txin.prevout.hash.GetHex(), txin.prevout.n))); + errors.emplace_back(Untranslated(strprintf("%s:%u is already spent", txin.prevout.hash.GetHex(), txin.prevout.n))); return Result::MISC_ERROR; } PreselectedInput& preset_txin = new_coin_control.Select(txin.prevout); @@ -319,7 +319,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo auto res = CreateTransaction(wallet, recipients, /*change_pos=*/std::nullopt, new_coin_control, false); if (!res) { - errors.push_back(Untranslated("Unable to create transaction.") + Untranslated(" ") + util::ErrorString(res)); + errors.emplace_back(Untranslated("Unable to create transaction.") + Untranslated(" ") + util::ErrorString(res)); return Result::WALLET_ERROR; } @@ -361,7 +361,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti } auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid); if (it == wallet.mapWallet.end()) { - errors.push_back(Untranslated("Invalid or non-wallet transaction id")); + errors.emplace_back(Untranslated("Invalid or non-wallet transaction id")); return Result::MISC_ERROR; } const CWalletTx& oldWtx = it->second; @@ -382,7 +382,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti // mark the original tx as bumped bumped_txid = tx->GetHash(); if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) { - errors.push_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced")); + errors.emplace_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced")); } return Result::OK; } diff --git a/src/wallet/salvage.cpp b/src/wallet/salvage.cpp index 0ac1b66897..457119396a 100644 --- a/src/wallet/salvage.cpp +++ b/src/wallet/salvage.cpp @@ -117,7 +117,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil Db db(env->dbenv.get(), 0); result = db.verify(newFilename.c_str(), nullptr, &strDump, DB_SALVAGE | DB_AGGRESSIVE); if (result == DB_VERIFY_BAD) { - warnings.push_back(Untranslated("Salvage: Database salvage found errors, all data may not be recoverable.")); + warnings.emplace_back(Untranslated("Salvage: Database salvage found errors, all data may not be recoverable.")); } if (result != 0 && result != DB_VERIFY_BAD) { error = strprintf(Untranslated("Salvage: Database salvage failed with result %d."), result); @@ -144,7 +144,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil break; getline(strDump, valueHex); if (valueHex == DATA_END) { - warnings.push_back(Untranslated("Salvage: WARNING: Number of keys in data does not match number of values.")); + warnings.emplace_back(Untranslated("Salvage: WARNING: Number of keys in data does not match number of values.")); break; } salvagedData.emplace_back(ParseHex(keyHex), ParseHex(valueHex)); @@ -153,7 +153,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil bool fSuccess; if (keyHex != DATA_END) { - warnings.push_back(Untranslated("Salvage: WARNING: Unexpected end of file while reading salvage output.")); + warnings.emplace_back(Untranslated("Salvage: WARNING: Unexpected end of file while reading salvage output.")); fSuccess = false; } else { fSuccess = (result == 0); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 82c0d2caf1..c0341a8111 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -290,7 +290,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s // Legacy wallets are being deprecated, warn if the loaded wallet is legacy if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { - warnings.push_back(_("Wallet loaded successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. Legacy wallets can be migrated to a descriptor wallet with migratewallet.")); + warnings.emplace_back(_("Wallet loaded successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. Legacy wallets can be migrated to a descriptor wallet with migratewallet.")); } NotifyWalletLoaded(context, wallet); @@ -483,7 +483,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string& // Legacy wallets are being deprecated, warn if a newly created wallet is legacy if (!(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) { - warnings.push_back(_("Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future.")); + warnings.emplace_back(_("Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future.")); } status = DatabaseStatus::SUCCESS; |