btcjson: add Warnings field to GetBlockChainInfoResult
What changed, and why it matters
This commit adds a missing 'Warnings' field to btcd's JSON-RPC response structure for getblockchaininfo. It is a compatibility fix so btcd can parse responses from Bitcoin Core versions that include this field, whether it is a single string or an array of strings. There is no security vulnerability here.
No security action needed. Treat as a normal compatibility/bugfix update.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds a Warnings field of type StringOrArray to GetBlockChainInfoResult in btcjson/chainsvrresults.go and updates the RPC help text in rpcserverhelp.go. StringOrArray is an existing helper type that accepts either a JSON string or array during unmarshalling. This resolves JSON unmarshalling errors when getblockchaininfo responses from newer Bitcoin Core nodes contain a warnings field.
Changed components
btcjson/chainsvrresults.gorpcserverhelp.goInspect captured patch +14 / −12
diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go
index b511d3c..120ee79 100644
--- a/btcjson/chainsvrresults.go
+++ b/btcjson/chainsvrresults.go
@@ -226,18 +226,19 @@ type UnifiedSoftForks struct {
// GetBlockChainInfoResult models the data returned from the getblockchaininfo
// command.
type GetBlockChainInfoResult struct {
- Chain string `json:"chain"`
- Blocks int32 `json:"blocks"`
- Headers int32 `json:"headers"`
- BestBlockHash string `json:"bestblockhash"`
- Difficulty float64 `json:"difficulty"`
- MedianTime int64 `json:"mediantime"`
- VerificationProgress float64 `json:"verificationprogress,omitempty"`
- InitialBlockDownload bool `json:"initialblockdownload,omitempty"`
- Pruned bool `json:"pruned"`
- PruneHeight int32 `json:"pruneheight,omitempty"`
- ChainWork string `json:"chainwork,omitempty"`
- SizeOnDisk int64 `json:"size_on_disk,omitempty"`
+ Chain string `json:"chain"`
+ Blocks int32 `json:"blocks"`
+ Headers int32 `json:"headers"`
+ BestBlockHash string `json:"bestblockhash"`
+ Difficulty float64 `json:"difficulty"`
+ MedianTime int64 `json:"mediantime"`
+ VerificationProgress float64 `json:"verificationprogress,omitempty"`
+ InitialBlockDownload bool `json:"initialblockdownload,omitempty"`
+ Pruned bool `json:"pruned"`
+ PruneHeight int32 `json:"pruneheight,omitempty"`
+ ChainWork string `json:"chainwork,omitempty"`
+ SizeOnDisk int64 `json:"size_on_disk,omitempty"`
+ Warnings StringOrArray `json:"warnings"`
*SoftForks
*UnifiedSoftForks
}
diff --git a/rpcserverhelp.go b/rpcserverhelp.go
index 133fb48..34a6c74 100644
--- a/rpcserverhelp.go
+++ b/rpcserverhelp.go
@@ -187,6 +187,7 @@ var helpDescsEnUS = map[string]string{
"getblockchaininforesult-initialblockdownload": "Estimate of whether this node is in Initial Block Download mode",
"getblockchaininforesult-softforks": "The status of the super-majority soft-forks",
"getblockchaininforesult-unifiedsoftforks": "The status of the super-majority soft-forks used by bitcoind on or after v0.19.0",
+ "getblockchaininforesult-warnings": "Any network and blockchain warnings",
// SoftForkDescription help.
"softforkdescription-reject": "The current activation status of the softfork",
Why this scored 19/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.