Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Wallet describes a hierarchical deterministic Wallet that produces Catapult-ED25519-compatible accounts.

This class provides with a bridge between BIP32-ED25519 compatible key pairs and symbol ready private and public keys.

example

Usage of hierarchical deterministic wallets

const xkey = ExtendedKey.createFromSeed('000102030405060708090a0b0c0d0e0f');
const wallet = new Wallet(xkey);

// get master account
const masterAccount = wallet.getAccountPrivateKey();

// get DEFAULT WALLET
const defaultWallet = wallet.getChildAccountPrivateKey();

// derive specific child path
const childWallet = wallet.getChildAccountPrivateKey('m/44\'/4343\'/0\'/0\'/0\'');
see

https://github.com/nemtech/NIP/issues/12

since

0.3.0

Hierarchy

  • Wallet

Index

Constructors

constructor

Properties

Readonly extendedKey

extendedKey: ExtendedKey

Protected publicKey

publicKey: Buffer

The wallet public key.

var

{Buffer}

Protected readOnly

readOnly: boolean = false

Whether the wallet is read-only or not.

var

{boolean}

Static DEFAULT_WALLET_PATH

DEFAULT_WALLET_PATH: string = 'm/44\'/4343\'/0\'/0\'/0\''

The default wallet derivaton path.

var

{string}

Methods

getAccountPrivateKey

  • getAccountPrivateKey(): string
  • Get a symbol private key string with the extended key property.

    No derivation is done in this step. Derivation must be done either before calling this method or using the getChildAccount method.

    throws

    {Error} On call of this method with a read-only wallet.

    Returns string

    main account private key.

getAccountPublicKey

  • getAccountPublicKey(): string
  • Get a symbol public key string with the extended key property.

    No derivation is done in this step. Derivation must be done either before calling this method or using the getChildPublicAccount method.

    Returns string

    the account public key.

getChildAccountPrivateKey

  • getChildAccountPrivateKey(path?: string): string
  • Get a symbol private key string with the derived child account.

    In case no derivation path is provided, the default wallet path will be used, see Wallet.DEFAULT_WALLET_PATH.

    see

    Wallet.DEFAULT_WALLET_PATH

    throws

    {Error} On call of this method with a read-only wallet.

    Parameters

    • path: string = Wallet.DEFAULT_WALLET_PATH

      Child derivation path, default to Wallet.DEFAULT_WALLET_PATH.

    Returns string

    the private key

getChildAccountPublicKey

  • getChildAccountPublicKey(path?: string): string
  • Get a symbol public key with the derived child account.

    In case no derivation path is provided, the default wallet path will be used, see Wallet.DEFAULT_WALLET_PATH.

    see

    Wallet.DEFAULT_WALLET_PATH

    Parameters

    • path: string = Wallet.DEFAULT_WALLET_PATH

      Child derivation path, default to Wallet.DEFAULT_WALLET_PATH.

    Returns string

    string the child public key.

isReadOnly

  • isReadOnly(): boolean
  • Return whether the current wallet is read-only, or not.

    In case of an initialization with an extended public key, the wallet is set to be read-only.

    Returns boolean

Generated using TypeDoc