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

Function check_scriptpubkey_watches

plugins/bwatch/bwatch_scanner.c:17–48  ·  view source on GitHub ↗

Check all scriptpubkey watches via hash lookup */

Source from the content-addressed store, hash-verified

15
16/* Check all scriptpubkey watches via hash lookup */
17static void check_scriptpubkey_watches(struct command *cmd,
18 struct bwatch *bwatch,
19 const struct bitcoin_tx *tx,
20 u32 blockheight,
21 const struct bitcoin_blkid *blockhash,
22 u32 txindex)
23{
24 struct bitcoin_txid txid;
25
26 bitcoin_txid(tx, &txid);
27
28 for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
29 struct watch *w;
30 struct scriptpubkey k = {
31 .script = tx->wtx->outputs[i].script,
32 .len = tx->wtx->outputs[i].script_len
33 };
34
35 w = scriptpubkey_watches_get(bwatch->scriptpubkey_watches, &k);
36 if (!w)
37 continue;
38 if (w->start_block != UINT32_MAX
39 && blockheight < w->start_block) {
40 plugin_log(cmd->plugin, LOG_BROKEN,
41 "Watch for script %s on height >= %u found on block %u???",
42 tal_hexstr(tmpctx, k.script, k.len),
43 w->start_block, blockheight);
44 continue;
45 }
46 bwatch_send_watch_found(cmd, tx, blockheight, w, txindex, i);
47 }
48}
49
50/* Check all outpoint watches via hash lookup */
51static void check_outpoint_watches(struct command *cmd,

Callers 1

Calls 4

tal_hexstrFunction · 0.85
bwatch_send_watch_foundFunction · 0.85
bitcoin_txidClass · 0.70
plugin_logFunction · 0.50

Tested by

no test coverage detected