diff --git a/SECP256K1.cpp b/SECP256K1.cpp index 1de0400..4d0c76c 100644 --- a/SECP256K1.cpp +++ b/SECP256K1.cpp @@ -427,13 +427,14 @@ void Secp256K1::GetHash160(int type,bool compressed, void Secp256K1::GetHash160(int type, bool compressed, Point &pubKey, unsigned char *hash) { + unsigned char shapk[64]; + switch (type) { case P2PKH: case BECH32: { unsigned char publicKeyBytes[128]; - unsigned char shapk[64]; if (!compressed) { @@ -461,7 +462,6 @@ void Secp256K1::GetHash160(int type, bool compressed, Point &pubKey, unsigned ch // Redeem Script (1 to 1 P2SH) unsigned char script[64]; - unsigned char shapk[64]; script[0] = 0x00; // OP_0 script[1] = 0x14; // PUSH 20 bytes diff --git a/Vanity.cpp b/Vanity.cpp index fdc3bee..5a8a9fa 100644 --- a/Vanity.cpp +++ b/Vanity.cpp @@ -572,6 +572,8 @@ void VanitySearch::updateFound() { // ---------------------------------------------------------------------------- +static int nbFail = 0; + bool VanitySearch::checkPrivKey(string addr, Int &key, int32_t incr, int endomorphism, bool mode) { Int k(&key); @@ -598,19 +600,12 @@ bool VanitySearch::checkPrivKey(string addr, Int &key, int32_t incr, int endomor Point p = secp.ComputePublicKey(&k); string chkAddr = secp.GetAddress(searchType, mode, p); if (chkAddr != addr) { - if (mode) { - // Compressed address (key may be the opposite one) - k.Neg(); - k.Add(&secp.order); - p = secp.ComputePublicKey(&k); - string chkAddr = secp.GetAddress(searchType, mode, p); - if (chkAddr != addr) { - printf("\nWarning, wrong private key generated !\n"); - printf(" Addr :%s\n", addr.c_str()); - printf(" Check:%s\n", chkAddr.c_str()); - return false; - } - } else { + //Key may be the opposite one (negative zero or compressed key) + k.Neg(); + k.Add(&secp.order); + p = secp.ComputePublicKey(&k); + string chkAddr = secp.GetAddress(searchType, mode, p); + if (chkAddr != addr) { printf("\nWarning, wrong private key generated !\n"); printf(" Addr :%s\n", addr.c_str()); printf(" Check:%s\n", chkAddr.c_str());