Title: Two questions about hashing the block header. Post by: tobasco on January 14, 2015, 11:16:42 AM Hi there,
I'm looking at the block header information on this page: https://en.bitcoin.it/wiki/Block_hashing_algorithm It covers the following block header fields: Version hashPrevBlock hashMerkleRoot Time Bits Nonce 1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article? 2. A question about the Bits field. When hashing the block header in the example PHP code at the bottom of the bitcoin wiki page, the value used for Bits is 440711666. However, when looking at the block information (http://blockexplorer.com/b/125552 (http://blockexplorer.com/b/125552)), the value they have displayed for Bits is Difficulty?: 244 112.487774 ("Bits"?: 1a44b9f2) How do I convert the difficulty/bits information displayed on blockexplorer to 440711666? Title: Re: Two questions about hashing the block header. Post by: ncsupanda on January 14, 2015, 11:29:07 AM Hi there, I'm looking at the block header information on this page: https://en.bitcoin.it/wiki/Block_hashing_algorithm It covers the following block header fields: Version hashPrevBlock hashMerkleRoot Time Bits Nonce 1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article? 2. A question about the Bits field. When hashing the block header in the example PHP code at the bottom of the bitcoin wiki page, the value used for Bits is 440711666. However, when looking at the block information (http://blockexplorer.com/b/125552 (http://blockexplorer.com/b/125552)), the value they have displayed for Bits is Difficulty?: 244 112.487774 ("Bits"?: 1a44b9f2) How do I convert the difficulty/bits information displayed on blockexplorer to 440711666? Take a look at the source code - the first question answers itself. https://github.com/bitcoin/bitcoin Title: Re: Two questions about hashing the block header. Post by: dabura667 on January 14, 2015, 11:43:18 AM 1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article? 2. A question about the Bits field. 1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code? 2. https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_stored_in_blocks.3F Once you figure out how to calculate the msb with the remaining 3 bytes at this link, you'll figure it out. Title: Re: Two questions about hashing the block header. Post by: tobasco on January 14, 2015, 11:57:54 AM 1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code? Yes. Sorry my terminology is poor. I was able to find (I think) that hashMerkleRoot is a block header field name from this file: https://github.com/bitcoin/bitcoin/blob/master/src/merkleblock.cpp However I must confess that I am noob to the source. Can you point me in the direction of where I might find the code for the hashing the block header (and thus the field/container names)? Title: Re: Two questions about hashing the block header. Post by: ncsupanda on January 14, 2015, 12:00:10 PM 1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code? Yes. Sorry my terminology is poor. I was able to find (I think) that hashMerkleRoot is a block header field name from this file: https://github.com/bitcoin/bitcoin/blob/master/src/merkleblock.cpp However I must confess that I am noob to the source. Can you point me in the direction of where I might find the code for the hashing the block header (and thus the field/container names)? By "hashing the block header" are you referring to hashing the contents of the merkleblock.cpp file? Title: Re: Two questions about hashing the block header. Post by: tobasco on January 14, 2015, 12:21:42 PM By "hashing the block header" are you referring to hashing the contents of the merkleblock.cpp file? I do not understand the structure of the code well enough to answer your question accurately. Although I'd say that "hashing the contents of the merkleblock.cpp file" is an inaccurate evaluation of what I'm looking to achieve. To try and clarify, what I believe I am now looking for are the file(s) that performs this: "When mining bitcoin, the hashcash algorithm repeatedly hashes the block header while incrementing the counter & extraNonce fields." - https://en.bitcoin.it/wiki/Block_hashing_algorithm Note that finding the block header field names (container names?) in the source code is still my primary goal. Title: Re: Two questions about hashing the block header. Post by: tobasco on January 14, 2015, 02:02:03 PM Okay, so f2b9441a is the Little-endian of 440711666.
Where does 440711666 come from? https://en.bitcoin.it/wiki/Block_hashing_algorithm (https://en.bitcoin.it/wiki/Block_hashing_algorithm) (PHP script at the bottom) Title: Re: Two questions about hashing the block header. Post by: ncsupanda on January 14, 2015, 02:07:25 PM Okay, so f2b9441a is the Little-endian of 440711666. Where does 440711666 come from? https://en.bitcoin.it/wiki/Block_hashing_algorithm (https://en.bitcoin.it/wiki/Block_hashing_algorithm) (PHP script at the bottom) Current target difficulty. Title: Re: Two questions about hashing the block header. Post by: tobasco on January 14, 2015, 02:12:36 PM I see, thank you.
So how does 244 112.487774 = 440711666? http://blockexplorer.com/b/125552 (http://blockexplorer.com/b/125552) Title: Re: Two questions about hashing the block header. Post by: grau on January 14, 2015, 05:53:01 PM Below explanation using Matematica. I am sure you figure what the operations mean even if you do not use it regularly.
Code: In[15]:= minTarget = Title: Re: Two questions about hashing the block header. Post by: doof on January 16, 2015, 12:47:54 AM I did a c# example too
https://bitcointalk.org/index.php?topic=888078.msg9791851#msg9791851 |