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