@@ -40,9 +40,7 @@ use crate::offers::invoice::{
40
40
UnsignedBolt12Invoice , DEFAULT_RELATIVE_EXPIRY ,
41
41
} ;
42
42
use crate :: offers:: invoice_error:: InvoiceError ;
43
- use crate :: offers:: invoice_request:: {
44
- InvoiceRequest , InvoiceRequestBuilder , VerifiedInvoiceRequestLegacy ,
45
- } ;
43
+ use crate :: offers:: invoice_request:: { InvoiceRequest , InvoiceRequestBuilder , InvoiceSigningInfo } ;
46
44
use crate :: offers:: nonce:: Nonce ;
47
45
use crate :: offers:: offer:: { DerivedMetadata , Offer , OfferBuilder } ;
48
46
use crate :: offers:: parse:: Bolt12SemanticError ;
@@ -406,7 +404,7 @@ fn enqueue_onion_message_with_reply_paths<T: OnionMessageContents + Clone>(
406
404
pub enum InvreqResponseInstructions {
407
405
/// We are the recipient of this payment, and a [`Bolt12Invoice`] should be sent in response to
408
406
/// the invoice request since it is now verified.
409
- SendInvoice ( VerifiedInvoiceRequestLegacy ) ,
407
+ SendInvoice ( InvoiceSigningInfo ) ,
410
408
/// We are a static invoice server and should respond to this invoice request by retrieving the
411
409
/// [`StaticInvoice`] corresponding to the `recipient_id` and `invoice_id` and calling
412
410
/// `OffersMessageFlow::enqueue_static_invoice`.
@@ -920,7 +918,7 @@ where
920
918
Ok ( builder. into ( ) )
921
919
}
922
920
923
- /// Creates a response for the provided [`VerifiedInvoiceRequestLegacy `].
921
+ /// Creates a response for the provided [`InvoiceSigningInfo `].
924
922
///
925
923
/// A response can be either an [`OffersMessage::Invoice`] with additional [`MessageContext`],
926
924
/// or an [`OffersMessage::InvoiceError`], depending on the [`InvoiceRequest`].
@@ -929,9 +927,8 @@ where
929
927
/// - We fail to generate valid payment paths to include in the [`Bolt12Invoice`].
930
928
/// - We fail to generate a valid signed [`Bolt12Invoice`] for the [`InvoiceRequest`].
931
929
pub fn create_response_for_invoice_request < ES : Deref , NS : Deref , R : Deref > (
932
- & self , signer : & NS , router : & R , entropy_source : ES ,
933
- invoice_request : VerifiedInvoiceRequestLegacy , amount_msats : u64 ,
934
- payment_hash : PaymentHash , payment_secret : PaymentSecret ,
930
+ & self , signer : & NS , router : & R , entropy_source : ES , invoice_request : InvoiceSigningInfo ,
931
+ amount_msats : u64 , payment_hash : PaymentHash , payment_secret : PaymentSecret ,
935
932
usable_channels : Vec < ChannelDetails > ,
936
933
) -> ( OffersMessage , Option < MessageContext > )
937
934
where
@@ -945,7 +942,7 @@ where
945
942
let relative_expiry = DEFAULT_RELATIVE_EXPIRY . as_secs ( ) as u32 ;
946
943
947
944
let context = PaymentContext :: Bolt12Offer ( Bolt12OfferContext {
948
- offer_id : invoice_request. offer_id ,
945
+ offer_id : invoice_request. offer_id ( ) ,
949
946
invoice_request : invoice_request. fields ( ) ,
950
947
} ) ;
951
948
@@ -968,35 +965,36 @@ where
968
965
#[ cfg( not( feature = "std" ) ) ]
969
966
let created_at = Duration :: from_secs ( self . highest_seen_timestamp . load ( Ordering :: Acquire ) as u64 ) ;
970
967
971
- let response = if invoice_request. keys . is_some ( ) {
972
- #[ cfg( feature = "std" ) ]
973
- let builder = invoice_request. respond_using_derived_keys ( payment_paths, payment_hash) ;
974
- #[ cfg( not( feature = "std" ) ) ]
975
- let builder = invoice_request. respond_using_derived_keys_no_std (
976
- payment_paths,
977
- payment_hash,
978
- created_at,
979
- ) ;
980
- builder
981
- . map ( InvoiceBuilder :: < DerivedSigningPubkey > :: from)
982
- . and_then ( |builder| builder. allow_mpp ( ) . build_and_sign ( secp_ctx) )
983
- . map_err ( InvoiceError :: from)
984
- } else {
985
- #[ cfg( feature = "std" ) ]
986
- let builder = invoice_request. respond_with ( payment_paths, payment_hash) ;
987
- #[ cfg( not( feature = "std" ) ) ]
988
- let builder = invoice_request. respond_with_no_std ( payment_paths, payment_hash, created_at) ;
989
- builder
990
- . map ( InvoiceBuilder :: < ExplicitSigningPubkey > :: from)
991
- . and_then ( |builder| builder. allow_mpp ( ) . build ( ) )
992
- . map_err ( InvoiceError :: from)
993
- . and_then ( |invoice| {
994
- #[ cfg( c_bindings) ]
995
- let mut invoice = invoice;
996
- invoice
997
- . sign ( |invoice : & UnsignedBolt12Invoice | signer. sign_bolt12_invoice ( invoice) )
998
- . map_err ( InvoiceError :: from)
999
- } )
968
+ let response = match invoice_request {
969
+ InvoiceSigningInfo :: DerivedKeys ( request) => {
970
+ #[ cfg( feature = "std" ) ]
971
+ let builder = request. respond_using_derived_keys ( payment_paths, payment_hash) ;
972
+ #[ cfg( not( feature = "std" ) ) ]
973
+ let builder = request. respond_using_derived_keys_no_std ( payment_paths, payment_hash, created_at) ;
974
+ builder
975
+ . map ( InvoiceBuilder :: < DerivedSigningPubkey > :: from)
976
+ . and_then ( |builder| builder. allow_mpp ( ) . build_and_sign ( secp_ctx) )
977
+ . map_err ( InvoiceError :: from)
978
+ } ,
979
+ InvoiceSigningInfo :: ExplicitKeys ( request) => {
980
+ #[ cfg( feature = "std" ) ]
981
+ let builder = request. respond_with ( payment_paths, payment_hash) ;
982
+ #[ cfg( not( feature = "std" ) ) ]
983
+ let builder = request. respond_with_no_std ( payment_paths, payment_hash, created_at) ;
984
+ builder
985
+ . map ( InvoiceBuilder :: < ExplicitSigningPubkey > :: from)
986
+ . and_then ( |builder| builder. allow_mpp ( ) . build ( ) )
987
+ . map_err ( InvoiceError :: from)
988
+ . and_then ( |invoice| {
989
+ #[ cfg( c_bindings) ]
990
+ let mut invoice = invoice;
991
+ invoice
992
+ . sign ( |invoice : & UnsignedBolt12Invoice | {
993
+ signer. sign_bolt12_invoice ( invoice)
994
+ } )
995
+ . map_err ( InvoiceError :: from)
996
+ } )
997
+ } ,
1000
998
} ;
1001
999
1002
1000
match response {
0 commit comments