#ifndef LIGHTNING_PLUGINS_BWATCH_BWATCH_H
#define LIGHTNING_PLUGINS_BWATCH_BWATCH_H
#include "config.h"
#include <bitcoin/block.h>
#include <bitcoin/short_channel_id.h>
#include <bitcoin/tx.h>
#include <plugins/libplugin.h>
#include <wire/wire.h>
struct scriptpubkey_watches;
struct outpoint_watches;
struct scid_watches;
struct blockdepth_watches;
struct plugin_timer;
struct block_record_wire;
enum watch_type {
WATCH_SCRIPTPUBKEY,
WATCH_OUTPOINT,
WATCH_SCID,
WATCH_BLOCKDEPTH,
};
struct scriptpubkey {
const u8 *script;
size_t len;
};
struct watch {
enum watch_type type;
u32 start_block;
wirestring **owners;
union {
struct scriptpubkey scriptpubkey;
struct bitcoin_outpoint outpoint;
struct short_channel_id scid;
} key;
};
struct bwatch {
struct plugin *plugin;
u32 current_height;
struct bitcoin_blkid current_blockhash;
struct block_record_wire *block_history;
struct scriptpubkey_watches *scriptpubkey_watches;
struct outpoint_watches *outpoint_watches;
struct scid_watches *scid_watches;
struct blockdepth_watches *blockdepth_watches;
struct plugin_timer *poll_timer;
u32 poll_interval_ms;
bool experimental;
};
const struct block_record_wire *bwatch_last_block(const struct bwatch *bwatch);
struct bwatch *bwatch_of(struct plugin *plugin);
struct command_result *bwatch_poll_chain(struct command *cmd, void *unused);
void bwatch_remove_tip(struct command *cmd, struct bwatch *bwatch);
struct rescan_state {
const struct watch *watch;
u32 current_block;
u32 target_block;
};
void bwatch_start_rescan(struct command *cmd,
const struct watch *w,
u32 start_block,
u32 target_block);
#endif