Skip to content

Commit 076fd92

Browse files
committed
prevent opening of already opened xmr/wow/sal wallets
1 parent 3e137fd commit 076fd92

9 files changed

+41
-7
lines changed

lib/wallets/wallet/intermediate/lib_monero_wallet.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import '../../../utilities/enums/fee_rate_type_enum.dart';
3535
import '../../../utilities/logger.dart';
3636
import '../../../utilities/stack_file_system.dart';
3737
import '../../../wl_gen/interfaces/cs_monero_interface.dart';
38-
import '../../../wl_gen/interfaces/cs_salvium_interface.dart';
38+
import '../../../wl_gen/interfaces/cs_salvium_interface.dart'
39+
show WrappedWallet;
3940
import '../../crypto_currency/intermediate/cryptonote_currency.dart';
4041
import '../../isar/models/wallet_info.dart';
4142
import '../../models/tx_data.dart';
@@ -368,10 +369,14 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
368369
key: Wallet.mnemonicPassphraseKey(walletId: walletId),
369370
value: "",
370371
);
372+
373+
this.wallet = wallet;
374+
await updateNode();
375+
await csMonero.close(wallet, save: true);
376+
this.wallet = null;
371377
} catch (e, s) {
372378
Logging.instance.f("", error: e, stackTrace: s);
373379
}
374-
await updateNode();
375380
}
376381

377382
return super.init();

lib/wallets/wallet/intermediate/lib_salvium_wallet.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import '../../../utilities/amount/amount.dart';
3232
import '../../../utilities/enums/fee_rate_type_enum.dart';
3333
import '../../../utilities/logger.dart';
3434
import '../../../utilities/stack_file_system.dart';
35-
import '../../../wl_gen/interfaces/cs_monero_interface.dart';
35+
import '../../../wl_gen/interfaces/cs_monero_interface.dart'
36+
show CsWalletListener, CsOutput, CsRecipient, CsPendingTransaction;
3637
import '../../../wl_gen/interfaces/cs_salvium_interface.dart';
3738
import '../../crypto_currency/intermediate/cryptonote_currency.dart';
3839
import '../../isar/models/wallet_info.dart';
@@ -349,10 +350,14 @@ abstract class LibSalviumWallet<T extends CryptonoteCurrency>
349350
key: Wallet.mnemonicPassphraseKey(walletId: walletId),
350351
value: "",
351352
);
353+
354+
this.wallet = wallet;
355+
await updateNode();
356+
await csSalvium.close(wallet, save: true);
357+
this.wallet = null;
352358
} catch (e, s) {
353359
Logging.instance.f("", error: e, stackTrace: s);
354360
}
355-
await updateNode();
356361
}
357362

358363
return super.init();

lib/wallets/wallet/intermediate/lib_wownero_wallet.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ import '../../../utilities/amount/amount.dart';
3434
import '../../../utilities/enums/fee_rate_type_enum.dart';
3535
import '../../../utilities/logger.dart';
3636
import '../../../utilities/stack_file_system.dart';
37-
import '../../../wl_gen/interfaces/cs_monero_interface.dart';
38-
import '../../../wl_gen/interfaces/cs_salvium_interface.dart';
37+
import '../../../wl_gen/interfaces/cs_monero_interface.dart'
38+
show CsWalletListener, CsOutput, CsRecipient, CsPendingTransaction;
39+
import '../../../wl_gen/interfaces/cs_salvium_interface.dart'
40+
show WrappedWallet;
3941
import '../../../wl_gen/interfaces/cs_wownero_interface.dart';
4042
import '../../crypto_currency/intermediate/cryptonote_currency.dart';
4143
import '../../isar/models/wallet_info.dart';
@@ -372,10 +374,14 @@ abstract class LibWowneroWallet<T extends CryptonoteCurrency>
372374
key: Wallet.mnemonicPassphraseKey(walletId: walletId),
373375
value: "",
374376
);
377+
378+
this.wallet = wallet;
379+
await updateNode();
380+
await csWownero.close(wallet, save: true);
381+
this.wallet = null;
375382
} catch (e, s) {
376383
Logging.instance.f("", error: e, stackTrace: s);
377384
}
378-
await updateNode();
379385
}
380386

381387
return super.init();

lib/wl_gen/interfaces/cs_monero_interface.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ abstract class CsMoneroInterface {
155155
bool validateAddress(String address, int network);
156156

157157
String getSeed(WrappedWallet wallet);
158+
159+
Future<void> close(WrappedWallet wallet, {bool save = false});
158160
}
159161

160162
// forwarding class

lib/wl_gen/interfaces/cs_salvium_interface.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ abstract class CsSalviumInterface {
169169
bool validateAddress(String address, int network);
170170

171171
String getSeed(WrappedWallet wallet);
172+
173+
Future<void> close(WrappedWallet wallet, {bool save = false});
172174
}
173175

174176
// lol...

lib/wl_gen/interfaces/cs_wownero_interface.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,6 @@ abstract class CsWowneroInterface {
156156
bool validateAddress(String address, int network);
157157

158158
String getSeed(WrappedWallet wallet);
159+
160+
Future<void> close(WrappedWallet wallet, {bool save = false});
159161
}

tool/wl_templates/SAL_cs_salvium_interface_impl.template.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ class _CsSalviumInterfaceImpl extends CsSalviumInterface {
555555

556556
@override
557557
String getSeed(WrappedWallet wallet) => wallet.actual.getSeed();
558+
559+
@override
560+
Future<void> close(WrappedWallet wallet, {bool save = false}) =>
561+
wallet.actual.close(save: save);
558562
}
559563

560564
//END_ON

tool/wl_templates/WOW_cs_wownero_interface_impl.template.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ class _CsWowneroInterfaceImpl extends CsWowneroInterface {
505505
@override
506506
String getSeed(WrappedWallet wallet) =>
507507
wallet.get<lib_wownero.Wallet>().getSeed();
508+
509+
@override
510+
Future<void> close(WrappedWallet wallet, {bool save = false}) =>
511+
wallet.get<lib_wownero.Wallet>().close(save: save);
508512
}
509513

510514
//END_ON

tool/wl_templates/XMR_cs_monero_interface_impl.template.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ class _CsMoneroInterfaceImpl extends CsMoneroInterface {
498498
@override
499499
String getSeed(WrappedWallet wallet) =>
500500
wallet.get<lib_monero.Wallet>().getSeed();
501+
502+
@override
503+
Future<void> close(WrappedWallet wallet, {bool save = false}) =>
504+
wallet.get<lib_monero.Wallet>().close(save: save);
501505
}
502506

503507
//END_ON

0 commit comments

Comments
 (0)