Skip to Content
Sur cette page

CryptoHDKey

La classe CryptoHDKey représente les informations d’une clé déterministe hiérarchique.

OneKey peut exporter cet objet de registre sous forme de QR code afin que le portefeuille puisse dériver des adresses à partir des données de clé publique.

Paramètres

ParamètreTypeDescription
isMasterbooleanIndique s’il s’agit d’une clé maîtresse
isPrivateKeybooleanIndique s’il s’agit d’une clé privée
keyBufferLes données de la clé
chainCodeBufferLe code de chaîne
useInfoCryptoCoinInfoLes informations d’utilisation
originCryptoKeypathLe chemin d’origine
childrenCryptoKeypathLe chemin des enfants
parentFingerprintBufferL’empreinte du parent
namestringLe nom (facultatif)
notestringLa note (facultative)

Valeurs de note

  • 'account.standard' – Compte BIP44 Standard
  • 'account.ledger_live' – Compte Ledger Live
  • 'account.ledger_legacy' – Compte Ledger Legacy

Exemple UR

UR:CRYPTO-HDKEY/PDAXHDCLAOZTRDKBTKFPRFKBCWVEWYBGDPNTCPVLEOENJSWMBKFTLTRESNWTNLTLMKJYVYMWBSAAHDCXCSBNNLLNBZIAJZTPKPPKJOSTCEZSJEKGYKJOCSKNHFTPSWTIGHVABDIEGTBWWLTEAHTAADEHOYADCSFNAMTAADDYOYADLNCSDWYKCSFNYKAEYKATTAADDYOYADLRAEWKLAWKAYAEASINFPIAIAJLKPJTJYCXEHBKKOGHISINJKCXINJKCXHSC

Exemple de décodage

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(); }
Dernière mise à jour le