mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
5ff5225245
Now that we have the new package `lnd/channeldb/models` we can invert the depenency between `channeldb` and `invoices`. - Move all the invoice related types and errors to the `invoices` package. - Ensure that all the packages dealing with invoices use the types and interfaces defined in the `invoices` package. - Implement the InvoiceDB interface (defined in `lnd/invoices`) in channeldb. - Add new mock for InterfaceDB. - `InvoiceRegistery` tests are now in its own subpacakge (they need to import both invoices & channeldb). This is temporary until we can decouple them.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package contractcourt
|
|
|
|
import (
|
|
"github.com/lightningnetwork/lnd/channeldb/models"
|
|
"github.com/lightningnetwork/lnd/invoices"
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
)
|
|
|
|
type notifyExitHopData struct {
|
|
payHash lntypes.Hash
|
|
paidAmount lnwire.MilliSatoshi
|
|
hodlChan chan<- interface{}
|
|
expiry uint32
|
|
currentHeight int32
|
|
}
|
|
|
|
type mockRegistry struct {
|
|
notifyChan chan notifyExitHopData
|
|
notifyErr error
|
|
notifyResolution invoices.HtlcResolution
|
|
}
|
|
|
|
func (r *mockRegistry) NotifyExitHopHtlc(payHash lntypes.Hash,
|
|
paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32,
|
|
circuitKey models.CircuitKey, hodlChan chan<- interface{},
|
|
payload invoices.Payload) (invoices.HtlcResolution, error) {
|
|
|
|
r.notifyChan <- notifyExitHopData{
|
|
hodlChan: hodlChan,
|
|
payHash: payHash,
|
|
paidAmount: paidAmount,
|
|
expiry: expiry,
|
|
currentHeight: currentHeight,
|
|
}
|
|
|
|
return r.notifyResolution, r.notifyErr
|
|
}
|
|
|
|
func (r *mockRegistry) HodlUnsubscribeAll(subscriber chan<- interface{}) {}
|
|
|
|
func (r *mockRegistry) LookupInvoice(lntypes.Hash) (invoices.Invoice,
|
|
error) {
|
|
|
|
return invoices.Invoice{}, invoices.ErrInvoiceNotFound
|
|
}
|