# @exodus/hardware-wallets 中文文档

规范地址：https://npmcn.com/package/%40exodus/hardware-wallets/

版本：3\.6\.5
npm 元数据更新时间：2026-08-20T16:58:58.900Z
中文译文更新时间：2026-11-14T04:13:00.823Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40exodus/hardware-wallets
原文对照：https://npmcn.com/package/%40exodus/hardware-wallets/?lang=original
项目主页：https://github.com/ExodusMovement/exodus/tree/master/libs/features/hardware-wallets
源码仓库：https://github.com/ExodusMovement/exodus

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：72.7 kB，31 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：13 个
- 首次发布：2024-08-07T14:53:51.544Z
- 最新版本发布：2026-08-20T16:58:58.718Z
- 近 30 天下载量：10826（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：35（近 12 个月 8 个）

## 中文简介

一个Exodus SDK特性,为硬件钱包设备的互动提供高水平抽象

## 安装

```sh
npm install @exodus/hardware-wallets
```

也可以使用：`pnpm add @exodus/hardware-wallets`、`yarn add @exodus/hardware-wallets`、`bun add @exodus/hardware-wallets`

## README

# @ exodus/ 硬件- 钱包

这个功能是用于与硬件钱包设备交互的高度抽象.

| 特性 | 支助 |
| :-: | :-: |
| 同步公钥 | ✅ |
| 签名交易 | ✅ |
| 签名信件 | ✅ |
| 软件管理 | ❌ |

## 设备支持矩阵

| 制造商 | 设备模型 | 支助 |
| :-: | :-: | :-: |
| 编辑器 | 纳诺 S | ✅ |
| 编辑器 | 纳诺S+ | ✅ |
| 编辑器 | 纳诺X | ✅ |
| 编辑器 | 税 | ✅ |
| 色谱 | 一个 | ❌ |
| 色谱 | T级 | ❌ |
| 色谱 | 保险 3 | ❌ |
| 色谱 | 保险 5 | ❌ |

## 使用量

### 和IoC

```typescript
import hardwareWallets from '@exodus/hardware-wallets'

ioc.use(hardwareWallets())
```

## 建筑

### 术语

可能需要一些术语来正确理解资产的各种“状态”之间的区别.

-   **支持** 资产:我们实施该装置所支持的所有资产.
-   **已安装** 资产:由我们实施后支持并由用户安装在设备上的所有资产.
-   **可使用** 资产: 由我们执行所支持、安装在装置上并在装置上打开的所有资产(铅管).
-   **同步** 资产:公共密钥已同步到钱包账户整合通道的所有资产.

### `scan({ assetName, accountIndexes, addressLimit, addressOffset })`

这个 `scan` 函数在登入时用于从 `addressOffset` 每个账户索引 `accountIndexes` 从硬件钱包设备。 它使用网络API调用来取回相应的余额. 调用此功能不会使状态发生任何永久的改变,而且其状态都呈平时状态. 此功能可以让用户"扫描"账户,地址和余额,而无需完全承诺一个账户索引并同步它.

> \[叹息\] 此函数只能在硬件钱包设备上载时使用.

```mermaid
sequenceDiagram
    Consumer->>+HardwareWallets: scan({ assetName, accountIndexes, addressOffset })
    HardwareWallets->>+HardwareWalletDevice: getAddress({ assetName, derivationPath })
    HardwareWalletDevice-->>-HardwareWallets: address0
    HardwareWallets->>+HardwareWalletDevice: getAddress({ assetName, derivationPath })
    HardwareWalletDevice-->>-HardwareWallets: address1
    HardwareWallets->>+Asset: api.getBalanceForAddress(address0)
    Asset-->>-HardwareWallets: balance0
    HardwareWallets->>+Asset: api.getBalanceForAddress(address1)
    Asset-->>-HardwareWallets: balance1
    HardwareWallets-->>-Consumer: First N addresses with balance <br> for given account indexes

```

### `sync({ accountIndex })`

为给定的所有可用资产同步公钥( XPUBs / 公钥) `accountIndex` 从硬件钱包设备中临时存储,供将来使用。 硬件钱包设备可能在此方法调用后断开,并且仍然可以上载.

