Skip to content

Commit d076d16

Browse files
committedMay 8, 2024
Merge #353: Allow warnings to be either a string or a string sequence.
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
2 parents cc22671 + 87c95f6 commit d076d16

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎json/src/lib.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,14 @@ pub struct GetAddressInfoResult {
10041004
pub label: Option<String>,
10051005
}
10061006

1007+
/// Used to represent values that can either be a string or a string array.
1008+
#[derive(Clone, Debug, Deserialize, Serialize)]
1009+
#[serde(untagged)]
1010+
pub enum StringOrStringArray {
1011+
String(String),
1012+
StringArray(Vec<String>),
1013+
}
1014+
10071015
/// Models the result of "getblockchaininfo"
10081016
#[derive(Clone, Debug, Deserialize, Serialize)]
10091017
pub struct GetBlockchainInfoResult {
@@ -1045,8 +1053,8 @@ pub struct GetBlockchainInfoResult {
10451053
/// Status of softforks in progress
10461054
#[serde(default)]
10471055
pub softforks: HashMap<String, Softfork>,
1048-
/// Any network and blockchain warnings.
1049-
pub warnings: String,
1056+
/// Any network and blockchain warnings. In later versions of bitcoind, it's an array of strings.
1057+
pub warnings: StringOrStringArray,
10501058
}
10511059

10521060
#[derive(Clone, PartialEq, Eq, Debug)]

0 commit comments

Comments
 (0)