message: allow encoding XPrv in humean readable format too
diff: @@ -208,9 +208,13 @@ impl serde::Serialize for XPrv
  fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
  where S: serde::Serializer,
  {
  + if serializer.is_human_readable() {
  + serializer.serialize_str(&hex::encode(self.as_ref()))
  + } else {
  serializer.serialize_bytes(self.as_ref())
  }
  }
  +}
  struct XPrvVisitor();
  impl XPrvVisitor { fn new() -> Self { XPrvVisitor {} } }
  impl<'de> serde::de::Visitor<'de> for XPrvVisitor {
  @@ -220,6 +224,16 @@ impl<'de> serde::de::Visitor<'de> for XPrvVisitor {
  write!(fmt, "Expecting an Extended Private Key (`XPrv`) of {} bytes.", XPRV_SIZE)
  }
  + fn visit_str<'a, E>(self, v: &'a str) -> Result<Self::Value, E>
  + where E: serde::de::Error
  + {
  + let bytes = hex::decode(v);
  +
  + match XPrv::from_slice(&bytes) {
  + None => Err(E::invalid_length(bytes.len(), &"96 bytes")),
  + Some(xpub) => Ok(xpub)
  + }
  + }
  fn visit_bytes<'a, E>(self, v: &'a [u8]) -> Result<Self::Value, E>
  where E: serde::de::Error
  {
  @@ -234,9 +248,13 @@ impl<'de> serde::Deserialize<'de> for XPrv
  fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
  where D: serde::Deserializer<'de>
  {
  + if deserializer.is_human_readable() {
  + deserializer.deserialize_str(XPrvVisitor::new())
  + } else {
  deserializer.deserialize_bytes(XPrvVisitor::new())
  }
  }
  +}
  #[derive(Clone, Copy)]
  pub struct XPub([u8; XPUB_SIZE]);
  