mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-25 16:01:04 +02:00
Currently the invoice registry cannot tell apart the htlcs that pay to an invoice. Because htlcs may also be replayed on startup, it isn't possible to determine the total amount paid to an invoice. This commit is a first step towards fixing that. It reports the circuit keys of htlcs to the invoice registry, which forms the basis for accurate invoice accounting.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
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 {
|
|
notifyChan chan notifyExitHopData
|
|
notifyErr error
|
|
notifyEvent *invoices.HodlEvent
|
|
}
|
|
|
|
func (r *mockRegistry) NotifyExitHopHtlc(payHash lntypes.Hash,
|
|
paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32,
|
|
circuitKey channeldb.CircuitKey, hodlChan chan<- interface{},
|
|
eob []byte) (*invoices.HodlEvent, error) {
|
|
|
|
r.notifyChan <- notifyExitHopData{
|
|
hodlChan: hodlChan,
|
|
payHash: payHash,
|
|
paidAmount: paidAmount,
|
|
expiry: expiry,
|
|
currentHeight: currentHeight,
|
|
}
|
|
|
|
return r.notifyEvent, r.notifyErr
|
|
}
|
|
|
|
func (r *mockRegistry) HodlUnsubscribeAll(subscriber chan<- interface{}) {}
|
|
|
|
func (r *mockRegistry) LookupInvoice(lntypes.Hash) (channeldb.Invoice, uint32,
|
|
error) {
|
|
|
|
return channeldb.Invoice{}, 0, channeldb.ErrInvoiceNotFound
|
|
}
|