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). */
| 617 | * Will return early with null fields if block isn't known (yet). |
| 618 | */ |
| 619 | static 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, |
nothing calls this directly
no test coverage detected