TxConfDialog: detect churn transaction

remotes/1691844314220217825/master
tobtoht 3 years ago
parent 58c9c1a006
commit 3987569d55
Signed by untrusted user: tobtoht
GPG Key ID: 1CADD27F41F45C3C

@ -21,6 +21,7 @@ TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QStrin
ui->setupUi(this);
ui->label_warning->setText("You are about to send a transaction.\nVerify the information below.");
ui->label_note->hide();
QString preferredCur = config()->get(Config::preferredFiatCurrency).toString();
@ -46,10 +47,18 @@ TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QStrin
ui->label_fee->setText(QString("%1 (%2 %3)").arg(amounts[1], amounts_fiat[1], preferredCur));
ui->label_total->setText(QString("%1 (%2 %3)").arg(amounts[2], amounts_fiat[2], preferredCur));
auto subaddressIndex = m_ctx->currentWallet->subaddressIndex(address);
QString addressExtra;
if (subaddressIndex.first >= 0) {
ui->label_note->setText("Note: this is a churn transaction.");
ui->label_note->show();
}
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
ui->label_address->setFont(ModelUtils::getMonospaceFont());
ui->label_address->setToolTip(address);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Send");
connect(ui->btn_Advanced, &QPushButton::clicked, this, &TxConfDialog::setShowAdvanced);

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>844</width>
<height>248</height>
<width>612</width>
<height>288</height>
</rect>
</property>
<property name="windowTitle">
@ -24,6 +24,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_note">
<property name="text">
<string>note</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>

@ -150,6 +150,15 @@ QString Wallet::address(quint32 accountIndex, quint32 addressIndex) const
return QString::fromStdString(m_walletImpl->address(accountIndex, addressIndex));
}
QPair<int, int> Wallet::subaddressIndex(const QString &address) const
{
std::pair<uint32_t, uint32_t> i;
if (!m_walletImpl->subaddressIndex(address.toStdString(), i)) {
return QPair<int, int>(-1, -1);
}
return QPair<int, int>(i.first, i.second);
}
QString Wallet::path() const
{
return QDir::toNativeSeparators(QString::fromStdString(m_walletImpl->path()));

@ -139,6 +139,10 @@ public:
//! returns wallet's public address
Q_INVOKABLE QString address(quint32 accountIndex, quint32 addressIndex) const;
//! returns the subaddress index (major, minor) of the address
// (-1, -1) if address does not belong to wallet
Q_INVOKABLE QPair<int, int> subaddressIndex(const QString &address) const;
//! returns wallet file's path
QString path() const;

Loading…
Cancel
Save