Bitcoin Core  26.99.0
P2P Digital Currency
transactionrecord.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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>
9 #include <uint256.h>
10 
11 #include <QList>
12 #include <QString>
13 
14 namespace interfaces {
15 class Node;
16 class Wallet;
17 struct WalletTx;
18 struct WalletTxStatus;
19 }
20 
24  enum Status {
34  };
35 
37  bool countsForBalance{false};
39  std::string sortKey;
40 
43  int matures_in{0};
49  qint64 depth{0};
54 
55  bool needsUpdate{false};
56 };
57 
62 {
63 public:
64  enum Type
65  {
72  };
73 
75  static const int RecommendedNumConfirmations = 6;
76 
78  hash(), time(0), type(Other), debit(0), credit(0), idx(0)
79  {
80  }
81 
82  TransactionRecord(uint256 _hash, qint64 _time):
83  hash(_hash), time(_time), type(Other), debit(0),
84  credit(0), idx(0)
85  {
86  }
87 
88  TransactionRecord(uint256 _hash, qint64 _time,
89  Type _type, const std::string &_address,
90  const CAmount& _debit, const CAmount& _credit):
91  hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
92  idx(0)
93  {
94  }
95 
98  static bool showTransaction();
99  static QList<TransactionRecord> decomposeTransaction(const interfaces::WalletTx& wtx);
100 
104  qint64 time;
106  std::string address;
112  int idx;
113 
116 
119 
121  QString getTxHash() const;
122 
124  int getOutputIndex() const;
125 
128  void updateStatus(const interfaces::WalletTxStatus& wtx, const uint256& block_hash, int numBlocks, int64_t block_time);
129 
132  bool statusUpdateNeeded(const uint256& block_hash) const;
133 };
134 
135 #endif // BITCOIN_QT_TRANSACTIONRECORD_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
UI model for a transaction.
int idx
Subtransaction index, for sort key.
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
TransactionRecord(uint256 _hash, qint64 _time)
TransactionStatus status
Status: can change with block chain update.
int getOutputIndex() const
Return the output index of the subtransaction
QString getTxHash() const
Return the unique identifier for this transaction (part)
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
TransactionRecord(uint256 _hash, qint64 _time, Type _type, const std::string &_address, const CAmount &_debit, const CAmount &_credit)
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
256-bit opaque blob.
Definition: uint256.h:106
UI model for transaction status.
bool countsForBalance
Transaction counts towards available balance.
uint256 m_cur_block_hash
Current block hash (to know whether cached status is still valid)
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
@ Unconfirmed
Normal (sent/received) transactions.
@ Immature
Generated (mined) transactions.
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
@ NotAccepted
Mined but not accepted.
@ Conflicted
Conflicts with other transaction or mempool.
@ Abandoned
Abandoned from the wallet.
std::string sortKey
Sorting key based on status.
Updated transaction status.
Definition: wallet.h:411