@@ -950,20 +950,26 @@ impl OutboundPayments {
950
950
payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route, Some ( retry_strategy) ,
951
951
payment_params, entropy_source, best_block_height
952
952
) ;
953
- match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
954
- hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
955
- PendingOutboundPayment :: InvoiceReceived { .. }
956
- | PendingOutboundPayment :: StaticInvoiceReceived { .. } => {
957
- * entry. into_mut ( ) = retryable_payment;
953
+ let mut invoice_request_opt = None ;
954
+ let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
955
+ match outbounds. entry ( payment_id) {
956
+ hash_map:: Entry :: Occupied ( entry) => match entry. remove ( ) {
957
+ PendingOutboundPayment :: InvoiceReceived { .. } => {
958
+ outbounds. insert ( payment_id, retryable_payment) ;
959
+ } ,
960
+ PendingOutboundPayment :: StaticInvoiceReceived { invoice_request, .. } => {
961
+ invoice_request_opt = Some ( invoice_request) ;
962
+ outbounds. insert ( payment_id, retryable_payment) ;
958
963
} ,
959
964
_ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
960
965
} ,
961
966
hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
962
967
}
968
+ core:: mem:: drop ( outbounds) ;
963
969
964
970
let result = self . pay_route_internal (
965
- & route, payment_hash, & recipient_onion, keysend_preimage, None , payment_id ,
966
- Some ( route_params. final_value_msat ) , onion_session_privs, node_signer,
971
+ & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request_opt . as_ref ( ) ,
972
+ payment_id , Some ( route_params. final_value_msat ) , onion_session_privs, node_signer,
967
973
best_block_height, & send_payment_along_path
968
974
) ;
969
975
log_info ! (
0 commit comments