Skip to Content
本页目录

CryptoHDKey

CryptoHDKey 类表示分层确定性密钥信息。

OneKey 可以将该注册表对象导出为二维码,钱包据此使用公钥数据派生地址。

参数

参数类型描述
isMasterboolean是否为主密钥
isPrivateKeyboolean是否为私钥
keyBuffer密钥数据
chainCodeBuffer链码
useInfoCryptoCoinInfo使用信息
originCryptoKeypath原始路径
childrenCryptoKeypath子路径
parentFingerprintBuffer父指纹
namestring名称(可选)
notestring备注(可选)

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(); }
最后更新于