diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -404,18 +404,21 @@ } void TransactionView::abandonTx() { - if (!transactionView || !transactionView->selectionModel()) return; + if (!transactionView || !transactionView->selectionModel()) { + return; + } QModelIndexList selection = transactionView->selectionModel()->selectedRows(0); // get the hash from the TxHashRole (QVariant / QString) - uint256 hash; QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString(); - hash.SetHex(hashQStr.toStdString()); + + TxId txid; + txid.SetHex(hashQStr.toStdString()); // Abandon the wallet transaction over the walletModel - model->abandonTransaction(hash); + model->abandonTransaction(txid); // Update the table model->getTransactionTableModel()->updateTransaction(hashQStr, CT_UPDATED, diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -223,7 +223,7 @@ const std::string &sRequest); bool transactionCanBeAbandoned(const TxId &txid) const; - bool abandonTransaction(uint256 hash) const; + bool abandonTransaction(const TxId &txid) const; static bool isWalletEnabled(); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -686,9 +686,9 @@ return true; } -bool WalletModel::abandonTransaction(uint256 hash) const { +bool WalletModel::abandonTransaction(const TxId &txid) const { LOCK2(cs_main, wallet->cs_wallet); - return wallet->AbandonTransaction(hash); + return wallet->AbandonTransaction(txid); } bool WalletModel::isWalletEnabled() { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1101,7 +1101,7 @@ * Mark a transaction (and it in-wallet descendants) as abandoned so its * inputs may be respent. */ - bool AbandonTransaction(const uint256 &hashTx); + bool AbandonTransaction(const TxId &txid); /* Returns the wallets help message */ static std::string GetWalletHelpString(bool showDebug); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1194,25 +1194,25 @@ return false; } -bool CWallet::AbandonTransaction(const uint256 &hashTx) { +bool CWallet::AbandonTransaction(const TxId &txid) { LOCK2(cs_main, cs_wallet); CWalletDB walletdb(*dbw, "r+"); - std::set todo; - std::set done; + std::set todo; + std::set done; // Can't mark abandoned if confirmed or in mempool. - assert(mapWallet.count(hashTx)); - CWalletTx &origtx = mapWallet[hashTx]; + assert(mapWallet.count(txid)); + CWalletTx &origtx = mapWallet[txid]; if (origtx.GetDepthInMainChain() > 0 || origtx.InMempool()) { return false; } - todo.insert(hashTx); + todo.insert(txid); while (!todo.empty()) { - uint256 now = *todo.begin(); + const TxId now = *todo.begin(); todo.erase(now); done.insert(now); assert(mapWallet.count(now)); @@ -1234,7 +1234,7 @@ // Iterate over all its outputs, and mark transactions in the wallet // that spend them abandoned too. TxSpends::const_iterator iter = - mapTxSpends.lower_bound(COutPoint(hashTx, 0)); + mapTxSpends.lower_bound(COutPoint(txid, 0)); while (iter != mapTxSpends.end() && iter->first.GetTxId() == now) { if (!done.count(iter->second)) { todo.insert(iter->second);