Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getnetworkinfo core RPC introduced new field in json object. #2224

Closed
ziggie1984 opened this issue Aug 6, 2024 · 2 comments · Fixed by #2245 or barebitcoin/btcd#4
Closed

getnetworkinfo core RPC introduced new field in json object. #2224

ziggie1984 opened this issue Aug 6, 2024 · 2 comments · Fixed by #2245 or barebitcoin/btcd#4

Comments

@ziggie1984
Copy link
Contributor

ziggie1984 commented Aug 6, 2024

The current master branch of bitcoin-core introduced a new field into the getnetworkinfo rpc json-response. We should adapt the btcd code to account for this however I am not sure how we should do this in a backwards compatible manner. Any suggestions from prior RPC updates of the core software ?

bitcoin-cli --regtest getnetworkinfo
{
  ...
  "warnings": [
    "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
  ]
}
diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go
index 11c0483d..cfb75485 100644
--- a/btcjson/chainsvrresults.go
+++ b/btcjson/chainsvrresults.go
@@ -380,7 +380,7 @@ type GetNetworkInfoResult struct {
        RelayFee        float64                `json:"relayfee"`
        IncrementalFee  float64                `json:"incrementalfee"`
        LocalAddresses  []LocalAddressesResult `json:"localaddresses"`
-       Warnings        string                 `json:"warnings"`
+       Warnings        []string               `json:"warnings"`
 }

Thanks @michael1011 for pointing this out.

@stickies-v
Copy link

stickies-v commented Aug 6, 2024

FYI see bitcoin/bitcoin#29845 for more context. Old behaviour can temporarily be reverted via -deprecatedrpc=warnings as per the release notes but this will be removed in a future version so best to upgrade when you can.

See also https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md#versioning.

Where possible, these changes are also documented in the help RPC, see e.g.

./src/bitcoin-cli -regtest help getnetworkinfo | grep warnings
  "warnings" : [                                     (json array) any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)

@Roasbeef
Copy link
Member

Roasbeef commented Aug 6, 2024

. We should adapt the btcd code to account for this however I am not sure how we should do this in a backwards compatible manner. Any suggestions from prior RPC updates of the core software ?

See: #1934

We no longer commit to staying 1:1 in step with all the bitcoind related RPC changes. Even just on the wallet side, there've been a bunch over the past few years, and btcd doesn't integrate its own wallet, so there isn't as strong a case to mirror all the changes there.

For a change like this, one could consider adding a new field for the new value. Not sure how upstream clients that are depending (what do people even use it for today?) on the warnings field will handle the change in general through (string to slice).

guggero added a commit to guggero/btcd that referenced this issue Sep 2, 2024
Fixes btcsuite#2224 and lightningnetwork/lnd#9053.

Depending on the version of Bitcoin Core, the "warnings" field in the
response to getnetworkinfo is either a single string value or an array
of strings.
We can easily parse those two variants with a custom type that
implements an UnmarshalJSON method.
guggero added a commit to guggero/btcd that referenced this issue Sep 2, 2024
Fixes btcsuite#2224 and lightningnetwork/lnd#9053.

Depending on the version of Bitcoin Core, the "warnings" field in the
response to getnetworkinfo is either a single string value or an array
of strings.
We can easily parse those two variants with a custom type that
implements an UnmarshalJSON method.
PaulKorepanow pushed a commit to midl-xyz/btcd that referenced this issue Sep 12, 2024
Fixes btcsuite#2224 and lightningnetwork/lnd#9053.

Depending on the version of Bitcoin Core, the "warnings" field in the
response to getnetworkinfo is either a single string value or an array
of strings.
We can easily parse those two variants with a custom type that
implements an UnmarshalJSON method.
btcfind pushed a commit to btcfind/btcd that referenced this issue Sep 26, 2024
Fixes btcsuite#2224 and lightningnetwork/lnd#9053.

Depending on the version of Bitcoin Core, the "warnings" field in the
response to getnetworkinfo is either a single string value or an array
of strings.
We can easily parse those two variants with a custom type that
implements an UnmarshalJSON method.
octobocto pushed a commit to barebitcoin/btcd that referenced this issue Sep 27, 2024
Fixes btcsuite#2224 and lightningnetwork/lnd#9053.

Depending on the version of Bitcoin Core, the "warnings" field in the
response to getnetworkinfo is either a single string value or an array
of strings.
We can easily parse those two variants with a custom type that
implements an UnmarshalJSON method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants