diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 9214e7723d3..9a79a08df9f 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -276,8 +276,7 @@ void TransactionTableModel::updateAmountColumnTitle() void TransactionTableModel::updateTransaction(const QString &hash, int status, bool showTransaction) { - uint256 updated; - updated.SetHexDeprecated(hash.toStdString()); + Txid updated = Txid::FromHex(hash.toStdString()).value(); priv->updateWallet(walletModel->wallet(), updated, status, showTransaction); } diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 90a53fb2bbd..574824b4190 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -394,9 +394,13 @@ void TransactionView::contextualMenu(const QPoint &point) if (selection.empty()) return; - // check if transaction can be abandoned, disable context menu action in case it doesn't - uint256 hash; - hash.SetHexDeprecated(selection.at(0).data(TransactionTableModel::TxHashRole).toString().toStdString()); + // If the hash from the TxHashRole (QVariant / QString) is invalid, exit + QString hashQStr = selection.at(0).data(TransactionTableModel::TxHashRole).toString(); + std::optional maybeHash = Txid::FromHex(hashQStr.toStdString()); + if (!maybeHash) + return; + + Txid hash = *maybeHash; abandonAction->setEnabled(model->wallet().transactionCanBeAbandoned(hash)); bumpFeeAction->setEnabled(model->wallet().transactionCanBeBumped(hash)); copyAddressAction->setEnabled(GUIUtil::hasEntryData(transactionView, 0, TransactionTableModel::AddressRole)); @@ -414,9 +418,8 @@ void TransactionView::abandonTx() 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.SetHexDeprecated(hashQStr.toStdString()); + Txid hash = Txid::FromHex(hashQStr.toStdString()).value(); // Abandon the wallet transaction over the walletModel model->wallet().abandonTransaction(hash); @@ -429,9 +432,8 @@ void TransactionView::bumpFee([[maybe_unused]] bool checked) 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.SetHexDeprecated(hashQStr.toStdString()); + Txid hash = Txid::FromHex(hashQStr.toStdString()).value(); // Bump tx fee over the walletModel uint256 newHash;