Merge pull request 'TxConfDialog: detect churn transaction' (#302) from tobtoht/feather:txconf_detect_churn into master

Reviewed-on: https://git.wownero.com/feather/feather/pulls/302
This commit is contained in:
tobtoht 2021-01-25 17:44:36 +00:00
commit 9fc77f3bc9
4 changed files with 34 additions and 2 deletions

View file

@ -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);

View file

@ -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>

View file

@ -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()));

View file

@ -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;