Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BlockstackWallet

The BlockstackWallet class manages the hierarchical derivation paths for a standard blockstack client wallet. This includes paths for bitcoin payment address, blockstack identity addresses, blockstack application specific addresses. @private

Hierarchy

  • BlockstackWallet

Index

Constructors

constructor

Properties

rootNode

rootNode: BIP32

Methods

getBitcoinAddress

  • getBitcoinAddress(addressIndex: number): string
  • Get a bitcoin receive address at a given index

    Parameters

    • addressIndex: number

      the index of the address

    Returns string

    address

getBitcoinNode

  • getBitcoinNode(addressIndex: number, chainType?: string): BIP32
  • Parameters

    • addressIndex: number
    • Default value chainType: string = EXTERNAL_ADDRESS

    Returns BIP32

getBitcoinPrivateKey

  • getBitcoinPrivateKey(addressIndex: number): string
  • Get the private key hex-string for a given bitcoin receive address

    Parameters

    • addressIndex: number

      the index of the address

    Returns string

    the hex-string. this will be either 64 characters long to denote an uncompressed bitcoin address, or 66 characters long for a compressed bitcoin address.

getBitcoinPrivateKeychain

  • getBitcoinPrivateKeychain(): BIP32

getBitcoinPublicKeychain

  • getBitcoinPublicKeychain(): BIP32
  • Get the root node for the bitcoin public keychain

    Returns BIP32

    base58-encoding of the public node

getIdentityAddressNode

  • getIdentityAddressNode(identityIndex: number): BIP32
  • Parameters

    • identityIndex: number

    Returns BIP32

getIdentityKeyPair

  • getIdentityKeyPair(addressIndex: number, alwaysUncompressed?: boolean): IdentityKeyPair
  • Get the keypair information for a given identity index. This information is used to obtain the private key for an identity address and derive application specific keys for that address.

    Parameters

    • addressIndex: number

      the identity index

    • Default value alwaysUncompressed: boolean = false

      if true, always return a private-key hex string corresponding to the uncompressed address

    Returns IdentityKeyPair

    an IdentityKeyPair type object with keys: .key {String} - the private key hex-string .keyID {String} - the public key hex-string .address {String} - the identity address .appsNodeKey {String} - the base-58 encoding of the applications node .salt {String} - the salt used for creating app-specific addresses

getIdentityPrivateKeychain

  • getIdentityPrivateKeychain(): BIP32

getIdentityPublicKeychain

  • getIdentityPublicKeychain(): BIP32
  • Get the root node for the identity public keychain

    Returns BIP32

    base58-encoding of the public node

getIdentitySalt

  • getIdentitySalt(): string
  • Get a salt for use with creating application specific addresses

    Returns string

    the salt

toBase58

  • toBase58(): string

Static encryptMnemonic

  • encryptMnemonic(mnemonic: string, password: string): Promise<string>
  • Encrypt a mnemonic phrase with a password

    Parameters

    • mnemonic: string

      Raw mnemonic phrase

    • password: string

      Password to encrypt mnemonic with

    Returns Promise<string>

    Hex-encoded encrypted mnemonic

Static fromBase58

  • Initialize a blockstack wallet from a base58 string

    Parameters

    • keychain: string

      the Base58 string used to initialize the root node of the hierarchical wallet

    Returns BlockstackWallet

    the constructed wallet

Static fromEncryptedMnemonic

  • fromEncryptedMnemonic(data: string, password: string): Promise<BlockstackWallet>
  • Initialize a blockstack wallet from an encrypted phrase & password. Throws if the password is incorrect. Supports all formats of Blockstack phrases.

    Parameters

    • data: string

      The encrypted phrase as a hex-encoded string

    • password: string

      The plain password

    Returns Promise<BlockstackWallet>

    the constructed wallet

Static fromSeedBuffer

  • Initialize a blockstack wallet from a seed buffer

    Parameters

    • seed: Buffer

      the input seed for initializing the root node of the hierarchical wallet

    Returns BlockstackWallet

    the constructed wallet

Static generateMnemonic

  • generateMnemonic(): string
  • Generate a BIP-39 12 word mnemonic

    Returns string

    space-separated 12 word phrase

Static getAddressFromBIP32Node

  • getAddressFromBIP32Node(node: BIP32): string

Static getAddressFromBitcoinKeychain

  • getAddressFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): string
  • Get a bitcoin address given a base-58 encoded bitcoin node (usually called the account node)

    Parameters

    • keychainBase58: string

      base58-encoding of the node

    • addressIndex: number

      index of the address to get

    • Default value chainType: string = EXTERNAL_ADDRESS

      either 'EXTERNAL_ADDRESS' (for a "receive" address) or 'CHANGE_ADDRESS'

    Returns string

    the address

Static getAppPrivateKey

  • getAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string
  • Get a ECDSA private key hex-string for an application-specific address.

    Parameters

    • appsNodeKey: string

      the base58-encoded private key for applications node (the appsNodeKey return in getIdentityKeyPair())

    • salt: string

      a string, used to salt the application-specific addresses

    • appDomain: string

      the appDomain to generate a key for

    Returns string

    the private key hex-string. this will be a 64 character string

Static getAppsNode

  • getAppsNode(identityNode: BIP32): BIP32
  • Parameters

    • identityNode: BIP32

    Returns BIP32

Static getLegacyAppPrivateKey

  • getLegacyAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string
  • Get a ECDSA private key hex-string for an application-specific address.

    Parameters

    • appsNodeKey: string

      the base58-encoded private key for applications node (the appsNodeKey return in getIdentityKeyPair())

    • salt: string

      a string, used to salt the application-specific addresses

    • appDomain: string

      the appDomain to generate a key for

    Returns string

    the private key hex-string. this will be a 64 character string

Static getNodeFromBitcoinKeychain

  • getNodeFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): BIP32
  • Parameters

    • keychainBase58: string
    • addressIndex: number
    • Default value chainType: string = EXTERNAL_ADDRESS

    Returns BIP32

Generated using TypeDoc