Documentation
¶
Overview ¶
Package light is the single canonical source of the well-known Lux "light" dev mnemonic and of the deterministic ACCOUNT (wallet) keys derived from it.
Scope: LOCAL network only (primary network ID 1337, EVM chain ID 31337). The mnemonic is public by design — anyone can derive every account key from it, so it MUST NEVER back a production network. RefuseOnProduction is the guard that enforces this.
This package deliberately owns ONLY the deterministic value: the mnemonic and the secp256k1 wallet keys / addresses at the canonical BIP44 path m/44'/9000'/0'/0/i. It has NO staker-cert / NodeID / BLS surface: validator staking identities are intentionally NON-deterministic (random per-node staker keys, so a public seed can never impersonate a node) and live with each node's key material, never here.
Index ¶
Constants ¶
const LuxCoinType = 9000
LuxCoinType is the BIP44 coin type Lux uses by canonical convention. The full account path is m/44'/9000'/0'/0/i (purpose 44' / coin 9000' / account 0' hardened; change 0 / index i non-hardened) — identical to genesis.LoadKeysFromMnemonic and to every canonical-BIP44 wallet (Lux Wallet, MetaMask, `lux key derive`), so the same seed yields the same addresses everywhere.
const Mnemonic = "light light light light light light light light light light light energy"
Mnemonic is the well-known public Lux dev seed. Pass it as the value of LUX_MNEMONIC (or LIGHT_MNEMONIC) to bootstrap a local network. It is the SINGLE source of truth for this string across the ecosystem — every other package that needs it should reference light.Mnemonic, never re-declare it.
Variables ¶
This section is empty.
Functions ¶
func IsLight ¶
IsLight reports whether s is exactly the light Mnemonic. Compared in constant time so a timing attacker cannot probe the running config from outside.
func RefuseOnProduction ¶
RefuseOnProduction returns a non-nil error when the supplied mnemonic must not be used through the light (local-only) derivation path:
- empty string → error (no mnemonic set)
- any non-public seed → error (looks like a real/production mnemonic; luxfi/light is for local dev only, and a production seed must never be fed into a code path that derives from a publicly-known layout)
A recognised public/dev mnemonic (light, BIP-39 vectors, Hardhat, Trezor…) returns nil. This mirrors genesis.RefuseLightMnemonicOnProduction, minus the network-ID coupling: the caller decides WHERE it runs; this decides WHETHER a mnemonic is a safe public/dev value.
Types ¶
type Account ¶
type Account struct {
Index int // BIP44 address index i
ECPrivateKey []byte // 32-byte secp256k1 scalar
EVMAddress ids.ShortID // 20-byte H160 (C-Chain / EVM)
LuxAddress ids.ShortID // 20-byte P/X-Chain address (secp256k1 Address)
}
Account is one deterministic wallet identity derived from the light mnemonic. It carries only account-level material — no staker cert, no NodeID, no BLS — because those are intentionally non-deterministic and out of this package's concern.
func DeriveAccount ¶
DeriveAccount returns the deterministic wallet account at BIP44 index i (m/44'/9000'/0'/0/i) under the light mnemonic. Byte-for-byte identical to genesis.LoadKeysFromMnemonic's secp256k1 derivation and to any canonical BIP44 wallet on the same seed.
func DeriveAccounts ¶
DeriveAccounts returns the first n deterministic wallet accounts (indices 0..n-1). It walks the shared m/44'/9000'/0'/0 prefix once.
func (Account) ECPrivateKeyHex ¶
ECPrivateKeyHex returns the raw private key as lowercase hex (no 0x).
func (Account) EVMAddressHex ¶
EVMAddressHex returns the C-Chain address as 0x-prefixed hex.
func (Account) LuxAddressHex ¶
LuxAddressHex returns the P/X-Chain address as 0x-prefixed hex (the raw 20-byte H160 form; use LuxAddress.String() for the cb58 form).