103
103
//! ```
104
104
105
105
use bitcoin:: blockdata:: constants:: ChainHash ;
106
- use bitcoin:: hash_types:: { WPubkeyHash , WScriptHash } ;
107
106
use bitcoin:: network:: constants:: Network ;
108
107
use bitcoin:: secp256k1:: { KeyPair , PublicKey , Secp256k1 , self } ;
109
108
use bitcoin:: secp256k1:: schnorr:: Signature ;
110
109
use bitcoin:: address:: { Address , Payload , WitnessProgram , WitnessVersion } ;
111
- use bitcoin:: key:: TweakedPublicKey ;
112
110
use core:: time:: Duration ;
113
111
use core:: hash:: { Hash , Hasher } ;
114
112
use crate :: io;
@@ -118,6 +116,7 @@ use crate::ln::channelmanager::PaymentId;
118
116
use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures , InvoiceRequestFeatures , OfferFeatures } ;
119
117
use crate :: ln:: inbound_payment:: ExpandedKey ;
120
118
use crate :: ln:: msgs:: DecodeError ;
119
+ use crate :: offers:: invoice_macros:: invoice_builder_methods_common;
121
120
use crate :: offers:: invoice_request:: { INVOICE_REQUEST_PAYER_ID_TYPE , INVOICE_REQUEST_TYPES , IV_BYTES as INVOICE_REQUEST_IV_BYTES , InvoiceRequest , InvoiceRequestContents , InvoiceRequestTlvStream , InvoiceRequestTlvStreamRef } ;
122
121
use crate :: offers:: merkle:: { SignError , SignFn , SignatureTlvStream , SignatureTlvStreamRef , TaggedHash , TlvStream , WithoutSignatures , self } ;
123
122
use crate :: offers:: offer:: { Amount , OFFER_TYPES , OfferTlvStream , OfferTlvStreamRef , Quantity } ;
@@ -372,65 +371,6 @@ macro_rules! invoice_builder_methods { (
372
371
373
372
Ok ( Self { invreq_bytes, invoice: contents, signing_pubkey_strategy } )
374
373
}
375
-
376
- /// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
377
- /// Any expiry that has already passed is valid and can be checked for using
378
- /// [`Bolt12Invoice::is_expired`].
379
- ///
380
- /// Successive calls to this method will override the previous setting.
381
- pub fn relative_expiry( $( $self_mut) * $self: $self_type, relative_expiry_secs: u32 ) -> $return_type {
382
- let relative_expiry = Duration :: from_secs( relative_expiry_secs as u64 ) ;
383
- $self. invoice. fields_mut( ) . relative_expiry = Some ( relative_expiry) ;
384
- $return_value
385
- }
386
-
387
- /// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
388
- ///
389
- /// Successive calls to this method will add another address. Caller is responsible for not
390
- /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
391
- pub fn fallback_v0_p2wsh( $( $self_mut) * $self: $self_type, script_hash: & WScriptHash ) -> $return_type {
392
- use bitcoin:: hashes:: Hash ;
393
- let address = FallbackAddress {
394
- version: WitnessVersion :: V0 . to_num( ) ,
395
- program: Vec :: from( script_hash. to_byte_array( ) ) ,
396
- } ;
397
- $self. invoice. fields_mut( ) . fallbacks. get_or_insert_with( Vec :: new) . push( address) ;
398
- $return_value
399
- }
400
-
401
- /// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
402
- ///
403
- /// Successive calls to this method will add another address. Caller is responsible for not
404
- /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
405
- pub fn fallback_v0_p2wpkh( $( $self_mut) * $self: $self_type, pubkey_hash: & WPubkeyHash ) -> $return_type {
406
- use bitcoin:: hashes:: Hash ;
407
- let address = FallbackAddress {
408
- version: WitnessVersion :: V0 . to_num( ) ,
409
- program: Vec :: from( pubkey_hash. to_byte_array( ) ) ,
410
- } ;
411
- $self. invoice. fields_mut( ) . fallbacks. get_or_insert_with( Vec :: new) . push( address) ;
412
- $return_value
413
- }
414
-
415
- /// Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
416
- ///
417
- /// Successive calls to this method will add another address. Caller is responsible for not
418
- /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
419
- pub fn fallback_v1_p2tr_tweaked( $( $self_mut) * $self: $self_type, output_key: & TweakedPublicKey ) -> $return_type {
420
- let address = FallbackAddress {
421
- version: WitnessVersion :: V1 . to_num( ) ,
422
- program: Vec :: from( & output_key. serialize( ) [ ..] ) ,
423
- } ;
424
- $self. invoice. fields_mut( ) . fallbacks. get_or_insert_with( Vec :: new) . push( address) ;
425
- $return_value
426
- }
427
-
428
- /// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
429
- /// disallowed.
430
- pub fn allow_mpp( $( $self_mut) * $self: $self_type) -> $return_type {
431
- $self. invoice. fields_mut( ) . features. set_basic_mpp_optional( ) ;
432
- $return_value
433
- }
434
374
} }
435
375
436
376
impl < ' a > InvoiceBuilder < ' a , ExplicitSigningPubkey > {
@@ -443,30 +383,35 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
443
383
444
384
impl < ' a , S : SigningPubkeyStrategy > InvoiceBuilder < ' a , S > {
445
385
invoice_builder_methods ! ( self , Self , Self , self , S , mut ) ;
386
+ invoice_builder_methods_common ! ( self , Self , self . invoice. fields_mut( ) , Self , self , S , mut ) ;
446
387
}
447
388
448
389
#[ cfg( all( c_bindings, not( test) ) ) ]
449
390
impl < ' a > InvoiceWithExplicitSigningPubkeyBuilder < ' a > {
450
391
invoice_explicit_signing_pubkey_builder_methods ! ( self , & mut Self ) ;
451
392
invoice_builder_methods ! ( self , & mut Self , ( ) , ( ) , ExplicitSigningPubkey ) ;
393
+ invoice_builder_methods_common ! ( self , & mut Self , self . invoice. fields_mut( ) , ( ) , ( ) , ExplicitSigningPubkey ) ;
452
394
}
453
395
454
396
#[ cfg( all( c_bindings, test) ) ]
455
397
impl < ' a > InvoiceWithExplicitSigningPubkeyBuilder < ' a > {
456
398
invoice_explicit_signing_pubkey_builder_methods ! ( self , & mut Self ) ;
457
399
invoice_builder_methods ! ( self , & mut Self , & mut Self , self , ExplicitSigningPubkey ) ;
400
+ invoice_builder_methods_common ! ( self , & mut Self , self . invoice. fields_mut( ) , & mut Self , self , ExplicitSigningPubkey ) ;
458
401
}
459
402
460
403
#[ cfg( all( c_bindings, not( test) ) ) ]
461
404
impl < ' a > InvoiceWithDerivedSigningPubkeyBuilder < ' a > {
462
405
invoice_derived_signing_pubkey_builder_methods ! ( self , & mut Self ) ;
463
406
invoice_builder_methods ! ( self , & mut Self , ( ) , ( ) , DerivedSigningPubkey ) ;
407
+ invoice_builder_methods_common ! ( self , & mut Self , self . invoice. fields_mut( ) , ( ) , ( ) , DerivedSigningPubkey ) ;
464
408
}
465
409
466
410
#[ cfg( all( c_bindings, test) ) ]
467
411
impl < ' a > InvoiceWithDerivedSigningPubkeyBuilder < ' a > {
468
412
invoice_derived_signing_pubkey_builder_methods ! ( self , & mut Self ) ;
469
413
invoice_builder_methods ! ( self , & mut Self , & mut Self , self , DerivedSigningPubkey ) ;
414
+ invoice_builder_methods_common ! ( self , & mut Self , self . invoice. fields_mut( ) , & mut Self , self , DerivedSigningPubkey ) ;
470
415
}
471
416
472
417
#[ cfg( c_bindings) ]
0 commit comments