mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
htlc: Replay unprocessed HTLCs loaded from the DB
This commit is contained in:
parent
f7bfe166a8
commit
909913c265
@ -1978,6 +1978,7 @@ void htlcs_reconnect(struct lightningd *ld,
|
||||
struct htlc_in *hin;
|
||||
struct htlc_out *hout;
|
||||
struct htlc_in_map unprocessed;
|
||||
enum onion_type failcode;
|
||||
|
||||
/* Any HTLCs which happened to be incoming and weren't forwarded before
|
||||
* we shutdown/crashed: fail them now.
|
||||
@ -2037,9 +2038,17 @@ void htlcs_reconnect(struct lightningd *ld,
|
||||
for (hin = htlc_in_map_first(&unprocessed, &ini); hin;
|
||||
hin = htlc_in_map_next(&unprocessed, &ini)) {
|
||||
log_unusual(hin->key.channel->log,
|
||||
"Failing old unprocessed HTLC #%"PRIu64,
|
||||
"Replaying old unprocessed HTLC #%"PRIu64,
|
||||
hin->key.id);
|
||||
fail_in_htlc(hin, WIRE_TEMPORARY_NODE_FAILURE, NULL, NULL);
|
||||
if (!peer_accepted_htlc(hin->key.channel, hin->key.id, &failcode)) {
|
||||
fail_in_htlc(hin,
|
||||
failcode != 0
|
||||
? failcode
|
||||
: WIRE_TEMPORARY_NODE_FAILURE,
|
||||
NULL, NULL);
|
||||
} else if (failcode) {
|
||||
fail_in_htlc(hin, failcode, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't leak memory! */
|
||||
|
@ -1125,6 +1125,10 @@ def test_onchain_multihtlc_our_unilateral(node_factory, bitcoind):
|
||||
|
||||
# Now, restart and manually reconnect end nodes (so they don't ignore HTLCs)
|
||||
# In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE.
|
||||
# TODO Remove our reliance on HTLCs failing on startup and the need for
|
||||
# this plugin
|
||||
nodes[0].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py'
|
||||
nodes[-1].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py'
|
||||
nodes[0].restart()
|
||||
nodes[-1].restart()
|
||||
|
||||
@ -1213,6 +1217,10 @@ def test_onchain_multihtlc_their_unilateral(node_factory, bitcoind):
|
||||
|
||||
# Now, restart and manually reconnect end nodes (so they don't ignore HTLCs)
|
||||
# In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE.
|
||||
# TODO Remove our reliance on HTLCs failing on startup and the need for
|
||||
# this plugin
|
||||
nodes[0].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py'
|
||||
nodes[-1].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py'
|
||||
nodes[0].restart()
|
||||
nodes[-1].restart()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user