chainreg: accommodate buried taproot deployment in Bitcoin Core v31
What changed, and why it matters
This change updates LND's compatibility check so it can still recognize that Bitcoin Core supports Taproot after Bitcoin Core version 31 removed Taproot from its deployment list and added a new 'script_flags' field. Without this fix, LND might incorrectly think a fully capable Bitcoin Core backend does not support Taproot, potentially causing startup or feature-detection problems. It is a robustness fix, not a vulnerability patch.
No immediate security action required. Users running LND against Bitcoin Core v31 or later should ensure they are on a version containing this commit to avoid incorrect Taproot capability detection. Treat as a routine compatibility/maintenance update.
Security signals we found
Compatibility fix for upstream Bitcoin Core RPC changes
Prevents false-negative Taproot capability detection
No cryptographic, consensus, or permission logic changed
Evidence from the diff
The commit modifies chainreg/taproot_check.go’s backendSupportsTaproot() to detect Taproot support via two methods: the legacy presence of ‘taproot’ in getdeploymentinfo’s deployments map (pre-v31), and the new ‘script_flags’ array containing ‘TAPROOT’ (v31+). This accommodates Bitcoin Core PRs #26201 (buried Taproot deployment removal) and #32998 (script_flags addition). The change is additive and backward-compatible.
Changed components
chainreg/taproot_check.gobackendSupportsTaproot() functionInspect captured patch +11 / −1
diff --git a/chainreg/taproot_check.go b/chainreg/taproot_check.go
index dedc717..45c5c5b 100644
--- a/chainreg/taproot_check.go
+++ b/chainreg/taproot_check.go
@@ -2,6 +2,7 @@ package chainreg
import (
"encoding/json"
+ "slices"
"github.com/btcsuite/btcd/rpcclient"
)
@@ -48,6 +49,7 @@ func backendSupportsTaproot(rpc *rpcclient.Client) bool {
}
info := struct {
+ ScriptFlags []string `json:"script_flags"`
Deployments map[string]struct {
Type string `json:"type"`
Active bool `json:"active"`
@@ -59,6 +61,14 @@ func backendSupportsTaproot(rpc *rpcclient.Client) bool {
return false
}
+ // Before Bitcoin Core v31, taproot was still included as a BIP9
+ // deployment.
_, ok := info.Deployments["taproot"]
- return ok
+
+ // Since v31, taproot is activated at genesis and no longer appears
+ // as a deployment. Also in v31, Bitcoin Core added a "script_flags"
+ // field to getdeploymentinfo which lists all the verification flags.
+ hasFlag := slices.Contains(info.ScriptFlags, "TAPROOT")
+
+ return ok || hasFlag
}
Why this scored 37/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.