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

Function getrawblockbyheight

plugins/bcli.c:619–643  ·  view source on GitHub ↗

Get a raw block given its height. * Calls `getblockhash` then `getblock` to retrieve it from bitcoin_cli. * Will return early with null fields if block isn't known (yet). */

Source from the content-addressed store, hash-verified

617 * Will return early with null fields if block isn't known (yet).
618 */
619static struct command_result *getrawblockbyheight(struct command *cmd,
620 const char *buf,
621 const jsmntok_t *toks)
622{
623 struct getrawblock_stash *stash;
624 u32 *height;
625
626 /* bitcoin-cli wants a string. */
627 if (!param(cmd, buf, toks,
628 p_req("height", param_number, &height),
629 NULL))
630 return command_param_failed();
631
632 stash = tal(cmd, struct getrawblock_stash);
633 stash->block_height = *height;
634 tal_free(height);
635
636 start_bitcoin_cli(NULL, cmd, process_getblockhash, true,
637 BITCOIND_LOW_PRIO, stash,
638 "getblockhash",
639 take(tal_fmt(NULL, "%u", stash->block_height)),
640 NULL);
641
642 return command_still_pending(cmd);
643}
644
645/* Get infos about the block chain.
646 * Calls `getblockchaininfo` and returns headers count, blocks count,

Callers

nothing calls this directly

Calls 5

tal_freeFunction · 0.85
start_bitcoin_cliFunction · 0.85
command_param_failedFunction · 0.70
command_still_pendingFunction · 0.70
paramFunction · 0.50

Tested by

no test coverage detected