Commit graph

160 commits

Author SHA1 Message Date
Claude
9631efa5a8
feat(config): add HardforkActivationHeight helper
Returns the raw activation height for a given hardfork version.
Needed by the pre-hardfork transaction freeze logic.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:51:54 +00:00
Claude
18ceb7fa26
fix(chain): gate difficulty target switch on HF6, not HF2
Some checks failed
Security Scan / security (push) Successful in 8s
Test / Test (push) Failing after 20s
The 240s PoW target was incorrectly gated on HF2 (block 10,080), matching
the Zano upstream where HF2 coincides with the difficulty target change.
Lethean mainnet uses 120s blocks between HF2 and HF6 (999,999,999), so
the gate is corrected to HF6.

Also adds NextPoSDifficulty with the same HF6 gate using the PoS target
constants (DifficultyPosTarget / DifficultyPosTargetHF6). Both public
methods delegate to a shared nextDifficultyWith helper to avoid
duplicating the LWMA window logic.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:47:56 +00:00
Claude
d7917234ed
feat(consensus): add ErrBlockVersion alias and comprehensive block version tests
Add ErrBlockVersion as an alias for ErrBlockMajorVersion for clarity.
Add table-driven tests for expectedBlockMajorVersion covering all
hardfork boundaries (HF0 through HF4+) on both mainnet and testnet
schedules. Add standalone checkBlockVersion tests with Good/Bad/Ugly
pattern including version 255 edge case and exact HF1 boundary checks.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:47:47 +00:00
Claude
6a1f516f5f
test(wire): add HF1 mixed transaction round-trip integration test
Some checks failed
Security Scan / security (push) Successful in 8s
Test / Test (push) Failing after 17s
Verifies that a transaction containing TxInputToKey, TxInputHTLC,
TxInputMultisig inputs with TxOutToKey, TxOutMultisig, TxOutHTLC
output targets survives bit-identical encode/decode round-trip.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:41:28 +00:00
Claude
b1a0e9637b
feat(consensus): validate block major version for HF1
Adds expectedBlockMajorVersion and checkBlockVersion, called from
ValidateBlock before timestamp validation. Block version must match
the fork era: HF0->0, HF1->1, HF3->2, HF4+->3.
Tests cover both mainnet and testnet fork schedules including
boundary heights.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:40:11 +00:00
Claude
f88d582c64
feat(consensus): verify NLSAG signatures for HTLC inputs
verifyV1Signatures now counts and verifies TxInputHTLC alongside
TxInputToKey. HTLC inputs use the same ring signature scheme.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:38:28 +00:00
Claude
192d681ecd
feat(consensus): include HTLC/multisig in fee calculation and key image checks
sumInputs now sums TxInputHTLC.Amount and TxInputMultisig.Amount.
checkKeyImages now checks TxInputHTLC.KeyImage for double-spend.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:37:06 +00:00
Claude
ba29b55644
feat(consensus): gate HTLC and multisig types on HF1
checkInputTypes and checkOutputs now accept hf1Active flag.
HTLC and multisig inputs/outputs are rejected before HF1
(block 10,080) and accepted after.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:36:58 +00:00
Claude
830aa6055e
feat(wire): encode/decode TxOutMultisig and TxOutHTLC targets
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 20s
Adds target variant serialisation in both V1 and V2 output
encoders/decoders. Supports multisig (tag 0x04) and HTLC
(tag 0x23) targets within TxOutputBare.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:31:29 +00:00
Claude
14a2da9396
feat(wire): encode/decode TxInputHTLC and TxInputMultisig
Adds wire serialisation for HF1 HTLC (tag 0x22) and multisig
(tag 0x02) input types.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:28:55 +00:00
Claude
1ca75f9e3f
feat(types): add TxInputHTLC and TxInputMultisig input types
Input types for HF1 HTLC and multisig transactions.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:27:49 +00:00
Claude
30d174eaac
feat(types): add TxOutMultisig and TxOutHTLC target types
Output target types for HF1 HTLC and multisig transactions.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:27:01 +00:00
Claude
cc99c92c42
docs: HF5 confidential assets implementation plan
Some checks failed
Security Scan / security (push) Successful in 8s
Test / Test (push) Failing after 20s
Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:25:56 +00:00
Claude
0408d2f3fa
refactor(types): change TxOutputBare.Target to TxOutTarget interface
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 15s
Prepares for HF1 output target types (TxOutMultisig, TxOutHTLC).
All call sites updated to type-assert TxOutToKey where needed.

Modified files:
- types/transaction.go: TxOutputBare.Target is now TxOutTarget
- wire/transaction.go: encode/decode use type switch on target
- chain/ring.go: type-assert target to TxOutToKey for key extraction
- wallet/scanner.go: type-assert target before key comparison
- tui/explorer_model.go: type-assert target for display
- wire/transaction_test.go: type-assert in assertions
- wallet/builder_test.go: type-assert in assertions

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:23:27 +00:00
Claude
6eabe2a64d
docs: HF6 block time halving implementation plan
Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:21:34 +00:00
Claude
023f4b813c
docs: HF3 block version implementation plan
Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:20:56 +00:00
Claude
00e83582b7
feat(types): add TxOutTarget interface with TargetType method
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>
2026-03-16 20:20:26 +00:00
Claude
5a53c719de
docs: HF5 confidential assets + HF6 block time halving design specs
Some checks failed
Security Scan / security (push) Successful in 10s
Test / Test (push) Failing after 20s
HF5: Asset descriptor types, wire parsing for tag 40 + proof tags,
consensus validation for asset operations, pre-hardfork freeze.
Minimum viable approach: wire parsing first, deep validation later.

