Skip to content

Commit 7d9eb3f

Browse files
committed
Display onion v2 in bytes
1 parent 4ec46a7 commit 7d9eb3f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lightning/src/ln/msgs.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,9 @@ pub fn parse_onion_address(host: &str, port: u16) -> Result<SocketAddress, Socke
985985
}
986986
}
987987

988-
/// [`SocketAddress::OnionV2`] to onion address string
988+
/// [`SocketAddress::OnionV2`] to debug represent
989989
pub fn to_onion_v2_string(bytes: &[u8; 12]) -> String {
990-
let onion = base32::Alphabet::RFC4648 { padding: false }.encode(&bytes[..10]);
991-
let port = u16::from_be_bytes([bytes[10], bytes[11]]);
992-
format!("{}.onion:{}", onion, port)
990+
format!("OnionV2({:?})", bytes)
993991
}
994992

995993
/// [`SocketAddress::OnionV3`] to onion address string
@@ -4128,7 +4126,7 @@ mod tests {
41284126
assert_eq!(hostname, SocketAddress::from_str(&hostname.to_string()).unwrap());
41294127

41304128
let onion_v2 = SocketAddress::OnionV2 ([40, 4, 64, 185, 202, 19, 162, 75, 90, 200, 38, 7],);
4131-
assert_eq!("FACEBOOKCOREWWWI.onion:9735", &onion_v2.to_string());
4129+
assert_eq!("OnionV2([40, 4, 64, 185, 202, 19, 162, 75, 90, 200, 38, 7])", &onion_v2.to_string());
41324130
assert_eq!(Err(SocketAddressParseError::InvalidOnionV3), SocketAddress::from_str("FACEBOOKCOREWWWI.onion:9735"));
41334131

41344132
let onion_v3 = SocketAddress::OnionV3 {

0 commit comments

Comments
 (0)