Skip to Content
硬件接入基础 API打开钱包会话
本页目录

打开钱包会话

Protocol V1 / V2 统一入口:打开标准钱包,或让用户选择隐藏钱包。

请用本方法,不要再用已废弃的 getPassphraseState。地址和签名仍然带 deviceId + passphraseState,不要每次签名都重新开 Session。没有 resume-hidden。后续第一笔带 passphraseState 的方法里,Core 已经会恢复。

契约说明见 钱包会话。

import { OpenWalletSessionMode } from '@onekeyfe/hd-core'; const res = await HardwareSDK.openWalletSession(connectId, { mode: OpenWalletSessionMode.Standard, }); if (!res.success) throw new Error(res.payload.error);

参数

可选通用参数

这次调用不要把 mode 和 useEmptyPassphrase / initSession 混在一起。

参数类型必填说明
mode'standard' | 'select-hidden'是使用 @onekeyfe/hd-core 导出的 OpenWalletSessionMode

返回结果

{ success: true, payload: { protocol: 'V1' | 'V2', deviceId: string, resumed: boolean, walletType: 'standard' | 'hidden', passphraseState: string | null, // 标准钱包为 null } }

持久化 deviceId、walletType、passphraseState。固件 session_id 不会出现在返回值里。

错误

{ success: false, payload: { error: string, code?: string | number, } }

这次调用传入 mode: 'resume-hidden' 或 deviceId / passphraseState 会返回 CallMethodInvalidParameter。恢复已绑定的隐藏钱包:下一笔地址 / 签名带上 passphraseState。DeviceCheckUnlockTypeError 表示当前 PIN / Attach-to-PIN 上下文到不了目标钱包。

最后更新于