cnct+htlcswitch+invoices: report circuit key to invoice registry

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.
This commit is contained in:
Joost Jager
2019-08-08 15:48:31 +02:00
parent 5871d69bde
commit 05e6b62cb2
9 changed files with 76 additions and 28 deletions

View File

@@ -27,6 +27,9 @@ type htlcIncomingContestResolver struct {
// successfully.
htlcExpiry uint32
// circuitKey describes the incoming htlc that is being resolved.
circuitKey channeldb.CircuitKey
// htlcSuccessResolver is the inner resolver that may be utilized if we
// learn of the preimage.
htlcSuccessResolver
@@ -166,7 +169,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
// identical to HTLC resolution in the link.
event, err := h.Registry.NotifyExitHopHtlc(
h.payHash, h.htlcAmt, h.htlcExpiry, currentHeight,
hodlChan, nil,
h.circuitKey, hodlChan, nil,
)
switch err {
case channeldb.ErrInvoiceNotFound: