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

Function rune_to_base64

ccan/ccan/rune/coding.c:377–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377char *rune_to_base64(const tal_t *ctx, const struct rune *rune)
378{
379 u8 hash32[32];
380 char *ret;
381 size_t ret_len;
382 struct wbuf wbuf;
383
384 /* We're going to prepend hash */
385 wbuf.off = sizeof(hash32);
386 wbuf.len = 64;
387 wbuf.buf = tal_arr(NULL, char, wbuf.len);
388
389 to_string(&wbuf, rune, hash32);
390 /* Prepend hash */
391 memcpy(wbuf.buf, hash32, sizeof(hash32));
392
393 ret = tal_arr(ctx, char, base64_encoded_length(wbuf.off) + 1);
394 ret_len = base64_encode_using_maps(&base64_maps_urlsafe,
395 ret, tal_bytelen(ret),
396 wbuf.buf, wbuf.off - 1);
397 ret[ret_len] = '\0';
398 tal_free(wbuf.buf);
399 return ret;
400}
401
402struct rune *rune_from_string(const tal_t *ctx, const char *str)
403{

Callers 3

mainFunction · 0.85
mainFunction · 0.85
reply_with_runeFunction · 0.85

Calls 5

base64_encoded_lengthFunction · 0.85
base64_encode_using_mapsFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
to_stringFunction · 0.70

Tested by 2

mainFunction · 0.68
mainFunction · 0.68