forked from ciphrex/mSIGNA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatetxdialog.h
141 lines (104 loc) · 3.37 KB
/
createtxdialog.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
///////////////////////////////////////////////////////////////////////////////
//
// mSIGNA
//
// createtxdialog.h
//
// Copyright (c) 2013 Eric Lombrozo
//
// All Rights Reserved.
#pragma once
class UnspentTxOutModel;
class UnspentTxOutView;
class QTextEdit;
#include <QDialog>
#include <QHBoxLayout>
// TODO: move TaggedOutput to another file, remove the following dependency
#include "accountmodel.h"
#include "paymentrequest.h"
#include <CoinQ/CoinQ_typedefs.h>
class QComboBox;
class QLineEdit;
class QCheckBox;
class QPushButton;
class QVBoxLayout;
class QItemSelection;
class TxOutLayout : public QHBoxLayout
{
Q_OBJECT
public:
TxOutLayout(uint64_t currencyDivisor, const QString& currencySymbol, uint64_t maxCurrencyValue, unsigned int maxCurrencyDecimals, QWidget* parent = nullptr);
void setAddress(const QString& address);
QString getAddress() const;
bytes_t getScript() const;
void setValue(uint64_t value);
uint64_t getValue() const;
void setRecipient(const QString& recipient);
QString getRecipient() const;
QPushButton* getRemoveButton() const { return removeButton; }
void removeWidgets();
private:
unsigned char base58_versions[2];
QLineEdit* addressEdit;
QLineEdit* amountEdit;
QLineEdit* recipientEdit;
QPushButton* removeButton;
uint64_t currencyDivisor;
QString currencySymbol;
uint64_t currencyMax;
unsigned int currencyDecimals;
};
class CoinControlWidget : public QWidget
{
Q_OBJECT
public:
CoinControlWidget(CoinDB::Vault* vault, const QString& accountName, QWidget* parent = nullptr);
std::vector<unsigned long> getInputTxOutIds() const;
void updateAll();
// Windows repaint workaround
void refreshView();
public slots:
void updateTotal(const QItemSelection& selected, const QItemSelection& deselected);
private:
UnspentTxOutModel* model;
UnspentTxOutView* view;
QLineEdit* totalEdit;
};
class CreateTxDialog : public QDialog
{
Q_OBJECT
public:
CreateTxDialog(const QString& accountName, const PaymentRequest& paymentRequest = PaymentRequest(), QWidget* parent = nullptr);
CreateTxDialog(CoinDB::Vault* vault, const QString& accountName, const PaymentRequest& paymentRequest = PaymentRequest(), QWidget* parent = nullptr);
QString getAccountName() const;
uint64_t getFeeValue() const;
std::vector<unsigned long> getInputTxOutIds() const;
std::vector<std::shared_ptr<CoinDB::TxOut>> getTxOuts();
std::vector<TaggedOutput> getOutputs();
enum status_t { SAVE_ONLY, SIGN_AND_SAVE, SIGN_AND_SEND };
status_t getStatus() const { return status; }
public slots:
void addTxOut(const PaymentRequest& paymentRequest = PaymentRequest());
private slots:
void switchCoinControl(int state);
void removeTxOut(TxOutLayout* txOutLayout);
void setRemoveEnabled(bool enabled = true);
private:
QComboBox* accountComboBox;
QLineEdit* feeEdit;
QCheckBox* coinControlCheckBox;
CoinControlWidget* coinControlWidget;
QVBoxLayout* txOutVBoxLayout;
QVBoxLayout* mainLayout;
std::set<TxOutLayout*> txOutLayouts;
QPushButton* signAndSendButton;
QPushButton* signAndSaveButton;
QPushButton* saveButton;
QPushButton* cancelButton;
status_t status;
uint64_t currencyDivisor;
QString currencySymbol;
uint64_t currencyMax;
unsigned int currencyDecimals;
uint64_t defaultFee;
};