Browse Source

fix privkey in request_force_close_from_backup

patch-4
ThomasV 4 years ago
parent
commit
f06433e435
  1. 4
      electrum/lnworker.py
  2. 3
      electrum/tests/regtest/regtest.sh

4
electrum/lnworker.py

@ -2141,6 +2141,7 @@ class LNWallet(LNWorker):
self.logger.info(f'requesting channel force close: {channel_id.hex()}')
if isinstance(cb, ImportedChannelBackupStorage):
node_id = cb.node_id
privkey = cb.privkey
addresses = [(cb.host, cb.port, 0)]
# TODO also try network addresses from gossip db (as it might have changed)
else:
@ -2148,12 +2149,13 @@ class LNWallet(LNWorker):
if not self.channel_db:
raise Exception('Enable gossip first')
node_id = self.network.channel_db.get_node_by_prefix(cb.node_id_prefix)
privkey = self.node_keypair.privkey
addresses = self.network.channel_db.get_node_addresses(node_id)
if not addresses:
raise Exception('Peer not found in gossip database')
for host, port, timestamp in addresses:
peer_addr = LNPeerAddr(host, port, node_id)
transport = LNTransport(self.node_keypair.privkey, peer_addr, proxy=self.network.proxy)
transport = LNTransport(privkey, peer_addr, proxy=self.network.proxy)
peer = Peer(self, node_id, transport, is_channel_backup=True)
try:
async with TaskGroup(wait=any) as group:

3
electrum/tests/regtest/regtest.sh

@ -137,10 +137,12 @@ if [[ $1 == "backup" ]]; then
wait_for_balance alice 1
echo "alice opens channel"
bob_node=$($bob nodeid)
$alice setconfig use_recoverable_channels False
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
@ -150,6 +152,7 @@ if [[ $1 == "backup" ]]; then
$alice -o restore "$seed"
$alice daemon -d
$alice load_wallet
$alice import_channel_backup $backup
$alice request_force_close $channel
wait_for_balance alice 0.989
fi

Loading…
Cancel
Save