diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -405,18 +405,18 @@ LOCK2(cs_main, pwallet->cs_wallet); - uint256 hash; - hash.SetHex(request.params[0].get_str()); - std::vector<uint256> vHash; - vHash.push_back(hash); - std::vector<uint256> vHashOut; + TxId txid; + txid.SetHex(request.params[0].get_str()); + std::vector<TxId> txIds; + txIds.push_back(txid); + std::vector<TxId> txIdsOut; - if (pwallet->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) { + if (pwallet->ZapSelectTx(txIds, txIdsOut) != DB_LOAD_OK) { throw JSONRPCError(RPC_WALLET_ERROR, "Could not properly delete the transaction."); } - if (vHashOut.empty()) { + if (txIdsOut.empty()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction does not exist in wallet."); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1008,8 +1008,8 @@ DBErrors LoadWallet(bool &fFirstRunRet); DBErrors ZapWalletTx(std::vector<CWalletTx> &vWtx); - DBErrors ZapSelectTx(std::vector<uint256> &vHashIn, - std::vector<uint256> &vHashOut); + DBErrors ZapSelectTx(std::vector<TxId> &txIdsIn, + std::vector<TxId> &txIdsOut); bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3197,13 +3197,13 @@ return DB_LOAD_OK; } -DBErrors CWallet::ZapSelectTx(std::vector<uint256> &vHashIn, - std::vector<uint256> &vHashOut) { +DBErrors CWallet::ZapSelectTx(std::vector<TxId> &txIdsIn, + std::vector<TxId> &txIdsOut) { AssertLockHeld(cs_wallet); // mapWallet DBErrors nZapSelectTxRet = - CWalletDB(*dbw, "cr+").ZapSelectTx(vHashIn, vHashOut); - for (uint256 hash : vHashOut) { - mapWallet.erase(hash); + CWalletDB(*dbw, "cr+").ZapSelectTx(txIdsIn, txIdsOut); + for (const TxId &txid : txIdsOut) { + mapWallet.erase(txid); } if (nZapSelectTxRet == DB_NEED_REWRITE) { diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -215,11 +215,11 @@ std::list<CAccountingEntry> &acentries); DBErrors LoadWallet(CWallet *pwallet); - DBErrors FindWalletTx(std::vector<uint256> &vTxHash, + DBErrors FindWalletTx(std::vector<TxId> &txIds, std::vector<CWalletTx> &vWtx); DBErrors ZapWalletTx(std::vector<CWalletTx> &vWtx); - DBErrors ZapSelectTx(std::vector<uint256> &vHashIn, - std::vector<uint256> &vHashOut); + DBErrors ZapSelectTx(std::vector<TxId> &txIdsIn, + std::vector<TxId> &txIdsOut); /* Try to (very carefully!) recover wallet database (with a possible key * type filter) */ static bool Recover(const std::string &filename, void *callbackDataIn, diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -641,7 +641,7 @@ return result; } -DBErrors CWalletDB::FindWalletTx(std::vector<uint256> &vTxHash, +DBErrors CWalletDB::FindWalletTx(std::vector<TxId> &txIds, std::vector<CWalletTx> &vWtx) { bool fNoncriticalErrors = false; DBErrors result = DB_LOAD_OK; @@ -678,13 +678,13 @@ std::string strType; ssKey >> strType; if (strType == "tx") { - uint256 hash; - ssKey >> hash; + TxId txid; + ssKey >> txid; CWalletTx wtx; ssValue >> wtx; - vTxHash.push_back(hash); + txIds.push_back(txid); vWtx.push_back(wtx); } } @@ -702,38 +702,38 @@ return result; } -DBErrors CWalletDB::ZapSelectTx(std::vector<uint256> &vTxHashIn, - std::vector<uint256> &vTxHashOut) { +DBErrors CWalletDB::ZapSelectTx(std::vector<TxId> &txIdsIn, + std::vector<TxId> &txIdsOut) { // Build list of wallet TXs and hashes. - std::vector<uint256> vTxHash; + std::vector<TxId> txIds; std::vector<CWalletTx> vWtx; - DBErrors err = FindWalletTx(vTxHash, vWtx); + DBErrors err = FindWalletTx(txIds, vWtx); if (err != DB_LOAD_OK) { return err; } - std::sort(vTxHash.begin(), vTxHash.end()); - std::sort(vTxHashIn.begin(), vTxHashIn.end()); + std::sort(txIds.begin(), txIds.end()); + std::sort(txIdsIn.begin(), txIdsIn.end()); // Erase each matching wallet TX. bool delerror = false; - std::vector<uint256>::iterator it = vTxHashIn.begin(); - for (uint256 hash : vTxHash) { - while (it < vTxHashIn.end() && (*it) < hash) { + std::vector<TxId>::iterator it = txIdsIn.begin(); + for (const TxId &txid : txIds) { + while (it < txIdsIn.end() && (*it) < txid) { it++; } - if (it == vTxHashIn.end()) { + if (it == txIdsIn.end()) { break; } - if ((*it) == hash) { - if (!EraseTx(hash)) { + if ((*it) == txid) { + if (!EraseTx(txid)) { LogPrint(BCLog::DB, "Transaction was found for deletion but " "returned database error: %s\n", - hash.GetHex()); + txid.GetHex()); delerror = true; } - vTxHashOut.push_back(hash); + txIdsOut.push_back(txid); } } @@ -745,15 +745,15 @@ DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx> &vWtx) { // Build list of wallet TXs. - std::vector<uint256> vTxHash; - DBErrors err = FindWalletTx(vTxHash, vWtx); + std::vector<TxId> txIds; + DBErrors err = FindWalletTx(txIds, vWtx); if (err != DB_LOAD_OK) { return err; } // Erase each wallet TX. - for (uint256 &hash : vTxHash) { - if (!EraseTx(hash)) { + for (const TxId &txid : txIds) { + if (!EraseTx(txid)) { return DB_CORRUPT; } }