2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* The JSON Wallet formats allow a simple way to store the private
|
|
|
|
* keys needed in Ethereum along with related information and allows
|
|
|
|
* for extensible forms of encryption.
|
|
|
|
*
|
|
|
|
* These utilities facilitate decrypting and encrypting the most common
|
|
|
|
* JSON Wallet formats.
|
|
|
|
*
|
|
|
|
* @_subsection: api/wallet:JSON Wallets [json-wallets]
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
import type { ProgressCallback } from "../crypto/index.js";
|
|
|
|
import type { BytesLike } from "../utils/index.js";
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* The contents of a JSON Keystore Wallet.
|
|
|
|
*/
|
2023-02-02 12:05:47 +03:00
|
|
|
export type KeystoreAccount = {
|
2022-09-05 23:57:11 +03:00
|
|
|
address: string;
|
|
|
|
privateKey: string;
|
|
|
|
mnemonic?: {
|
2022-11-10 12:05:51 +03:00
|
|
|
path?: string;
|
|
|
|
locale?: string;
|
2022-09-05 23:57:11 +03:00
|
|
|
entropy: string;
|
|
|
|
};
|
|
|
|
};
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* The parameters to use when encrypting a JSON Keystore Wallet.
|
|
|
|
*/
|
2023-02-02 12:05:47 +03:00
|
|
|
export type EncryptOptions = {
|
2022-11-10 12:05:51 +03:00
|
|
|
progressCallback?: ProgressCallback;
|
2022-09-05 23:57:11 +03:00
|
|
|
iv?: BytesLike;
|
|
|
|
entropy?: BytesLike;
|
|
|
|
client?: string;
|
|
|
|
salt?: BytesLike;
|
|
|
|
uuid?: string;
|
|
|
|
scrypt?: {
|
|
|
|
N?: number;
|
|
|
|
r?: number;
|
|
|
|
p?: number;
|
|
|
|
};
|
|
|
|
};
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Returns true if %%json%% is a valid JSON Keystore Wallet.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
export declare function isKeystoreJson(json: string): boolean;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Returns the account details for the JSON Keystore Wallet %%json%%
|
|
|
|
* using %%password%%.
|
|
|
|
*
|
|
|
|
* It is preferred to use the [async version](decryptKeystoreJson)
|
|
|
|
* instead, which allows a [[ProgressCallback]] to keep the user informed
|
|
|
|
* as to the decryption status.
|
|
|
|
*
|
|
|
|
* This method will block the event loop (freezing all UI) until decryption
|
|
|
|
* is complete, which can take quite some time, depending on the wallet
|
|
|
|
* paramters and platform.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
export declare function decryptKeystoreJsonSync(json: string, _password: string | Uint8Array): KeystoreAccount;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Resolves to the decrypted JSON Keystore Wallet %%json%% using the
|
|
|
|
* %%password%%.
|
|
|
|
*
|
|
|
|
* If provided, %%progress%% will be called periodically during the
|
|
|
|
* decrpytion to provide feedback, and if the function returns
|
|
|
|
* ``false`` will halt decryption.
|
|
|
|
*
|
|
|
|
* The %%progressCallback%% will **always** receive ``0`` before
|
|
|
|
* decryption begins and ``1`` when complete.
|
|
|
|
*/
|
2022-09-05 23:57:11 +03:00
|
|
|
export declare function decryptKeystoreJson(json: string, _password: string | Uint8Array, progress?: ProgressCallback): Promise<KeystoreAccount>;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Return the JSON Keystore Wallet for %%account%% encrypted with
|
|
|
|
* %%password%%.
|
|
|
|
*
|
|
|
|
* The %%options%% can be used to tune the password-based key
|
|
|
|
* derivation function parameters, explicitly set the random values
|
|
|
|
* used. Any provided [[ProgressCallback]] is ignord.
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
export declare function encryptKeystoreJsonSync(account: KeystoreAccount, password: string | Uint8Array, options?: EncryptOptions): string;
|
2022-11-30 23:44:23 +03:00
|
|
|
/**
|
|
|
|
* Resolved to the JSON Keystore Wallet for %%account%% encrypted
|
|
|
|
* with %%password%%.
|
|
|
|
*
|
|
|
|
* The %%options%% can be used to tune the password-based key
|
|
|
|
* derivation function parameters, explicitly set the random values
|
|
|
|
* used and provide a [[ProgressCallback]] to receive periodic updates
|
|
|
|
* on the completion status..
|
|
|
|
*/
|
2022-11-10 12:05:51 +03:00
|
|
|
export declare function encryptKeystoreJson(account: KeystoreAccount, password: string | Uint8Array, options?: EncryptOptions): Promise<string>;
|
2022-09-05 23:57:11 +03:00
|
|
|
//# sourceMappingURL=json-keystore.d.ts.map
|