> \[叹息\] 只能同步所支持资产的子集. 一些硬件钱包设备如Ledger不同时支持多个资产,因为特定资产应用程序必须在设备上安装并打开.

```mermaid
sequenceDiagram
    participant Consumer
    participant HardwareWallets
    participant Device
    participant BaseAsset

    Consumer->>HardwareWallets: sync({ accountIndex })
    activate HardwareWallets

    HardwareWallets->>Device: listUseableAssetNames()
    activate Device
    Device-->>HardwareWallets: [assetName0, assetName1, ...]
    deactivate Device

    loop for each assetName
        HardwareWallets->>BaseAsset: getSupportedPurposes({ compatibilityMode: 'ledger' })
        activate BaseAsset
        BaseAsset-->>HardwareWallets: [purpose0, purpose1, ...]
        deactivate BaseAsset

        loop for each purpose
            alt getXPub is supported
                HardwareWallets->>Device: getXPub({ assetName, derivationPath })
                activate Device
                Device-->>HardwareWallets: xpub
                deactivate Device
                HardwareWallets->>HardwareWallets: Store keyIdentifier and xpub
            else getPublicKey instead
                HardwareWallets->>Device: getPublicKey({ assetName, derivationPath })
                activate Device
                Device-->>HardwareWallets: publicKey
                deactivate Device
                HardwareWallets->>HardwareWallets: Store keyIdentifier and publicKey
            end
        end
    end

    HardwareWallets->>HardwareWallets: Generate random ID
    HardwareWallets->>HardwareWallets: Store keys in syncedKeysMap with ID

    HardwareWallets-->>Consumer: SyncedKeysId
    deactivate HardwareWallets

```

### `addPublicKeysToWalletAccount({ walletAccount, syncedKeysId })`

将公钥(XPUBS / 公钥)添加到已有的钱包账户中.

-   移动同步公钥( XPUBs / 公钥) `syncedKeysId` 从临时模拟对象映射到 a `walletAccounts`公用钥匙店 将储存在核聚变中.
-   启动资产恢复程序并触发更新 `txLogMonitor`

```mermaid
sequenceDiagram
    participant Consumer
    participant HardwareWallets
    participant PublicKeyStore
    participant RestoreProgressTracker
    participant TxLogMonitors

    Consumer->>HardwareWallets: addPublicKeysToWalletAccount({ walletAccount, syncedKeysId })
    activate HardwareWallets

    HardwareWallets->>HardwareWallets: Retrieve keys from syncedKeysMap using syncedKeysId
    Note right of HardwareWallets: Retrieves assetNames and keysToSync

    loop for each key in keysToSync
        HardwareWallets->>PublicKeyStore: add({ walletAccount, keyIdentifier, xpub, publicKey })

    end

    loop for each assetName in assetNames
        HardwareWallets->>RestoreProgressTracker: restoreAsset(assetName)
        HardwareWallets->>TxLogMonitors: update({ assetName, refresh: true })
    end

    deactivate HardwareWallets
    HardwareWallets-->>Consumer: void
```

### `create({ syncedKeysId })`

创建新的硬件钱包账户和呼叫 `addPublicKeysToWalletAccount()` 要同步新建的钱包账户的公共密钥.

## 常见问题

### @exodus/hardware-wallets 是什么？

一个Exodus SDK特性,为硬件钱包设备的互动提供高水平抽象

### 如何安装 @exodus/hardware-wallets？

在项目目录运行 npm install @exodus/hardware-wallets，或使用 pnpm add / yarn add / bun add。

### @exodus/hardware-wallets 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @exodus/hardware-wallets 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @exodus/hardware-wallets 可以商用吗？

@exodus/hardware-wallets 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @exodus/hardware-wallets 的下载量有多少？

根据 npm 官方下载统计，@exodus/hardware-wallets 在 2026/10/14 – 2026/11/12 这 30 天内被下载 10,826 次，日均约 361 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @exodus/hardware-wallets 还在维护吗？

最新版本 3\.6\.5 发布于 2026/08/21（2 个月前）；至今共发布 35 个版本，其中过去 12 个月发布了 8 个；首次发布于 2024/08/07。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

