Bitcoin Core 32.99.0
P2P Digital Currency
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
wallet::CWalletTx Class Reference

A transaction with a bunch of additional info that only the owner cares about. More...

#include <transaction.h>

Collaboration diagram for wallet::CWalletTx:
[legend]

Public Types

enum  AmountType { DEBIT , CREDIT , AMOUNTTYPE_ENUM_ELEMENTS }
 

Public Member Functions

 CWalletTx (CTransactionRef tx, const TxState &state)
 
template<typename Stream >
 CWalletTx (deserialize_type, Stream &s, const std::map< Wtxid, CTransactionRef > &variants)
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename Stream >
void Unserialize (Stream &s)
 
CTransactionRef GetTx () const
 
bool Update (CTransactionRef tx, const TxState &new_state, WalletBatch &batch, bool metadata_changed)
 
void MarkDirty ()
 make sure balances are recalculated More...
 
bool IsMalleation (const CWalletTx &tx) const
 True if tx is a malleation of this, i.e. More...
 
bool InMempool () const
 
int64_t GetTxTime () const
 
template<typename T >
const T * state () const
 
template<typename T >
T * state ()
 
void updateState (interfaces::Chain &chain)
 Update transaction state when attaching to a chain, filling in heights of conflicted and confirmed blocks. More...
 
bool isAbandoned () const
 
bool isMempoolConflicted () const
 
bool isBlockConflicted () const
 
bool isInactive () const
 
bool isUnconfirmed () const
 
bool isConfirmed () const
 
const TxidGetHash () const LIFETIMEBOUND
 
const WtxidGetWitnessHash () const LIFETIMEBOUND
 
bool IsCoinBase () const
 
const std::map< Wtxid, CTransactionRef > & GetTxs () const
 
 CWalletTx (const CWalletTx &)=delete
 
CWalletTxoperator= (const CWalletTx &)=delete
 
 CWalletTx (CWalletTx &&)=default
 

Public Attributes

std::optional< std::string > m_from
 
std::optional< std::string > m_message
 
std::optional< std::string > m_comment
 
std::optional< std::string > m_comment_to
 
std::optional< Txidm_replaces_txid
 
std::optional< Txidm_replaced_by_txid
 
std::vector< std::string > m_messages
 
std::vector< std::string > m_payment_requests
 
unsigned int nTimeReceived
 time received by this node More...
 
unsigned int nTimeSmart
 Stable timestamp that never changes, and reflects the order a transaction was added to the wallet. More...
 
std::optional< bool > m_cached_from_me {std::nullopt}
 
int64_t nOrderPos
 position in ordered transaction list More...
 
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
 
CachableAmount m_amounts [AMOUNTTYPE_ENUM_ELEMENTS]
 
bool m_is_cache_empty {true}
 This flag is true if all m_amounts caches are empty. More...
 
bool fChangeCached
 
CAmount nChangeCached
 
TxState m_state
 
std::set< Txidmempool_conflicts
 
std::optional< Txidtruc_child_in_mempool
 

Private Member Functions

void SetDefaults ()
 
void Init ()
 
void RecomputeCanonical ()
 Set m_canonical_wtxid to the best variant under the unconfirmed rule (witnessed preferred, then least weight). More...
 

Private Attributes

Wtxid m_canonical_wtxid
 
std::map< Wtxid, CTransactionRefm_txs
 

Detailed Description

A transaction with a bunch of additional info that only the owner cares about.

It includes any unrecorded transactions needed to link it back to the block chain.

Definition at line 193 of file transaction.h.

Member Enumeration Documentation

◆ AmountType

Enumerator
DEBIT 
CREDIT 
AMOUNTTYPE_ENUM_ELEMENTS 

Definition at line 227 of file transaction.h.

Constructor & Destructor Documentation

◆ CWalletTx() [1/4]

wallet::CWalletTx::CWalletTx ( CTransactionRef  tx,
const TxState state 
)
inline

Definition at line 239 of file transaction.h.

Here is the call graph for this function:

◆ CWalletTx() [2/4]

