Pages:
Author

Topic: More Genesis Block Discussion - page 5. (Read 33918 times)

member
Activity: 87
Merit: 10
May 16, 2013, 04:50:13 PM
#27
Okay So I know this thread is a bit old but I need some help. I tried the steps to get the genesis block (Change nonce to 0 and change "if (false && block.GetHash()" to "if (true && block.GetHash()") I did all that and compiled it and it ran for about half an hour before displaying this error: "litecoind: main.cpp:2061: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed." Also tried with SmallChange and got the same result.

Any idea how I could fix this? 
sr. member
Activity: 308
Merit: 250
May 09, 2013, 08:23:36 PM
#26
OK, scratch that. Now I have mined a Genesis block, set up some .conf info--how do I mine my new coin? Everything I get from ./coinname getinfo looks right, but I get error 500 when trying to connect minerd...

Whats the next step?
sr. member
Activity: 308
Merit: 250
May 09, 2013, 07:08:02 PM
#25


after a long time you get...


How long? What kind of processing power?
legendary
Activity: 934
Merit: 1000
May 07, 2013, 07:04:47 AM
#24
Doesn't mean I'm not liking this thread ....  Smiley
Tongue good! In the meanwhile I'm getting the hang of it.. The thing that I have the most problems with is the language itself.. Never did anything with c++.. It's not too hard, but you have to get to know the syntax and variable definitions..
legendary
Activity: 3920
Merit: 2349
Eadem mutata resurgo
May 07, 2013, 06:56:03 AM
#23
Doesn't mean I'm not liking this thread ....  Smiley
legendary
Activity: 934
Merit: 1000
May 06, 2013, 08:05:58 AM
#22
OK Think I found the answer.. Gavin if you could confirm I understand it that would be very nice Cheesy

The key used in the source at
Code:
txNew.vout[0].scriptPubKey 

Is the public ECDSA key for that address right?

To answer yet again my own question: It is... And the steps I provided are correct..

Below a simple python script to generate the WIF and Wallet address (courtesy of a number of ppl on the forum)
Code:
import hashlib, binascii

t='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

def numtowif(numpriv):
 # for bitcoin (80=128)
 # for testcoin (EF==239 == testnet)
 step1 = 'EF'+hex(numpriv)[2:].strip('L').zfill(64)
 step2 = hashlib.sha256(binascii.unhexlify(step1)).hexdigest()
 step3 = hashlib.sha256(binascii.unhexlify(step2)).hexdigest()
 step4 = int(step1 + step3[:8] , 16)
 return ''.join([t[step4/(58**l)%58] for l in range(100)])[::-1].lstrip('1')

def wiftonum(wifpriv):
 return sum([t.index(wifpriv[::-1][l])*(58**l) for l in range(len(wifpriv))])/(2**32)%(2**256)

def validwif(wifpriv):
 return numtowif(wiftonum(wifpriv))==wifpriv

def pubtoaddr(numpub):
 pubkey1=hex(numpub)[2:].strip('L').zfill(130)
 #print pubkey1
 pubkey2=hashlib.sha256(binascii.unhexlify(pubkey1)).hexdigest()
 #print pubkey2
 pubkey3=hashlib.new('ripemd160',binascii.unhexlify(pubkey2)).hexdigest()
 #print pubkey3
 # for bitcoin (0)
 #pubkey3b='00'+pubkey3
 # for testcoin (111)
 pubkey3b='6f'+pubkey3
 #print pubkey3b
 pubkey4=hashlib.sha256(binascii.unhexlify(pubkey3b)).hexdigest()
 #pubkey4=hashlib.sha256(binascii.unhexlify(pubkey3b)).hexdigest()
 #print pubkey4
 pubkey5=hashlib.sha256(binascii.unhexlify(pubkey4)).hexdigest()
 #print pubkey5
 pubkey5a=pubkey5[:8]
 #print pubkey5a
 pubkey6=pubkey3b+pubkey5a
 #print pubkey6
 #print pubkey6[:2]
 pubnum=int(pubkey6,16)
 #print pubnum
 pubnumlist=[]
 while pubnum!=0: pubnumlist.append(pubnum%58); pubnum/=58
 address=''
 for l in ['123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'[x] for x in pubnumlist]:
  address=l+address
 if pubkey6[:2]=='00':
  address='1'+address
 return address

