31
31
//! # use lightning::offers::invoice::BlindedPayInfo;
32
32
//! # use lightning::blinded_path::BlindedPath;
33
33
//! #
34
- //! # fn create_payment_paths() -> Vec<(BlindedPath, BlindedPayInfo )> { unimplemented!() }
34
+ //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath )> { unimplemented!() }
35
35
//! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
36
36
//! #
37
37
//! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::ParseError> {
@@ -166,7 +166,7 @@ impl SigningPubkeyStrategy for DerivedSigningPubkey {}
166
166
167
167
impl < ' a > InvoiceBuilder < ' a , ExplicitSigningPubkey > {
168
168
pub ( super ) fn for_offer (
169
- invoice_request : & ' a InvoiceRequest , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > ,
169
+ invoice_request : & ' a InvoiceRequest , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
170
170
created_at : Duration , payment_hash : PaymentHash
171
171
) -> Result < Self , SemanticError > {
172
172
let amount_msats = Self :: check_amount_msats ( invoice_request) ?;
@@ -182,7 +182,7 @@ impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
182
182
}
183
183
184
184
pub ( super ) fn for_refund (
185
- refund : & ' a Refund , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
185
+ refund : & ' a Refund , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > , created_at : Duration ,
186
186
payment_hash : PaymentHash , signing_pubkey : PublicKey
187
187
) -> Result < Self , SemanticError > {
188
188
let amount_msats = refund. amount_msats ( ) ;
@@ -199,7 +199,7 @@ impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
199
199
200
200
impl < ' a > InvoiceBuilder < ' a , DerivedSigningPubkey > {
201
201
pub ( super ) fn for_offer_using_keys (
202
- invoice_request : & ' a InvoiceRequest , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > ,
202
+ invoice_request : & ' a InvoiceRequest , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
203
203
created_at : Duration , payment_hash : PaymentHash , keys : KeyPair
204
204
) -> Result < Self , SemanticError > {
205
205
let amount_msats = Self :: check_amount_msats ( invoice_request) ?;
@@ -215,7 +215,7 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
215
215
}
216
216
217
217
pub ( super ) fn for_refund_using_keys (
218
- refund : & ' a Refund , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
218
+ refund : & ' a Refund , payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > , created_at : Duration ,
219
219
payment_hash : PaymentHash , keys : KeyPair ,
220
220
) -> Result < Self , SemanticError > {
221
221
let amount_msats = refund. amount_msats ( ) ;
@@ -247,7 +247,7 @@ impl<'a, S: SigningPubkeyStrategy> InvoiceBuilder<'a, S> {
247
247
}
248
248
249
249
fn fields (
250
- payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
250
+ payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > , created_at : Duration ,
251
251
payment_hash : PaymentHash , amount_msats : u64 , signing_pubkey : PublicKey
252
252
) -> InvoiceFields {
253
253
InvoiceFields {
@@ -454,7 +454,7 @@ enum InvoiceContents {
454
454
/// Invoice-specific fields for an `invoice` message.
455
455
#[ derive( Clone , Debug , PartialEq ) ]
456
456
struct InvoiceFields {
457
- payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > ,
457
+ payment_paths : Vec < ( BlindedPayInfo , BlindedPath ) > ,
458
458
created_at : Duration ,
459
459
relative_expiry : Option < Duration > ,
460
460
payment_hash : PaymentHash ,
@@ -476,7 +476,7 @@ impl Invoice {
476
476
///
477
477
/// Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this
478
478
/// privacy is lost if a public node id is used for [`Invoice::signing_pubkey`].
479
- pub fn payment_paths ( & self ) -> & [ ( BlindedPath , BlindedPayInfo ) ] {
479
+ pub fn payment_paths ( & self ) -> & [ ( BlindedPayInfo , BlindedPath ) ] {
480
480
& self . contents . fields ( ) . payment_paths [ ..]
481
481
}
482
482
@@ -703,8 +703,8 @@ impl InvoiceFields {
703
703
} ;
704
704
705
705
InvoiceTlvStreamRef {
706
- paths : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( path , _ ) | path) ) ) ,
707
- blindedpay : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( _ , payinfo ) | payinfo) ) ) ,
706
+ paths : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( _ , path ) | path) ) ) ,
707
+ blindedpay : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( payinfo , _ ) | payinfo) ) ) ,
708
708
created_at : Some ( self . created_at . as_secs ( ) ) ,
709
709
relative_expiry : self . relative_expiry . map ( |duration| duration. as_secs ( ) as u32 ) ,
710
710
payment_hash : Some ( & self . payment_hash ) ,
@@ -750,13 +750,13 @@ tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, {
750
750
} ) ;
751
751
752
752
type BlindedPathIter < ' a > = core:: iter:: Map <
753
- core:: slice:: Iter < ' a , ( BlindedPath , BlindedPayInfo ) > ,
754
- for <' r > fn ( & ' r ( BlindedPath , BlindedPayInfo ) ) -> & ' r BlindedPath ,
753
+ core:: slice:: Iter < ' a , ( BlindedPayInfo , BlindedPath ) > ,
754
+ for <' r > fn ( & ' r ( BlindedPayInfo , BlindedPath ) ) -> & ' r BlindedPath ,
755
755
> ;
756
756
757
757
type BlindedPayInfoIter < ' a > = core:: iter:: Map <
758
- core:: slice:: Iter < ' a , ( BlindedPath , BlindedPayInfo ) > ,
759
- for <' r > fn ( & ' r ( BlindedPath , BlindedPayInfo ) ) -> & ' r BlindedPayInfo ,
758
+ core:: slice:: Iter < ' a , ( BlindedPayInfo , BlindedPath ) > ,
759
+ for <' r > fn ( & ' r ( BlindedPayInfo , BlindedPath ) ) -> & ' r BlindedPayInfo ,
760
760
> ;
761
761
762
762
/// Information needed to route a payment across a [`BlindedPath`].
@@ -878,15 +878,15 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
878
878
} ,
879
879
) = tlv_stream;
880
880
881
- let payment_paths = match ( paths , blindedpay ) {
882
- ( None , _ ) => return Err ( SemanticError :: MissingPaths ) ,
883
- ( _ , None ) => return Err ( SemanticError :: InvalidPayInfo ) ,
884
- ( Some ( paths) , _ ) if paths. is_empty ( ) => return Err ( SemanticError :: MissingPaths ) ,
885
- ( Some ( paths ) , Some ( blindedpay ) ) if paths. len ( ) != blindedpay. len ( ) => {
881
+ let payment_paths = match ( blindedpay , paths ) {
882
+ ( _ , None ) => return Err ( SemanticError :: MissingPaths ) ,
883
+ ( None , _ ) => return Err ( SemanticError :: InvalidPayInfo ) ,
884
+ ( _ , Some ( paths) ) if paths. is_empty ( ) => return Err ( SemanticError :: MissingPaths ) ,
885
+ ( Some ( blindedpay ) , Some ( paths ) ) if paths. len ( ) != blindedpay. len ( ) => {
886
886
return Err ( SemanticError :: InvalidPayInfo ) ;
887
887
} ,
888
- ( Some ( paths ) , Some ( blindedpay ) ) => {
889
- paths . into_iter ( ) . zip ( blindedpay . into_iter ( ) ) . collect :: < Vec < _ > > ( )
888
+ ( Some ( blindedpay ) , Some ( paths ) ) => {
889
+ blindedpay . into_iter ( ) . zip ( paths . into_iter ( ) ) . collect :: < Vec < _ > > ( )
890
890
} ,
891
891
} ;
892
892
@@ -1052,8 +1052,8 @@ mod tests {
1052
1052
payer_note: None ,
1053
1053
} ,
1054
1054
InvoiceTlvStreamRef {
1055
- paths: Some ( Iterable ( payment_paths. iter( ) . map( |( path , _ ) | path) ) ) ,
1056
- blindedpay: Some ( Iterable ( payment_paths. iter( ) . map( |( _ , payinfo ) | payinfo) ) ) ,
1055
+ paths: Some ( Iterable ( payment_paths. iter( ) . map( |( _ , path ) | path) ) ) ,
1056
+ blindedpay: Some ( Iterable ( payment_paths. iter( ) . map( |( payinfo , _ ) | payinfo) ) ) ,
1057
1057
created_at: Some ( now. as_secs( ) ) ,
1058
1058
relative_expiry: None ,
1059
1059
payment_hash: Some ( & payment_hash) ,
@@ -1130,8 +1130,8 @@ mod tests {
1130
1130
payer_note: None ,
1131
1131
} ,
1132
1132
InvoiceTlvStreamRef {
1133
- paths: Some ( Iterable ( payment_paths. iter( ) . map( |( path , _ ) | path) ) ) ,
1134
- blindedpay: Some ( Iterable ( payment_paths. iter( ) . map( |( _ , payinfo ) | payinfo) ) ) ,
1133
+ paths: Some ( Iterable ( payment_paths. iter( ) . map( |( _ , path ) | path) ) ) ,
1134
+ blindedpay: Some ( Iterable ( payment_paths. iter( ) . map( |( payinfo , _ ) | payinfo) ) ) ,
1135
1135
created_at: Some ( now. as_secs( ) ) ,
1136
1136
relative_expiry: None ,
1137
1137
payment_hash: Some ( & payment_hash) ,
@@ -1516,7 +1516,7 @@ mod tests {
1516
1516
1517
1517
let empty_payment_paths = vec ! [ ] ;
1518
1518
let mut tlv_stream = invoice. as_tlv_stream ( ) ;
1519
- tlv_stream. 3 . paths = Some ( Iterable ( empty_payment_paths. iter ( ) . map ( |( path , _ ) | path) ) ) ;
1519
+ tlv_stream. 3 . paths = Some ( Iterable ( empty_payment_paths. iter ( ) . map ( |( _ , path ) | path) ) ) ;
1520
1520
1521
1521
match Invoice :: try_from ( tlv_stream. to_bytes ( ) ) {
1522
1522
Ok ( _) => panic ! ( "expected error" ) ,
@@ -1526,7 +1526,7 @@ mod tests {
1526
1526
let mut payment_paths = payment_paths ( ) ;
1527
1527
payment_paths. pop ( ) ;
1528
1528
let mut tlv_stream = invoice. as_tlv_stream ( ) ;
1529
- tlv_stream. 3 . blindedpay = Some ( Iterable ( payment_paths. iter ( ) . map ( |( _ , payinfo ) | payinfo) ) ) ;
1529
+ tlv_stream. 3 . blindedpay = Some ( Iterable ( payment_paths. iter ( ) . map ( |( payinfo , _ ) | payinfo) ) ) ;
1530
1530
1531
1531
match Invoice :: try_from ( tlv_stream. to_bytes ( ) ) {
1532
1532
Ok ( _) => panic ! ( "expected error" ) ,
0 commit comments