From a60326a593a39d1904cdef47442f61e9e2a67e96 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sat, 22 May 2021 20:13:48 +0200 Subject: [PATCH] Improve warning message on remote node attack --- src/mainwindow.cpp | 20 +++++++++++++++----- src/model/NodeModel.cpp | 10 +++++++++- src/utils/nodes.cpp | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1a81f29..5429cb7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -565,10 +565,10 @@ void MainWindow::onConnectionStatusChanged(int status) void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVector &address) { auto tx_status = tx->status(); - auto err = QString("Can't create transaction: "); + QString err{"Can't create transaction: "}; - if(tx_status != PendingTransaction::Status_Ok){ - auto tx_err = tx->errorString(); + if (tx_status != PendingTransaction::Status_Ok){ + QString tx_err = tx->errorString(); qCritical() << tx_err; if (m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_WrongVersion) @@ -576,15 +576,25 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVecto else err = QString("%1 %2").arg(err).arg(tx_err); + if (tx_err.contains("Daemon response did not include the requested real output")) { + QString currentNode = m_ctx->nodes->connection().toAddress(); + + err += QString("\nYou are currently connected to: %1\n\n" + "This node may be acting maliciously. You are strongly recommended to disconnect from this node." + "Please report this incident to dev@featherwallet.org, #feather on OFTC or /r/FeatherWallet.").arg(currentNode); + } + qDebug() << Q_FUNC_INFO << err; this->displayWalletErrorMsg(err); m_ctx->wallet->disposeTransaction(tx); - } else if (tx->txCount() == 0) { + } + else if (tx->txCount() == 0) { err = QString("%1 %2").arg(err).arg("No unmixable outputs to sweep."); qDebug() << Q_FUNC_INFO << err; this->displayWalletErrorMsg(err); m_ctx->wallet->disposeTransaction(tx); - } else { + } + else { const auto &description = m_ctx->tmpTxDescription; // Show advanced dialog on multi-destination transactions diff --git a/src/model/NodeModel.cpp b/src/model/NodeModel.cpp index 6224d0b..040d4ce 100644 --- a/src/model/NodeModel.cpp +++ b/src/model/NodeModel.cpp @@ -69,7 +69,15 @@ QVariant NodeModel::data(const QModelIndex &index, int role) const { } } } - else if(role == Qt::BackgroundRole) { + else if (role == Qt::ToolTipRole) { + switch (index.column()) { + case NodeModel::URL: { + if (node.isActive) + return QString("Feather is connected to this node."); + } + } + } + else if (role == Qt::BackgroundRole) { if (node.isConnecting) return QBrush(ColorScheme::YELLOW.asColor(true)); else if (node.isActive) diff --git a/src/utils/nodes.cpp b/src/utils/nodes.cpp index 8646262..e477fd2 100644 --- a/src/utils/nodes.cpp +++ b/src/utils/nodes.cpp @@ -229,7 +229,7 @@ void Nodes::autoConnect(bool forceReconnect) { } // try a connect - auto node = this->pickEligibleNode(); + FeatherNode node = this->pickEligibleNode(); this->connectToNode(node); return; }