Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/white-book/04-服务篇/02-链服务/IIdentityService.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ IIdentityService {

## 派生路径规范

| 链类型 | 派生路径 | 算法 |
|-------|---------|------|
| EVM 兼容 | m/44'/60'/0'/0/{index} | secp256k1 |
| Bitcoin | m/44'/0'/0'/0/{index} | secp256k1 |
| BFM 链 | m/44'/9999'/0'/0/{index} | Ed25519 |
| 链类型 | 派生路径 | 算法 | 地址格式 |
|-------|---------|------|---------|
| EVM 兼容 | m/44'/60'/0'/0/{index} | secp256k1 | 0x... (checksum) |
| Bitcoin | m/84'/0'/0'/0/{index} | secp256k1 | bc1q... (Native SegWit) |
| Tron | m/44'/195'/0'/0/{index} | secp256k1 | T... (Base58Check) |
| BioForest | m/44'/9999'/0'/0/{index} | Ed25519 | b... (Base58) |

> **注意**: Bitcoin 使用 BIP84 路径(Native SegWit),不再使用 BIP44 Legacy 路径。

### 派生流程

Expand Down
39 changes: 29 additions & 10 deletions docs/white-book/04-服务篇/07-链配置管理/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ interface ChainConfig {
// 必需字段
id: string // 唯一标识,格式: /^[a-z0-9-]+$/
version: string // 配置版本,格式: "major.minor"
type: ChainConfigType // 链类型
chainKind: ChainKind // 链类型(严格枚举,不支持 custom)
name: string // 显示名称
symbol: string // 原生代币符号
decimals: number // 原生代币精度
Expand All @@ -113,7 +113,7 @@ interface ChainConfig {
source: ChainConfigSource // 配置来源
}

type ChainConfigType = 'bioforest' | 'evm' | 'bip39' | 'custom'
type ChainKind = 'bioforest' | 'evm' | 'bitcoin' | 'tron'
type ChainConfigSource = 'default' | 'subscription' | 'manual'
```

Expand Down Expand Up @@ -156,18 +156,37 @@ EVM 兼容链,使用 BIP44 派生(coin type 60):

**支持的链**: Ethereum, BSC, Polygon 等

### bip39
### bitcoin

其他使用 BIP39/BIP44 的链:
Bitcoin 网络,使用 BIP84 派生(Native SegWit):

| 链 | Coin Type | 说明 |
|---|-----------|------|
| Bitcoin | 0 | UTXO 模型 |
| Tron | 195 | 账户模型 |
| 字段 | 说明 |
|-----|------|
| decimals | 8 |
| 地址格式 | `bc1q...` (Native SegWit P2WPKH) |

**派生路径**: `m/84'/0'/account'/0/index`

### tron

Tron 网络,使用 BIP44 派生(coin type 195):

| 字段 | 说明 |
|-----|------|
| decimals | 6 |
| 地址格式 | `T...` (Base58Check) |

**派生路径**: `m/44'/195'/account'/0/index`

---

## 严格类型验证

### custom
从版本 2.0.0 起,`chainKind` 采用严格枚举验证:

未知类型,用于向前兼容。应用 **MAY** 显示但 **MUST NOT** 执行交易操作。
- **MUST** 使用 `bioforest`、`evm`、`bitcoin`、`tron` 之一
- **MUST NOT** 使用 `custom` 或 `bip39`(已废弃)
- 未知类型将导致配置加载失败,而不是静默降级

---

Expand Down
133 changes: 72 additions & 61 deletions public/configs/testnet-chains.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,73 @@
[
{
"id": "ethereum-sepolia",
"version": "1.0",
"type": "evm",
"name": "Ethereum Sepolia",
"symbol": "SepoliaETH",
"icon": "../icons/ethereum/chain.svg",
"decimals": 18,
"api": { "url": "https://rpc.sepolia.org", "path": "eth" },
"explorer": {
"url": "https://sepolia.etherscan.io",
"queryTx": "https://sepolia.etherscan.io/tx/:hash",
"queryAddress": "https://sepolia.etherscan.io/address/:address"
{
"version": "2.0.0",
"chains": [
{
"id": "ethereum-sepolia",
"version": "1.0",
"chainKind": "evm",
"name": "Ethereum Sepolia",
"symbol": "SepoliaETH",
"icon": "../icons/ethereum/chain.svg",
"decimals": 18,
"api": {
"ethereum-rpc": "https://rpc.sepolia.org"
},
"explorer": {
"url": "https://sepolia.etherscan.io",
"queryTx": "https://sepolia.etherscan.io/tx/:hash",
"queryAddress": "https://sepolia.etherscan.io/address/:address"
}
},
{
"id": "bsc-testnet",
"version": "1.0",
"chainKind": "evm",
"name": "BSC Testnet",
"symbol": "tBNB",
"icon": "../icons/binance/chain.svg",
"decimals": 18,
"api": {
"ethereum-rpc": "https://bsc-testnet-rpc.publicnode.com"
},
"explorer": {
"url": "https://testnet.bscscan.com",
"queryTx": "https://testnet.bscscan.com/tx/:hash",
"queryAddress": "https://testnet.bscscan.com/address/:address"
}
},
{
"id": "tron-nile",
"version": "1.0",
"chainKind": "tron",
"name": "Tron Nile Testnet",
"symbol": "TRX",
"icon": "../icons/tron/chain.svg",
"decimals": 6,
"api": {
"tron-rpc": "https://nile.trongrid.io"
},
"explorer": {
"url": "https://nile.tronscan.org",
"queryTx": "https://nile.tronscan.org/#/transaction/:hash",
"queryAddress": "https://nile.tronscan.org/#/address/:address"
}
},
{
"id": "bitcoin-signet",
"version": "1.0",
"chainKind": "bitcoin",
"name": "Bitcoin Signet",
"symbol": "sBTC",
"icon": "../icons/bitcoin/chain.svg",
"decimals": 8,
"api": {
"mempool-v1": "https://mempool.space/signet/api"
},
"explorer": {
"url": "https://mempool.space/signet",
"queryTx": "https://mempool.space/signet/tx/:hash",
"queryAddress": "https://mempool.space/signet/address/:address"
}
}
},
{
"id": "bsc-testnet",
"version": "1.0",
"type": "evm",
"name": "BSC Testnet",
"symbol": "tBNB",
"icon": "../icons/binance/chain.svg",
"decimals": 18,
"api": { "url": "https://bsc-testnet-rpc.publicnode.com", "path": "bnb" },
"explorer": {
"url": "https://testnet.bscscan.com",
"queryTx": "https://testnet.bscscan.com/tx/:hash",
"queryAddress": "https://testnet.bscscan.com/address/:address"
}
},
{
"id": "tron-nile",
"version": "1.0",
"type": "bip39",
"name": "Tron Nile Testnet",
"symbol": "TRX",
"icon": "../icons/tron/chain.svg",
"decimals": 6,
"api": { "url": "https://nile.trongrid.io", "path": "tron" },
"explorer": {
"url": "https://nile.tronscan.org",
"queryTx": "https://nile.tronscan.org/#/transaction/:hash",
"queryAddress": "https://nile.tronscan.org/#/address/:address"
}
},
{
"id": "bitcoin-signet",
"version": "1.0",
"type": "bip39",
"name": "Bitcoin Signet",
"symbol": "sBTC",
"icon": "../icons/bitcoin/chain.svg",
"decimals": 8,
"api": { "url": "https://mempool.space/signet/api", "path": "btc" },
"explorer": {
"url": "https://mempool.space/signet",
"queryTx": "https://mempool.space/signet/tx/:hash",
"queryAddress": "https://mempool.space/signet/address/:address"
}
}
]
]
}
152 changes: 0 additions & 152 deletions src/lib/crypto/address-derivation.test.ts

This file was deleted.

Loading