waitblockheight

lightning-waitblockheight -- Command for waiting for blocks on the blockchain

SYNOPSIS

waitblockheight blockheight [timeout]

DESCRIPTION

The waitblockheight RPC command waits until the blockchain has reached the specified blockheight.

  • blockheight (u32): Current blockheight of the blockchain if the value is greater than this number. If it is a present or past block height, then the command returns immediately.
  • timeout (u32, optional): Only wait up to specified seconds. The default is 60 seconds.

RETURN VALUE

On success, an object is returned, containing:

  • blockheight (u32): The current block height (>= blockheight parameter).

If timeout seconds is reached without the specified blockheight being reached, this command will fail with a code of 2000.

ERRORS

The following error codes may occur:

  • 2000: Timed out.

AUTHOR

ZmnSCPxj <ZmnSCPxj@protonmail.com> is mainly responsible.

RESOURCES

Main web site: https://github.com/ElementsProject/lightning

EXAMPLES

Example 1: This will return immediately since the current blockheight exceeds the requested waitblockheight.

Request:

lightning-cli waitblockheight -k "blockheight"=126
{
  "id": "example:waitblockheight#1",
  "method": "waitblockheight",
  "params": {
    "blockheight": 126
  }
}

Response:

{
  "blockheight": 130
}

Example 2: This will return after the next block is mined because requested waitblockheight is one block higher than the current blockheight.

Request:

lightning-cli waitblockheight -k "blockheight"=131 "timeout"=600
{
  "id": "example:waitblockheight#2",
  "method": "waitblockheight",
  "params": {
    "blockheight": 131,
    "timeout": 600
  }
}

Response:

{
  "blockheight": 131
}