Skip to content

Commit

Permalink
lnpeer: make "trigger_force_close" work with eclair 0.7+ remotes
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Jun 7, 2022
1 parent 8251830 commit 90dbac5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions electrum/lnpeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,8 @@ async def on_open_channel(self, payload):

async def trigger_force_close(self, channel_id: bytes):
await self.initialized
# First, we intentionally send a "channel_reestablish" msg with an old state.
# Many nodes (but not all) automatically force-close when seeing this.
latest_point = secret_to_pubkey(42) # we need a valid point (BOLT2)
self.send_message(
"channel_reestablish",
Expand All @@ -1059,6 +1061,13 @@ async def trigger_force_close(self, channel_id: bytes):
next_revocation_number=0,
your_last_per_commitment_secret=0,
my_current_per_commitment_point=latest_point)
# Newish nodes that have lightning/bolts/pull/950 force-close upon receiving an "error" msg,
# so send that too. E.g. old "channel_reestablish" is not enough for eclair 0.7+,
# but "error" is. see https://github.com/ACINQ/eclair/pull/2036
# The receiving node:
# - upon receiving `error`:
# - MUST fail the channel referred to by `channel_id`, if that channel is with the sending node.
self.send_message("error", channel_id=channel_id, data=b"", len=0)

def schedule_force_closing(self, channel_id: bytes):
""" wrapper of lnworker's method, that raises if channel is not with this peer """
Expand Down

0 comments on commit 90dbac5

Please sign in to comment.