Fix errors from seed restore not being shown to user properly (#2019)

This commit is contained in:
cyan 2025-02-12 12:41:35 +01:00 committed by GitHub
parent 92fc6a4a60
commit 637bc1cdc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View file

@ -100,7 +100,7 @@ void restoreWalletFromSeedSync(
required String passphrase, required String passphrase,
required String seed, required String seed,
int nettype = 0, int nettype = 0,
int restoreHeight = 0}) async { int restoreHeight = 0}) {
txhistory = null; txhistory = null;
final newWptr = monero.WalletManager_recoveryWallet( final newWptr = monero.WalletManager_recoveryWallet(
wmPtr, wmPtr,
@ -404,7 +404,7 @@ void _restoreFromSeed(Map<String, dynamic> args) {
final seed = args['seed'] as String; final seed = args['seed'] as String;
final restoreHeight = args['restoreHeight'] as int; final restoreHeight = args['restoreHeight'] as int;
restoreWalletFromSeedSync( return restoreWalletFromSeedSync(
path: path, password: password, passphrase: passphrase, seed: seed, restoreHeight: restoreHeight); path: path, password: password, passphrase: passphrase, seed: seed, restoreHeight: restoreHeight);
} }
@ -472,13 +472,13 @@ Future<void> createWallet(
'nettype': nettype 'nettype': nettype
}); });
Future<void> restoreFromSeed( void restoreFromSeed(
{required String path, {required String path,
required String password, required String password,
required String passphrase, required String passphrase,
required String seed, required String seed,
int nettype = 0, int nettype = 0,
int restoreHeight = 0}) async => int restoreHeight = 0}) =>
_restoreFromSeed({ _restoreFromSeed({
'path': path, 'path': path,
'password': password, 'password': password,

View file

@ -292,14 +292,21 @@ class MoneroWalletService extends WalletService<
Future<MoneroWallet> restoreFromSeed( Future<MoneroWallet> restoreFromSeed(
MoneroRestoreWalletFromSeedCredentials credentials, MoneroRestoreWalletFromSeedCredentials credentials,
{bool? isTestnet}) async { {bool? isTestnet}) async {
// Restore from Polyseed if (credentials.mnemonic.split(" ").length == 16) {
if (Polyseed.isValidSeed(credentials.mnemonic)) { // Restore from Polyseed
return restoreFromPolyseed(credentials); try {
if (Polyseed.isValidSeed(credentials.mnemonic)) {
return restoreFromPolyseed(credentials);
}
} catch (e) {
printV("Polyseed restore failed: $e");
rethrow;
}
} }
try { try {
final path = await pathForWallet(name: credentials.name, type: getType()); final path = await pathForWallet(name: credentials.name, type: getType());
await monero_wallet_manager.restoreFromSeed( monero_wallet_manager.restoreFromSeed(
path: path, path: path,
password: credentials.password!, password: credentials.password!,
passphrase: credentials.passphrase, passphrase: credentials.passphrase,