| 373 | } |
| 374 | |
| 375 | bool 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 | |
| 411 | bool unwatch_scriptpubkey_(const tal_t *ctx, |
| 412 | struct chain_topology *topo, |
nothing calls this directly
no test coverage detected