]>
Commit | Line | Data |
---|---|---|
f488e735 WL |
1 | #ifndef TRANSACTIONRECORD_H |
2 | #define TRANSACTIONRECORD_H | |
3 | ||
4 | #include "main.h" | |
5 | ||
6 | #include <QList> | |
7 | ||
8 | class TransactionStatus | |
9 | { | |
10 | public: | |
11 | TransactionStatus(): | |
12 | confirmed(false), sortKey(""), maturity(Mature), | |
13 | matures_in(0), status(Offline), depth(0), open_for(0) | |
14 | { } | |
15 | ||
16 | enum Maturity | |
17 | { | |
18 | Immature, | |
19 | Mature, | |
f488e735 WL |
20 | MaturesWarning, /* Will likely not mature because no nodes have confirmed */ |
21 | NotAccepted | |
22 | }; | |
23 | ||
24 | enum Status { | |
25 | OpenUntilDate, | |
26 | OpenUntilBlock, | |
27 | Offline, | |
28 | Unconfirmed, | |
29 | HaveConfirmations | |
30 | }; | |
31 | ||
32 | bool confirmed; | |
33 | std::string sortKey; | |
34 | ||
35 | /* For "Generated" transactions */ | |
36 | Maturity maturity; | |
37 | int matures_in; | |
38 | ||
39 | /* Reported status */ | |
40 | Status status; | |
41 | int64 depth; | |
42 | int64 open_for; /* Timestamp if status==OpenUntilDate, otherwise number of blocks */ | |
43 | }; | |
44 | ||
45 | class TransactionRecord | |
46 | { | |
47 | public: | |
48 | enum Type | |
49 | { | |
50 | Other, | |
51 | Generated, | |
52 | SendToAddress, | |
53 | SendToIP, | |
54 | RecvFromAddress, | |
55 | RecvFromIP, | |
56 | SendToSelf | |
57 | }; | |
58 | ||
59 | TransactionRecord(): | |
60 | hash(), time(0), type(Other), address(""), debit(0), credit(0) | |
61 | { | |
62 | } | |
63 | ||
64 | TransactionRecord(uint256 hash, int64 time, const TransactionStatus &status): | |
65 | hash(hash), time(time), type(Other), address(""), debit(0), | |
66 | credit(0), status(status) | |
67 | { | |
68 | } | |
69 | ||
70 | TransactionRecord(uint256 hash, int64 time, const TransactionStatus &status, | |
71 | Type type, const std::string &address, | |
72 | int64 debit, int64 credit): | |
73 | hash(hash), time(time), type(type), address(address), debit(debit), credit(credit), | |
74 | status(status) | |
75 | { | |
76 | } | |
77 | ||
78 | static bool showTransaction(const CWalletTx &wtx); | |
79 | static QList<TransactionRecord> decomposeTransaction(const CWalletTx &wtx); | |
80 | ||
81 | /* Fixed */ | |
82 | uint256 hash; | |
83 | int64 time; | |
84 | Type type; | |
85 | std::string address; | |
86 | int64 debit; | |
87 | int64 credit; | |
88 | ||
89 | /* Status: can change with block chain update */ | |
90 | TransactionStatus status; | |
91 | }; | |
92 | ||
93 | #endif // TRANSACTIONRECORD_H |