fix(firo): fail empty Spark auto mints
What changed, and why it matters
This commit adds a safety check to Stack Wallet's Firo Spark auto-minting feature. Previously, if the wallet tried to automatically convert all eligible coins into Spark private coins and somehow produced no transactions, it would silently return an empty result. Now it throws a clear error instead. This prevents the wallet from incorrectly assuming a successful private mint happened when nothing was actually sent.
Review the full Spark auto-mint flow to identify why `results` could be empty (e.g., fee estimation, coin selection, insufficient funds, or race conditions) and ensure callers handle the new exception safely. Consider adding tests for the empty-results case.
Security signals we found
Defensive guard against empty transaction list in privacy-sensitive auto-mint flow
Potential silent failure / inconsistent state if empty results were treated as success
Privacy coin minting logic (Spark/Firo) is a high-value target for correctness bugs
Evidence from the diff
In spark_interface.dart, after the Spark minting loop, the patch adds: if (autoMintAll && results.isEmpty) throw Exception("No Spark mint transactions were created");. This guards the autoMintAll path from returning an empty results list. The change is defensive: without it, callers might treat an empty result as success, potentially leading to stale UTXO state, missing mints, or incorrect balance assumptions. The patch is minimal and partial—it only adds the guard, not root-cause fixes for why results might be empty.
Changed components
lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dartFiro Spark auto-mint functionalityInspect captured patch +4 / −0
diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart
index ed6719d..ae423ff 100644
--- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart
+++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart
@@ -2213,6 +2213,10 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
throw Exception("Failed to mint expected amounts");
}
+ if (autoMintAll && results.isEmpty) {
+ throw Exception("No Spark mint transactions were created");
+ }
+
return results;
}
Why this scored 32/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.