Browse Source

gossip: Add function to notify gossipd about an outpoint spend

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
633f893ec4
  1. 2
      lightningd/chaintopology.c
  2. 7
      lightningd/gossip_control.c
  3. 5
      lightningd/gossip_control.h

2
lightningd/chaintopology.c

@ -16,6 +16,7 @@
#include <common/timeout.h> #include <common/timeout.h>
#include <common/utils.h> #include <common/utils.h>
#include <inttypes.h> #include <inttypes.h>
#include <lightningd/gossip_control.h>
/* Mutual recursion via timer. */ /* Mutual recursion via timer. */
static void try_extend_tip(struct chain_topology *topo); 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, b->height, &input->txid,
input->index); input->index);
if (scid) { if (scid) {
gossipd_notify_spend(topo->bitcoind->ld, scid);
tal_free(scid); tal_free(scid);
} }
} }

7
lightningd/gossip_control.c

@ -216,6 +216,13 @@ void gossip_init(struct lightningd *ld)
subd_send_msg(ld->gossip, msg); 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, static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply,
const int *fds UNUSED, const int *fds UNUSED,
struct command *cmd) struct command *cmd)

5
lightningd/gossip_control.h

@ -1,10 +1,15 @@
#ifndef LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H #ifndef LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H
#define LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H #define LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H
#include "config.h" #include "config.h"
#include <bitcoin/short_channel_id.h>
#include <ccan/short_types/short_types.h> #include <ccan/short_types/short_types.h>
#include <stdbool.h> #include <stdbool.h>
struct lightningd; struct lightningd;
void gossip_init(struct lightningd *ld); 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 */ #endif /* LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H */

Loading…
Cancel
Save