htlcswitch: modify the InvoiceDatabase interface to allow specifying final payment amt

In this commit, we modify the InvoiceDatabase slightly to allow the link
to record what the final payment about for an invoice was. It may be the
case that the invoice actually had no specified value, or that the payer
paid more than necessary. As a result, it's important that our on-disk
records properly reflect this.

To fix this issue, the SettleInvoice method now also accepts the final
amount paid.

Fixes #856.
This commit is contained in:
Olaoluwa Osuntokun
2018-04-24 20:43:55 -07:00
parent edbdcddea1
commit a32f2b79da
4 changed files with 20 additions and 6 deletions

View File

@@ -673,7 +673,9 @@ func (i *mockInvoiceRegistry) LookupInvoice(rHash chainhash.Hash) (channeldb.Inv
return invoice, i.finalDelta, nil
}
func (i *mockInvoiceRegistry) SettleInvoice(rhash chainhash.Hash) error {
func (i *mockInvoiceRegistry) SettleInvoice(rhash chainhash.Hash,
amt lnwire.MilliSatoshi) error {
i.Lock()
defer i.Unlock()
@@ -687,6 +689,7 @@ func (i *mockInvoiceRegistry) SettleInvoice(rhash chainhash.Hash) error {
}
invoice.Terms.Settled = true
invoice.AmtPaid = amt
i.invoices[rhash] = invoice
return nil