* Entrypoint for the txowatch callback, stores tx and calls onchain_txo_spent. */
| 217 | * Entrypoint for the txowatch callback, stores tx and calls onchain_txo_spent. |
| 218 | */ |
| 219 | static enum watch_result onchain_txo_watched(struct channel *channel, |
| 220 | const struct bitcoin_tx *tx, |
| 221 | size_t input_num, |
| 222 | const struct block *block) |
| 223 | { |
| 224 | struct bitcoin_txid txid; |
| 225 | bitcoin_txid(tx, &txid); |
| 226 | |
| 227 | /* Store the channeltx so we can replay later */ |
| 228 | wallet_channeltxs_add(channel->peer->ld->wallet, channel, |
| 229 | WIRE_ONCHAIND_SPENT, &txid, input_num, |
| 230 | block->height); |
| 231 | |
| 232 | onchain_txo_spent(channel, tx, input_num, block->height); |
| 233 | |
| 234 | /* We don't need to keep watching: If this output is double-spent |
| 235 | * (reorg), we'll get a zero depth cb to onchain_tx_watched, and |
| 236 | * restart onchaind. */ |
| 237 | return DELETE_WATCH; |
| 238 | } |
| 239 | |
| 240 | /* To avoid races, we watch the tx and all outputs. */ |
| 241 | static void watch_tx_and_outputs(struct channel *channel, |
nothing calls this directly
no test coverage detected