From c9cd074760034b2acc0415e55349163dd82c0f6f Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Tue, 7 Jul 2020 18:26:31 +0800 Subject: [PATCH] Backend/UtxoCoin: stop considering invalid fee estimation results 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. --- src/GWallet.Backend/UtxoCoin/ElectrumClient.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs b/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs index 6fc31f3c4..bfecda1cc 100644 --- a/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs +++ b/src/GWallet.Backend/UtxoCoin/ElectrumClient.fs @@ -86,6 +86,11 @@ module ElectrumClient = let EstimateFee (numBlocksTarget: int) (stratumServer: Async): Async = 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 }