Skip to content

Commit 81a6f32

Browse files
committed
Fix negative mintedValue passing through zero-check in fee loop
The guard at the top of the inner fee loop only checked mintedValue == BigInt.zero, but mintedValue can go negative when nFeeRet (starting from minFeeForGroup on retry) exceeds the UTXO group's total value. A negative mintedValue would flow into createSparkMintRecipients causing invalid outputs. Change the check to <= BigInt.zero to match the intent of the commented-out MoneyRange check from the C++ reference implementation. https://claude.ai/code/session_01D9ssjMkQAMoCUcrPzVVtEq
1 parent 3d0dec1 commit 81a6f32

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
16531653
}
16541654

16551655
// if (!MoneyRange(mintedValue) || mintedValue == 0) {
1656-
if (mintedValue == BigInt.zero) {
1656+
if (mintedValue <= BigInt.zero) {
16571657
valueAndUTXOs.remove(itr);
16581658
skipCoin = true;
16591659
break;

0 commit comments

Comments
 (0)