1
0

lnchannel: verify sig of remote chanupd (for inc edge of direct chan)

This is re the channel update for the incoming direction of our own channels.
This message can only come from the counterparty itself so maybe the sig check
is redundant... but for sanity I think we should check it anyway.
This commit is contained in:
SomberNight
2021-03-16 19:07:31 +01:00
parent bcfcc20363
commit 468f3b2b8d
4 changed files with 18 additions and 8 deletions

View File

@@ -569,12 +569,14 @@ class ChannelDB(SqlDB):
c.execute("INSERT INTO address (node_id, host, port, timestamp) VALUES (?,?,?,?)", (addr.pubkey, addr.host, addr.port, 0))
@classmethod
def verify_channel_update(cls, payload) -> None:
def verify_channel_update(cls, payload, *, start_node: bytes = None) -> None:
short_channel_id = payload['short_channel_id']
short_channel_id = ShortChannelID(short_channel_id)
if constants.net.rev_genesis_bytes() != payload['chain_hash']:
raise InvalidGossipMsg('wrong chain hash')
if not verify_sig_for_channel_update(payload, payload['start_node']):
start_node = payload.get('start_node', None) or start_node
assert start_node is not None
if not verify_sig_for_channel_update(payload, start_node):
raise InvalidGossipMsg(f'failed verifying channel update for {short_channel_id}')
@classmethod