mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
add guard Lightning usage with isInitialized check (#3128)
This commit is contained in:
@@ -164,6 +164,8 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isLightningInitialized => lightningWallet?.isInitialized == true;
|
||||
|
||||
@override
|
||||
bool get hasRescan => true;
|
||||
|
||||
@@ -339,7 +341,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||
@override
|
||||
Future<ElectrumBalance> fetchBalances() async {
|
||||
final balance = await super.fetchBalances();
|
||||
if (lightningWallet == null) {
|
||||
if (!isLightningInitialized || lightningWallet == null) {
|
||||
return balance;
|
||||
}
|
||||
|
||||
@@ -358,7 +360,7 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
||||
@override
|
||||
@action
|
||||
Future<void> subscribeForUpdates() async {
|
||||
if (lightningWallet != null) {
|
||||
if (isLightningInitialized && lightningWallet != null) {
|
||||
lightningWallet!.setEventListener(
|
||||
onTransactionEvent: (tx) async {
|
||||
if (transactionHistory.transactions[tx.id]?.isPending != tx.isPending) {
|
||||
|
||||
@@ -41,6 +41,8 @@ class LightningWallet {
|
||||
|
||||
StreamSubscription<LogEntry>? _logSubscription;
|
||||
|
||||
bool get isInitialized => _eventStream != null;
|
||||
|
||||
void _subscribeToLogStream(File logFile) {
|
||||
_logSubscription = _logStream?.listen((logEntry) {
|
||||
logFile.writeAsStringSync("[${logEntry.level}] ${logEntry.line}\n", mode: FileMode.append);
|
||||
|
||||
Reference in New Issue
Block a user