Transaction structure
CheckTransaction() rejects empty inputs/outputs, oversize transactions, negative outputs, excessive outputs, duplicate inputs and invalid non-coinbase null prevouts.
Double-spend gate
AcceptToMemoryPool() checks HaveInputs(tx) and rejects inputs that are already spent.
Consensus validation interface
main.h explicitly defines CheckInputs() as checking inputs for double spends, scripts/signatures and amounts, without modifying the UTXO set.
1. Transaction sanity checks
These checks happen before the transaction is accepted into the mempool. They protect basic transaction invariants and reject malformed or economically invalid output values.
tx.vin.empty() → bad-txns-vin-emptytx.vout.empty() → bad-txns-vout-emptyMAX_BLOCK_SIZE.MAX_MONEY, and totals outside MoneyRange().set<COutPoint> detects repeated prevouts and rejects them.CheckTransaction().2. Double-spend protection path
In AcceptToMemoryPool(), VTA first checks whether the transaction already exists in the pool, then checks for conflicts on each input outpoint. If view.HaveInputs(tx) is false, the transaction is rejected with bad-txns-inputs-spent.
This is direct source evidence that the mempool admission path contains a spent-input/conflict gate.
AcceptToMemoryPool().3. CheckInputs contract
The VTA main.h interface describes CheckInputs() as checking whether all transaction inputs are valid, specifically including no double spends, scripts & signatures, and amounts. It also states that this function does not modify the UTXO set.
The same header exposes UpdateCoins() separately to apply a valid transaction's effects to the UTXO view. This separation is important for auditing: validation and state mutation are represented as separate operations.
Verified source architecture.
4. Script/signature validation interface
VerifySignature()main.h declares VerifySignature(const CCoins&, const CTransaction&, ...).CScriptCheckmain.h defines a script-check object carrying the previous output script, spending transaction, input index, flags and hash type.AreInputsStandard()5. UTXO/state transition
main.h exposes UpdateCoins() as the function that applies a transaction's effects to the UTXO view and records undo information. The source also exposes block/transaction database verification and block-processing functions.
This gives us a clean audit boundary:
- Validate: determine whether the transaction is acceptable.
- Apply: update the UTXO state only after validation.
- Undo: preserve undo information for state restoration.
6. Banking/payment relevance
Value integrity
Negative, excessive and out-of-range aggregate outputs are rejected at transaction validation.
Spend integrity
Spent-input conflicts are explicitly checked before mempool admission.
Banking readiness
These code controls alone do not prove regulatory, operational, custody, liquidity or production-banking suitability.
NEXT — P2P & Network Security Audit
Ab next code layer: network se transaction kaise aata hai aur node usko kaise handle karta hai.
- Peer connection and message processing
- Block/transaction propagation
- Orphan transaction handling
- Peer misbehavior and banning controls
- DoS/rate-limit protections
- Chain activation, fork handling and best-chain selection
Goal: identify concrete network-security mechanisms and then compare them with the Bitcoin-derived reference architecture.