@@ -1106,12 +1106,14 @@ impl OutboundPayments {
11061106 Ok ( ( ) )
11071107 }
11081108
1109- #[ rustfmt:: skip]
11101109 pub ( super ) fn static_invoice_received < ES : Deref > (
11111110 & self , invoice : & StaticInvoice , payment_id : PaymentId , features : Bolt12InvoiceFeatures ,
11121111 best_block_height : u32 , duration_since_epoch : Duration , entropy_source : ES ,
1113- pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > >
1114- ) -> Result < ( ) , Bolt12PaymentError > where ES :: Target : EntropySource {
1112+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
1113+ ) -> Result < ( ) , Bolt12PaymentError >
1114+ where
1115+ ES :: Target : EntropySource ,
1116+ {
11151117 macro_rules! abandon_with_entry {
11161118 ( $payment: expr, $reason: expr) => {
11171119 assert!(
@@ -1130,64 +1132,82 @@ impl OutboundPayments {
11301132 match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
11311133 hash_map:: Entry :: Occupied ( mut entry) => match entry. get_mut ( ) {
11321134 PendingOutboundPayment :: AwaitingInvoice {
1133- retry_strategy, retryable_invoice_request, route_params_config, ..
1135+ retry_strategy,
1136+ retryable_invoice_request,
1137+ route_params_config,
1138+ ..
11341139 } => {
11351140 let invreq = & retryable_invoice_request
11361141 . as_ref ( )
11371142 . ok_or ( Bolt12PaymentError :: UnexpectedInvoice ) ?
11381143 . invoice_request ;
11391144 if !invoice. is_from_same_offer ( invreq) {
1140- return Err ( Bolt12PaymentError :: UnexpectedInvoice )
1145+ return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ;
11411146 }
11421147 if invoice. invoice_features ( ) . requires_unknown_bits_from ( & features) {
11431148 abandon_with_entry ! ( entry, PaymentFailureReason :: UnknownRequiredFeatures ) ;
1144- return Err ( Bolt12PaymentError :: UnknownRequiredFeatures )
1149+ return Err ( Bolt12PaymentError :: UnknownRequiredFeatures ) ;
11451150 }
1146- if duration_since_epoch > invoice. created_at ( ) . saturating_add ( invoice. relative_expiry ( ) ) {
1151+ if duration_since_epoch
1152+ > invoice. created_at ( ) . saturating_add ( invoice. relative_expiry ( ) )
1153+ {
11471154 abandon_with_entry ! ( entry, PaymentFailureReason :: PaymentExpired ) ;
1148- return Err ( Bolt12PaymentError :: SendingFailed ( RetryableSendFailure :: PaymentExpired ) )
1155+ return Err ( Bolt12PaymentError :: SendingFailed (
1156+ RetryableSendFailure :: PaymentExpired ,
1157+ ) ) ;
11491158 }
11501159
1151- let amount_msat = match InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats ( invreq) {
1160+ let amount_msat = match InvoiceBuilder :: < DerivedSigningPubkey > :: amount_msats (
1161+ invreq,
1162+ ) {
11521163 Ok ( amt) => amt,
11531164 Err ( _) => {
11541165 // We check this during invoice request parsing, when constructing the invreq's
11551166 // contents from its TLV stream.
11561167 debug_assert ! ( false , "LDK requires an msat amount in either the invreq or the invreq's underlying offer" ) ;
11571168 abandon_with_entry ! ( entry, PaymentFailureReason :: UnexpectedError ) ;
1158- return Err ( Bolt12PaymentError :: UnknownRequiredFeatures )
1159- }
1169+ return Err ( Bolt12PaymentError :: UnknownRequiredFeatures ) ;
1170+ } ,
11601171 } ;
1161- let keysend_preimage = PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ;
1162- let payment_hash = PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
1172+ let keysend_preimage =
1173+ PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ;
1174+ let payment_hash =
1175+ PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
11631176 let pay_params = PaymentParameters :: from_static_invoice ( invoice)
11641177 . with_user_config_ignoring_fee_limit ( * route_params_config) ;
1165- let mut route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
1166- route_params. max_total_routing_fee_msat = route_params_config. max_total_routing_fee_msat ;
1178+ let mut route_params =
1179+ RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
1180+ route_params. max_total_routing_fee_msat =
1181+ route_params_config. max_total_routing_fee_msat ;
11671182
11681183 if let Err ( ( ) ) = onion_utils:: set_max_path_length (
1169- & mut route_params, & RecipientOnionFields :: spontaneous_empty ( ) , Some ( keysend_preimage) ,
1170- Some ( invreq) , best_block_height
1184+ & mut route_params,
1185+ & RecipientOnionFields :: spontaneous_empty ( ) ,
1186+ Some ( keysend_preimage) ,
1187+ Some ( invreq) ,
1188+ best_block_height,
11711189 ) {
11721190 abandon_with_entry ! ( entry, PaymentFailureReason :: RouteNotFound ) ;
1173- return Err ( Bolt12PaymentError :: SendingFailed ( RetryableSendFailure :: OnionPacketSizeExceeded ) )
1191+ return Err ( Bolt12PaymentError :: SendingFailed (
1192+ RetryableSendFailure :: OnionPacketSizeExceeded ,
1193+ ) ) ;
11741194 }
1175- let absolute_expiry = duration_since_epoch. saturating_add ( ASYNC_PAYMENT_TIMEOUT_RELATIVE_EXPIRY ) ;
1195+ let absolute_expiry =
1196+ duration_since_epoch. saturating_add ( ASYNC_PAYMENT_TIMEOUT_RELATIVE_EXPIRY ) ;
11761197
11771198 * entry. into_mut ( ) = PendingOutboundPayment :: StaticInvoiceReceived {
11781199 payment_hash,
11791200 keysend_preimage,
11801201 retry_strategy : * retry_strategy,
11811202 route_params,
1182- invoice_request :
1183- retryable_invoice_request
1203+ invoice_request : retryable_invoice_request
11841204 . take ( )
11851205 . ok_or ( Bolt12PaymentError :: UnexpectedInvoice ) ?
11861206 . invoice_request ,
11871207 static_invoice : invoice. clone ( ) ,
11881208 expiry_time : absolute_expiry,
11891209 } ;
1190- return Ok ( ( ) )
1210+ return Ok ( ( ) ) ;
11911211 } ,
11921212 _ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
11931213 } ,
0 commit comments