Lux Docs
Lux Skills Reference

Lux Wallet

Multi-Platform HD Wallet

Overview

Lux Wallet is a multi-platform HD wallet application built as a Yarn Berry monorepo (@luxwallet/monorepo v1.0.0). It ships Desktop (Electron), Web, Mobile (iOS/Android), and Browser Extension from a single TypeScript codebase. Fork of OneKey v5, extensively customized with @luxfi/* packages for Lux Network integration, supporting 27 blockchain families and hardware wallet signing.

Quick Reference

ItemValue
Repogithub.com/luxfi/wallet
Local path~/work/lux/wallet/
Root package@luxwallet/monorepo v1.0.0
Package managerYarn 4.1.0 (Berry) -- NOT pnpm
Node requirement>= 20
LicenseBSD 3-Clause (Lux Industries Inc. 2020-2025)
TypeScriptStrict mode, ES6 target, CommonJS module
React18.x (root), 17.x (ext app)
React Native0.73.7
Expo50.0.5
UI frameworkTamagui 1.79.19 (cross-platform)
EVM libsviem 2.9.x, ethers 5.4.x, ethereumjs-util
Local DBIndexedDB (web/ext), Realm (native) -- OneKeyV5

Architecture

@luxwallet/monorepo
|
+-- apps/
|   +-- ext/           @luxwallet/x v0.92.79  (Chrome/Firefox/Safari extension)
|   +-- desktop/       @onekeyhq/desktop      (Electron 27)
|   +-- mobile/        @onekeyhq/mobile       (React Native + Expo)
|   +-- web/           @onekeyhq/web          (SPA, webpack, port 3000)
|   +-- web-embed/     @onekeyhq/web-embed    (Embedded webview, port 3008)
|
+-- packages/
    +-- core/          @onekeyhq/core          (Chain APIs, crypto, HD derivation)
    +-- kit/           @onekeyhq/kit           (UI views, Redux state, navigation)
    +-- kit-bg/        @onekeyhq/kit-bg        (Background services, vaults, DB)
    +-- shared/        @onekeyhq/shared        (Constants, config, utils, platform)
    +-- components/    @onekeyhq/components    (Tamagui UI component library)
    +-- qr-wallet-sdk/ @onekeyhq/qr-wallet-sdk (Air-gapped QR signing, Keystone)

Layer Diagram

+---------------------------------------------------------+
|                    App Layer (apps/*)                     |
|   ext | desktop | mobile | web | web-embed              |
+---------------------------------------------------------+
|                    UI Layer (packages/kit)                |
|   Views: Home, Send, Receive, Swap, Staking, DApp, ...  |
|   State: Redux Toolkit + jotai + redux-persist           |
+---------------------------------------------------------+
|              Background Layer (packages/kit-bg)          |
|   Services: 40+ background services                     |
|   Vaults:   Per-chain keyring + vault implementations    |
|   DB:       IndexedDB (web) / Realm (native)            |
+---------------------------------------------------------+
|              Core Layer (packages/core)                  |
|   Chains:   27 chain implementations                    |
|   Secret:   BIP-32/39/340, AES-256-CBC, curves          |
|   Base:     CoreChainApiBase, ChainSigner               |
+---------------------------------------------------------+
|              Shared Layer (packages/shared)              |
|   Config, constants, preset networks, platform env      |
+---------------------------------------------------------+

Core Concepts

HD Key Derivation

The wallet implements BIP-32 (SLIP-0010 variant) hierarchical deterministic key derivation with three elliptic curves:

CurveSeed KeyUsed By
secp256k1Bitcoin seedBTC, EVM, Cosmos, Tron, XRP, Doge, LTC, BCH, Kaspa, CKB
ed25519ed25519 seedSOL, Aptos, SUI, NEAR, Algo, Cardano, Polkadot, Nostr
nistp256Nist256p1 seed(Reserved, supported but not primary for any chain)

Key derivation flow:

Mnemonic (BIP-39, English wordlist)
    |
    v
mnemonicToSeedSync(mnemonic, passphrase?)  -- 512-bit seed
    |
    v
HMAC-SHA512(curve_seed_key, seed)  -- master key + chain code
    |
    v
CKDPriv(parent, index)  -- child key derivation
    |                       hardened: index  >= 2^31
    |                       ed25519: hardened only (SLIP-0010)
    v
Per-chain address generation

Master key generation follows SLIP-0010 retry logic: if the derived key is invalid ( >= group order or zero), re-derive using HMAC-SHA512(key, I) recursively.

Entropy storage: Mnemonic entropy is stored with a 2-byte prefix (language code + length) padded to 32 bytes with random data, then encrypted. Supports 12/15/18/21/24-word mnemonics (entropy lengths 16/20/24/28/32 bytes).

BIP Path Templates by Chain

ChainDefault TemplateCoin TypeAddress Encoding
BTC Nested SegWitm/49'/0'/\{i\}'/0/00P2SH_P2WPKH
BTC Taprootm/86'/0'/\{i\}'/0/00P2TR
BTC Native SegWitm/84'/0'/\{i\}'/0/00P2WPKH
BTC Legacym/44'/0'/\{i\}'/0/00P2PKH
EVM (standard)m/44'/60'/0'/0/\{i\}60keccak256
EVM (Ledger Live)m/44'/60'/\{i\}'/0/060keccak256
SOL (standard)m/44'/501'/\{i\}'/0'501ed25519 pubkey
SOL (Ledger Live)m/44'/501'/\{i\}'501ed25519 pubkey
Cosmosm/44'/118'/0'/0/\{i\}118bech32
Cardanom/1852'/1815'/\{i\}'1815bech32
Polkadotm/44'/354'/0'/0/\{i\}354SS58
Tronm/44'/195'/0'/0/\{i\}195base58check
XRPm/44'/144'/0'/0/\{i\}144base58
Aptosm/44'/637'/\{i\}'637hex
SUIm/44'/784'/\{i\}'/0'/0'784hex
NEARm/44'/397'/\{i\}'397implicit/named
Filecoinm/44'/461'/0'/0/\{i\}461f1/f3
Kaspam/44'/111111'/\{i\}'111111bech32
Lightningm/44'/81297820149147'/0'/0/\{i\}81297820149147invoice

Supported Chains (27 Families)

Production-enabled chain implementations with vault + keyring + core API:

#Impl IDChainAccount TypeCurveUTXONFT
1evmEthereum + all EVM (Lux C-Chain, BSC, Polygon, Arbitrum, Optimism, etc.)SIMPLEsecp256k1NoYes
2btcBitcoinUTXOsecp256k1YesNo
3tbtcBitcoin TestnetUTXOsecp256k1YesNo
4solSolanaSIMPLEed25519NoYes
5adaCardanoUTXOed25519YesNo
6dotPolkadot / SubstrateVARIANTed25519NoNo
7cosmosCosmos Hub, Osmosis, Juno, Akash, Fetch, Celestia, Secret Network, Crypto.orgVARIANTsecp256k1NoNo
8nearNEAR ProtocolVARIANTed25519NoNo
9algoAlgorandSIMPLEed25519NoNo
10aptosAptosSIMPLEed25519NoNo
11suiSuiSIMPLEed25519NoNo
12tronTRONSIMPLEsecp256k1NoNo
13xrpXRP LedgerSIMPLEsecp256k1NoNo
14dogeDogecoinUTXOsecp256k1YesNo
15ltcLitecoinUTXOsecp256k1YesNo
16bchBitcoin CashUTXOsecp256k1YesNo
17neuraiNeuraiUTXOsecp256k1YesNo
18filFilecoinSIMPLEsecp256k1NoNo
19cfxConfluxSIMPLEsecp256k1NoNo
20kaspaKaspaSIMPLEsecp256k1NoNo
21nexaNexaUTXOsecp256k1YesNo
22lightningLightning NetworkSIMPLEsecp256k1NoNo
23tlightningLightning TestnetSIMPLEsecp256k1NoNo
24nostrNostrSIMPLEsecp256k1NoNo
25dynexDynexSIMPLEed25519NoNo
26nervosNervos CKBSIMPLEsecp256k1NoNo
27xmrMoneroSIMPLEed25519NoNo

EVM networks include: Ethereum, Lux C-Chain, BSC, Polygon, Arbitrum, Optimism, Fantom, Mantle, Manta Pacific, Blast, and many more via the preset networks configuration.

Key Management and Encryption

At-rest encryption: All private keys and seed material are encrypted with AES-256-CBC before storage.

Encryption: AES-256-CBC
KDF:        PBKDF2-HMAC-SHA256 (5000 iterations, 32-byte salt)
Key length: 256-bit (32 bytes)
IV:         128-bit (16 bytes, random per encrypt)
Storage:    salt(32) || iv(16) || ciphertext

Password encoding: Passwords are never passed as raw strings in non-production builds. A SENSITIVE_ENCODE prefix mechanism encrypts passwords with a per-session random key (UUID-based) so they cannot be read from debugger breakpoints.

Credential types:

  • |RP| prefix: HD credential (recovery phrase -- encrypted \{entropyWithLangPrefixed, seed\} JSON)
  • |PK| prefix: Imported credential (encrypted \{privateKey\} JSON)
  • |VS| prefix: Verify string (encrypted known plaintext for password verification)

Additional encryptors:

  • RSA (1024-bit, PKCS8) for inter-process secure key exchange
  • BIP-340 Schnorr (Taproot tagged hashes: TapLeaf, TapBranch, TapSighash, TapTweak)

Keyring Architecture

Each chain vault has 6 keyring types:

KeyringClassPurpose
KeyringHdKeyringHdBaseHD wallet (mnemonic-derived)
KeyringImportedKeyringImportedBaseImported private key
KeyringHardwareKeyringHardwareBaseHardware wallet (OneKey, Ledger, Trezor)
KeyringWatchingKeyringWatchingBaseWatch-only (address or xpub)
KeyringQrKeyringQrBaseAir-gapped QR signing (Keystone)
KeyringExternalKeyringExternalBaseExternal wallet (WalletConnect, injected)

All keyrings implement:

  • prepareAccounts() -- derive or import accounts
  • signTransaction() -- sign and return ISignedTxPro
  • signMessage() -- sign arbitrary messages
  • getPrivateKeys() / exportAccountSecretKeys() (HD/imported only)

Hardware Wallet Integration

Hardware support via @onekeyfe/hd-core v1.0.3 SDK:

DeviceTransportSDK Package
OneKey Classic/Touch/Mini/ProBLE, USB@onekeyfe/hd-ble-sdk, @onekeyfe/hd-web-sdk
LedgerWebHID@ledgerhq/hw-app-eth v6.34.9, @ledgerhq/hw-transport-webhid v6.27.20
TrezorWebExtension@trezor/connect-webextension v9.2.2
KeystoneQR (air-gapped)@keystonehq/keystone-sdk v0.4.1
BitBoxWebUSBbitbox-api v0.3.2
GridPlus LatticeHTTP@luxfi/eth-lattice-keyring v1.1.1

Hardware signing flow (EVM example):

  1. KeyringHardware.signTransaction() gets SDK instance and account path
  2. Encodes transaction as EVMTransaction or EVMTransactionEIP1559
  3. Calls sdk.evmSignTransaction(connectId, deviceId, \{path, transaction\})
  4. Receives \{v, r, s\} signature from device
  5. buildSignedTxFromSignatureEvm() assembles and serializes the signed tx
  6. Returns \{txid, rawTx, encodedTx\}

Transaction Building

The wallet uses a typed transaction system:

IUnsignedTxPro = {
  encodedTx: IEncodedTx;     // Chain-specific encoded transaction
  feeInfo?: IFeeInfoUnit;    // Gas/fee estimation
  swapInfo?: ISwapTxInfo;    // DEX swap metadata
  stakingInfo?: IStakingInfo; // Staking operation metadata
  transfersInfo?: ITransferInfo[];
}

ISignedTxPro = {
  txid: string;
  rawTx: string;
  encodedTx: IEncodedTx | null;
  signature?: string;
  publicKey?: string;
}

Each chain's CoreChainSoftware handles:

  1. packUnsignedTxForSign() -- serialize tx to signing digest
  2. signer.sign(digest) -- ECDSA/EdDSA signature with recovery
  3. buildSignedTx() -- attach signature, compute txid

DApp Connection

The wallet supports DApp interaction via:

  • Injected provider: @onekeyfe/cross-inpage-provider-* packages inject window.ethereum (EVM), window.solana, etc.
  • WalletConnect v2: @walletconnect/universal-provider v2.11.2, @walletconnect/web3wallet v1.10.2
  • Coinbase Wallet SDK: @coinbase/wallet-sdk v3.8.x
  • Gnosis Safe: @gnosis.pm/safe-core-sdk v1.1.1, @luxfi/eth-gnosis-keyring v0.0.2

The ServiceDApp (946 lines) manages connection lifecycle, permission grants, and method routing.

Database Layer

PlatformEngineDB Name
Web / ExtensionIndexedDBOneKeyV5
iOS / AndroidRealmOneKeyV5

Account types stored:

  • SIMPLE -- single address (EVM, SOL, etc.)
  • UTXO -- multi-address (BTC, DOGE, LTC, BCH)
  • VARIANT -- address varies by network (Cosmos, NEAR)

Store names include: Wallet, Account, Device, Credential, SignedMessage, SignedTransaction, ConnectedSite, and more.

Lux-Specific Packages

The browser extension (apps/ext) uses @luxfi/* packages for Lux Network integration:

PackageVersionPurpose
@luxfi/common^0.3.61Shared Lux utilities
@luxfi/lux-api0.7.23Lux Network RPC client
@luxfi/lux-security-engine2.0.4Transaction security analysis
@luxfi/lux-swap0.0.39DEX aggregation
@luxfi/eth-hd-keyring4.3.2HD keyring for EVM
@luxfi/eth-simple-keyring5.0.1Simple key import
@luxfi/eth-trezor-keyring2.5.2Trezor hardware signing
@luxfi/eth-lattice-keyring1.1.1GridPlus Lattice signing
@luxfi/eth-walletconnect-keyring2.1.3WalletConnect keyring
@luxfi/eth-coinbase-keyring0.0.1Coinbase wallet keyring
@luxfi/eth-gnosis-keyring0.0.2Gnosis Safe multisig
@luxfi/eth-watch-keyring1.0.0Watch-only addresses
@luxfi/gnosis-sdk1.3.6Gnosis Safe SDK
@luxfi/festats1.0.1Frontend analytics
@luxfi/page-provider0.3.5DApp page injection
@luxfi/widgets1.0.9Embeddable UI widgets
blake2b-luxgithub:luxfi/blake2b-luxBlake2b hash (resolution)

Platforms

PlatformApp PackageTechnologyKey Deps
Chrome/Firefox/Safari@luxwallet/x v0.92.79Webpack 5, MV2/MV3, Tailwindantd 4.x, styled-components
Desktop@onekeyhq/desktopElectron 27, webpackelectron-root-path, keytar
iOS@onekeyhq/mobileReact Native 0.73.7, Expo 50expo-camera, react-native-ble
Android@onekeyhq/mobileReact Native 0.73.7, Expo 50expo-camera, react-native-ble
Web@onekeyhq/webwebpack-dev-server, port 3000--
Web Embed@onekeyhq/web-embedwebpack, port 3008Cardano WASM agent

Background Services (40+)

Key services in packages/kit-bg/src/services/:

ServicePurpose
ServiceAccountAccount creation, derivation, management
ServicePasswordPassword encoding, biometric auth
ServiceSendTransaction construction and broadcasting
ServiceSwapDEX swap routing and execution
ServiceStakingStaking delegation and rewards
ServiceDAppDApp connection and method dispatch
ServiceHardwareHardware device management, firmware updates
ServiceNetworkNetwork configuration and switching
ServiceTokenToken discovery, balances, prices
ServiceNFTNFT indexing and display
ServiceHistoryTransaction history (local + on-chain)
ServiceDiscoveryDApp browser and discovery
ServiceCloudBackupiCloud/Google Drive backup
ServiceLightningLightning Network invoice management
ServiceNostrNostr key and event signing
ServiceWalletConnectWalletConnect v2 session management
ServiceFirmwareUpdateHardware wallet firmware OTA
ServiceQrWalletAir-gapped QR wallet protocol
ServiceValidatorAddress and transaction validation

UI Views

Primary views in packages/kit/src/views/:

Home | Send | Receive | Swap | Staking | Market | Discovery (DApp browser) | AssetList | AssetDetails | AccountManagerStacks | Setting | Onboarding | FirmwareUpdate | LightningNetwork | ScanQrCode | AddressBook | FiatCrypto | CloudBackup | KeyTag | LiteCard | UniversalSearch

Development

# Install (requires Node  >= 20, git-lfs)
yarn

# Development
yarn app:web              # Web on port 3000
yarn app:ext              # Browser extension (MV3 dev build)
yarn app:desktop          # Electron desktop
yarn app:ios              # iOS via USB
yarn app:android          # Android

# Building
yarn app:ext:build        # Production extension
yarn app:web:build        # Production web

# Testing
yarn test                 # Jest test suite

# Linting
yarn lint                 # TSC + ESLint + folder lint + i18n check

# Clean
yarn clean                # Full workspace clean
yarn reinstall            # Clean + install

Security Model

  1. Mnemonic never stored in plaintext -- encrypted as IBip39RevealableSeed with AES-256-CBC
  2. Private keys encrypted at rest -- PBKDF2 KDF with 5000 iterations
  3. Password verification -- encrypted known string (DEFAULT_VERIFY_STRING) used to check password correctness without storing the password
  4. Session encoding -- passwords encoded with per-session random key to prevent debugger interception
  5. Extension isolation -- decodePassword() throws if called from extension UI process (must use background)
  6. Hardware signing -- private keys never leave the hardware device
  7. QR air-gap -- Keystone SDK for fully offline signing via animated QR codes

Patches

15 patch-package patches maintained in /patches/:

  • @kaspa/core-lib, coinselect (UTXO selection fix)
  • @tamagui/animate, @tamagui/switch (UI fixes)
  • @walletconnect/modal-react-native (RN compat)
  • react-native-* (various RN fixes)
  • expo-camera, metro (build fixes)
  • protobufjs (serialization fix)
  • lux/lux-crypto.md -- Cryptographic primitives and curves
  • lux/lux-safe.md -- Multisig wallets (Gnosis Safe fork)
  • lux/lux-sdk.md -- Go SDK wallet utilities
  • lux/lux-ledger.md -- Ledger hardware integration

On this page