Fix Transaction.calcRecommendedFee()

This commit is contained in:
catbref 2020-04-08 18:10:19 +01:00
parent d2eb8b0c2b
commit 7ded8954c6

View File

@ -345,18 +345,10 @@ public abstract class Transaction {
BigDecimal maxBytePerUnitFee = BlockChain.getInstance().getMaxBytesPerUnitFee();
BigDecimal recommendedFee = BigDecimal.valueOf(dataLength).divide(maxBytePerUnitFee, MathContext.DECIMAL32).setScale(8);
BigDecimal unitFeeCount = BigDecimal.valueOf(dataLength).divide(maxBytePerUnitFee, RoundingMode.UP);
// security margin
recommendedFee = recommendedFee.add(new BigDecimal("0.00000001"));
if (recommendedFee.compareTo(BlockChain.getInstance().getUnitFee()) <= 0) {
recommendedFee = BlockChain.getInstance().getUnitFee();
} else {
recommendedFee = recommendedFee.setScale(0, RoundingMode.CEILING);
}
return recommendedFee.setScale(8);
BigDecimal recommendedFee = BlockChain.getInstance().getUnitFee().multiply(unitFeeCount).setScale(8);
return recommendedFee;
}
/**