1616
1717package fr .acinq .eclair .payment .send
1818
19+ import akka .actor .typed .scaladsl .adapter .ClassicActorRefOps
1920import akka .actor .{ActorRef , FSM , Props , Status }
2021import akka .event .Logging .MDC
2122import fr .acinq .bitcoin .scalacompat .ByteVector32
@@ -58,7 +59,7 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
5859 val routeParams = r.routeParams.copy(randomize = false ) // we don't randomize the first attempt, regardless of configuration choices
5960 log.debug(" sending {} with maximum fee {}" , r.recipient.totalAmount, r.routeParams.getMaxFee(r.recipient.totalAmount))
6061 val d = PaymentProgress (r, r.maxAttempts, Map .empty, Ignore .empty, retryRouteRequest = false , failures = Nil )
61- router ! createRouteRequest(nodeParams, routeParams, d, cfg)
62+ router ! createRouteRequest(self, nodeParams, routeParams, d, cfg)
6263 goto(WAIT_FOR_ROUTES ) using d
6364 }
6465
@@ -74,11 +75,11 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
7475 // remaining amount. In that case we discard these routes and send a new request to the router.
7576 log.debug(" discarding routes, another child payment failed so we need to recompute them ({} payments still pending for {})" , d.pending.size, d.pending.values.map(_.amount).sum)
7677 val routeParams = d.request.routeParams.copy(randomize = true ) // we randomize route selection when we retry
77- router ! createRouteRequest(nodeParams, routeParams, d, cfg)
78+ router ! createRouteRequest(self, nodeParams, routeParams, d, cfg)
7879 stay() using d.copy(retryRouteRequest = false )
7980 }
8081
81- case Event (Status . Failure (t), d : PaymentProgress ) =>
82+ case Event (PaymentRouteNotFound (t), d : PaymentProgress ) =>
8283 log.warning(" router error: {}" , t.getMessage)
8384 // If no route can be found, we will retry once with the channels that we previously ignored.
8485 // Channels are mostly ignored for temporary reasons, likely because they didn't have enough balance to forward
@@ -87,7 +88,7 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
8788 if (d.ignore.channels.nonEmpty) {
8889 log.debug(" retry sending payment without ignoring channels {} ({} payments still pending for {})" , d.ignore.channels.map(_.shortChannelId).mkString(" ," ), d.pending.size, d.pending.values.map(_.amount).sum)
8990 val routeParams = d.request.routeParams.copy(randomize = true ) // we randomize route selection when we retry
90- router ! createRouteRequest(nodeParams, routeParams, d, cfg).copy(ignore = d.ignore.emptyChannels())
91+ router ! createRouteRequest(self, nodeParams, routeParams, d, cfg).copy(ignore = d.ignore.emptyChannels())
9192 retriedFailedChannels = true
9293 stay() using d.copy(remainingAttempts = (d.remainingAttempts - 1 ).max(0 ), ignore = d.ignore.emptyChannels(), retryRouteRequest = false )
9394 } else {
@@ -135,7 +136,7 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
135136 log.debug(" child payment failed, retrying payment ({} payments still pending for {})" , stillPending.size, stillPending.values.map(_.amount).sum)
136137 val routeParams = d.request.routeParams.copy(randomize = true ) // we randomize route selection when we retry
137138 val d1 = d.copy(pending = stillPending, ignore = ignore1, failures = d.failures ++ pf.failures, request = d.request.copy(recipient = recipient1), retryRouteRequest = false )
138- router ! createRouteRequest(nodeParams, routeParams, d1, cfg)
139+ router ! createRouteRequest(self, nodeParams, routeParams, d1, cfg)
139140 goto(WAIT_FOR_ROUTES ) using d1
140141 }
141142
@@ -164,7 +165,7 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
164165 gotoSucceededOrStop(PaymentSucceeded (d.request, ps.paymentPreimage, ps.parts, d.pending - ps.parts.head.id))
165166
166167 case Event (_ : RouteResponse , _) => stay()
167- case Event (_ : Status . Failure , _) => stay()
168+ case Event (_ : PaymentRouteNotFound , _) => stay()
168169 }
169170
170171 when(PAYMENT_SUCCEEDED ) {
@@ -190,7 +191,7 @@ class MultiPartPaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig,
190191 }
191192
192193 case Event (_ : RouteResponse , _) => stay()
193- case Event (_ : Status . Failure , _) => stay()
194+ case Event (_ : PaymentRouteNotFound , _) => stay()
194195 }
195196
196197 private def spawnChildPaymentFsm (childId : UUID ): ActorRef = {
@@ -368,8 +369,8 @@ object MultiPartPaymentLifecycle {
368369 */
369370 case class PaymentSucceeded (request : SendMultiPartPayment , preimage : ByteVector32 , parts : Seq [PartialPayment ], pending : Set [UUID ]) extends Data
370371
371- private def createRouteRequest (nodeParams : NodeParams , routeParams : RouteParams , d : PaymentProgress , cfg : SendPaymentConfig ): RouteRequest = {
372- RouteRequest (nodeParams.nodeId, d.request.recipient, routeParams, d.ignore, allowMultiPart = true , d.pending.values.toSeq, Some (cfg.paymentContext))
372+ private def createRouteRequest (replyTo : ActorRef , nodeParams : NodeParams , routeParams : RouteParams , d : PaymentProgress , cfg : SendPaymentConfig ): RouteRequest = {
373+ RouteRequest (replyTo.toTyped, nodeParams.nodeId, d.request.recipient, routeParams, d.ignore, allowMultiPart = true , d.pending.values.toSeq, Some (cfg.paymentContext))
373374 }
374375
375376 private def createChildPayment (replyTo : ActorRef , route : Route , request : SendMultiPartPayment ): SendPaymentToRoute = {
0 commit comments