From 8efacd4dda359bffae2120dfd58942637f32a52c Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Tue, 4 Mar 2025 20:43:39 +0100 Subject: [PATCH] Deprecate `PrivateKey::from_slice` method Since arrays better convey the intention than slices when parsing fixed-sized bytes we're migrating to them. This deprecates the `from_slice` method similarly to how we do it elsewhere. --- bitcoin/src/crypto/key.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index ed16e7a72..c1d67bb64 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -468,6 +468,7 @@ impl PrivateKey { } /// Deserializes a private key from a slice. + #[deprecated(since = "TBD", note = "use from_byte_array instead")] pub fn from_slice( data: &[u8], network: impl Into, @@ -1606,6 +1607,8 @@ mod tests { } #[test] + #[allow(deprecated)] // tests the deprecated function + #[allow(deprecated_in_future)] fn invalid_private_key_len() { use crate::Network; assert!(PrivateKey::from_slice(&[1u8; 31], Network::Regtest).is_err());