Skip to content

fix: accept chaininfo warnings in any JSON shape - #57

Merged
setavenger merged 1 commit into
setavenger:masterfrom
bitsagarob:fix/chaininfo-warnings-shape
Sep 23, 2026
Merged

setavenger merged 1 commit into
setavenger:masterfrom
bitsagarob:fix/chaininfo-warnings-shape

Conversation

@bitsagarob

Copy link
Copy Markdown
Contributor

Initial sync fails immediately on Bitcoin Core v28+ with

initial sync failed: json: cannot unmarshal array into Go struct
field ChainInfo.warnings of type string

because Core v28 changed the warnings field of chaininfo from a string to an array of strings (the -deprecatedrpc=warnings escape hatch was removed again in v29, so every version this project's README supports, v30+, returns the array). Verified live against Core v31.1: /rest/chaininfo.json returns "warnings": [].

This field has already flipped once: the struct originally declared []string, #53 changed it to string (fixing #50), and the follow-up comments on #50 then showed v31 answering with an array again. Declaring it as json.RawMessage accepts both shapes, so this class of breakage ends here. Nothing in the oracle reads the field, so no behavior changes.

Tested: mainnet initial sync from height 709656 runs on Core v31.1 with this patch (250k+ blocks indexed at the time of writing).

Initial sync fails immediately on Bitcoin Core v28+ with

    initial sync failed: json: cannot unmarshal array into Go struct
    field ChainInfo.warnings of type string

because Core v28 changed the `warnings` field of chaininfo from a
string to an array of strings (the `-deprecatedrpc=warnings` escape
hatch was removed again in v29, so every version this project's README
supports, v30+, returns the array). Verified live against Core v31.1:
`/rest/chaininfo.json` returns `"warnings": []`.

This field has already flipped once: the struct originally declared
`[]string`, setavenger#53 changed it to `string` (fixing setavenger#50), and the follow-up
comments on setavenger#50 then showed v31 answering with an array again. Declaring
it as `json.RawMessage` accepts both shapes, so this class of breakage
ends here. Nothing in the oracle reads the field, so no behavior
changes.

Tested: mainnet initial sync from height 709656 runs on Core v31.1 with
this patch (250k+ blocks indexed at the time of writing).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@macgyver13

Copy link
Copy Markdown

ACK 039fc5b

tested on Core v31.1

@setavenger
setavenger merged commit f9ab7fd into setavenger:master Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants