From d2cdd9d86f3cf519a4ad9427e9a6ea8d70a6a75a Mon Sep 17 00:00:00 2001 From: ziggie Date: Thu, 13 Nov 2025 10:42:05 +0100 Subject: [PATCH] paymentsdb: add note to RegisterAttempt --- payments/db/interface.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/payments/db/interface.go b/payments/db/interface.go index c41dc371f..7fefad089 100644 --- a/payments/db/interface.go +++ b/payments/db/interface.go @@ -61,6 +61,17 @@ type PaymentControl interface { InitPayment(lntypes.Hash, *PaymentCreationInfo) error // RegisterAttempt atomically records the provided HTLCAttemptInfo. + // + // IMPORTANT: Callers MUST serialize calls to RegisterAttempt for the + // same payment hash. Concurrent calls will result in race conditions + // where both calls read the same initial payment state, validate + // against stale data, and could cause overpayment. For example: + // - Both goroutines fetch payment with 400 sats sent + // - Both validate sending 650 sats won't overpay (within limit) + // - Both commit successfully + // - Result: 1700 sats sent, exceeding the payment amount + // The payment router/controller layer is responsible for ensuring + // serialized access per payment hash. RegisterAttempt(lntypes.Hash, *HTLCAttemptInfo) (*MPPayment, error) // SettleAttempt marks the given attempt settled with the preimage. If