electrum

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

commit bce74717a644a6d838c3dd6e064b069875be2b9a
parent beeb81e179143795546a8c67a376754111824a22
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 16 Aug 2019 22:45:58 +0200

lnpeer: in onion errors, handle channel updates both with and w/o type

Diffstat:
Melectrum/lnpeer.py | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -1102,9 +1102,16 @@ class Peer(Logger): if code in failure_codes: offset = failure_codes[code] channel_update_len = int.from_bytes(data[offset:offset+2], byteorder="big") - channel_update = (258).to_bytes(length=2, byteorder="big") + data[offset+2: offset+2+channel_update_len] - message_type, payload = decode_msg(channel_update) - payload['raw'] = channel_update + channel_update_as_received = data[offset+2: offset+2+channel_update_len] + channel_update_typed = (258).to_bytes(length=2, byteorder="big") + channel_update_as_received + # note: some nodes put channel updates in error msgs with the leading msg_type already there. + # we try decoding both ways here. + try: + message_type, payload = decode_msg(channel_update_typed) + payload['raw'] = channel_update_typed + except: # FIXME: too broad + message_type, payload = decode_msg(channel_update_as_received) + payload['raw'] = channel_update_as_received categorized_chan_upds = self.channel_db.add_channel_updates([payload]) blacklist = False if categorized_chan_upds.good: