htlcswitch: reject duplicate payments to same invoice
In this commit, we modify the way the link handles HTLC’s that it detects is destined for itself. Before this commit if a payment hash came across for an invoice we’d already settled, then we’d gladly accept the payment _again_. As we’d like to enforce the norm that an invoice is NEVER to be used twice, this commit modifies that behavior to instead reject an incoming payment that attempts to re-use an invoice. Fixes #560.
This commit is contained in:
2 files changed
+80
-4
No files matched your search
@@ -1313,6 +1313,20 @@ func (l *channelLink) processLockedInHtlcs(
|
||||
continue
|
||||
}
|
||||
|
||||
// If this invoice has already been settled,
|
||||
// then we'll reject it as we don't allow an
|
||||
// invoice to be paid twice.
|
||||
if invoice.Terms.Settled == true {
|
||||
log.Warnf("Rejecting duplicate "+
|
||||
"payment for hash=%x", pd.RHash[:])
|
||||
failure := lnwire.FailUnknownPaymentHash{}
|
||||
l.sendHTLCError(
|
||||
pd.HtlcIndex, failure, obfuscator,
|
||||
)
|
||||
needUpdate = true
|
||||
continue
|
||||
}
|
||||
|
||||
// If we're not currently in debug mode, and
|
||||
// the extended htlc doesn't meet the value
|
||||
// requested, then we'll fail the htlc.
|
||||
|
||||
Reference in new issue
Block a user