Skip to content

Commit

Permalink
Merge pull request #4 from paxosglobal/remove-version-check
Browse files Browse the repository at this point in the history
remove version check
  • Loading branch information
ygaberman-px authored Jun 26, 2023
2 parents 7d1adc1 + 6554741 commit 2a1e888
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions rpcclient/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1619,32 +1619,31 @@ 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
// connected to a bitcoind backend, which exposes its version through
// 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")
version := BitcoindPost19
c.backendVersion = &version
return BitcoindPost19, nil
}

// Parse the bitcoind version and cache it.
Expand Down

0 comments on commit 2a1e888

Please sign in to comment.