Implement filter row instead of tabs, allows for more expressive filters
[novacoin.git] / src / qt / transactionrecord.h
1 #ifndef TRANSACTIONRECORD_H
2 #define TRANSACTIONRECORD_H
3
4 #include "uint256.h"
5
6 #include <QList>
7
8 class CWallet;
9 class CWalletTx;
10
11 class TransactionStatus
12 {
13 public:
14     TransactionStatus():
15             confirmed(false), sortKey(""), maturity(Mature),
16             matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1)
17     { }
18
19     enum Maturity
20     {
21         Immature,
22         Mature,
23         MaturesWarning, /* Will likely not mature because no nodes have confirmed */
24         NotAccepted
25     };
26
27     enum Status {
28         OpenUntilDate,
29         OpenUntilBlock,
30         Offline,
31         Unconfirmed,
32         HaveConfirmations
33     };
34
35     bool confirmed;
36     std::string sortKey;
37
38     /* For "Generated" transactions */
39     Maturity maturity;
40     int matures_in;
41
42     /* Reported status */
43     Status status;
44     int64 depth;
45     int64 open_for; /* Timestamp if status==OpenUntilDate, otherwise number of blocks */
46
47     /* Current number of blocks (to know whether cached status is still valid. */
48     int cur_num_blocks;
49 };
50
51 class TransactionRecord
52 {
53 public:
54     enum Type
55     {
56         Other,
57         Generated,
58         SendToAddress,
59         SendToIP,
60         RecvWithAddress,
61         RecvFromIP,
62         SendToSelf
63     };
64
65     /* Number of confirmation needed for transaction */
66     static const int NumConfirmations = 6;
67
68     TransactionRecord():
69             hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
70     {
71     }
72
73     TransactionRecord(uint256 hash, int64 time):
74             hash(hash), time(time), type(Other), address(""), debit(0),
75             credit(0), idx(0)
76     {
77     }
78
79     TransactionRecord(uint256 hash, int64 time,
80                 Type type, const std::string &address,
81                 int64 debit, int64 credit):
82             hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
83             idx(0)
84     {
85     }
86
87     /* Decompose CWallet transaction to model transaction records.
88      */
89     static bool showTransaction(const CWalletTx &wtx);
90     static QList<TransactionRecord> decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx);
91
92     /* Fixed */
93     uint256 hash;
94     int64 time;
95     Type type;
96     std::string address;
97     int64 debit;
98     int64 credit;
99
100     /* Subtransaction index, for sort key */
101     int idx;
102
103     /* Status: can change with block chain update */
104     TransactionStatus status;
105
106     /* Update status from wallet tx.
107      */
108     void updateStatus(const CWalletTx &wtx);
109
110     /* Is a status update needed?
111      */
112     bool statusUpdateNeeded();
113 };
114
115 #endif // TRANSACTIONRECORD_H