Cw 528 backup wallet files (#1281)

* monero wallet backup changes

* [skipci] updates

* monero fixes

* start work for bitcoin/eth

* cleanup

* [skipci] more cleanup

* add all other coins

* merge fixes

* add corrupted test

* build for testing

* actually be able to test monero

* review fixes

* more review fixes
This commit is contained in:
Matthew Fosse 2024-02-07 07:44:29 -08:00 committed by GitHub
parent e4ddf82e69
commit 26fe28891d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 264 additions and 117 deletions

View file

@ -51,11 +51,22 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
Future<BitcoinCashWallet> openWallet(String name, String password) async {
final walletInfo = walletInfoSource.values.firstWhereOrNull(
(info) => info.id == WalletBase.idFor(name, getType()))!;
final wallet = await BitcoinCashWalletBase.open(
password: password, name: name, walletInfo: walletInfo,
unspentCoinsInfo: unspentCoinsInfoSource);
await wallet.init();
return wallet;
try {
final wallet = await BitcoinCashWalletBase.open(
password: password, name: name, walletInfo: walletInfo,
unspentCoinsInfo: unspentCoinsInfoSource);
await wallet.init();
saveBackup(name);
return wallet;
} catch(_) {
await restoreWalletFilesFromBackup(name);
final wallet = await BitcoinCashWalletBase.open(
password: password, name: name, walletInfo: walletInfo,
unspentCoinsInfo: unspentCoinsInfoSource);
await wallet.init();
return wallet;
}
}
@override
@ -78,6 +89,7 @@ class BitcoinCashWalletService extends WalletService<BitcoinCashNewWalletCredent
unspentCoinsInfo: unspentCoinsInfoSource);
await currentWallet.renameWalletFiles(newName);
await saveBackup(newName);
final newWalletInfo = currentWalletInfo;
newWalletInfo.id = WalletBase.idFor(newName, getType());