32
32
//! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder};
33
33
//! # use lightning::blinded_path::payment::BlindedPaymentPath;
34
34
//! #
35
- //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPaymentPath) > { unimplemented!() }
35
+ //! # fn create_payment_paths() -> Vec<BlindedPaymentPath> { unimplemented!() }
36
36
//! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
37
37
//! #
38
38
//! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
@@ -111,7 +111,7 @@ use core::time::Duration;
111
111
use core:: hash:: { Hash , Hasher } ;
112
112
use crate :: io;
113
113
use crate :: blinded_path:: message:: BlindedMessagePath ;
114
- use crate :: blinded_path:: payment:: BlindedPaymentPath ;
114
+ use crate :: blinded_path:: payment:: { WriteableBlindedPath , ReadableBlindedPath , BlindedPaymentPath } ;
115
115
use crate :: ln:: types:: PaymentHash ;
116
116
use crate :: ln:: channelmanager:: PaymentId ;
117
117
use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
@@ -128,7 +128,7 @@ use crate::offers::parse::{Bolt12ParseError, Bolt12SemanticError, ParsedMessage}
128
128
use crate :: offers:: payer:: { PAYER_METADATA_TYPE , PayerTlvStream , PayerTlvStreamRef } ;
129
129
use crate :: offers:: refund:: { IV_BYTES_WITH_METADATA as REFUND_IV_BYTES_WITH_METADATA , IV_BYTES_WITHOUT_METADATA as REFUND_IV_BYTES_WITHOUT_METADATA , Refund , RefundContents } ;
130
130
use crate :: offers:: signer:: { Metadata , self } ;
131
- use crate :: util:: ser:: { HighZeroBytesDroppedBigSize , Iterable , Readable , SeekReadable , WithoutLength , Writeable , Writer } ;
131
+ use crate :: util:: ser:: { HighZeroBytesDroppedBigSize , Iterable , IterableOwned , Readable , SeekReadable , WithoutLength , Writeable , Writer } ;
132
132
use crate :: util:: string:: PrintableString ;
133
133
134
134
#[ allow( unused_imports) ]
@@ -212,7 +212,7 @@ impl SigningPubkeyStrategy for DerivedSigningPubkey {}
212
212
macro_rules! invoice_explicit_signing_pubkey_builder_methods { ( $self: ident, $self_type: ty) => {
213
213
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
214
214
pub ( super ) fn for_offer(
215
- invoice_request: & ' a InvoiceRequest , payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >,
215
+ invoice_request: & ' a InvoiceRequest , payment_paths: Vec <BlindedPaymentPath >,
216
216
created_at: Duration , payment_hash: PaymentHash , signing_pubkey: PublicKey
217
217
) -> Result <Self , Bolt12SemanticError > {
218
218
let amount_msats = Self :: amount_msats( invoice_request) ?;
@@ -228,7 +228,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods { ($self: ident, $s
228
228
229
229
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
230
230
pub ( super ) fn for_refund(
231
- refund: & ' a Refund , payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >, created_at: Duration ,
231
+ refund: & ' a Refund , payment_paths: Vec <BlindedPaymentPath >, created_at: Duration ,
232
232
payment_hash: PaymentHash , signing_pubkey: PublicKey
233
233
) -> Result <Self , Bolt12SemanticError > {
234
234
let amount_msats = refund. amount_msats( ) ;
@@ -270,7 +270,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods { ($self: ident, $s
270
270
macro_rules! invoice_derived_signing_pubkey_builder_methods { ( $self: ident, $self_type: ty) => {
271
271
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
272
272
pub ( super ) fn for_offer_using_keys(
273
- invoice_request: & ' a InvoiceRequest , payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >,
273
+ invoice_request: & ' a InvoiceRequest , payment_paths: Vec <BlindedPaymentPath >,
274
274
created_at: Duration , payment_hash: PaymentHash , keys: Keypair
275
275
) -> Result <Self , Bolt12SemanticError > {
276
276
let amount_msats = Self :: amount_msats( invoice_request) ?;
@@ -287,7 +287,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods { ($self: ident, $se
287
287
288
288
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
289
289
pub ( super ) fn for_refund_using_keys(
290
- refund: & ' a Refund , payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >, created_at: Duration ,
290
+ refund: & ' a Refund , payment_paths: Vec <BlindedPaymentPath >, created_at: Duration ,
291
291
payment_hash: PaymentHash , keys: Keypair ,
292
292
) -> Result <Self , Bolt12SemanticError > {
293
293
let amount_msats = refund. amount_msats( ) ;
@@ -356,8 +356,8 @@ macro_rules! invoice_builder_methods { (
356
356
357
357
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
358
358
fn fields(
359
- payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >, created_at: Duration ,
360
- payment_hash : PaymentHash , amount_msats: u64 , signing_pubkey: PublicKey
359
+ payment_paths: Vec <BlindedPaymentPath >, created_at: Duration , payment_hash : PaymentHash ,
360
+ amount_msats: u64 , signing_pubkey: PublicKey
361
361
) -> InvoiceFields {
362
362
InvoiceFields {
363
363
payment_paths, created_at, relative_expiry: None , payment_hash, amount_msats,
@@ -603,7 +603,7 @@ enum InvoiceContents {
603
603
/// Invoice-specific fields for an `invoice` message.
604
604
#[ derive( Clone , Debug , PartialEq ) ]
605
605
struct InvoiceFields {
606
- payment_paths : Vec < ( BlindedPayInfo , BlindedPaymentPath ) > ,
606
+ payment_paths : Vec < BlindedPaymentPath > ,
607
607
created_at : Duration ,
608
608
relative_expiry : Option < Duration > ,
609
609
payment_hash : PaymentHash ,
@@ -988,7 +988,7 @@ impl InvoiceContents {
988
988
}
989
989
}
990
990
991
- fn payment_paths ( & self ) -> & [ ( BlindedPayInfo , BlindedPaymentPath ) ] {
991
+ fn payment_paths ( & self ) -> & [ BlindedPaymentPath ] {
992
992
& self . fields ( ) . payment_paths [ ..]
993
993
}
994
994
@@ -1125,8 +1125,8 @@ impl InvoiceFields {
1125
1125
} ;
1126
1126
1127
1127
InvoiceTlvStreamRef {
1128
- paths : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( _ , path) | path) ) ) ,
1129
- blindedpay : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |( payinfo , _ ) | payinfo) ) ) ,
1128
+ paths : Some ( IterableOwned ( self . payment_paths . iter ( ) . map ( |path| path. writeable_path ( ) ) ) ) ,
1129
+ blindedpay : Some ( Iterable ( self . payment_paths . iter ( ) . map ( |path| & path . payinfo ) ) ) ,
1130
1130
created_at : Some ( self . created_at . as_secs ( ) ) ,
1131
1131
relative_expiry : self . relative_expiry . map ( |duration| duration. as_secs ( ) as u32 ) ,
1132
1132
payment_hash : Some ( & self . payment_hash ) ,
@@ -1193,7 +1193,7 @@ impl TryFrom<Vec<u8>> for Bolt12Invoice {
1193
1193
}
1194
1194
1195
1195
tlv_stream ! ( InvoiceTlvStream , InvoiceTlvStreamRef , 160 ..240 , {
1196
- ( 160 , paths: ( Vec <BlindedPaymentPath >, WithoutLength , Iterable < ' a , BlindedPathIter <' a>, BlindedPaymentPath >) ) ,
1196
+ ( 160 , paths: ( Vec <ReadableBlindedPath >, WithoutLength , IterableOwned < BlindedPathIter < ' a> , WriteableBlindedPath <' a>>) ) ,
1197
1197
( 162 , blindedpay: ( Vec <BlindedPayInfo >, WithoutLength , Iterable <' a, BlindedPayInfoIter <' a>, BlindedPayInfo >) ) ,
1198
1198
( 164 , created_at: ( u64 , HighZeroBytesDroppedBigSize ) ) ,
1199
1199
( 166 , relative_expiry: ( u32 , HighZeroBytesDroppedBigSize ) ) ,
@@ -1207,13 +1207,13 @@ tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, {
1207
1207
} ) ;
1208
1208
1209
1209
pub ( super ) type BlindedPathIter < ' a > = core:: iter:: Map <
1210
- core:: slice:: Iter < ' a , ( BlindedPayInfo , BlindedPaymentPath ) > ,
1211
- for <' r > fn ( & ' r ( BlindedPayInfo , BlindedPaymentPath ) ) -> & ' r BlindedPaymentPath ,
1210
+ core:: slice:: Iter < ' a , BlindedPaymentPath > ,
1211
+ for <' r > fn ( & ' r BlindedPaymentPath ) -> WriteableBlindedPath < ' r > ,
1212
1212
> ;
1213
1213
1214
1214
pub ( super ) type BlindedPayInfoIter < ' a > = core:: iter:: Map <
1215
- core:: slice:: Iter < ' a , ( BlindedPayInfo , BlindedPaymentPath ) > ,
1216
- for <' r > fn ( & ' r ( BlindedPayInfo , BlindedPaymentPath ) ) -> & ' r BlindedPayInfo ,
1215
+ core:: slice:: Iter < ' a , BlindedPaymentPath > ,
1216
+ for <' r > fn ( & ' r BlindedPaymentPath ) -> & ' r BlindedPayInfo ,
1217
1217
> ;
1218
1218
1219
1219
/// Information needed to route a payment across a [`BlindedPaymentPath`].
@@ -1388,8 +1388,8 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
1388
1388
}
1389
1389
1390
1390
pub ( super ) fn construct_payment_paths (
1391
- blinded_payinfos : Option < Vec < BlindedPayInfo > > , blinded_paths : Option < Vec < BlindedPaymentPath > >
1392
- ) -> Result < Vec < ( BlindedPayInfo , BlindedPaymentPath ) > , Bolt12SemanticError > {
1391
+ blinded_payinfos : Option < Vec < BlindedPayInfo > > , blinded_paths : Option < Vec < ReadableBlindedPath > >
1392
+ ) -> Result < Vec < BlindedPaymentPath > , Bolt12SemanticError > {
1393
1393
match ( blinded_payinfos, blinded_paths) {
1394
1394
( _, None ) => Err ( Bolt12SemanticError :: MissingPaths ) ,
1395
1395
( None , _) => Err ( Bolt12SemanticError :: InvalidPayInfo ) ,
@@ -1398,7 +1398,12 @@ pub(super) fn construct_payment_paths(
1398
1398
Err ( Bolt12SemanticError :: InvalidPayInfo )
1399
1399
} ,
1400
1400
( Some ( blindedpay) , Some ( paths) ) => {
1401
- Ok ( blindedpay. into_iter ( ) . zip ( paths. into_iter ( ) ) . collect :: < Vec < _ > > ( ) )
1401
+ Ok ( blindedpay
1402
+ . into_iter ( )
1403
+ . zip ( paths. into_iter ( ) )
1404
+ . map ( |( payinfo, path) | BlindedPaymentPath :: from_readable_blinded_path ( path, payinfo) )
1405
+ . collect :: < Vec < _ > > ( )
1406
+ )
1402
1407
} ,
1403
1408
}
1404
1409
}
0 commit comments