-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtransactionview.cpp
More file actions
50 lines (45 loc) · 1.42 KB
/
Copy pathtransactionview.cpp
File metadata and controls
50 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <QDateTime>
#include "transactionview.h"
#include "ui_transactionview.h"
#include "format.h"
#include <QJsonObject>
#include <QJsonDocument>
TransactionView::TransactionView(QWidget *parent, const QString& txJson) :
QDialog(parent),
ui(new Ui::transactionview)
{
// prepare txJsonHumanView and txJsonRawView
QByteArray arrTx;
arrTx.append(txJson);
QJsonDocument TxRec(QJsonDocument::fromJson(arrTx));
QJsonObject Tx(TxRec.object());
Tx.insert("Amount", Amount(Tx["Amount"].toString().toLongLong()));
Tx.insert("Fee", Amount(Tx["Fee"].toString().toLongLong()));
Tx.insert("date", timeFormat(Tx["date"].toDouble()));
if (static_cast<uint32_t>(Tx["Flags"].toDouble()) == 0x80000000u)
Tx.insert("Flags", "tfFullyCanonicalSig");
else Tx.insert("Flags", "todo: fix output");
TxRec.setObject(Tx);
txJsonHumanView = TxRec.toJson(QJsonDocument::Indented);
txJsonRawView = txJson;
// setup gui
ui->setupUi(this);
ui->txBrowser->setText(txJson);
}
TransactionView::~TransactionView()
{
delete ui;
}
void TransactionView::on_changeViewButton_clicked()
{
if (isHumanView != true){
ui->txBrowser->setText(txJsonHumanView);
ui->changeViewButton->setText("Raw View");
isHumanView = true;
}
else {
ui->txBrowser->setText(txJsonRawView);
ui->changeViewButton->setText("Human View");
isHumanView = false;
}
}