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

Function rune_is_derived_anyversion

ccan/ccan/rune/coding.c:132–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132const char *rune_is_derived_anyversion(const struct rune *source,
133 const struct rune *rune)
134{
135 struct sha256_ctx shactx;
136 size_t i;
137
138 if (tal_count(rune->restrs) < tal_count(source->restrs))
139 return "Fewer restrictions than master";
140
141 /* If we add the same restrictions to source rune, do we match? */
142 shactx = source->shactx;
143 for (i = 0; i < tal_count(rune->restrs); i++) {
144 /* First restrictions must be identical */
145 if (i < tal_count(source->restrs)) {
146 if (!rune_restr_eq(source->restrs[i], rune->restrs[i]))
147 return "Does not match master restrictions";
148 } else
149 rune_sha256_add_restr(&shactx, rune->restrs[i]);
150 }
151
152 if (memcmp(shactx.s, rune->shactx.s, sizeof(shactx.s)) != 0)
153 return "Not derived from master";
154 return NULL;
155}
156
157static bool peek_char(const char *data, size_t len, char *c)
158{

Callers 2

rune_is_derivedFunction · 0.85
mainFunction · 0.85

Calls 2

rune_restr_eqFunction · 0.85
rune_sha256_add_restrFunction · 0.85

Tested by 1

mainFunction · 0.68