Add readExtraAliasEntryOld (tag 20) and readExtraAliasEntry (tag 33)
wire readers so the node can deserialise blocks containing alias
registrations. Without these readers, mainnet sync would fail on any
block with an alias transaction. Three round-trip tests validate the
new readers.
Also apply AX-2 (comments as usage examples) across 12 files: add
concrete usage-example comments to exported functions in config/,
types/, wire/, chain/, difficulty/, and consensus/. Fix stale doc
in consensus/doc.go that incorrectly referenced *config.ChainConfig.
Co-Authored-By: Virgil <virgil@lethean.io>
Migrate types/asset.go from fmt.Errorf to coreerr.E() for consistency
with the rest of the types package. Add usage-example comments (AX-2) to
all key exported functions in consensus/, chain/, and types/ so agents
can see concrete calling patterns without reading implementation details.
Co-Authored-By: Virgil <virgil@lethean.io>
Reject Zarcanum inputs and outputs before HF4 instead of letting
unsupported combinations pass semantic validation.
Also restrict PoS miner stake inputs to txin_to_key pre-HF4 and
txin_zc post-HF4, with regression coverage for the affected paths.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
verifyV1Signatures now counts and verifies TxInputHTLC alongside
TxInputToKey. HTLC inputs use the same ring signature scheme.
Co-Authored-By: Charon <charon@lethean.io>
sumInputs now sums TxInputHTLC.Amount and TxInputMultisig.Amount.
checkKeyImages now checks TxInputHTLC.KeyImage for double-spend.
Co-Authored-By: Charon <charon@lethean.io>
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>
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>
Connect crypto.CheckRingSignature() to verifyV1Signatures() so
pre-HF4 transactions have their ring signatures cryptographically
verified when a RingOutputsFn callback is provided.
Co-Authored-By: Charon <charon@lethean.io>
Add integration test, update architecture docs with consensus/ package
description, record Phase 7 in project history.
Co-Authored-By: Charon <charon@lethean.io>
VerifyTransactionSignatures with structural checks for v1 NLSAG and
v2+ CLSAG. Crypto bridge calls marked as TODO for wiring.
Co-Authored-By: Charon <charon@lethean.io>
CheckDifficulty compares a 256-bit LE hash against a difficulty target.
CheckPoWHash computes RandomX hash and checks against difficulty.
Co-Authored-By: Charon <charon@lethean.io>
ValidateBlock combines timestamp, miner tx, and reward checks into
a single entry point for block-level consensus validation.
Co-Authored-By: Charon <charon@lethean.io>
ValidateBlockReward checks miner tx output sum against expected reward
with size penalty and hardfork-aware fee treatment.
Co-Authored-By: Charon <charon@lethean.io>
ValidateMinerTx checks genesis input height, input count (1 for PoW,
2 for PoS), and stake input type per hardfork version.
Co-Authored-By: Charon <charon@lethean.io>
Add consensus/ package with doc.go and sentinel error types for all
validation failures. Add MaxTransactionBlobSize constant to config.
Co-Authored-By: Charon <charon@lethean.io>