[#CTransaction] = CTransaction :mrdocs: 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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CTransaction; ---- == Member Functions [cols="1,4"] |=== | Name| Description | xref:CTransaction/2constructor-04e.adoc[`CTransaction`] [.small]#[constructor]# | Constructors | xref:CTransaction/ComputeTotalSize.adoc[`ComputeTotalSize`] | Calculate the total transaction size in bytes, including witness data. "Total Size" defined in BIP141 and BIP144. | xref:CTransaction/GetHash.adoc[`GetHash`] | Returns the cached transaction id. | xref:CTransaction/GetValueOut.adoc[`GetValueOut`] | Returns the total value of all outputs. | xref:CTransaction/GetWitnessHash.adoc[`GetWitnessHash`] | Returns the cached witness transaction id. | xref:CTransaction/HasWitness.adoc[`HasWitness`] | Returns true when any input carries witness data. | xref:CTransaction/IsCoinBase.adoc[`IsCoinBase`] | Returns true when the transaction is a coinbase. | xref:CTransaction/IsNull.adoc[`IsNull`] | Returns true when the transaction has no inputs and no outputs. | xref:CTransaction/Serialize.adoc[`Serialize`] | Serializes the transaction using the stream's transaction parameters. | xref:CTransaction/ToString.adoc[`ToString`] | Returns a human‐readable description of the transaction. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:CTransaction/nLockTime.adoc[`nLockTime`] | Lock time before which the transaction is not valid. | xref:CTransaction/version.adoc[`version`] | Transaction version number. | xref:CTransaction/vin.adoc[`vin`] | Inputs spent by this transaction. | xref:CTransaction/vout.adoc[`vout`] | Outputs created by this transaction. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:CTransaction/CURRENT_VERSION.adoc[`CURRENT_VERSION`] | Default transaction version used for newly created transactions. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:operator_eq-05b.adoc[operator==]` | Compares two transactions for equality by witness hash. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:CalculateSequenceLocks.adoc[`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. | xref:CheckTransaction.adoc[`CheckTransaction`] | Performs context‐independent validity checks on a transaction. | xref:EncodeHexTx.adoc[`EncodeHexTx`] | Serialize a transaction and encode it as a hex string. | xref:GetDust.adoc[`GetDust`] | Get the vout index numbers of all dust outputs | xref:GetEntriesForConflicts.adoc[`GetEntriesForConflicts`] | Get all descendants of iters_conflicting. Checks that there are no more than MAX_REPLACEMENT_CANDIDATES distinct clusters affected. | xref:GetLegacySigOpCount.adoc[`GetLegacySigOpCount`] | Count ECDSA signature operations the old‐fashioned (pre‐0.6) way | xref:GetP2SHSigOpCount.adoc[`GetP2SHSigOpCount`] | Count ECDSA signature operations in pay‐to‐script‐hash inputs. | xref:GetTransactionSigOpCost.adoc[`GetTransactionSigOpCost`] | Compute total signature operation cost of a transaction. | xref:GetVirtualTransactionSize-01.adoc[`GetVirtualTransactionSize`] | Compute the virtual size of a transaction, accounting for sigop cost. | xref:IsFinalTx.adoc[`IsFinalTx`] | Check if transaction is final and can be included in a block with the specified height and time. Consensus critical. | xref:IsRBFOptIn.adoc[`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. | xref:IsRBFOptInEmptyMempool.adoc[`IsRBFOptInEmptyMempool`] | Determine the RBF signaling state of a transaction assuming an empty mempool. | xref:IsStandardTx.adoc[`IsStandardTx`] | Check for standard transaction types | xref:IsWitnessStandard.adoc[`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. | xref:PreCheckEphemeralTx.adoc[`PreCheckEphemeralTx`] | Called for each transaction once transaction fees are known. Does context‐less checks about a single transaction. | xref:SequenceLocks.adoc[`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. | xref:SignalsOptInRBF.adoc[`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. | xref:SpendsNonAnchorWitnessProg.adoc[`SpendsNonAnchorWitnessProg`] | Check whether this transaction spends any witness program but P2A, including not‐yet‐defined ones. May return `false` early for consensus‐invalid transactions. | xref:TxToUniv.adoc[`TxToUniv`] | Fill a JSON object with a human‐readable description of a transaction. | xref:ValidateInputsStandardness.adoc[`ValidateInputsStandardness`] | Check for standard transaction types | xref:Consensus/CheckTxInputs.adoc[`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. | xref:wallet/CalculateMaximumSignedTxSize-00.adoc[`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. | xref:wallet/CalculateMaximumSignedTxSize-0d.adoc[`wallet::CalculateMaximumSignedTxSize`] | Calculate the size of the transaction, looking up previous outputs from the wallet. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#