From 5ee368f0f9f911c6e7032dcde2365359648200ca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 17 Jul 2018 16:28:08 -0700 Subject: [PATCH] channeldb: ensure that we return an invoice on duplicate settles In this commit, we fix an existing bug related to duplicate invoice settle.s Before this commit, the second (and later) times an invoice was settled we would return a nil pointer. This would result in the new invoiceRegistry panicing as it would go to attempt to notify with a nil invoice. We fix this by returning the invoice on disk (unmodified) for each settle after the initial one. Fixes #1568. --- channeldb/invoices.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/channeldb/invoices.go b/channeldb/invoices.go index d315c4a0..feb07442 100644 --- a/channeldb/invoices.go +++ b/channeldb/invoices.go @@ -8,9 +8,9 @@ import ( "io" "time" + "github.com/btcsuite/btcd/wire" "github.com/coreos/bbolt" "github.com/lightningnetwork/lnd/lnwire" - "github.com/btcsuite/btcd/wire" ) var ( @@ -704,7 +704,7 @@ func settleInvoice(invoices, settleIndex *bolt.Bucket, invoiceNum []byte, // Add idempotency to duplicate settles, return here to avoid // overwriting the previous info. if invoice.Terms.Settled { - return nil, nil + return &invoice, nil } // Now that we know the invoice hasn't already been settled, we'll