Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactionrecord.h
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_QT_TRANSACTIONRECORD_H | #ifndef BITCOIN_QT_TRANSACTIONRECORD_H | ||||
#define BITCOIN_QT_TRANSACTIONRECORD_H | #define BITCOIN_QT_TRANSACTIONRECORD_H | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <primitives/blockhash.h> | |||||
#include <primitives/txid.h> | #include <primitives/txid.h> | ||||
#include <QList> | #include <QList> | ||||
#include <QString> | #include <QString> | ||||
namespace interfaces { | namespace interfaces { | ||||
class Node; | class Node; | ||||
class Wallet; | class Wallet; | ||||
struct WalletTx; | struct WalletTx; | ||||
struct WalletTxStatus; | struct WalletTxStatus; | ||||
} // namespace interfaces | } // namespace interfaces | ||||
/** | /** | ||||
* UI model for transaction status. The transaction status is the part of a | * UI model for transaction status. The transaction status is the part of a | ||||
* transaction that will change over time. | * transaction that will change over time. | ||||
*/ | */ | ||||
class TransactionStatus { | class TransactionStatus { | ||||
public: | public: | ||||
TransactionStatus() | TransactionStatus() | ||||
: countsForBalance(false), sortKey(""), matures_in(0), | : countsForBalance(false), sortKey(""), matures_in(0), | ||||
status(Unconfirmed), depth(0), open_for(0), cur_num_blocks(-1) {} | status(Unconfirmed), depth(0), open_for(0) {} | ||||
enum Status { | enum Status { | ||||
/** | /** | ||||
* Have 6 or more confirmations (normal tx) or fully mature (mined tx) | * Have 6 or more confirmations (normal tx) or fully mature (mined tx) | ||||
*/ | */ | ||||
Confirmed, | Confirmed, | ||||
/// Normal (sent/received) transactions | /// Normal (sent/received) transactions | ||||
/** Transaction not yet final, waiting for date */ | /** Transaction not yet final, waiting for date */ | ||||
Show All 34 Lines | public: | ||||
/** | /** | ||||
* Timestamp if status==OpenUntilDate, otherwise number of additional | * Timestamp if status==OpenUntilDate, otherwise number of additional | ||||
* blocks that need to be mined before finalization | * blocks that need to be mined before finalization | ||||
*/ | */ | ||||
qint64 open_for; | qint64 open_for; | ||||
/**@}*/ | /**@}*/ | ||||
/** Current number of blocks (to know whether cached status is still valid) | /** | ||||
* Current block hash (to know whether cached status is still valid) | |||||
*/ | */ | ||||
int cur_num_blocks; | BlockHash m_cur_block_hash{}; | ||||
}; | }; | ||||
/** | /** | ||||
* UI model for a transaction. A core transaction can be represented by multiple | * UI model for a transaction. A core transaction can be represented by multiple | ||||
* UI transactions if it has multiple outputs. | * UI transactions if it has multiple outputs. | ||||
*/ | */ | ||||
class TransactionRecord { | class TransactionRecord { | ||||
public: | public: | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | public: | ||||
/** Return the unique identifier for this transaction (part) */ | /** Return the unique identifier for this transaction (part) */ | ||||
QString getTxID() const; | QString getTxID() const; | ||||
/** Return the output index of the subtransaction */ | /** Return the output index of the subtransaction */ | ||||
int getOutputIndex() const; | int getOutputIndex() const; | ||||
/** Update status from core wallet tx. | /** Update status from core wallet tx. | ||||
*/ | */ | ||||
void updateStatus(const interfaces::WalletTxStatus &wtx, int numBlocks, | void updateStatus(const interfaces::WalletTxStatus &wtx, | ||||
const BlockHash &block_hash, int numBlocks, | |||||
int64_t block_time); | int64_t block_time); | ||||
/** Return whether a status update is needed. | /** Return whether a status update is needed. | ||||
*/ | */ | ||||
bool statusUpdateNeeded(int numBlocks) const; | bool statusUpdateNeeded(const BlockHash &block_hash) const; | ||||
}; | }; | ||||
#endif // BITCOIN_QT_TRANSACTIONRECORD_H | #endif // BITCOIN_QT_TRANSACTIONRECORD_H |