Upgrading to Bitcoin Core — Ladder Script is being ported from Bitcoin Ghost to a clean Bitcoin Core v30.0 fork. Some tools may be temporarily unavailable.

Patch Overview

What changes are needed to add Ladder Script to Bitcoin Core

154Lines Added
16Files Modified
11,318New Code (Rung Lib)
21New Files
Ladder Script adds a self-contained library (src/rung/) to Bitcoin Core. The patch to existing code is minimal: 154 lines across 16 files. The bulk of the implementation (11,318 lines) lives in new files that do not touch existing code.
Patch to Existing Bitcoin Core

These are the only modifications to existing Bitcoin Core files. Each change is surgical and additive.

FileChangeLines
validation.cppRoute v4 RUNG_TX inputs spending MLSC outputs to VerifyRungTx. Pass block_height through CheckInputScripts. ValidateRungOutputs call. MLSC-only flag on mainnet.+43
script/interpreter.cppPrecompute ladder sighash caches for v4 transactions. Reuses BIP341 hash infrastructure.+13
script/interpreter.hAdd SigVersion::LADDER = 4 and m_ladder_ready flag to PrecomputedTransactionData.+5
primitives/transaction.hDefine RUNG_TX_VERSION = 4.+4
script/script_error.cppAdd SCRIPT_ERR_LADDER_INVALID_WITNESS and SCRIPT_ERR_LADDER_EVAL_FALSE error strings.+4
script/solver.cppDetect 0xC2 prefix as TxoutType::RUNG_CONDITIONS in the script solver.+7
script/solver.hAdd RUNG_CONDITIONS to TxoutType enum.+1
policy/policy.cppRoute v4 transactions to rung::IsStandardRungTx. Bypass standard input/witness checks for MLSC outputs.+17
rpc/mempool.cppSkip burn-amount check for MLSC outputs in sendrawtransaction and submitpackage.+5
rpc/util.cppAdd LadderDestination visitor for address description RPC.+8
addresstype.cppExtract LadderDestination from RUNG_CONDITIONS outputs. Encode as scriptPubKey.+14
addresstype.hDefine LadderDestination struct. Add to CTxDestination variant.+24
key_io.cppEncode/decode rung1... Bech32m addresses.+35
bech32.hAdd RUNG_ADDRESS character limit (500) for rung addresses.+1
CMakeLists.txtAdd add_subdirectory(rung) and link bitcoin_rung.+5
test/CMakeLists.txtAdd rung_tests.cpp to test binary.+1
New Rung Library (src/rung/)

Self-contained library. No modifications to existing Bitcoin Core code. Builds as libbitcoin_rung.a.

FileLinesPurpose
evaluator.cpp3,503All 61 block evaluators, EvalBlock dispatch, EvalRung (AND), EvalLadder (OR), VerifyRungTx entry point, BatchVerifier
rpc.cpp2,605RPC commands: createrung, createrungtx, signrungtx, decoderung, parseladder, formatladder, computectvhash, generatepqkeypair
types.h1,423Block type enum (61 types), data types, RungCoil, implicit field layouts, micro-header table, BlockDescriptor table
serialize.cpp944Wire format: micro-headers, implicit fields, DeserializeLadderWitness, SerializeLadderWitness, anti-spam enforcement
conditions.cpp657MLSC Merkle tree: leaf computation, proof verification, merkle_pub_key, CreateMLSCScript
descriptor.cpp566Conditions descriptor language: ParseDescriptor, FormatDescriptor
evaluator.h266Evaluator declarations, LadderSignatureChecker, BatchVerifier, RungEvalContext, TxAggregateContext
conditions.h202RungConditions, MLSCProof, MLSC output helpers, Merkle leaf computation declarations
adaptor.cpp187Adaptor signature verification and secret extraction
policy.cpp149Mempool policy: IsBaseBlockType, IsCovenantBlockType, IsStatefulBlockType, IsStandardRungTx
sighash.cpp146SignatureHashLadder: tagged hash, ANYPREVOUT/ANYPREVOUTANYSCRIPT skip rules
pq_verify.cpp145Post-quantum signature verification: FALCON-512, FALCON-1024, Dilithium3, SPHINCS+
serialize.h123Constants (MAX_RUNGS=16, MAX_BLOCKS=8, etc.), SerializationContext
sighash.h64SignatureHashLadder declaration, ANYPREVOUT constants
descriptor.h58ParseDescriptor, FormatDescriptor declarations
adaptor.h57Adaptor signature types and declarations
pq_verify.h51PQ verification declarations, scheme detection
aggregate.h51AggregateProof, TxAggregateContext structs
types.cpp45RungField::IsValid implementation
aggregate.cpp41VerifyAggregateSpend, VerifyDeferredAttestation
policy.h35Policy function declarations
Test Coverage
LayerCountWhat
Unit tests480Block evaluation, serialisation, sighash, conditions, policy, MLSC proofs, field validation
Regtest functional60Every block type: create, sign, broadcast, mine, spend on live regtest node
TLA+ formal specs809 specifications, 3.3M states checked: evaluation semantics, anti-spam, wire format, Merkle proofs, sighash, covenants, cross-input
Patch Files

Two patch files apply to Bitcoin Core v30.1:

patches/bitcoin-core-v30-ladder-script.patch
+154 lines across 16 files
Core integration: routing, sighash, script solver, policy, address encoding, RPC, build system
patches/validation-block-height.patch
+43 lines across 2 files
Block height plumbing for EPOCH_GATE and height-dependent governance blocks
Total change to existing Bitcoin Core: 197 lines across 18 files. The remaining 11,318 lines are new, self-contained code in src/rung/ that does not modify any existing function.