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

Function from_string

ccan/ccan/rune/coding.c:281–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281static struct rune *from_string(const tal_t *ctx,
282 const char *str,
283 const u8 *hash32)
284{
285 size_t len = strlen(str);
286 struct rune *rune = tal(ctx, struct rune);
287
288 /* Now count up how many bytes we should have hashed: secret uses
289 * first block. */
290 rune->shactx.bytes = 64;
291
292 rune->restrs = tal_arr(rune, struct rune_restr *, 0);
293 rune->unique_id = NULL;
294 rune->version = NULL;
295
296 while (len) {
297 struct rune_restr *restr;
298 restr = rune_restr_decode(rune, &str, &len);
299 if (!restr)
300 return tal_free(rune);
301 if (!rune_add_restr(rune, restr))
302 return tal_free(rune);
303 }
304
305 /* Now we replace with canned hash state */
306 memcpy(rune->shactx.s, hash32, 32);
307 for (size_t i = 0; i < 8; i++)
308 rune->shactx.s[i] = be32_to_cpu(rune->shactx.s[i]);
309
310 return rune;
311}
312
313struct rune_restr *rune_restr_from_string(const tal_t *ctx,
314 const char *str,

Callers 2

rune_from_base64nFunction · 0.85
rune_from_stringFunction · 0.85

Calls 4

rune_restr_decodeFunction · 0.85
tal_freeFunction · 0.85
rune_add_restrFunction · 0.85
be32_to_cpuFunction · 0.85

Tested by

no test coverage detected