Skip to content

Commit

Permalink
Add fee validation for replacement transaction info
Browse files Browse the repository at this point in the history
  • Loading branch information
omurovch committed Mar 28, 2024
1 parent 3f22d8a commit d0d3283
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,13 @@ class ReplacementTransactionBuilder(
}

val confirmedUtxoTotalValue = unspentOutputProvider.getConfirmedSpendableUtxo().sumOf { it.output.value }
val feeRange = LongRange(absoluteFee, originalFee + removableOutputsValue + confirmedUtxoTotalValue)
val maxFeeAmount = originalFee + removableOutputsValue + confirmedUtxoTotalValue

return ReplacementTransactionInfo(replacementTxMinSize, feeRange)
return if (absoluteFee > maxFeeAmount) {
null
} else {
ReplacementTransactionInfo(replacementTxMinSize, LongRange(absoluteFee, maxFeeAmount))
}
}

sealed class BuildError : Throwable() {
Expand Down

0 comments on commit d0d3283

Please sign in to comment.