print "wallet import format"
print numtowif(0x5e4a8229e81a434b0646dcdbeb4b03083e2bd05af26fcf2e4e4aa37eacb2913b)
print "wallet public address"
print pubtoaddr(0x04580e17442b4465fbf1eb8a039855343739f69f83222c3c6590c219dcd2d883bff96ebf6198ddb9a75baffffbc1be62f05261d7dfec58d8a06cf3809c6cefe620)

Might have to be adapted a bit for your purpose depending on what's in base58.cpp

Also a nice script to generate ECDSA keypairs (for testing purposes only!)

Code:
#!/usr/bin/env python
"""
Generate an ECDSA keypair and Bitcoin-compatible payment address.
Requires Brian Warner's excellent python-ecdsa library.


http://github.com/aristus/bitcoin-printer
"""
from ecdsa.ecdsa import Public_key, int_to_string
from ecdsa.ellipticcurve import CurveFp, Point
from binascii import hexlify
import hashlib
ripehash = hashlib.new('ripemd160')


# ***WARNING*** This is possibly insecure! ***WARNING***
from random import SystemRandom
randrange = SystemRandom().randrange


## Bitcoin has an adorable encoding scheme that includes numbers and letters
## but excludes letters which look like numbers, eg "l" and "O"
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)
def b58encode(v):
  long_value = 0L
  for (i, c) in enumerate(v[::-1]):
    long_value += (256**i) * ord(c)
  result = ''
  while long_value >= __b58base:
    div, mod = divmod(long_value, __b58base)
    result = __b58chars[mod] + result
    long_value = div
  result = __b58chars[long_value] + result
  nPad = 0
  for c in v:
    if c == '\0': nPad += 1
    else: break
  return (__b58chars[0]*nPad) + result

def generate_btc_address():
    # secp256k1, not included in stock ecdsa
    _p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2FL
    _r = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L
    _b = 0x0000000000000000000000000000000000000000000000000000000000000007L
    _a = 0x0000000000000000000000000000000000000000000000000000000000000000L
    _Gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798L
    _Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L
    curve_256 = CurveFp(_p, _a, _b)
    generator = Point(curve_256, _Gx, _Gy, _r)

    secret = randrange(1, generator.order())
    pubkey = Public_key(generator, generator * secret)
    step1 = '\x04' + int_to_string(pubkey.point.x()) + \
        int_to_string(pubkey.point.y())
    step2 = hashlib.sha256(step1).digest()
    ripehash.update(step2)
    step4 = '\x00' + ripehash.digest()
    step5 = hashlib.sha256(step4).digest()
    step6 = hashlib.sha256(step5).digest()
    chksum = step6[:4]
    addr = step4 + chksum
    addr_58 = b58encode(addr)
    return (
        hex(secret)[2:-1],
        hexlify(step1),
        hexlify(addr),
        addr_58
    )


if __name__ == '__main__':
    secret, pubkey, addr, addr_58 = generate_btc_address()
    print 'secret: ', secret
    print 'pubkey: ', pubkey
    print 'address:', addr
    print 'addr_58:', addr_58

legendary
Activity: 934
Merit: 1000
May 06, 2013, 07:59:27 AM
#21
I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...

So what then? I thought this forum was meant for people to ask questions, apparently I was wrong in that assumption. I'm trying to understand how it all works. Best way for me to learn is to actually do stuff (If you ever developed anything you'd know you don't learn that from books ;-)).

I just checked somethings.. the last two altcoins were created by peopl with less than 20 posts on this forum.. Does that mean they are geniusses? I'd rather put my trust in someone that asks things if he's not sure, than in someone who doesnt..

As for that matter, let's say I am developing an altcoin to be released, wouldn't you rather have it released by someone who's been asking around?

So far I managed to do almost everything without asking for help, but even that one question I asked is still unanswered on the forum..
member
Activity: 84
Merit: 10
May 06, 2013, 07:09:08 AM
#20
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...

I get that but who said I'm trying to compete with bitcoin, as I've said before I'm doing this to learn more about bitcoin and also to commemorate f.a. Hayek.
legendary
Activity: 3920
Merit: 2349
Eadem mutata resurgo
May 06, 2013, 12:30:36 AM
#19
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I agree, I was thinking this also .... people are free to experiment but who would want to put trust in a blockchain that was began by someone who was not yet fully competent to create their own genesis block is probably the free market answer ...
legendary
Activity: 934
Merit: 1000
May 05, 2013, 02:54:19 PM
#18
OK Think I found the answer.. Gavin if you could confirm I understand it that would be very nice Cheesy

