Browse Source

txowatch: include block in which spending tx is found.

onchaind wants the block height, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
4ba1599494
  1. 2
      daemon/chaintopology.c
  2. 2
      daemon/peer.c
  3. 6
      daemon/watch.c
  4. 9
      daemon/watch.h

2
daemon/chaintopology.c

@ -110,7 +110,7 @@ static void connect_block(struct chain_topology *topo,
txo = txowatch_hash_get(&topo->txowatches, &out);
if (txo)
txowatch_fire(topo, txo, tx, j);
txowatch_fire(topo, txo, tx, j, b);
}
/* We did spends first, in case that tells us to watch tx. */

2
daemon/peer.c

@ -3787,6 +3787,7 @@ static enum watch_result our_unilateral_depth(struct peer *peer,
static enum watch_result our_htlc_spent(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
const struct block *block,
struct htlc *h)
{
struct sha256 sha;
@ -4199,6 +4200,7 @@ static struct sha256 *get_rhash(struct peer *peer, u64 commit_num,
static enum watch_result anchor_spent(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
const struct block *block,
void *unused)
{
Pkt *err;

6
daemon/watch.c

@ -141,6 +141,7 @@ struct txowatch *watch_txo_(const tal_t *ctx,
enum watch_result (*cb)(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
const struct block *block,
void *),
void *cbdata)
{
@ -204,7 +205,8 @@ void txwatch_fire(struct chain_topology *topo,
void txowatch_fire(struct chain_topology *topo,
const struct txowatch *txow,
const struct bitcoin_tx *tx,
size_t input_num)
size_t input_num,
const struct block *block)
{
struct sha256_double txid;
enum watch_result r;
@ -220,7 +222,7 @@ void txowatch_fire(struct chain_topology *topo,
txid.sha.u.u8[1],
txid.sha.u.u8[2],
txid.sha.u.u8[3]);
r = txow->cb(txow->peer, tx, input_num, txow->cbdata);
r = txow->cb(txow->peer, tx, input_num, block, txow->cbdata);
switch (r) {
case DELETE_WATCH:
tal_free(txow);

9
daemon/watch.h

@ -9,6 +9,7 @@
#include <ccan/typesafe_cb/typesafe_cb.h>
struct bitcoin_tx;
struct block;
struct lightningd_state;
enum watch_result {
@ -35,6 +36,7 @@ struct txowatch {
enum watch_result (*cb)(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
const struct block *block,
void *cbdata);
void *cbdata;
@ -119,6 +121,7 @@ struct txowatch *watch_txo_(const tal_t *ctx,
enum watch_result (*cb)(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
const struct block *block,
void *),
void *cbdata);
@ -128,7 +131,8 @@ struct txowatch *watch_txo_(const tal_t *ctx,
(cb), (cbdata), \
struct peer *, \
const struct bitcoin_tx *, \
size_t), \
size_t, \
const struct block *block), \
(cbdata))
void txwatch_fire(struct chain_topology *topo,
@ -137,7 +141,8 @@ void txwatch_fire(struct chain_topology *topo,
void txowatch_fire(struct chain_topology *topo,
const struct txowatch *txow,
const struct bitcoin_tx *tx, size_t input_num);
const struct bitcoin_tx *tx, size_t input_num,
const struct block *block);
bool watching_txid(const struct chain_topology *topo,
const struct sha256_double *txid);

Loading…
Cancel
Save