[test] Add getblockchaininfo functional test
[bitcoinplatinum.git] / src / qt / transactionrecord.h
bloba26e676142531c905c564e8eee6d77ac5eadb4a2
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_QT_TRANSACTIONRECORD_H
6 #define BITCOIN_QT_TRANSACTIONRECORD_H
8 #include "amount.h"
9 #include "uint256.h"
11 #include <QList>
12 #include <QString>
14 class CWallet;
15 class CWalletTx;
17 /** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
19 class TransactionStatus
21 public:
22 TransactionStatus():
23 countsForBalance(false), sortKey(""),
24 matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1)
25 { }
27 enum Status {
28 Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
29 /// Normal (sent/received) transactions
30 OpenUntilDate, /**< Transaction not yet final, waiting for date */
31 OpenUntilBlock, /**< Transaction not yet final, waiting for block */
32 Offline, /**< Not sent to any other nodes **/
33 Unconfirmed, /**< Not yet mined into a block **/
34 Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/
35 Conflicted, /**< Conflicts with other transaction or mempool **/
36 Abandoned, /**< Abandoned from the wallet **/
37 /// Generated (mined) transactions
38 Immature, /**< Mined but waiting for maturity */
39 MaturesWarning, /**< Transaction will likely not mature because no nodes have confirmed */
40 NotAccepted /**< Mined but not accepted */
43 /// Transaction counts towards available balance
44 bool countsForBalance;
45 /// Sorting key based on status
46 std::string sortKey;
48 /** @name Generated (mined) transactions
49 @{*/
50 int matures_in;
51 /**@}*/
53 /** @name Reported status
54 @{*/
55 Status status;
56 qint64 depth;
57 qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
58 of additional blocks that need to be mined before
59 finalization */
60 /**@}*/
62 /** Current number of blocks (to know whether cached status is still valid) */
63 int cur_num_blocks;
65 bool needsUpdate;
68 /** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
69 multiple outputs.
71 class TransactionRecord
73 public:
74 enum Type
76 Other,
77 Generated,
78 SendToAddress,
79 SendToOther,
80 RecvWithAddress,
81 RecvFromOther,
82 SendToSelf
85 /** Number of confirmation recommended for accepting a transaction */
86 static const int RecommendedNumConfirmations = 6;
88 TransactionRecord():
89 hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
93 TransactionRecord(uint256 _hash, qint64 _time):
94 hash(_hash), time(_time), type(Other), address(""), debit(0),
95 credit(0), idx(0)
99 TransactionRecord(uint256 _hash, qint64 _time,
100 Type _type, const std::string &_address,
101 const CAmount& _debit, const CAmount& _credit):
102 hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
103 idx(0)
107 /** Decompose CWallet transaction to model transaction records.
109 static bool showTransaction(const CWalletTx &wtx);
110 static QList<TransactionRecord> decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx);
112 /** @name Immutable transaction attributes
113 @{*/
114 uint256 hash;
115 qint64 time;
116 Type type;
117 std::string address;
118 CAmount debit;
119 CAmount credit;
120 /**@}*/
122 /** Subtransaction index, for sort key */
123 int idx;
125 /** Status: can change with block chain update */
126 TransactionStatus status;
128 /** Whether the transaction was sent/received with a watch-only address */
129 bool involvesWatchAddress;
131 /** Return the unique identifier for this transaction (part) */
132 QString getTxID() const;
134 /** Return the output index of the subtransaction */
135 int getOutputIndex() const;
137 /** Update status from core wallet tx.
139 void updateStatus(const CWalletTx &wtx);
141 /** Return whether a status update is needed.
143 bool statusUpdateNeeded() const;
146 #endif // BITCOIN_QT_TRANSACTIONRECORD_H