跳到主要内容

alephiumGetAddress

使用要求

  • 固件版本要求
    • UKey Lite 24 / UKey Lite 25 / UKey Core 26: 1.1.0

Alephium:获取地址

根据传入的 BIP32 路径派生地址,并把结果返回给调用方。开启设备展示时,用户需要在 Ukey Wallet 上核对并确认该地址。

const result = await HardwareSDK.alephiumGetAddress(connectId, deviceId, {
path: "m/44'/1234'/0'/0/0",
showOnUKey: false,
group: 0,
includePublicKey: true,
});

参数

可选通用参数

导出单个地址

  • path - 必需 string | Array<number>,字符串数组最小长度限制为 3
  • group - 可选 number | null | undefined
  • showOnUKey - 可选 boolean,决定是否在设备上进行地址显示;默认值为 true

导出批量地址

  • bundle - 数组对象Array,对象包含的字段有 pathshowOnUKeygroup

示例

// 获取单个地址
const response = await HardwareSDK.alephiumGetAddress(connectId, deviceId, {
path: "m/44'/1234'/1'/0/0",
showOnUKey: true,
});

// 获取多个地址
const batchResponse = await HardwareSDK.alephiumGetAddress(
connectId,
deviceId,
{
bundle: [
{
path: "m/44'/1234'/3'/0/0",
showOnUKey: false,
},
{
path: "m/44'/1234'/4'/0/0",
showOnUKey: false,
},
],
},
);

返回结果

仅返回一个地址的结果

{
success: true,
payload: {
address: string, // 返回的地址
derivedPath: string,
publicKey: string,
path: Array<number> // 派生路径
}
}

批量地址返回示例(顺序与请求一致)

{
success: true,
payload: [
{ address: string, derivedPath: string, publicKey: string, path: Array<number> }, // 账户 1
{ address: string, derivedPath: string, publicKey: string, path: Array<number> }, // 账户 2
{ address: string, derivedPath: string, publicKey: string, path: Array<number> } // 账户 3
]
}

错误

{
success: false,
payload: {
error: string, // 错误消息
code: number // 错误码
}
}