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
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 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
48 /** @name Generated (mined) transactions
53 /** @name Reported status
57 qint64 open_for
; /**< Timestamp if status==OpenUntilDate, otherwise number
58 of additional blocks that need to be mined before
62 /** Current number of blocks (to know whether cached status is still valid) */
68 /** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
71 class TransactionRecord
85 /** Number of confirmation recommended for accepting a transaction */
86 static const int RecommendedNumConfirmations
= 6;
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),
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
),
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
122 /** Subtransaction index, for sort key */
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