diag(mwc): initialize MWC Rust trace logger on first wallet open
What changed, and why it matters
This commit adds diagnostic logging for the Mimblewimblecoin (MWC) wallet. It initializes a Rust-side trace logger the first time an MWC wallet is opened, so that if the underlying native code crashes silently, developers have a log file to inspect. It is a debugging/diagnostic improvement, not a fix for an exploitable vulnerability.
No security action required. Treat as a normal diagnostic/logging improvement. Review log file permissions and storage location to ensure the new `mwc-wallet.log` does not inadvertently expose sensitive material such as addresses, transaction graph data, or keys.
Security signals we found
Adds logging only; no privilege boundary crossed
No input validation, cryptographic, or memory-safety changes
Failure path is caught and logged, preserving prior behavior
Static guard prevents repeated initialization
Evidence from the diff
The change introduces a static boolean guard _mwcLogsInitialized and calls libMwc.initLogs(config: config) once per process when an MWC wallet is first opened. Output is directed to <wallet_dir>/mwc-wallet.log. The call is wrapped in a try/catch so failure does not prevent wallet opening. The commit message frames this as a diagnostic aid for silent native crashes (SIGSEGV/abort) in scan() or listener code.
Changed components
lib/wallets/wallet/impl/mimblewimblecoin_wallet.dartMWC wallet open flowlibMwc Rust bridge loggingInspect captured patch +14 / −0
diff --git a/lib/wallets/wallet/impl/mimblewimblecoin_wallet.dart b/lib/wallets/wallet/impl/mimblewimblecoin_wallet.dart
index 9a7dbc5..58aedff 100644
--- a/lib/wallets/wallet/impl/mimblewimblecoin_wallet.dart
+++ b/lib/wallets/wallet/impl/mimblewimblecoin_wallet.dart
@@ -45,6 +45,8 @@ class MimblewimblecoinWallet extends Bip39Wallet {
NodeModel? _mimblewimblecoinNode;
Timer? timer;
+ static bool _mwcLogsInitialized = false;
+
double highestPercent = 0;
Future<double> get getSyncPercent async {
final int lastScannedBlock =
@@ -103,6 +105,18 @@ class MimblewimblecoinWallet extends Bip39Wallet {
if (existing != null && existing.isNotEmpty) return existing;
final config = await _getRealConfig();
+ // Initialize MWC's own Rust logger once per process so trace-level
+ // output from scan()/listener lands in <wallet_dir>/mwc-wallet.log.
+ // This is invaluable when the native side crashes silently (SIGSEGV
+ // / abort) without leaving a Rust panic.
+ if (!_mwcLogsInitialized) {
+ try {
+ await libMwc.initLogs(config: config);
+ _mwcLogsInitialized = true;
+ } catch (e, s) {
+ Logging.instance.w("libMwc.initLogs failed: $e\n$s");
+ }
+ }
final password = await secureStorageInterface.read(
key: '${walletId}_password',
);
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.