diff --git a/cw_bitcoin/lib/litecoin_wallet.dart b/cw_bitcoin/lib/litecoin_wallet.dart index bd9f079048..8b4c526ba2 100644 --- a/cw_bitcoin/lib/litecoin_wallet.dart +++ b/cw_bitcoin/lib/litecoin_wallet.dart @@ -973,7 +973,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { // throw Exception("MWEB is not enabled! can't calculate fee without starting the mweb server!"); // rather than throwing an exception, filter out mweb inputs and outputs: utxos = utxos.where((utxo) => utxo.utxo.scriptType != SegwitAddresType.mweb).toList(); - outputs = outputs.where((output) => output.toOutput.scriptPubKey.getAddressType() != SegwitAddresType.mweb).toList(); + outputs = outputs + .where((output) => output.toOutput.scriptPubKey.getAddressType() != SegwitAddresType.mweb) + .toList(); paysToMweb = false; spendsMweb = false; printV("FILTERED OUT MWEB INPUTS AND OUTPUTS!"); @@ -991,7 +993,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { ); } - if (outputs.length == 1 && outputs[0].toOutput.amount == BigInt.zero) { outputs = [ BitcoinScriptOutput( @@ -1219,7 +1220,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future setMwebEnabled(bool enabled) async { - if (mwebEnabled == enabled) { + if (mwebEnabled == enabled && + alwaysScan == enabled && + (walletAddresses as LitecoinWalletAddresses).mwebEnabled == enabled) { return; } diff --git a/lib/src/screens/settings/mweb_logs_page.dart b/lib/src/screens/settings/mweb_logs_page.dart index 3c5470214a..3c29ecdd85 100644 --- a/lib/src/screens/settings/mweb_logs_page.dart +++ b/lib/src/screens/settings/mweb_logs_page.dart @@ -80,9 +80,9 @@ class MwebLogsPage extends BasePage { rightButtonText: S.of(context).save_to_downloads, leftButtonText: S.of(context).share, actionRightButton: () async { - const downloadDirPath = "/storage/emulated/0/Download"; - final filePath = downloadDirPath + "/debug.log"; - await mwebSettingsViewModelBase.saveLogsLocally(filePath); + final inAppPath = "${(await getApplicationSupportDirectory()).path}/logs/debug.log"; + final localPath = "/storage/emulated/0/Download/debug.log"; + await mwebSettingsViewModelBase.saveLogsLocally(inAppPath, localPath); Navigator.of(dialogContext).pop(); }, actionLeftButton: () async { @@ -101,11 +101,12 @@ class MwebLogsPage extends BasePage { } Future share(BuildContext context) async { - final filePath = (await getAppDir()).path + "/debug.log"; - bool success = await mwebSettingsViewModelBase.saveLogsLocally(filePath); + final inAppPath = "${(await getApplicationSupportDirectory()).path}/logs/debug.log"; + final localPath = "/storage/emulated/0/Download/debug.log"; + bool success = await mwebSettingsViewModelBase.saveLogsLocally(inAppPath, localPath); if (!success) return; - await ShareUtil.shareFile(filePath: filePath, fileName: "debug.log", context: context); - await mwebSettingsViewModelBase.removeLogsLocally(filePath); + await ShareUtil.shareFile(filePath: localPath, fileName: "debug.log", context: context); + await mwebSettingsViewModelBase.removeLogsLocally(localPath); } Future _saveFile() async { diff --git a/lib/view_model/settings/mweb_settings_view_model.dart b/lib/view_model/settings/mweb_settings_view_model.dart index 11e4c8177c..583a62771f 100644 --- a/lib/view_model/settings/mweb_settings_view_model.dart +++ b/lib/view_model/settings/mweb_settings_view_model.dart @@ -3,6 +3,8 @@ import 'dart:io'; import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/utils/exception_handler.dart'; +import 'package:cw_core/root_dir.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:flutter/widgets.dart'; import 'package:mobx/mobx.dart'; @@ -47,16 +49,16 @@ abstract class MwebSettingsViewModelBase with Store { _settingsStore.mwebAlwaysScan = value; } - Future saveLogsLocally(String filePath) async { + Future saveLogsLocally(String inAppPath, String localPath) async { try { - final appSupportPath = (await getApplicationSupportDirectory()).path; - final logsFile = File("$appSupportPath/logs/debug.log"); + final logsFile = File(inAppPath); if (!logsFile.existsSync()) { throw Exception('Logs file does not exist'); } - await logsFile.copy(filePath); + await logsFile.copy(localPath); return true; } catch (e, s) { + printV("@@@@@ ERROR SAVING LOGS @@@@@@@@"); ExceptionHandler.onError(FlutterErrorDetails( exception: e, stack: s,