Skip to content

Commit

Permalink
[qt] TransactionView: highlight replacement tx after fee bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Aug 1, 2018
1 parent c88529a commit d795c61
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/qt/transactionview.cpp
Expand Up @@ -19,6 +19,7 @@

#include <ui_interface.h>

#include <QApplication>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QDesktopServices>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/qt/transactionview.h
Expand Up @@ -110,6 +110,8 @@ private Q_SLOTS:
/** 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);
Expand Down
5 changes: 2 additions & 3 deletions src/qt/walletmodel.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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") + "<br />(" +
QString::fromStdString(errors[0])+")");
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletmodel.h
Expand Up @@ -194,7 +194,7 @@ class WalletModel : public QObject
void loadReceiveRequests(std::vector<std::string>& 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;
Expand Down

0 comments on commit d795c61

Please sign in to comment.