mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
daemon: allow multiple watches on the same tx.
This turns out to make life easier for watching HTLC timeouts (we just place a new watch for each HTLC). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
77a89bcf2b
commit
c94c495257
@ -137,6 +137,7 @@ static void connect_blocks(struct lightningd_state *dstate, struct block *b)
|
||||
struct bitcoin_tx *tx = b->full_txs[i];
|
||||
struct txwatch *w;
|
||||
struct sha256_double txid;
|
||||
struct txwatch_hash_iter iter;
|
||||
size_t j;
|
||||
|
||||
/* Tell them if it spends a txo we care about. */
|
||||
@ -153,8 +154,9 @@ static void connect_blocks(struct lightningd_state *dstate, struct block *b)
|
||||
|
||||
/* We do spends first, in case that tells us to watch tx. */
|
||||
bitcoin_txid(tx, &txid);
|
||||
w = txwatch_hash_get(&dstate->txwatches, &txid);
|
||||
if (w) {
|
||||
for (w = txwatch_hash_getfirst(&dstate->txwatches, &txid, &iter);
|
||||
w;
|
||||
w = txwatch_hash_getnext(&dstate->txwatches, &txid, &iter)){
|
||||
add_tx_to_block(b, w);
|
||||
/* Fire if it's the first we've seen it: this might
|
||||
* set up txo watches, which could fire in this block */
|
||||
|
@ -90,8 +90,6 @@ struct txwatch *watch_txid_(const tal_t *ctx,
|
||||
{
|
||||
struct txwatch *w;
|
||||
|
||||
assert(!txwatch_hash_get(&peer->dstate->txwatches, txid));
|
||||
|
||||
w = tal(ctx, struct txwatch);
|
||||
w->depth = -1;
|
||||
w->txid = *txid;
|
||||
|
Loading…
Reference in New Issue
Block a user