CTransaction

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

NameDescription
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

NameDescription
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

NameDescription
CURRENT_VERSION Default transaction version used for newly created transactions.

Friends

NameDescription
operator==Compares two transactions for equality by witness hash.

Non-Member Functions

NameDescription
CalculateSequenceLocksCalculates 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.
CheckTransactionPerforms context-independent validity checks on a transaction.
EncodeHexTxSerialize a transaction and encode it as a hex string.
GetDustGet the vout index numbers of all dust outputs
GetEntriesForConflictsGet all descendants of iters_conflicting. Checks that there are no more than MAX_REPLACEMENT_CANDIDATES distinct clusters affected.
GetLegacySigOpCountCount ECDSA signature operations the old-fashioned (pre-0.6) way
GetP2SHSigOpCountCount ECDSA signature operations in pay-to-script-hash inputs.
GetTransactionSigOpCostCompute total signature operation cost of a transaction.
GetVirtualTransactionSizeCompute the virtual size of a transaction, accounting for sigop cost.
IsFinalTxCheck if transaction is final and can be included in a block with the specified height and time. Consensus critical.
IsRBFOptInDetermine 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.
IsRBFOptInEmptyMempoolDetermine the RBF signaling state of a transaction assuming an empty mempool.
IsStandardTxCheck for standard transaction types
IsWitnessStandardCheck 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.
PreCheckEphemeralTxCalled for each transaction once transaction fees are known. Does context-less checks about a single transaction.
SequenceLocksCheck 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.
SignalsOptInRBFCheck 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.
SpendsNonAnchorWitnessProgCheck whether this transaction spends any witness program but P2A, including not-yet-defined ones. May return false early for consensus-invalid transactions.
TxToUnivFill a JSON object with a human-readable description of a transaction.
ValidateInputsStandardnessCheck for standard transaction types
Consensus::CheckTxInputsCheck 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::CalculateMaximumSignedTxSizeCalculate the size of the transaction using CoinControl to determine whether to expect signature grinding when calculating the size of the input spend.
wallet::CalculateMaximumSignedTxSizeCalculate the size of the transaction, looking up previous outputs from the wallet.