cnct+htlcswitch+invoices: move invoice parameter check out of link

This commit is the final step in making the link unaware of invoices. It
now purely offers the htlc to the invoice registry and follows
instructions from the invoice registry about how and when to respond to
the htlc.

The change also fixes a bug where upon restart, hodl htlcs were
subjected to the invoice minimum cltv delta requirement again. If the
block height has increased in the mean while, the htlc would be canceled
back.

Furthermore the invoice registry interaction is aligned between link and
contract resolvers.
This commit is contained in:
Joost Jager
2019-04-16 12:11:20 +02:00
parent e095819385
commit 064e8492de
16 changed files with 533 additions and 265 deletions

View File

@@ -766,7 +766,9 @@ func newMockRegistry(minDelta uint32) *mockInvoiceRegistry {
return testInvoiceCltvExpiry, nil
}
registry := invoices.NewRegistry(cdb, decodeExpiry)
finalCltvRejectDelta := int32(5)
registry := invoices.NewRegistry(cdb, decodeExpiry, finalCltvRejectDelta)
registry.Start()
return &mockInvoiceRegistry{
@@ -784,10 +786,12 @@ func (i *mockInvoiceRegistry) SettleHodlInvoice(preimage lntypes.Preimage) error
}
func (i *mockInvoiceRegistry) NotifyExitHopHtlc(rhash lntypes.Hash,
amt lnwire.MilliSatoshi, hodlChan chan<- interface{}) (
*invoices.HodlEvent, error) {
amt lnwire.MilliSatoshi, expiry uint32, currentHeight int32,
hodlChan chan<- interface{}) (*invoices.HodlEvent, error) {
event, err := i.registry.NotifyExitHopHtlc(rhash, amt, hodlChan)
event, err := i.registry.NotifyExitHopHtlc(
rhash, amt, expiry, currentHeight, hodlChan,
)
if err != nil {
return nil, err
}