Options
All
  • Public
  • Public/Protected
  • All
Menu

@stacks/keychain

Create and manage keys/wallets for the Stacks blockchain.

Installation

npm install @stacks/keychain

Index

Type aliases

AllowedKeyEntropyBits

AllowedKeyEntropyBits: 128 | 256

Properties

default

default: { Wallet: typeof Wallet }

Type declaration

Variables

Const DEFAULT_PROFILE

DEFAULT_PROFILE: Profile = ...

Const derivationPaths

derivationPaths: { 1: string; 2147483648: string } = ...

Type declaration

  • 1: string
  • 2147483648: string

Const registrars

registrars: { id.blockstack: { apiUrl: string; registerUrl: string }; test-personal.id: { apiUrl: string; registerUrl: string } } = ...

Type declaration

  • id.blockstack: { apiUrl: string; registerUrl: string }
    • apiUrl: string
    • registerUrl: string
  • test-personal.id: { apiUrl: string; registerUrl: string }
    • apiUrl: string
    • registerUrl: string

Functions

assertIsTruthy

  • assertIsTruthy<T>(val: any): asserts val is NonNullable<T>

decrypt

  • decrypt(dataBuffer: Buffer | string, password: string): Promise<string>
  • Decrypt an encrypted mnemonic phrase with a password. Legacy triplesec encrypted payloads are also supported.

    Parameters

    • dataBuffer: Buffer | string
    • password: string

      Password for data

    Returns Promise<string>

    the raw mnemonic phrase

deriveIdentityKeyPair

  • deriveIdentityKeyPair(identityOwnerAddressNode: IdentityAddressOwnerNode): IdentityKeyPair

deriveRootKeychainFromMnemonic

  • deriveRootKeychainFromMnemonic(plaintextMnemonic: string): Promise<BIP32Interface>

deriveStxAddressChain

  • deriveStxAddressChain(chain: ChainID): (rootNode: BIP32Interface) => { address: string; childKey: BIP32Interface; privateKey: string }
  • Parameters

    Returns (rootNode: BIP32Interface) => { address: string; childKey: BIP32Interface; privateKey: string }

      • (rootNode: BIP32Interface): { address: string; childKey: BIP32Interface; privateKey: string }
      • Parameters

        • rootNode: BIP32Interface

        Returns { address: string; childKey: BIP32Interface; privateKey: string }

        • address: string
        • childKey: BIP32Interface
        • privateKey: string

encrypt

  • encrypt(phrase: string, password: string): Promise<Buffer>
  • Encrypt a raw mnemonic phrase to be password protected

    Parameters

    • phrase: string

      Raw mnemonic phrase

    • password: string

      Password to encrypt mnemonic with

    Returns Promise<Buffer>

    The encrypted phrase

encryptMnemonicFormatted

  • encryptMnemonicFormatted(plaintextMnemonic: string, password: string): Promise<{ encryptedMnemonic: Buffer; encryptedMnemonicHex: string }>

Const fetchProfile

  • fetchProfile(__namedParameters: { gaiaUrl: string; identity: Identity }): Promise<null | Profile>

generateEncryptedMnemonicRootKeychain

  • generateEncryptedMnemonicRootKeychain(password: string, entropy: AllowedKeyEntropyBits): Promise<{ encryptedMnemonicPhrase: string; rootNode: BIP32Interface }>

generateMnemonicRootKeychain

  • generateMnemonicRootKeychain(entropy: AllowedKeyEntropyBits): Promise<{ plaintextMnemonic: string; rootNode: BIP32Interface }>

getAddress

  • getAddress(node: BIP32Interface): string

getBitcoinAddressNode

  • getBitcoinAddressNode(bitcoinKeychain: BIP32Interface, addressIndex?: number, chainType?: string): BIP32Interface

getBitcoinPrivateKeychain

  • getBitcoinPrivateKeychain(rootNode: BIP32Interface): BIP32Interface

getBlockchainIdentities

  • getBlockchainIdentities(rootNode: BIP32Interface, identitiesToGenerate: number): Promise<{ bitcoinPublicKeychain: string; firstBitcoinAddress: string; identities: Identity[]; identityAddresses: string[]; identityKeypairs: IdentityKeyPair[]; identityPublicKeychain: string }>
  • Parameters

    • rootNode: BIP32Interface
    • identitiesToGenerate: number

    Returns Promise<{ bitcoinPublicKeychain: string; firstBitcoinAddress: string; identities: Identity[]; identityAddresses: string[]; identityKeypairs: IdentityKeyPair[]; identityPublicKeychain: string }>

getDerivationPath

  • getDerivationPath(chain: ChainID): string

getIdentityOwnerAddressNode

  • getIdentityOwnerAddressNode(identityPrivateKeychain: BIP32Interface, identityIndex?: number): Promise<default>

getIdentityPrivateKeychain

  • getIdentityPrivateKeychain(rootNode: BIP32Interface): BIP32Interface

Const getProfileURLFromZoneFile

  • getProfileURLFromZoneFile(name: string): Promise<undefined | string>

Const makeIdentity

  • makeIdentity(rootNode: BIP32Interface, index: number): Promise<Identity>

Const recursiveRestoreIdentities

  • recursiveRestoreIdentities(__namedParameters: RecursiveMakeIdentitiesOptions): Promise<Identity[]>
  • Restore identities by recursively making a new identity, and checking if it has a username.

    As soon as a username is not found for an identity, the recursion stops.

    Parameters

    • __namedParameters: RecursiveMakeIdentitiesOptions

    Returns Promise<Identity[]>

Const registerSubdomain

  • registerSubdomain(__namedParameters: RegisterParams): Promise<Identity>

Const signAndUploadProfile

  • signAndUploadProfile(__namedParameters: { gaiaHubConfig?: GaiaHubConfig; gaiaHubUrl: string; identity: Identity; profile: Profile }): Promise<void>

signProfileForUpload

uploadProfile

  • uploadProfile(gaiaHubUrl: string, identity: Identity, signedProfileTokenData: string, gaiaHubConfig?: GaiaHubConfig): Promise<string>

Const validateSubdomain

  • Validate the format and availability of a subdomain. Will return an error of enum IdentityNameValidityError if an error is present. If no errors are found, will return null.

    Parameters

    • name: string

      the subdomain to be registered

    • subdomain: Subdomains = ...

      a valid Subdomains enum

    Returns Promise<null | IdentityNameValidityError>

Const validateSubdomainAvailability

  • validateSubdomainAvailability(name: string, subdomain?: Subdomains): Promise<any>

Const validateSubdomainFormat

Generated using TypeDoc