Skip to content

Commit 3271428

Browse files
committed
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`.
1 parent 20f287f commit 3271428

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lightning/src/ln/msgs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ use crate::onion_message;
3939
use crate::sign::{NodeSigner, Recipient};
4040

4141
use crate::prelude::*;
42+
#[cfg(feature = "std")]
4243
use core::convert::TryFrom;
4344
use core::fmt;
4445
use core::fmt::Debug;
4546
use core::ops::Deref;
47+
#[cfg(feature = "std")]
4648
use core::str::FromStr;
4749
use crate::io::{self, Cursor, Read};
4850
use crate::io_extras::read_to_end;
@@ -956,7 +958,10 @@ impl From<std::net::SocketAddr> for SocketAddress {
956958
}
957959
}
958960

959-
fn parse_onion_address(host: &str, port: u16) -> Result<SocketAddress, SocketAddressParseError> {
961+
/// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
962+
///
963+
/// The host part must end with ".onion".
964+
pub fn parse_onion_address(host: &str, port: u16) -> Result<SocketAddress, SocketAddressParseError> {
960965
if host.ends_with(".onion") {
961966
let domain = &host[..host.len() - ".onion".len()];
962967
if domain.len() != 56 {

0 commit comments

Comments
 (0)