p2p: Remove `Magic::from_params` method
What changed, and why it matters
This commit removes a small helper method called Magic::from_params from the rust-bitcoin peer-to-peer networking crate. The method was redundant because the same conversion can already be done through Rust's standard TryFrom trait. There is no security issue here; it is a routine code cleanup to simplify the public API and remove an unnecessary dependency on the Params type.
No security action needed. Developers using Magic::from_params should migrate to Magic::try_from(params.network()) or equivalent TryFrom usage when updating to a version containing this commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes Magic::from_params(params: impl AsRef
Changed components
p2p/src/lib.rsMagic type public APIInspect captured patch +1 / −6
diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs
index 2d51fb45..21b5a4d3 100644
--- a/p2p/src/lib.rs
+++ b/p2p/src/lib.rs
@@ -36,7 +36,7 @@ use core::{fmt, ops};
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
use bitcoin::consensus::encode::{self, Decodable, Encodable};
-use bitcoin::network::{Network, Params, TestnetVersion};
+use bitcoin::network::{Network, TestnetVersion};
use hex::FromHex;
use internals::impl_to_hex_from_lower_hex;
use io::{BufRead, Write};
@@ -287,11 +287,6 @@ impl Magic {
/// Gets network magic bytes.
pub fn to_bytes(self) -> [u8; 4] { self.0 }
-
- /// Returns the magic bytes for the network defined by `params`.
- pub fn from_params(params: impl AsRef<Params>) -> Option<Self> {
- params.as_ref().network.try_into().ok()
- }
}
impl FromStr for Magic {
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.