-
Notifications
You must be signed in to change notification settings - Fork 6
/
Transaction.h
59 lines (41 loc) · 1.33 KB
/
Transaction.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
#ifndef TRANSACTION_H
#define TRANSACTION_H
#include <QByteArray>
#include <QString>
#include <QDateTime>
class Transaction
{
public:
typedef enum
{
NORMAL,
REWARD
} TransactionType;
Transaction();
Transaction(const Transaction &in);
Transaction(const QByteArray &from, const QByteArray &to, unsigned int amount);
Transaction(const QByteArray &to);
void operator=(const Transaction &in);
friend bool operator==(const Transaction &a, const Transaction &b);
QByteArray getJson();
QByteArray getMessageJson();
void signTransaction(const QByteArray &privateKey, const QByteArray &publicKey);
bool verifySignature();
const QByteArray getPublicKey() const;
const QByteArray getSignature() const;
TransactionType getType() const;
const QByteArray getToAddress() const;
const QByteArray getFromAddress() const;
unsigned int getAmount() const;
bool parseFromJsonObject(const QJsonObject &messageJson);
private:
QByteArray m_toAddress;
QByteArray m_fromAddress;
unsigned int m_amount;
TransactionType m_type;
QByteArray m_signature;
QByteArray m_publicKey;
QDateTime m_timeStamp;
};
bool operator==(const Transaction &a, const Transaction &b);
#endif // TRANSACTION_H