chainreg: shutdown if backend node doesn't support taproot

In this commit, we add a check during normal node construction to see if
the backend node supports Taproot. If it doesn't, then we want to
shutdown and force the user to take note.

To check if the node supports Taproot, we'll first try the normal
getblockchaininfo call. If this works, cool, then we can rely on the
value. If it doesn't, then we'll fall back to the getdeploymentinfo call
which was added in a recent version of bitcoind [1]. Newer versions of
bitcoind might also have this call, and the getblockchaininfo call, but
not actually populate the softforks field [2]. In this case, we'll fall
back, and we also account for the case when the getblockchaininfo RPC is
removed all together.

[1]: https://github.com/bitcoin/bitcoin/pull/23508
[2]: https://github.com/bitcoin/bitcoin/pull/25114

Fixes #6773
This commit is contained in:
Olaoluwa Osuntokun
2022-08-04 19:55:10 -07:00
parent 115b041874
commit 492f8b6999
3 changed files with 82 additions and 0 deletions

View File

@@ -496,6 +496,14 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
// Before we continue any further, we'll ensure that the
// backend understands Taproot. If not, then all the default
// features can't be used.
if !backendSupportsTaproot(chainConn) {
return nil, nil, fmt.Errorf("node backend does not " +
"support taproot")
}
// The api we will use for our health check depends on the
// bitcoind version.
cmd, ver, err := getBitcoindHealthCheckCmd(chainConn)
@@ -675,6 +683,21 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
return nil, nil, err
}
// Before we continue any further, we'll ensure that the
// backend understands Taproot. If not, then all the default
// features can't be used.
restConfCopy := *rpcConfig
restConfCopy.Endpoint = ""
restConfCopy.HTTPPostMode = true
chainConn, err := rpcclient.New(&restConfCopy, nil)
if err != nil {
return nil, nil, err
}
if !backendSupportsTaproot(chainConn) {
return nil, nil, fmt.Errorf("node backend does not " +
"support taproot")
}
cc.ChainSource = chainRPC
// Use a query for our best block as a health check.