Skip to content

Commit 9b1b724

Browse files
authored
Merge pull request #2633 from TheBlueMatt/2023-09-expose-onion-parse
Expose `parse_onion_address` publicly in `no-std`
2 parents 20f287f + 3271428 commit 9b1b724

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lightning/src/ln/msgs.rs

+6-1
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)