commit fe1b2149cbadce8e9d4ad5e008e3ee60a0b3c1e4
parent 1d9311aeefb9f9b4d76d72b792d784fb9f024bfd
Author: ThomasV <thomasv@electrum.org>
Date: Thu, 28 Jan 2021 11:14:53 +0100
lnpeer: fix flen in INIT
Diffstat:
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
@@ -133,12 +133,16 @@ class Peer(Logger):
async def initialize(self):
if isinstance(self.transport, LNTransport):
await self.transport.handshake()
- # FIXME: "flen" hardcoded but actually it depends on "features"...:
- self.send_message("init", gflen=0, flen=2, features=self.features.for_init_message(),
- init_tlvs={
- 'networks':
- {'chains': constants.net.rev_genesis_bytes()}
- })
+ features = self.features.for_init_message()
+ b = int.bit_length(features)
+ flen = b // 8 + int(bool(b % 8))
+ self.send_message(
+ "init", gflen=0, flen=flen,
+ features=features,
+ init_tlvs={
+ 'networks':
+ {'chains': constants.net.rev_genesis_bytes()}
+ })
self._sent_init = True
self.maybe_set_initialized()