Bitcoin Core  31.0.0
P2P Digital Currency
transactionrecord.h
Go to the documentation of this file.
1 // Copyright (c) 2011-present 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.
4 
5 #ifndef BITCOIN_QT_TRANSACTIONRECORD_H
6 #define BITCOIN_QT_TRANSACTIONRECORD_H
7 
8 #include <consensus/amount.h>
10 #include <uint256.h>
11 
12 #include <QList>
13 #include <QString>
14 
15 namespace interfaces {
16 class Node;
17 class Wallet;
18 struct WalletTx;
19 struct WalletTxStatus;
20 }
21 
25  enum Status {
27  Unconfirmed,
32  Immature,
35  };
36 
38  bool countsForBalance{false};
40  std::string sortKey;
41 
44  int matures_in{0};
50  qint64 depth{0};
55 
56  bool needsUpdate{false};
57 };
58 
63 {
64 public:
65  enum Type
66  {
73  };
74 
76  static const int RecommendedNumConfirmations = 6;
77 
79  hash(), time(0), type(Other), debit(0), credit(0), idx(0)
80  {
81  }
82 
83  TransactionRecord(Txid _hash, qint64 _time):
84  hash(_hash), time(_time), type(Other), debit(0),
85  credit(0), idx(0)
86  {
87  }
88 
89  TransactionRecord(Txid _hash, qint64 _time,
90  Type _type, const std::string &_address,
91  const CAmount& _debit, const CAmount& _credit):
92  hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
93  idx(0)
94  {
95  }
96 
99  static bool showTransaction();
100  static QList<TransactionRecord> decomposeTransaction(const interfaces::WalletTx& wtx);
101 
105  qint64 time;
107  std::string address;
113  int idx;
114 
117 
119  QString getTxHash() const;
120 
122  int getOutputIndex() const;
123 
126  void updateStatus(const interfaces::WalletTxStatus& wtx, const uint256& block_hash, int numBlocks, int64_t block_time);
127 
130  bool statusUpdateNeeded(const uint256& block_hash) const;
131 };
132 
133 #endif // BITCOIN_QT_TRANSACTIONRECORD_H
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
int idx
Subtransaction index, for sort key.
Generated (mined) transactions.
QString getTxHash() const
Return the unique identifier for this transaction (part)
Mined but not accepted.
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
TransactionRecord(Txid _hash, qint64 _time, Type _type, const std::string &_address, const CAmount &_debit, const CAmount &_credit)
TransactionRecord(Txid _hash, qint64 _time)
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
std::string sortKey
Sorting key based on status.
int getOutputIndex() const
Return the output index of the subtransaction.
UI model for a transaction.
TransactionStatus status
Status: can change with block chain update.
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
256-bit opaque blob.
Definition: uint256.h:195
UI model for transaction status.
uint256 m_cur_block_hash
Current block hash (to know whether cached status is still valid)
bool countsForBalance
Transaction counts towards available balance.
Normal (sent/received) transactions.
Confirmed, but waiting for the recommended number of confirmations.
Abandoned from the wallet.
Updated transaction status.
Definition: wallet.h:400
Conflicts with other transaction or mempool.
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.