@@ -898,6 +898,47 @@ impl OutboundPayments {
898
898
} ;
899
899
}
900
900
901
+ #[ cfg( async_payments) ]
902
+ pub ( super ) fn send_payment_for_static_invoice < R : Deref , ES : Deref , NS : Deref , IH , SP , L : Deref > (
903
+ & self , payment_id : PaymentId , payment_release_secret : [ u8 ; 32 ] , router : & R ,
904
+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
905
+ best_block_height : u32 , logger : & L ,
906
+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
907
+ send_payment_along_path : SP ,
908
+ ) -> Result < ( ) , Bolt12PaymentError >
909
+ where
910
+ R :: Target : Router ,
911
+ ES :: Target : EntropySource ,
912
+ NS :: Target : NodeSigner ,
913
+ L :: Target : Logger ,
914
+ IH : Fn ( ) -> InFlightHtlcs ,
915
+ SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
916
+ {
917
+ let ( payment_hash, route_params) =
918
+ match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
919
+ hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
920
+ PendingOutboundPayment :: StaticInvoiceReceived {
921
+ payment_hash, payment_release_secret : release_secret, route_params, ..
922
+ } => {
923
+ if payment_release_secret != * release_secret {
924
+ return Err ( Bolt12PaymentError :: UnexpectedInvoice )
925
+ }
926
+ ( * payment_hash, route_params. clone ( ) )
927
+ } ,
928
+ _ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
929
+ } ,
930
+ hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
931
+ } ;
932
+
933
+ self . find_route_and_send_payment (
934
+ payment_hash, payment_id, route_params, router, first_hops, & inflight_htlcs,
935
+ entropy_source, node_signer, best_block_height, logger, pending_events,
936
+ & send_payment_along_path
937
+ ) ;
938
+
939
+ Ok ( ( ) )
940
+ }
941
+
901
942
pub ( super ) fn check_retry_payments < R : Deref , ES : Deref , NS : Deref , SP , IH , FH , L : Deref > (
902
943
& self , router : & R , first_hops : FH , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
903
944
best_block_height : u32 ,
@@ -1163,7 +1204,20 @@ impl OutboundPayments {
1163
1204
* payment. into_mut ( ) = retryable_payment;
1164
1205
( recipient_onion, None , onion_session_privs)
1165
1206
} ,
1166
- PendingOutboundPayment :: StaticInvoiceReceived { .. } => todo ! ( ) ,
1207
+ PendingOutboundPayment :: StaticInvoiceReceived {
1208
+ payment_hash, keysend_preimage, retry_strategy, ..
1209
+ } => {
1210
+ let keysend_preimage = Some ( * keysend_preimage) ;
1211
+ let recipient_onion = RecipientOnionFields :: spontaneous_empty ( ) ;
1212
+ let retry_strategy = Some ( * retry_strategy) ;
1213
+ let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
1214
+ let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
1215
+ * payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route,
1216
+ retry_strategy, payment_params, entropy_source, best_block_height
1217
+ ) ;
1218
+ * payment. into_mut ( ) = retryable_payment;
1219
+ ( recipient_onion, keysend_preimage, onion_session_privs)
1220
+ } ,
1167
1221
PendingOutboundPayment :: Fulfilled { .. } => {
1168
1222
log_error ! ( logger, "Payment already completed" ) ;
1169
1223
return
0 commit comments