TransactionInfoDialog: add tx key

This commit is contained in:
tobtoht 2020-10-20 01:05:42 +02:00
parent 70f1846de6
commit 302c258e6b
6 changed files with 53 additions and 35 deletions

View file

@ -8,16 +8,23 @@
#include "libwalletqt/WalletManager.h" #include "libwalletqt/WalletManager.h"
#include <QDebug> #include <QDebug>
TransactionInfoDialog::TransactionInfoDialog(Coins *coins, TransactionInfo *txInfo, QWidget *parent) TransactionInfoDialog::TransactionInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent)
: QDialog(parent) : QDialog(parent)
, ui(new Ui::TransactionInfoDialog) , ui(new Ui::TransactionInfoDialog)
, m_coins(coins) , m_wallet(wallet)
, m_txInfo(txInfo) , m_txInfo(txInfo)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->txid->setText(QString(txInfo->hash())); ui->label_txid->setText(QString(txInfo->hash()));
ui->txid->setCursorPosition(0);
if (txInfo->direction() == TransactionInfo::Direction_In) {
ui->txKey->hide();
} else {
QString txKey = m_wallet->getTxKey(txInfo->hash());
txKey = txKey.isEmpty() ? "unknown" : txKey;
ui->label_txKey->setText(txKey);
}
ui->label_status->setText(QString("Status: %1 confirmations").arg(txInfo->confirmations())); 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"))); ui->label_date->setText(QString("Date: %1").arg(txInfo->timestamp().toString("yyyy-MM-dd HH:mm")));
@ -30,7 +37,7 @@ TransactionInfoDialog::TransactionInfoDialog(Coins *coins, TransactionInfo *txIn
ui->label_fee->setText(QString("Fee: %1").arg(txInfo->isCoinbase() ? WalletManager::displayAmount(0) : 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())); ui->label_unlockTime->setText(QString("Unlock time: %1 (height)").arg(txInfo->unlockTime()));
qDebug() << m_coins->coins_from_txid(txInfo->hash()); qDebug() << m_wallet->coins()->coins_from_txid(txInfo->hash());
QString destinations = txInfo->destinations_formatted(); QString destinations = txInfo->destinations_formatted();
if (destinations.isEmpty()) { if (destinations.isEmpty()) {

View file

@ -8,6 +8,7 @@
#include <QtSvg/QSvgWidget> #include <QtSvg/QSvgWidget>
#include "libwalletqt/Coins.h" #include "libwalletqt/Coins.h"
#include "libwalletqt/TransactionInfo.h" #include "libwalletqt/TransactionInfo.h"
#include "libwalletqt/Wallet.h"
namespace Ui { namespace Ui {
class TransactionInfoDialog; class TransactionInfoDialog;
@ -18,14 +19,14 @@ class TransactionInfoDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit TransactionInfoDialog(Coins *coins, TransactionInfo *txInfo, QWidget *parent = nullptr); explicit TransactionInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent = nullptr);
~TransactionInfoDialog() override; ~TransactionInfoDialog() override;
private: private:
Ui::TransactionInfoDialog *ui; Ui::TransactionInfoDialog *ui;
TransactionInfo *m_txInfo; TransactionInfo *m_txInfo;
Coins *m_coins; Wallet *m_wallet;
}; };
#endif //FEATHER_TRANSACTIONINFODIALOG_H #endif //FEATHER_TRANSACTIONINFODIALOG_H

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>547</width> <width>547</width>
<height>332</height> <height>436</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,32 +15,41 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QGroupBox" name="groupBox">
<property name="text"> <property name="title">
<string>Transaction ID:</string> <string>Transaction ID:</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_txid">
<property name="text">
<string>txid</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="txid"> <widget class="QGroupBox" name="txKey">
<property name="sizePolicy"> <property name="title">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <string>Transaction key:</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>525</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>txid</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_txKey">
<property name="text">
<string>txKey</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>

View file

@ -45,11 +45,11 @@ HistoryWidget::HistoryWidget(QWidget *parent)
} }
void HistoryWidget::setModel(Coins *coins, TransactionHistoryProxyModel *model, TransactionHistory *txHistory) void HistoryWidget::setModel(TransactionHistoryProxyModel *model, Wallet *wallet)
{ {
m_coins = coins;
m_model = model; m_model = model;
m_txHistory = txHistory; m_wallet = wallet;
m_txHistory = m_wallet->history();
ui->history->setModel(m_model); ui->history->setModel(m_model);
ui->history->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->history->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
@ -66,7 +66,7 @@ void HistoryWidget::showTxDetails() {
}); });
if (i != nullptr) { if (i != nullptr) {
auto * dialog = new TransactionInfoDialog(m_coins, i, this); auto * dialog = new TransactionInfoDialog(m_wallet, i, this);
dialog->exec(); dialog->exec();
} }
} }

View file

@ -7,6 +7,7 @@
#include "model/TransactionHistoryModel.h" #include "model/TransactionHistoryModel.h"
#include "model/TransactionHistoryProxyModel.h" #include "model/TransactionHistoryProxyModel.h"
#include "libwalletqt/Coins.h" #include "libwalletqt/Coins.h"
#include "libwalletqt/Wallet.h"
#include <QWidget> #include <QWidget>
#include <QMenu> #include <QMenu>
@ -21,7 +22,7 @@ Q_OBJECT
public: public:
explicit HistoryWidget(QWidget *parent = nullptr); explicit HistoryWidget(QWidget *parent = nullptr);
void setModel(Coins * coins, TransactionHistoryProxyModel * model, TransactionHistory * txHistory); void setModel(TransactionHistoryProxyModel *model, Wallet *wallet);
~HistoryWidget() override; ~HistoryWidget() override;
public slots: public slots:
@ -51,7 +52,7 @@ private:
QMenu *m_copyMenu; QMenu *m_copyMenu;
TransactionHistory *m_txHistory; TransactionHistory *m_txHistory;
TransactionHistoryProxyModel *m_model; TransactionHistoryProxyModel *m_model;
Coins *m_coins; Wallet *m_wallet = nullptr;
}; };
#endif //FEATHER_HISTORYWIDGET_H #endif //FEATHER_HISTORYWIDGET_H

View file

@ -604,7 +604,7 @@ void MainWindow::onWalletOpened() {
// history page // history page
m_ctx->currentWallet->history()->refresh(m_ctx->currentWallet->currentSubaddressAccount()); m_ctx->currentWallet->history()->refresh(m_ctx->currentWallet->currentSubaddressAccount());
ui->historyWidget->setModel(m_ctx->currentWallet->coins(), m_ctx->currentWallet->historyModel(), m_ctx->currentWallet->history()); ui->historyWidget->setModel(m_ctx->currentWallet->historyModel(), m_ctx->currentWallet);
connect(m_ctx->currentWallet->history(), &TransactionHistory::txNoteChanged, [this]{ connect(m_ctx->currentWallet->history(), &TransactionHistory::txNoteChanged, [this]{
m_ctx->storeWallet(); m_ctx->storeWallet();
}); });