2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_WATCH_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_WATCH_H
|
2016-01-21 21:11:49 +01:00
|
|
|
#include "config.h"
|
2017-12-18 07:41:52 +01:00
|
|
|
#include <bitcoin/tx.h>
|
2016-01-21 21:11:49 +01:00
|
|
|
#include <ccan/htable/htable_type.h>
|
|
|
|
|
2017-08-23 02:58:44 +02:00
|
|
|
struct block;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct channel;
|
|
|
|
struct chain_topology;
|
2018-08-13 05:05:33 +02:00
|
|
|
struct lightningd;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct txowatch;
|
|
|
|
struct txwatch;
|
2016-01-21 21:11:49 +01:00
|
|
|
|
2016-06-30 01:40:11 +02:00
|
|
|
enum watch_result {
|
|
|
|
DELETE_WATCH = -1,
|
|
|
|
KEEP_WATCHING = -2
|
|
|
|
};
|
|
|
|
|
2021-10-13 05:45:36 +02:00
|
|
|
const struct bitcoin_outpoint *txowatch_keyof(const struct txowatch *w);
|
|
|
|
size_t txo_hash(const struct bitcoin_outpoint *out);
|
|
|
|
bool txowatch_eq(const struct txowatch *w, const struct bitcoin_outpoint *out);
|
2016-01-21 21:11:49 +01:00
|
|
|
|
|
|
|
HTABLE_DEFINE_TYPE(struct txowatch, txowatch_keyof, txo_hash, txowatch_eq,
|
|
|
|
txowatch_hash);
|
|
|
|
|
2017-12-18 07:41:52 +01:00
|
|
|
const struct bitcoin_txid *txwatch_keyof(const struct txwatch *w);
|
|
|
|
size_t txid_hash(const struct bitcoin_txid *txid);
|
|
|
|
bool txwatch_eq(const struct txwatch *w, const struct bitcoin_txid *txid);
|
2016-01-21 21:11:49 +01:00
|
|
|
HTABLE_DEFINE_TYPE(struct txwatch, txwatch_keyof, txid_hash, txwatch_eq,
|
|
|
|
txwatch_hash);
|
|
|
|
|
|
|
|
|
2018-02-20 21:59:09 +01:00
|
|
|
struct txwatch *watch_txid(const tal_t *ctx,
|
|
|
|
struct chain_topology *topo,
|
|
|
|
struct channel *channel,
|
|
|
|
const struct bitcoin_txid *txid,
|
2018-08-13 05:05:33 +02:00
|
|
|
enum watch_result (*cb)(struct lightningd *ld,
|
|
|
|
struct channel *channel,
|
|
|
|
const struct bitcoin_txid *,
|
2019-06-28 03:58:31 +02:00
|
|
|
const struct bitcoin_tx *,
|
2018-02-20 21:59:09 +01:00
|
|
|
unsigned int depth));
|
2016-04-24 12:09:21 +02:00
|
|
|
|
2018-02-20 21:59:09 +01:00
|
|
|
struct txwatch *watch_tx(const tal_t *ctx,
|
|
|
|
struct chain_topology *topo,
|
|
|
|
struct channel *channel,
|
|
|
|
const struct bitcoin_tx *tx,
|
2018-08-13 05:05:33 +02:00
|
|
|
enum watch_result (*cb)(struct lightningd *ld,
|
|
|
|
struct channel *channel,
|
|
|
|
const struct bitcoin_txid *,
|
2019-06-28 03:58:31 +02:00
|
|
|
const struct bitcoin_tx *,
|
2018-08-13 05:05:33 +02:00
|
|
|
unsigned int depth));
|
2018-02-20 21:59:09 +01:00
|
|
|
|
|
|
|
struct txowatch *watch_txo(const tal_t *ctx,
|
|
|
|
struct chain_topology *topo,
|
|
|
|
struct channel *channel,
|
2021-10-13 05:45:36 +02:00
|
|
|
const struct bitcoin_outpoint *outpoint,
|
2018-02-20 21:59:09 +01:00
|
|
|
enum watch_result (*cb)(struct channel *channel,
|
|
|
|
const struct bitcoin_tx *tx,
|
|
|
|
size_t input_num,
|
|
|
|
const struct block *block));
|
2016-04-24 12:09:21 +02:00
|
|
|
|
2018-01-29 03:21:18 +01:00
|
|
|
struct txwatch *find_txwatch(struct chain_topology *topo,
|
|
|
|
const struct bitcoin_txid *txid,
|
2018-02-12 11:13:04 +01:00
|
|
|
const struct channel *channel);
|
2018-01-29 03:21:18 +01:00
|
|
|
|
2017-03-02 13:21:49 +01:00
|
|
|
void txwatch_fire(struct chain_topology *topo,
|
2018-04-10 11:14:50 +02:00
|
|
|
const struct bitcoin_txid *txid,
|
2016-04-24 12:20:35 +02:00
|
|
|
unsigned int depth);
|
2016-04-24 12:18:35 +02:00
|
|
|
|
2018-02-21 16:57:45 +01:00
|
|
|
void txowatch_fire(const struct txowatch *txow,
|
2017-08-23 02:58:44 +02:00
|
|
|
const struct bitcoin_tx *tx, size_t input_num,
|
|
|
|
const struct block *block);
|
2016-04-24 12:18:35 +02:00
|
|
|
|
2017-03-02 13:21:49 +01:00
|
|
|
bool watching_txid(const struct chain_topology *topo,
|
2017-12-18 07:41:52 +01:00
|
|
|
const struct bitcoin_txid *txid);
|
2016-05-04 08:40:37 +02:00
|
|
|
|
2019-06-28 03:58:31 +02:00
|
|
|
/* FIXME: Implement bitcoin_tx_dup() so we tx arg can be TAKEN */
|
|
|
|
void txwatch_inform(const struct chain_topology *topo,
|
|
|
|
const struct bitcoin_txid *txid,
|
|
|
|
const struct bitcoin_tx *tx_may_steal);
|
|
|
|
|
2017-03-02 13:21:49 +01:00
|
|
|
void watch_topology_changed(struct chain_topology *topo);
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_WATCH_H */
|