2022-09-05 23:57:11 +03:00
|
|
|
import { SigningKey } from "../crypto/index.js";
|
|
|
|
import { BaseWallet } from "./base-wallet.js";
|
2022-11-10 12:05:51 +03:00
|
|
|
import { HDNodeWallet } from "./hdwallet.js";
|
2022-09-05 23:57:11 +03:00
|
|
|
import type { ProgressCallback } from "../crypto/index.js";
|
|
|
|
import type { Provider } from "../providers/index.js";
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* A **Wallet** manages a single private key which is used to sign
|
|
|
|
* transactions, messages and other common payloads.
|
|
|
|
*
|
|
|
|
* This class is generally the main entry point for developers
|
|
|
|
* that wish to use a private key directly, as it can create
|
|
|
|
* instances from a large variety of common sources, including
|
|
|
|
* raw private key, [[link-bip-39]] mnemonics and encrypte JSON
|
|
|
|
* wallets.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
export declare class Wallet extends BaseWallet {
|
|
|
|
#private;
|
2022-12-03 05:27:06 +03:00
|
|
|
/**
|
2023-08-15 07:58:04 +03:00
|
|
|
* Create a new wallet for the private %%key%%, optionally connected
|
2022-12-03 05:27:06 +03:00
|
|
|
* to %%provider%%.
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
constructor(key: string | SigningKey, provider?: null | Provider);
|
2022-09-05 23:57:11 +03:00
|
|
|
connect(provider: null | Provider): Wallet;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with
|
|
|
|
* %%password%%.
|
|
|
|
*
|
|
|
|
* If %%progressCallback%% is specified, it will receive periodic
|
|
|
|
* updates as the encryption process progreses.
|
|
|
|
*/
|
|
|
|
encrypt(password: Uint8Array | string, progressCallback?: ProgressCallback): Promise<string>;
|
|
|
|
/**
|
|
|
|
* Returns a [JSON Keystore Wallet](json-wallets) encryped with
|
|
|
|
* %%password%%.
|
|
|
|
*
|
|
|
|
* It is preferred to use the [async version](encrypt) instead,
|
|
|
|
* which allows a [[ProgressCallback]] to keep the user informed.
|
|
|
|
*
|
|
|
|
* This method will block the event loop (freezing all UI) until
|
|
|
|
* it is complete, which may be a non-trivial duration.
|
|
|
|
*/
|
|
|
|
encryptSync(password: Uint8Array | string): string;
|
2022-12-03 05:27:06 +03:00
|
|
|
/**
|
|
|
|
* Creates (asynchronously) a **Wallet** by decrypting the %%json%%
|
|
|
|
* with %%password%%.
|
|
|
|
*
|
|
|
|
* If %%progress%% is provided, it is called periodically during
|
|
|
|
* decryption so that any UI can be updated.
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
static fromEncryptedJson(json: string, password: Uint8Array | string, progress?: ProgressCallback): Promise<HDNodeWallet | Wallet>;
|
2022-12-03 05:27:06 +03:00
|
|
|
/**
|
|
|
|
* Creates a **Wallet** by decrypting the %%json%% with %%password%%.
|
|
|
|
*
|
|
|
|
* The [[fromEncryptedJson]] method is preferred, as this method
|
|
|
|
* will lock up and freeze the UI during decryption, which may take
|
|
|
|
* some time.
|
|
|
|
*/
|
2022-11-30 23:44:23 +03:00
|
|
|
static fromEncryptedJsonSync(json: string, password: Uint8Array | string): HDNodeWallet | Wallet;
|
2022-12-03 05:27:06 +03:00
|
|
|
/**
|
2023-11-12 02:00:39 +03:00
|
|
|
* Creates a new random [[HDNodeWallet]] using the available
|
2022-12-03 05:27:06 +03:00
|
|
|
* [cryptographic random source](randomBytes).
|
|
|
|
*
|
|
|
|
* If there is no crytographic random source, this will throw.
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
static createRandom(provider?: null | Provider): HDNodeWallet;
|
2022-12-03 05:27:06 +03:00
|
|
|
/**
|
|
|
|
* Creates a [[HDNodeWallet]] for %%phrase%%.
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
static fromPhrase(phrase: string, provider?: Provider): HDNodeWallet;
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
//# sourceMappingURL=wallet.d.ts.map
|