do not raise BaseException
This commit is contained in:
@@ -36,7 +36,7 @@ from .sql_db import SqlDB, sql
|
|||||||
from . import constants
|
from . import constants
|
||||||
from .util import bh2u, profiler, get_headers_dir, bfh, is_ip_address, list_enabled_bits
|
from .util import bh2u, profiler, get_headers_dir, bfh, is_ip_address, list_enabled_bits
|
||||||
from .logging import Logger
|
from .logging import Logger
|
||||||
from .lnutil import LN_GLOBAL_FEATURES_KNOWN_SET, LNPeerAddr
|
from .lnutil import LN_GLOBAL_FEATURES_KNOWN_SET, LNPeerAddr, format_short_channel_id
|
||||||
from .lnverifier import LNChannelVerifier, verify_sig_for_channel_update
|
from .lnverifier import LNChannelVerifier, verify_sig_for_channel_update
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -430,10 +430,11 @@ class ChannelDB(SqlDB):
|
|||||||
|
|
||||||
def verify_channel_update(self, payload):
|
def verify_channel_update(self, payload):
|
||||||
short_channel_id = payload['short_channel_id']
|
short_channel_id = payload['short_channel_id']
|
||||||
|
scid = format_short_channel_id(short_channel_id)
|
||||||
if constants.net.rev_genesis_bytes() != payload['chain_hash']:
|
if constants.net.rev_genesis_bytes() != payload['chain_hash']:
|
||||||
raise Exception('wrong chain hash')
|
raise Exception('wrong chain hash')
|
||||||
if not verify_sig_for_channel_update(payload, payload['start_node']):
|
if not verify_sig_for_channel_update(payload, payload['start_node']):
|
||||||
raise BaseException('verify error')
|
raise Exception(f'failed verifying channel update for {scid}')
|
||||||
|
|
||||||
def add_node_announcement(self, msg_payloads):
|
def add_node_announcement(self, msg_payloads):
|
||||||
if type(msg_payloads) is dict:
|
if type(msg_payloads) is dict:
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ class Peer(Logger):
|
|||||||
elif encoded[0] == 1:
|
elif encoded[0] == 1:
|
||||||
decoded = zlib.decompress(encoded[1:])
|
decoded = zlib.decompress(encoded[1:])
|
||||||
else:
|
else:
|
||||||
raise BaseException('zlib')
|
raise Exception(f'decode_short_ids: unexpected first byte: {encoded[0]}')
|
||||||
ids = [decoded[i:i+8] for i in range(0, len(decoded), 8)]
|
ids = [decoded[i:i+8] for i in range(0, len(decoded), 8)]
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user