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
26 changes: 25 additions & 1 deletion src/ffi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ impl std::fmt::Display for Offer {
/// This struct can also be used for LN-Address recipients.
///
/// [Homograph Attacks]: https://en.wikipedia.org/wiki/IDN_homograph_attack
#[derive(uniffi::Object)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, uniffi::Object)]
#[uniffi::export(Debug, Display, Eq)]
pub struct HumanReadableName {
pub(crate) inner: LdkHumanReadableName,
}
Expand Down Expand Up @@ -439,6 +440,12 @@ impl AsRef<LdkHumanReadableName> for HumanReadableName {
}
}

impl std::fmt::Display for HumanReadableName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.inner)
}
}

/// A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`].
///
/// Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to
Expand Down Expand Up @@ -1987,4 +1994,21 @@ mod tests {

assert_eq!(ldk_invoice.signable_hash().to_vec(), wrapped_invoice.signable_hash());
}

#[test]
fn test_hrn_traits() {
let encoded = "alice@lightning.space";
let hrn1 = HumanReadableName::from_encoded(encoded).unwrap();
let hrn2 = HumanReadableName::from_encoded(encoded).unwrap();

assert_eq!(hrn1.to_string(), "₿alice@lightning.space");

assert_eq!(hrn1, hrn2);

let debug_output = format!("{:?}", hrn1);
assert!(debug_output.contains("HumanReadableName"));

let hrn3 = hrn1;
assert_eq!(hrn1, hrn3);
}
}
Loading