From 656fd68c3139ce397d2f7da123a165ef5ae899c6 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 16 Jul 2024 21:09:47 -0300 Subject: [PATCH] fix estimatefees: esplora loop. --- README.md | 4 ++-- estimatefees.go | 13 +++++++------ main.go | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9524fcf..d232faa 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ apt install lightningd mkdir -p ~/.lightning/plugins echo 'disable-plugin=bcli' >> .lightning/config cd ~/.lightning/plugins -wget https://github.com/nbd-wtf/trustedcoin/releases/download/v0.8.1/trustedcoin-v0.8.1-linux-amd64.tar.gz -tar -xvf trustedcoin-v0.8.1-linux-amd64.tar.gz +wget https://github.com/nbd-wtf/trustedcoin/releases/download/v0.8.2/trustedcoin-v0.8.2-linux-amd64.tar.gz +tar -xvf trustedcoin-v0.8.2-linux-amd64.tar.gz cd lightningd ``` diff --git a/estimatefees.go b/estimatefees.go index 084d0b8..0c3c7de 100644 --- a/estimatefees.go +++ b/estimatefees.go @@ -78,14 +78,15 @@ func getFeeRatesFromEsplora() (feerates map[string]float64, err error) { defer w.Body.Close() if w.StatusCode >= 300 { - err = errors.New(endpoint + " error: " + w.Status) - return + continue } - err = json.NewDecoder(w.Body).Decode(&feerates) - return + if err := json.NewDecoder(w.Body).Decode(&feerates); err != nil { + continue + } else { + return feerates, nil + } } - err = errors.New("none of the esploras returned usable responses") - return + return nil, errors.New("none of the esploras returned usable responses") } diff --git a/main.go b/main.go index 14bdccc..85f46ee 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "github.com/fiatjaf/lightningd-gjson-rpc/plugin" ) -const version = "0.8.1" +const version = "0.8.2" var ( network string