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

Function test_enc

devtools/encodeaddr.c:7–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <stdio.h>
6
7static void test_enc(const char *hrp, const char *hex)
8{
9 u8 *val;
10 bool ok;
11 u8 ver;
12 char *out;
13
14 val = tal_hexdata(NULL, hex, strlen(hex));
15 assert(val);
16 out = tal_arr(NULL, char, 73 + strlen(hrp));
17 /* First byte is version */
18 ver = (val[0] == 0 ? 0 : val[0] - 0x50);
19 /* Second byte is OP_PUSH */
20 assert(val[1] == tal_bytelen(val) - 2);
21 ok = segwit_addr_encode(out, hrp, ver, val+2, tal_bytelen(val)-2);
22 assert(ok);
23 printf("%s\n", out);
24}
25
26int main(int argc, char *argv[])
27{

Callers 1

mainFunction · 0.85

Calls 3

tal_hexdataFunction · 0.85
tal_bytelenFunction · 0.85
segwit_addr_encodeFunction · 0.85

Tested by

no test coverage detected