Skip to content

Commit 392f3b9

Browse files
authored
Serialize with bip70 (#19)
1 parent 06a6c15 commit 392f3b9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

json/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ pub enum StringOrStringArray {
10171017
pub struct GetBlockchainInfoResult {
10181018
/// Current network name as defined in BIP70 (main, test, signet, regtest)
10191019
#[serde(deserialize_with = "deserialize_bip70_network")]
1020+
#[serde(serialize_with = "serialize_bip70_network")]
10201021
pub chain: Network,
10211022
/// The current number of blocks processed in the server
10221023
pub blocks: u64,
@@ -2190,6 +2191,13 @@ where
21902191
Ok(Some(res))
21912192
}
21922193

2194+
fn serialize_bip70_network<S>(network: &Network, serializer: S) -> Result<S::Ok, S::Error>
2195+
where
2196+
S: serde::Serializer,
2197+
{
2198+
serializer.serialize_str(network.to_core_arg())
2199+
}
2200+
21932201
/// deserialize_bip70_network deserializes a Bitcoin Core network according to BIP70
21942202
/// The accepted input variants are: {"main", "test", "signet", "regtest"}
21952203
fn deserialize_bip70_network<'de, D>(deserializer: D) -> Result<Network, D::Error>

0 commit comments

Comments
 (0)