@@ -73,6 +73,7 @@ pub use lightning::ln::PaymentSecret;
7373pub use lightning:: routing:: router:: { RouteHint , RouteHintHop } ;
7474#[ doc( no_inline) ]
7575pub use lightning:: routing:: gossip:: RoutingFees ;
76+ use lightning:: util:: string:: UntrustedString ;
7677
7778mod de;
7879mod ser;
@@ -269,6 +270,15 @@ pub enum Bolt11InvoiceDescription<'f> {
269270 Hash ( & ' f Sha256 ) ,
270271}
271272
273+ impl < ' f > Display for Bolt11InvoiceDescription < ' f > {
274+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
275+ match self {
276+ Bolt11InvoiceDescription :: Direct ( desc) => write ! ( f, "{}" , desc. 0 ) ,
277+ Bolt11InvoiceDescription :: Hash ( hash) => write ! ( f, "{}" , hash. 0 ) ,
278+ }
279+ }
280+ }
281+
272282/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
273283/// invalid.
274284///
@@ -470,8 +480,8 @@ impl Sha256 {
470480///
471481/// # Invariants
472482/// The description can be at most 639 __bytes__ long
473- #[ derive( Clone , Debug , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
474- pub struct Description ( String ) ;
483+ #[ derive( Clone , Debug , Hash , Eq , PartialEq , Ord , PartialOrd , Default ) ]
484+ pub struct Description ( UntrustedString ) ;
475485
476486/// Payee public key
477487#[ derive( Clone , Debug , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
@@ -520,7 +530,7 @@ impl Ord for Bolt11InvoiceSignature {
520530/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
521531///
522532#[ derive( Clone , Debug , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
523- pub struct PrivateRoute ( RouteHint ) ;
533+ pub struct PrivateRoute ( pub RouteHint ) ;
524534
525535/// Tag constants as specified in BOLT11
526536#[ allow( missing_docs) ]
@@ -675,7 +685,7 @@ impl<H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool> InvoiceBui
675685 pub fn invoice_description ( self , description : Bolt11InvoiceDescription ) -> InvoiceBuilder < tb:: True , H , T , C , S , M > {
676686 match description {
677687 Bolt11InvoiceDescription :: Direct ( desc) => {
678- self . description ( desc. clone ( ) . into_inner ( ) )
688+ self . description ( desc. clone ( ) . into_inner ( ) . 0 )
679689 }
680690 Bolt11InvoiceDescription :: Hash ( hash) => {
681691 self . description_hash ( hash. 0 )
@@ -1136,6 +1146,12 @@ impl PositiveTimestamp {
11361146 }
11371147}
11381148
1149+ impl From < PositiveTimestamp > for Duration {
1150+ fn from ( val : PositiveTimestamp ) -> Self {
1151+ val. 0
1152+ }
1153+ }
1154+
11391155#[ cfg( feature = "std" ) ]
11401156impl From < PositiveTimestamp > for SystemTime {
11411157 fn from ( val : PositiveTimestamp ) -> Self {
@@ -1502,27 +1518,19 @@ impl Description {
15021518 if description. len ( ) > 639 {
15031519 Err ( CreationError :: DescriptionTooLong )
15041520 } else {
1505- Ok ( Description ( description) )
1521+ Ok ( Description ( UntrustedString ( description) ) )
15061522 }
15071523 }
15081524
1509- /// Returns the underlying description [`String `]
1510- pub fn into_inner ( self ) -> String {
1525+ /// Returns the underlying description [`UntrustedString `]
1526+ pub fn into_inner ( self ) -> UntrustedString {
15111527 self . 0
15121528 }
15131529}
15141530
1515- impl From < Description > for String {
1516- fn from ( val : Description ) -> Self {
1517- val. into_inner ( )
1518- }
1519- }
1520-
1521- impl Deref for Description {
1522- type Target = str ;
1523-
1524- fn deref ( & self ) -> & str {
1525- & self . 0
1531+ impl Display for Description {
1532+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
1533+ write ! ( f, "{}" , self . 0 )
15261534 }
15271535}
15281536
0 commit comments