mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
ad5cd9c8bb
* multi: extend InvoiceDB methods with a context argument This commit adds a context to InvoiceDB's methods. Along this refactor we also extend InvoiceRegistry methods with contexts where it makes sense. This change is essential to be able to provide kvdb and sqldb implementations for InvoiceDB. * channeldb: restrict invoice tests to only use an InvoiceDB instance * docs: update release notes for 0.18.0
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package contractcourt
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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(context.Context, lntypes.Hash) (
|
|
invoices.Invoice, error) {
|
|
|
|
return invoices.Invoice{}, invoices.ErrInvoiceNotFound
|
|
}
|