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ètre | Type | Description |
|---|---|---|
isMaster | boolean | Indique s’il s’agit d’une clé maîtresse |
isPrivateKey | boolean | Indique s’il s’agit d’une clé privée |
key | Buffer | Les données de la clé |
chainCode | Buffer | Le code de chaîne |
useInfo | CryptoCoinInfo | Les informations d’utilisation |
origin | CryptoKeypath | Le chemin d’origine |
children | CryptoKeypath | Le chemin des enfants |
parentFingerprint | Buffer | L’empreinte du parent |
name | string | Le nom (facultatif) |
note | string | La 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/PDAXHDCLAOZTRDKBTKFPRFKBCWVEWYBGDPNTCPVLEOENJSWMBKFTLTRESNWTNLTLMKJYVYMWBSAAHDCXCSBNNLLNBZIAJZTPKPPKJOSTCEZSJEKGYKJOCSKNHFTPSWTIGHVABDIEGTBWWLTEAHTAADEHOYADCSFNAMTAADDYOYADLNCSDWYKCSFNYKAEYKATTAADDYOYADLRAEWKLAWKAYAEASINFPIAIAJLKPJTJYCXEHBKKOGHISINJKCXINJKCXHSCExemple 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