Merge pull request #111 from elichai/display
Removed ffi call from Display implementation
This commit is contained in:
commit
5d9faf2023
16
src/lib.rs
16
src/lib.rs
|
@ -179,19 +179,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
|
||||||
impl fmt::Display for Signature {
|
impl fmt::Display for Signature {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut v = [0; 72];
|
let sig = self.serialize_der();
|
||||||
let mut len = v.len() as usize;
|
for v in sig.iter() {
|
||||||
unsafe {
|
write!(f, "{:02x}", v)?;
|
||||||
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])?;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue