Commit graph

195 commits

Author SHA1 Message Date
Virgil
e25e3e73e7 refactor(wire): deduplicate output target encoding
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:39:45 +00:00
Virgil
c787990b9a refactor(ax): clarify ring and wallet names
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:36:16 +00:00
Virgil
3686a82b33 fix(consensus): validate HTLC tags in v2 signatures
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:32:39 +00:00
Virgil
d6f31dbe57 fix(cli): tighten chain command validation
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:22:48 +00:00
Virgil
41f2d52979 chore(spec): verify RFC coverage
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
No missing HF1/HF3/HF5 implementation gaps were found in the current codebase.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 20:18:13 +00:00
Virgil
050d530b29 feat(consensus): validate HF5 asset operations
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:14:54 +00:00
Virgil
c1b68523c6 fix(consensus): enforce tx versions across fork eras
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 20:04:24 +00:00
Virgil
be99c5e93a fix(wire): reject unsupported transaction variants
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Add explicit errors for unknown input/output variants in the wire encoder and tighten transparent output validation in consensus. Cover the new failure paths with unit tests.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 19:56:50 +00:00
Virgil
d2caf68d94 fix(p2p): report malformed peer builds
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 19:49:03 +00:00
Virgil
ccdcfbaacf refactor(blockchain): clarify handshake sync naming
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 19:21:12 +00:00
Virgil
f1738527bc feat(chain): select HTLC ring keys by expiry
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 19:11:37 +00:00
Virgil
21c5d49ef9 fix(sync): validate peers and persist HTLC spends
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Centralise handshake response validation so outbound sync checks both network identity and minimum peer build version through the p2p layer. Also record HTLC key images as spent during block processing, matching the HF1 input semantics and preventing those spends from being omitted from chain state.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 19:01:07 +00:00
Virgil
0ba5bbe49c feat(consensus): enforce block version in chain sync
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
2026-04-04 18:56:36 +00:00
Virgil
01f4e5cd0a feat(chain): support multisig and HTLC ring outputs
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 18:52:40 +00:00
Virgil
d3143d3f88 feat(consensus): enforce hf5 tx version and add asset descriptors
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 18:34:49 +00:00
Virgil
f7ee451fc4 fix(blockchain): enforce HF5 freeze and peer build gate
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 18:30:32 +00:00
Virgil
8e6dc326df feat(crypto): add generic double-Schnorr bridge
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
Expose generate/verify wrappers for generic_double_schnorr_sig and add a consensus helper for balance-proof checks.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 18:26:33 +00:00
Virgil
a2df164822 refactor(blockchain): spell out command sync names
Some checks failed
Security Scan / security (push) Has been cancelled
Test / Test (push) Has been cancelled
Co-Authored-By: Charon <charon@lethean.io>
2026-04-04 04:18:37 +00:00
Virgil
243749a6d8 refactor: align command paths with AX naming
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run
2026-04-04 04:10:23 +00:00
d004158022 Merge pull request '[agent/claude] Migrate module path to dappco.re/go/core/blockchain. Update ...' (#4) from agent/migrate-module-path-to-dappco-re-go-core into main
Some checks failed
Security Scan / security (push) Successful in 9s
Test / Test (push) Failing after 22s
2026-03-22 02:49:31 +00:00
Snider
34128d8e98 refactor: migrate module path to dappco.re/go/core/blockchain
Some checks failed
Security Scan / security (pull_request) Successful in 11s
Test / Test (pull_request) Failing after 19s
Update go.mod module line, all require/replace directives, and every
.go import path from forge.lthn.ai/core/go-blockchain to
dappco.re/go/core/blockchain. Add replace directives to bridge
dappco.re paths to existing forge.lthn.ai registry during migration.
Update CLAUDE.md, README, and docs to reflect the new module path.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 01:49:26 +00:00
Snider
6370d96c31 Merge remote-tracking branch 'github/dev'
Some checks failed
Security Scan / security (push) Successful in 10s
Test / Test (push) Failing after 23s
2026-03-22 00:58:07 +00:00
Snider
2b145d6ebf chore: sync dependencies for v0.1.5
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 17:54:14 +00:00
Snider
abb1e2b748 chore: sync dependencies for v0.1.4
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 17:50:27 +00:00
Claude
97c5510184
refactor: complete coreerr.E() conversion across all packages
Some checks failed
Security Scan / security (push) Successful in 12s
Test / Test (push) Failing after 25s
Convert all remaining fmt.Errorf and errors.New in production code
to coreerr.E(). Covers crypto/ (keygen, signature, clsag, keyimage,
pow), consensus/block, and chain/ring. Only sentinel error definitions
in errors.go and varint.go retain errors.New (correct usage).

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 23:42:51 +00:00
Claude
772cd1b0fd
refactor: convert remaining fmt.Errorf to coreerr.E()
Some checks failed
Security Scan / security (push) Successful in 8s
Test / Test (push) Failing after 22s
Converts the last 3 fmt.Errorf calls in production code (excluding
crypto/ CGo boundary) to coreerr.E() for conventions consistency.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 23:24:53 +00:00
Snider
f19054f7b1 chore: sync dependencies for v0.1.3
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 22:20:06 +00:00
Claude
70fab6f7d0
fix: restore HF5 asset tags, HTLC/multisig inputs, and tx version check after conventions sweep
Some checks failed
Test / Test (push) Failing after 16s
Security Scan / security (push) Failing after 13m58s
The conventions sweep (71f0a5c) overwrote HF5 code and removed HTLC/multisig
input handling. This commit restores:

- wire: HF5 asset wire tags (40/49/50/51) and reader functions for
  asset_descriptor_operation, asset_operation_proof,
  asset_operation_ownership_proof, and asset_operation_ownership_proof_eth
- wire: HTLC and multisig input encode/decode with string field helpers
- consensus: checkTxVersion enforcing version 3 after HF5 / rejecting before
- consensus: HF1-gated acceptance of HTLC and multisig input/output types
- consensus: HTLC key image deduplication in checkKeyImages
- consensus: HTLC ring signature counting in verifyV1Signatures
- chain: corrected error assertion in TestChain_GetBlockByHeight_NotFound

All 14 packages pass go test -race ./...

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 21:32:33 +00:00
Claude
89b0375e18
fix(wire): restore TxOutTarget type switches after conventions sweep
The coreerr.E() sweep reverted the HF1 type assertion changes in
encodeOutputsV1/V2 and decodeOutputsV1/V2. Restores full target
variant support (TxOutToKey, TxOutMultisig, TxOutHTLC) in all four
output functions.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 21:23:48 +00:00
Snider
71f0a5c1d5 refactor: replace fmt.Errorf/os.* with go-io/go-log conventions
Some checks failed
Security Scan / security (push) Successful in 11s
Test / Test (push) Failing after 23s
Replace all fmt.Errorf and errors.New in production code with
coreerr.E("Caller.Method", "message", err) from go-log. Replace
os.MkdirAll with coreio.Local.EnsureDir from go-io. Sentinel errors
(consensus/errors.go, wire/varint.go) intentionally kept as errors.New
for errors.Is compatibility.

270 error call sites converted across 38 files. Test files untouched.
crypto/ directory (CGO) untouched.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 21:17:49 +00:00
Claude
8d41b76db3
feat(consensus): add pre-hardfork transaction freeze for HF5
Some checks failed
Security Scan / security (push) Successful in 8s
Test / Test (push) Failing after 16s
Rejects non-coinbase transactions during the 60-block window before
HF5 activation. Coinbase transactions are exempt. Implements
IsPreHardforkFreeze and ValidateTransactionInBlock.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:59:19 +00:00
Claude
efbf050c1b
feat(consensus): enforce transaction version 3 after HF5
After HF5 activation, only version 3 transactions are accepted.
Before HF5, version 3 is rejected. Matches C++ check_tx_semantic
hardfork gating logic.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:57:54 +00:00
Claude
939ad198fe
test(wire): add v3 transaction round-trip tests with asset operations
Tests v3 transactions containing asset_descriptor_operation (tag 40)
in extra and asset_operation_proof (tag 49) in proofs. Validates
hardfork_id encoding and bit-identical round-tripping.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:56:36 +00:00
Claude
d8e12a1539
feat(wire): add asset proof tags 49, 50, 51 readers
Reads asset_operation_proof, asset_operation_ownership_proof, and
asset_operation_ownership_proof_eth structures. All use CHAIN_TRANSITION_VER
with version byte prefix. Stored as opaque bytes.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:55:33 +00:00
Claude
3e79f34a65
feat(wire): add asset_descriptor_operation tag 40 reader
Reads the CHAIN_TRANSITION_VER structure for asset deploy/emit/update/burn
operations. Stores as opaque bytes for bit-identical round-tripping.
Required for HF5 block deserialisation.

Co-Authored-By: Charon <charon@lethean.io>
2026-03-16 20:53:39 +00:00
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