Skip to content

Conversation

@Gaubee
Copy link
Contributor

@Gaubee Gaubee commented Jan 5, 2026

Summary

Fixes chain settings not persisting by unifying all derivation paths through chain-adapter as single source of truth.

Changes

Phase 1: Strict ChainKind enum

  • Remove custom from ChainKindSchema → strict bioforest | evm | bitcoin | tron
  • Remove normalizeUnknownType/normalizeUnknownKind fallback logic
  • Update testnet-chains.json to use proper chainKind values

Phase 2: Unified derivation in chain-adapter

  • Implement deriveAddress/deriveAddresses in EVM/Tron/Bitcoin identity services
  • All identity services now use unified deriveKey/deriveBitcoinKey from @/lib/crypto
  • Input semantics: seed = TextEncoder().encode(mnemonic) (UTF-8 encoded mnemonic)

Phase 3: BIP84 Native SegWit for Bitcoin

  • Update bitcoin-strategy to use BIP84 path m/84'/0'/account'/0/index
  • Bitcoin addresses now use Native SegWit format (bc1q...)
  • BREAKING: Existing Bitcoin Legacy addresses will change

Cleanup

  • Remove deprecated bip39/ adapter directory
  • Replace ChainConfigType with ChainKind across all adapters
  • Update white-book documentation

Testing

  • All 1713 unit tests passing
  • Updated tests to expect bc1q... address format

Breaking Changes

  • ChainKind no longer accepts custom or bip39
  • Bitcoin addresses change from Legacy (1...) to Native SegWit (bc1q...)

Gaubee added 5 commits January 5, 2026 15:20
…dapter

BREAKING CHANGE: ChainKind 'custom' is removed. All chains must use
one of: 'bioforest', 'evm', 'bitcoin', 'tron'.

Changes:
- Remove 'custom' from ChainKindSchema, strict validation rejects unknown kinds
- Remove normalizeUnknownType/normalizeUnknownKind fallback logic
- Update testnet-chains.json to use proper chainKind values
- Implement EVM/Tron/Bitcoin identity services using unified deriveKey
- Identity services now expect UTF-8 encoded mnemonic as seed input
- Export deriveBitcoinKey and BitcoinPurpose from @/lib/crypto
- Update address-derivation.ts to handle tron separately from bitcoin
- Fix all tests to use valid chainKind values
- Update bitcoin-strategy to use BIP84 Native SegWit (bc1q...) instead of Legacy P2PKH
- Update key-material-provider to derive Bitcoin keys using BIP84 path (m/84'/0'/...)
- Remove 'custom' chainKind handling from build-wallet-chain-addresses
- Replace ChainConfigType with ChainKind across all adapters
- Fix bitcoin/adapter.ts chainType from 'bip39' to 'bitcoin'
- Update tests to expect bc1q... address format
Bitcoin and Tron now have their own dedicated adapters.
The shared bip39 adapter is no longer needed.
- Update ChainConfigType to ChainKind with strict enum
- Document Bitcoin BIP84 Native SegWit path (m/84'/0'/...)
- Add Tron derivation path documentation
- Remove deprecated custom/bip39 type references
- Add strict type validation section
…derivation

- Add derive-wallet-chain-addresses.ts helper to chain-adapter
- Update create.tsx, recover.tsx, wallet.ts to use chain-adapter for derivation
- Remove lib/crypto/address-derivation.ts (bypass code)
- Remove services/wallet/chain-derivation directory (bypass code)

This ensures all address derivation flows through chain-adapter's identity
services, eliminating inconsistent derivation logic across the codebase.
@Gaubee Gaubee merged commit a7db54c into main Jan 5, 2026
5 checks passed
@Gaubee Gaubee deleted the feat/refactor-chain-single-truth branch January 5, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants