channel_announcements:
- construct_channel_announcement: return also whether node ids are in reverse order - maybe_send_channel_announcement: return early if signatures have not been received
This commit is contained in:
@@ -251,7 +251,8 @@ def get_mychannel_info(short_channel_id: ShortChannelID,
|
||||
chan = my_channels.get(short_channel_id)
|
||||
if not chan:
|
||||
return
|
||||
ci = ChannelInfo.from_raw_msg(chan.construct_channel_announcement_without_sigs())
|
||||
raw_msg, _ = chan.construct_channel_announcement_without_sigs()
|
||||
ci = ChannelInfo.from_raw_msg(raw_msg)
|
||||
return ci._replace(capacity_sat=chan.constraints.capacity)
|
||||
|
||||
def get_mychannel_policy(short_channel_id: bytes, node_id: bytes,
|
||||
|
||||
@@ -806,9 +806,9 @@ class Channel(AbstractChannel):
|
||||
self.config[REMOTE].multisig_key.pubkey,
|
||||
self.config[LOCAL].multisig_key.pubkey]
|
||||
node_ids = [self.node_id, self.get_local_pubkey()]
|
||||
sorted_node_ids = list(sorted(node_ids))
|
||||
if sorted_node_ids != node_ids:
|
||||
node_ids = sorted_node_ids
|
||||
is_reverse = node_ids[0] > node_ids[1]
|
||||
if is_reverse:
|
||||
node_ids.reverse()
|
||||
bitcoin_keys.reverse()
|
||||
chan_ann = encode_msg(
|
||||
"channel_announcement",
|
||||
@@ -821,10 +821,10 @@ class Channel(AbstractChannel):
|
||||
bitcoin_key_1=bitcoin_keys[0],
|
||||
bitcoin_key_2=bitcoin_keys[1],
|
||||
)
|
||||
return chan_ann
|
||||
return chan_ann, is_reverse
|
||||
|
||||
def get_channel_announcement_hash(self):
|
||||
chan_ann = self.construct_channel_announcement_without_sigs()
|
||||
chan_ann, _ = self.construct_channel_announcement_without_sigs()
|
||||
return sha256d(chan_ann[256+2:])
|
||||
|
||||
def is_static_remotekey_enabled(self) -> bool:
|
||||
|
||||
@@ -476,7 +476,7 @@ class Peer(Logger):
|
||||
self.send_node_announcement(alias)
|
||||
for chan in public_channels:
|
||||
if chan.is_open() and chan.peer_state == PeerState.GOOD:
|
||||
self.send_channel_announcement(chan)
|
||||
self.maybe_send_channel_announcement(chan)
|
||||
await asyncio.sleep(600)
|
||||
|
||||
async def query_gossip(self):
|
||||
@@ -1379,18 +1379,15 @@ class Peer(Logger):
|
||||
raw_msg = encode_msg(message_type, **payload)
|
||||
self.transport.send_bytes(raw_msg)
|
||||
|
||||
def send_channel_announcement(self, chan: Channel):
|
||||
node_ids = [chan.node_id, chan.get_local_pubkey()]
|
||||
def maybe_send_channel_announcement(self, chan: Channel):
|
||||
node_sigs = [chan.config[REMOTE].announcement_node_sig, chan.config[LOCAL].announcement_node_sig]
|
||||
bitcoin_sigs = [chan.config[REMOTE].announcement_bitcoin_sig, chan.config[LOCAL].announcement_bitcoin_sig]
|
||||
bitcoin_keys = [chan.config[REMOTE].multisig_key.pubkey, chan.config[LOCAL].multisig_key.pubkey]
|
||||
sorted_node_ids = list(sorted(node_ids))
|
||||
if sorted_node_ids != node_ids:
|
||||
if not bitcoin_sigs[0] or not bitcoin_sigs[1]:
|
||||
return
|
||||
raw_msg, is_reverse = chan.construct_channel_announcement_without_sigs()
|
||||
if is_reverse:
|
||||
node_sigs.reverse()
|
||||
bitcoin_sigs.reverse()
|
||||
node_ids.reverse()
|
||||
bitcoin_keys.reverse()
|
||||
raw_msg = chan.construct_channel_announcement_without_sigs()
|
||||
message_type, payload = decode_msg(raw_msg)
|
||||
payload['node_signature_1'] = node_sigs[0]
|
||||
payload['node_signature_2'] = node_sigs[1]
|
||||
|
||||
Reference in New Issue
Block a user