@@ -925,25 +925,17 @@ impl OutboundPayments {
925
925
!pmt. is_awaiting_invoice ( ) )
926
926
}
927
927
928
- /// Errors immediately on [`RetryableSendFailure`] error conditions. Otherwise, further errors may
929
- /// be surfaced asynchronously via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`].
930
- ///
931
- /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
932
- /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
933
- fn send_payment_internal < R : Deref , NS : Deref , ES : Deref , IH , SP , L : Deref > (
934
- & self , payment_id : PaymentId , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields ,
935
- keysend_preimage : Option < PaymentPreimage > , retry_strategy : Retry , mut route_params : RouteParameters ,
936
- router : & R , first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES ,
937
- node_signer : & NS , best_block_height : u32 , logger : & L ,
938
- pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > , send_payment_along_path : SP ,
939
- ) -> Result < ( ) , RetryableSendFailure >
928
+ fn find_initial_route < R : Deref , NS : Deref , IH , L : Deref > (
929
+ & self , payment_id : PaymentId , payment_hash : PaymentHash ,
930
+ recipient_onion : & RecipientOnionFields , keysend_preimage : Option < PaymentPreimage > ,
931
+ route_params : & mut RouteParameters , router : & R , first_hops : & Vec < ChannelDetails > ,
932
+ inflight_htlcs : & IH , node_signer : & NS , best_block_height : u32 , logger : & L ,
933
+ ) -> Result < Route , RetryableSendFailure >
940
934
where
941
935
R :: Target : Router ,
942
- ES :: Target : EntropySource ,
943
936
NS :: Target : NodeSigner ,
944
937
L :: Target : Logger ,
945
938
IH : Fn ( ) -> InFlightHtlcs ,
946
- SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
947
939
{
948
940
#[ cfg( feature = "std" ) ] {
949
941
if has_expired ( & route_params) {
@@ -954,7 +946,7 @@ impl OutboundPayments {
954
946
}
955
947
956
948
onion_utils:: set_max_path_length (
957
- & mut route_params, & recipient_onion, keysend_preimage, best_block_height
949
+ route_params, recipient_onion, keysend_preimage, best_block_height
958
950
)
959
951
. map_err ( |( ) | {
960
952
log_error ! ( logger, "Can't construct an onion packet without exceeding 1300-byte onion \
@@ -963,7 +955,7 @@ impl OutboundPayments {
963
955
} ) ?;
964
956
965
957
let mut route = router. find_route_with_id (
966
- & node_signer. get_node_id ( Recipient :: Node ) . unwrap ( ) , & route_params,
958
+ & node_signer. get_node_id ( Recipient :: Node ) . unwrap ( ) , route_params,
967
959
Some ( & first_hops. iter ( ) . collect :: < Vec < _ > > ( ) ) , inflight_htlcs ( ) ,
968
960
payment_hash, payment_id,
969
961
) . map_err ( |_| {
@@ -972,12 +964,40 @@ impl OutboundPayments {
972
964
RetryableSendFailure :: RouteNotFound
973
965
} ) ?;
974
966
975
- if route. route_params . as_ref ( ) != Some ( & route_params) {
967
+ if route. route_params . as_ref ( ) != Some ( route_params) {
976
968
debug_assert ! ( false ,
977
969
"Routers are expected to return a Route which includes the requested RouteParameters" ) ;
978
970
route. route_params = Some ( route_params. clone ( ) ) ;
979
971
}
980
972
973
+ Ok ( route)
974
+ }
975
+
976
+ /// Errors immediately on [`RetryableSendFailure`] error conditions. Otherwise, further errors may
977
+ /// be surfaced asynchronously via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`].
978
+ ///
979
+ /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
980
+ /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
981
+ fn send_payment_internal < R : Deref , NS : Deref , ES : Deref , IH , SP , L : Deref > (
982
+ & self , payment_id : PaymentId , payment_hash : PaymentHash , recipient_onion : RecipientOnionFields ,
983
+ keysend_preimage : Option < PaymentPreimage > , retry_strategy : Retry , mut route_params : RouteParameters ,
984
+ router : & R , first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES ,
985
+ node_signer : & NS , best_block_height : u32 , logger : & L ,
986
+ pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > , send_payment_along_path : SP ,
987
+ ) -> Result < ( ) , RetryableSendFailure >
988
+ where
989
+ R :: Target : Router ,
990
+ ES :: Target : EntropySource ,
991
+ NS :: Target : NodeSigner ,
992
+ L :: Target : Logger ,
993
+ IH : Fn ( ) -> InFlightHtlcs ,
994
+ SP : Fn ( SendAlongPathArgs ) -> Result < ( ) , APIError > ,
995
+ {
996
+ let route = self . find_initial_route (
997
+ payment_id, payment_hash, & recipient_onion, keysend_preimage, & mut route_params, router,
998
+ & first_hops, & inflight_htlcs, node_signer, best_block_height, logger,
999
+ ) ?;
1000
+
981
1001
let onion_session_privs = self . add_new_pending_payment ( payment_hash,
982
1002
recipient_onion. clone ( ) , payment_id, keysend_preimage, & route, Some ( retry_strategy) ,
983
1003
Some ( route_params. payment_params . clone ( ) ) , entropy_source, best_block_height)
0 commit comments