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

Function json_bwatch_add_blockdepth

plugins/bwatch/bwatch_interface.c:489–510  ·  view source on GitHub ↗

Register a blockdepth watch for `owner` anchored at `start_block`. * Each new block fires a watch_found with depth = tip - start_block + 1. */

Source from the content-addressed store, hash-verified

487/* Register a blockdepth watch for `owner` anchored at `start_block`.
488 * Each new block fires a watch_found with depth = tip - start_block + 1. */
489struct command_result *json_bwatch_add_blockdepth(struct command *cmd,
490 const char *buffer,
491 const jsmntok_t *params)
492{
493 struct bwatch *bwatch = bwatch_of(cmd->plugin);
494 const char *owner;
495 u32 *start_block;
496 struct watch *w;
497
498 if (!param(cmd, buffer, params,
499 p_req("owner", param_string, &owner),
500 p_req("start_block", param_u32, &start_block),
501 NULL))
502 return command_param_failed();
503
504 /* start_block doubles as the watch key (confirm_height) and
505 * the anchor for depth = tip - start_block + 1. */
506 w = bwatch_add_watch(cmd, bwatch, WATCH_BLOCKDEPTH,
507 NULL, NULL, NULL, start_block,
508 *start_block, owner);
509 return add_watch_and_maybe_rescan(cmd, bwatch, w, *start_block);
510}
511
512/* Drop one owner from a blockdepth watch; the watch itself goes away
513 * once the last owner is removed. */

Callers

nothing calls this directly

Calls 5

bwatch_ofFunction · 0.85
bwatch_add_watchFunction · 0.85
paramFunction · 0.50
command_param_failedFunction · 0.50

Tested by

no test coverage detected