Bitcoin Forum
November 14, 2024, 02:00:42 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Anyone have a blank template for sha-256 main.cpp to test?  (Read 1571 times)
mistercoin (OP)
Legendary
*
Offline Offline

Activity: 1051
Merit: 1000


https://r.honeygain.me/XEDDM2B07C


View Profile WWW
July 15, 2013, 08:50:15 PM
 #1

I want to make a coin that I can play around with on my own vps's and pc, not to distribute to anybody but myself.

Now that that's out of the way. I want to make it SHA256 instead of scrypt. I am interested in the concept of cryptography and I am having trouble finding an SHA-256 Main.cpp that doesnt already have the genesis block mined, so the arguments are not there. For scrypt getting the genisis block down is as follows:

Code:
 //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x"));

        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)
        {
            printf("Searching for genesis block...\n");
            // This will figure out a valid hash and Nonce if you're
            // creating a different genesis block:
            uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
            uint256 thash;
            char scratchpad[SCRYPT_SCRATCHPAD_SIZE];

            loop
            {
                scrypt_1024_1_1_256_sp(BEGIN(block.nVersion), BEGIN(thash), scratchpad);
                if (thash <= hashTarget)
                    break;
                if ((block.nNonce & 0xFFF) == 0)
                {
                    printf("nonce %08X: hash = %s (target = %s)\n", block.nNonce, thash.ToString().c_str(), hashTarget.ToString().c_str());
                }
                ++block.nNonce;
                if (block.nNonce == 0)
                {
                    printf("NONCE WRAPPED, incrementing time\n");
                    ++block.nTime;
                }
            }
            printf("block.nTime = %u \n", block.nTime);
            printf("block.nNonce = %u \n", block.nNonce);
            printf("block.GetHash = %s\n", block.GetHash().ToString().c_str());
        }

        block.print();
        assert(block.GetHash() == hashGenesisBlock);

        // Start new block file
        unsigned int nFile;
        unsigned int nBlockPos;
        if (!block.WriteToDisk(nFile, nBlockPos))
            return error("LoadBlockIndex() : writing genesis block to disk failed");
        if (!block.AddToBlockIndex(nFile, nBlockPos))
            return error("LoadBlockIndex() : genesis block not accepted");
    }

    return true;
}



void PrintBlockTree()
{

But every SHA256 coin I see already has it's Genesis block mined and has only this type of code, and varies from currency to currency:

Code:
//// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x3c2d8f85fab4d17aac558cc648a1a58acff0de6deb890c29985690052c5993c2"));
        block.print();
        assert(block.GetHash() == hashGenesisBlock);
        assert(block.CheckBlock());

        // Start new block file
        unsigned int nFile;
        unsigned int nBlockPos;
        if (!block.WriteToDisk(nFile, nBlockPos))
            return error("LoadBlockIndex() : writing genesis block to disk failed");
        if (!block.AddToBlockIndex(nFile, nBlockPos))
            return error("LoadBlockIndex() : genesis block not accepted");

        // ppcoin: initialize synchronized checkpoint
        if (!Checkpoints::WriteSyncCheckpoint(hashGenesisBlock))
            return error("LoadBlockIndex() : failed to init sync checkpoint");
    }

    // ppcoin: if checkpoint master key changed must reset sync-checkpoint
    {
        CTxDB txdb;
        string strPubKey = "";
        if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::strMasterPubKey)
        {
            // write checkpoint master key to db
            txdb.TxnBegin();
            if (!txdb.WriteCheckpointPubKey(CSyncCheckpoint::strMasterPubKey))
                return error("LoadBlockIndex() : failed to write new checkpoint master key to db");
            if (!txdb.TxnCommit())
                return error("LoadBlockIndex() : failed to commit new checkpoint master key to db");
            if ((!fTestNet) && !Checkpoints::ResetSyncCheckpoint())
                return error("LoadBlockIndex() : failed to reset sync-checkpoint");
        }
        txdb.Close();
    }

    return true;
}



void PrintBlockTree()

I repeat, that this is PURELY for my own purposes in tests and my own knowledge and understanding of how cryptocurrency works. I will not be releasing anything from this.

If you don't have anything useful to add to this thread, please save your time. But if you want to contribute, please do..

Mcoin--

markm
Legendary
*
Offline Offline

Activity: 3010
Merit: 1121



View Profile WWW
July 15, 2013, 09:06:20 PM
 #2

Old code used to have something like that, all the UKB, CDN, mBC, GMC, GRF, NKL etc currencies all had that, as that was how I found their genesis blocks, I'd start it up, leave if overnight or a few days or whatever it took, eventually it would tell me what the actual new genesis block hash and such were in the log as it bombed from the hard coded expected value at top of file not matching the newly made block.

Then I'd take the actual value shown in the log plug it in as expected value to check for and presto, ready to run.

Maybe look at multicoin, maybe I took that code from there?

Does groupcoin have it? If not how would I have made its genesis block?

In general how are people making genesis blocks for SHA256 coins without some such code that tells them in the log both the actual value and the expected value when its check that those values match fails?

Maybe some of them hack back out that loop once they have their new genesis block?

-MarkM-


Browser-launched Crossfire client now online (select CrossCiv server for Galactic  Milieu)
Free website hosting with PHP, MySQL etc: http://hosting.knotwork.com/
mistercoin (OP)
Legendary
*
Offline Offline

Activity: 1051
Merit: 1000


https://r.honeygain.me/XEDDM2B07C


View Profile WWW
July 15, 2013, 09:31:31 PM
 #3

Old code used to have something like that, all the UKB, CDN, mBC, GMC, GRF, NKL etc currencies all had that, as that was how I found their genesis blocks, I'd start it up, leave if overnight or a few days or whatever it took, eventually it would tell me what the actual new genesis block hash and such were in the log as it bombed from the hard coded expected value at top of file not matching the newly made block.

Then I'd take the actual value shown in the log plug it in as expected value to check for and presto, ready to run.

Maybe look at multicoin, maybe I took that code from there?

Does groupcoin have it? If not how would I have made its genesis block?

In general how are people making genesis blocks for SHA256 coins without some such code that tells them in the log both the actual value and the expected value when its check that those values match fails?

Maybe some of them hack back out that loop once they have their new genesis block?

-MarkM-



Hmm, ill check out groupcoin. Seems to be a hard one to find, iv'e looked everywhere. :S

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!