1 | /**
|
2 | * Explain HD Wallets..
|
3 | *
|
4 | * @_subsection: api/wallet:HD Wallets [hd-wallets]
|
5 | */
|
6 | import { SigningKey } from "../crypto/index.js";
|
7 | import { VoidSigner } from "../providers/index.js";
|
8 | import { BaseWallet } from "./base-wallet.js";
|
9 | import { Mnemonic } from "./mnemonic.js";
|
10 | import type { ProgressCallback } from "../crypto/index.js";
|
11 | import type { Provider } from "../providers/index.js";
|
12 | import type { BytesLike, Numeric } from "../utils/index.js";
|
13 | import type { Wordlist } from "../wordlists/index.js";
|
14 | /**
|
15 | * The default derivation path for Ethereum HD Nodes. (i.e. ``"m/44'/60'/0'/0/0"``)
|
16 | */
|
17 | export declare const defaultPath: string;
|
18 | /**
|
19 | * An **HDNodeWallet** is a [[Signer]] backed by the private key derived
|
20 | * from an HD Node using the [[link-bip-32]] stantard.
|
21 | *
|
22 | * An HD Node forms a hierarchal structure with each HD Node having a
|
23 | * private key and the ability to derive child HD Nodes, defined by
|
24 | * a path indicating the index of each child.
|
25 | */
|
26 | export declare class HDNodeWallet extends BaseWallet {
|
27 | #private;
|
28 | /**
|
29 | * The compressed public key.
|
30 | */
|
31 | readonly publicKey: string;
|
32 | /**
|
33 | * The fingerprint.
|
34 | *
|
35 | * A fingerprint allows quick qay to detect parent and child nodes,
|
36 | * but developers should be prepared to deal with collisions as it
|
37 | * is only 4 bytes.
|
38 | */
|
39 | readonly fingerprint: string;
|
40 | /**
|
41 | * The parent fingerprint.
|
42 | */
|
43 | readonly parentFingerprint: string;
|
44 | /**
|
45 | * The mnemonic used to create this HD Node, if available.
|
46 | *
|
47 | * Sources such as extended keys do not encode the mnemonic, in
|
48 | * which case this will be ``null``.
|
49 | */
|
50 | readonly mnemonic: null | Mnemonic;
|
51 | /**
|
52 | * The chaincode, which is effectively a public key used
|
53 | * to derive children.
|
54 | */
|
55 | readonly chainCode: string;
|
56 | /**
|
57 | * The derivation path of this wallet.
|
58 | *
|
59 | * Since extended keys do not provide full path details, this
|
60 | * may be ``null``, if instantiated from a source that does not
|
61 | * encode it.
|
62 | */
|
63 | readonly path: null | string;
|
64 | /**
|
65 | * The child index of this wallet. Values over ``2 *\* 31`` indicate
|
66 | * the node is hardened.
|
67 | */
|
68 | readonly index: number;
|
69 | /**
|
70 | * The depth of this wallet, which is the number of components
|
71 | * in its path.
|
72 | */
|
73 | readonly depth: number;
|
74 | /**
|
75 | * @private
|
76 | */
|
77 | constructor(guard: any, signingKey: SigningKey, parentFingerprint: string, chainCode: string, path: null | string, index: number, depth: number, mnemonic: null | Mnemonic, provider: null | Provider);
|
78 | connect(provider: null | Provider): HDNodeWallet;
|
79 | /**
|
80 | * Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with
|
81 | * %%password%%.
|
82 | *
|
83 | * If %%progressCallback%% is specified, it will receive periodic
|
84 | * updates as the encryption process progreses.
|
85 | */
|
86 | encrypt(password: Uint8Array | string, progressCallback?: ProgressCallback): Promise<string>;
|
87 | /**
|
88 | * Returns a [JSON Keystore Wallet](json-wallets) encryped with
|
89 | * %%password%%.
|
90 | *
|
91 | * It is preferred to use the [async version](encrypt) instead,
|
92 | * which allows a [[ProgressCallback]] to keep the user informed.
|
93 | *
|
94 | * This method will block the event loop (freezing all UI) until
|
95 | * it is complete, which may be a non-trivial duration.
|
96 | */
|
97 | encryptSync(password: Uint8Array | string): string;
|
98 | /**
|
99 | * The extended key.
|
100 | *
|
101 | * This key will begin with the prefix ``xpriv`` and can be used to
|
102 | * reconstruct this HD Node to derive its children.
|
103 | */
|
104 | get extendedKey(): string;
|
105 | /**
|
106 | * Returns true if this wallet has a path, providing a Type Guard
|
107 | * that the path is non-null.
|
108 | */
|
109 | hasPath(): this is {
|
110 | path: string;
|
111 | };
|
112 | /**
|
113 | * Returns a neutered HD Node, which removes the private details
|
114 | * of an HD Node.
|
115 | *
|
116 | * A neutered node has no private key, but can be used to derive
|
117 | * child addresses and other public data about the HD Node.
|
118 | */
|
119 | neuter(): HDNodeVoidWallet;
|
120 | /**
|
121 | * Return the child for %%index%%.
|
122 | */
|
123 | deriveChild(_index: Numeric): HDNodeWallet;
|
124 | /**
|
125 | * Return the HDNode for %%path%% from this node.
|
126 | */
|
127 | derivePath(path: string): HDNodeWallet;
|
128 | /**
|
129 | * Creates a new HD Node from %%extendedKey%%.
|
130 | *
|
131 | * If the %%extendedKey%% will either have a prefix or ``xpub`` or
|
132 | * ``xpriv``, returning a neutered HD Node ([[HDNodeVoidWallet]])
|
133 | * or full HD Node ([[HDNodeWallet) respectively.
|
134 | */
|
135 | static fromExtendedKey(extendedKey: string): HDNodeWallet | HDNodeVoidWallet;
|
136 | /**
|
137 | * Creates a new random HDNode.
|
138 | */
|
139 | static createRandom(password?: string, path?: string, wordlist?: Wordlist): HDNodeWallet;
|
140 | /**
|
141 | * Create an HD Node from %%mnemonic%%.
|
142 | */
|
143 | static fromMnemonic(mnemonic: Mnemonic, path?: string): HDNodeWallet;
|
144 | /**
|
145 | * Creates an HD Node from a mnemonic %%phrase%%.
|
146 | */
|
147 | static fromPhrase(phrase: string, password?: string, path?: string, wordlist?: Wordlist): HDNodeWallet;
|
148 | /**
|
149 | * Creates an HD Node from a %%seed%%.
|
150 | */
|
151 | static fromSeed(seed: BytesLike): HDNodeWallet;
|
152 | }
|
153 | /**
|
154 | * A **HDNodeVoidWallet** cannot sign, but provides access to
|
155 | * the children nodes of a [[link-bip-32]] HD wallet addresses.
|
156 | *
|
157 | * The can be created by using an extended ``xpub`` key to
|
158 | * [[HDNodeWallet_fromExtendedKey]] or by
|
159 | * [nuetering](HDNodeWallet-neuter) a [[HDNodeWallet]].
|
160 | */
|
161 | export declare class HDNodeVoidWallet extends VoidSigner {
|
162 | /**
|
163 | * The compressed public key.
|
164 | */
|
165 | readonly publicKey: string;
|
166 | /**
|
167 | * The fingerprint.
|
168 | *
|
169 | * A fingerprint allows quick qay to detect parent and child nodes,
|
170 | * but developers should be prepared to deal with collisions as it
|
171 | * is only 4 bytes.
|
172 | */
|
173 | readonly fingerprint: string;
|
174 | /**
|
175 | * The parent node fingerprint.
|
176 | */
|
177 | readonly parentFingerprint: string;
|
178 | /**
|
179 | * The chaincode, which is effectively a public key used
|
180 | * to derive children.
|
181 | */
|
182 | readonly chainCode: string;
|
183 | /**
|
184 | * The derivation path of this wallet.
|
185 | *
|
186 | * Since extended keys do not provider full path details, this
|
187 | * may be ``null``, if instantiated from a source that does not
|
188 | * enocde it.
|
189 | */
|
190 | readonly path: null | string;
|
191 | /**
|
192 | * The child index of this wallet. Values over ``2 *\* 31`` indicate
|
193 | * the node is hardened.
|
194 | */
|
195 | readonly index: number;
|
196 | /**
|
197 | * The depth of this wallet, which is the number of components
|
198 | * in its path.
|
199 | */
|
200 | readonly depth: number;
|
201 | /**
|
202 | * @private
|
203 | */
|
204 | constructor(guard: any, address: string, publicKey: string, parentFingerprint: string, chainCode: string, path: null | string, index: number, depth: number, provider: null | Provider);
|
205 | connect(provider: null | Provider): HDNodeVoidWallet;
|
206 | /**
|
207 | * The extended key.
|
208 | *
|
209 | * This key will begin with the prefix ``xpub`` and can be used to
|
210 | * reconstruct this neutered key to derive its children addresses.
|
211 | */
|
212 | get extendedKey(): string;
|
213 | /**
|
214 | * Returns true if this wallet has a path, providing a Type Guard
|
215 | * that the path is non-null.
|
216 | */
|
217 | hasPath(): this is {
|
218 | path: string;
|
219 | };
|
220 | /**
|
221 | * Return the child for %%index%%.
|
222 | */
|
223 | deriveChild(_index: Numeric): HDNodeVoidWallet;
|
224 | /**
|
225 | * Return the signer for %%path%% from this node.
|
226 | */
|
227 | derivePath(path: string): HDNodeVoidWallet;
|
228 | }
|
229 | /**
|
230 | * Returns the [[link-bip-32]] path for the account at %%index%%.
|
231 | *
|
232 | * This is the pattern used by wallets like Ledger.
|
233 | *
|
234 | * There is also an [alternate pattern](getIndexedAccountPath) used by
|
235 | * some software.
|
236 | */
|
237 | export declare function getAccountPath(_index: Numeric): string;
|
238 | /**
|
239 | * Returns the path using an alternative pattern for deriving accounts,
|
240 | * at %%index%%.
|
241 | *
|
242 | * This derivation path uses the //index// component rather than the
|
243 | * //account// component to derive sequential accounts.
|
244 | *
|
245 | * This is the pattern used by wallets like MetaMask.
|
246 | */
|
247 | export declare function getIndexedAccountPath(_index: Numeric): string;
|
248 | //# sourceMappingURL=hdwallet.d.ts.map |
\ | No newline at end of file |