To avoid races, we watch the tx and all outputs. */
| 239 | |
| 240 | /* To avoid races, we watch the tx and all outputs. */ |
| 241 | static void watch_tx_and_outputs(struct channel *channel, |
| 242 | const struct bitcoin_tx *tx) |
| 243 | { |
| 244 | struct bitcoin_outpoint outpoint; |
| 245 | struct txwatch *txw; |
| 246 | struct lightningd *ld = channel->peer->ld; |
| 247 | |
| 248 | bitcoin_txid(tx, &outpoint.txid); |
| 249 | |
| 250 | /* Make txwatch a parent of txo watches, so we can unwatch together. */ |
| 251 | txw = watch_tx(channel->owner, ld->topology, channel, tx, |
| 252 | onchain_tx_watched); |
| 253 | |
| 254 | for (outpoint.n = 0; outpoint.n < tx->wtx->num_outputs; outpoint.n++) |
| 255 | watch_txo(txw, ld->topology, channel, &outpoint, |
| 256 | onchain_txo_watched); |
| 257 | } |
| 258 | |
| 259 | static void handle_onchain_log_coin_move(struct channel *channel, const u8 *msg) |
| 260 | { |
no test coverage detected