diff --git a/cw_lightning/lib/lightning_wallet.dart b/cw_lightning/lib/lightning_wallet.dart index 1c3e13fc3..b2a94724c 100644 --- a/cw_lightning/lib/lightning_wallet.dart +++ b/cw_lightning/lib/lightning_wallet.dart @@ -95,6 +95,7 @@ abstract class LightningWalletBase extends ElectrumWallet with Store { late final ObservableMap _balance; StreamSubscription>? _paymentsSub; StreamSubscription? _nodeStateSub; + StreamSubscription? _logStream; @override @computed @@ -183,8 +184,23 @@ abstract class LightningWalletBase extends ElectrumWallet with Store { await setupBreez(await Mnemonic.toSeed(mnemonic)); } + void _logSdkEntries(LogEntry entry) { + switch (entry.level) { + case "ERROR": + case "WARN": + case "INFO": + // case "DEBUG": + // case "TRACE": + print("BREEZ:${entry.level}: ${entry.line}"); + break; + } + } + Future setupBreez(Uint8List seedBytes) async { final sdk = await BreezSDK(); + _logStream?.cancel(); + _logStream = sdk.logStream.listen(_logSdkEntries); + try { if (!(await sdk.isInitialized())) { sdk.initialize(); @@ -194,10 +210,6 @@ abstract class LightningWalletBase extends ElectrumWallet with Store { return; } - // sdk.logStream.listen((LogEntry event) { - // print("Breez log: ${event.line}"); - // }); - GreenlightCredentials greenlightCredentials = GreenlightCredentials( developerKey: base64.decode(secrets.greenlightKey), developerCert: base64.decode(secrets.greenlightCert),