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

View file

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