Bitcoin Core  0.20.99
P2P Digital Currency
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
CWalletTx Class Reference

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

#include <wallet.h>

Collaboration diagram for CWalletTx:
[legend]

Classes

struct  Confirmation
 

Public Types

enum  AmountType {
  DEBIT, CREDIT, IMMATURE_CREDIT, AVAILABLE_CREDIT,
  AMOUNTTYPE_ENUM_ELEMENTS
}
 
enum  Status { UNCONFIRMED, CONFIRMED, CONFLICTED, ABANDONED }
 

Public Member Functions

CAmount GetCachableAmount (AmountType type, const isminefilter &filter, bool recalculate=false) const
 
 CWalletTx (const CWallet *wallet, CTransactionRef arg)
 
void Init ()
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename Stream >
void Unserialize (Stream &s)
 
void SetTx (CTransactionRef arg)
 
void MarkDirty ()
 make sure balances are recalculated More...
 
CAmount GetDebit (const isminefilter &filter) const
 filter decides which addresses will count towards the debit More...
 
CAmount GetCredit (const isminefilter &filter) const
 
CAmount GetImmatureCredit (bool fUseCache=true) const
 
CAmount GetAvailableCredit (bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS
 
CAmount GetImmatureWatchOnlyCredit (const bool fUseCache=true) const
 
CAmount GetChange () const
 
int GetSpendSize (unsigned int out, bool use_max_sig=false) const
 
void GetAmounts (std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter) const
 
bool IsFromMe (const isminefilter &filter) const
 
bool IsEquivalentTo (const CWalletTx &tx) const
 
bool InMempool () const
 
bool IsTrusted () const
 
bool IsTrusted (std::set< uint256 > &trusted_parents) const
 
int64_t GetTxTime () const
 
bool SubmitMemoryPoolAndRelay (std::string &err_string, bool relay)
 
std::set< uint256GetConflicts () const NO_THREAD_SAFETY_ANALYSIS
 
int GetDepthInMainChain () const NO_THREAD_SAFETY_ANALYSIS
 Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockchain 0 : in memory pool, waiting to be included in a block >=1 : this many blocks deep in the main chain. More...
 
bool IsInMainChain () const
 
int GetBlocksToMaturity () const
 
bool isAbandoned () const
 
void setAbandoned ()
 
bool isConflicted () const
 
void setConflicted ()
 
bool isUnconfirmed () const
 
void setUnconfirmed ()
 
bool isConfirmed () const
 
void setConfirmed ()
 
const uint256GetHash () const
 
bool IsCoinBase () const
 
bool IsImmatureCoinBase () const
 
 CWalletTx (CWalletTx const &)=delete
 
void operator= (CWalletTx const &x)=delete
 

Public Attributes

mapValue_t mapValue
 Key/value map with information about the transaction. More...
 
std::vector< std::pair< std::string, std::string > > vOrderForm
 
unsigned int fTimeReceivedIsTxTime
 
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...
 
bool fFromMe
 From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node, and set to 0 for transactions that were created externally and came in through the network or sendrawtransaction RPC. More...
 
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
 
bool fInMempool
 
CAmount nChangeCached
 
CTransactionRef tx
 
Confirmation m_confirm
 

Private Attributes

const CWalletpwallet
 

Static Private Attributes

static const uint256 ABANDON_HASH
 Constant used in hashBlock to indicate tx has been abandoned, only used at serialization/deserialization to avoid ambiguity with conflicted. More...
 

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 265 of file wallet.h.

Member Enumeration Documentation

◆ AmountType

Enumerator
DEBIT 
CREDIT 
IMMATURE_CREDIT 
AVAILABLE_CREDIT 
AMOUNTTYPE_ENUM_ELEMENTS 

Definition at line 325 of file wallet.h.

◆ Status

Enumerator
UNCONFIRMED 
CONFIRMED 
CONFLICTED 
ABANDONED 

Definition at line 371 of file wallet.h.

Constructor & Destructor Documentation

◆ CWalletTx() [1/2]

CWalletTx::CWalletTx ( const CWallet wallet,
CTransactionRef  arg 
)
inline

Definition at line 339 of file wallet.h.

◆ CWalletTx() [2/2]

CWalletTx::CWalletTx ( CWalletTx const &  )
delete

Member Function Documentation

◆ GetBlocksToMaturity()

int CWalletTx::GetBlocksToMaturity ( ) const
Returns
number of blocks to maturity for this transaction: 0 : is not a coinbase transaction, or is a mature coinbase transaction >0 : is a coinbase transaction which matures in this many blocks

Definition at line 4167 of file wallet.cpp.

◆ GetDepthInMainChain()

int CWalletTx::GetDepthInMainChain ( ) const

Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockchain 0 : in memory pool, waiting to be included in a block >=1 : this many blocks deep in the main chain.

Definition at line 4158 of file wallet.cpp.

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

◆ GetHash()

const uint256& CWalletTx::GetHash ( ) const
inline

Definition at line 545 of file wallet.h.

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

◆ GetSpendSize()

int CWalletTx::GetSpendSize ( unsigned int  out,
bool  use_max_sig = false 
) const
inline

Definition at line 477 of file wallet.h.

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

◆ Init()

void CWalletTx::Init ( )
inline

Definition at line 346 of file wallet.h.

◆ isAbandoned()

bool CWalletTx::isAbandoned ( ) const
inline

Definition at line 531 of file wallet.h.

Here is the caller graph for this function:

◆ IsCoinBase()

bool CWalletTx::IsCoinBase ( ) const
inline

Definition at line 546 of file wallet.h.

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

◆ isConfirmed()

bool CWalletTx::isConfirmed ( ) const
inline

Definition at line 543 of file wallet.h.

Here is the caller graph for this function:

◆ isConflicted()

bool CWalletTx::isConflicted ( ) const
inline

Definition at line 539 of file wallet.h.

Here is the caller graph for this function:

◆ IsFromMe()

bool CWalletTx::IsFromMe ( const isminefilter filter) const
inline

Definition at line 485 of file wallet.h.

Here is the caller graph for this function:

◆ IsImmatureCoinBase()

bool CWalletTx::IsImmatureCoinBase ( ) const

Definition at line 4176 of file wallet.cpp.

Here is the caller graph for this function:

◆ IsInMainChain()

bool CWalletTx::IsInMainChain ( ) const
inline

Definition at line 523 of file wallet.h.

◆ isUnconfirmed()

bool CWalletTx::isUnconfirmed ( ) const
inline

Definition at line 541 of file wallet.h.

Here is the caller graph for this function:

◆ MarkDirty()

void CWalletTx::MarkDirty ( )
inline

make sure balances are recalculated

Definition at line 454 of file wallet.h.

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

◆ operator=()

void CWalletTx::operator= ( CWalletTx const &  x)
delete

◆ Serialize()

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

< Used to be vMerkleBranch

< Used to be vtxPrev

< Used to be fSpent

Definition at line 394 of file wallet.h.

Here is the call graph for this function:

◆ setAbandoned()

void CWalletTx::setAbandoned ( )
inline

Definition at line 532 of file wallet.h.

◆ setConfirmed()

void CWalletTx::setConfirmed ( )
inline

Definition at line 544 of file wallet.h.

◆ setConflicted()

void CWalletTx::setConflicted ( )
inline

Definition at line 540 of file wallet.h.

◆ SetTx()

void CWalletTx::SetTx ( CTransactionRef  arg)
inline

Definition at line 448 of file wallet.h.

Here is the caller graph for this function:

◆ setUnconfirmed()

void CWalletTx::setUnconfirmed ( )
inline

Definition at line 542 of file wallet.h.

Here is the caller graph for this function:

◆ Unserialize()

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

< Used to be vMerkleBranch

< Used to be vtxPrev

Used to be fSpent

Definition at line 413 of file wallet.h.

Here is the call graph for this function:

Member Data Documentation

◆ ABANDON_HASH

const uint256 CWalletTx::ABANDON_HASH
staticprivate

Constant used in hashBlock to indicate tx has been abandoned, only used at serialization/deserialization to avoid ambiguity with conflicted.

Definition at line 273 of file wallet.h.

◆ fChangeCached

bool CWalletTx::fChangeCached
mutable

Definition at line 335 of file wallet.h.

◆ fFromMe

bool CWalletTx::fFromMe

From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node, and set to 0 for transactions that were created externally and came in through the network or sendrawtransaction RPC.

Definition at line 320 of file wallet.h.

◆ fInMempool

bool CWalletTx::fInMempool
mutable

Definition at line 336 of file wallet.h.

◆ fTimeReceivedIsTxTime

unsigned int CWalletTx::fTimeReceivedIsTxTime

Definition at line 303 of file wallet.h.

◆ m_amounts

CachableAmount CWalletTx::m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
mutable

Definition at line 327 of file wallet.h.

◆ m_confirm

Confirmation CWalletTx::m_confirm

Definition at line 391 of file wallet.h.

◆ m_is_cache_empty

bool 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 334 of file wallet.h.

◆ m_it_wtxOrdered

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

Definition at line 322 of file wallet.h.

◆ mapValue

mapValue_t CWalletTx::mapValue

Key/value map with information about the transaction.

The following keys can be read and written through the map and are serialized in the wallet database:

"comment", "to"   - comment strings provided to sendtoaddress,
                    and sendmany wallet RPCs
"replaces_txid"   - txid (as HexStr) of transaction replaced by
                    bumpfee on transaction created by bumpfee
"replaced_by_txid" - txid (as HexStr) of transaction created by
                    bumpfee on transaction replaced by bumpfee
"from", "message" - obsolete fields that could be set in UI prior to
                    2011 (removed in commit 4d9b223)

The following keys are serialized in the wallet database, but shouldn't be read or written through the map (they will be temporarily added and removed from the map during serialization):

"fromaccount"     - serialized strFromAccount value
"n"               - serialized nOrderPos value
"timesmart"       - serialized nTimeSmart value
"spent"           - serialized vfSpent value that existed prior to
                    2014 (removed in commit 93a18a3)

Definition at line 301 of file wallet.h.

◆ nChangeCached

CAmount CWalletTx::nChangeCached
mutable

Definition at line 337 of file wallet.h.

◆ nOrderPos

int64_t CWalletTx::nOrderPos

position in ordered transaction list

Definition at line 321 of file wallet.h.

◆ nTimeReceived

unsigned int CWalletTx::nTimeReceived

time received by this node

Definition at line 304 of file wallet.h.

◆ nTimeSmart

unsigned int 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 314 of file wallet.h.

◆ pwallet

const CWallet* CWalletTx::pwallet
private

Definition at line 268 of file wallet.h.

◆ tx

CTransactionRef CWalletTx::tx

Definition at line 361 of file wallet.h.

◆ vOrderForm

std::vector<std::pair<std::string, std::string> > CWalletTx::vOrderForm

Definition at line 302 of file wallet.h.


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