Skip to content

Commit

Permalink
lightningd: append (as much as we can) version into default name if D…
Browse files Browse the repository at this point in the history
…EVELOPER=1

This helps for bug reporting, where we may need to diagnose the other
end.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Feb 22, 2018
1 parent 655ae90 commit 85f1a9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 18 additions & 4 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,16 +608,30 @@ void setup_color_and_alias(struct lightningd *ld)

if (!ld->alias) {
u64 adjective, noun;
char *name;

memcpy(&adjective, der+3, sizeof(adjective));
memcpy(&noun, der+3+sizeof(adjective), sizeof(noun));
noun %= ARRAY_SIZE(codename_noun);
adjective %= ARRAY_SIZE(codename_adjective);

/* Only use 32 characters */
name = tal_fmt(ld, "%s%s-",
codename_adjective[adjective],
codename_noun[noun]);
#if DEVELOPER
assert(strlen(name) < 32);
int taillen = 32 - strlen(name);
if (taillen > strlen(version()))
taillen = strlen(version());
/* Fit as much of end of version() as possible */
tal_append_fmt(&name, "%s",
version() + strlen(version()) - taillen);
#endif
assert(strlen(name) <= 32);
ld->alias = tal_arrz(ld, u8, 33);
assert(strlen(codename_adjective[adjective])
+ strlen(codename_noun[noun]) < 33);
strcpy((char*)ld->alias, codename_adjective[adjective]);
strcat((char*)ld->alias, codename_noun[noun]);
strcpy((char*)ld->alias, name);
tal_free(name);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,13 +1763,13 @@ def test_gossip_jsonrpc(self):
# Might not have seen other node-announce yet.
# TODO(cdecker) Can't check these without DEVELOPER=1, re-enable after we get alias and color into getinfo
if DEVELOPER:
assert n1['alias'] == 'JUNIORBEAM'
assert n1['alias'].startswith('JUNIORBEAM')
assert n1['color'] == '0266e4'
if 'alias' not in n2:
assert 'color' not in n2
assert 'addresses' not in n2
else:
assert n2['alias'] == 'SILENTARTIST'
assert n2['alias'].startswith('SILENTARTIST')
assert n2['color'] == '022d22'

assert [c['active'] for c in l1.rpc.listchannels()['channels']] == [True, True]
Expand Down

0 comments on commit 85f1a9b

Please sign in to comment.