electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f16358ec3c60cef07c63257a64315f53e044acb7
parent bed4ddbcb4f9d2efa8334ebae21550577f83a2eb
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 12 Mar 2021 16:10:02 +0100

add request_force_close command to CLI
add regtest for channel backup

Diffstat:
Melectrum/commands.py | 6++++++
Melectrum/tests/regtest.py | 3+++
Melectrum/tests/regtest/regtest.sh | 24++++++++++++++++++++++++
3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -1081,6 +1081,12 @@ class Commands: coro = wallet.lnworker.force_close_channel(chan_id) if force else wallet.lnworker.close_channel(chan_id) return await coro + @command('wn') + async def request_force_close(self, channel_point, wallet: Abstract_Wallet = None): + txid, index = channel_point.split(':') + chan_id, _ = channel_id_from_funding_tx(txid, int(index)) + return await wallet.lnworker.request_force_close_from_backup(chan_id) + @command('w') async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None): txid, index = channel_point.split(':') diff --git a/electrum/tests/regtest.py b/electrum/tests/regtest.py @@ -36,6 +36,9 @@ class TestLightning(unittest.TestCase): class TestLightningAB(TestLightning): agents = ['alice', 'bob'] + def test_backup(self): + self.run_shell(['backup']) + def test_breach(self): self.run_shell(['breach']) diff --git a/electrum/tests/regtest/regtest.sh b/electrum/tests/regtest/regtest.sh @@ -133,6 +133,30 @@ if [[ $1 == "breach" ]]; then fi +if [[ $1 == "backup" ]]; then + wait_for_balance alice 1 + echo "alice opens channel" + bob_node=$($bob nodeid) + channel=$($alice open_channel $bob_node 0.15) + echo "channel point: $channel" + new_blocks 3 + wait_until_channel_open alice + backup=$($alice export_channel_backup $channel) + request=$($bob add_lightning_request 0.01 -m "blah" | jq -r ".invoice") + echo "alice pays" + $alice lnpay $request + seed=$($alice getseed) + $alice stop + sleep 2 # FIXME: we should not have to do that.. + mv /tmp/alice/regtest/wallets/default_wallet /tmp/alice/regtest/wallets/default_wallet.old + $alice -o restore "$seed" + $alice daemon -d + $alice load_wallet + $alice import_channel_backup $backup + $alice request_force_close $channel +fi + + if [[ $1 == "extract_preimage" ]]; then # instead of settling bob will broadcast $bob enable_htlc_settle false