@@ -184,7 +184,7 @@ pub const SIGNATURE_TAG: &'static str = concat!("lightning", "invoice", "signatu
184184/// [module-level documentation]: self
185185pub struct InvoiceBuilder < ' a , S : SigningPubkeyStrategy > {
186186 invreq_bytes : & ' a Vec < u8 > ,
187- invoice : InvoiceContents ,
187+ invoice : Box < InvoiceContents > ,
188188 signing_pubkey_strategy : S ,
189189}
190190
@@ -200,7 +200,7 @@ pub struct InvoiceBuilder<'a, S: SigningPubkeyStrategy> {
200200#[ cfg( c_bindings) ]
201201pub struct InvoiceWithExplicitSigningPubkeyBuilder < ' a > {
202202 invreq_bytes : & ' a Vec < u8 > ,
203- invoice : InvoiceContents ,
203+ invoice : Box < InvoiceContents > ,
204204 signing_pubkey_strategy : ExplicitSigningPubkey ,
205205}
206206
@@ -216,7 +216,7 @@ pub struct InvoiceWithExplicitSigningPubkeyBuilder<'a> {
216216#[ cfg( c_bindings) ]
217217pub struct InvoiceWithDerivedSigningPubkeyBuilder < ' a > {
218218 invreq_bytes : & ' a Vec < u8 > ,
219- invoice : InvoiceContents ,
219+ invoice : Box < InvoiceContents > ,
220220 signing_pubkey_strategy : DerivedSigningPubkey ,
221221}
222222
@@ -246,7 +246,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
246246 created_at: Duration , payment_hash: PaymentHash , signing_pubkey: PublicKey ,
247247 ) -> Result <Self , Bolt12SemanticError > {
248248 let amount_msats = Self :: amount_msats( invoice_request) ?;
249- let contents = InvoiceContents :: ForOffer {
249+ let contents = Box :: new ( InvoiceContents :: ForOffer {
250250 invoice_request: invoice_request. contents. clone( ) ,
251251 fields: Self :: fields(
252252 payment_paths,
@@ -255,7 +255,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
255255 amount_msats,
256256 signing_pubkey,
257257 ) ,
258- } ;
258+ } ) ;
259259
260260 Self :: new( & invoice_request. bytes, contents, ExplicitSigningPubkey { } )
261261 }
@@ -266,7 +266,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
266266 payment_hash: PaymentHash , signing_pubkey: PublicKey ,
267267 ) -> Result <Self , Bolt12SemanticError > {
268268 let amount_msats = refund. amount_msats( ) ;
269- let contents = InvoiceContents :: ForRefund {
269+ let contents = Box :: new ( InvoiceContents :: ForRefund {
270270 refund: refund. contents. clone( ) ,
271271 fields: Self :: fields(
272272 payment_paths,
@@ -275,7 +275,7 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
275275 amount_msats,
276276 signing_pubkey,
277277 ) ,
278- } ;
278+ } ) ;
279279
280280 Self :: new( & refund. bytes, contents, ExplicitSigningPubkey { } )
281281 }
@@ -319,7 +319,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
319319 ) -> Result <Self , Bolt12SemanticError > {
320320 let amount_msats = Self :: amount_msats( invoice_request) ?;
321321 let signing_pubkey = keys. public_key( ) ;
322- let contents = InvoiceContents :: ForOffer {
322+ let contents = Box :: new ( InvoiceContents :: ForOffer {
323323 invoice_request: invoice_request. contents. clone( ) ,
324324 fields: Self :: fields(
325325 payment_paths,
@@ -328,7 +328,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
328328 amount_msats,
329329 signing_pubkey,
330330 ) ,
331- } ;
331+ } ) ;
332332
333333 Self :: new( & invoice_request. bytes, contents, DerivedSigningPubkey ( keys) )
334334 }
@@ -340,7 +340,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
340340 ) -> Result <Self , Bolt12SemanticError > {
341341 let amount_msats = refund. amount_msats( ) ;
342342 let signing_pubkey = keys. public_key( ) ;
343- let contents = InvoiceContents :: ForRefund {
343+ let contents = Box :: new ( InvoiceContents :: ForRefund {
344344 refund: refund. contents. clone( ) ,
345345 fields: Self :: fields(
346346 payment_paths,
@@ -349,7 +349,7 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
349349 amount_msats,
350350 signing_pubkey,
351351 ) ,
352- } ;
352+ } ) ;
353353
354354 Self :: new( & refund. bytes, contents, DerivedSigningPubkey ( keys) )
355355 }
@@ -429,7 +429,7 @@ macro_rules! invoice_builder_methods {
429429
430430 #[ cfg_attr( c_bindings, allow( dead_code) ) ]
431431 fn new(
432- invreq_bytes: & ' a Vec <u8 >, contents: InvoiceContents ,
432+ invreq_bytes: & ' a Vec <u8 >, contents: Box < InvoiceContents > ,
433433 signing_pubkey_strategy: $type_param,
434434 ) -> Result <Self , Bolt12SemanticError > {
435435 if contents. fields( ) . payment_paths. is_empty( ) {
@@ -593,7 +593,7 @@ impl<'a> From<InvoiceWithDerivedSigningPubkeyBuilder<'a>>
593593pub struct UnsignedBolt12Invoice {
594594 bytes : Vec < u8 > ,
595595 experimental_bytes : Vec < u8 > ,
596- contents : InvoiceContents ,
596+ contents : Box < InvoiceContents > ,
597597 tagged_hash : TaggedHash ,
598598}
599599
@@ -622,7 +622,7 @@ where
622622}
623623
624624impl UnsignedBolt12Invoice {
625- fn new ( invreq_bytes : & [ u8 ] , contents : InvoiceContents ) -> Self {
625+ fn new ( invreq_bytes : & [ u8 ] , contents : Box < InvoiceContents > ) -> Self {
626626 // TLV record ranges applicable to invreq_bytes.
627627 const NON_EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = 0 ..INVOICE_REQUEST_TYPES . end ;
628628 const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
@@ -731,7 +731,7 @@ impl AsRef<TaggedHash> for UnsignedBolt12Invoice {
731731#[ derive( Clone , Debug ) ]
732732pub struct Bolt12Invoice {
733733 bytes : Vec < u8 > ,
734- contents : InvoiceContents ,
734+ contents : Box < InvoiceContents > ,
735735 signature : Signature ,
736736 tagged_hash : TaggedHash ,
737737}
@@ -974,7 +974,7 @@ impl Bolt12Invoice {
974974 pub fn verify_using_metadata < T : secp256k1:: Signing > (
975975 & self , key : & ExpandedKey , secp_ctx : & Secp256k1 < T > ,
976976 ) -> Result < PaymentId , ( ) > {
977- let ( metadata, iv_bytes) = match & self . contents {
977+ let ( metadata, iv_bytes) = match & * self . contents {
978978 InvoiceContents :: ForOffer { invoice_request, .. } => {
979979 ( & invoice_request. inner . payer . 0 , INVOICE_REQUEST_IV_BYTES )
980980 } ,
@@ -992,7 +992,7 @@ impl Bolt12Invoice {
992992 & self , payment_id : PaymentId , nonce : Nonce , key : & ExpandedKey , secp_ctx : & Secp256k1 < T > ,
993993 ) -> Result < PaymentId , ( ) > {
994994 let metadata = Metadata :: payer_data ( payment_id, nonce, key) ;
995- let iv_bytes = match & self . contents {
995+ let iv_bytes = match & * self . contents {
996996 InvoiceContents :: ForOffer { .. } => INVOICE_REQUEST_IV_BYTES ,
997997 InvoiceContents :: ForRefund { .. } => REFUND_IV_BYTES_WITHOUT_METADATA ,
998998 } ;
@@ -1027,7 +1027,7 @@ impl Bolt12Invoice {
10271027 }
10281028
10291029 pub ( crate ) fn is_for_refund_without_paths ( & self ) -> bool {
1030- match self . contents {
1030+ match & * self . contents {
10311031 InvoiceContents :: ForOffer { .. } => false ,
10321032 InvoiceContents :: ForRefund { .. } => self . message_paths ( ) . is_empty ( ) ,
10331033 }
@@ -1422,7 +1422,7 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
14221422 fn try_from ( bytes : Vec < u8 > ) -> Result < Self , Self :: Error > {
14231423 let invoice = ParsedMessage :: < PartialInvoiceTlvStream > :: try_from ( bytes) ?;
14241424 let ParsedMessage { mut bytes, tlv_stream } = invoice;
1425- let contents = InvoiceContents :: try_from ( tlv_stream) ?;
1425+ let contents = Box :: new ( InvoiceContents :: try_from ( tlv_stream) ?) ;
14261426
14271427 let tagged_hash = TaggedHash :: from_valid_tlv_stream_bytes ( SIGNATURE_TAG , & bytes) ;
14281428
@@ -1606,15 +1606,15 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
16061606 experimental_invoice_request_tlv_stream,
16071607 experimental_invoice_tlv_stream,
16081608 ) = tlv_stream;
1609- let contents = InvoiceContents :: try_from ( (
1609+ let contents = Box :: new ( InvoiceContents :: try_from ( (
16101610 payer_tlv_stream,
16111611 offer_tlv_stream,
16121612 invoice_request_tlv_stream,
16131613 invoice_tlv_stream,
16141614 experimental_offer_tlv_stream,
16151615 experimental_invoice_request_tlv_stream,
16161616 experimental_invoice_tlv_stream,
1617- ) ) ?;
1617+ ) ) ?) ;
16181618
16191619 let signature = signature
16201620 . ok_or ( Bolt12ParseError :: InvalidSemantics ( Bolt12SemanticError :: MissingSignature ) ) ?;
0 commit comments