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

Function from_zbase32

lightningd/signmessage.c:36–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36static const u8 *from_zbase32(const tal_t *ctx, const char *msg)
37{
38 u5 *u5arr;
39 u8 *u8arr;
40 size_t len;
41
42 u5arr = tal_arr(tmpctx, u5, strlen(msg));
43 for (size_t i = 0; i < tal_bytelen(u5arr); i++) {
44 u5arr[i] = zbase32_revchars[(unsigned char)msg[i]];
45 if (u5arr[i] > 31)
46 return NULL;
47 }
48
49 u8arr = tal_arr(ctx, u8, (tal_bytelen(u5arr) * 5 + 7) / 8);
50 len = 0;
51 if (!bech32_convert_bits(u8arr, &len, 8,
52 u5arr, tal_bytelen(u5arr), 5, false))
53 return tal_free(u8arr);
54 return len == tal_bytelen(u8arr) ? u8arr : tal_free(u8arr);
55}
56
57static struct command_result *json_signmessage(struct command *cmd,
58 const char *buffer,

Callers 1

json_checkmessageFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
bech32_convert_bitsFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected