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

Function watch_scriptpubkey_

lightningd/watch.c:375–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375bool watch_scriptpubkey_(const tal_t *ctx,
376 struct chain_topology *topo,
377 const u8 *scriptpubkey TAKES,
378 const struct bitcoin_outpoint *expected_outpoint,
379 struct amount_sat expected_amount,
380 void (*cb)(struct lightningd *ld,
381 const struct bitcoin_tx *tx,
382 u32 outnum,
383 const struct txlocator *loc,
384 void *),
385 void *arg)
386{
387 struct scriptpubkeywatch *w;
388
389 if (find_watchscriptpubkey(topo->scriptpubkeywatches,
390 scriptpubkey,
391 expected_outpoint,
392 expected_amount,
393 cb, arg)) {
394 if (taken(scriptpubkey))
395 tal_free(scriptpubkey);
396 return false;
397 }
398
399 w = tal(ctx, struct scriptpubkeywatch);
400 w->swl.script = tal_dup_talarr(w, u8, scriptpubkey);
401 w->swl.len = tal_bytelen(w->swl.script);
402 w->expected_outpoint = *expected_outpoint;
403 w->expected_amount = expected_amount;
404 w->cb = cb;
405 w->arg = arg;
406 scriptpubkeywatch_hash_add(topo->scriptpubkeywatches, w);
407 tal_add_destructor2(w, destroy_scriptpubkeywatch, topo);
408 return true;
409}
410
411bool unwatch_scriptpubkey_(const tal_t *ctx,
412 struct chain_topology *topo,

Callers

nothing calls this directly

Calls 4

find_watchscriptpubkeyFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected