Browse Source

ln: commit fee updates as soon as possible

regtest_lnd
Janus 6 years ago
committed by SomberNight
parent
commit
3a5d19de7d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/lnbase.py
  2. 2
      electrum/lnworker.py

7
electrum/lnbase.py

@ -1040,7 +1040,7 @@ class Peer(PrintError):
channel_id = payload["channel_id"] channel_id = payload["channel_id"]
self.channels[channel_id].receive_update_fee(int.from_bytes(payload["feerate_per_kw"], "big")) self.channels[channel_id].receive_update_fee(int.from_bytes(payload["feerate_per_kw"], "big"))
def on_bitcoin_fee_update(self, chan): async def bitcoin_fee_update(self, chan):
""" """
called when our fee estimates change called when our fee estimates change
""" """
@ -1062,6 +1062,11 @@ class Peer(PrintError):
return return
self.send_message(gen_msg("update_fee", channel_id=chan.channel_id, feerate_per_kw=feerate_per_kw)) self.send_message(gen_msg("update_fee", channel_id=chan.channel_id, feerate_per_kw=feerate_per_kw))
sig_64, htlc_sigs = chan.sign_next_commitment()
self.send_message(gen_msg("commitment_signed", channel_id=chan.channel_id, signature=sig_64, num_htlcs=len(htlc_sigs), htlc_signature=b"".join(htlc_sigs)))
await self.receive_revoke(chan)
await self.receive_commitment(chan)
self.revoke(chan)
self.lnworker.save_channel(chan) self.lnworker.save_channel(chan)
def current_feerate_per_kw(self): def current_feerate_per_kw(self):

2
electrum/lnworker.py

@ -150,7 +150,7 @@ class LNWorker(PrintError):
self.print_error("peer not found for {}".format(bh2u(chan.node_id))) self.print_error("peer not found for {}".format(bh2u(chan.node_id)))
return return
if event == 'fee': if event == 'fee':
peer.on_bitcoin_fee_update(chan) await peer.bitcoin_fee_update(chan)
conf = self.wallet.get_tx_height(chan.funding_outpoint.txid).conf conf = self.wallet.get_tx_height(chan.funding_outpoint.txid).conf
peer.on_network_update(chan, conf) peer.on_network_update(chan, conf)

Loading…
Cancel
Save