@@ -382,7 +382,8 @@ impl std::fmt::Display for Offer {
382382/// This struct can also be used for LN-Address recipients.
383383///
384384/// [Homograph Attacks]: https://en.wikipedia.org/wiki/IDN_homograph_attack
385- #[ derive( uniffi:: Object ) ]
385+ #[ derive( Clone , Copy , Debug , Hash , PartialEq , Eq , uniffi:: Object ) ]
386+ #[ uniffi:: export( Debug , Display , Eq ) ]
386387pub struct HumanReadableName {
387388 pub ( crate ) inner : LdkHumanReadableName ,
388389}
@@ -439,6 +440,12 @@ impl AsRef<LdkHumanReadableName> for HumanReadableName {
439440 }
440441}
441442
443+ impl std:: fmt:: Display for HumanReadableName {
444+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
445+ write ! ( f, "{}" , self . inner)
446+ }
447+ }
448+
442449/// A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`].
443450///
444451/// Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to
@@ -1987,4 +1994,21 @@ mod tests {
19871994
19881995 assert_eq ! ( ldk_invoice. signable_hash( ) . to_vec( ) , wrapped_invoice. signable_hash( ) ) ;
19891996 }
1997+
1998+ #[ test]
1999+ fn test_hrn_traits ( ) {
2000+ let encoded = "alice@lightning.space" ;
2001+ let hrn1 = HumanReadableName :: from_encoded ( encoded) . unwrap ( ) ;
2002+ let hrn2 = HumanReadableName :: from_encoded ( encoded) . unwrap ( ) ;
2003+
2004+ assert_eq ! ( hrn1. to_string( ) , "₿alice@lightning.space" ) ;
2005+
2006+ assert_eq ! ( hrn1, hrn2) ;
2007+
2008+ let debug_output = format ! ( "{:?}" , hrn1) ;
2009+ assert ! ( debug_output. contains( "HumanReadableName" ) ) ;
2010+
2011+ let hrn3 = hrn1;
2012+ assert_eq ! ( hrn1, hrn3) ;
2013+ }
19902014}
0 commit comments