Register a blockdepth watch for `owner` anchored at `start_block`. * Each new block fires a watch_found with depth = tip - start_block + 1. */
| 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. */ |
| 489 | struct 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. */ |
nothing calls this directly
no test coverage detected