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

Function rune_from_base64n

ccan/ccan/rune/coding.c:341–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341struct rune *rune_from_base64n(const tal_t *ctx, const char *str, size_t len)
342{
343 size_t blen;
344 u8 *data;
345 struct rune *rune;
346
347 data = tal_arr(NULL, u8, base64_decoded_length(len) + 1);
348
349 blen = base64_decode_using_maps(&base64_maps_urlsafe,
350 (char *)data, tal_bytelen(data),
351 str, len);
352 if (blen == -1)
353 goto fail;
354
355 if (blen < 32)
356 goto fail;
357
358 data[blen] = '\0';
359 /* Sanity check that it's a valid string! */
360 if (strlen((char *)data + 32) != blen - 32)
361 goto fail;
362
363 rune = from_string(ctx, (const char *)data + 32, data);
364 tal_free(data);
365 return rune;
366
367fail:
368 tal_free(data);
369 return NULL;
370}
371
372struct rune *rune_from_base64(const tal_t *ctx, const char *str)
373{

Callers 4

rune_from_base64Function · 0.85
check_runeFunction · 0.85
param_runeFunction · 0.85
param_decodableFunction · 0.85

Calls 5

base64_decoded_lengthFunction · 0.85
base64_decode_using_mapsFunction · 0.85
tal_bytelenFunction · 0.85
from_stringFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected