invoices+htlcswitch+lnrpc: cancel invoice

This commit is contained in:
Joost Jager
2019-01-11 11:19:16 +01:00
parent 9cd88a04b7
commit 1b87fbfab2
13 changed files with 1020 additions and 590 deletions

View File

@@ -18,7 +18,7 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lightning-onion"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
@@ -735,6 +735,25 @@ func (i *mockInvoiceRegistry) SettleInvoice(rhash lntypes.Hash,
return nil
}
func (i *mockInvoiceRegistry) CancelInvoice(payHash lntypes.Hash) error {
i.Lock()
defer i.Unlock()
invoice, ok := i.invoices[payHash]
if !ok {
return channeldb.ErrInvoiceNotFound
}
if invoice.Terms.State == channeldb.ContractCanceled {
return nil
}
invoice.Terms.State = channeldb.ContractCanceled
i.invoices[payHash] = invoice
return nil
}
func (i *mockInvoiceRegistry) AddInvoice(invoice channeldb.Invoice) error {
i.Lock()
defer i.Unlock()