mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +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 actualFee = creditingAmount - spentAmount
|
||||||
val estimatedFee = expectedFeeRate * expectedTx
|
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 min = Satoshis(-acceptableVariance)
|
||||||
val max = Satoshis(acceptableVariance)
|
val max = Satoshis(acceptableVariance)
|
||||||
val difference = estimatedFee - actualFee
|
val difference = estimatedFee - actualFee
|
||||||
if (difference <= min) {
|
if (difference < min) {
|
||||||
TxBuilderError.HighFee
|
TxBuilderError.highFee(estimatedFee, actualFee)
|
||||||
} else if (difference >= max) {
|
} else if (difference > max) {
|
||||||
TxBuilderError.LowFee
|
TxBuilderError.lowFee(min = estimatedFee, actual = actualFee)
|
||||||
} else {
|
} else {
|
||||||
Success(())
|
Success(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.bitcoins.core.wallet.builder
|
package org.bitcoins.core.wallet.builder
|
||||||
|
|
||||||
|
import org.bitcoins.core.currency.CurrencyUnit
|
||||||
import org.bitcoins.core.protocol.transaction.TransactionOutput
|
import org.bitcoins.core.protocol.transaction.TransactionOutput
|
||||||
|
|
||||||
import scala.util.Failure
|
import scala.util.Failure
|
||||||
|
@ -169,15 +170,21 @@ object TxBuilderError {
|
||||||
/** Means that the fee was too low for
|
/** Means that the fee was too low for
|
||||||
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
|
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
|
||||||
*/
|
*/
|
||||||
val LowFee = Failure(
|
def lowFee(min: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = {
|
||||||
new IllegalArgumentException("Means that the fee was too low"))
|
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
|
/** Means tha this transaction pays too high of a fee for
|
||||||
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
|
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val HighFee = Failure(
|
def highFee(max: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = {
|
||||||
new IllegalArgumentException("Means that the fee was too high"))
|
Failure(
|
||||||
|
new IllegalArgumentException(
|
||||||
|
s"Means that the fee was too high, max=$max actual=$actual"))
|
||||||
|
}
|
||||||
|
|
||||||
/** Indicates we are spending multiple
|
/** Indicates we are spending multiple
|
||||||
* [[org.bitcoins.core.protocol.script.CLTVScriptPubKey CLTVScriptPubKey]],
|
* [[org.bitcoins.core.protocol.script.CLTVScriptPubKey CLTVScriptPubKey]],
|
||||||
|
|
Loading…
Add table
Reference in a new issue