| 3476 | tal_free(to_delete); |
| 3477 | } |
| 3478 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 3479 | const char *buffer, |
| 3480 | const jsmntok_t *obj, |
| 3481 | const jsmntok_t *params) |
| 3482 | { |
| 3483 | unsigned int *target_block_height; |
| 3484 | u32 block_height; |
| 3485 | unsigned int *timeout; |
| 3486 | struct waitblockheight_waiter *w; |
| 3487 | |
| 3488 | if (!param(cmd, buffer, params, |
| 3489 | p_req("blockheight", param_number, &target_block_height), |
| 3490 | p_opt_def("timeout", param_number, &timeout, 60), |
| 3491 | NULL)) |
| 3492 | return command_param_failed(); |
| 3493 | |
| 3494 | /* Check if already reached anyway. */ |
| 3495 | block_height = get_block_height(cmd->ld->topology); |
| 3496 | if (*target_block_height <= block_height) |
| 3497 | return waitblockheight_complete(cmd, block_height); |
| 3498 | |
| 3499 | /* Create a new waitblockheight command. */ |
| 3500 | w = tal(cmd, struct waitblockheight_waiter); |
| 3501 | tal_add_destructor(w, &destroy_waitblockheight_waiter); |
| 3502 | list_add(&cmd->ld->waitblockheight_commands, &w->list); |
| 3503 | w->cmd = cmd; |
| 3504 | w->block_height = *target_block_height; |
| 3505 | w->removed = false; |
| 3506 | /* Install the timeout. */ |
| 3507 | (void) new_reltimer(cmd->ld->timers, w, time_from_sec(*timeout), |
| 3508 | &timeout_waitblockheight_waiter, w); |
| 3509 | |
| 3510 | return command_still_pending(cmd); |
| 3511 | } |
| 3512 | |
| 3513 | static const struct json_command waitblockheight_command = { |
| 3514 | "waitblockheight", |
nothing calls this directly
no test coverage detected