electrum icon indicating copy to clipboard operation
electrum copied to clipboard

Can't restore lightning channels from backup

Open s1ckoleg opened this issue 2 years ago • 3 comments

Currently I'm testing lightning network on signet using Electrum wallet. I want to simulate situation when I need to recover wallet and lightning channel from backup on another VM.

So I created wallet and opened channel, got seed phrase and exported channel backup:

electrum --signet -w $wallets/test.wallet getseed
electrum --signet -w $wallets/test.wallet export_channel_backup <channel_point>

Then I restore it on another VM:

electrum --signet restore "<seed phrase>"
electrum --signet -w /root/.electrum/signet/wallets/default_wallet load_wallet

But after that I cannot close the channel:

electrum --signet -w /root/.electrum/signet/wallets/default_wallet close_channel <channel_point>
(inside daemon): Traceback (most recent call last):
  File "/home/oleg/electrum/Electrum-4.5.8/venv/lib/python3.12/site-packages/electrum/daemon.py", line 254, in handle
    response['result'] = await f(*params)
                         ^^^^^^^^^^^^^^^^
  File "/home/oleg/electrum/Electrum-4.5.8/venv/lib/python3.12/site-packages/electrum/daemon.py", line 361, in run_cmdline
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/oleg/electrum/Electrum-4.5.8/venv/lib/python3.12/site-packages/electrum/commands.py", line 168, in func_wrapper
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/oleg/electrum/Electrum-4.5.8/venv/lib/python3.12/site-packages/electrum/commands.py", line 1237, in close_channel
    return await coro
           ^^^^^^^^^^
  File "/home/oleg/electrum/Electrum-4.5.8/venv/lib/python3.12/site-packages/electrum/lnworker.py", line 2841, in close_channel
    chan = self._channels[chan_id]
           ~~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'\x95\xdc\xc3_)\xb71\xcbK\xd3\x05,\x12R\xf6X\xa7\xeb\xe5C\xa6fu\xbd\x94\x08\xcf\x04\xf9r\x9dn'

internal error while executing RPC

Cannot request force close:

electrum --signet -w /root/.electrum/signet/wallets/default_wallet request_force_close <channel_point>

This command doesn't return any errors, but channel status still the same. Also in Electrum logs I can see Sending ERROR, but no more details.

Also I cannot see lightning balance:

electrum --signet -w /root/.electrum/signet/wallets/default_wallet getbalance
{
    "confirmed": "0.0008694"
    <--- "lightning" should be here
}

If I copy .wallet file from one machine to another it works perfectly, but I'd like to use this builtin backup mechanism

s1ckoleg avatar Nov 29 '24 05:11 s1ckoleg

The traceback you are seeing is because the wallet does not have a channel with the provided funding outpoint. I assume you imported the channel backup after restoring. The only thing you can do with an imported backup is request a force close, but you cannot initiate a cooperative close with it. I will fix the traceback, so that it displays a proper error message instead of crashing.

Similarly, it is normal that you do not see a lightning balance in the wallet. The current channel backup does not give you access to the lightning balance.

The current situation with channel backups is complicated. We are working towards channels that can be fully recovered from seed. I hope this will greatly simplify the user experience.

ecdsa avatar Nov 29 '24 09:11 ecdsa

If I copy .wallet file from one machine to another it works perfectly, but I'd like to use this builtin backup mechanism

Please be aware that this is dangerous. You may lose all your funds in the channel if you use the same wallet file in two machines.

ecdsa avatar Nov 29 '24 09:11 ecdsa

This command doesn't return any errors, but channel status still the same. Also in Electrum logs I can see Sending ERROR, but no more details.

this actually means that it worked. the remote should force close because they receive an error.

ecdsa avatar Nov 29 '24 09:11 ecdsa