@@ -916,6 +916,47 @@ impl OutboundPayments {
916
916
} ;
917
917
}
918
918
919
+ #[ cfg( async_payments) ]
920
+ pub ( super ) fn send_payment_for_static_invoice < R : Deref , ES : Deref , NS : Deref , IH , SP , L : Deref > (
921
+ & self , payment_id : PaymentId , payment_release_secret : [ u8 ; 32 ] , router : & R ,
922
+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
923
+ best_block_height : u32 , logger : & L ,
924
+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
925
+ send_payment_along_path : SP ,
926
+ ) -> Result < ( ) , Bolt12PaymentError >
927
+ where
928
+ R :: Target : Router ,
929
+ ES :: Target : EntropySource ,
930
+ NS :: Target : NodeSigner ,
931
+ L :: Target : Logger ,
932
+ IH : Fn ( ) -> InFlightHtlcs ,
933
+ SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
934
+ {
935
+ let ( payment_hash, route_params) =
936
+ match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
937
+ hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
938
+ PendingOutboundPayment :: StaticInvoiceReceived {
939
+ payment_hash, payment_release_secret : release_secret, route_params, ..
940
+ } => {
941
+ if payment_release_secret != * release_secret {
942
+ return Err ( Bolt12PaymentError :: UnexpectedInvoice )
943
+ }
944
+ ( * payment_hash, route_params. clone ( ) )
945
+ } ,
946
+ _ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
947
+ } ,
948
+ hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
949
+ } ;
950
+
951
+ self . find_route_and_send_payment (
952
+ payment_hash, payment_id, route_params, router, first_hops, & inflight_htlcs,
953
+ entropy_source, node_signer, best_block_height, logger, pending_events,
954
+ & send_payment_along_path
955
+ ) ;
956
+
957
+ Ok ( ( ) )
958
+ }
959
+
919
960
pub ( super ) fn check_retry_payments < R : Deref , ES : Deref , NS : Deref , SP , IH , FH , L : Deref > (
920
961
& self , router : & R , first_hops : FH , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
921
962
best_block_height : u32 ,
@@ -1181,7 +1222,21 @@ impl OutboundPayments {
1181
1222
* payment. into_mut ( ) = retryable_payment;
1182
1223
( total_amount, recipient_onion, None , onion_session_privs)
1183
1224
} ,
1184
- PendingOutboundPayment :: StaticInvoiceReceived { .. } => todo ! ( ) ,
1225
+ PendingOutboundPayment :: StaticInvoiceReceived {
1226
+ payment_hash, keysend_preimage, retry_strategy, ..
1227
+ } => {
1228
+ let keysend_preimage = Some ( * keysend_preimage) ;
1229
+ let total_amount = route_params. final_value_msat ;
1230
+ let recipient_onion = RecipientOnionFields :: spontaneous_empty ( ) ;
1231
+ let retry_strategy = Some ( * retry_strategy) ;
1232
+ let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
1233
+ let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
1234
+ * payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route,
1235
+ retry_strategy, payment_params, entropy_source, best_block_height
1236
+ ) ;
1237
+ * payment. into_mut ( ) = retryable_payment;
1238
+ ( total_amount, recipient_onion, keysend_preimage, onion_session_privs)
1239
+ } ,
1185
1240
PendingOutboundPayment :: Fulfilled { .. } => {
1186
1241
log_error ! ( logger, "Payment already completed" ) ;
1187
1242
return
0 commit comments