2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-12-26 19:56:06 +00:00
|
|
|
// Copyright (c) 2020-2021, The Monero Project.
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include "transactioninfodialog.h"
|
|
|
|
#include "ui_transactioninfodialog.h"
|
|
|
|
|
|
|
|
#include "libwalletqt/CoinsInfo.h"
|
|
|
|
#include "libwalletqt/WalletManager.h"
|
2021-01-29 14:51:59 +00:00
|
|
|
#include "libwalletqt/Transfer.h"
|
2020-11-08 11:08:15 +00:00
|
|
|
#include "utils.h"
|
2021-01-29 14:51:59 +00:00
|
|
|
#include "utils/ColorScheme.h"
|
2020-11-08 11:08:15 +00:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2020-10-19 23:05:42 +00:00
|
|
|
TransactionInfoDialog::TransactionInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent)
|
2020-10-07 10:36:04 +00:00
|
|
|
: QDialog(parent)
|
|
|
|
, ui(new Ui::TransactionInfoDialog)
|
2020-10-19 23:05:42 +00:00
|
|
|
, m_wallet(wallet)
|
2020-10-07 10:36:04 +00:00
|
|
|
, m_txInfo(txInfo)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2020-11-08 11:08:15 +00:00
|
|
|
m_txProofWidget = new TxProofWidget(this, wallet, txInfo);
|
|
|
|
|
2020-10-19 23:05:42 +00:00
|
|
|
ui->label_txid->setText(QString(txInfo->hash()));
|
|
|
|
|
|
|
|
if (txInfo->direction() == TransactionInfo::Direction_In) {
|
2021-01-29 14:51:59 +00:00
|
|
|
ui->frameTxKey->hide();
|
2020-10-19 23:05:42 +00:00
|
|
|
} else {
|
|
|
|
QString txKey = m_wallet->getTxKey(txInfo->hash());
|
2021-01-29 14:51:59 +00:00
|
|
|
if (txKey.isEmpty()) {
|
|
|
|
ui->btn_CopyTxKey->setEnabled(false);
|
|
|
|
ui->btn_CopyTxKey->setToolTip("Transaction key unknown");
|
|
|
|
}
|
|
|
|
m_txKey = txKey;
|
2020-10-19 23:05:42 +00:00
|
|
|
}
|
2021-01-29 14:51:59 +00:00
|
|
|
connect(ui->btn_CopyTxKey, &QPushButton::pressed, this, &TransactionInfoDialog::copyTxKey);
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2020-12-14 19:29:58 +00:00
|
|
|
QString blockHeight = QString::number(txInfo->blockHeight());
|
|
|
|
if (blockHeight == "0")
|
|
|
|
blockHeight = "Unconfirmed";
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->label_status->setText(QString("Status: %1 confirmations").arg(txInfo->confirmations()));
|
|
|
|
ui->label_date->setText(QString("Date: %1").arg(txInfo->timestamp().toString("yyyy-MM-dd HH:mm")));
|
2020-12-14 19:29:58 +00:00
|
|
|
ui->label_blockHeight->setText(QString("Block height: %1").arg(blockHeight));
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
QString direction = txInfo->direction() == TransactionInfo::Direction_In ? "received" : "sent";
|
|
|
|
ui->label_amount->setText(QString("Amount %1: %2").arg(direction, txInfo->displayAmount()));
|
|
|
|
|
|
|
|
QString fee = txInfo->fee().isEmpty() ? "n/a" : txInfo->fee();
|
|
|
|
ui->label_fee->setText(QString("Fee: %1").arg(txInfo->isCoinbase() ? WalletManager::displayAmount(0) : fee));
|
|
|
|
ui->label_unlockTime->setText(QString("Unlock time: %1 (height)").arg(txInfo->unlockTime()));
|
|
|
|
|
2020-10-19 23:05:42 +00:00
|
|
|
qDebug() << m_wallet->coins()->coins_from_txid(txInfo->hash());
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-01-29 14:51:59 +00:00
|
|
|
QTextCursor cursor = ui->destinations->textCursor();
|
|
|
|
for (const auto& transfer : txInfo->transfers()) {
|
|
|
|
auto address = transfer->address();
|
|
|
|
auto amount = WalletManager::displayAmount(transfer->amount());
|
|
|
|
auto index = m_wallet->subaddressIndex(address);
|
|
|
|
cursor.insertText(address, Utils::addressTextFormat(index));
|
|
|
|
cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
|
|
|
|
cursor.insertBlock();
|
|
|
|
}
|
|
|
|
if (txInfo->transfers().size() == 0) {
|
2020-12-16 14:37:20 +00:00
|
|
|
ui->frameDestinations->hide();
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 11:08:15 +00:00
|
|
|
ui->txProofWidget->addWidget(m_txProofWidget);
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
this->adjustSize();
|
|
|
|
}
|
|
|
|
|
2021-01-29 14:51:59 +00:00
|
|
|
void TransactionInfoDialog::copyTxKey() {
|
|
|
|
Utils::copyToClipboard(m_txKey);
|
|
|
|
}
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
TransactionInfoDialog::~TransactionInfoDialog() {
|
|
|
|
delete ui;
|
|
|
|
}
|