Bitcoin Forum
May 05, 2024, 02:10:40 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 5 6 »  All
  Print  
Author Topic: More Genesis Block Discussion  (Read 33862 times)
AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
April 27, 2013, 09:03:21 PM
 #1

This is a seperate discussion from the one about how to generate a Genesis Block here:

https://bitcointalk.org/index.php?topic=187888.0

This thread I want to past the parts of the code that cover the genesis block for discussion of what the code is doing so I can better understand the process. I am using the SmallChange source code who's commit really well shows you all the edits you need to make a new Altcoin, I've been able to make all the changes except the pieces below which I am still trying to understand before I do any major tinkering (all the following snippets are found in main.cpp)...

to see the small change source edits go here: https://github.com/bfroemel/smallchange/commit/947a0fafd8d033f6f0960c4ff0748f76a3d58326

Code:
1971 	1974 	         pchMessageStart[1] = 0xc1;
1972 1975         pchMessageStart[2] = 0xb7;
1973 1976         pchMessageStart[3] = 0xdc;
1974   -        hashGenesisBlock = uint256("0xf5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f");
   1977 +        hashGenesisBlock = uint256("0xa50faf35e1dddf4a076a907fbcef6d9d1595390cdb1c818a35dae53b67ad0aa8");

In this part I guess it just relates to generating the Gblock and puting in the number there.

Code:
1992 	  	-
1993   -        // Genesis Block:
1994   -        // CBlock(hash=12a765e31ffd4059bada, PoW=0000050c34a64b415b6b, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=97ddfbbae6, nTime=1317972665, nBits=1e0ffff0, nNonce=2084524493, vtx=1)
1995   -        //   CTransaction(hash=97ddfbbae6, ver=1, vin.size=1, vout.size=1, nLockTime=0)
1996   -        //     CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d0104404e592054696d65732030352f4f63742f32303131205374657665204a6f62732c204170706c65e280997320566973696f6e6172792c2044696573206174203536)
1997   -        //     CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
1998   -        //   vMerkleTree: 97ddfbbae6
1999   -
   1995 +    
   1996 +  // Genesis block:
   1997 +  // block.nTime = 1366559428
   1998 +  // block.nNonce = 2085386442
   1999 +  // block.GetHash = 384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5
   2000 +  // CBlock(hash=384b060671f4a93948e9, PoW=00000951e146b0026411, ver=1,
   2001 +  //  hashPrevBlock=00000000000000000000, hashMerkleRoot=5a2e19825b,
   2002 +  //  nTime=1366559428, nBits=1e0ffff0, nNonce=2085386442, vtx=1)
   2003 +  // CTransaction(hash=5a2e19825b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
   2004 +  // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d010441746f646f3a207265706c616365207769746820736f6d657468696e67207468617420656e7375726573206e6f207072656d696e696e6720746f6f6b20706c616365)
   2005 +  // CTxOut(error)
   2006 +  // vMerkleTree: 5a2e19825b
   2007 +        


I'm assuming there are all the variables, but what is what and would I get them all from running a genesis block generating script.

Code:
  // Genesis block