template<typename Stream >
wallet::CWalletTx::CWalletTx ( deserialize_type  ,
Stream &  s,
const std::map< Wtxid, CTransactionRef > &  variants 
)
inline

Definition at line 248 of file transaction.h.

Here is the call graph for this function:

◆ CWalletTx() [3/4]

wallet::CWalletTx::CWalletTx ( const CWalletTx )
delete

◆ CWalletTx() [4/4]

wallet::CWalletTx::CWalletTx ( CWalletTx &&  )
default

Member Function Documentation

◆ GetHash()

const Txid & wallet::CWalletTx::GetHash ( ) const
inline

Definition at line 390 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTx()

CTransactionRef wallet::CWalletTx::GetTx ( ) const
inline

Definition at line 351 of file transaction.h.

Here is the caller graph for this function:

◆ GetTxs()

const std::map< Wtxid, CTransactionRef > & wallet::CWalletTx::GetTxs ( ) const
inline

Definition at line 394 of file transaction.h.

Here is the caller graph for this function:

◆ GetTxTime()

int64_t wallet::CWalletTx::GetTxTime ( ) const

Definition at line 24 of file transaction.cpp.

Here is the caller graph for this function:

◆ GetWitnessHash()

const Wtxid & wallet::CWalletTx::GetWitnessHash ( ) const
inline

Definition at line 391 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void wallet::CWalletTx::Init ( )
inlineprivate

Definition at line 415 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InMempool()

bool wallet::CWalletTx::InMempool ( ) const

Definition at line 19 of file transaction.cpp.

Here is the caller graph for this function:

◆ isAbandoned()

bool wallet::CWalletTx::isAbandoned ( ) const
inline

Definition at line 384 of file transaction.h.

Here is the caller graph for this function:

◆ isBlockConflicted()

bool wallet::CWalletTx::isBlockConflicted ( ) const
inline

Definition at line 386 of file transaction.h.

Here is the caller graph for this function:

◆ IsCoinBase()

bool wallet::CWalletTx::IsCoinBase ( ) const
inline

Definition at line 392 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isConfirmed()

bool wallet::CWalletTx::isConfirmed ( ) const
inline

Definition at line 389 of file transaction.h.

Here is the caller graph for this function:

◆ isInactive()

bool wallet::CWalletTx::isInactive ( ) const
inline

Definition at line 387 of file transaction.h.

Here is the caller graph for this function:

◆ IsMalleation()

bool wallet::CWalletTx::IsMalleation ( const CWalletTx tx) const

True if tx is a malleation of this, i.e.

it has the exact same version, locktime, input order, input outpoints, input sequences, and outputs. Input scriptSigs and input scriptWitnesses may differ.

Definition at line 14 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isMempoolConflicted()

bool wallet::CWalletTx::isMempoolConflicted ( ) const
inline

Definition at line 385 of file transaction.h.

Here is the caller graph for this function:

◆ isUnconfirmed()

bool wallet::CWalletTx::isUnconfirmed ( ) const
inline

Definition at line 388 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MarkDirty()

void wallet::CWalletTx::MarkDirty ( )
inline

make sure balances are recalculated

Definition at line 360 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

CWalletTx & wallet::CWalletTx::operator= ( const CWalletTx )
delete

◆ RecomputeCanonical()

void wallet::CWalletTx::RecomputeCanonical ( )
private

Set m_canonical_wtxid to the best variant under the unconfirmed rule (witnessed preferred, then least weight).

Ignores state.

Definition at line 98 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serialize()

template<typename Stream >
void wallet::CWalletTx::Serialize ( Stream &  s) const
inline

Definition at line 275 of file transaction.h.

Here is the call graph for this function:

◆ SetDefaults()

void wallet::CWalletTx::SetDefaults ( )
inlineprivate

Definition at line 406 of file transaction.h.

Here is the caller graph for this function:

◆ state() [1/2]

template<typename T >
T * wallet::CWalletTx::state ( )
inline

Definition at line 378 of file transaction.h.

◆ state() [2/2]

template<typename T >
const T * wallet::CWalletTx::state ( ) const
inline

Definition at line 377 of file transaction.h.

Here is the caller graph for this function:

◆ Unserialize()

