Script engine predates BIP65 — no CHECKLOCKTIMEVERIFY, so no atomic swaps #34
Labels
No labels
do-not-open-till-X-Day
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SubGeniusFinance/dobbscoin-source#34
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The consensus script engine predates BIP65/112/141.
CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFYand segwit are absent from the tree entirely — not merelyunactivated.
OP_NOP2(0xb1) andOP_NOP3(0xb2) are still plain NOPs.Verification
The newest consensus rule referenced anywhere in
src/is BIP66.versionbits.cpp,blockencodings.cppandpolicy/are absent, so the tree ispre-0.12 despite
CLIENT_VERSION_MINOR 13.Why it matters
Atomic swaps need a timelocked refund path. Without
CHECKLOCKTIMEVERIFYthe onlyoption is a pre-signed refund transaction referencing the funding txid, which is
fragile under transaction malleability — and malleability is also unfixed here.
BIP65 resolves both at once: it exists precisely so the funder can reclaim with a
freshly-constructed transaction after the timeout, instead of relying on a
pre-signed one. CLTV alone is sufficient for HTLC-based atomic swaps. Segwit is
not required for this.
Scope
Minimal path is BIP65 only:
OP_NOP2asOP_CHECKLOCKTIMEVERIFYin the interpreterversionbitsis absent, so BIP9 is not available — but height-gated activation isa pattern already running in production in the sibling Offerings codebase
(
IsAfterRestorationFork(nHeight)). A testnet exists (CTestNetParams) and shouldcarry the first activation.
BIP112 (CSV) and BIP141 (segwit) are separate, larger, and not required for swaps.
Also worth fixing regardless
CLIENT_VERSION_MINOR 13implies a 0.13 lineage the code does not have. It willmislead the next reader — it briefly misled this investigation.
Scheduling note, after reading forum topic 31 (merge mining) and topic 24 (roadmap).
This should ride the block 2,000,000 fork rather than wait for a governance track
of its own.
HARDFORK_AUXPOW_MAIN = 2000000is a hard fork every node must take — currently~95,500 blocks out, ~132 days. The expensive part of any consensus change is the
upgrade campaign, and merge mining is already buying one. After 2M the upgrade
audience includes foreign pool operators who merge-mine us incidentally; a fork
then is a request they can decline.
Two clarifications on scope:
with a freshly-built transaction after a timeout, instead of a pre-signed refund.
That removes the malleability dependency, so segwit is not required for swaps.
IsStandardTxrejects
nVersion > CURRENT_VERSION(src/main.cpp:643), which blocks CSV.CLTV is unaffected — it is a soft fork on a redefined NOP and works on v1.
So the Roadmap 3 sequence (CSV -> segwit -> bech32 -> wallet) is not a prerequisite
here. This is one opcode, separable from that decision entirely.
Implemented on branch
bip65-cltv-height(ba8e8e00,14bdb014). Not merged.CLTV activates by height, not by a version supermajority — see #40 for why a version-gated deployment cannot work on this chain after block 2,000,000.
HARDFORK_CLTV_MAINis 2,000,000, the same height as the AuxPoW fork, so the network upgrades once rather than twice.Before activation the opcode behaves exactly as
OP_NOP2did, which is what keeps this a soft fork.One thing that would have made the feature useless if missed:
DISCOURAGE_UPGRADABLE_NOPSis part ofSTANDARD_SCRIPT_VERIFY_FLAGS, so a CLTV transaction was non-standard and would never have relayed — consensus-valid and undeliverable. The CLTV flag is now in the standard set too, which also stops a node relaying a transaction its ownConnectBlockwould later reject.Coverage: 12 unit tests in
src/test/cltv_tests.cpp, plus on-chain tests that build real blocks on regtest to check the height gate itself (unit tests cannot see a wiring error between the interpreter andConnectBlock).Full suite is unchanged at its pre-existing 62 failures (48
script_tests, 14transaction_tests), verified identical onmain— see #43.Merged to
mainMerge commit
2513af45, 2026-09-15. What actually landed:9b82f8f0consensus:OP_NOP2becomesOP_CHECKLOCKTIMEVERIFY, activated by heightcdfc7d47policy: relay CLTV transactions and enforce the lock in the mempool1748c666rpc: restore the regtest exemption ongetblocktemplate082aa2ebqa: activation tested on a real chain; testnet height moved above coinbase maturity37a1687ebuild: ignore stray.bakbinaries insrc/The comment above named
ba8e8e00and14bdb014. Those were rebased away before the merge and sit on no branch; the list above is what is onmain.Activation
HARDFORK_CLTV_MAIN = 2000000, deliberately the same height as the AuxPoW fork, so the network takes one upgrade instead of two.HARDFORK_CLTV_TESTNET = 20, past AuxPoW's 10, so regtest crosses each boundary on its own. Below the activation height the opcode behaves exactly asOP_NOP2always did, which is what makes this a soft fork rather than a second hard fork.What is not done
Merging is not shipping. No release carries this yet, and CLTV does nothing on mainnet until block 2,000,000 regardless. Closing the code half of this issue; deployment rides the next release, and enforcement rides the fork height.