verify node and channel announcements before entering sql lock
This commit is contained in:
@@ -71,8 +71,6 @@ class LNChannelVerifier(NetworkJobOnDefaultServer):
|
||||
return
|
||||
if short_channel_id in self.blacklist:
|
||||
return
|
||||
if not verify_sigs_for_channel_announcement(msg_payload):
|
||||
return
|
||||
with self.lock:
|
||||
self.unverified_channel_info[short_channel_id] = msg_payload
|
||||
|
||||
@@ -180,19 +178,6 @@ class LNChannelVerifier(NetworkJobOnDefaultServer):
|
||||
self.unverified_channel_info.pop(short_channel_id, None)
|
||||
|
||||
|
||||
def verify_sigs_for_channel_announcement(msg_bytes: bytes) -> bool:
|
||||
msg_type, chan_ann = decode_msg(msg_bytes)
|
||||
assert msg_type == 'channel_announcement'
|
||||
pre_hash = msg_bytes[2+256:]
|
||||
h = sha256d(pre_hash)
|
||||
pubkeys = [chan_ann['node_id_1'], chan_ann['node_id_2'], chan_ann['bitcoin_key_1'], chan_ann['bitcoin_key_2']]
|
||||
sigs = [chan_ann['node_signature_1'], chan_ann['node_signature_2'], chan_ann['bitcoin_signature_1'], chan_ann['bitcoin_signature_2']]
|
||||
for pubkey, sig in zip(pubkeys, sigs):
|
||||
if not ecc.verify_signature(pubkey, sig, h):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def verify_sig_for_channel_update(chan_upd: dict, node_id: bytes) -> bool:
|
||||
msg_bytes = chan_upd['raw']
|
||||
pre_hash = msg_bytes[2+64:]
|
||||
|
||||
Reference in New Issue
Block a user