///
///
///
import { Account } from "@ganache/ethereum-utils";
import { Data, Quantity } from "@ganache/utils";
import crypto from "crypto";
import { EthereumInternalOptions } from "@ganache/ethereum-options";
import { Address } from "@ganache/ethereum-address";
type ThenArg = T extends PromiseLike ? U : T;
type EncryptType = ThenArg>;
type MaybeEncrypted = {
encrypted: true;
key: EncryptType;
} | {
encrypted: false;
key: Buffer;
};
export default class Wallet {
#private;
readonly addresses: string[];
readonly initialAccounts: Account[];
readonly knownAccounts: Set;
readonly keyFiles: Map;
readonly unlockedAccounts: Map;
readonly lockTimers: Map;
constructor(opts: EthereumInternalOptions["wallet"], logging: EthereumInternalOptions["logging"]);
encrypt(privateKey: Data, passphrase: string): Promise<{
crypto: {
cipher: string;
ciphertext: Data;
cipherparams: {
iv: Data;
};
kdf: string;
kdfParams: {
salt: Data;
dklen: 32;
n: 1024;
p: 8;
r: 1;
};
mac: Data;
};
id: string;
version: number;
}>;
/**
* Syncronous version of the `encrypt` function.
* @param privateKey -
* @param passphrase -
*/
encryptSync(privateKey: Data, passphrase: string): {
crypto: {
cipher: string;
ciphertext: Data;
cipherparams: {
iv: Data;
};
kdf: string;
kdfParams: {
salt: Data;
dklen: 32;
n: 1024;
p: 8;
r: 1;
};
mac: Data;
};
id: string;
version: number;
};
finishEncryption(derivedKey: Buffer, privateKey: Data, salt: Buffer, iv: Buffer, uuid: Buffer): {
crypto: {
cipher: string;
ciphertext: Data;
cipherparams: {
iv: Data;
};
kdf: string;
kdfParams: {
salt: Data;
dklen: 32;
n: 1024;
p: 8;
r: 1;
};
mac: Data;
};
id: string;
version: number;
};
decrypt(keyfile: EncryptType, passphrase: crypto.BinaryLike): Promise;
/**
* Stores a mapping of addresses to either encrypted (if a passphrase is used
* or the user specified --lock option) or unencrypted private keys.
* @param address - The address whose private key is being stored.
* @param privateKey - The passphrase to store.
* @param passphrase - The passphrase to use to encrypt the private key. If
* passphrase is empty, the private key will not be encrypted.
* @param lock - Flag to specify that accounts should be encrypted regardless
* of if the passphrase is empty.
*/
addToKeyFile(address: Address, privateKey: Data, passphrase: string, lock: boolean): Promise;
/**
* Synchronus version of `addToKeyFile`.
* Stores a mapping of addresses to either encrypted (if a passphrase is used
* or the user specified --lock option) or unencrypted private keys.
* @param address - The address whose private key is being stored.
* @param privateKey - The passphrase to store.
* @param passphrase - The passphrase to use to encrypt the private key. If
* passphrase is empty, the private key will not be encrypted.
* @param lock - Flag to specify that accounts should be encrypted regardless
* of if the passphrase is empty.
*/
addToKeyFileSync(address: Address, privateKey: Data, passphrase: string, lock: boolean): void;
/**
* Fetches the private key for a specific address. If the keyFile is encrypted
* for the address, the passphrase is used to decrypt.
* @param address - The address whose private key is to be fetched.
* @param passphrase - The passphrase used to decrypt the private key.
*/
getFromKeyFile(address: Address, passphrase: string): Promise;
static createAccount(balance: Quantity, privateKey: Data, address: Address): Account;
static createAccountFromPrivateKey(privateKey: Data): Account;
createRandomAccount(): Account;
unlockAccount(address: Address, passphrase: string, duration: number): Promise;
addUnknownAccount(address: Address, passphrase: string): Promise;
removeKnownAccount(address: Address, passphrase: string): Promise;
createFakePrivateKey(address: string): Data;
lockAccount(lowerAddress: string): boolean;
}
export {};
//# sourceMappingURL=wallet.d.ts.map