template<typename Stream >
void wallet::CWalletTx::Unserialize ( Stream &  s)
inline

Definition at line 307 of file transaction.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update()

bool wallet::CWalletTx::Update ( CTransactionRef  tx,
const TxState new_state,
WalletBatch batch,
bool  metadata_changed 
)

Definition at line 55 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateState()

void wallet::CWalletTx::updateState ( interfaces::Chain chain)

Update transaction state when attaching to a chain, filling in heights of conflicted and confirmed blocks.

Definition at line 30 of file transaction.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fChangeCached

bool wallet::CWalletTx::fChangeCached
mutable

Definition at line 236 of file transaction.h.

◆ m_amounts

CachableAmount wallet::CWalletTx::m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
mutable

Definition at line 228 of file transaction.h.

◆ m_cached_from_me

std::optional<bool> wallet::CWalletTx::m_cached_from_me {std::nullopt}
mutable

Definition at line 222 of file transaction.h.

◆ m_canonical_wtxid

Wtxid wallet::CWalletTx::m_canonical_wtxid
private

Definition at line 422 of file transaction.h.

◆ m_comment

std::optional<std::string> wallet::CWalletTx::m_comment

Definition at line 202 of file transaction.h.

◆ m_comment_to

std::optional<std::string> wallet::CWalletTx::m_comment_to

Definition at line 203 of file transaction.h.

◆ m_from

std::optional<std::string> wallet::CWalletTx::m_from

Definition at line 199 of file transaction.h.

◆ m_is_cache_empty

bool wallet::CWalletTx::m_is_cache_empty {true}
mutable

This flag is true if all m_amounts caches are empty.

This is particularly useful in places where MarkDirty is conditionally called and the condition can be expensive and thus can be skipped if the flag is true. See MarkDestinationsDirty.

Definition at line 235 of file transaction.h.

◆ m_it_wtxOrdered

std::multimap<int64_t,CWalletTx*>::const_iterator wallet::CWalletTx::m_it_wtxOrdered

Definition at line 224 of file transaction.h.

◆ m_message

std::optional<std::string> wallet::CWalletTx::m_message

Definition at line 200 of file transaction.h.

◆ m_messages

std::vector<std::string> wallet::CWalletTx::m_messages

Definition at line 207 of file transaction.h.

◆ m_payment_requests

std::vector<std::string> wallet::CWalletTx::m_payment_requests

Definition at line 209 of file transaction.h.

◆ m_replaced_by_txid

std::optional<Txid> wallet::CWalletTx::m_replaced_by_txid

Definition at line 205 of file transaction.h.

◆ m_replaces_txid

std::optional<Txid> wallet::CWalletTx::m_replaces_txid

Definition at line 204 of file transaction.h.

◆ m_state

TxState wallet::CWalletTx::m_state

Definition at line 260 of file transaction.h.

◆ m_txs

std::map<Wtxid, CTransactionRef> wallet::CWalletTx::m_txs
private

Definition at line 423 of file transaction.h.

◆ mempool_conflicts

std::set<Txid> wallet::CWalletTx::mempool_conflicts

Definition at line 268 of file transaction.h.

◆ nChangeCached

CAmount wallet::CWalletTx::nChangeCached
mutable

Definition at line 237 of file transaction.h.

◆ nOrderPos

int64_t wallet::CWalletTx::nOrderPos

position in ordered transaction list

Definition at line 223 of file transaction.h.

◆ nTimeReceived

unsigned int wallet::CWalletTx::nTimeReceived

time received by this node

Definition at line 210 of file transaction.h.

◆ nTimeSmart

unsigned int wallet::CWalletTx::nTimeSmart

Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.

Timestamp is based on the block time for a transaction added as part of a block, or else the time when the transaction was received if it wasn't part of a block, with the timestamp adjusted in both cases so timestamp order matches the order transactions were added to the wallet. More details can be found in CWallet::ComputeTimeSmart().

Definition at line 220 of file transaction.h.

◆ truc_child_in_mempool

std::optional<Txid> wallet::CWalletTx::truc_child_in_mempool

Definition at line 272 of file transaction.h.


The documentation for this class was generated from the following files: