Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lightning/src/onion_message/dns_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use dnssec_prover::rr::Name;

use lightning_types::features::NodeFeatures;

use core::fmt;

use crate::blinded_path::message::DNSResolverContext;
use crate::io;
#[cfg(feature = "dnssec")]
Expand Down Expand Up @@ -287,6 +289,12 @@ impl Readable for HumanReadableName {
}
}

impl fmt::Display for HumanReadableName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "₿{}@{}", self.user(), self.domain())
}
}

#[cfg(feature = "dnssec")]
struct PendingResolution {
start_height: u32,
Expand Down Expand Up @@ -473,3 +481,24 @@ impl OMNameResolver {
None
}
}

#[cfg(test)]
mod tests {
use super::HumanReadableName;

#[test]
fn test_hrn_display_format() {
let user = "user";
let domain = "example.com";
let hrn = HumanReadableName::new(user, domain)
.expect("Failed to create HumanReadableName for user");

// Assert that the formatted string matches the expected output
let expected_display = format!("₿{}@{}", user, domain);
assert_eq!(
format!("{}", hrn),
expected_display,
"HumanReadableName display format mismatch"
);
}
}
Loading