Bitcoin Core  22.99.0
P2P Digital Currency
transactionrecord.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 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 {
25 public:
28  { }
29 
30  enum Status {
32  Unconfirmed,
37  Immature,
40  };
41 
45  std::string sortKey;
46 
55  qint64 depth;
56  qint64 open_for;
63 
65 };
66 
71 {
72 public:
73  enum Type
74  {
82  };
83 
85  static const int RecommendedNumConfirmations = 6;
86 
88  hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
89  {
90  }
91 
92  TransactionRecord(uint256 _hash, qint64 _time):
93  hash(_hash), time(_time), type(Other), address(""), debit(0),
94  credit(0), idx(0)
95  {
96  }
97 
98  TransactionRecord(uint256 _hash, qint64 _time,
99  Type _type, const std::string &_address,
100  const CAmount& _debit, const CAmount& _credit):
101  hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
102  idx(0)
103  {
104  }
105 
108  static bool showTransaction();
109  static QList<TransactionRecord> decomposeTransaction(const interfaces::WalletTx& wtx);
110 
114  qint64 time;
116  std::string address;
122  int idx;
123 
126 
129 
131  QString getTxHash() const;
132 
134  int getOutputIndex() const;
135 
138  void updateStatus(const interfaces::WalletTxStatus& wtx, const uint256& block_hash, int numBlocks, int64_t block_time);
139 
142  bool statusUpdateNeeded(const uint256& block_hash) const;
143 };
144 
145 #endif // BITCOIN_QT_TRANSACTIONRECORD_H
TransactionRecord::TransactionRecord
TransactionRecord(uint256 _hash, qint64 _time, Type _type, const std::string &_address, const CAmount &_debit, const CAmount &_credit)
Definition: transactionrecord.h:98
interfaces
Definition: dummywallet.cpp:10
TransactionRecord::statusUpdateNeeded
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
Definition: transactionrecord.cpp:226
TransactionRecord::getTxHash
QString getTxHash() const
Return the unique identifier for this transaction (part)
Definition: transactionrecord.cpp:232
TransactionRecord::idx
int idx
Subtransaction index, for sort key.
Definition: transactionrecord.h:122
TransactionRecord::decomposeTransaction
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
Definition: transactionrecord.cpp:32
TransactionStatus::sortKey
std::string sortKey
Sorting key based on status.
Definition: transactionrecord.h:45
TransactionStatus::needsUpdate
bool needsUpdate
Definition: transactionrecord.h:64
TransactionRecord::TransactionRecord
TransactionRecord(uint256 _hash, qint64 _time)
Definition: transactionrecord.h:92
TransactionRecord::status
TransactionStatus status
Status: can change with block chain update.
Definition: transactionrecord.h:125
TransactionRecord::hash
uint256 hash
Definition: transactionrecord.h:113
TransactionRecord::RecvWithAddress
@ RecvWithAddress
Definition: transactionrecord.h:79
uint256.h
TransactionStatus::Conflicted
@ Conflicted
Conflicts with other transaction or mempool.
Definition: transactionrecord.h:35
TransactionRecord::credit
CAmount credit
Definition: transactionrecord.h:118
TransactionRecord::RecommendedNumConfirmations
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Definition: transactionrecord.h:85
TransactionStatus::TransactionStatus
TransactionStatus()
Definition: transactionrecord.h:26
TransactionRecord::RecvFromOther
@ RecvFromOther
Definition: transactionrecord.h:80
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:70
TransactionRecord::time
qint64 time
Definition: transactionrecord.h:114
TransactionStatus::m_cur_block_hash
uint256 m_cur_block_hash
Current block hash (to know whether cached status is still valid)
Definition: transactionrecord.h:62
TransactionStatus::open_for
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Definition: transactionrecord.h:56
TransactionRecord::SendToOther
@ SendToOther
Definition: transactionrecord.h:78
TransactionStatus::Status
Status
Definition: transactionrecord.h:30
TransactionRecord::involvesWatchAddress
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
Definition: transactionrecord.h:128
interfaces::WalletTx
Definition: wallet.h:385
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
TransactionRecord::Generated
@ Generated
Definition: transactionrecord.h:76
uint256
256-bit opaque blob.
Definition: uint256.h:126
interfaces::WalletTxStatus
Updated transaction status.
Definition: wallet.h:401
TransactionRecord::debit
CAmount debit
Definition: transactionrecord.h:117
TransactionStatus::Abandoned
@ Abandoned
Abandoned from the wallet.
Definition: transactionrecord.h:36
TransactionRecord::SendToSelf
@ SendToSelf
Definition: transactionrecord.h:81
TransactionStatus::Immature
@ Immature
Generated (mined) transactions.
Definition: transactionrecord.h:38
TransactionRecord::type
Type type
Definition: transactionrecord.h:115
TransactionStatus::Confirmed
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
Definition: transactionrecord.h:31
TransactionRecord::address
std::string address
Definition: transactionrecord.h:116
TransactionRecord::Type
Type
Definition: transactionrecord.h:73
TransactionStatus
UI model for transaction status.
Definition: transactionrecord.h:23
TransactionStatus::Confirming
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
Definition: transactionrecord.h:34
TransactionStatus::status
Status status
Definition: transactionrecord.h:54
TransactionStatus::matures_in
int matures_in
Definition: transactionrecord.h:49
TransactionRecord::getOutputIndex
int getOutputIndex() const
Return the output index of the subtransaction
Definition: transactionrecord.cpp:237
TransactionRecord::SendToAddress
@ SendToAddress
Definition: transactionrecord.h:77
TransactionStatus::depth
qint64 depth
Definition: transactionrecord.h:55
TransactionStatus::NotAccepted
@ NotAccepted
Mined but not accepted.
Definition: transactionrecord.h:39
TransactionStatus::countsForBalance
bool countsForBalance
Transaction counts towards available balance.
Definition: transactionrecord.h:43
TransactionStatus::Unconfirmed
@ Unconfirmed
Normal (sent/received) transactions.
Definition: transactionrecord.h:33
TransactionRecord::TransactionRecord
TransactionRecord()
Definition: transactionrecord.h:87
amount.h
TransactionRecord::updateStatus
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
Definition: transactionrecord.cpp:168
TransactionRecord::Other
@ Other
Definition: transactionrecord.h:75
TransactionRecord::showTransaction
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
Definition: transactionrecord.cpp:22