本页目录
CryptoHDKey
CryptoHDKey 类表示分层确定性密钥信息。
OneKey 可以将该注册表对象导出为二维码,钱包据此使用公钥数据派生地址。
参数
| 参数 | 类型 | 描述 |
|---|---|---|
isMaster | boolean | 是否为主密钥 |
isPrivateKey | boolean | 是否为私钥 |
key | Buffer | 密钥数据 |
chainCode | Buffer | 链码 |
useInfo | CryptoCoinInfo | 使用信息 |
origin | CryptoKeypath | 原始路径 |
children | CryptoKeypath | 子路径 |
parentFingerprint | Buffer | 父指纹 |
name | string | 名称(可选) |
note | string | 备注(可选) |
Note 值
'account.standard'– BIP44 标准账户'account.ledger_live'– Ledger Live 账户'account.ledger_legacy'– Ledger Legacy 账户
UR 示例
UR:CRYPTO-HDKEY/PDAXHDCLAOZTRDKBTKFPRFKBCWVEWYBGDPNTCPVLEOENJSWMBKFTLTRESNWTNLTLMKJYVYMWBSAAHDCXCSBNNLLNBZIAJZTPKPPKJOSTCEZSJEKGYKJOCSKNHFTPSWTIGHVABDIEGTBWWLTEAHTAADEHOYADCSFNAMTAADDYOYADLNCSDWYKCSFNYKAEYKATTAADDYOYADLRAEWKLAWKAYAEASINFPIAIAJLKPJTJYCXEHBKKOGHISINJKCXINJKCXHSC解码示例
import { URDecoder } from '@ngraveio/bc-ur';
import { CryptoHDKey } from '@keystonehq/bc-ur-registry';
const dec = new URDecoder();
// push each scanned frame string into the decoder
// dec.receivePart(frame)
if (dec.isError()) throw new Error('Could not decode account QR code');
if (dec.isSuccess()) {
const ur = dec.resultUR();
if (ur.type !== 'crypto-hdkey') throw new Error('Expected crypto-hdkey');
const hdkey = CryptoHDKey.fromCBOR(ur.cbor);
if (hdkey.isPrivateKey()) throw new Error('Expected a public account export');
const name = hdkey.getName();
const note = hdkey.getNote();
const chainCode = hdkey.getChainCode();
const origin = hdkey.getOrigin();
const xfp = origin?.getSourceFingerprint();
}最后更新于