mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-21 05:53:09 +00:00
Hack in zerotier-idtool to allow generation of vanity addresses.
This commit is contained in:
parent
0bcc7d46a3
commit
68d950c344
22
one.cpp
22
one.cpp
@ -571,7 +571,7 @@ static void idtoolPrintHelp(FILE *out,const char *pn)
|
|||||||
COPYRIGHT_NOTICE ZT_EOL_S
|
COPYRIGHT_NOTICE ZT_EOL_S
|
||||||
LICENSE_GRANT ZT_EOL_S);
|
LICENSE_GRANT ZT_EOL_S);
|
||||||
fprintf(out,"Usage: %s <command> [<args>]"ZT_EOL_S""ZT_EOL_S"Commands:"ZT_EOL_S,pn);
|
fprintf(out,"Usage: %s <command> [<args>]"ZT_EOL_S""ZT_EOL_S"Commands:"ZT_EOL_S,pn);
|
||||||
fprintf(out," generate [<identity.secret>] [<identity.public>]"ZT_EOL_S);
|
fprintf(out," generate [<identity.secret>] [<identity.public>] [<vanity>]"ZT_EOL_S);
|
||||||
fprintf(out," validate <identity.secret/public>"ZT_EOL_S);
|
fprintf(out," validate <identity.secret/public>"ZT_EOL_S);
|
||||||
fprintf(out," getpublic <identity.secret>"ZT_EOL_S);
|
fprintf(out," getpublic <identity.secret>"ZT_EOL_S);
|
||||||
fprintf(out," sign <identity.secret> <file>"ZT_EOL_S);
|
fprintf(out," sign <identity.secret> <file>"ZT_EOL_S);
|
||||||
@ -607,8 +607,28 @@ static int idtool(int argc,char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1],"generate")) {
|
if (!strcmp(argv[1],"generate")) {
|
||||||
|
uint64_t vanity = 0;
|
||||||
|
int vanityBits = 0;
|
||||||
|
if (argc >= 5) {
|
||||||
|
vanity = Utils::hexStrToU64(argv[4]) & 0xffffffffffULL;
|
||||||
|
vanityBits = 4 * strlen(argv[4]);
|
||||||
|
if (vanityBits > 40)
|
||||||
|
vanityBits = 40;
|
||||||
|
}
|
||||||
|
|
||||||
Identity id;
|
Identity id;
|
||||||
|
for(;;) {
|
||||||
id.generate();
|
id.generate();
|
||||||
|
if ((id.address().toInt() >> (40 - vanityBits)) == vanity) {
|
||||||
|
if (vanityBits > 0) {
|
||||||
|
fprintf(stderr,"vanity address: found %.10llx !\n",(unsigned long long)id.address().toInt());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,"vanity address: tried %.10llx looking for first %d bits of %.10llx\n",(unsigned long long)id.address().toInt(),vanityBits,(unsigned long long)(vanity << (40 - vanityBits)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string idser = id.toString(true);
|
std::string idser = id.toString(true);
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
if (!OSUtils::writeFile(argv[2],idser)) {
|
if (!OSUtils::writeFile(argv[2],idser)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user