The key used in the source at
Code:
txNew.vout[0].scriptPubKey 

Is the public ECDSA key for that address right?

So all you have to do is create a public/private ECDSA keypair and convert the public key to an address using:
Version = 1 byte of 0 (zero); on the test network, this is 1 byte of 111 // Or whatever is set in base58.h
Key hash = Version concatenated with RIPEMD-160(SHA-256(public key))
Checksum = 1st 4 bytes of SHA-256(SHA-256(Key hash))
Xxxcoin Address = Base58Encode(Key hash concatenated with Checksum)

To import the private key in my new wallet I would have to follow these steps:
Code:
1 - Take a private key 
   0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
2 - Add a 0x80 byte in front of it
   800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
3 - Perform SHA-256 hash on the extended key
   8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592
4 - Perform SHA-256 hash on result of SHA-256 hash
   507A5B8DFED0FC6FE8801743720CEDEC06AA5C6FCA72B07C49964492FB98A714
5 - Take the first 4 bytes of the second SHA-256 hash, this is the checksum
   507A5B8D
6 - Add the 4 checksum bytes from point 5 at the end of the extended key from point 2
   800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D
7 - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the Wallet Import Format
   5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ

Does that sum it up?

Thanks
legendary
Activity: 934
Merit: 1000
May 05, 2013, 01:35:42 PM
#17
Gavin, you can probably a question i'm having.. I "mined" the genesis block, and it shows op in the daemon when I query it with getblockhash 0. I also see that it contains exactly 1 transaction like it's supposed to.

 What I don't get is that "mining" (generating sounds better) the genesis block happens before you actually create a wallet so that one transaction is not "in" my wallet.

 I assume this is caused by the txNew lines in LoadBlockIndex:

Code:
        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;

This was changes in the Smallchange code to:
Code:
        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 = 0;
        txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG; // a privkey for that 'vanity' pubkey would be interesting ;)

I'm assuming that this code creates a transaction from the genesis block to a wallet address. In Litecoin this is
Code:
CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;

In SmallChange this is changed to 0x0 but that doesn't matter because the value is 0 anyway.

I copied that smallchange code however and changed the value to 10.

Now when I look at the genesis block I get:
Code:
    "tx" : [
        "d966cccce1ccfab008bac6ab9ef6c4c223b77847fb6924d837639997ef21d29f"
    ],
even though the transaction failed in the generation:
Code:
hashMerkleRoot=d966cccce1, nTime=1367758074, nBits=1e0ffff0, nNonce=924421, vtx=1)
  CTransaction(hash=d966cccce1, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043d6e7974696d657320352d35204f66662d7468652d43756666204f62616d61204c696e652050757420552e532e20696e2042696e64206f6e205379726961)
    CTxOut(error)

when I try to read the transaction i get
Code:
error: {"code":-5,"message":"No information available about transaction"}

Now for the question...

How can I populate this line
Code:
txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG;

If I don't have a wallet yet? Or do you simply create the wallet first, retrieve the address and start again?

Thanks

member
Activity: 84
Merit: 10
May 05, 2013, 12:53:03 PM
#16
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.


I'm trying to learn been studying furiously
legendary
Activity: 1652
Merit: 2300
Chief Scientist
May 05, 2013, 12:31:40 PM
#15
lightenup gave me this advice for generating a genesis block:

Awww, that is cheating!

You really have no business creating your own block chain if you don't understand the code well enough to figure out how to mine a new genesis block without somebody else's help.
member
Activity: 84
Merit: 10
May 05, 2013, 12:23:44 PM
#14
In command line..

Don't really think it matters much, as long as you delete ur wallet u should be able to start over again any time. However you can tweak the test setting  for testimg purposes (see what difficulty does etc..).

I'm now mining my own coin :-p

However i haven't actually found the genesis block. I expected it to be in my wallet with a transaction, but it isn't..

From what I read I think some will create a script that automatically mines the genesis block to save time, otherwise I guess it takes awhile, I guess for Saotoshi it took 6 days

Keep me updated on your progress in this thread!

What's the name of your coin?
legendary
Activity: 934
Merit: 1000
May 05, 2013, 11:11:24 AM
#13
In command line..

Don't really think it matters much, as long as you delete ur wallet u should be able to start over again any time. However you can tweak the test setting  for testimg purposes (see what difficulty does etc..).

I'm now mining my own coin :-p