HF6: Block time target switch from 120s to 240s. ~10 lines.
Flagged potential bug: current code gates on HF2 not HF6.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:09:56 +00:00
Claude
c7c169dd67
docs: HF1 transaction types implementation plan
Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:09:03 +00:00
Claude
ef232fcb80
docs: HF3 block version 2 design spec
Block major version validation covering all hardfork transitions.
Single expectedBlockMajorVersion function handles HF0→HF4.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:05:55 +00:00
Claude
a71976f259
docs: address spec review — 12 issues fixed
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>
2026-03-16 20:02:02 +00:00
Claude
57b8bbce2d
docs: HF1 transaction types design spec
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>
2026-03-16 19:59:16 +00:00
Snider
dfb8467bb2 chore: sync go.mod dependencies
Some checks failed
Security Scan / security (push) Successful in 10s
Test / Test (push) Failing after 15s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-15 15:37:24 +00:00
Snider
b4b532ceb9 chore: add .core/ and .idea/ to .gitignore
Some checks failed
Security Scan / security (push) Successful in 7s
Test / Test (push) Failing after 19s
2026-03-15 10:17:49 +00:00
Snider
2e81130b66 fix: update stale import paths and dependency versions from extraction
Some checks failed
Test / Test (push) Failing after 38s
Security Scan / security (push) Failing after 11m7s
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>
2026-03-14 13:38:59 +00:00
Snider
98d308c831 docs: remove completed plan files
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 25s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-14 08:20:11 +00:00
Snider
d0c64c8ad6 docs: add CLAUDE.md project instructions
Some checks failed
Security Scan / security (push) Successful in 10s
Test / Test (push) Failing after 22s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-13 13:38:01 +00:00
Snider
f7cd812263 docs: add human-friendly documentation
Some checks failed
Security Scan / security (push) Successful in 7s
Test / Test (push) Failing after 18s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 13:02:39 +00:00
Snider
98cb698f93 fix: remove accidentally re-added cmd/chain/main.go
Some checks failed
Security Scan / security (push) Successful in 7s
Test / Test (push) Failing after 23s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:27:35 +00:00
Snider
9bc33e2860 fix: code review fixes — log.Fatalf, goroutine lifecycle, stale doc
- 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>
2026-03-09 16:27:21 +00:00
Snider
a77d9592bf chore: add .core/build.yaml for core-chain binary
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:24:05 +00:00
Snider
ca8334a324 refactor: remove old cmd/chain entry point (replaced by cmd/core-chain)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:23:51 +00:00
Snider
8e87fdac3c fix: wait for syncLoop goroutine before closing store in daemon mode
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>
2026-03-09 16:23:36 +00:00
Snider
aa3d8270a2 feat: modernise CLI — AddChainCommands, explorer/sync subcommands, core-chain binary
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>
2026-03-09 16:21:42 +00:00
Snider
d8c2e84115 fix: update go.mod replace directives for local workspace
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:12:10 +00:00
2ddfe66a8f Merge pull request 'chore: Go 1.26 modernization' (#2) from chore/go-1.26-modernization into main
Some checks failed
Security Scan / security (push) Successful in 13s
Test / Test (push) Failing after 36s
2026-02-24 18:01:44 +00:00
Claude
6324e5f3ca
chore: use slices.Contains for linear search
Some checks failed
Security Scan / security (pull_request) Successful in 12s
Test / Test (pull_request) Failing after 35s
Replace manual loop-and-break index search with slices.IndexFunc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:19:31 +00:00
Claude
5df40c1de1
chore: sort.Slice → slices.SortFunc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:17:40 +00:00
Claude
45636455ba
chore: use min()/max() builtins (Go 1.21+)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:16:01 +00:00
Claude
33a0b57d72
chore: use range-over-integer (Go 1.22+)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:14:08 +00:00
Claude
aefec104d4
chore: fmt.Errorf(static) → errors.New
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 16:11:27 +00:00
Claude
d8eb6c5478
docs: archive completed plans, expand history for TUI and difficulty
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 30s
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>
2026-02-24 13:47:35 +00:00
Claude
1da986a0f4
ci: add Forgejo Actions test and security scan workflows
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 34s
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>
2026-02-23 03:28:02 +00:00
Claude
cd8ed3d502
docs: add TUI dashboard to architecture and history
Co-Authored-By: Charon <charon@lethean.io>
2026-02-23 00:06:28 +00:00
Claude
0aba33fa6e
test(tui): add ExplorerModel navigation and view tests
Add 5 tests covering Enter (block detail), Esc (back to list),
PgDown, Home, and coinbase-only block detail rendering.

Co-Authored-By: Charon <charon@lethean.io>
2026-02-23 00:05:10 +00:00
Claude
7e95ced104
feat(tui): add cmd/chain binary wiring Frame + P2P sync
Co-Authored-By: Charon <charon@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 00:03:14 +00:00
Claude
527284327b
feat(tui): add ExplorerModel with block list, detail, and tx views
Co-Authored-By: Charon <charon@lethean.io>
2026-02-23 00:00:05 +00:00
Claude
8978aaf878
feat(tui): add KeyHintsModel for context-sensitive footer
Co-Authored-By: Charon <charon@lethean.io>
2026-02-22 23:57:07 +00:00
Claude
df6d4c82c0
feat(tui): add StatusModel for chain sync header
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>
2026-02-22 23:55:22 +00:00
Claude
572237696a
feat(tui): add Node wrapper with status polling
Co-Authored-By: Charon <charon@lethean.io>
2026-02-22 23:52:50 +00:00