add request_force_close command to CLI
add regtest for channel backup
This commit is contained in:
@@ -1081,6 +1081,12 @@ class Commands:
|
|||||||
coro = wallet.lnworker.force_close_channel(chan_id) if force else wallet.lnworker.close_channel(chan_id)
|
coro = wallet.lnworker.force_close_channel(chan_id) if force else wallet.lnworker.close_channel(chan_id)
|
||||||
return await coro
|
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')
|
@command('w')
|
||||||
async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None):
|
async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None):
|
||||||
txid, index = channel_point.split(':')
|
txid, index = channel_point.split(':')
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ class TestLightning(unittest.TestCase):
|
|||||||
class TestLightningAB(TestLightning):
|
class TestLightningAB(TestLightning):
|
||||||
agents = ['alice', 'bob']
|
agents = ['alice', 'bob']
|
||||||
|
|
||||||
|
def test_backup(self):
|
||||||
|
self.run_shell(['backup'])
|
||||||
|
|
||||||
def test_breach(self):
|
def test_breach(self):
|
||||||
self.run_shell(['breach'])
|
self.run_shell(['breach'])
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,30 @@ if [[ $1 == "breach" ]]; then
|
|||||||
fi
|
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
|
if [[ $1 == "extract_preimage" ]]; then
|
||||||
# instead of settling bob will broadcast
|
# instead of settling bob will broadcast
|
||||||
$bob enable_htlc_settle false
|
$bob enable_htlc_settle false
|
||||||
|
|||||||
Reference in New Issue
Block a user