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

Function to_bech32_charset

common/bech32_util.c:108–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108char *to_bech32_charset(const tal_t *ctx,
109 const char *hrp, const u8 *data)
110{
111 u5 *u5data = tal_arr(NULL, u5, 0);
112 char *ret;
113
114 bech32_push_bits(&u5data, data, tal_bytelen(data) * 8);
115 ret = tal_dup_arr(ctx, char, hrp, strlen(hrp),
116 1 + tal_bytelen(u5data) + 1);
117 ret[strlen(hrp)] = '1';
118 for (size_t i = 0; i < tal_bytelen(u5data); i++)
119 ret[strlen(hrp) + 1 + i] = bech32_charset[u5data[i]];
120 ret[strlen(hrp) + 1 + tal_bytelen(u5data)] = '\0';
121 tal_free(u5data);
122 return ret;
123}

Callers 4

offer_encodeFunction · 0.70
invrequest_encodeFunction · 0.70
invoice_encodeFunction · 0.70
mainFunction · 0.50

Calls 3

bech32_push_bitsFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected