MCPcopy Create free account
hub / github.com/ElementsProject/lightning / onchain_txo_watched

Function onchain_txo_watched

lightningd/onchain_control.c:219–238  ·  view source on GitHub ↗

* Entrypoint for the txowatch callback, stores tx and calls onchain_txo_spent. */

Source from the content-addressed store, hash-verified

217 * Entrypoint for the txowatch callback, stores tx and calls onchain_txo_spent.
218 */
219static 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. */
241static void watch_tx_and_outputs(struct channel *channel,

Callers

nothing calls this directly

Calls 3

onchain_txo_spentFunction · 0.85
bitcoin_txidClass · 0.70
wallet_channeltxs_addFunction · 0.50

Tested by

no test coverage detected