Skip to content

Commit

Permalink
Backend/UtxoCoin: stop considering invalid fee estimation results
Browse files Browse the repository at this point in the history
Reported by Andrew Cann, caught when running with regtest: it could be
dangerous to not look at these values and reject them, given that we use
an average-calculation later. Well, "dangerous", the worst that could
happen is that we use a fee that is too low.
  • Loading branch information
knocte committed Jul 7, 2020
1 parent 23d347b commit c9cd074
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GWallet.Backend/UtxoCoin/ElectrumClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ module ElectrumClient =
let EstimateFee (numBlocksTarget: int) (stratumServer: Async<StratumClient>): Async<decimal> = async {
let! stratumClient = stratumServer
let! estimateFeeResult = stratumClient.BlockchainEstimateFee numBlocksTarget
if estimateFeeResult.Result = -1m then
return raise <| ServerMisconfiguredException("Fee estimation returned a -1 error code")
elif estimateFeeResult.Result <= 0m then
return raise <| ServerMisconfiguredException(SPrintF1 "Fee estimation returned an invalid non-positive value %M"
estimateFeeResult.Result)
return estimateFeeResult.Result
}

Expand Down

0 comments on commit c9cd074

Please sign in to comment.