Skip to content

Commit

Permalink
Merge #353: Allow warnings to be either a string or a string sequence.
Browse files Browse the repository at this point in the history
87c95f6 Allow warnings to be either a string or a string sequence. (Arik Sosman)

Pull request description:

  In recent versions of bitcoind, `getblockchaininfo` returns a result whose `warnings` key is no longer a string, but an array of strings. This PR allows the parsing of either. Fixes #352.

ACKs for top commit:
  tcharding:
    ACK 87c95f6
  apoelstra:
    ACK 87c95f6 also assuming that you tested this against an actual recent node

Tree-SHA512: eccf2efe9ee69f4523cdb49d9b3d314a2a246991dccd3840b377523e38847640ec7ecbfcb6e0469f6b8bf355e51d5870e86402ee574327b0b4668130f3a0e351
  • Loading branch information
apoelstra committed May 8, 2024
2 parents cc22671 + 87c95f6 commit d076d16
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,14 @@ pub struct GetAddressInfoResult {
pub label: Option<String>,
}

/// Used to represent values that can either be a string or a string array.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum StringOrStringArray {
String(String),
StringArray(Vec<String>),
}

/// Models the result of "getblockchaininfo"
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GetBlockchainInfoResult {
Expand Down Expand Up @@ -1045,8 +1053,8 @@ pub struct GetBlockchainInfoResult {
/// Status of softforks in progress
#[serde(default)]
pub softforks: HashMap<String, Softfork>,
/// Any network and blockchain warnings.
pub warnings: String,
/// Any network and blockchain warnings. In later versions of bitcoind, it's an array of strings.
pub warnings: StringOrStringArray,
}

#[derive(Clone, PartialEq, Eq, Debug)]
Expand Down

0 comments on commit d076d16

Please sign in to comment.