Merge pull request #4924 from champo/check_payreq_multipart

routerrpc,routing: limit max parts if the invoice doesn't declare MPP support
This commit is contained in:
Olaoluwa Osuntokun 2021-02-03 16:53:49 -08:00 committed by GitHub
commit 301f1a870e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

@ -648,6 +648,10 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.Amount = *payReq.MilliSat
}
if !payReq.Features.HasFeature(lnwire.MPPOptional) {
payIntent.MaxParts = 1
}
copy(payIntent.PaymentHash[:], payReq.PaymentHash[:])
destKey := payReq.Destination.SerializeCompressed()
copy(payIntent.Target[:], destKey)

@ -278,6 +278,12 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
return nil, errNoPathFound
}
if !p.payment.DestFeatures.HasFeature(lnwire.MPPOptional) {
p.log.Debug("not splitting because destination doesn't declare MPP")
return nil, errNoPathFound
}
// No splitting if this is the last shard.
isLastShard := activeShards+1 >= p.payment.MaxParts
if isLastShard {