paymentsdb: make verifyAttempt more robust

We now return an error when blinded and non blinded attempts are
combined. This was theoretically possible to register a legacy
attempt in combination with a blinded payment. This would have
been prevented by other checks in the code because legacy payments
are not split into shards.
This commit is contained in:
ziggie authored and yyforyongyu committed 2025-11-12 22:54:03 +08:00
1 parent cbfc0e0dc2
commit c08f918ffc
3 files changed
+273

No files matched your search

+8
View File
@@ -755,6 +755,7 @@ func verifyAttempt(payment *MPPayment, attempt *HTLCAttemptInfo) error {
for _, h := range payment.InFlightHTLCs() {
hMpp := h.Route.FinalHop().MPP
hBlinded := len(h.Route.FinalHop().EncryptedData) != 0
// If this is a blinded payment, then no existing HTLCs
// should have MPP records.
@@ -762,6 +763,13 @@ func verifyAttempt(payment *MPPayment, attempt *HTLCAttemptInfo) error {
return ErrMPPRecordInBlindedPayment
}
// If the payment is blinded (previous attempts used blinded
// paths) and the attempt is not, or vice versa, return an
// error.
if isBlinded != hBlinded {
return ErrMixedBlindedAndNonBlindedPayments
}
// If this is a blinded payment, then we just need to
// check that the TotalAmtMsat field for this shard
// is equal to that of any other shard in the same