Bitcoin Core 32.1.0
P2P Digital Currency
Loading...
Searching...
No Matches
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.
 CTransaction (CMutableTransaction &&tx)
template<typename Stream>
void Serialize (Stream &s) const
template<typename Stream>
 CTransaction (deserialize_type, const TransactionSerParams &params, Stream &s)
 This deserializing constructor is provided instead of an Unserialize method.
template<typename Stream>
 CTransaction (deserialize_type, Stream &s)
bool IsNull () const
const Txid & GetHash () const LIFETIMEBOUND
const Wtxid & GetWitnessHash () const LIFETIMEBOUND
CAmount GetValueOut () const
unsigned int ComputeTotalSize () const
 Calculate the total transaction size in bytes, including witness data.
bool IsCoinBase () const
bool Equals (const CTransaction &other, const EqualsOptions opts={}) const
std::string ToString () const
bool HasWitness () const

Public Attributes

const std::vector< CTxIn > vin
const std::vector< CTxOut > vout
const uint32_t version
const uint32_t nLockTime

Static Public Attributes

static constexpr uint32_t CURRENT_VERSION {2}

Private Member Functions

Txid ComputeHash () const
Wtxid ComputeWitnessHash () const
bool ComputeHasWitness () const

Private Attributes

const bool m_has_witness
 Memory only.
const Txid hash
const Wtxid m_witness_hash

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 286 of file transaction.h.

Constructor & Destructor Documentation

◆ CTransaction() [1/4]

CTransaction::CTransaction ( const CMutableTransaction & tx)
explicit

Convert a CMutableTransaction into a CTransaction.

Definition at line 95 of file transaction.cpp.

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

◆ CTransaction() [2/4]

CTransaction::CTransaction ( CMutableTransaction && tx)
explicit

Definition at line 96 of file transaction.cpp.

Here is the call graph for this function:

◆ CTransaction() [3/4]

template<typename Stream>
CTransaction::CTransaction ( deserialize_type ,
const TransactionSerParams & params,
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 326 of file transaction.h.

Here is the call graph for this function:

◆ CTransaction() [4/4]

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

Definition at line 328 of file transaction.h.

Here is the call graph for this function:

Member Function Documentation

◆ ComputeHash()

Txid CTransaction::ComputeHash ( ) const
private

Definition at line 81 of file transaction.cpp.

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

◆ ComputeHasWitness()

bool CTransaction::ComputeHasWitness ( ) const
private

Definition at line 74 of file transaction.cpp.

Here is the caller graph for this function:

◆ ComputeTotalSize()

unsigned int CTransaction::ComputeTotalSize ( ) const

Calculate 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 110 of file transaction.cpp.

Here is the caller graph for this function:

◆ ComputeWitnessHash()

Wtxid CTransaction::ComputeWitnessHash ( ) const
private

Definition at line 86 of file transaction.cpp.

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

◆ Equals()

bool CTransaction::Equals ( const CTransaction & other,
const EqualsOptions opts = {} ) const
inline

Definition at line 352 of file transaction.h.

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

◆ GetHash()

const Txid & CTransaction::GetHash ( ) const
inline

Definition at line 334 of file transaction.h.

Here is the caller graph for this function:

◆ GetValueOut()

CAmount CTransaction::GetValueOut ( ) const

Definition at line 98 of file transaction.cpp.

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

◆ GetWitnessHash()

const Wtxid & CTransaction::GetWitnessHash ( ) const
inline

Definition at line 335 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 caller graph for this function:

◆ IsCoinBase()

bool CTransaction::IsCoinBase ( ) const
inline

Definition at line 347 of file transaction.h.

Here is the caller graph for this function:

◆ IsNull()

bool CTransaction::IsNull ( ) const
inline

Definition at line 330 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 319 of file transaction.h.

Here is the call graph for this function:

◆ ToString()

std::string CTransaction::ToString ( ) const

Definition at line 115 of file transaction.cpp.

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

Member Data Documentation

◆ CURRENT_VERSION

uint32_t CTransaction::CURRENT_VERSION {2}
staticconstexpr

Definition at line 290 of file transaction.h.

◆ hash

const Txid CTransaction::hash
private

Definition at line 305 of file transaction.h.

◆ m_has_witness

const bool CTransaction::m_has_witness
private

Memory only.

Definition at line 304 of file transaction.h.

◆ m_witness_hash

const Wtxid CTransaction::m_witness_hash
private

Definition at line 306 of file transaction.h.

◆ nLockTime

const uint32_t CTransaction::nLockTime

Definition at line 300 of file transaction.h.

◆ version

const uint32_t CTransaction::version

Definition at line 299 of file transaction.h.

◆ vin

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

Definition at line 297 of file transaction.h.

◆ vout

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

Definition at line 298 of file transaction.h.


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