You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #492: Fix broken serde::Deserialize and FromStr impl of keyPair
1f327b4 Bump version number to v0.24.1 (elsirion)
53c1354 Fix broken `serde::Deserialize` and `FromStr` impl of `keyPair` (elsirion)
Pull request description:
Fixes#491
ACKs for top commit:
apoelstra:
ACK 1f327b4
Tree-SHA512: 1af54667b7a1b310035fa35bd2aeb508e432d8c7f153ae1b9850431ba77dcc3e2194c1cda45a1ed5218d955d9284ba6512cf8ab6dafc673f23ccdad7c601b1b6
Copy file name to clipboardexpand all lines: CHANGELOG.md
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
# 0.24.1 - 2022-10-25
2
+
3
+
*[Fix broken deserialization logic of `KeyPair`](https://github.com/rust-bitcoin/rust-secp256k1/issues/491) that previously always panicked. After the patch deserialization only panics if neither the `global-context` nor the `alloc` (default) feature is active.
let ctx:Secp256k1<crate::SignOnlyPreallocated> = panic!("The previous implementation was panicking too, please enable the global-context feature of rust-secp256k1");
1068
+
1069
+
#[allow(clippy::needless_borrow)]
1063
1070
KeyPair::from_seckey_str(&ctx, s)
1064
1071
}
1065
1072
}
@@ -1093,8 +1100,17 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
1093
1100
}else{
1094
1101
let visitor = super::serde_util::Tuple32Visitor::new(
1095
1102
"raw 32 bytes KeyPair",
1096
-
|data| unsafe{
1097
-
let ctx = Secp256k1::from_raw_all(ffi::secp256k1_context_no_precomp as*mut ffi::Context);
let ctx:Secp256k1<crate::SignOnlyPreallocated> = panic!("The previous implementation was panicking too, please enable the global-context feature of rust-secp256k1");
1112
+
1113
+
#[allow(clippy::needless_borrow)]
1098
1114
KeyPair::from_seckey_slice(&ctx, data)
1099
1115
}
1100
1116
);
@@ -1630,12 +1646,14 @@ pub mod serde_keypair {
1630
1646
#[cfg(test)]
1631
1647
#[allow(unused_imports)]
1632
1648
mod test {
1649
+
use bitcoin_hashes::hex::ToHex;
1633
1650
usesuper::*;
1634
1651
1635
1652
use core::str::FromStr;
1636
1653
1637
1654
#[cfg(any(feature = "alloc", feature = "std"))]
1638
1655
use rand::{Error,RngCore, thread_rng, rngs::mock::StepRng};
0 commit comments