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

Function block_from_response

plugins/bwatch/bwatch.c:39–56  ·  view source on GitHub ↗

Parse the bitcoin block out of a getrawblockbyheight response. */

Source from the content-addressed store, hash-verified

37
38/* Parse the bitcoin block out of a getrawblockbyheight response. */
39static struct bitcoin_block *block_from_response(const char *buf,
40 const jsmntok_t *result,
41 struct bitcoin_blkid *blockhash_out)
42{
43 const jsmntok_t *blocktok = json_get_member(buf, result, "block");
44 struct bitcoin_block *block;
45
46 if (!blocktok)
47 return NULL;
48
49 block = bitcoin_block_from_hex(tmpctx, chainparams,
50 buf + blocktok->start,
51 blocktok->end - blocktok->start);
52 if (block && blockhash_out)
53 bitcoin_block_blkid(block, blockhash_out);
54
55 return block;
56}
57
58/* Fetch a block by height for normal polling. */
59static struct command_result *fetch_block_handle(struct command *cmd,

Callers 2

handle_blockFunction · 0.85
rescan_block_doneFunction · 0.85

Calls 3

json_get_memberFunction · 0.85
bitcoin_block_from_hexFunction · 0.85
bitcoin_block_blkidFunction · 0.85

Tested by

no test coverage detected