paymentsdb: add note to RegisterAttempt

This commit is contained in:
ziggie committed 2026-02-25 08:02:14 +01:00
1 parent 510f6fb532
commit d2cdd9d86f
1 file changed
+11
+11
View File
@@ -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