Commit graph

154 commits

Author SHA1 Message Date
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
Claude
04861acf93
feat(tui): add custom bubbletea message types
Co-Authored-By: Charon <charon@lethean.io>
2026-02-22 23:50:15 +00:00
Claude
969e30905f
feat(tui): add core/cli dependency for Frame TUI
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>
2026-02-22 23:48:58 +00:00
Claude
1cc956631e
docs: add blockchain TUI dashboard design
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>
2026-02-22 23:34:12 +00:00
Claude
fedf337da9
chore: sync workspace dependency versions
Run go work sync to align dependency versions across workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:41:04 +00:00
Claude
a803fd1794
feat(consensus): V2 Zarcanum signature and proof verification
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>
2026-02-22 00:06:10 +00:00
Claude
3c76dd7070
fix(difficulty): correct LWMA algorithm and hardfork-aware target
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>
2026-02-21 22:32:57 +00:00