The peer can ask about an array of short channel ids: we don't assemble the * reply immediately but process them one at a time in dump_gossip which is * called when there's nothing more important to send. */
| 165 | * reply immediately but process them one at a time in dump_gossip which is |
| 166 | * called when there's nothing more important to send. */ |
| 167 | const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg) |
| 168 | { |
| 169 | struct bitcoin_blkid chain; |
| 170 | u8 *encoded; |
| 171 | struct short_channel_id *scids; |
| 172 | bigsize_t *flags; |
| 173 | struct tlv_query_short_channel_ids_tlvs *tlvs; |
| 174 | |
| 175 | if (!fromwire_query_short_channel_ids(tmpctx, msg, &chain, &encoded, |
| 176 | &tlvs)) { |
| 177 | return towire_warningfmt(peer, NULL, |
| 178 | "Bad query_short_channel_ids w/tlvs %s", |
| 179 | tal_hex(tmpctx, msg)); |
| 180 | } |
| 181 | if (tlvs->query_flags) { |
| 182 | /* BOLT #7: |
| 183 | * |
| 184 | * The receiver: |
| 185 | *... |
| 186 | * - if the incoming message includes |
| 187 | * `query_short_channel_ids_tlvs`: |
| 188 | * - if `encoding_type` is not a known encoding type: |
| 189 | * - MAY send a `warning`. |
| 190 | * - MAY close the connection. |
| 191 | */ |
| 192 | flags = decode_scid_query_flags(tmpctx, tlvs->query_flags); |
| 193 | if (!flags) { |
| 194 | return towire_warningfmt(peer, NULL, |
| 195 | "Bad query_short_channel_ids query_flags %s", |
| 196 | tal_hex(tmpctx, msg)); |
| 197 | } |
| 198 | } else |
| 199 | flags = NULL; |
| 200 | |
| 201 | /* BOLT #7 |
| 202 | * |
| 203 | * The receiver: |
| 204 | * ... |
| 205 | * - if does not maintain up-to-date channel information for `chain_hash`: |
| 206 | * - MUST set `complete` to 0. |
| 207 | */ |
| 208 | if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) { |
| 209 | status_peer_debug(&peer->id, |
| 210 | "sent query_short_channel_ids chainhash %s", |
| 211 | type_to_string(tmpctx, struct bitcoin_blkid, &chain)); |
| 212 | return towire_reply_short_channel_ids_end(peer, &chain, 0); |
| 213 | } |
| 214 | |
| 215 | /* BOLT #7: |
| 216 | * |
| 217 | * - if it has not sent `reply_short_channel_ids_end` to a |
| 218 | * previously received `query_short_channel_ids` from this |
| 219 | * sender: |
| 220 | * - MAY send a `warning`. |
| 221 | * - MAY close the connection. |
| 222 | */ |
| 223 | if (peer->scid_queries || peer->scid_query_nodes) { |
| 224 | return towire_warningfmt(peer, NULL, |
no test coverage detected