gossip: Add function to notify gossipd about an outpoint spend

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-03-28 12:03:40 +02:00
parent a8d587c418
commit 633f893ec4
3 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <common/timeout.h>
#include <common/utils.h>
#include <inttypes.h>
#include <lightningd/gossip_control.h>
/* 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);
}
}

View File

@ -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)

View File

@ -1,10 +1,15 @@
#ifndef LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H
#define LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
#include <ccan/short_types/short_types.h>
#include <stdbool.h>
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 */