From ea686e8adc29832e3362d2afef48e4f0a169bbb7 Mon Sep 17 00:00:00 2001 From: Yakov Gaberman <81639957+ygaberman-px@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:50:30 -0400 Subject: [PATCH 1/2] remove version check --- rpcclient/infrastructure.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index fbc43a4568..98d8e75218 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -1619,24 +1619,15 @@ func (c *Client) BackendVersion() (BackendVersion, error) { // to a btcd backend if it does exist. info, err := c.GetInfo() - switch err := err.(type) { + switch err.(type) { // Parse the btcd version and cache it. case nil: log.Debugf("Detected btcd version: %v", info.Version) version := Btcd c.backendVersion = &version return *c.backendVersion, nil - - // Inspect the RPC error to ensure the method was not found, otherwise - // we actually ran into an error. - case *btcjson.RPCError: - if err.Code != btcjson.ErrRPCMethodNotFound.Code { - return 0, fmt.Errorf("unable to detect btcd version: "+ - "%v", err) - } - default: - return 0, fmt.Errorf("unable to detect btcd version: %v", err) + log.Debugf("Could not detect bitcoind version from GetInfo. error: %v", err) } // Since the GetInfo method was not found, we assume the client is @@ -1644,7 +1635,13 @@ func (c *Client) BackendVersion() (BackendVersion, error) { // GetNetworkInfo. networkInfo, err := c.GetNetworkInfo() if err != nil { - return 0, fmt.Errorf("unable to detect bitcoind version: %v", err) + log.Debugf("Could not detect bitcoind version from GetNetworkInfo. error: %v", err) + } + + // assume the network is beyond v0.19 + if networkInfo == nil { + log.Debug("Could not detect bitcoind version. Assuming post v0.19") + return BitcoindPost19, nil } // Parse the bitcoind version and cache it. From 65547419df33572771b876c40c5c23e922bc3717 Mon Sep 17 00:00:00 2001 From: Yakov Gaberman <81639957+ygaberman-px@users.noreply.github.com> Date: Mon, 26 Jun 2023 15:06:05 -0400 Subject: [PATCH 2/2] cache backend version --- rpcclient/infrastructure.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 98d8e75218..77d0d8b73f 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -1641,6 +1641,8 @@ func (c *Client) BackendVersion() (BackendVersion, error) { // assume the network is beyond v0.19 if networkInfo == nil { log.Debug("Could not detect bitcoind version. Assuming post v0.19") + version := BitcoindPost19 + c.backendVersion = &version return BitcoindPost19, nil }