From 16c13568a902fd3b72683c901819e64d3a332cd7 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 27 Apr 2022 08:34:04 -0500 Subject: [PATCH] Lnd probing: only update route with mpp record if we can (#4293) --- .../lnd/rpc/internal/LndRouterClient.scala | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lnd-rpc/src/main/scala/org/bitcoins/lnd/rpc/internal/LndRouterClient.scala b/lnd-rpc/src/main/scala/org/bitcoins/lnd/rpc/internal/LndRouterClient.scala index 6048a56af8..8c71717cef 100644 --- a/lnd-rpc/src/main/scala/org/bitcoins/lnd/rpc/internal/LndRouterClient.scala +++ b/lnd-rpc/src/main/scala/org/bitcoins/lnd/rpc/internal/LndRouterClient.scala @@ -73,15 +73,20 @@ trait LndRouterClient { self: LndRpcClient => } def sendToRoute(invoice: LnInvoice, route: Route): Future[HTLCAttempt] = { - val milliSatoshis = - invoice.amount.map(MilliSatoshis(_)).getOrElse(MilliSatoshis.zero) - val last = route.hops.last - val secret = invoice.lnTags.secret.get.secret.bytes - val mpp = - MPPRecord(paymentAddr = secret, totalAmtMsat = milliSatoshis.toLong) - val update = last.copy(mppRecord = Some(mpp), tlvPayload = true) - val updatedHops = route.hops.init :+ update - val updatedRoute = route.copy(hops = updatedHops) + val updatedRoute = invoice.lnTags.secret match { + case Some(secretTag) => + val milliSatoshis = + invoice.amount.map(MilliSatoshis(_)).getOrElse(MilliSatoshis.zero) + val last = route.hops.last + val secret = secretTag.secret.bytes + val mpp = + MPPRecord(paymentAddr = secret, totalAmtMsat = milliSatoshis.toLong) + val update = last.copy(mppRecord = Some(mpp), tlvPayload = true) + val updatedHops = route.hops.init :+ update + + route.copy(hops = updatedHops) + case None => route + } val request = SendToRouteRequest(paymentHash = invoice.lnTags.paymentHash.bytes,