Merge pull request #111 from elichai/display

Removed ffi call from Display implementation
This commit is contained in:
Andrew Poelstra 2019-05-21 20:22:00 +00:00 committed by GitHub
commit 5d9faf2023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 13 deletions

View File

@ -179,19 +179,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl fmt::Display for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut v = [0; 72];
let mut len = v.len() as usize;
unsafe {
let err = ffi::secp256k1_ecdsa_signature_serialize_der(
ffi::secp256k1_context_no_precomp,
v.as_mut_ptr(),
&mut len,
self.as_ptr()
);
debug_assert!(err == 1);
}
for i in 0..len {
write!(f, "{:02x}", v[i])?;
let sig = self.serialize_der();
for v in sig.iter() {
write!(f, "{:02x}", v)?;
}
Ok(())
}