Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_QT_TRANSACTIONRECORD_H6#define BITCOIN_QT_TRANSACTIONRECORD_H8#include <consensus/amount.h>9#include <primitives/transaction_identifier.h>10#include <uint256.h>12#include <QList>13#include <QString>15namespace interfaces {16class Node;17class Wallet;18struct WalletTx;19struct WalletTxStatus;20}22/** UI model for transaction status. The transaction status is the part of a transaction that will change over time.23*/24struct TransactionStatus {25enum Status {26Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/27/// Normal (sent/received) transactions28Unconfirmed, /**< Not yet mined into a block **/29Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/30Conflicted, /**< Conflicts with other transaction or mempool **/31Abandoned, /**< Abandoned from the wallet **/32/// Generated (mined) transactions33Immature, /**< Mined but waiting for maturity */34NotAccepted /**< Mined but not accepted */35};37/// Transaction counts towards available balance38bool countsForBalance{false};39/// Sorting key based on status40std::string sortKey;42/** @name Generated (mined) transactions43@{*/44int matures_in{0};45/**@}*/47/** @name Reported status48@{*/49Status status{Unconfirmed};50qint64 depth{0};51/**@}*/53/** Current block hash (to know whether cached status is still valid) */54uint256 m_cur_block_hash{};56bool needsUpdate{false};57};59/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has60multiple outputs.61*/62class TransactionRecord63{64public:65enum Type66{67Other,68Generated,69SendToAddress,70SendToOther,71RecvWithAddress,72RecvFromOther,73};75/** Number of confirmation recommended for accepting a transaction */76static constexpr int RecommendedNumConfirmations{6};78TransactionRecord():79hash(), time(0), type(Other), debit(0), credit(0), idx(0)80{81}83TransactionRecord(Txid _hash, qint64 _time):84hash(_hash), time(_time), type(Other), debit(0),85credit(0), idx(0)86{87}89TransactionRecord(Txid _hash, qint64 _time,90Type _type, const std::string &_address,91const CAmount& _debit, const CAmount& _credit):92hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),93idx(0)94{95}97/** Decompose CWallet transaction to model transaction records.98*/99static bool showTransaction();100static QList<TransactionRecord> decomposeTransaction(const interfaces::WalletTx& wtx);102/** @name Immutable transaction attributes103@{*/104Txid hash;105qint64 time;106Type type;107std::string address;108CAmount debit;109CAmount credit;110/**@}*/112/** Subtransaction index, for sort key */113int idx;115/** Status: can change with block chain update */116TransactionStatus status;118/** Return the unique identifier for this transaction (part) */119QString getTxHash() const;121/** Return the output index of the subtransaction */122int getOutputIndex() const;124/** Update status from core wallet tx.125*/126void updateStatus(const interfaces::WalletTxStatus& wtx, const uint256& block_hash, int numBlocks, int64_t block_time);128/** Return whether a status update is needed.129*/130bool statusUpdateNeeded(const uint256& block_hash) const;131};133#endif // BITCOIN_QT_TRANSACTIONRECORD_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.