I'm working on a coin using yescrypt algorithm along the lines of Bitzeny or Yenten. I found this post:
https://bitcointalk.org/index.php?topic=181981.0Which gives a program for generating a genesis block. However it appears that it only works for sha256 coins. What code would I need to change to make this work for my yescrypt coin?
Or would there be a better way?
The debug.log method doesn't work, that only worked with bitcoin code prior to 2014.
Here may be some relevant code in the genesis creator program:
//if(generateBlock)
{
printf("Generating block...\n");
if(!unixtime)
{
unixtime = time(NULL);
}
unsigned char block_header[80], block_hash1[32], block_hash2[32];
uint32_t blockversion = 1;
memcpy(block_header, &blockversion, 4);
memset(block_header+4, 0, 32);
byteswap(transaction->merkleHash, 32); // We swapped it before, so do it again now.
memcpy(block_header+36, transaction->merkleHash, 32);
memcpy(block_header+68, &unixtime, 4);
memcpy(block_header+72, &nBits, 4);
memcpy(block_header+76, &startNonce, 4);
uint32_t *pNonce = (uint32_t *)(block_header + 76);
uint32_t *pUnixtime = (uint32_t *)(block_header + 68);
unsigned int counter, start = time(NULL);
while(1)
{
SHA256(block_header, 80, block_hash1);
SHA256(block_hash1, 32, block_hash2);
unsigned int check = *((uint32_t *)(block_hash2 + 28)); // The hash is in little-endian, so we check the last 4 bytes.
if(check == 0) // \x00\x00\x00\x00
{
byteswap(block_hash2, 32);
char *blockHash = bin2hex(block_hash2, 32);
printf("\nBlock found!\nHash: %s\nNonce: %u\nUnix time: %u", blockHash, startNonce, unixtime);
free(blockHash);
break;
}
startNonce++;
counter+=1;
if(time(NULL)-start >= 1)
{
printf("\r%d Hashes/s, Nonce %u\r", counter, startNonce);
counter = 0;
start = time(NULL);
}
*pNonce = startNonce;
if(startNonce > 4294967294LL)
{
//printf("\nBlock found!\nHash: %s\nNonce: %u\nUnix time: %u", blockHash, startNonce, unixtime);
unixtime++;
*pUnixtime = unixtime;
startNonce = 0;
}
}
}