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

Function setup_color_and_alias

lightningd/options.c:1309–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1307 "ENTOURAGE", "GENESIS", "WALK", "SPATULA", "RAGE", "FIRE", "MASTER" };
1308
1309void setup_color_and_alias(struct lightningd *ld)
1310{
1311 if (!ld->rgb)
1312 /* You can't get much red by default */
1313 ld->rgb = tal_dup_arr(ld, u8, ld->id.k, 3, 0);
1314
1315 if (!ld->alias) {
1316 u64 adjective, noun;
1317 char *name;
1318
1319 memcpy(&adjective, ld->id.k+3, sizeof(adjective));
1320 memcpy(&noun, ld->id.k+3+sizeof(adjective), sizeof(noun));
1321 noun %= ARRAY_SIZE(codename_noun);
1322 adjective %= ARRAY_SIZE(codename_adjective);
1323
1324 /* Only use 32 characters */
1325 name = tal_fmt(ld, "%s%s",
1326 codename_adjective[adjective],
1327 codename_noun[noun]);
1328#if DEVELOPER
1329 assert(strlen(name) < 32);
1330 int taillen = 31 - strlen(name);
1331 if (taillen > strlen(version()))
1332 taillen = strlen(version());
1333 /* Fit as much of end of version() as possible */
1334 tal_append_fmt(&name, "-%s",
1335 version() + strlen(version()) - taillen);
1336#endif
1337 assert(strlen(name) <= 32);
1338 ld->alias = tal_arrz(ld, u8, 33);
1339 strcpy((char*)ld->alias, name);
1340 tal_free(name);
1341 }
1342}
1343
1344void handle_early_opts(struct lightningd *ld, int argc, char *argv[])
1345{

Callers 1

mainFunction · 0.70

Calls 3

tal_append_fmtFunction · 0.85
tal_freeFunction · 0.85
versionFunction · 0.50

Tested by

no test coverage detected