gossipd: don't ignore wrong chain in 'query_channel_range'

Give a NULL reply with the 'complete' flag to 0 instead
This commit is contained in:
darosior 2019-09-03 00:10:53 +02:00 committed by Rusty Russell
parent 870d75613f
commit ea6c95b2b3
1 changed files with 10 additions and 2 deletions

View File

@ -1196,13 +1196,21 @@ static u8 *handle_query_channel_range(struct peer *peer, const u8 *msg)
query_option_flags = 0;
#endif
/* FIXME: if they ask for the wrong chain, we should not ignore it,
* but give an empty response with the `complete` flag unset? */
/* If they ask for the wrong chain, we give an empty response
* with the `complete` flag unset */
if (!bitcoin_blkid_eq(&peer->daemon->chain_hash, &chain_hash)) {
status_trace("%s sent query_channel_range chainhash %s",
type_to_string(tmpctx, struct node_id, &peer->id),
type_to_string(tmpctx, struct bitcoin_blkid,
&chain_hash));
#if EXPERIMENTAL_FEATURES
u8 *end = towire_reply_channel_range(NULL, &chain_hash, first_blocknum,
number_of_blocks, false, NULL, NULL);
#else
u8 *end = towire_reply_channel_range(NULL, &chain_hash, first_blocknum,
number_of_blocks, false, NULL);
#endif
queue_peer_msg(peer, take(end));
return NULL;
}