mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
channeldb: move idempotency up the call tree
As a preparation for subscribing to single invoices, InvoiceRegistry needs to become aware of settling a settled invoice.
This commit is contained in:
@@ -378,6 +378,14 @@ func (i *InvoiceRegistry) SettleInvoice(rHash lntypes.Hash,
|
||||
// If this isn't a debug invoice, then we'll attempt to settle an
|
||||
// invoice matching this rHash on disk (if one exists).
|
||||
invoice, err := i.cdb.SettleInvoice(rHash, amtPaid)
|
||||
|
||||
// Implement idempotency by returning success if the invoice was already
|
||||
// settled.
|
||||
if err == channeldb.ErrInvoiceAlreadySettled {
|
||||
log.Debugf("Invoice %v already settled", rHash)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user