restore static method

Future<Wallet> restore(
  1. String keystore, {
  2. required WalletConfig config,
})

restore recovers a wallet from wallet JSON and wallet config. The password in config must match the password used to create the wallet

Implementation

static Future<Wallet> restore(String keystore,
    {required WalletConfig config}) async {
  try {
    final Map data = await _methodChannel.invokeMethod('restore', {
      'keystore': keystore,
      'password': config.password,
      'seedRpc': config.seedRPCServerAddr?.isNotEmpty == true
          ? config.seedRPCServerAddr
          : [DEFAULT_SEED_RPC_SERVER],
    });
    Wallet wallet = Wallet(walletConfig: config);
    wallet.keystore = data['keystore'];
    wallet.address = data['address'];
    wallet.seed = data['seed'];
    wallet.publicKey = data['publicKey'];
    return wallet;
  } catch (e) {
    rethrow;
  }
}