lnd.xprv/contractcourt
Joost Jager d6d9ec6aa5
invoices: replay awareness
Previously the invoice registry wasn't aware of replayed htlcs. This was
dealt with by keeping the invoice accept/settle logic idempotent, so
that a replay wouldn't have an effect.

This mechanism has two limitations:

1. No accurate tracking of the total amount paid to an invoice. The total
amount couldn't just be increased with every htlc received, because it
could be a replay which would lead to counting the htlc amount multiple
times. Therefore the total amount was set to the amount of the first
htlc that was received, even though there may have been multiple htlcs
paying to the invoice.

2. Impossible to check htlc expiry consistently for hodl invoices. When
an htlc is new, its expiry needs to be checked against the invoice cltv
delta. But for a replay, that check must be skipped. The htlc was
accepted in time, the invoice was moved to the accepted state and a
replay some blocks later shouldn't lead to that htlc being cancelled.
Because the invoice registry couldn't recognize replays, it stopped
checking htlc expiry heights when the invoice reached the accepted
state. This prevents hold htlcs from being cancelled after a restart.
But unfortunately this also caused additional htlcs to be accepted on an
already accepted invoice without their expiry being checked.

In this commit, the invoice registry starts to persistently track htlcs
so that replays can be recognized. For replays, an htlc resolution
action is returned early. This fixes both limitations mentioned above.
2019-09-04 19:20:31 +02:00
..
briefcase_test.go contractcourt: add storage for the confirmed CommitSet 2019-05-27 15:26:44 -07:00
briefcase.go contractcourt/briefcase: avoid bucket modification in ForEach loop 2019-06-14 21:09:02 +02:00
chain_arbitrator_test.go contractcourt: add new ChainArbitrator struct as central coordinator of package 2018-01-22 19:19:36 -08:00
chain_arbitrator.go contractcourt: write confirmed CommitSet to disk before MarkChannelClosed 2019-05-27 15:26:46 -07:00
chain_watcher_test.go multi: address lingering TODO by no longer wiping out local HTLCs on remote close 2019-05-27 14:34:13 -07:00
chain_watcher.go contractcourt: add new checkLocalChainActions method use in main state step 2019-05-27 15:26:36 -07:00
channel_arbitrator_test.go contractcourt: write confirmed CommitSet to disk before MarkChannelClosed 2019-05-27 15:26:46 -07:00
channel_arbitrator.go invoices: replay awareness 2019-09-04 19:20:31 +02:00
commit_sweep_resolver.go multi: support arbitrary client fee preferences to UtxoSweeper 2019-05-24 15:30:38 -07:00
contract_resolvers.go cnct: expose non-incubating htlcs after channel force close 2019-02-01 09:36:47 +01:00
htlc_incoming_contest_resolver.go cnct+htlcswitch+invoices: report circuit key to invoice registry 2019-09-04 19:20:13 +02:00
htlc_incoming_resolver_test.go cnct/test: add incoming contest resolver test 2019-05-15 14:42:18 +02:00
htlc_outgoing_contest_resolver.go contractcourt: extract which timeout HTLC output to watch into new method 2019-03-19 16:50:09 -07:00
htlc_success_resolver.go cnct+htlcswitch+invoices: move invoice parameter check out of link 2019-05-15 14:42:12 +02:00
htlc_timeout_resolver_test.go cnct/test: extend mockWitnessBeacon 2019-05-15 14:42:15 +02:00
htlc_timeout_resolver.go contractcourt: simplify htlcTimeoutResolver, unify with HTLC contest logic 2019-03-19 16:50:27 -07:00
interfaces.go multi: use separate cltv expiry field from invoice 2019-09-04 19:20:19 +02:00
log.go multi: init subsystem loggers via build pkg 2018-10-05 13:04:45 +09:00
mock_registry_test.go multi: use separate cltv expiry field from invoice 2019-09-04 19:20:19 +02:00
utils_test.go cnct/test: add incoming contest resolver test 2019-05-15 14:42:18 +02:00