mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 15:00:34 +01:00
This basically means moving the code from gossipd to connectd to handle these queries. This will get connectd have finer control over ratelimiting them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
241 lines
14 KiB
C
241 lines
14 KiB
C
#include "config.h"
|
|
int unused_main(int argc, char *argv[]);
|
|
#define main unused_main
|
|
#include "../queries.c"
|
|
#undef main
|
|
#include <common/blinding.h>
|
|
#include <common/channel_type.h>
|
|
#include <common/ecdh.h>
|
|
#include <common/json_stream.h>
|
|
#include <common/onionreply.h>
|
|
#include <common/setup.h>
|
|
#include <stdio.h>
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
/* Generated stub for amount_asset_is_main */
|
|
bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
|
|
{ fprintf(stderr, "amount_asset_is_main called!\n"); abort(); }
|
|
/* Generated stub for amount_asset_to_sat */
|
|
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
|
|
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
|
|
/* Generated stub for amount_feerate */
|
|
bool amount_feerate(u32 *feerate UNNEEDED, struct amount_sat fee UNNEEDED, size_t weight UNNEEDED)
|
|
{ fprintf(stderr, "amount_feerate called!\n"); abort(); }
|
|
/* Generated stub for amount_sat */
|
|
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
|
|
/* Generated stub for amount_sat_add */
|
|
bool amount_sat_add(struct amount_sat *val UNNEEDED,
|
|
struct amount_sat a UNNEEDED,
|
|
struct amount_sat b UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat_add called!\n"); abort(); }
|
|
/* Generated stub for amount_sat_eq */
|
|
bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat_eq called!\n"); abort(); }
|
|
/* Generated stub for amount_sat_greater_eq */
|
|
bool amount_sat_greater_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat_greater_eq called!\n"); abort(); }
|
|
/* Generated stub for amount_sat_sub */
|
|
bool amount_sat_sub(struct amount_sat *val UNNEEDED,
|
|
struct amount_sat a UNNEEDED,
|
|
struct amount_sat b UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat_sub called!\n"); abort(); }
|
|
/* Generated stub for amount_sat_to_asset */
|
|
struct amount_asset amount_sat_to_asset(struct amount_sat *sat UNNEEDED, const u8 *asset UNNEEDED)
|
|
{ fprintf(stderr, "amount_sat_to_asset called!\n"); abort(); }
|
|
/* Generated stub for amount_tx_fee */
|
|
struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
|
|
{ fprintf(stderr, "amount_tx_fee called!\n"); abort(); }
|
|
/* Generated stub for bigsize_len */
|
|
size_t bigsize_len(bigsize_t v UNNEEDED)
|
|
{ fprintf(stderr, "bigsize_len called!\n"); abort(); }
|
|
/* Generated stub for decode_scid_query_flags */
|
|
bigsize_t *decode_scid_query_flags(const tal_t *ctx UNNEEDED,
|
|
const struct tlv_query_short_channel_ids_tlvs_query_flags *qf UNNEEDED)
|
|
{ fprintf(stderr, "decode_scid_query_flags called!\n"); abort(); }
|
|
/* Generated stub for decode_short_ids */
|
|
struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *encoded UNNEEDED)
|
|
{ fprintf(stderr, "decode_short_ids called!\n"); abort(); }
|
|
/* Generated stub for fromwire */
|
|
const u8 *fromwire(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, void *copy UNNEEDED, size_t n UNNEEDED)
|
|
{ fprintf(stderr, "fromwire called!\n"); abort(); }
|
|
/* Generated stub for fromwire_bool */
|
|
bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_bool called!\n"); abort(); }
|
|
/* Generated stub for fromwire_connectd_dev_set_max_scids_encode_size */
|
|
bool fromwire_connectd_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_connectd_dev_set_max_scids_encode_size called!\n"); abort(); }
|
|
/* Generated stub for fromwire_fail */
|
|
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
|
|
/* Generated stub for fromwire_query_channel_range */
|
|
bool fromwire_query_channel_range(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, u32 *first_blocknum UNNEEDED, u32 *number_of_blocks UNNEEDED, struct tlv_query_channel_range_tlvs **tlvs UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_query_channel_range called!\n"); abort(); }
|
|
/* Generated stub for fromwire_query_short_channel_ids */
|
|
bool fromwire_query_short_channel_ids(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, u8 **encoded_short_ids UNNEEDED, struct tlv_query_short_channel_ids_tlvs **tlvs UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_query_short_channel_ids called!\n"); abort(); }
|
|
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
|
|
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
|
|
secp256k1_ecdsa_signature *signature UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); }
|
|
/* Generated stub for fromwire_sha256 */
|
|
void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); }
|
|
/* Generated stub for fromwire_tal_arrn */
|
|
u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED,
|
|
const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_tal_arrn called!\n"); abort(); }
|
|
/* Generated stub for fromwire_u16 */
|
|
u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_u16 called!\n"); abort(); }
|
|
/* Generated stub for fromwire_u32 */
|
|
u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_u32 called!\n"); abort(); }
|
|
/* Generated stub for fromwire_u64 */
|
|
u64 fromwire_u64(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_u64 called!\n"); abort(); }
|
|
/* Generated stub for fromwire_u8 */
|
|
u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_u8 called!\n"); abort(); }
|
|
/* Generated stub for fromwire_u8_array */
|
|
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
|
|
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
|
|
/* Generated stub for get_gossmap */
|
|
struct gossmap *get_gossmap(struct daemon *daemon UNNEEDED)
|
|
{ fprintf(stderr, "get_gossmap called!\n"); abort(); }
|
|
/* Generated stub for gossmap_chan_byidx */
|
|
struct gossmap_chan *gossmap_chan_byidx(const struct gossmap *map UNNEEDED, u32 idx UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_chan_byidx called!\n"); abort(); }
|
|
/* Generated stub for gossmap_chan_get_announce */
|
|
u8 *gossmap_chan_get_announce(const tal_t *ctx UNNEEDED,
|
|
const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_chan *c UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_chan_get_announce called!\n"); abort(); }
|
|
/* Generated stub for gossmap_chan_get_update */
|
|
u8 *gossmap_chan_get_update(const tal_t *ctx UNNEEDED,
|
|
const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_chan *chan UNNEEDED,
|
|
int dir UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_chan_get_update called!\n"); abort(); }
|
|
/* Generated stub for gossmap_chan_get_update_details */
|
|
void gossmap_chan_get_update_details(const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_chan *chan UNNEEDED,
|
|
int dir UNNEEDED,
|
|
u32 *timestamp UNNEEDED,
|
|
u8 *message_flags UNNEEDED,
|
|
u8 *channel_flags UNNEEDED,
|
|
u32 *fee_base_msat UNNEEDED,
|
|
u32 *fee_proportional_millionths UNNEEDED,
|
|
struct amount_msat *htlc_minimum_msat UNNEEDED,
|
|
struct amount_msat *htlc_maximum_msat UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_chan_get_update_details called!\n"); abort(); }
|
|
/* Generated stub for gossmap_chan_scid */
|
|
struct short_channel_id gossmap_chan_scid(const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_chan *c UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_chan_scid called!\n"); abort(); }
|
|
/* Generated stub for gossmap_find_chan */
|
|
struct gossmap_chan *gossmap_find_chan(const struct gossmap *map UNNEEDED,
|
|
const struct short_channel_id *scid UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_find_chan called!\n"); abort(); }
|
|
/* Generated stub for gossmap_find_node */
|
|
struct gossmap_node *gossmap_find_node(const struct gossmap *map UNNEEDED,
|
|
const struct node_id *id UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_find_node called!\n"); abort(); }
|
|
/* Generated stub for gossmap_max_chan_idx */
|
|
u32 gossmap_max_chan_idx(const struct gossmap *map UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_max_chan_idx called!\n"); abort(); }
|
|
/* Generated stub for gossmap_node_get_announce */
|
|
u8 *gossmap_node_get_announce(const tal_t *ctx UNNEEDED,
|
|
const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_node *n UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_node_get_announce called!\n"); abort(); }
|
|
/* Generated stub for gossmap_node_get_id */
|
|
void gossmap_node_get_id(const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_node *node UNNEEDED,
|
|
struct node_id *id UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_node_get_id called!\n"); abort(); }
|
|
/* Generated stub for gossmap_nth_node */
|
|
struct gossmap_node *gossmap_nth_node(const struct gossmap *map UNNEEDED,
|
|
const struct gossmap_chan *chan UNNEEDED,
|
|
int n UNNEEDED)
|
|
{ fprintf(stderr, "gossmap_nth_node called!\n"); abort(); }
|
|
/* Generated stub for inject_peer_msg */
|
|
void inject_peer_msg(struct peer *peer UNNEEDED, const u8 *msg TAKES UNNEEDED)
|
|
{ fprintf(stderr, "inject_peer_msg called!\n"); abort(); }
|
|
/* Generated stub for master_badmsg */
|
|
void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
|
{ fprintf(stderr, "master_badmsg called!\n"); abort(); }
|
|
/* Generated stub for node_id_cmp */
|
|
int node_id_cmp(const struct node_id *a UNNEEDED, const struct node_id *b UNNEEDED)
|
|
{ fprintf(stderr, "node_id_cmp called!\n"); abort(); }
|
|
/* Generated stub for status_fmt */
|
|
void status_fmt(enum log_level level UNNEEDED,
|
|
const struct node_id *peer UNNEEDED,
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
|
|
/* Generated stub for tlv_reply_channel_range_tlvs_new */
|
|
struct tlv_reply_channel_range_tlvs *tlv_reply_channel_range_tlvs_new(const tal_t *ctx UNNEEDED)
|
|
{ fprintf(stderr, "tlv_reply_channel_range_tlvs_new called!\n"); abort(); }
|
|
/* Generated stub for towire */
|
|
void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
|
|
{ fprintf(stderr, "towire called!\n"); abort(); }
|
|
/* Generated stub for towire_bool */
|
|
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
|
|
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
|
|
/* Generated stub for towire_channel_update_timestamps */
|
|
void towire_channel_update_timestamps(u8 **p UNNEEDED, const struct channel_update_timestamps *channel_update_timestamps UNNEEDED)
|
|
{ fprintf(stderr, "towire_channel_update_timestamps called!\n"); abort(); }
|
|
/* Generated stub for towire_reply_channel_range */
|
|
u8 *towire_reply_channel_range(const tal_t *ctx UNNEEDED, const struct bitcoin_blkid *chain_hash UNNEEDED, u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED, u8 sync_complete UNNEEDED, const u8 *encoded_short_ids UNNEEDED, const struct tlv_reply_channel_range_tlvs *tlvs UNNEEDED)
|
|
{ fprintf(stderr, "towire_reply_channel_range called!\n"); abort(); }
|
|
/* Generated stub for towire_reply_short_channel_ids_end */
|
|
u8 *towire_reply_short_channel_ids_end(const tal_t *ctx UNNEEDED, const struct bitcoin_blkid *chain_hash UNNEEDED, u8 full_information UNNEEDED)
|
|
{ fprintf(stderr, "towire_reply_short_channel_ids_end called!\n"); abort(); }
|
|
/* Generated stub for towire_secp256k1_ecdsa_signature */
|
|
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
|
|
const secp256k1_ecdsa_signature *signature UNNEEDED)
|
|
{ fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); }
|
|
/* Generated stub for towire_sha256 */
|
|
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
|
|
{ fprintf(stderr, "towire_sha256 called!\n"); abort(); }
|
|
/* Generated stub for towire_u16 */
|
|
void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED)
|
|
{ fprintf(stderr, "towire_u16 called!\n"); abort(); }
|
|
/* Generated stub for towire_u32 */
|
|
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
|
|
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }
|
|
/* Generated stub for towire_u64 */
|
|
void towire_u64(u8 **pptr UNNEEDED, u64 v UNNEEDED)
|
|
{ fprintf(stderr, "towire_u64 called!\n"); abort(); }
|
|
/* Generated stub for towire_u8 */
|
|
void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
|
|
{ fprintf(stderr, "towire_u8 called!\n"); abort(); }
|
|
/* Generated stub for towire_u8_array */
|
|
void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED)
|
|
{ fprintf(stderr, "towire_u8_array called!\n"); abort(); }
|
|
/* Generated stub for towire_warningfmtv */
|
|
u8 *towire_warningfmtv(const tal_t *ctx UNNEEDED,
|
|
const struct channel_id *channel UNNEEDED,
|
|
const char *fmt UNNEEDED,
|
|
va_list ap UNNEEDED)
|
|
{ fprintf(stderr, "towire_warningfmtv called!\n"); abort(); }
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
u8 *update;
|
|
common_setup(argv[0]);
|
|
|
|
update = tal_hexdata(NULL, "010276df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c8029328206226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006700000100005d50f933000000900000000000000000000003e80000000a",
|
|
strlen("010276df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c8029328206226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006700000100005d50f933000000900000000000000000000003e80000000a"));
|
|
assert(crc32_of_update(update) == 0x1112fa30);
|
|
tal_free(update);
|
|
|
|
update = tal_hexdata(NULL, "010206737e9e18d3e4d0ab4066ccaecdcc10e648c5f1c5413f1610747e0d463fa7fa39c1b02ea2fd694275ecfefe4fe9631f24afd182ab75b805e16cd550941f858c06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006d00000100005d50f935010000300000000000000000000000640000000b00000000000186a0",
|
|
strlen("010206737e9e18d3e4d0ab4066ccaecdcc10e648c5f1c5413f1610747e0d463fa7fa39c1b02ea2fd694275ecfefe4fe9631f24afd182ab75b805e16cd550941f858c06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006d00000100005d50f935010000300000000000000000000000640000000b00000000000186a0"));
|
|
assert(crc32_of_update(update) == 0xf32ce968);
|
|
tal_free(update);
|
|
common_shutdown();
|
|
return 0;
|
|
}
|