cnct: add invoice registry interface
Create an interface type to be able to mock the registry in unit tests.
This commit is contained in:
2 files changed
+29
-2
No files matched your search
@@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/invoices"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/sweep"
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
@@ -146,7 +145,7 @@ type ChainArbitratorConfig struct {
|
|||||||
|
|
||||||
// Registry is the invoice database that is used by resolvers to lookup
|
// Registry is the invoice database that is used by resolvers to lookup
|
||||||
// preimages and settle invoices.
|
// preimages and settle invoices.
|
||||||
Registry *invoices.InvoiceRegistry
|
Registry Registry
|
||||||
|
|
||||||
// NotifyClosedChannel is a function closure that the ChainArbitrator
|
// NotifyClosedChannel is a function closure that the ChainArbitrator
|
||||||
// will use to notify the ChannelNotifier about a newly closed channel.
|
// will use to notify the ChannelNotifier about a newly closed channel.
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package contractcourt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/invoices"
|
||||||
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Registry is an interface which represents the invoice registry.
|
||||||
|
type Registry interface {
|
||||||
|
// LookupInvoice attempts to look up an invoice according to its 32
|
||||||
|
// byte payment hash. This method should also reutrn the min final CLTV
|
||||||
|
// delta for this invoice. We'll use this to ensure that the HTLC
|
||||||
|
// extended to us gives us enough time to settle as we prescribe.
|
||||||
|
LookupInvoice(lntypes.Hash) (channeldb.Invoice, uint32, error)
|
||||||
|
|
||||||
|
// NotifyExitHopHtlc attempts to mark an invoice as settled. If the
|
||||||
|
// invoice is a debug invoice, then this method is a noop as debug
|
||||||
|
// invoices are never fully settled. The return value describes how the
|
||||||
|
// htlc should be resolved. If the htlc cannot be resolved immediately,
|
||||||
|
// the resolution is sent on the passed in hodlChan later.
|
||||||
|
NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliSatoshi,
|
||||||
|
hodlChan chan<- interface{}) (*invoices.HodlEvent, error)
|
||||||
|
|
||||||
|
// HodlUnsubscribeAll unsubscribes from all hodl events.
|
||||||
|
HodlUnsubscribeAll(subscriber chan<- interface{})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user