UNPKG

2.94 kBTypeScriptView Raw
1import { SigningKey } from "../crypto/index.js";
2import { BaseWallet } from "./base-wallet.js";
3import { HDNodeWallet } from "./hdwallet.js";
4import type { ProgressCallback } from "../crypto/index.js";
5import type { Provider } from "../providers/index.js";
6/**
7 * A **Wallet** manages a single private key which is used to sign
8 * transactions, messages and other common payloads.
9 *
10 * This class is generally the main entry point for developers
11 * that wish to use a private key directly, as it can create
12 * instances from a large variety of common sources, including
13 * raw private key, [[link-bip-39]] mnemonics and encrypte JSON
14 * wallets.
15 */
16export declare class Wallet extends BaseWallet {
17 #private;
18 /**
19 * Create a new wallet for the private %%key%%, optionally connected
20 * to %%provider%%.
21 */
22 constructor(key: string | SigningKey, provider?: null | Provider);
23 connect(provider: null | Provider): Wallet;
24 /**
25 * Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with
26 * %%password%%.
27 *
28 * If %%progressCallback%% is specified, it will receive periodic
29 * updates as the encryption process progreses.
30 */
31 encrypt(password: Uint8Array | string, progressCallback?: ProgressCallback): Promise<string>;
32 /**
33 * Returns a [JSON Keystore Wallet](json-wallets) encryped with
34 * %%password%%.
35 *
36 * It is preferred to use the [async version](encrypt) instead,
37 * which allows a [[ProgressCallback]] to keep the user informed.
38 *
39 * This method will block the event loop (freezing all UI) until
40 * it is complete, which may be a non-trivial duration.
41 */
42 encryptSync(password: Uint8Array | string): string;
43 /**
44 * Creates (asynchronously) a **Wallet** by decrypting the %%json%%
45 * with %%password%%.
46 *
47 * If %%progress%% is provided, it is called periodically during
48 * decryption so that any UI can be updated.
49 */
50 static fromEncryptedJson(json: string, password: Uint8Array | string, progress?: ProgressCallback): Promise<HDNodeWallet | Wallet>;
51 /**
52 * Creates a **Wallet** by decrypting the %%json%% with %%password%%.
53 *
54 * The [[fromEncryptedJson]] method is preferred, as this method
55 * will lock up and freeze the UI during decryption, which may take
56 * some time.
57 */
58 static fromEncryptedJsonSync(json: string, password: Uint8Array | string): HDNodeWallet | Wallet;
59 /**
60 * Creates a new random [[HDNodeWallet]] using the available
61 * [cryptographic random source](randomBytes).
62 *
63 * If there is no crytographic random source, this will throw.
64 */
65 static createRandom(provider?: null | Provider): HDNodeWallet;
66 /**
67 * Creates a [[HDNodeWallet]] for %%phrase%%.
68 */
69 static fromPhrase(phrase: string, provider?: Provider): HDNodeWallet;
70}
71//# sourceMappingURL=wallet.d.ts.map
\No newline at end of file