mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 02:39:18 +01:00
2024 11 27 processtransaction flaky test (#5793)
* Fix TxUtil.isValidFeeRange() * Make fee checks exclusive
This commit is contained in:
parent
6f13f263ee
commit
98e89a6e93
2 changed files with 18 additions and 9 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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]],
|
||||
|
|
Loading…
Add table
Reference in a new issue