invoices+channeldb: move invoice state check to invoiceregistry

This commit is contained in:
Joost Jager
2019-06-10 12:02:06 +02:00
parent e45d4d703a
commit 18c025151a
3 changed files with 13 additions and 11 deletions

View File

@@ -526,6 +526,15 @@ func (i *InvoiceRegistry) LookupInvoice(rHash lntypes.Hash) (channeldb.Invoice,
func (i *InvoiceRegistry) checkHtlcParameters(invoice *channeldb.Invoice,
amtPaid lnwire.MilliSatoshi, htlcExpiry uint32, currentHeight int32) error {
switch invoice.Terms.State {
case channeldb.ContractAccepted:
return channeldb.ErrInvoiceAlreadyAccepted
case channeldb.ContractSettled:
return channeldb.ErrInvoiceAlreadySettled
case channeldb.ContractCanceled:
return channeldb.ErrInvoiceAlreadyCanceled
}
expiry, err := i.decodeFinalCltvExpiry(string(invoice.PaymentRequest))
if err != nil {
return err