From: Matt Corallo Date: Sat, 30 Sep 2023 18:05:10 +0000 (+0000) Subject: Expose `parse_onion_address` publicly in `no-std` X-Git-Tag: v0.0.117~6^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=327142894dc51200255af73721fd58a8187c6021;p=rust-lightning Expose `parse_onion_address` publicly in `no-std` The reason for having a separate `parse_onion_address` from `FromStr` is to have an onion parsing function in `no-std`, but when we added it we forgot to make it public. We do this here, as well as fix a few compilation warnings in `no-std`. --- diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index e4cc1f195..a68ac3521 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -39,10 +39,12 @@ use crate::onion_message; use crate::sign::{NodeSigner, Recipient}; use crate::prelude::*; +#[cfg(feature = "std")] use core::convert::TryFrom; use core::fmt; use core::fmt::Debug; use core::ops::Deref; +#[cfg(feature = "std")] use core::str::FromStr; use crate::io::{self, Cursor, Read}; use crate::io_extras::read_to_end; @@ -956,7 +958,10 @@ impl From for SocketAddress { } } -fn parse_onion_address(host: &str, port: u16) -> Result { +/// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. +/// +/// The host part must end with ".onion". +pub fn parse_onion_address(host: &str, port: u16) -> Result { if host.ends_with(".onion") { let domain = &host[..host.len() - ".onion".len()]; if domain.len() != 56 {