2
2
3
3
use crate :: { Bolt11Invoice , CreationError , Currency , InvoiceBuilder , SignOrCreationError } ;
4
4
5
- use crate :: { prelude:: * , Description , InvoiceDescription , Sha256 } ;
5
+ use crate :: { prelude:: * , Description , Bolt11InvoiceDescription , Sha256 } ;
6
6
use bech32:: ToBase32 ;
7
7
use bitcoin_hashes:: Hash ;
8
8
use lightning:: chain;
71
71
L :: Target : Logger ,
72
72
{
73
73
let description = Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?;
74
- let description = InvoiceDescription :: Direct ( & description, ) ;
74
+ let description = Bolt11InvoiceDescription :: Direct ( & description, ) ;
75
75
_create_phantom_invoice :: < ES , NS , L > (
76
76
amt_msat, payment_hash, description, invoice_expiry_delta_secs, phantom_route_hints,
77
77
entropy_source, node_signer, logger, network, min_final_cltv_expiry_delta, duration_since_epoch,
@@ -127,7 +127,7 @@ where
127
127
L :: Target : Logger ,
128
128
{
129
129
_create_phantom_invoice :: < ES , NS , L > (
130
- amt_msat, payment_hash, InvoiceDescription :: Hash ( & description_hash) ,
130
+ amt_msat, payment_hash, Bolt11InvoiceDescription :: Hash ( & description_hash) ,
131
131
invoice_expiry_delta_secs, phantom_route_hints, entropy_source, node_signer, logger, network,
132
132
min_final_cltv_expiry_delta, duration_since_epoch,
133
133
)
@@ -136,7 +136,7 @@ where
136
136
const MAX_CHANNEL_HINTS : usize = 3 ;
137
137
138
138
fn _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 ,
140
140
invoice_expiry_delta_secs : u32 , phantom_route_hints : Vec < PhantomRouteHints > , entropy_source : ES ,
141
141
node_signer : NS , logger : L , network : Currency , min_final_cltv_expiry_delta : Option < u16 > , duration_since_epoch : Duration ,
142
142
) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
@@ -157,10 +157,10 @@ where
157
157
}
158
158
159
159
let invoice = match description {
160
- InvoiceDescription :: Direct ( description) => {
160
+ Bolt11InvoiceDescription :: Direct ( description) => {
161
161
InvoiceBuilder :: new ( network) . description ( description. 0 . clone ( ) )
162
162
}
163
- InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
163
+ Bolt11InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
164
164
} ;
165
165
166
166
// 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
417
417
{
418
418
_create_invoice_from_channelmanager_and_duration_since_epoch (
419
419
channelmanager, node_signer, logger, network, amt_msat,
420
- InvoiceDescription :: Hash ( & description_hash) ,
420
+ Bolt11InvoiceDescription :: Hash ( & description_hash) ,
421
421
duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta,
422
422
)
423
423
}
@@ -442,7 +442,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T:
442
442
{
443
443
_create_invoice_from_channelmanager_and_duration_since_epoch (
444
444
channelmanager, node_signer, logger, network, amt_msat,
445
- InvoiceDescription :: Direct (
445
+ Bolt11InvoiceDescription :: Direct (
446
446
& Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
447
447
) ,
448
448
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:
451
451
452
452
fn _create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , ES : Deref , NS : Deref , SP : Deref , F : Deref , R : Deref , L : Deref > (
453
453
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 ,
455
455
duration_since_epoch : Duration , invoice_expiry_delta_secs : u32 , min_final_cltv_expiry_delta : Option < u16 > ,
456
456
) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
457
457
where
@@ -503,7 +503,7 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_
503
503
. map_err ( |( ) | SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?;
504
504
_create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash (
505
505
channelmanager, node_signer, logger, network, amt_msat,
506
- InvoiceDescription :: Direct (
506
+ Bolt11InvoiceDescription :: Direct (
507
507
& Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
508
508
) ,
509
509
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_
513
513
514
514
fn _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 > (
515
515
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 > ,
519
519
) -> Result < Bolt11Invoice , SignOrCreationError < ( ) > >
520
520
where
521
521
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
537
537
log_trace ! ( logger, "Creating invoice with payment hash {}" , log_bytes!( payment_hash. 0 ) ) ;
538
538
539
539
let invoice = match description {
540
- InvoiceDescription :: Direct ( description) => {
540
+ Bolt11InvoiceDescription :: Direct ( description) => {
541
541
InvoiceBuilder :: new ( network) . description ( description. 0 . clone ( ) )
542
542
}
543
- InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
543
+ Bolt11InvoiceDescription :: Hash ( hash) => InvoiceBuilder :: new ( network) . description_hash ( hash. 0 ) ,
544
544
} ;
545
545
546
546
let mut invoice = invoice
@@ -794,7 +794,7 @@ fn prefer_current_channel(min_inbound_capacity_msat: Option<u64>, current_channe
794
794
mod test {
795
795
use core:: cell:: RefCell ;
796
796
use core:: time:: Duration ;
797
- use crate :: { Currency , Description , InvoiceDescription , SignOrCreationError , CreationError } ;
797
+ use crate :: { Currency , Description , Bolt11InvoiceDescription , SignOrCreationError , CreationError } ;
798
798
use bitcoin_hashes:: { Hash , sha256} ;
799
799
use bitcoin_hashes:: sha256:: Hash as Sha256 ;
800
800
use lightning:: sign:: PhantomKeysManager ;
@@ -852,7 +852,7 @@ mod test {
852
852
assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
853
853
// If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
854
854
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( ) ) ) ) ;
856
856
assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
857
857
858
858
// Invoice SCIDs should always use inbound SCID aliases over the real channel ID, if one is
@@ -948,7 +948,7 @@ mod test {
948
948
) . unwrap ( ) ;
949
949
assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
950
950
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( ) ) ) ) ) ;
952
952
}
953
953
954
954
#[ test]
@@ -965,7 +965,7 @@ mod test {
965
965
) . unwrap ( ) ;
966
966
assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
967
967
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( ) ) ) ) ;
969
969
assert_eq ! ( invoice. payment_hash( ) , & sha256:: Hash :: from_slice( & payment_hash. 0 [ ..] ) . unwrap( ) ) ;
970
970
}
971
971
@@ -1317,7 +1317,7 @@ mod test {
1317
1317
} ;
1318
1318
1319
1319
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( ) ) ) ) ;
1321
1321
assert_eq ! ( invoice. route_hints( ) . len( ) , 2 ) ;
1322
1322
assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
1323
1323
assert ! ( !invoice. features( ) . unwrap( ) . supports_basic_mpp( ) ) ;
@@ -1455,7 +1455,7 @@ mod test {
1455
1455
assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 200_000 ) ) ;
1456
1456
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
1457
1457
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( ) ) ) ) ) ;
1459
1459
}
1460
1460
1461
1461
#[ test]
0 commit comments