1 // Copyright (c) 2011-2013 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
17 /** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
19 class TransactionStatus
23 countsForBalance(false), sortKey(""),
24 matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1)
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 /// Generated (mined) transactions
37 Immature, /**< Mined but waiting for maturity */
38 MaturesWarning, /**< Transaction will likely not mature because no nodes have confirmed */
39 NotAccepted /**< Mined but not accepted */
42 /// Transaction counts towards available balance
43 bool countsForBalance;
44 /// Sorting key based on status
47 /** @name Generated (mined) transactions
52 /** @name Reported status
56 qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
57 of additional blocks that need to be mined before
61 /** Current number of blocks (to know whether cached status is still valid) */
65 /** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
68 class TransactionRecord
82 /** Number of confirmation recommended for accepting a transaction */
83 static const int RecommendedNumConfirmations = 6;
86 hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
90 TransactionRecord(uint256 hash, qint64 time):
91 hash(hash), time(time), type(Other), address(""), debit(0),
96 TransactionRecord(uint256 hash, qint64 time,
97 Type type, const std::string &address,
98 const CAmount& debit, const CAmount& credit):
99 hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
104 /** Decompose CWallet transaction to model transaction records.
106 static bool showTransaction(const CWalletTx &wtx);
107 static QList<TransactionRecord> decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx);
109 /** @name Immutable transaction attributes
119 /** Subtransaction index, for sort key */
122 /** Status: can change with block chain update */
123 TransactionStatus status;
125 /** Whether the transaction was sent/received with a watch-only address */
126 bool involvesWatchAddress;
128 /** Return the unique identifier for this transaction (part) */
129 QString getTxID() const;
131 /** Format subtransaction id */
132 static QString formatSubTxId(const uint256 &hash, int vout);
134 /** Update status from core wallet tx.
136 void updateStatus(const CWalletTx &wtx);
138 /** Return whether a status update is needed.
140 bool statusUpdateNeeded();
143 #endif // BITCOIN_QT_TRANSACTIONRECORD_H