mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
DefaultCoinSelector: use checked add to sum up output values
This commit is contained in:
parent
f6cb6c15d1
commit
26f343a607
1 changed files with 2 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.bitcoinj.wallet;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.math.LongMath;
|
||||
import org.bitcoinj.base.BitcoinNetwork;
|
||||
import org.bitcoinj.base.Coin;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
@ -57,7 +58,7 @@ public class DefaultCoinSelector implements CoinSelector {
|
|||
// Only pick chain-included transactions, or transactions that are ours and pending.
|
||||
if (!shouldSelect(output.getParentTransaction())) continue;
|
||||
selected.add(output);
|
||||
total += output.getValue().value;
|
||||
total = LongMath.checkedAdd(total, output.getValue().value);
|
||||
}
|
||||
// Total may be lower than target here, if the given candidates were insufficient to create to requested
|
||||
// transaction.
|
||||
|
|
Loading…
Add table
Reference in a new issue