BIP32HWallet.fromSecretStorage constructor
Factory constructor to create a BIP32 hierarchical wallet from secret storage.
encryptedWallet
is the encrypted wallet data.
password
is the password used to decrypt the wallet.
Implementation
factory BIP32HWallet.fromSecretStorage(
String encryptedWallet, String password) {
try {
final secret = SecretWallet.decode(encryptedWallet, password);
final toJson = json.decode(secret.credentials);
final CurrencySymbol symbol = CurrencySymbol.fromName(toJson["currency"]);
if (toJson["xprv"] != null) {
return BIP32HWallet.fromXPrivateKey(toJson["xprv"],
currencySymbol: symbol);
}
return BIP32HWallet.fromXpublicKey(toJson["xpub"],
currencySymbol: symbol);
} catch (e) {
throw ArgumentError("Invalid BIP32 Secret wallet");
}
}