@@ -956,6 +956,47 @@ impl OutboundPayments {
956
956
} ;
957
957
}
958
958
959
+ #[ cfg( async_payments) ]
960
+ pub ( super ) fn send_payment_for_static_invoice < R : Deref , ES : Deref , NS : Deref , IH , SP , L : Deref > (
961
+ & self , payment_id : PaymentId , payment_release_secret : [ u8 ; 32 ] , router : & R ,
962
+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
963
+ best_block_height : u32 , logger : & L ,
964
+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
965
+ send_payment_along_path : SP ,
966
+ ) -> Result < ( ) , Bolt12PaymentError >
967
+ where
968
+ R :: Target : Router ,
969
+ ES :: Target : EntropySource ,
970
+ NS :: Target : NodeSigner ,
971
+ L :: Target : Logger ,
972
+ IH : Fn ( ) -> InFlightHtlcs ,
973
+ SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
974
+ {
975
+ let ( payment_hash, route_params) =
976
+ match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
977
+ hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
978
+ PendingOutboundPayment :: StaticInvoiceReceived {
979
+ payment_hash, payment_release_secret : release_secret, route_params, ..
980
+ } => {
981
+ if payment_release_secret != * release_secret {
982
+ return Err ( Bolt12PaymentError :: UnexpectedInvoice )
983
+ }
984
+ ( * payment_hash, route_params. clone ( ) )
985
+ } ,
986
+ _ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
987
+ } ,
988
+ hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
989
+ } ;
990
+
991
+ self . find_route_and_send_payment (
992
+ payment_hash, payment_id, route_params, router, first_hops, & inflight_htlcs,
993
+ entropy_source, node_signer, best_block_height, logger, pending_events,
994
+ & send_payment_along_path
995
+ ) ;
996
+
997
+ Ok ( ( ) )
998
+ }
999
+
959
1000
pub ( super ) fn check_retry_payments < R : Deref , ES : Deref , NS : Deref , SP , IH , FH , L : Deref > (
960
1001
& self , router : & R , first_hops : FH , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
961
1002
best_block_height : u32 ,
@@ -1235,7 +1276,21 @@ impl OutboundPayments {
1235
1276
debug_assert ! ( false ) ;
1236
1277
return
1237
1278
} ,
1238
- PendingOutboundPayment :: StaticInvoiceReceived { .. } => todo ! ( ) ,
1279
+ PendingOutboundPayment :: StaticInvoiceReceived {
1280
+ payment_hash, keysend_preimage, retry_strategy, ..
1281
+ } => {
1282
+ let keysend_preimage = Some ( * keysend_preimage) ;
1283
+ let total_amount = route_params. final_value_msat ;
1284
+ let recipient_onion = RecipientOnionFields :: spontaneous_empty ( ) ;
1285
+ let retry_strategy = Some ( * retry_strategy) ;
1286
+ let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
1287
+ let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
1288
+ * payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route,
1289
+ retry_strategy, payment_params, entropy_source, best_block_height
1290
+ ) ;
1291
+ * payment. into_mut ( ) = retryable_payment;
1292
+ ( total_amount, recipient_onion, keysend_preimage, onion_session_privs)
1293
+ } ,
1239
1294
PendingOutboundPayment :: Fulfilled { .. } => {
1240
1295
log_error ! ( logger, "Payment already completed" ) ;
1241
1296
return
0 commit comments