diff --git a/common/gossip_constants.h b/common/gossip_constants.h index d23ac2d5f..e5e652092 100644 --- a/common/gossip_constants.h +++ b/common/gossip_constants.h @@ -78,4 +78,7 @@ #define GOSSIP_TOKEN_TIME(dev_fast_gossip_flag) \ DEV_FAST_GOSSIP(dev_fast_gossip_flag, 1, 3600) +/* This is where we keep our gossip */ +#define GOSSIP_STORE_FILENAME "gossip_store" + #endif /* LIGHTNING_COMMON_GOSSIP_CONSTANTS_H */ diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 8f83d0cf1..238677d58 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -24,7 +24,6 @@ #include #include -#define GOSSIP_STORE_FILENAME "gossip_store" #define GOSSIP_STORE_TEMP_FILENAME "gossip_store.tmp" struct gossip_store { diff --git a/plugins/Makefile b/plugins/Makefile index 02cb8fdc9..46443b7d9 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -101,7 +101,7 @@ PLUGIN_COMMON_OBJS := \ wire/tlvstream.o \ wire/towire.o -plugins/pay: bitcoin/chainparams.o $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/pay: bitcoin/chainparams.o $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) common/gossmap.o common/route.o common/dijkstra.o $(PLUGIN_PAY_OBJS): $(PLUGIN_PAY_LIB_HEADER) plugins/autoclean: bitcoin/chainparams.o $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) @@ -110,7 +110,7 @@ plugins/txprepare: bitcoin/chainparams.o $(PLUGIN_TXPREPARE_OBJS) $(PLUGIN_LIB_O plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion$(EXP)_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/onion$(EXP)_wiregen.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) common/gossmap.o common/route.o common/dijkstra.o $(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) plugins/spenderp: bitcoin/chainparams.o $(PLUGIN_SPENDER_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 93501fae3..9daa21dbe 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1,13 +1,19 @@ #include #include #include +#include +#include #include #include +#include #include #include #include +#include #include +static struct gossmap *gossmap; + /* BOLT #11: * * `c` (24): `data_length` variable. * `min_final_cltv_expiry` to use for the last HTLC in the route. @@ -23,6 +29,15 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd, static u64 next_id = 0; + /* Now we're actually creating a payment, load gossip store */ + if (!gossmap) { + gossmap = notleak_with_children(gossmap_load(NULL, + GOSSIP_STORE_FILENAME)); + if (!gossmap) + plugin_err(cmd->plugin, "Could not load gossmap %s: %s", + GOSSIP_STORE_FILENAME, strerror(errno)); + } + p->children = tal_arr(p, struct payment *, 0); p->parent = parent; p->modifiers = mods;