From 633f893ec4d0a0d4398405f30bdd2945b3a0b466 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 28 Mar 2018 12:03:40 +0200 Subject: [PATCH] gossip: Add function to notify gossipd about an outpoint spend Signed-off-by: Christian Decker --- lightningd/chaintopology.c | 2 ++ lightningd/gossip_control.c | 7 +++++++ lightningd/gossip_control.h | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index a58db2353..7618fa0ac 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -16,6 +16,7 @@ #include #include #include +#include /* Mutual recursion via timer. */ static void try_extend_tip(struct chain_topology *topo); @@ -415,6 +416,7 @@ static void topo_update_spends(struct chain_topology *topo, struct block *b) b->height, &input->txid, input->index); if (scid) { + gossipd_notify_spend(topo->bitcoind->ld, scid); tal_free(scid); } } diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 1a2958e97..ae6908622 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -216,6 +216,13 @@ void gossip_init(struct lightningd *ld) subd_send_msg(ld->gossip, msg); } +void gossipd_notify_spend(struct lightningd *ld, + const struct short_channel_id *scid) +{ + u8 *msg = towire_gossip_outpoint_spent(tmpctx, scid); + subd_send_msg(ld->gossip, msg); +} + static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply, const int *fds UNUSED, struct command *cmd) diff --git a/lightningd/gossip_control.h b/lightningd/gossip_control.h index 8a4d6febc..ec0683b37 100644 --- a/lightningd/gossip_control.h +++ b/lightningd/gossip_control.h @@ -1,10 +1,15 @@ #ifndef LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H #define LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H #include "config.h" +#include #include #include struct lightningd; void gossip_init(struct lightningd *ld); + +void gossipd_notify_spend(struct lightningd *ld, + const struct short_channel_id *scid); + #endif /* LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H */