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