pass 0 as amount to prevent no element issues, it is not displayed anywhere anyway (#2684)
What changed, and why it matters
This commit makes two small changes to the Litecoin wallet code. First, it replaces a calculation that added up all transaction output amounts with a fixed value of 0, because the amount field is not shown to users anyway and the old code could crash when a transaction had no outputs. Second, it removes a leftover debug print statement. There is no clear security vulnerability here; it appears to be a bug-fix and cleanup change.
No security action required. Treat as routine bug fix and code cleanup. If desired, verify downstream consumers of the amount parameter handle 0 correctly and that the previous summed amount was indeed unused in UI or fee calculations.
Security signals we found
No security-relevant signals identified in the diff
Change is defensive: prevents a no-element runtime exception
No cryptographic, authentication, or authorization changes
Evidence from the diff
In cw_bitcoin/lib/litecoin_wallet.dart, the code previously computed the total of btcTx.outputs via reduce() and passed that as the amount argument to a transaction-building helper. If outputs was empty, reduce() on an empty iterable throws a StateError (‘No element’), causing a crash. The patch passes amount: 0 instead, with the commit message stating this amount is not displayed. In cw_bitcoin/lib/litecoin_wallet_addresses.dart, a debug printV(‘aaaaaa’) call is removed. No security-sensitive logic is altered.
Changed components
cw_bitcoin/lib/litecoin_wallet.dartcw_bitcoin/lib/litecoin_wallet_addresses.dartInspect captured patch +1 / −2
diff --git a/cw_bitcoin/lib/litecoin_wallet.dart b/cw_bitcoin/lib/litecoin_wallet.dart
index 7b2412d3..91d927da 100644
--- a/cw_bitcoin/lib/litecoin_wallet.dart
+++ b/cw_bitcoin/lib/litecoin_wallet.dart
@@ -1350,7 +1350,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
btcTx,
type,
electrumClient: electrumClient,
- amount: btcTx.outputs.reduce((a, b) => TxOutput(amount: a.amount + b.amount, scriptPubKey: a.scriptPubKey)).amount.toInt(),
+ amount: 0,
fee: resp.fee.toInt(),
feeRate: "",
network: network,
diff --git a/cw_bitcoin/lib/litecoin_wallet_addresses.dart b/cw_bitcoin/lib/litecoin_wallet_addresses.dart
index fe39ab7c..9b321186 100644
--- a/cw_bitcoin/lib/litecoin_wallet_addresses.dart
+++ b/cw_bitcoin/lib/litecoin_wallet_addresses.dart
@@ -70,7 +70,6 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with
}
Future<void> ensureMwebAddressUpToIndexExists(int index) async {
- printV("aaaaaa");
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
return null;
}
Why this scored 15/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.