@@ -21,6 +21,8 @@ use crate::ln::channelmanager::{EventCompletionAction, HTLCSource, PaymentId};
2121use crate :: ln:: onion_utils;
2222use crate :: ln:: onion_utils:: { DecodedOnionFailure , HTLCFailReason } ;
2323use crate :: offers:: invoice:: Bolt12Invoice ;
24+ #[ cfg( async_payments) ]
25+ use crate :: offers:: invoice_request:: CurrencyConversion ;
2426use crate :: offers:: invoice_request:: InvoiceRequest ;
2527use crate :: offers:: nonce:: Nonce ;
2628use crate :: offers:: static_invoice:: StaticInvoice ;
@@ -1113,11 +1115,11 @@ impl OutboundPayments {
11131115
11141116 #[ cfg( async_payments) ]
11151117 #[ rustfmt:: skip]
1116- pub ( super ) fn static_invoice_received < ES : Deref > (
1117- & self , invoice : & StaticInvoice , payment_id : PaymentId , features : Bolt12InvoiceFeatures ,
1118+ pub ( super ) fn static_invoice_received < ES : Deref , CC : Deref > (
1119+ & self , invoice : & StaticInvoice , currency_conversion : & CC , payment_id : PaymentId , features : Bolt12InvoiceFeatures ,
11181120 best_block_height : u32 , duration_since_epoch : Duration , entropy_source : ES ,
11191121 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > >
1120- ) -> Result < ( ) , Bolt12PaymentError > where ES :: Target : EntropySource {
1122+ ) -> Result < ( ) , Bolt12PaymentError > where ES :: Target : EntropySource , CC :: Target : CurrencyConversion {
11211123 macro_rules! abandon_with_entry {
11221124 ( $payment: expr, $reason: expr) => {
11231125 assert!(
@@ -1154,7 +1156,7 @@ impl OutboundPayments {
11541156 return Err ( Bolt12PaymentError :: SendingFailed ( RetryableSendFailure :: PaymentExpired ) )
11551157 }
11561158
1157- let amount_msat = match InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( invreq) {
1159+ let amount_msat = match InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( invreq, currency_conversion ) {
11581160 Ok ( amt) => amt,
11591161 Err ( _) => {
11601162 // We check this during invoice request parsing, when constructing the invreq's
@@ -2758,7 +2760,7 @@ mod tests {
27582760 } ;
27592761 #[ cfg( feature = "std" ) ]
27602762 use crate :: offers:: invoice:: DEFAULT_RELATIVE_EXPIRY ;
2761- use crate :: offers:: invoice_request:: InvoiceRequest ;
2763+ use crate :: offers:: invoice_request:: { DefaultCurrencyConversion , InvoiceRequest } ;
27622764 use crate :: offers:: nonce:: Nonce ;
27632765 use crate :: offers:: offer:: OfferBuilder ;
27642766 use crate :: offers:: test_utils:: * ;
@@ -3141,7 +3143,7 @@ mod tests {
31413143 . build ( ) . unwrap ( )
31423144 . request_invoice ( & expanded_key, nonce, & secp_ctx, payment_id) . unwrap ( )
31433145 . build_and_sign ( ) . unwrap ( )
3144- . respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , created_at) . unwrap ( )
3146+ . respond_with_no_std ( & DefaultCurrencyConversion { } , payment_paths ( ) , payment_hash ( ) , created_at) . unwrap ( )
31453147 . build ( ) . unwrap ( )
31463148 . sign ( recipient_sign) . unwrap ( ) ;
31473149
@@ -3188,7 +3190,7 @@ mod tests {
31883190 . build ( ) . unwrap ( )
31893191 . request_invoice ( & expanded_key, nonce, & secp_ctx, payment_id) . unwrap ( )
31903192 . build_and_sign ( ) . unwrap ( )
3191- . respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
3193+ . respond_with_no_std ( & DefaultCurrencyConversion { } , payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
31923194 . build ( ) . unwrap ( )
31933195 . sign ( recipient_sign) . unwrap ( ) ;
31943196
@@ -3251,7 +3253,7 @@ mod tests {
32513253 . build ( ) . unwrap ( )
32523254 . request_invoice ( & expanded_key, nonce, & secp_ctx, payment_id) . unwrap ( )
32533255 . build_and_sign ( ) . unwrap ( )
3254- . respond_with_no_std ( payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
3256+ . respond_with_no_std ( & DefaultCurrencyConversion { } , payment_paths ( ) , payment_hash ( ) , now ( ) ) . unwrap ( )
32553257 . build ( ) . unwrap ( )
32563258 . sign ( recipient_sign) . unwrap ( ) ;
32573259
0 commit comments