txinfo: warn if integrated address is missing

This commit is contained in:
tobtoht 2024-10-06 17:19:45 +02:00
parent da0d7e7100
commit b0a64231b9
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
6 changed files with 44 additions and 5 deletions

2
monero

@ -1 +1 @@
Subproject commit 16e051c8a880a63aacdd217f24c55f9f6154bb00 Subproject commit d50ba728d79cc3a96c928f7736503268ad567cba

View file

@ -70,10 +70,14 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *pare
ui->frameInputs->hide(); ui->frameInputs->hide();
// } // }
ui->frame_destinationsWarning->hide();
QTextCursor cursor = ui->outputs->textCursor(); QTextCursor cursor = ui->outputs->textCursor();
auto transfers = txInfo->transfers(); auto transfers = txInfo->transfers();
if (!transfers.isEmpty()) { if (!transfers.isEmpty()) {
bool hasIntegrated = false;
for (const auto& transfer : transfers) { for (const auto& transfer : transfers) {
auto address = transfer->address(); auto address = transfer->address();
auto amount = WalletManager::displayAmount(transfer->amount()); 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(address, Utils::addressTextFormat(index, transfer->amount()));
cursor.insertText(QString(" %1").arg(amount), QTextCharFormat()); cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
cursor.insertBlock(); 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()))); ui->label_outputs->setText(QString("Destinations (%2)").arg(QString::number(transfers.size())));
this->adjustHeight(ui->outputs, 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 { } else {
ui->frameOutputs->hide(); ui->frameOutputs->hide();
} }

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>929</width> <width>929</width>
<height>715</height> <height>723</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -184,6 +184,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="InfoFrame" name="frame_destinationsWarning">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QTextEdit" name="outputs"> <widget class="QTextEdit" name="outputs">
<property name="sizePolicy"> <property name="sizePolicy">
@ -287,6 +297,14 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>InfoFrame</class>
<extends>QFrame</extends>
<header>components.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View file

@ -75,10 +75,10 @@ void TransactionHistory::refresh()
clearRows(); clearRows();
quint64 lastTxHeight = 0; quint64 lastTxHeight = 0;
bool hasFakePaymentId = m_wallet->isTrezor();
m_locked = false; m_locked = false;
m_minutesToUnlock = 0; m_minutesToUnlock = 0;
uint64_t min_height = 0; uint64_t min_height = 0;
uint64_t max_height = (uint64_t)-1; uint64_t max_height = (uint64_t)-1;
uint64_t wallet_height = m_wallet->blockChainHeight(); uint64_t wallet_height = m_wallet->blockChainHeight();
@ -176,7 +176,7 @@ void TransactionHistory::refresh()
// single output transaction might contain multiple transfers // single output transaction might contain multiple transfers
for (auto const &d: pd.m_dests) 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); t->m_transfers.append(transfer);
} }
for (auto const &r: pd.m_rings) for (auto const &r: pd.m_rings)
@ -229,7 +229,7 @@ void TransactionHistory::refresh()
for (auto const &d: pd.m_dests) 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); t->m_transfers.append(transfer);
} }
for (auto const &r: pd.m_rings) for (auto const &r: pd.m_rings)

View file

@ -167,6 +167,10 @@ QString TransactionRow::rings_formatted() const
return rings; return rings;
} }
bool TransactionRow::hasPaymentId() const {
return m_paymentId != "0000000000000000";
}
TransactionRow::~TransactionRow() TransactionRow::~TransactionRow()
{ {
qDeleteAll(m_transfers); qDeleteAll(m_transfers);

View file

@ -52,6 +52,7 @@ public:
QList<QString> destinations() const; QList<QString> destinations() const;
QList<Transfer*> transfers() const; QList<Transfer*> transfers() const;
QString rings_formatted() const; QString rings_formatted() const;
bool hasPaymentId() const;
private: private:
explicit TransactionRow(QObject *parent); explicit TransactionRow(QObject *parent);