Pages:
Author

Topic: How do you create an altcoin? - page 10. (Read 21870 times)

member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:30:19 PM
More like till an alt-coin dev sees the thread.
I got my fingers crossed a dev runs across it, ill keep checking in
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:28:54 PM
More like till an alt-coin dev sees the thread.
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:27:13 PM
Is this whole thing on hold till we can get someone to help with the genesis block?
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:23:24 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.

It's open source... it may be obscure... but that doesn't mean people don't have a right to know how to do it.
By the end of this thread hopefully we'll all know how it works!   Wink
Yeah, but we likely won't understand the process itself.

We'll figure it out   Grin
I like your positive attitude Cheesy
hero member
Activity: 631
Merit: 501
April 13, 2013, 07:21:50 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.

It's open source... it may be obscure... but that doesn't mean people don't have a right to know how to do it.
By the end of this thread hopefully we'll all know how it works!   Wink
Yeah, but we likely won't understand the process itself.

We'll figure it out   Grin
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:20:48 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.

It's open source... it may be obscure... but that doesn't mean people don't have a right to know how to do it.
By the end of this thread hopefully we'll all know how it works!   Wink
This, I was not expecting this much interest when I started this thread but now myself and im sure a bunch of others really want to know what goes into this
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:19:19 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.

It's open source... it may be obscure... but that doesn't mean people don't have a right to know how to do it.
By the end of this thread hopefully we'll all know how it works!   Wink
Yeah, but we likely won't understand the process itself.
hero member
Activity: 631
Merit: 501
April 13, 2013, 07:17:33 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.

It's open source... it may be obscure... but that doesn't mean people don't have a right to know how to do it.
By the end of this thread hopefully we'll all know how it works!   Wink
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:16:49 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.
But then how did altcoin authors create theirs?  Undecided
They've learned C++ and have no issue with the C++ semantics? Understand Cryptography more than we do?
True, true  Cheesy Tongue
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:15:49 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.
But then how did altcoin authors create theirs?  Undecided
They've learned C++ and have no issue with the C++ semantics? Understand Cryptography more than we do?
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:15:03 PM
Perhaps, but a q on this. Do you really want to create a sha256 alt, or LiteCoin (or better yet PPCoin) type chain instead?  

Really either is fine at this point im just trying to get somthing running
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:13:00 PM
Ive made a discovery... i think??
That's where I derived my information from, by following the functions.
hero member
Activity: 874
Merit: 1000
April 13, 2013, 07:12:19 PM
Perhaps, but a q on this. Do you really want to create a sha256 alt, or LiteCoin (or better yet PPCoin) type chain instead?  
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:12:05 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.
But then how did altcoin authors create theirs?  Undecided
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:11:21 PM
Ive made a discovery... i think??

Starting on line 1,985 of main.cpp

Code:
    //
    // Init with genesis block
    //
    if (mapBlockIndex.empty())
    {
        if (!fAllowNew)
            return false;

        // Genesis Block:
        // CBlock(hash=12a765e31ffd4059bada, PoW=0000050c34a64b415b6b, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=97ddfbbae6, nTime=1317972665, nBits=1e0ffff0, nNonce=2084524493, vtx=1)
        //   CTransaction(hash=97ddfbbae6, ver=1, vin.size=1, vout.size=1, nLockTime=0)
        //     CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536)
        //     CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
        //   vMerkleTree: 97ddfbbae6

        // Genesis block
        const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 50 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = block.BuildMerkleTree();
        block.nVersion = 1;
        block.nTime    = 1317972665;
        block.nBits    = 0x1e0ffff0;
        block.nNonce   = 2084524493;

        if (fTestNet)
        {
            block.nTime    = 1317798646;
            block.nNonce   = 385270584;
        }
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:10:06 PM
If Sunny King can help us, it'd be nice. But I guess the reason the genesis block creation information is not found easily is because every noob(me included) on the block will have an alt-currency out by the end of the day.
member
Activity: 98
Merit: 10
x1 7970 | Aprox. 587 kh/s
April 13, 2013, 07:07:09 PM
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 07:02:26 PM
Ok, so we basically have this

Code:
        const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 50 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = block.BuildMerkleTree();

What we are interested in is, BuildMerkleTree which is found in main.h

Code:
    uint256 BuildMerkleTree() const
    {
        vMerkleTree.clear();
        BOOST_FOREACH(const CTransaction& tx, vtx)
            vMerkleTree.push_back(tx.GetHash());
        int j = 0;
        for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
        {
            for (int i = 0; i < nSize; i += 2)
            {
                int i2 = std::min(i+1, nSize-1);
                vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]),  END(vMerkleTree[j+i]),
                                           BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2])));
            }
            j += nSize;
        }
        return (vMerkleTree.empty() ? 0 : vMerkleTree.back());
    }

Next we are interested in this, I believe.

Code:
vMerkleTree.push_back(tx.GetHash());
since we have only one transaction, this will return as soon as it computes the has. So we see tx.GetHash, and that tx is of type CTransaction, so we head in that class, which is in main.h again

and see this coide

Code:
    uint256 GetHash() const
    {
        return SerializeHash(*this);
    }

which passes the instance of the object to SerializeHash. SerializeHash is located in hash.h

Code:
template
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
{
    CHashWriter ss(nType, nVersion);
    ss << obj;
    return ss.GetHash();
}

Here we see that the object is written(I think, not sure) to ss which is an instance of CHashWriter which is also in main.h and that is where the funky business happens that is uber hard to understand.

But here we go,

Code:
class CHashWriter
{
private:
    SHA256_CTX ctx;

public:
    int nType;
    int nVersion;

    void Init() {
        SHA256_Init(&ctx);
    }

    CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {
        Init();
    }

    CHashWriter& write(const char *pch, size_t size) {
        SHA256_Update(&ctx, pch, size);
        return (*this);
    }

    // invalidates the object
    uint256 GetHash() {
        uint256 hash1;
        SHA256_Final((unsigned char*)&hash1, &ctx);
        uint256 hash2;
        SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
        return hash2;
    }

    template
    CHashWriter& operator<<(const T& obj) {
        // Serialize to this stream
        ::Serialize(*this, obj, nType, nVersion);
        return (*this);
    }
};

CHashWriter, small, but deadly. I guess what we are further interested in, is

Code:
    template
    CHashWriter& operator<<(const T& obj) {
        // Serialize to this stream
        ::Serialize(*this, obj, nType, nVersion);
        return (*this);
    }
which as you calls some global function Serialize that may or may not be located in serialize.h
legendary
Activity: 1316
Merit: 1011
April 13, 2013, 07:00:02 PM
Didn't read all through it yet but maybe this helps? https://bitcointalksearch.org/topic/how-is-the-genesis-block-made-171355
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 13, 2013, 06:57:21 PM
In addition 5th said you need a valid Merkle root... that the one in his code was for illustration.
Someone with experience will need to chime in on that one.
Truth be told I dig deep and deep in Bitcoin's source and it does some kind of serialization of objects and stuff and finally produces a merkle root hash..seriously ridiculously hard to even figure out what the hell happens.

Your post count is 666 and you mentioned hell on your 666 post. :|
OMG! I was just thinking this Cheesy Cheesy Cheesy
LOL, I didn't even notice.
Pages:
Jump to: