Browse Source

handle failing htlc after restart

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
committed by ThomasV
parent
commit
864efa029b
  1. 10
      electrum/lnbase.py

10
electrum/lnbase.py

@ -1014,10 +1014,16 @@ class Peer(PrintError):
chan = self.channels[channel_id] chan = self.channels[channel_id]
htlc_id = int.from_bytes(payload["id"], "big") htlc_id = int.from_bytes(payload["id"], "big")
key = (channel_id, htlc_id) key = (channel_id, htlc_id)
try:
route = self.attempted_route[key] route = self.attempted_route[key]
except KeyError:
# the remote might try to fail an htlc after we restarted...
# attempted_route is not persisted, so we will get here then
self.print_error("UPDATE_FAIL_HTLC. cannot decode! attempted route is MISSING. {}".format(key))
else:
failure_msg, sender_idx = decode_onion_error(payload["reason"], [x.node_id for x in route], chan.onion_keys[htlc_id]) failure_msg, sender_idx = decode_onion_error(payload["reason"], [x.node_id for x in route], chan.onion_keys[htlc_id])
code = failure_msg.code code = failure_msg.code
code_name = ONION_FAILURE_CODE_MAP.get(code, 'unknown_error!!') code_name = ONION_FAILURE_CODE_MAP.get(code, 'unknown_error??')
data = failure_msg.data data = failure_msg.data
self.print_error("UPDATE_FAIL_HTLC", code_name, code, data) self.print_error("UPDATE_FAIL_HTLC", code_name, code, data)
try: try:
@ -1028,8 +1034,8 @@ class Peer(PrintError):
# TODO this should depend on the error # TODO this should depend on the error
# also, we need finer blacklisting (directed edges; nodes) # also, we need finer blacklisting (directed edges; nodes)
self.network.path_finder.blacklist.add(short_chan_id) self.network.path_finder.blacklist.add(short_chan_id)
self.print_error("HTLC failure with code {} ({})".format(code, code_name)) self.print_error("HTLC failure with code {} ({})".format(code, code_name))
# process update_fail_htlc on channel
chan = self.channels[channel_id] chan = self.channels[channel_id]
chan.receive_fail_htlc(htlc_id) chan.receive_fail_htlc(htlc_id)
await self.receive_commitment(chan) await self.receive_commitment(chan)

Loading…
Cancel
Save