X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=src%2Futil%2Fser.rs;h=d832c7018825e75df028bd2e2b8ea538962cc0e3;hb=2950ffe54e480610dcaf0188a8f556165bbe7efe;hp=78fd4c1ce8ab8a77e5e747c390d12520205a68e2;hpb=70d06b46106a49d1434ac168175859278db92620;p=rust-lightning diff --git a/src/util/ser.rs b/src/util/ser.rs index 78fd4c1c..d832c701 100644 --- a/src/util/ser.rs +++ b/src/util/ser.rs @@ -6,7 +6,7 @@ use std::io::{Read, Write}; use std::collections::HashMap; use std::hash::Hash; -use secp256k1::{Secp256k1, Signature}; +use secp256k1::Signature; use secp256k1::key::{PublicKey, SecretKey}; use bitcoin::util::hash::Sha256dHash; use bitcoin::blockdata::script::Script; @@ -203,6 +203,10 @@ macro_rules! impl_array { } //TODO: performance issue with [u8; size] with impl_array!() +impl_array!(3); // for rgb +impl_array!(4); // for IPv4 +impl_array!(10); // for OnionV2 +impl_array!(16); // for IPv6 impl_array!(32); // for channel id & hmac impl_array!(33); // for PublicKey impl_array!(64); // for Signature @@ -311,7 +315,7 @@ impl Writeable for PublicKey { impl Readable for PublicKey { fn read(r: &mut R) -> Result { let buf: [u8; 33] = Readable::read(r)?; - match PublicKey::from_slice(&Secp256k1::without_caps(), &buf) { + match PublicKey::from_slice(&buf) { Ok(key) => Ok(key), Err(_) => return Err(DecodeError::InvalidValue), } @@ -329,7 +333,7 @@ impl Writeable for SecretKey { impl Readable for SecretKey { fn read(r: &mut R) -> Result { let buf: [u8; 32] = Readable::read(r)?; - match SecretKey::from_slice(&Secp256k1::without_caps(), &buf) { + match SecretKey::from_slice(&buf) { Ok(key) => Ok(key), Err(_) => return Err(DecodeError::InvalidValue), } @@ -351,14 +355,14 @@ impl Readable for Sha256dHash { impl Writeable for Signature { fn write(&self, w: &mut W) -> Result<(), ::std::io::Error> { - self.serialize_compact(&Secp256k1::without_caps()).write(w) + self.serialize_compact().write(w) } } impl Readable for Signature { fn read(r: &mut R) -> Result { let buf: [u8; 64] = Readable::read(r)?; - match Signature::from_compact(&Secp256k1::without_caps(), &buf) { + match Signature::from_compact(&buf) { Ok(sig) => Ok(sig), Err(_) => return Err(DecodeError::InvalidValue), }