From b0a64231b96bc778d977189b7e8b67b9db04d7e2 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sun, 6 Oct 2024 17:19:45 +0200 Subject: [PATCH] txinfo: warn if integrated address is missing --- monero | 2 +- src/dialog/TxInfoDialog.cpp | 16 ++++++++++++++++ src/dialog/TxInfoDialog.ui | 20 +++++++++++++++++++- src/libwalletqt/TransactionHistory.cpp | 6 +++--- src/libwalletqt/rows/TransactionRow.cpp | 4 ++++ src/libwalletqt/rows/TransactionRow.h | 1 + 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/monero b/monero index 16e051c..d50ba72 160000 --- a/monero +++ b/monero @@ -1 +1 @@ -Subproject commit 16e051c8a880a63aacdd217f24c55f9f6154bb00 +Subproject commit d50ba728d79cc3a96c928f7736503268ad567cba diff --git a/src/dialog/TxInfoDialog.cpp b/src/dialog/TxInfoDialog.cpp index e014cb1..a9cd5b6 100644 --- a/src/dialog/TxInfoDialog.cpp +++ b/src/dialog/TxInfoDialog.cpp @@ -70,10 +70,14 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *pare ui->frameInputs->hide(); // } + ui->frame_destinationsWarning->hide(); + QTextCursor cursor = ui->outputs->textCursor(); auto transfers = txInfo->transfers(); if (!transfers.isEmpty()) { + bool hasIntegrated = false; + for (const auto& transfer : transfers) { auto address = transfer->address(); auto amount = WalletManager::displayAmount(transfer->amount()); @@ -81,9 +85,21 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *pare cursor.insertText(address, Utils::addressTextFormat(index, transfer->amount())); cursor.insertText(QString(" %1").arg(amount), QTextCharFormat()); cursor.insertBlock(); + + if (WalletManager::baseAddressFromIntegratedAddress(transfer->address(), constants::networkType) != transfer->address()) { + hasIntegrated = true; + } } ui->label_outputs->setText(QString("Destinations (%2)").arg(QString::number(transfers.size()))); this->adjustHeight(ui->outputs, transfers.size()); + + // Trezor saves a mangled payment ID. + if (m_wallet->isTrezor() && !hasIntegrated && txInfo->hasPaymentId()) { + ui->frame_destinationsWarning->setInfo(icons()->icon("warning"), "The address displayed here does not contain a payment ID. " + "If you are making a repeat payment to a service, " + "do not copy the address from here to prevent a loss of funds."); + ui->frame_destinationsWarning->show(); + } } else { ui->frameOutputs->hide(); } diff --git a/src/dialog/TxInfoDialog.ui b/src/dialog/TxInfoDialog.ui index 22405d9..ca9cecd 100644 --- a/src/dialog/TxInfoDialog.ui +++ b/src/dialog/TxInfoDialog.ui @@ -7,7 +7,7 @@ 0 0 929 - 715 + 723 @@ -184,6 +184,16 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + @@ -287,6 +297,14 @@ + + + InfoFrame + QFrame +
components.h
+ 1 +
+
diff --git a/src/libwalletqt/TransactionHistory.cpp b/src/libwalletqt/TransactionHistory.cpp index 905af2d..064352d 100644 --- a/src/libwalletqt/TransactionHistory.cpp +++ b/src/libwalletqt/TransactionHistory.cpp @@ -75,10 +75,10 @@ void TransactionHistory::refresh() clearRows(); quint64 lastTxHeight = 0; + bool hasFakePaymentId = m_wallet->isTrezor(); m_locked = false; m_minutesToUnlock = 0; - uint64_t min_height = 0; uint64_t max_height = (uint64_t)-1; uint64_t wallet_height = m_wallet->blockChainHeight(); @@ -176,7 +176,7 @@ void TransactionHistory::refresh() // single output transaction might contain multiple transfers for (auto const &d: pd.m_dests) { - Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id)), this); + Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)), this); t->m_transfers.append(transfer); } for (auto const &r: pd.m_rings) @@ -229,7 +229,7 @@ void TransactionHistory::refresh() for (auto const &d: pd.m_dests) { - Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id)), this); + Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)), this); t->m_transfers.append(transfer); } for (auto const &r: pd.m_rings) diff --git a/src/libwalletqt/rows/TransactionRow.cpp b/src/libwalletqt/rows/TransactionRow.cpp index 0edb315..ff6ab30 100644 --- a/src/libwalletqt/rows/TransactionRow.cpp +++ b/src/libwalletqt/rows/TransactionRow.cpp @@ -167,6 +167,10 @@ QString TransactionRow::rings_formatted() const return rings; } +bool TransactionRow::hasPaymentId() const { + return m_paymentId != "0000000000000000"; +} + TransactionRow::~TransactionRow() { qDeleteAll(m_transfers); diff --git a/src/libwalletqt/rows/TransactionRow.h b/src/libwalletqt/rows/TransactionRow.h index 68b21e2..34d6f58 100644 --- a/src/libwalletqt/rows/TransactionRow.h +++ b/src/libwalletqt/rows/TransactionRow.h @@ -52,6 +52,7 @@ public: QList destinations() const; QList transfers() const; QString rings_formatted() const; + bool hasPaymentId() const; private: explicit TransactionRow(QObject *parent);