mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 09:29:48 +00:00
breez fixes
This commit is contained in:
parent
9459b74f94
commit
362c0bd231
10 changed files with 20 additions and 14 deletions
|
@ -831,7 +831,7 @@ abstract class ElectrumWalletBase
|
||||||
Future<void> rescan({required int height}) async => throw UnimplementedError();
|
Future<void> rescan({required int height}) async => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close({bool? switchingToSameWalletType}) async {
|
||||||
try {
|
try {
|
||||||
await electrumClient.close();
|
await electrumClient.close();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
|
@ -80,7 +80,7 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
||||||
|
|
||||||
Future<void> rescan({required int height});
|
Future<void> rescan({required int height});
|
||||||
|
|
||||||
void close();
|
void close({bool? switchingToSameWalletType});
|
||||||
|
|
||||||
Future<void> changePassword(String password);
|
Future<void> changePassword(String password);
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ abstract class EVMChainWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void close() {
|
void close({bool? switchingToSameWalletType}) {
|
||||||
_client.stop();
|
_client.stop();
|
||||||
_transactionsUpdateTimer?.cancel();
|
_transactionsUpdateTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,10 +233,12 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
|
||||||
print("initialized breez: ${(await sdk.isInitialized())}");
|
print("initialized breez: ${(await sdk.isInitialized())}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stopBreez() async {
|
Future<void> stopBreez(bool disconnect) async {
|
||||||
final sdk = await BreezSDK();
|
if (disconnect) {
|
||||||
if (await sdk.isInitialized()) {
|
final sdk = await BreezSDK();
|
||||||
await sdk.disconnect();
|
if (await sdk.isInitialized()) {
|
||||||
|
await sdk.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await _nodeStateSub?.cancel();
|
await _nodeStateSub?.cancel();
|
||||||
await _paymentsSub?.cancel();
|
await _paymentsSub?.cancel();
|
||||||
|
@ -363,12 +365,13 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
|
||||||
Future<String> makePath() async => pathForWallet(name: walletInfo.name, type: walletInfo.type);
|
Future<String> makePath() async => pathForWallet(name: walletInfo.name, type: walletInfo.type);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close({bool? switchingToSameWalletType}) async {
|
||||||
try {
|
try {
|
||||||
await electrumClient.close();
|
await electrumClient.close();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
try {
|
try {
|
||||||
await stopBreez();
|
bool shouldDisconnect = switchingToSameWalletType == null || !switchingToSameWalletType;
|
||||||
|
await stopBreez(shouldDisconnect);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print("Error stopping breez: $e\n$s");
|
print("Error stopping breez: $e\n$s");
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ abstract class MoneroWalletBase
|
||||||
Future<void>? updateBalance() => null;
|
Future<void>? updateBalance() => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void close() {
|
void close({bool? switchingToSameWalletType}) {
|
||||||
_listener?.stop();
|
_listener?.stop();
|
||||||
_onAccountChangeReaction?.reaction.dispose();
|
_onAccountChangeReaction?.reaction.dispose();
|
||||||
_autoSaveTimer?.cancel();
|
_autoSaveTimer?.cancel();
|
||||||
|
|
|
@ -138,7 +138,7 @@ abstract class NanoWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void close() {
|
void close({bool? switchingToSameWalletType}) {
|
||||||
_client.stop();
|
_client.stop();
|
||||||
_receiveTimer?.cancel();
|
_receiveTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ abstract class SolanaWalletBase
|
||||||
Future<void> changePassword(String password) => throw UnimplementedError("changePassword");
|
Future<void> changePassword(String password) => throw UnimplementedError("changePassword");
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void close() {
|
void close({bool? switchingToSameWalletType}) {
|
||||||
_client.stop();
|
_client.stop();
|
||||||
_transactionsUpdateTimer?.cancel();
|
_transactionsUpdateTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ abstract class TronWalletBase
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void close() {
|
void close({bool? switchingToSameWalletType}) {
|
||||||
_transactionsUpdateTimer?.cancel();
|
_transactionsUpdateTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ class WalletCreationService {
|
||||||
case WalletType.solana:
|
case WalletType.solana:
|
||||||
case WalletType.tron:
|
case WalletType.tron:
|
||||||
return true;
|
return true;
|
||||||
|
case WalletType.lightning:
|
||||||
case WalletType.monero:
|
case WalletType.monero:
|
||||||
case WalletType.none:
|
case WalletType.none:
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cake_wallet/di.dart';
|
||||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||||
import 'package:cake_wallet/utils/exception_handler.dart';
|
import 'package:cake_wallet/utils/exception_handler.dart';
|
||||||
import 'package:cw_core/transaction_info.dart';
|
import 'package:cw_core/transaction_info.dart';
|
||||||
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cw_core/balance.dart';
|
import 'package:cw_core/balance.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
|
@ -37,7 +38,8 @@ abstract class AppStoreBase with Store {
|
||||||
@action
|
@action
|
||||||
Future<void> changeCurrentWallet(
|
Future<void> changeCurrentWallet(
|
||||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet) async {
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet) async {
|
||||||
this.wallet?.close();
|
bool switchingToSameWalletType = this.wallet?.type == wallet.type;
|
||||||
|
this.wallet?.close(switchingToSameWalletType: switchingToSameWalletType);
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
this.wallet!.setExceptionHandler(ExceptionHandler.onError);
|
this.wallet!.setExceptionHandler(ExceptionHandler.onError);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue