Skip to content

Commit 1f5ad75

Browse files
committed
paymentsdb: verify total amount for last hop in the blinded path
1 parent 509aa31 commit 1f5ad75

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

payments/db/errors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ var (
8383
// paths or vice versa.
8484
ErrMixedBlindedAndNonBlindedPayments = errors.New("mixed blinded and " +
8585
"non-blinded payments")
86+
// ErrBlindedPaymentMissingTotalAmount is returned if we try to
87+
// register a blinded payment attempt where the final hop doesn't set
88+
// the total amount.
89+
ErrBlindedPaymentMissingTotalAmount = errors.New("blinded payment " +
90+
"final hop must set total amount")
8691

8792
// ErrMPPPaymentAddrMismatch is returned if we try to register an MPP
8893
// shard where the payment address doesn't match existing shards.

payments/db/payment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,13 @@ func verifyAttempt(payment *MPPayment, attempt *HTLCAttemptInfo) error {
744744
// in the split payment is correct.
745745
isBlinded := len(attempt.Route.FinalHop().EncryptedData) != 0
746746

747+
// For blinded payments, the last hop must set the total amount.
748+
if isBlinded {
749+
if attempt.Route.FinalHop().TotalAmtMsat == 0 {
750+
return ErrBlindedPaymentMissingTotalAmount
751+
}
752+
}
753+
747754
// Make sure any existing shards match the new one with regards
748755
// to MPP options.
749756
mpp := attempt.Route.FinalHop().MPP

0 commit comments

Comments
 (0)