2019-04-16 12:33:30 +03:00
|
|
|
package contractcourt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
|
|
|
"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 {
|
2019-12-20 13:25:07 +03:00
|
|
|
notifyChan chan notifyExitHopData
|
|
|
|
notifyErr error
|
|
|
|
notifyResolution *invoices.HtlcResolution
|
2019-04-16 12:33:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *mockRegistry) NotifyExitHopHtlc(payHash lntypes.Hash,
|
|
|
|
paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32,
|
2019-08-08 16:48:31 +03:00
|
|
|
circuitKey channeldb.CircuitKey, hodlChan chan<- interface{},
|
2019-12-20 13:25:07 +03:00
|
|
|
payload invoices.Payload) (*invoices.HtlcResolution, error) {
|
2019-04-16 12:33:30 +03:00
|
|
|
|
|
|
|
r.notifyChan <- notifyExitHopData{
|
|
|
|
hodlChan: hodlChan,
|
|
|
|
payHash: payHash,
|
|
|
|
paidAmount: paidAmount,
|
|
|
|
expiry: expiry,
|
|
|
|
currentHeight: currentHeight,
|
|
|
|
}
|
|
|
|
|
2019-12-20 13:25:07 +03:00
|
|
|
return r.notifyResolution, r.notifyErr
|
2019-04-16 12:33:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *mockRegistry) HodlUnsubscribeAll(subscriber chan<- interface{}) {}
|
|
|
|
|
2019-08-20 15:54:39 +03:00
|
|
|
func (r *mockRegistry) LookupInvoice(lntypes.Hash) (channeldb.Invoice,
|
2019-04-16 12:33:30 +03:00
|
|
|
error) {
|
|
|
|
|
2019-08-20 15:54:39 +03:00
|
|
|
return channeldb.Invoice{}, channeldb.ErrInvoiceNotFound
|
2019-04-16 12:33:30 +03:00
|
|
|
}
|