Establishes the interface that all output target types will implement.
TxOutToKey now satisfies TxOutTarget via its TargetType() method.
Prepares for HF1 output target types (TxOutMultisig, TxOutHTLC).
Co-Authored-By: Charon <charon@lethean.io>
Block major version validation covering all hardfork transitions.
Single expectedBlockMajorVersion function handles HF0→HF4.
Co-Authored-By: Charon <charon@lethean.io>
Fix gaps from spec review: sumInputs/checkKeyImages/verifyV1Signatures
for HTLC inputs, complete call-site list for TxOutTarget refactor,
both v1+v2 decoders, function signature changes, block version check
placement, HTLCOrigin naming clarification.
Co-Authored-By: Charon <charon@lethean.io>
Add design for HTLC and multisig transaction type support needed for
hardfork 1 activation at block 10,080. Covers types, wire, and consensus
changes with TxOutTarget interface refactor.
Co-Authored-By: Charon <charon@lethean.io>
Resolve stale forge.lthn.ai/core/cli v0.1.0 references (tag never existed,
earliest is v0.0.1) and regenerate go.sum via workspace-aware go mod tidy.
Co-Authored-By: Virgil <virgil@lethean.io>
- Replace log.Fatalf with fmt.Errorf in explorer store open (proper error return)
- Add WaitGroup for syncLoop goroutine in runExplorer (same pattern as daemon)
- Fix stale doc comment mentioning 'mine' subcommand
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents race where store.Close() runs while syncLoop is still
accessing the database after context cancellation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate from stdlib flag to cli.Main() + WithCommands() pattern:
- AddChainCommands() registration with persistent --data-dir/--seed/--testnet flags
- Explorer subcommand (TUI block explorer, replaces old default mode)
- Sync subcommand with headless foreground and --daemon/--stop modes
- sync_service.go extracts syncLoop/syncOnce from old main.go
- cmd/core-chain/main.go standalone binary entry point
- Add go-process dependency for daemon lifecycle
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move all 21 plan files to docs/plans/completed/ — every phase (0-9) is
implemented. Expand history.md with full writeups for the Difficulty
Computation, V2+ Zarcanum Consensus, and TUI Dashboard sections that
were previously just bullet points.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses reusable workflows from core/go-devops for Go testing
(with race detector and coverage) and security scanning
(govulncheck, gitleaks, trivy).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements StatusModel as a cli.FrameModel that renders a single-line
chain status bar showing height, sync percentage, difficulty, peer
count and tip age. Includes formatAge and formatDifficulty helpers
with SI suffixes. Adds core/cli as a direct dependency.
Co-Authored-By: Charon <charon@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add forge.lthn.ai/core/cli to go.mod with replace directive pointing
to the local workspace path. Also adds transitive replace directives
for core/go and core/go-crypt which are dependencies of core/cli.
Co-Authored-By: Charon <charon@lethean.io>
Standalone TUI in go-blockchain using core/cli Frame (bubbletea).
Day-one scope: chain sync status header + block explorer content.
Model library pattern (tui/) with thin cmd/chain/ wiring.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add full V2 transaction verification pipeline: parse SignaturesRaw variant
vector into structured ZC signature data, verify CLSAG GGX ring signatures
per ZC input, verify BPP range proofs, and verify BGE asset surjection
proofs with correct ring construction (mul8 point arithmetic).
Fix three wire format bugs that caused V2 parsing failures:
- RefTypeGlobalIndex (tag 0x1A) uses 8-byte LE, not varint
- Raw uint64_t variant (tagUint64) uses 8-byte LE, not varint
- zarcanum_tx_data_v1 fee uses FIELD() → 8-byte LE, not VARINT_FIELD()
Add cn_point_sub to C++ bridge and Go wrapper for BGE ring construction.
Add GetZCRingOutputs to chain for fetching ZC ring member data.
Co-Authored-By: Charon <charon@lethean.io>
Rewrites the LWMA difficulty algorithm to match the C++ daemon exactly:
- Uses N=60 window with linear weighting (position 1..n)
- Clamps solve times to [-6T, 6T]
- Excludes genesis block from the difficulty window
- Selects target based on hardfork: 120s pre-HF2, 240s post-HF2
On testnet, HF2 activates at height 10 (active from height 11),
doubling the target from 120s to 240s. The previous fixed 120s target
produced exactly half the expected difficulty from height 11 onward.
Integration test verifies all 2576 testnet blocks match the daemon.
Co-Authored-By: Charon <charon@lethean.io>
Local difficulty computation for P2P sync — replaces hardcoded
difficulty=0 with LWMA-based calculation from stored block history.
Co-Authored-By: Charon <charon@lethean.io>
LevinP2PConn wraps a levin.Connection to implement the P2PConnection
interface, handling timed_sync keep-alive responses automatically.
Integration test syncs the full testnet chain (2577 blocks) via P2P
in under 5 seconds.
Co-Authored-By: Charon <charon@lethean.io>
RESPONSE_CHAIN_ENTRY includes the fork-point block as its first
entry. The sync loop now skips blocks already stored to avoid
height validation failures on subsequent chain iterations.
Co-Authored-By: Charon <charon@lethean.io>
SparseChainHistory returned a zero hash when the chain was empty,
which the daemon could not resolve. Send the genesis hash instead
so the peer can locate the fork point and respond with chain entries.
Co-Authored-By: Charon <charon@lethean.io>