| 3684 | tal_free(to_delete); |
| 3685 | } |
| 3686 | static struct command_result *json_waitblockheight(struct command *cmd, |
| 3687 | const char *buffer, |
| 3688 | const jsmntok_t *obj, |
| 3689 | const jsmntok_t *params) |
| 3690 | { |
| 3691 | unsigned int *target_block_height; |
| 3692 | u32 block_height; |
| 3693 | unsigned int *timeout; |
| 3694 | struct waitblockheight_waiter *w; |
| 3695 | |
| 3696 | if (!param(cmd, buffer, params, |
| 3697 | p_req("blockheight", param_number, &target_block_height), |
| 3698 | p_opt_def("timeout", param_number, &timeout, 60), |
| 3699 | NULL)) |
| 3700 | return command_param_failed(); |
| 3701 | |
| 3702 | /* Check if already reached anyway. */ |
| 3703 | block_height = get_block_height(cmd->ld->topology); |
| 3704 | if (*target_block_height <= block_height) |
| 3705 | return waitblockheight_complete(cmd, block_height); |
| 3706 | |
| 3707 | /* Create a new waitblockheight command. */ |
| 3708 | w = tal(cmd, struct waitblockheight_waiter); |
| 3709 | tal_add_destructor(w, &destroy_waitblockheight_waiter); |
| 3710 | list_add(&cmd->ld->waitblockheight_commands, &w->list); |
| 3711 | w->cmd = cmd; |
| 3712 | w->block_height = *target_block_height; |
| 3713 | w->removed = false; |
| 3714 | /* Install the timeout. */ |
| 3715 | (void) new_reltimer(cmd->ld->timers, w, time_from_sec(*timeout), |
| 3716 | &timeout_waitblockheight_waiter, w); |
| 3717 | |
| 3718 | return command_still_pending(cmd); |
| 3719 | } |
| 3720 | |
| 3721 | static const struct json_command waitblockheight_command = { |
| 3722 | "waitblockheight", |
nothing calls this directly
no test coverage detected