@@ -208,43 +208,40 @@ class PaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig, router: A
208208 Metrics .PaymentError .withTag(Tags .Failure , Tags .FailureType (UnreadableRemoteFailure (request.amount, Nil , e, htlcFailure.holdTimes))).increment()
209209 failure
210210 }) match {
211- case res@ Right (Sphinx .DecryptedFailurePacket (nodeId , failureMessage)) =>
211+ case res@ Right (Sphinx .DecryptedFailurePacket (_, index , failureMessage)) =>
212212 // We have discovered some liquidity information with this payment: we update the router accordingly.
213- val stoppedRoute = route.stopAt(nodeId )
213+ val stoppedRoute = route.stopAt(index )
214214 if (stoppedRoute.hops.length > 1 ) {
215215 router ! Router .RouteCouldRelay (stoppedRoute)
216216 }
217217 failureMessage match {
218218 case TemporaryChannelFailure (update_opt, _) =>
219- route.hops.find(_.nodeId == nodeId) match {
220- case Some (failingHop) =>
221- val isLiquidityIssue = update_opt match {
222- // If the relay parameters have changed, it's not necessarily a liquidity issue.
223- case Some (update) => HopRelayParams .areSame(failingHop.params, HopRelayParams .FromAnnouncement (update), ignoreHtlcSize = true )
224- case None => true
225- }
226- if (isLiquidityIssue) {
227- router ! Router .ChannelCouldNotRelay (stoppedRoute.amount, failingHop)
228- }
229- case _ => ()
219+ val failingHop = route.hops(index)
220+ val isLiquidityIssue = update_opt match {
221+ // If the relay parameters have changed, it's not necessarily a liquidity issue.
222+ case Some (update) => HopRelayParams .areSame(failingHop.params, HopRelayParams .FromAnnouncement (update), ignoreHtlcSize = true )
223+ case None => true
224+ }
225+ if (isLiquidityIssue) {
226+ router ! Router .ChannelCouldNotRelay (stoppedRoute.amount, failingHop)
230227 }
231228 case _ => // other errors should not be used for liquidity issues
232229 }
233230 res
234231 case res => res
235232 }) match {
236- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage)) if nodeId == recipient.nodeId =>
233+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage)) if nodeId == recipient.nodeId =>
237234 // if destination node returns an error, we fail the payment immediately
238235 log.warning(s " received an error message from target nodeId= $nodeId, failing the payment (failure= $failureMessage) " )
239236 myStop(request, Left (PaymentFailed (id, paymentHash, failures :+ RemoteFailure (request.amount, route.fullRoute, e))))
240- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage)) if route.finalHop_opt.collect { case h : NodeHop if h.nodeId == nodeId => h }.nonEmpty =>
237+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage)) if route.finalHop_opt.collect { case h : NodeHop if h.nodeId == nodeId => h }.nonEmpty =>
241238 // if trampoline node returns an error, we fail the payment immediately
242239 log.warning(s " received an error message from trampoline nodeId= $nodeId, failing the payment (failure= $failureMessage) " )
243240 myStop(request, Left (PaymentFailed (id, paymentHash, failures :+ RemoteFailure (request.amount, route.fullRoute, e))))
244241 case res if failures.size + 1 >= request.maxAttempts =>
245242 // otherwise we never try more than maxAttempts, no matter the kind of error returned
246243 val failure = res match {
247- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage)) =>
244+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage)) =>
248245 log.info(s " received an error message from nodeId= $nodeId (failure= $failureMessage) " )
249246 failureMessage match {
250247 case failureMessage : Update => handleUpdate(nodeId, failureMessage, d)
@@ -261,11 +258,11 @@ class PaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig, router: A
261258 log.warning(s " cannot parse returned error: unwrapped= $unwrapped, route= ${route.printNodes()}" )
262259 val failure = UnreadableRemoteFailure (request.amount, route.fullRoute, e, htlcFailure.holdTimes)
263260 retry(failure, d)
264- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage : Node )) =>
261+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage : Node )) =>
265262 log.info(s " received 'Node' type error message from nodeId= $nodeId, trying to route around it (failure= $failureMessage) " )
266263 val failure = RemoteFailure (request.amount, route.fullRoute, e)
267264 retry(failure, d)
268- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage : Update )) =>
265+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage : Update )) =>
269266 log.info(s " received 'Update' type error message from nodeId= $nodeId, retrying payment (failure= $failureMessage) " )
270267 val failure = RemoteFailure (request.amount, route.fullRoute, e)
271268 if (failureMessage.update_opt.forall(update => Announcements .checkSig(update, nodeId))) {
@@ -292,7 +289,7 @@ class PaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig, router: A
292289 goto(WAITING_FOR_ROUTE ) using WaitingForRoute (request, failures :+ failure, ignore + nodeId)
293290 }
294291 }
295- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _ : InvalidOnionBlinding )) =>
292+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, _ : InvalidOnionBlinding )) =>
296293 // there was a failure inside the blinded route we used: we cannot know why it failed, so let's ignore it.
297294 log.info(s " received an error coming from nodeId= $nodeId inside the blinded route, retrying with different blinded routes " )
298295 val failure = RemoteFailure (request.amount, route.fullRoute, e)
@@ -305,7 +302,7 @@ class PaymentLifecycle(nodeParams: NodeParams, cfg: SendPaymentConfig, router: A
305302 router ! RouteRequest (self, nodeParams.nodeId, recipient, request.routeParams, ignore1, paymentContext = Some (cfg.paymentContext))
306303 goto(WAITING_FOR_ROUTE ) using WaitingForRoute (request, failures :+ failure, ignore1)
307304 }
308- case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, failureMessage)) =>
305+ case Right (e@ Sphinx .DecryptedFailurePacket (nodeId, _, failureMessage)) =>
309306 log.info(s " received an error message from nodeId= $nodeId, trying to use a different channel (failure= $failureMessage) " )
310307 val failure = RemoteFailure (request.amount, route.fullRoute, e)
311308 retry(failure, d)
0 commit comments