3232//! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder};
3333//! # use lightning::blinded_path::payment::BlindedPaymentPath;
3434//! #
35- //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPaymentPath) > { unimplemented!() }
35+ //! # fn create_payment_paths() -> Vec<BlindedPaymentPath> { unimplemented!() }
3636//! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
3737//! #
3838//! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
@@ -111,7 +111,7 @@ use core::time::Duration;
111111use core:: hash:: { Hash , Hasher } ;
112112use crate :: io;
113113use crate :: blinded_path:: message:: BlindedMessagePath ;
114- use crate :: blinded_path:: payment:: BlindedPaymentPath ;
114+ use crate :: blinded_path:: payment:: { WriteableBlindedPath , ReadableBlindedPath , BlindedPaymentPath } ;
115115use crate :: ln:: types:: PaymentHash ;
116116use crate :: ln:: channelmanager:: PaymentId ;
117117use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
@@ -128,7 +128,7 @@ use crate::offers::parse::{Bolt12ParseError, Bolt12SemanticError, ParsedMessage}
128128use crate :: offers:: payer:: { PAYER_METADATA_TYPE , PayerTlvStream , PayerTlvStreamRef } ;
129129use 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 } ;
130130use 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 } ;
132132use crate :: util:: string:: PrintableString ;
133133
134134#[ allow( unused_imports) ]
@@ -212,7 +212,7 @@ impl SigningPubkeyStrategy for DerivedSigningPubkey {}
212212macro_rules! invoice_explicit_signing_pubkey_builder_methods { ( $self: ident, $self_type: ty) => {
213213 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
214214 pub ( super ) fn for_offer(
215- invoice_request: & ' a InvoiceRequest , payment_paths: Vec <( BlindedPayInfo , BlindedPaymentPath ) >,
215+ invoice_request: & ' a InvoiceRequest , payment_paths: Vec <BlindedPaymentPath >,
216216 created_at: Duration , payment_hash: PaymentHash , signing_pubkey: PublicKey
217217 ) -> Result <Self , Bolt12SemanticError > {
218218 let amount_msats = Self :: amount_msats( invoice_request) ?;
@@ -228,7 +228,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods { ($self: ident, $s
228228
229229 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
230230 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 ,
232232 payment_hash: PaymentHash , signing_pubkey: PublicKey
233233 ) -> Result <Self , Bolt12SemanticError > {
234234 let amount_msats = refund. amount_msats( ) ;
@@ -270,7 +270,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods { ($self: ident, $s
270270macro_rules! invoice_derived_signing_pubkey_builder_methods { ( $self: ident, $self_type: ty) => {
271271 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
272272 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 >,
274274 created_at: Duration , payment_hash: PaymentHash , keys: Keypair
275275 ) -> Result <Self , Bolt12SemanticError > {
276276 let amount_msats = Self :: amount_msats( invoice_request) ?;
@@ -287,7 +287,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods { ($self: ident, $se
287287
288288 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
289289 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 ,
291291 payment_hash: PaymentHash , keys: Keypair ,
292292 ) -> Result <Self , Bolt12SemanticError > {
293293 let amount_msats = refund. amount_msats( ) ;
@@ -356,8 +356,8 @@ macro_rules! invoice_builder_methods { (
356356
357357 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
358358 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
361361 ) -> InvoiceFields {
362362 InvoiceFields {
363363 payment_paths, created_at, relative_expiry: None , payment_hash, amount_msats,
@@ -603,7 +603,7 @@ enum InvoiceContents {
603603/// Invoice-specific fields for an `invoice` message.
604604#[ derive( Clone , Debug , PartialEq ) ]
605605struct InvoiceFields {
606- payment_paths : Vec < ( BlindedPayInfo , BlindedPaymentPath ) > ,
606+ payment_paths : Vec < BlindedPaymentPath > ,
607607 created_at : Duration ,
608608 relative_expiry : Option < Duration > ,
609609 payment_hash : PaymentHash ,
@@ -988,7 +988,7 @@ impl InvoiceContents {
988988 }
989989 }
990990
991- fn payment_paths ( & self ) -> & [ ( BlindedPayInfo , BlindedPaymentPath ) ] {
991+ fn payment_paths ( & self ) -> & [ BlindedPaymentPath ] {
992992 & self . fields ( ) . payment_paths [ ..]
993993 }
994994
@@ -1125,8 +1125,8 @@ impl InvoiceFields {
11251125 } ;
11261126
11271127 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 ) ) ) ,
11301130 created_at : Some ( self . created_at . as_secs ( ) ) ,
11311131 relative_expiry : self . relative_expiry . map ( |duration| duration. as_secs ( ) as u32 ) ,
11321132 payment_hash : Some ( & self . payment_hash ) ,
@@ -1193,7 +1193,7 @@ impl TryFrom<Vec<u8>> for Bolt12Invoice {
11931193}
11941194
11951195tlv_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>>) ) ,
11971197 ( 162 , blindedpay: ( Vec <BlindedPayInfo >, WithoutLength , Iterable <' a, BlindedPayInfoIter <' a>, BlindedPayInfo >) ) ,
11981198 ( 164 , created_at: ( u64 , HighZeroBytesDroppedBigSize ) ) ,
11991199 ( 166 , relative_expiry: ( u32 , HighZeroBytesDroppedBigSize ) ) ,
@@ -1207,13 +1207,13 @@ tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, {
12071207} ) ;
12081208
12091209pub ( 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 > ,
12121212> ;
12131213
12141214pub ( 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 ,
12171217> ;
12181218
12191219/// Information needed to route a payment across a [`BlindedPaymentPath`].
@@ -1388,8 +1388,8 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
13881388}
13891389
13901390pub ( 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 > {
13931393 match ( blinded_payinfos, blinded_paths) {
13941394 ( _, None ) => Err ( Bolt12SemanticError :: MissingPaths ) ,
13951395 ( None , _) => Err ( Bolt12SemanticError :: InvalidPayInfo ) ,
@@ -1398,7 +1398,12 @@ pub(super) fn construct_payment_paths(
13981398 Err ( Bolt12SemanticError :: InvalidPayInfo )
13991399 } ,
14001400 ( 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+ )
14021407 } ,
14031408 }
14041409}
0 commit comments