However i haven't actually found the genesis block. I expected it to be in my wallet with a transaction, but it isn't..
member
Activity: 84
Merit: 10
May 05, 2013, 10:25:13 AM
#12
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
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("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!



nice, where am I putting -testnet -noirc, is that in command line or make file?
legendary
Activity: 934
Merit: 1000
May 05, 2013, 08:35:38 AM
#11
What I did so far:

Change pszTimestamp to a sentence from newspaper
change block.nTime to current time

compile

run compiled source with -testnet -noirc

now u see some lines and a crash
Code:
b115383690ee67ebeef9a7e754342638cd7bbf488561998e6d1bc1ed367484f6 // Block derived from pszTimestamp
b8fa883689f099d3942ff73439d9f55d60a5e257b0d69a8f0f6ab4572ecff415 // Genesisblock (invalid cuz its already coded wrong)
bd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9 // MerkleRoot (Valid because its newly calculated

corresponding to code:
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("0xbd58bf217abb76059de07dc519f6c3dcdf5b1a7bb9219a66d24205e08f3716f9"));

update main.cpp with the mentioned merkleroot (it crashed because of the last assert) and run again

you should have already changed the false to true in
Code:
        // If genesis block hash does not match, then generate new genesis hash.
        if (true && block.GetHash() != hashGenesisBlock)

so it will find a genesis block for your string

after a long time you get:
Code:
nonce 003C1000: hash = e8525d8ae8a74a33dbc4b06a64c97ced84dfd29628b3e9e4197c7030cc4a09d3 (target = 00000ffff0000000000000000000000000000000000000000000000000000000)
block.nTime = 1367704866
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33
CBlock(hash=fafdbfc957ea6867a074, PoW=000000b1398554a520b5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=bd58bf217a, nTime=1367704866, nBits=1e0ffff0, nNonce=3939341, vtx=1)
  CTransaction(hash=bd58bf217a, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01043741442e6e6c20342f352042657672696a64696e6773646167207a6f6e6e69672c20646161726e61206f6f6b207a6f6d657273207761726d)
    CTxOut(error)
  vMerkleTree: bd58bf217a
xx: main.cpp:2070: bool LoadBlockIndex(bool): Assertion `block.GetHash() == hashGenesisBlock' failed.
Aborted (core dumped)

Now you have the valid Genesisblock and nNonce:
block.nNonce = 3939341
block.GetHash = fafdbfc957ea6867a0743ff80c4ae126c7dd9fa82057255228a4d58f6ccfdf33

Update your code with these values and your ready to go!

member
Activity: 84
Merit: 10
May 03, 2013, 08:29:47 AM
#10
lightenup gave me this advice for generating a genesis block:

Quote
Well, change something in the genesis block data and observe the assertion when you start the node software.

For actual genesis block generation look at what happens after the assertion in the code:
Code:

       assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));

        // If genesis block hash does not match, then generate new genesis hash.
        if (false && block.GetHash() != hashGenesisBlock)
        {


So you'd need to change this if(false && ... ) to if (true && ...) s.t. the node software tries to find the genesis hash.


Concerning your previous question: you need to lookup base58. It appears that the letter S is encoded as 62 and s (smaller case S) is 63, 64 would be a T a.s.o. .. I just counted away from the original Litecoin code base where it has been an L.


So using all the other advice can someone confirm the following for me:

- Step 1 Set the nonce value to 0 and change the Timestamp to a recent headling
- change the false&& to true&&
- Compile the software
- When It attempts to find the block and see if it does not match the timestamp if will begin mining the new genesis block
- Once it does this successfully example the block.dat and get the hash
- hardcode the hash into the code
- job complete

Is this about right?
member
Activity: 84
Merit: 10
May 02, 2013, 08:36:51 AM
#9
http://www.epochconverter.com/

this will give you the epoc time for

block_nTime=
member
Activity: 84
Merit: 10
May 01, 2013, 10:22:36 PM
#8
Do I just change the phrase and the software will hash it, or do I need to Pre hash the text?

Choose a date.
Change the text.
Start with nonce = 0.
Have it calculate the new block.
Get the block hash and make it the merkel root.

Done.

sounds easy enough, most people discuss doing this using linux which I'm not as familiar with. Should I be ok doing this in codeblocks, basically changing the variables as you mention then building the code and running it? I also have VC++ but havn't learned how to use it yet mainly been using codeblocks so far.
Pages:
Jump to: