electrum

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

commit b29cdc02da10836fc32e6be76b6ca5f463bd86ac
parent c478f3bb91371204c9015fb7160a9c26ca15607e
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 22 Dec 2020 12:28:40 +0100

Require gossip_queries in LNWallet (follow-up f83d2d9fee160e7b5475d397672559fc8f947470)
 - workaround lnd bug https://github.com/lightningnetwork/lnd/issues/3651
 - also reduces bandwidth usage

Diffstat:
Melectrum/lnpeer.py | 9+++++++++
Melectrum/lnworker.py | 3+++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -256,6 +256,8 @@ class Peer(Logger): self.gossip_queue.put_nowait(('channel_update', payload)) def maybe_save_remote_update(self, payload): + if not self.channels: + return for chan in self.channels.values(): if chan.short_channel_id == payload['short_channel_id']: chan.set_remote_update(payload['raw']) @@ -265,7 +267,14 @@ class Peer(Logger): # Save (some bounded number of) orphan channel updates for later # as it might be for our own direct channel with this peer # (and we might not yet know the short channel id for that) + # Background: this code is here to deal with a bug in LND, + # see https://github.com/lightningnetwork/lnd/issues/3651 + # and https://github.com/lightningnetwork/lightning-rfc/pull/657 + # This code assumes gossip_queries is set. BOLT7: "if the + # gossip_queries feature is negotiated, [a node] MUST NOT + # send gossip it did not generate itself" short_channel_id = ShortChannelID(payload['short_channel_id']) + self.logger.info(f'received orphan channel update {short_channel_id}') self.orphan_channel_updates[short_channel_id] = payload while len(self.orphan_channel_updates) > 25: self.orphan_channel_updates.popitem(last=False) diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -554,6 +554,9 @@ class LNWallet(LNWorker): self.lnrater: LNRater = None self.features |= LnFeatures.OPTION_DATA_LOSS_PROTECT_REQ self.features |= LnFeatures.OPTION_STATIC_REMOTEKEY_REQ + # we do not want to receive unrequested gossip (see lnpeer.maybe_save_remote_update) + self.features |= LnFeatures.GOSSIP_QUERIES_REQ + self.payments = self.db.get_dict('lightning_payments') # RHASH -> amount, direction, is_paid # FIXME amt should be msat self.preimages = self.db.get_dict('lightning_preimages') # RHASH -> preimage # note: this sweep_address is only used as fallback; as it might result in address-reuse