@@ -123,8 +123,9 @@ pub struct OfferBuilder<'a, M: MetadataStrategy, T: secp256k1::Signing> {
123
123
///
124
124
/// [module-level documentation]: self
125
125
#[ cfg( c_bindings) ]
126
- pub struct OfferWithExplicitMetadataBuilder {
126
+ pub struct OfferWithExplicitMetadataBuilder < ' a > {
127
127
offer : OfferContents ,
128
+ secp_ctx : Option < & ' a Secp256k1 < secp256k1:: All > > ,
128
129
}
129
130
130
131
/// Builds an [`Offer`] for the "offer to be paid" flow.
@@ -133,8 +134,9 @@ pub struct OfferWithExplicitMetadataBuilder {
133
134
///
134
135
/// [module-level documentation]: self
135
136
#[ cfg( c_bindings) ]
136
- pub struct OfferWithDerivedMetadataBuilder {
137
+ pub struct OfferWithDerivedMetadataBuilder < ' a > {
137
138
offer : OfferContents ,
139
+ secp_ctx : Option < & ' a Secp256k1 < secp256k1:: All > > ,
138
140
}
139
141
140
142
/// Indicates how [`Offer::metadata`] may be set.
@@ -180,7 +182,6 @@ macro_rules! offer_explicit_metadata_builder_methods { (
180
182
} ,
181
183
#[ cfg( not( c_bindings) ) ]
182
184
metadata_strategy: core:: marker:: PhantomData ,
183
- #[ cfg( not( c_bindings) ) ]
184
185
secp_ctx: None ,
185
186
}
186
187
}
@@ -211,7 +212,7 @@ macro_rules! offer_derived_metadata_builder_methods { () => {
211
212
#[ cfg( not( c_bindings) ) ]
212
213
secp_ctx: & ' a Secp256k1 <T >,
213
214
#[ cfg( c_bindings) ]
214
- _secp_ctx : & Secp256k1 <secp256k1:: All >,
215
+ secp_ctx : & ' a Secp256k1 <secp256k1:: All >,
215
216
) -> Self where ES :: Target : EntropySource {
216
217
let nonce = Nonce :: from_entropy_source( entropy_source) ;
217
218
let derivation_material = MetadataMaterial :: new( nonce, expanded_key, IV_BYTES , None ) ;
@@ -224,7 +225,6 @@ macro_rules! offer_derived_metadata_builder_methods { () => {
224
225
} ,
225
226
#[ cfg( not( c_bindings) ) ]
226
227
metadata_strategy: core:: marker:: PhantomData ,
227
- #[ cfg( not( c_bindings) ) ]
228
228
secp_ctx: Some ( secp_ctx) ,
229
229
}
230
230
}
@@ -345,7 +345,7 @@ macro_rules! offer_builder_methods { (
345
345
tlv_stream. node_id = None ;
346
346
}
347
347
348
- let ( derived_metadata, keys) = metadata. derive_from( tlv_stream, $self. secp_ctx( ) ) ;
348
+ let ( derived_metadata, keys) = metadata. derive_from( tlv_stream, $self. secp_ctx) ;
349
349
metadata = derived_metadata;
350
350
if let Some ( keys) = keys {
351
351
$self. offer. signing_pubkey = keys. public_key( ) ;
@@ -390,10 +390,6 @@ macro_rules! offer_builder_test_methods { (
390
390
impl < ' a , M : MetadataStrategy , T : secp256k1:: Signing > OfferBuilder < ' a , M , T > {
391
391
offer_builder_methods ! ( self , Self , Self , self ) ;
392
392
393
- fn secp_ctx ( & self ) -> Option < & Secp256k1 < T > > {
394
- self . secp_ctx
395
- }
396
-
397
393
#[ cfg( test) ]
398
394
offer_builder_test_methods ! ( self , Self , Self , self ) ;
399
395
}
@@ -409,7 +405,7 @@ impl<'a, T: secp256k1::Signing> OfferBuilder<'a, DerivedMetadata, T> {
409
405
}
410
406
411
407
#[ cfg( c_bindings) ]
412
- impl OfferWithExplicitMetadataBuilder {
408
+ impl < ' a > OfferWithExplicitMetadataBuilder < ' a > {
413
409
#[ cfg( not( test) ) ]
414
410
offer_explicit_metadata_builder_methods ! ( self , & mut Self , ( ) , ( ) ) ;
415
411
#[ cfg( not( test) ) ]
@@ -419,28 +415,18 @@ impl OfferWithExplicitMetadataBuilder {
419
415
offer_explicit_metadata_builder_methods ! ( self , & mut Self , & mut Self , self ) ;
420
416
#[ cfg( test) ]
421
417
offer_builder_methods ! ( self , & mut Self , & mut Self , self ) ;
422
-
423
- fn secp_ctx ( & self ) -> Option < & Secp256k1 < secp256k1:: All > > {
424
- None
425
- }
426
-
427
418
#[ cfg( test) ]
428
419
offer_builder_test_methods ! ( self , & mut Self , & mut Self , self ) ;
429
420
}
430
421
431
422
#[ cfg( c_bindings) ]
432
- impl OfferWithDerivedMetadataBuilder {
423
+ impl < ' a > OfferWithDerivedMetadataBuilder < ' a > {
433
424
offer_derived_metadata_builder_methods ! ( ) ;
434
425
#[ cfg( not( test) ) ]
435
426
offer_builder_methods ! ( self , & mut Self , ( ) , ( ) ) ;
436
427
437
428
#[ cfg( test) ]
438
429
offer_builder_methods ! ( self , & mut Self , & mut Self , self ) ;
439
-
440
- fn secp_ctx ( & self ) -> Option < & Secp256k1 < secp256k1:: All > > {
441
- Some ( secp256k1:: SECP256K1 . deref ( ) )
442
- }
443
-
444
430
#[ cfg( test) ]
445
431
offer_builder_test_methods ! ( self , & mut Self , & mut Self , self ) ;
446
432
}
0 commit comments