Bitcoin Core  25.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
CTransaction Class Reference

The basic transaction that is broadcasted on the network and contained in blocks. More...

#include <transaction.h>

Collaboration diagram for CTransaction:
[legend]

Public Member Functions

 CTransaction (const CMutableTransaction &tx)
 Convert a CMutableTransaction into a CTransaction. More...
 
 CTransaction (CMutableTransaction &&tx)
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename Stream >
 CTransaction (deserialize_type, Stream &s)
 This deserializing constructor is provided instead of an Unserialize method. More...
 
bool IsNull () const
 
const uint256GetHash () const
 
const uint256GetWitnessHash () const
 
CAmount GetValueOut () const
 
unsigned int GetTotalSize () const
 Get the total transaction size in bytes, including witness data. More...
 
bool IsCoinBase () const
 
std::string ToString () const
 
bool HasWitness () const
 

Public Attributes

const std::vector< CTxInvin
 
const std::vector< CTxOutvout
 
const int32_t nVersion
 
const uint32_t nLockTime
 

Static Public Attributes

static const int32_t CURRENT_VERSION =2
 

Private Member Functions

uint256 ComputeHash () const
 
uint256 ComputeWitnessHash () const
 

Private Attributes

const uint256 hash
 Memory only. More...
 
const uint256 m_witness_hash
 

Friends

bool operator== (const CTransaction &a, const CTransaction &b)
 
bool operator!= (const CTransaction &a, const CTransaction &b)
 

Detailed Description

The basic transaction that is broadcasted on the network and contained in blocks.

A transaction can contain multiple inputs and outputs.

Definition at line 294 of file transaction.h.

Constructor & Destructor Documentation

◆ CTransaction() [1/3]

CTransaction::CTransaction ( const CMutableTransaction tx)
explicit

Convert a CMutableTransaction into a CTransaction.

Definition at line 86 of file transaction.cpp.

◆ CTransaction() [2/3]

CTransaction::CTransaction ( CMutableTransaction &&  tx)
explicit

Definition at line 87 of file transaction.cpp.

◆ CTransaction() [3/3]

template<typename Stream >
CTransaction::CTransaction ( deserialize_type  ,
Stream &  s 
)
inline

This deserializing constructor is provided instead of an Unserialize method.

Unserialize is not possible, since it would require overwriting const fields.

Definition at line 331 of file transaction.h.

Member Function Documentation

◆ ComputeHash()

uint256 CTransaction::ComputeHash ( ) const
private

Definition at line 73 of file transaction.cpp.

Here is the call graph for this function:

◆ ComputeWitnessHash()

uint256 CTransaction::ComputeWitnessHash ( ) const
private

Definition at line 78 of file transaction.cpp.

Here is the call graph for this function:

◆ GetHash()

const uint256& CTransaction::GetHash ( ) const
inline

Definition at line 337 of file transaction.h.

Here is the caller graph for this function:

◆ GetTotalSize()

unsigned int CTransaction::GetTotalSize ( ) const

Get the total transaction size in bytes, including witness data.

"Total Size" defined in BIP141 and BIP144.

Returns
Total transaction size in bytes

Definition at line 101 of file transaction.cpp.

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

◆ GetValueOut()

CAmount CTransaction::GetValueOut ( ) const

Definition at line 89 of file transaction.cpp.

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

◆ GetWitnessHash()

const uint256& CTransaction::GetWitnessHash ( ) const
inline

Definition at line 338 of file transaction.h.

Here is the caller graph for this function:

◆ HasWitness()

bool CTransaction::HasWitness ( ) const
inline

Definition at line 367 of file transaction.h.

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

◆ IsCoinBase()

bool CTransaction::IsCoinBase ( ) const
inline

Definition at line 350 of file transaction.h.

Here is the caller graph for this function:

◆ IsNull()

bool CTransaction::IsNull ( ) const
inline

Definition at line 333 of file transaction.h.

Here is the caller graph for this function:

◆ Serialize()

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

Definition at line 324 of file transaction.h.

Here is the call graph for this function:

◆ ToString()

std::string CTransaction::ToString ( ) const

Definition at line 106 of file transaction.cpp.

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

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const CTransaction a,
const CTransaction b 
)
friend

Definition at line 360 of file transaction.h.

◆ operator==

bool operator== ( const CTransaction a,
const CTransaction b 
)
friend

Definition at line 355 of file transaction.h.

Member Data Documentation

◆ CURRENT_VERSION

const int32_t CTransaction::CURRENT_VERSION =2
static

Definition at line 298 of file transaction.h.

◆ hash

const uint256 CTransaction::hash
private

Memory only.

Definition at line 312 of file transaction.h.

◆ m_witness_hash

const uint256 CTransaction::m_witness_hash
private

Definition at line 313 of file transaction.h.

◆ nLockTime

const uint32_t CTransaction::nLockTime

Definition at line 308 of file transaction.h.

◆ nVersion

const int32_t CTransaction::nVersion

Definition at line 307 of file transaction.h.

◆ vin

const std::vector<CTxIn> CTransaction::vin

Definition at line 305 of file transaction.h.

◆ vout

const std::vector<CTxOut> CTransaction::vout

Definition at line 306 of file transaction.h.


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