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

Function from_string

ccan/ccan/rune/coding.c:280–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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