|
|
@ -10,6 +10,10 @@ |
|
|
|
|
|
|
|
struct bitcoin_tx; |
|
|
|
struct block; |
|
|
|
struct channel; |
|
|
|
struct chain_topology; |
|
|
|
struct txowatch; |
|
|
|
struct txwatch; |
|
|
|
|
|
|
|
enum watch_result { |
|
|
|
DELETE_WATCH = -1, |
|
|
@ -21,26 +25,6 @@ struct txwatch_output { |
|
|
|
unsigned int index; |
|
|
|
}; |
|
|
|
|
|
|
|
/* Watching an output */ |
|
|
|
struct txowatch { |
|
|
|
struct chain_topology *topo; |
|
|
|
|
|
|
|
/* Channel who owns us. */ |
|
|
|
struct channel *channel; |
|
|
|
|
|
|
|
/* Output to watch. */ |
|
|
|
struct txwatch_output out; |
|
|
|
|
|
|
|
/* A new tx. */ |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
size_t input_num, |
|
|
|
const struct block *block, |
|
|
|
void *cbdata); |
|
|
|
|
|
|
|
void *cbdata; |
|
|
|
}; |
|
|
|
|
|
|
|
const struct txwatch_output *txowatch_keyof(const struct txowatch *w); |
|
|
|
size_t txo_hash(const struct txwatch_output *out); |
|
|
|
bool txowatch_eq(const struct txowatch *w, const struct txwatch_output *out); |
|
|
@ -48,25 +32,6 @@ bool txowatch_eq(const struct txowatch *w, const struct txwatch_output *out); |
|
|
|
HTABLE_DEFINE_TYPE(struct txowatch, txowatch_keyof, txo_hash, txowatch_eq, |
|
|
|
txowatch_hash); |
|
|
|
|
|
|
|
struct txwatch { |
|
|
|
struct chain_topology *topo; |
|
|
|
|
|
|
|
/* Channel who owns us. */ |
|
|
|
struct channel *channel; |
|
|
|
|
|
|
|
/* Transaction to watch. */ |
|
|
|
struct bitcoin_txid txid; |
|
|
|
unsigned int depth; |
|
|
|
|
|
|
|
/* A new depth (0 if kicked out, otherwise 1 = tip, etc.) */ |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
unsigned int depth, |
|
|
|
void *cbdata); |
|
|
|
|
|
|
|
void *cbdata; |
|
|
|
}; |
|
|
|
|
|
|
|
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); |
|
|
@ -74,65 +39,31 @@ HTABLE_DEFINE_TYPE(struct txwatch, txwatch_keyof, txid_hash, txwatch_eq, |
|
|
|
txwatch_hash); |
|
|
|
|
|
|
|
|
|
|
|
struct txwatch *watch_txid_(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_txid *txid, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
struct txwatch *watch_txid(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_txid *txid, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *, |
|
|
|
unsigned int depth, |
|
|
|
void *), |
|
|
|
void *cbdata); |
|
|
|
unsigned int depth)); |
|
|
|
|
|
|
|
#define watch_txid(ctx, topo, channel_, txid, cb, cbdata) \ |
|
|
|
watch_txid_((ctx), (topo), (channel_), (txid), \ |
|
|
|
typesafe_cb_preargs(enum watch_result, void *, \ |
|
|
|
(cb), (cbdata), \ |
|
|
|
struct channel *, \ |
|
|
|
const struct bitcoin_tx *, \ |
|
|
|
unsigned int depth), \ |
|
|
|
(cbdata)) |
|
|
|
|
|
|
|
struct txwatch *watch_tx_(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
struct txwatch *watch_tx(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *, |
|
|
|
unsigned int depth, |
|
|
|
void *), |
|
|
|
void *cbdata); |
|
|
|
|
|
|
|
#define watch_tx(ctx, topo, channel_, tx, cb, cbdata) \ |
|
|
|
watch_tx_((ctx), (topo), (channel_), (tx), \ |
|
|
|
typesafe_cb_preargs(enum watch_result, void *, \ |
|
|
|
(cb), (cbdata), \ |
|
|
|
struct channel *, \ |
|
|
|
const struct bitcoin_tx *, \ |
|
|
|
unsigned int depth), \ |
|
|
|
(cbdata)) |
|
|
|
|
|
|
|
struct txowatch *watch_txo_(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_txid *txid, |
|
|
|
unsigned int output, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
size_t input_num, |
|
|
|
const struct block *block, |
|
|
|
void *), |
|
|
|
void *cbdata); |
|
|
|
|
|
|
|
#define watch_txo(ctx, topo, channel_, txid, outnum, cb, cbdata) \ |
|
|
|
watch_txo_((ctx), (topo), (channel_), (txid), (outnum), \ |
|
|
|
typesafe_cb_preargs(enum watch_result, void *, \ |
|
|
|
(cb), (cbdata), \ |
|
|
|
struct channel *, \ |
|
|
|
const struct bitcoin_tx *, \ |
|
|
|
size_t, \ |
|
|
|
const struct block *block), \ |
|
|
|
(cbdata)) |
|
|
|
unsigned int depth)); |
|
|
|
|
|
|
|
struct txowatch *watch_txo(const tal_t *ctx, |
|
|
|
struct chain_topology *topo, |
|
|
|
struct channel *channel, |
|
|
|
const struct bitcoin_txid *txid, |
|
|
|
unsigned int output, |
|
|
|
enum watch_result (*cb)(struct channel *channel, |
|
|
|
const struct bitcoin_tx *tx, |
|
|
|
size_t input_num, |
|
|
|
const struct block *block)); |
|
|
|
|
|
|
|
struct txwatch *find_txwatch(struct chain_topology *topo, |
|
|
|
const struct bitcoin_txid *txid, |
|
|
|