Lnd probing: only update route with mpp record if we can (#4293)

This commit is contained in:
benthecarman 2022-04-27 08:34:04 -05:00 committed by GitHub
parent 6db1f26625
commit 16c13568a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,