@@ -986,6 +986,47 @@ impl OutboundPayments {
986986 } ;
987987 }
988988
989+ #[ cfg( async_payments) ]
990+ pub ( super ) fn send_payment_for_static_invoice < R : Deref , ES : Deref , NS : Deref , IH , SP , L : Deref > (
991+ & self , payment_id : PaymentId , payment_release_secret : [ u8 ; 32 ] , router : & R ,
992+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
993+ best_block_height : u32 , logger : & L ,
994+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
995+ send_payment_along_path : SP ,
996+ ) -> Result < ( ) , Bolt12PaymentError >
997+ where
998+ R :: Target : Router ,
999+ ES :: Target : EntropySource ,
1000+ NS :: Target : NodeSigner ,
1001+ L :: Target : Logger ,
1002+ IH : Fn ( ) -> InFlightHtlcs ,
1003+ SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
1004+ {
1005+ let ( payment_hash, route_params) =
1006+ match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
1007+ hash_map:: Entry :: Occupied ( entry) => match entry. get ( ) {
1008+ PendingOutboundPayment :: StaticInvoiceReceived {
1009+ payment_hash, payment_release_secret : release_secret, route_params, ..
1010+ } => {
1011+ if payment_release_secret != * release_secret {
1012+ return Err ( Bolt12PaymentError :: UnexpectedInvoice )
1013+ }
1014+ ( * payment_hash, route_params. clone ( ) )
1015+ } ,
1016+ _ => return Err ( Bolt12PaymentError :: DuplicateInvoice ) ,
1017+ } ,
1018+ hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
1019+ } ;
1020+
1021+ self . find_route_and_send_payment (
1022+ payment_hash, payment_id, route_params, router, first_hops, & inflight_htlcs,
1023+ entropy_source, node_signer, best_block_height, logger, pending_events,
1024+ & send_payment_along_path
1025+ ) ;
1026+
1027+ Ok ( ( ) )
1028+ }
1029+
9891030 pub ( super ) fn check_retry_payments < R : Deref , ES : Deref , NS : Deref , SP , IH , FH , L : Deref > (
9901031 & self , router : & R , first_hops : FH , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
9911032 best_block_height : u32 ,
@@ -1265,7 +1306,21 @@ impl OutboundPayments {
12651306 debug_assert ! ( false ) ;
12661307 return
12671308 } ,
1268- PendingOutboundPayment :: StaticInvoiceReceived { .. } => todo ! ( ) ,
1309+ PendingOutboundPayment :: StaticInvoiceReceived {
1310+ payment_hash, keysend_preimage, retry_strategy, ..
1311+ } => {
1312+ let keysend_preimage = Some ( * keysend_preimage) ;
1313+ let total_amount = route_params. final_value_msat ;
1314+ let recipient_onion = RecipientOnionFields :: spontaneous_empty ( ) ;
1315+ let retry_strategy = Some ( * retry_strategy) ;
1316+ let payment_params = Some ( route_params. payment_params . clone ( ) ) ;
1317+ let ( retryable_payment, onion_session_privs) = self . create_pending_payment (
1318+ * payment_hash, recipient_onion. clone ( ) , keysend_preimage, & route,
1319+ retry_strategy, payment_params, entropy_source, best_block_height
1320+ ) ;
1321+ * payment. into_mut ( ) = retryable_payment;
1322+ ( total_amount, recipient_onion, keysend_preimage, onion_session_privs)
1323+ } ,
12691324 PendingOutboundPayment :: Fulfilled { .. } => {
12701325 log_error ! ( logger, "Payment already completed" ) ;
12711326 return
0 commit comments