(self)
| 35 | type Error = UtilsError; |
| 36 | |
| 37 | fn try_into(self) -> Result<RecoverableSignature> { |
| 38 | let mut signature = [0u8; 64]; |
| 39 | signature[..32].copy_from_slice(self.r.as_bytes()); |
| 40 | signature[32..].copy_from_slice(self.s.as_bytes()); |
| 41 | |
| 42 | let recovery_id_32 = i32::try_from(self.v).map_err(|e| { |
| 43 | UtilsError::ConversionError(format!("could not convert u64 to i32 {}", e)) |
| 44 | })?; |
| 45 | let recovery_id: RecoveryId = RecoveryId::from_i32(recovery_id_32).map_err(|e| { |
| 46 | UtilsError::ConversionError(format!("could not convert i32 to RecoveryId {}", e)) |
| 47 | })?; |
| 48 | let recoverable_signature = RecoverableSignature::from_compact(&signature, recovery_id) |
| 49 | .map_err(|e| { |
| 50 | UtilsError::ConversionError(format!( |
| 51 | "could not convert a signature to a RecoverableSignature {}", |
| 52 | e |
| 53 | )) |
| 54 | })?; |
| 55 | |
| 56 | Ok(recoverable_signature) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | impl TryInto<Vec<u8>> for Signature { |
no outgoing calls
no test coverage detected