3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 23:03:04 +00:00

Note that a tx of exactly 1000 bytes may overpay.

This commit is contained in:
Mike Hearn 2013-06-12 17:42:18 +02:00
parent c91e811fc7
commit 74110a12d9

View File

@ -3111,10 +3111,12 @@ public class Wallet implements Serializable, BlockChainListener {
resetTxInputs(req, originalInputs);
BigInteger fees = req.fee == null ? BigInteger.ZERO : req.fee;
if (lastCalculatedSize > 0)
if (lastCalculatedSize > 0) {
// If the size is exactly 1000 bytes then we'll over-pay, but this should be rare.
fees = fees.add(BigInteger.valueOf((lastCalculatedSize / 1000) + 1).multiply(req.feePerKb));
else
} else {
fees = fees.add(req.feePerKb); // First time around the loop.
}
if (needAtLeastReferenceFee && fees.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0)
fees = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;