diff --git a/core/src/main/scala/org/bitcoins/core/protocol/transaction/TxUtil.scala b/core/src/main/scala/org/bitcoins/core/protocol/transaction/TxUtil.scala index d3a323b425..6c17e85fbe 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/transaction/TxUtil.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/transaction/TxUtil.scala @@ -289,7 +289,9 @@ object TxUtil { val actualFee = creditingAmount - spentAmount val estimatedFee = expectedFeeRate * expectedTx - isValidFeeRange(estimatedFee, actualFee, expectedFeeRate) + isValidFeeRange(estimatedFee = estimatedFee, + actualFee = actualFee, + feeRate = expectedFeeRate) } } @@ -328,10 +330,10 @@ object TxUtil { val min = Satoshis(-acceptableVariance) val max = Satoshis(acceptableVariance) val difference = estimatedFee - actualFee - if (difference <= min) { - TxBuilderError.HighFee - } else if (difference >= max) { - TxBuilderError.LowFee + if (difference < min) { + TxBuilderError.highFee(estimatedFee, actualFee) + } else if (difference > max) { + TxBuilderError.lowFee(min = estimatedFee, actual = actualFee) } else { Success(()) } diff --git a/core/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala b/core/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala index df48f3a8be..476a6fb302 100644 --- a/core/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala +++ b/core/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala @@ -1,5 +1,6 @@ package org.bitcoins.core.wallet.builder +import org.bitcoins.core.currency.CurrencyUnit import org.bitcoins.core.protocol.transaction.TransactionOutput import scala.util.Failure @@ -169,15 +170,21 @@ object TxBuilderError { /** Means that the fee was too low for * [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]] */ - val LowFee = Failure( - new IllegalArgumentException("Means that the fee was too low")) + def lowFee(min: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = { + Failure( + new IllegalArgumentException( + s"Means that the fee was too low min=$min actual=$actual")) + } /** Means tha this transaction pays too high of a fee for * [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]] */ - val HighFee = Failure( - new IllegalArgumentException("Means that the fee was too high")) + def highFee(max: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = { + Failure( + new IllegalArgumentException( + s"Means that the fee was too high, max=$max actual=$actual")) + } /** Indicates we are spending multiple * [[org.bitcoins.core.protocol.script.CLTVScriptPubKey CLTVScriptPubKey]],