22
33use crate :: { Bolt11Invoice , CreationError , Currency , InvoiceBuilder , SignOrCreationError } ;
44
5- use crate :: { prelude:: * , Description , InvoiceDescription , Sha256 } ;
5+ use crate :: { prelude:: * , Description , Bolt11InvoiceDescription , Sha256 } ;
66use bech32:: ToBase32 ;
77use bitcoin_hashes:: Hash ;
88use lightning:: chain;
7171 L :: Target : Logger ,
7272{
7373 let description = Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?;
74- let description = InvoiceDescription :: Direct ( & description, ) ;
74+ let description = Bolt11InvoiceDescription :: Direct ( & description, ) ;
7575 _create_phantom_invoice :: < ES , NS , L > (
7676 amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints,
7777 entropy_source, node_signer, logger, network, min_final_cltv_expiry_delta, duration_since_epoch,
@@ -127,7 +127,7 @@ where
127127 L :: Target : Logger ,
128128{
129129 _create_phantom_invoice :: < ES , NS , L > (
130- amt_msat, payment_hash, InvoiceDescription :: Hash ( & description_hash) ,
130+ amt_msat, payment_hash, Bolt11InvoiceDescription :: Hash ( & description_hash) ,
131131 invoice_expiry_delta_secs, phantom_route_hints, entropy_source, node_signer, logger, network,
132132 min_final_cltv_expiry_delta, duration_since_epoch,
133133 )
@@ -136,7 +136,7 @@ where
136136const MAX_CHANNEL_HINTS : usize = 3 ;
137137
138138fn _create_phantom_invoice < ES : Deref , NS : Deref , L : Deref > (
139- amt_msat : Option < u64 > , payment_hash : Option < PaymentHash > , description : InvoiceDescription ,
139+ amt_msat : Option < u64 > , payment_hash : Option < PaymentHash > , description : Bolt11InvoiceDescription ,
140140 invoice_expiry_delta_secs : u32 , phantom_route_hints : Vec < PhantomRouteHints > , entropy_source : ES ,
141141 node_signer : NS , logger : L , network : Currency , min_final_cltv_expiry_delta : Option < u16 > , duration_since_epoch : Duration ,
142142) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
@@ -157,10 +157,10 @@ where
157157 }
158158
159159 let invoice = match description {
160- InvoiceDescription :: Direct ( description) => {
160+ Bolt11InvoiceDescription :: Direct ( description) => {
161161 InvoiceBuilder :: new ( network) . description ( description. 0 . clone ( ) )
162162 }
163- InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
163+ Bolt11InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
164164 } ;
165165
166166 // If we ever see performance here being too slow then we should probably take this ExpandedKey as a parameter instead.
@@ -417,7 +417,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
417417{
418418 _create_invoice_from_channelmanager_and_duration_since_epoch (
419419 channelmanager, node_signer, logger, network, amt_msat,
420- InvoiceDescription :: Hash ( & description_hash) ,
420+ Bolt11InvoiceDescription :: Hash ( & description_hash) ,
421421 duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta,
422422 )
423423}
@@ -442,7 +442,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T:
442442{
443443 _create_invoice_from_channelmanager_and_duration_since_epoch (
444444 channelmanager, node_signer, logger, network, amt_msat,
445- InvoiceDescription :: Direct (
445+ Bolt11InvoiceDescription :: Direct (
446446 & Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
447447 ) ,
448448 duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta,
@@ -451,7 +451,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T:
451451
452452fn _create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , ES : Deref , NS : Deref , SP : Deref , F : Deref , R : Deref , L : Deref > (
453453 channelmanager : & ChannelManager < M , T , ES , NS , SP , F , R , L > , node_signer : NS , logger : L ,
454- network : Currency , amt_msat : Option < u64 > , description : InvoiceDescription ,
454+ network : Currency , amt_msat : Option < u64 > , description : Bolt11InvoiceDescription ,
455455 duration_since_epoch : Duration , invoice_expiry_delta_secs : u32 , min_final_cltv_expiry_delta : Option < u16 > ,
456456) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
457457 where
@@ -503,7 +503,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_
503503 . map_err ( |( ) | SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?;
504504 _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash (
505505 channelmanager, node_signer, logger, network, amt_msat,
506- InvoiceDescription :: Direct (
506+ Bolt11InvoiceDescription :: Direct (
507507 & Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
508508 ) ,
509509 duration_since_epoch, invoice_expiry_delta_secs, payment_hash, payment_secret,
@@ -513,9 +513,9 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_
513513
514514fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash < M : Deref , T : Deref , ES : Deref , NS : Deref , SP : Deref , F : Deref , R : Deref , L : Deref > (
515515 channelmanager : & ChannelManager < M , T , ES , NS , SP , F , R , L > , node_signer : NS , logger : L ,
516- network : Currency , amt_msat : Option < u64 > , description : InvoiceDescription , duration_since_epoch : Duration ,
517- invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash , payment_secret : PaymentSecret ,
518- min_final_cltv_expiry_delta : Option < u16 > ,
516+ network : Currency , amt_msat : Option < u64 > , description : Bolt11InvoiceDescription ,
517+ duration_since_epoch : Duration , invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash ,
518+ payment_secret : PaymentSecret , min_final_cltv_expiry_delta : Option < u16 > ,
519519) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
520520 where
521521 M :: Target : chain:: Watch < <SP :: Target as SignerProvider >:: Signer > ,
@@ -537,10 +537,10 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_has
537537 log_trace ! ( logger, "Creating invoice with payment hash {}" , log_bytes!( payment_hash. 0 ) ) ;
538538
539539 let invoice = match description {
540- InvoiceDescription :: Direct ( description) => {
540+ Bolt11InvoiceDescription :: Direct ( description) => {
541541 InvoiceBuilder :: new ( network) . description ( description. 0 . clone ( ) )
542542 }
543- InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
543+ Bolt11InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
544544 } ;
545545
546546 let mut invoice = invoice
@@ -794,7 +794,7 @@ fn prefer_current_channel(min_inbound_capacity_msat: Option<u64>, current_channe
794794mod test {
795795 use core:: cell:: RefCell ;
796796 use core:: time:: Duration ;
797- use crate :: { Currency , Description , InvoiceDescription , SignOrCreationError , CreationError } ;
797+ use crate :: { Currency , Description , Bolt11InvoiceDescription , SignOrCreationError , CreationError } ;
798798 use bitcoin_hashes:: { Hash , sha256} ;
799799 use bitcoin_hashes:: sha256:: Hash as Sha256 ;
800800 use lightning:: sign:: PhantomKeysManager ;
@@ -852,7 +852,7 @@ mod test {
852852 assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
853853 // If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
854854 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
855- assert_eq ! ( invoice. description( ) , InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
855+ assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
856856 assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
857857
858858 // Invoice SCIDs should always use inbound SCID aliases over the real channel ID, if one is
@@ -948,7 +948,7 @@ mod test {
948948 ) . unwrap ( ) ;
949949 assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
950950 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
951- assert_eq ! ( invoice. description( ) , InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
951+ assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
952952 }
953953
954954 #[ test]
@@ -965,7 +965,7 @@ mod test {
965965 ) . unwrap ( ) ;
966966 assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
967967 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
968- assert_eq ! ( invoice. description( ) , InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
968+ assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
969969 assert_eq ! ( invoice. payment_hash( ) , & sha256:: Hash :: from_slice( & payment_hash. 0 [ ..] ) . unwrap( ) ) ;
970970 }
971971
@@ -1317,7 +1317,7 @@ mod test {
13171317 } ;
13181318
13191319 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
1320- assert_eq ! ( invoice. description( ) , InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
1320+ assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
13211321 assert_eq ! ( invoice. route_hints( ) . len( ) , 2 ) ;
13221322 assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
13231323 assert ! ( !invoice. features( ) . unwrap( ) . supports_basic_mpp( ) ) ;
@@ -1455,7 +1455,7 @@ mod test {
14551455 assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 200_000 ) ) ;
14561456 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
14571457 assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
1458- assert_eq ! ( invoice. description( ) , InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Description hash phantom invoice" . as_bytes( ) ) ) ) ) ;
1458+ assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Description hash phantom invoice" . as_bytes( ) ) ) ) ) ;
14591459 }
14601460
14611461 #[ test]
0 commit comments