@@ -184,7 +184,7 @@ pub const SIGNATURE_TAG: &'static str = concat!("lightning", "invoice", "signatu
184
184
/// [module-level documentation]: self
185
185
pub struct InvoiceBuilder < ' a , S : SigningPubkeyStrategy > {
186
186
invreq_bytes : & ' a Vec < u8 > ,
187
- invoice : InvoiceContents ,
187
+ invoice : Box < InvoiceContents > ,
188
188
signing_pubkey_strategy : S ,
189
189
}
190
190
@@ -200,7 +200,7 @@ pub struct InvoiceBuilder<'a, S: SigningPubkeyStrategy> {
200
200
#[ cfg( c_bindings) ]
201
201
pub struct InvoiceWithExplicitSigningPubkeyBuilder < ' a > {
202
202
invreq_bytes : & ' a Vec < u8 > ,
203
- invoice : InvoiceContents ,
203
+ invoice : Box < InvoiceContents > ,
204
204
signing_pubkey_strategy : ExplicitSigningPubkey ,
205
205
}
206
206
@@ -216,7 +216,7 @@ pub struct InvoiceWithExplicitSigningPubkeyBuilder<'a> {
216
216
#[ cfg( c_bindings) ]
217
217
pub struct InvoiceWithDerivedSigningPubkeyBuilder < ' a > {
218
218
invreq_bytes : & ' a Vec < u8 > ,
219
- invoice : InvoiceContents ,
219
+ invoice : Box < InvoiceContents > ,
220
220
signing_pubkey_strategy : DerivedSigningPubkey ,
221
221
}
222
222
@@ -246,16 +246,16 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
246
246
created_at: Duration , payment_hash: PaymentHash , signing_pubkey: PublicKey ,
247
247
) -> Result <Self , Bolt12SemanticError > {
248
248
let amount_msats = Self :: amount_msats( invoice_request) ?;
249
- let contents = InvoiceContents :: ForOffer {
250
- invoice_request: invoice_request. contents. clone( ) ,
249
+ let contents = Box :: new ( InvoiceContents :: ForOffer {
250
+ invoice_request: * invoice_request. contents. clone( ) ,
251
251
fields: Self :: fields(
252
252
payment_paths,
253
253
created_at,
254
254
payment_hash,
255
255
amount_msats,
256
256
signing_pubkey,
257
257
) ,
258
- } ;
258
+ } ) ;
259
259
260
260
Self :: new( & invoice_request. bytes, contents, ExplicitSigningPubkey { } )
261
261
}
@@ -266,16 +266,16 @@ macro_rules! invoice_explicit_signing_pubkey_builder_methods {
266
266
payment_hash: PaymentHash , signing_pubkey: PublicKey ,
267
267
) -> Result <Self , Bolt12SemanticError > {
268
268
let amount_msats = refund. amount_msats( ) ;
269
- let contents = InvoiceContents :: ForRefund {
270
- refund: refund. contents. clone( ) ,
269
+ let contents = Box :: new ( InvoiceContents :: ForRefund {
270
+ refund: * refund. contents. clone( ) ,
271
271
fields: Self :: fields(
272
272
payment_paths,
273
273
created_at,
274
274
payment_hash,
275
275
amount_msats,
276
276
signing_pubkey,
277
277
) ,
278
- } ;
278
+ } ) ;
279
279
280
280
Self :: new( & refund. bytes, contents, ExplicitSigningPubkey { } )
281
281
}
@@ -319,16 +319,16 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
319
319
) -> Result <Self , Bolt12SemanticError > {
320
320
let amount_msats = Self :: amount_msats( invoice_request) ?;
321
321
let signing_pubkey = keys. public_key( ) ;
322
- let contents = InvoiceContents :: ForOffer {
323
- invoice_request: invoice_request. contents. clone( ) ,
322
+ let contents = Box :: new ( InvoiceContents :: ForOffer {
323
+ invoice_request: * invoice_request. contents. clone( ) ,
324
324
fields: Self :: fields(
325
325
payment_paths,
326
326
created_at,
327
327
payment_hash,
328
328
amount_msats,
329
329
signing_pubkey,
330
330
) ,
331
- } ;
331
+ } ) ;
332
332
333
333
Self :: new( & invoice_request. bytes, contents, DerivedSigningPubkey ( keys) )
334
334
}
@@ -340,16 +340,16 @@ macro_rules! invoice_derived_signing_pubkey_builder_methods {
340
340
) -> Result <Self , Bolt12SemanticError > {
341
341
let amount_msats = refund. amount_msats( ) ;
342
342
let signing_pubkey = keys. public_key( ) ;
343
- let contents = InvoiceContents :: ForRefund {
344
- refund: refund. contents. clone( ) ,
343
+ let contents = Box :: new ( InvoiceContents :: ForRefund {
344
+ refund: * refund. contents. clone( ) ,
345
345
fields: Self :: fields(
346
346
payment_paths,
347
347
created_at,
348
348
payment_hash,
349
349
amount_msats,
350
350
signing_pubkey,
351
351
) ,
352
- } ;
352
+ } ) ;
353
353
354
354
Self :: new( & refund. bytes, contents, DerivedSigningPubkey ( keys) )
355
355
}
@@ -429,7 +429,7 @@ macro_rules! invoice_builder_methods {
429
429
430
430
#[ cfg_attr( c_bindings, allow( dead_code) ) ]
431
431
fn new(
432
- invreq_bytes: & ' a Vec <u8 >, contents: InvoiceContents ,
432
+ invreq_bytes: & ' a Vec <u8 >, contents: Box < InvoiceContents > ,
433
433
signing_pubkey_strategy: $type_param,
434
434
) -> Result <Self , Bolt12SemanticError > {
435
435
if contents. fields( ) . payment_paths. is_empty( ) {
@@ -593,7 +593,7 @@ impl<'a> From<InvoiceWithDerivedSigningPubkeyBuilder<'a>>
593
593
pub struct UnsignedBolt12Invoice {
594
594
bytes : Vec < u8 > ,
595
595
experimental_bytes : Vec < u8 > ,
596
- contents : InvoiceContents ,
596
+ contents : Box < InvoiceContents > ,
597
597
tagged_hash : TaggedHash ,
598
598
}
599
599
@@ -622,7 +622,7 @@ where
622
622
}
623
623
624
624
impl UnsignedBolt12Invoice {
625
- fn new ( invreq_bytes : & [ u8 ] , contents : InvoiceContents ) -> Self {
625
+ fn new ( invreq_bytes : & [ u8 ] , contents : Box < InvoiceContents > ) -> Self {
626
626
// TLV record ranges applicable to invreq_bytes.
627
627
const NON_EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > = 0 ..INVOICE_REQUEST_TYPES . end ;
628
628
const EXPERIMENTAL_TYPES : core:: ops:: Range < u64 > =
@@ -731,7 +731,7 @@ impl AsRef<TaggedHash> for UnsignedBolt12Invoice {
731
731
#[ derive( Clone , Debug ) ]
732
732
pub struct Bolt12Invoice {
733
733
bytes : Vec < u8 > ,
734
- contents : InvoiceContents ,
734
+ contents : Box < InvoiceContents > ,
735
735
signature : Signature ,
736
736
tagged_hash : TaggedHash ,
737
737
}
@@ -974,7 +974,7 @@ impl Bolt12Invoice {
974
974
pub fn verify_using_metadata < T : secp256k1:: Signing > (
975
975
& self , key : & ExpandedKey , secp_ctx : & Secp256k1 < T > ,
976
976
) -> Result < PaymentId , ( ) > {
977
- let ( metadata, iv_bytes) = match & self . contents {
977
+ let ( metadata, iv_bytes) = match & * self . contents {
978
978
InvoiceContents :: ForOffer { invoice_request, .. } => {
979
979
( & invoice_request. inner . payer . 0 , INVOICE_REQUEST_IV_BYTES )
980
980
} ,
@@ -992,7 +992,7 @@ impl Bolt12Invoice {
992
992
& self , payment_id : PaymentId , nonce : Nonce , key : & ExpandedKey , secp_ctx : & Secp256k1 < T > ,
993
993
) -> Result < PaymentId , ( ) > {
994
994
let metadata = Metadata :: payer_data ( payment_id, nonce, key) ;
995
- let iv_bytes = match & self . contents {
995
+ let iv_bytes = match & * self . contents {
996
996
InvoiceContents :: ForOffer { .. } => INVOICE_REQUEST_IV_BYTES ,
997
997
InvoiceContents :: ForRefund { .. } => REFUND_IV_BYTES_WITHOUT_METADATA ,
998
998
} ;
@@ -1027,7 +1027,7 @@ impl Bolt12Invoice {
1027
1027
}
1028
1028
1029
1029
pub ( crate ) fn is_for_refund_without_paths ( & self ) -> bool {
1030
- match self . contents {
1030
+ match & * self . contents {
1031
1031
InvoiceContents :: ForOffer { .. } => false ,
1032
1032
InvoiceContents :: ForRefund { .. } => self . message_paths ( ) . is_empty ( ) ,
1033
1033
}
@@ -1422,7 +1422,7 @@ impl TryFrom<Vec<u8>> for UnsignedBolt12Invoice {
1422
1422
fn try_from ( bytes : Vec < u8 > ) -> Result < Self , Self :: Error > {
1423
1423
let invoice = ParsedMessage :: < PartialInvoiceTlvStream > :: try_from ( bytes) ?;
1424
1424
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) ?) ;
1426
1426
1427
1427
let tagged_hash = TaggedHash :: from_valid_tlv_stream_bytes ( SIGNATURE_TAG , & bytes) ;
1428
1428
@@ -1606,15 +1606,15 @@ impl TryFrom<ParsedMessage<FullInvoiceTlvStream>> for Bolt12Invoice {
1606
1606
experimental_invoice_request_tlv_stream,
1607
1607
experimental_invoice_tlv_stream,
1608
1608
) = tlv_stream;
1609
- let contents = InvoiceContents :: try_from ( (
1609
+ let contents = Box :: new ( InvoiceContents :: try_from ( (
1610
1610
payer_tlv_stream,
1611
1611
offer_tlv_stream,
1612
1612
invoice_request_tlv_stream,
1613
1613
invoice_tlv_stream,
1614
1614
experimental_offer_tlv_stream,
1615
1615
experimental_invoice_request_tlv_stream,
1616
1616
experimental_invoice_tlv_stream,
1617
- ) ) ?;
1617
+ ) ) ?) ;
1618
1618
1619
1619
let signature = signature
1620
1620
. ok_or ( Bolt12ParseError :: InvalidSemantics ( Bolt12SemanticError :: MissingSignature ) ) ?;
0 commit comments