From d795c610d3095eeff1bfe5c1a34877cf0a841823 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Wed, 1 Aug 2018 18:43:46 +0200 Subject: [PATCH] [qt] TransactionView: highlight replacement tx after fee bump --- src/qt/transactionview.cpp | 13 ++++++++++++- src/qt/transactionview.h | 2 ++ src/qt/walletmodel.cpp | 5 ++--- src/qt/walletmodel.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index e60a38793..2fd2b815a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -198,6 +199,11 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); + + // Highlight transaction after fee bump + connect(this, &TransactionView::bumpedFee, [this](const uint256& txid) { + focusTransaction(txid); + }); } void TransactionView::setModel(WalletModel *_model) @@ -428,9 +434,14 @@ void TransactionView::bumpFee() hash.SetHex(hashQStr.toStdString()); // Bump tx fee over the walletModel - if (model->bumpFee(hash)) { + uint256 newHash; + if (model->bumpFee(hash, newHash)) { // Update the table + transactionView->selectionModel()->clearSelection(); model->getTransactionTableModel()->updateTransaction(hashQStr, CT_UPDATED, true); + + qApp->processEvents(); + Q_EMIT bumpedFee(newHash); } } diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 66dc5bc86..9819fb432 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -110,6 +110,8 @@ Q_SIGNALS: /** Fired when a message should be reported to the user */ void message(const QString &title, const QString &message, unsigned int style); + void bumpedFee(const uint256& txid); + public Q_SLOTS: void chooseDate(int idx); void chooseType(int idx); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index cd55b40b7..17df1bd4d 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -492,7 +492,7 @@ bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t return m_wallet->addDestData(dest, key, sRequest); } -bool WalletModel::bumpFee(uint256 hash) +bool WalletModel::bumpFee(uint256 hash, uint256& new_hash) { CCoinControl coin_control; coin_control.m_signal_bip125_rbf = true; @@ -544,8 +544,7 @@ bool WalletModel::bumpFee(uint256 hash) return false; } // commit the bumped transaction - uint256 txid; - if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, txid)) { + if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) { QMessageBox::critical(0, tr("Fee bump error"), tr("Could not commit transaction") + "
(" + QString::fromStdString(errors[0])+")"); return false; diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index d8935c2fa..2d53a7dc4 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -194,7 +194,7 @@ public: void loadReceiveRequests(std::vector& vReceiveRequests); bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest); - bool bumpFee(uint256 hash); + bool bumpFee(uint256 hash, uint256& new_hash); static bool isWalletEnabled(); bool privateKeysDisabled() const;