Skip to content

Commit

Permalink
Merge pull request #2633 from TheBlueMatt/2023-09-expose-onion-parse
Browse files Browse the repository at this point in the history
Expose `parse_onion_address` publicly in `no-std`
  • Loading branch information
jkczyz authored Oct 3, 2023
2 parents 20f287f + 3271428 commit 9b1b724
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -956,7 +958,10 @@ impl From<std::net::SocketAddr> for SocketAddress {
}
}

fn parse_onion_address(host: &str, port: u16) -> Result<SocketAddress, SocketAddressParseError> {
/// 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<SocketAddress, SocketAddressParseError> {
if host.ends_with(".onion") {
let domain = &host[..host.len() - ".onion".len()];
if domain.len() != 56 {
Expand Down

0 comments on commit 9b1b724

Please sign in to comment.