-        const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
+        const char* pszTimestamp = "todo: replace with something that ensures no premining took place";
         CTransaction txNew;
         txNew.vin.resize(1);
         txNew.vout.resize(1);
         txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((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;
+        txNew.vout[0].nValue = 0;
+        txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG; // a privkey for that 'vanity' pubkey would be interesting ;)

This is the part that confuses me the most, what does the sentence have to do to it. Is the genesis block a numerical version of that phrase and they need to match?

Code:
2013 	  	-        block.nTime    = 1317972665;
   2021 +        block.nTime    = 1366559428;
2014 2022         block.nBits    = 0x1e0ffff0;
2015   -        block.nNonce   = 2084524493;
   2023 +        block.nNonce   = 2085386442;
2016 2024
2017 2025         if (fTestNet)
2018 2026         {
2019   -            block.nTime    = 1317798646;
2020   -            block.nNonce   = 385270584;
   2027 +            block.nTime    = 1366559428;
   2028 +            block.nNonce   = 386402991;
2021 2029         }
2022 2030
2023 2031         //// debug print
2024 2032         printf("%s\n", block.GetHash().ToString().c_str());
2025 2033         printf("%s\n", hashGenesisBlock.ToString().c_str());
2026 2034         printf("%s\n", block.hashMerkleRoot.ToString().c_str());
2027   -        assert(block.hashMerkleRoot == uint256("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"));
   2035 +        assert(block.hashMerkleRoot == uint256("0x5a2e19825b4162f68602039040f1e05d9f924ff00a3aff7327ca6abd6f3279bc"));
2028 2036  


here seems to be just more plugging in of the variables from above

1714875040
Hero Member
*
Offline Offline

Posts: 1714875040

View Profile Personal Message (Offline)

Ignore
1714875040
Reply with quote  #2

1714875040
Report to moderator
1714875040
Hero Member
*
Offline Offline

Posts: 1714875040

View Profile Personal Message (Offline)

Ignore
1714875040
Reply with quote  #2

1714875040
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714875040
Hero Member
*
Offline Offline

Posts: 1714875040

View Profile Personal Message (Offline)

Ignore
1714875040
Reply with quote  #2

1714875040
Report to moderator
1714875040
Hero Member
*
Offline Offline

Posts: 1714875040

View Profile Personal Message (Offline)

Ignore
1714875040
Reply with quote  #2

1714875040
Report to moderator
twobits
Sr. Member
****
Offline Offline

Activity: 574
Merit: 250



View Profile
April 28, 2013, 08:10:22 AM
 #2

The phrase is hashed into the block.

It is meant to be a proof of date.   It is mean to be some fact that would not have been known before the date in it, to prove the block was made on of after that date.

█████                █████      ███████             
█████                ███    █████████████       
█████                ██  █████████████████   
█████                █  ██████              ██████ 
█████                    ████                      ████ 
█████████████  █████                        ████
█████████████  █████                        ████
█████████████  █████                        ████
█████                    █████                             
█████                █  ██████              ███████
█████                ██  ███████████    █████ 
█████                ███    █████████    ████   
█████                █████      ███████    ██
███
███
███
███
███
███
███
███
███
HyperQuant.net
Platform for Professional Asset Management
███
███
███
███
███
███
███
███
███
WhitePaper
One-Pager
███
███
███
███
███
███
███
███
███
Telegram 
Facebook
Twitter
Medium
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
█████                █████      ███████             
█████                ███    █████████████       
█████                ██  █████████████████   
█████                █  ██████              ██████ 
█████                    ████                      ████ 
█████████████  █████                        ████
█████████████  █████                        ████
█████████████  █████                        ████
█████                    █████                             
█████                █  ██████              ███████
█████                ██  ███████████    █████ 
█████                ███    █████████    ████   
█████                █████      ███████    ██
AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
April 28, 2013, 02:25:41 PM
 #3

Do I just change the phrase and the software will hash it, or do I need to Pre hash the text?

AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
April 29, 2013, 01:15:34 PM
 #4

Quote
   1996    +  // Genesis block:
     1997    +  // block.nTime = 1366559428
     1998    +  // block.nNonce = 2085386442
     1999    +  // block.GetHash = 384b060671f4a93948e9c168216dadb0ca2fbc54aa11c86b0345b6af1c59b2f5
     2000    +  // CBlock(hash=384b060671f4a93948e9, PoW=00000951e146b0026411, ver=1,
     2001    +  //  hashPrevBlock=00000000000000000000, hashMerkleRoot=5a2e19825b,
     2002    +  //  nTime=1366559428, nBits=1e0ffff0, nNonce=2085386442, vtx=1)
     2003    +  // CTransaction(hash=5a2e19825b, ver=1, vin.size=1, vout.size=1, nLockTime=0)
     2004    +  // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d010441746f646f3a207265706c616365207769746820736f6d657468696e672074686 17420656e7375726573206e6f207072656d696e696e6720746f6f6b20706c616365)
     2005    +  // CTxOut(error)
     2006    +  // vMerkleTree: 5a2e19825b

Let me rephrase the question, of the variables above, when creating an altcoin how many of them HAVE to be changes, if they need to be changes how many of them are arbrtitrary how many need to be generated by some other process.

twelph
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
May 01, 2013, 02:08:24 AM
 #5

Bump because I would like to know this as well.

Trustworthy Buyers: TTBit
solracx
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


View Profile WWW
May 02, 2013, 01:43:23 AM
 #6

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.

ZenithCoin - Sustainable Scrypt Based Crypto Currency
AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 02, 2013, 02:19:33 AM
 #7

here's another quote about the same deal for peoples reference:

Quote
I got most of the coding done, it's mainly the gensis block is where I'm stuck at, if anyone would like to help pm me,

... the guy working with beertokens and WEEDS set-up a tool where anybody can create a genesis block fairly easily ... multi-coin and etc

https://bitcointalk.org/index.php?topic=24209.msg300830#msg300830

https://github.com/sacarlson/MultiCoin/blob/master/create_new_genisis_block.txt


for people who need advice compiling in windows...

install openssl-1.0.1d or e, then make sure the include dir is in the build script.
For windows build you see details here:
https://bitcointalk.org/index.php?topic=149479.0


AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 02, 2013, 02:22:36 AM
 #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.

AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 02, 2013, 12:36:51 PM
 #9

http://www.epochconverter.com/

this will give you the epoc time for

block_nTime=

AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 03, 2013, 12:29:47 PM
 #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?

tyrion70
Legendary
*
Offline Offline

Activity: 934
Merit: 1000



View Profile
May 05, 2013, 12:35:38 PM
 #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!


AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 05, 2013, 02:25:13 PM
 #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?

tyrion70
Legendary
*
Offline Offline

Activity: 934
Merit: 1000



View Profile
May 05, 2013, 03:11:24 PM
 #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..

AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 05, 2013, 04: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?

Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
May 05, 2013, 04: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.

How often do you get the chance to work on a potentially world-changing project?
AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 05, 2013, 04: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

tyrion70
Legendary
*
Offline Offline

Activity: 934
Merit: 1000



View Profile
May 05, 2013, 05: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<unsigned char>((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<unsigned char>((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


tyrion70
Legendary
*
Offline Offline

Activity: 934
Merit: 1000



View Profile
May 05, 2013, 06: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

marcus_of_augustus
Legendary
*
Offline Offline

Activity: 3920
Merit: 2348


Eadem mutata resurgo


View Profile
May 06, 2013, 04: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 ...

AlexMerced (OP)
Member
**
Offline Offline

Activity: 84
Merit: 10



View Profile WWW
May 06, 2013, 11: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.

Pages: [1] 2 3 4 5 6 »  All
  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!