2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Copyright (c) 2020, The Monero Project.
|
|
|
|
|
|
|
|
#include "txconfdialog.h"
|
|
|
|
#include "ui_txconfdialog.h"
|
|
|
|
#include "appcontext.h"
|
|
|
|
#include "utils/config.h"
|
|
|
|
#include "model/ModelUtils.h"
|
2020-10-16 03:05:05 +00:00
|
|
|
#include "libwalletqt/WalletManager.h"
|
|
|
|
#include "txconfadvdialog.h"
|
2020-10-21 14:52:34 +00:00
|
|
|
#include "globals.h"
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2020-10-16 03:05:05 +00:00
|
|
|
TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QString &address, const QString &description, int mixin, QWidget *parent)
|
2020-10-07 10:36:04 +00:00
|
|
|
: QDialog(parent)
|
|
|
|
, ui(new Ui::TxConfDialog)
|
2020-10-16 03:05:05 +00:00
|
|
|
, m_ctx(ctx)
|
2020-10-07 10:36:04 +00:00
|
|
|
, m_tx(tx)
|
|
|
|
, m_address(address)
|
|
|
|
, m_description(description)
|
|
|
|
, m_mixin(mixin)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->label_warning->setText("You are about to send a transaction.\nVerify the information below.");
|
|
|
|
|
|
|
|
QString preferredCur = config()->get(Config::preferredFiatCurrency).toString();
|
|
|
|
|
|
|
|
auto convert = [preferredCur](double amount){
|
|
|
|
return QString::number(AppContext::prices->convert("XMR", preferredCur, amount), 'f', 2);
|
|
|
|
};
|
|
|
|
|
|
|
|
QString amount = WalletManager::displayAmount(tx->amount());
|
2020-10-21 14:52:34 +00:00
|
|
|
QString amount_fiat = convert(tx->amount() / globals::cdiv);
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->label_amount->setText(QString("%1 (%2 %3)").arg(amount, amount_fiat, preferredCur));
|
|
|
|
|
|
|
|
QString fee = WalletManager::displayAmount(tx->fee());
|
2020-10-21 14:52:34 +00:00
|
|
|
QString fee_fiat = convert(tx->fee() / globals::cdiv);
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->label_fee->setText(QString("%1 (%2 %3)").arg(fee, fee_fiat, preferredCur));
|
|
|
|
|
|
|
|
QString total = WalletManager::displayAmount(tx->amount() + tx->fee());
|
2020-10-21 14:52:34 +00:00
|
|
|
QString total_fiat = convert((tx->amount() + tx->fee()) / globals::cdiv);
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->label_total->setText(QString("%1 (%2 %3)").arg(total, total_fiat, preferredCur));
|
|
|
|
|
|
|
|
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
|
|
|
|
ui->label_address->setFont(ModelUtils::getMonospaceFont());
|
|
|
|
ui->label_address->setToolTip(address);
|
|
|
|
|
2020-10-16 03:05:05 +00:00
|
|
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Send");
|
|
|
|
|
|
|
|
connect(ui->btn_Advanced, &QPushButton::clicked, this, &TxConfDialog::setShowAdvanced);
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2020-12-14 22:07:23 +00:00
|
|
|
AppContext::txCache[tx->txid()[0]] = tx->signedTxToHex(0);
|
2020-10-07 10:36:04 +00:00
|
|
|
this->adjustSize();
|
|
|
|
}
|
|
|
|
|
2020-10-16 03:05:05 +00:00
|
|
|
void TxConfDialog::setShowAdvanced() {
|
|
|
|
this->showAdvanced = true;
|
|
|
|
QDialog::reject();
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TxConfDialog::~TxConfDialog() {
|
|
|
|
delete ui;
|
|
|
|
}
|