mirror of
https://github.com/luxfi/keys.git
synced 2026-07-26 23:58:11 +00:00
keys: rename CoinTypeLux → CoinTypeUTXO + LUXCoinType → CoinTypeEVM
Name the SLIP-0044 coin-type constants by what they ARE — derivation roots for UTXO-layout chains (X/P, 9000') and for EVM chains (60', shared with Ethereum) — not by the brand that uses them. Same rule as utxoAddr/evmAddr from the project-wide chain-vocabulary scrub. SLIP-0044 values (9000, 60) unchanged. Zero external callers across lux/node, lux/cli, lux/wallet. No backwards-compat alias; forward only.
This commit is contained in:
@@ -546,7 +546,7 @@ func deriveMnemonicKeyForPath(mnemonic string, account, index uint32) ([]byte, e
|
||||
}
|
||||
|
||||
// m/44'/60' (coin type for LUX)
|
||||
key, err = key.NewChildKey(bip32.FirstHardenedChild + LUXCoinType)
|
||||
key, err = key.NewChildKey(bip32.FirstHardenedChild + CoinTypeEVM)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to derive coin type: %w", err)
|
||||
}
|
||||
@@ -572,8 +572,9 @@ func deriveMnemonicKeyForPath(mnemonic string, account, index uint32) ([]byte, e
|
||||
return key.Key, nil
|
||||
}
|
||||
|
||||
// LUXCoinType is the BIP-44 coin type for LUX (60' = standard Ethereum)
|
||||
const LUXCoinType = 60
|
||||
// CoinTypeEVM is the SLIP-0044 coin_type for EVM chains (60', shared with
|
||||
// Ethereum). C-Chain and any non-Lux L1 EVM derive under this tree.
|
||||
const CoinTypeEVM = 60
|
||||
|
||||
// deriveMnemonicKey derives an EC private key from mnemonic using BIP44 path m/44'/60'/0'/0/{index}
|
||||
func deriveMnemonicKey(mnemonic string, accountIndex uint32) ([]byte, error) {
|
||||
@@ -596,7 +597,7 @@ func deriveMnemonicKey(mnemonic string, accountIndex uint32) ([]byte, error) {
|
||||
}
|
||||
|
||||
// m/44'/60' (coin type for LUX)
|
||||
key, err = key.NewChildKey(bip32.FirstHardenedChild + LUXCoinType)
|
||||
key, err = key.NewChildKey(bip32.FirstHardenedChild + CoinTypeEVM)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to derive coin type: %w", err)
|
||||
}
|
||||
|
||||
+8
-7
@@ -61,12 +61,13 @@ import (
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
// CoinTypeLux is the SLIP-0044 coin_type for Lux P/X chains. Service
|
||||
// identities derive under m/44'/9000'/<serviceIndex>'/0'/0' so they
|
||||
// share the same coin-type as Lux staking keys but never collide with
|
||||
// account-zero derivations (serviceIndex is hashed from servicePath,
|
||||
// never 0 in practice for any well-formed path).
|
||||
const CoinTypeLux = 9000
|
||||
// CoinTypeUTXO is the SLIP-0044 coin_type for the UTXO-layout DAG-like
|
||||
// chains — X-Chain (AVM) + P-Chain. Service identities derive under
|
||||
// m/44'/9000'/<serviceIndex>'/0'/0' so they share the coin-type tree
|
||||
// with X/P staking keys but never collide with account-zero derivations
|
||||
// (serviceIndex is hashed from servicePath, never 0 in practice for
|
||||
// any well-formed path).
|
||||
const CoinTypeUTXO = 9000
|
||||
|
||||
// BIP44Purpose is the BIP-44 purpose constant. Pinned to 44 even though
|
||||
// service identities don't carry funds — staying inside the BIP-44
|
||||
@@ -163,7 +164,7 @@ func NewServiceIdentity(mnemonic, servicePath string) (*ServiceIdentity, error)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("keys: derive purpose: %w", err)
|
||||
}
|
||||
coin, err := purpose.NewChildKey(bip32.FirstHardenedChild + CoinTypeLux)
|
||||
coin, err := purpose.NewChildKey(bip32.FirstHardenedChild + CoinTypeUTXO)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("keys: derive coin: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user