The basic transaction that is broadcasted on the network and contained in blocks. A transaction can contain multiple inputs and outputs.

Synopsis

Declared in <primitives/transaction.h>

class CTransaction;

Member Functions

Name

Description

CTransaction [constructor]

Constructors

ComputeTotalSize

Calculate the total transaction size in bytes, including witness data. "Total Size" defined in BIP141 and BIP144.

GetHash

Returns the cached transaction id.

GetValueOut

Returns the total value of all outputs.

GetWitnessHash

Returns the cached witness transaction id.

HasWitness

Returns true when any input carries witness data.

IsCoinBase

Returns true when the transaction is a coinbase.

IsNull

Returns true when the transaction has no inputs and no outputs.

Serialize

Serializes the transaction using the stream's transaction parameters.

ToString

Returns a human‐readable description of the transaction.

Data Members

Name

Description

nLockTime

Lock time before which the transaction is not valid.

version

Transaction version number.

vin

Inputs spent by this transaction.

vout

Outputs created by this transaction.

Static Data Members

Name

Description

CURRENT_VERSION

Default transaction version used for newly created transactions.

Friends

Name

Description

operator==

Compares two transactions for equality by witness hash.

Non-Member Functions

Name

Description

CalculateSequenceLocks

Calculates the block height and previous block's median time past at which the transaction will be considered final in the context of BIP 68. For each input that is not sequence locked, the corresponding entries in prevHeights are set to 0 as they do not affect the calculation.

CheckTransaction

Performs context‐independent validity checks on a transaction.

EncodeHexTx

Serialize a transaction and encode it as a hex string.

GetDust

Get the vout index numbers of all dust outputs

GetEntriesForConflicts

Get all descendants of iters_conflicting. Checks that there are no more than MAX_REPLACEMENT_CANDIDATES distinct clusters affected.

GetLegacySigOpCount

Count ECDSA signature operations the old‐fashioned (pre‐0.6) way

GetP2SHSigOpCount

Count ECDSA signature operations in pay‐to‐script‐hash inputs.

GetTransactionSigOpCost

Compute total signature operation cost of a transaction.

GetVirtualTransactionSize

Compute the virtual size of a transaction, accounting for sigop cost.

IsFinalTx

Check if transaction is final and can be included in a block with the specified height and time. Consensus critical.

IsRBFOptIn

Determine whether an unconfirmed transaction is signaling opt‐in to RBF according to BIP 125 This involves checking sequence numbers of the transaction, as well as the sequence numbers of all in‐mempool ancestors.

IsRBFOptInEmptyMempool

Determine the RBF signaling state of a transaction assuming an empty mempool.

IsStandardTx

Check for standard transaction types

IsWitnessStandard

Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements These limits are adequate for multisignatures up to n‐of‐100 using OP_CHECKSIG, OP_ADD, and OP_EQUAL.

PreCheckEphemeralTx

Called for each transaction once transaction fees are known. Does context‐less checks about a single transaction.

SequenceLocks

Check if transaction is final per BIP 68 sequence numbers and can be included in a block. Consensus critical. Takes as input a list of heights at which tx's inputs (in order) confirmed.

SignalsOptInRBF

Check whether the sequence numbers on this transaction are signaling opt‐in to replace‐by‐fee, according to BIP 125. Allow opt‐out of transaction replacement by setting nSequence > MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL‐2) on all inputs.

SpendsNonAnchorWitnessProg

Check whether this transaction spends any witness program but P2A, including not‐yet‐defined ones. May return false early for consensus‐invalid transactions.

TxToUniv

Fill a JSON object with a human‐readable description of a transaction.

ValidateInputsStandardness

Check for standard transaction types

Consensus::CheckTxInputs

Check whether all inputs of this transaction are valid (no double spends and amounts) This does not modify the UTXO set. This does not check scripts and sigs.

wallet::CalculateMaximumSignedTxSize

Calculate the size of the transaction using CoinControl to determine whether to expect signature grinding when calculating the size of the input spend.

wallet::CalculateMaximumSignedTxSize

Calculate the size of the transaction, looking up previous outputs from the wallet.

Created with MrDocs