diff --git a/stackslib/src/chainstate/stacks/boot/mod.rs b/stackslib/src/chainstate/stacks/boot/mod.rs index 67f485429b..4347afcdc9 100644 --- a/stackslib/src/chainstate/stacks/boot/mod.rs +++ b/stackslib/src/chainstate/stacks/boot/mod.rs @@ -213,10 +213,30 @@ fn hex_deserialize<'de, D: serde::Deserializer<'de>>( Ok(bytes) } +fn serialize_u128_as_string(value: &u128, serializer: S) -> Result +where + S: serde::Serializer, +{ + serializer.serialize_str(&value.to_string()) +} + +fn deserialize_u128_from_string<'de, D>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, +{ + use std::str::FromStr; + let s = String::deserialize(deserializer)?; + u128::from_str(&s).map_err(serde::de::Error::custom) +} + #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct NakamotoSignerEntry { #[serde(serialize_with = "hex_serialize", deserialize_with = "hex_deserialize")] pub signing_key: [u8; 33], + #[serde( + serialize_with = "serialize_u128_as_string", + deserialize_with = "deserialize_u128_from_string" + )] pub stacked_amt: u128, pub weight: u32, }