UNPKG

6.51 kBTypeScriptView Raw
1/// <reference types="node" />
2import { BIP32Interface } from 'bitcoinjs-lib';
3/**
4 *
5 * @ignore
6 */
7export declare type IdentityKeyPair = {
8 key: string;
9 keyID: string;
10 address: string;
11 appsNodeKey: string;
12 salt: string;
13};
14/**
15 * The `BlockstackWallet` class manages the hierarchical derivation
16 * paths for a standard Blockstack client wallet. This includes paths
17 * for Bitcoin payment address, Blockstack identity addresses, Blockstack
18 * application specific addresses.
19 *
20 * @ignore
21 */
22export declare class BlockstackWallet {
23 rootNode: BIP32Interface;
24 constructor(rootNode: BIP32Interface);
25 toBase58(): string;
26 /**
27 * Initialize a Blockstack wallet from a seed buffer
28 * @param {Buffer} seed - the input seed for initializing the root node
29 * of the hierarchical wallet
30 * @return {BlockstackWallet} the constructed wallet
31 */
32 static fromSeedBuffer(seed: Buffer): BlockstackWallet;
33 /**
34 * Initialize a Blockstack wallet from a base58 string
35 * @param {string} keychain - the Base58 string used to initialize
36 * the root node of the hierarchical wallet
37 * @return {BlockstackWallet} the constructed wallet
38 */
39 static fromBase58(keychain: string): BlockstackWallet;
40 /**
41 * Initialize a blockstack wallet from an encrypted phrase & password. Throws
42 * if the password is incorrect. Supports all formats of Blockstack phrases.
43 * @param {string} data - The encrypted phrase as a hex-encoded string
44 * @param {string} password - The plain password
45 * @return {Promise<BlockstackWallet>} the constructed wallet
46 *
47 * @ignore
48 */
49 static fromEncryptedMnemonic(data: string, password: string): Promise<BlockstackWallet>;
50 /**
51 * Generate a BIP-39 12 word mnemonic
52 * @return {Promise<string>} space-separated 12 word phrase
53 */
54 static generateMnemonic(): string;
55 /**
56 * Encrypt a mnemonic phrase with a password
57 * @param {string} mnemonic - Raw mnemonic phrase
58 * @param {string} password - Password to encrypt mnemonic with
59 * @return {Promise<string>} Hex-encoded encrypted mnemonic
60 *
61 */
62 static encryptMnemonic(mnemonic: string, password: string): Promise<string>;
63 getIdentityPrivateKeychain(): BIP32Interface;
64 getBitcoinPrivateKeychain(): BIP32Interface;
65 getBitcoinNode(addressIndex: number, chainType?: string): BIP32Interface;
66 getIdentityAddressNode(identityIndex: number): BIP32Interface;
67 static getAppsNode(identityNode: BIP32Interface): BIP32Interface;
68 /**
69 * Get a salt for use with creating application specific addresses
70 * @return {String} the salt
71 */
72 getIdentitySalt(): string;
73 /**
74 * Get a bitcoin receive address at a given index
75 * @param {number} addressIndex - the index of the address
76 * @return {String} address
77 */
78 getBitcoinAddress(addressIndex: number): string;
79 /**
80 * Get the private key hex-string for a given bitcoin receive address
81 * @param {number} addressIndex - the index of the address
82 * @return {String} the hex-string. this will be either 64
83 * characters long to denote an uncompressed bitcoin address, or 66
84 * characters long for a compressed bitcoin address.
85 */
86 getBitcoinPrivateKey(addressIndex: number): string;
87 /**
88 * Get the root node for the bitcoin public keychain
89 * @return {String} base58-encoding of the public node
90 */
91 getBitcoinPublicKeychain(): BIP32Interface;
92 /**
93 * Get the root node for the identity public keychain
94 * @return {String} base58-encoding of the public node
95 */
96 getIdentityPublicKeychain(): BIP32Interface;
97 static getNodeFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): BIP32Interface;
98 /**
99 * Get a bitcoin address given a base-58 encoded bitcoin node
100 * (usually called the account node)
101 * @param {String} keychainBase58 - base58-encoding of the node
102 * @param {number} addressIndex - index of the address to get
103 * @param {String} chainType - either 'EXTERNAL_ADDRESS' (for a
104 * "receive" address) or 'CHANGE_ADDRESS'
105 * @return {String} the address
106 */
107 static getAddressFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): string;
108 /**
109 * Get a ECDSA private key hex-string for an application-specific
110 * address.
111 * @param {String} appsNodeKey - the base58-encoded private key for
112 * applications node (the `appsNodeKey` return in getIdentityKeyPair())
113 * @param {String} salt - a string, used to salt the
114 * application-specific addresses
115 * @param {String} appDomain - the appDomain to generate a key for
116 * @return {String} the private key hex-string. this will be a 64
117 * character string
118 */
119 static getLegacyAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string;
120 static getAddressFromBIP32Node(node: BIP32Interface): string;
121 /**
122 * Get a ECDSA private key hex-string for an application-specific
123 * address.
124 * @param {String} appsNodeKey - the base58-encoded private key for
125 * applications node (the `appsNodeKey` return in getIdentityKeyPair())
126 * @param {String} salt - a string, used to salt the
127 * application-specific addresses
128 * @param {String} appDomain - the appDomain to generate a key for
129 * @return {String} the private key hex-string. this will be a 64
130 * character string
131 */
132 static getAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string;
133 /**
134 * Get the keypair information for a given identity index. This
135 * information is used to obtain the private key for an identity address
136 * and derive application specific keys for that address.
137 * @param {number} addressIndex - the identity index
138 * @param {boolean} alwaysUncompressed - if true, always return a
139 * private-key hex string corresponding to the uncompressed address
140 * @return {Object} an IdentityKeyPair type object with keys:
141 * .key {String} - the private key hex-string
142 * .keyID {String} - the public key hex-string
143 * .address {String} - the identity address
144 * .appsNodeKey {String} - the base-58 encoding of the applications node
145 * .salt {String} - the salt used for creating app-specific addresses
146 */
147 getIdentityKeyPair(addressIndex: number, alwaysUncompressed?: boolean): IdentityKeyPair;
148}