p2p: change example to use configurable magic param
What changed, and why it matters
This is a one-line fix to a code example so it uses a configurable network parameter instead of always using the regtest network. It is not a security fix and does not change any library behavior.
No security action needed. Treat as a normal example/documentation fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes p2p/examples/ping-pong.rs to pass the already-configurable magic variable into V1NetworkMessage::new() rather than hardcoding Magic::REGTEST. The example previously ignored the user-selected network magic and would fail against mainnet/signet/testnet nodes, making the documented usage broken. This is a documentation/example bugfix with no effect on the rust-bitcoin library code.
Changed components
p2p/examples/ping-pong.rsInspect captured patch +1 / −1
diff --git a/p2p/examples/ping-pong.rs b/p2p/examples/ping-pong.rs
index 2f4f7eb6..4dc19e4b 100644
--- a/p2p/examples/ping-pong.rs
+++ b/p2p/examples/ping-pong.rs
@@ -42,7 +42,7 @@ fn main() {
let remote_socket: SocketAddr = SocketAddr::new(IpAddr::V4(ip), port);
let version_message = build_version_message(remote_socket);
- let version_message = message::V1NetworkMessage::new(Magic::REGTEST, version_message);
+ let version_message = message::V1NetworkMessage::new(magic, version_message);
if let Ok(mut stream) = TcpStream::connect(remote_socket) {
encoding::encode_to_writer(&version_message, &mut stream).unwrap();
Why this scored 15/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.