|
|
@ -205,10 +205,12 @@ vg_exec_upgrade_lock(vg_exec_context_t *vxcp) |
|
|
|
void * |
|
|
|
void * |
|
|
|
vg_thread_loop(void *arg) |
|
|
|
vg_thread_loop(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned char eckey_buf[128]; |
|
|
|
unsigned char hash_buf[128]; |
|
|
|
|
|
|
|
unsigned char *eckey_buf; |
|
|
|
unsigned char hash1[32]; |
|
|
|
unsigned char hash1[32]; |
|
|
|
|
|
|
|
|
|
|
|
int i, c, len, output_interval; |
|
|
|
int i, c, len, output_interval; |
|
|
|
|
|
|
|
int hash_len; |
|
|
|
|
|
|
|
|
|
|
|
const BN_ULONG rekey_max = 10000000; |
|
|
|
const BN_ULONG rekey_max = 10000000; |
|
|
|
BN_ULONG npoints, rekey_at, nbatch; |
|
|
|
BN_ULONG npoints, rekey_at, nbatch; |
|
|
@ -264,6 +266,20 @@ vg_thread_loop(void *arg) |
|
|
|
output_interval = 1000; |
|
|
|
output_interval = 1000; |
|
|
|
gettimeofday(&tvstart, NULL); |
|
|
|
gettimeofday(&tvstart, NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vcp->vc_format == VCF_SCRIPT) { |
|
|
|
|
|
|
|
hash_buf[ 0] = 0x51; // OP_1
|
|
|
|
|
|
|
|
hash_buf[ 1] = 0x41; // pubkey length
|
|
|
|
|
|
|
|
// gap for pubkey
|
|
|
|
|
|
|
|
hash_buf[67] = 0x51; // OP_1
|
|
|
|
|
|
|
|
hash_buf[68] = 0xae; // OP_CHECKMULTISIG
|
|
|
|
|
|
|
|
eckey_buf = hash_buf + 2; |
|
|
|
|
|
|
|
hash_len = 69; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
eckey_buf = hash_buf; |
|
|
|
|
|
|
|
hash_len = 65; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (1) { |
|
|
|
while (1) { |
|
|
|
if (++npoints >= rekey_at) { |
|
|
|
if (++npoints >= rekey_at) { |
|
|
|
pthread_mutex_lock(&vg_thread_lock); |
|
|
|
pthread_mutex_lock(&vg_thread_lock); |
|
|
@ -336,10 +352,11 @@ vg_thread_loop(void *arg) |
|
|
|
len = EC_POINT_point2oct(pgroup, ppnt[i], |
|
|
|
len = EC_POINT_point2oct(pgroup, ppnt[i], |
|
|
|
POINT_CONVERSION_UNCOMPRESSED, |
|
|
|
POINT_CONVERSION_UNCOMPRESSED, |
|
|
|
eckey_buf, |
|
|
|
eckey_buf, |
|
|
|
sizeof(eckey_buf), |
|
|
|
65, |
|
|
|
vxcp->vxc_bnctx); |
|
|
|
vxcp->vxc_bnctx); |
|
|
|
|
|
|
|
assert(len == 65); |
|
|
|
|
|
|
|
|
|
|
|
SHA256(eckey_buf, len, hash1); |
|
|
|
SHA256(hash_buf, hash_len, hash1); |
|
|
|
RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]); |
|
|
|
RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]); |
|
|
|
|
|
|
|
|
|
|
|
switch (test_func(vxcp)) { |
|
|
|
switch (test_func(vxcp)) { |
|
|
@ -450,6 +467,7 @@ usage(const char *name) |
|
|
|
"-N Generate namecoin address\n" |
|
|
|
"-N Generate namecoin address\n" |
|
|
|
"-T Generate bitcoin testnet address\n" |
|
|
|
"-T Generate bitcoin testnet address\n" |
|
|
|
"-X <version> Generate address with the given version\n" |
|
|
|
"-X <version> Generate address with the given version\n" |
|
|
|
|
|
|
|
"-F <format> Generate address with the given format (pubkey or script)\n" |
|
|
|
"-e Encrypt private keys, prompt for password\n" |
|
|
|
"-e Encrypt private keys, prompt for password\n" |
|
|
|
"-E <password> Encrypt private keys with <password> (UNSAFE)\n" |
|
|
|
"-E <password> Encrypt private keys with <password> (UNSAFE)\n" |
|
|
|
"-t <threads> Set number of worker threads (Default: number of CPUs)\n" |
|
|
|
"-t <threads> Set number of worker threads (Default: number of CPUs)\n" |
|
|
@ -464,7 +482,10 @@ int |
|
|
|
main(int argc, char **argv) |
|
|
|
main(int argc, char **argv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int addrtype = 0; |
|
|
|
int addrtype = 0; |
|
|
|
|
|
|
|
int scriptaddrtype = 5; |
|
|
|
int privtype = 128; |
|
|
|
int privtype = 128; |
|
|
|
|
|
|
|
int pubkeytype; |
|
|
|
|
|
|
|
enum vg_format format = VCF_PUBKEY; |
|
|
|
int regex = 0; |
|
|
|
int regex = 0; |
|
|
|
int caseinsensitive = 0; |
|
|
|
int caseinsensitive = 0; |
|
|
|
int verbose = 1; |
|
|
|
int verbose = 1; |
|
|
@ -481,7 +502,7 @@ main(int argc, char **argv) |
|
|
|
int nthreads = 0; |
|
|
|
int nthreads = 0; |
|
|
|
vg_context_t *vcp = NULL; |
|
|
|
vg_context_t *vcp = NULL; |
|
|
|
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "vqrikeE:NTX:t:h?f:o:s:")) != -1) { |
|
|
|
while ((opt = getopt(argc, argv, "vqrikeE:NTXF:t:h?f:o:s:")) != -1) { |
|
|
|
switch (opt) { |
|
|
|
switch (opt) { |
|
|
|
case 'v': |
|
|
|
case 'v': |
|
|
|
verbose = 2; |
|
|
|
verbose = 2; |
|
|
@ -501,14 +522,28 @@ main(int argc, char **argv) |
|
|
|
case 'N': |
|
|
|
case 'N': |
|
|
|
addrtype = 52; |
|
|
|
addrtype = 52; |
|
|
|
privtype = 180; |
|
|
|
privtype = 180; |
|
|
|
|
|
|
|
scriptaddrtype = -1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'T': |
|
|
|
case 'T': |
|
|
|
addrtype = 111; |
|
|
|
addrtype = 111; |
|
|
|
privtype = 239; |
|
|
|
privtype = 239; |
|
|
|
|
|
|
|
scriptaddrtype = 196; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'X': |
|
|
|
case 'X': |
|
|
|
addrtype = atoi(optarg); |
|
|
|
addrtype = atoi(optarg); |
|
|
|
privtype = 128 + addrtype; |
|
|
|
privtype = 128 + addrtype; |
|
|
|
|
|
|
|
scriptaddrtype = addrtype; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'F': |
|
|
|
|
|
|
|
if (!strcmp(optarg, "script")) |
|
|
|
|
|
|
|
format = VCF_SCRIPT; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
if (strcmp(optarg, "pubkey")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, |
|
|
|
|
|
|
|
"Invalid format '%s'\n", optarg); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'e': |
|
|
|
case 'e': |
|
|
|
prompt_password = 1; |
|
|
|
prompt_password = 1; |
|
|
@ -578,6 +613,18 @@ main(int argc, char **argv) |
|
|
|
"WARNING: case insensitive mode incompatible with " |
|
|
|
"WARNING: case insensitive mode incompatible with " |
|
|
|
"regular expressions\n"); |
|
|
|
"regular expressions\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pubkeytype = addrtype; |
|
|
|
|
|
|
|
if (format == VCF_SCRIPT) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (scriptaddrtype == -1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, |
|
|
|
|
|
|
|
"Address type incompatible with script format\n"); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
addrtype = scriptaddrtype; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (seedfile) { |
|
|
|
if (seedfile) { |
|
|
|
opt = -1; |
|
|
|
opt = -1; |
|
|
|
#if !defined(_WIN32) |
|
|
|
#if !defined(_WIN32) |
|
|
@ -626,6 +673,8 @@ main(int argc, char **argv) |
|
|
|
vcp->vc_verbose = verbose; |
|
|
|
vcp->vc_verbose = verbose; |
|
|
|
vcp->vc_result_file = result_file; |
|
|
|
vcp->vc_result_file = result_file; |
|
|
|
vcp->vc_remove_on_match = remove_on_match; |
|
|
|
vcp->vc_remove_on_match = remove_on_match; |
|
|
|
|
|
|
|
vcp->vc_format = format; |
|
|
|
|
|
|
|
vcp->vc_pubkeytype = pubkeytype; |
|
|
|
|
|
|
|
|
|
|
|
if (!vg_context_add_patterns(vcp, patterns, npatterns)) |
|
|
|
if (!vg_context_add_patterns(vcp, patterns, npatterns)) |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|