Author

Topic: How To Get The Data Needed To Find A Block? (Read 1115 times)

legendary
Activity: 1596
Merit: 1012
Democracy is vulnerable to a 51% attack.
September 20, 2012, 04:11:40 PM
#8
i know how to add one to a number but i am asking that must the nonce be incremented or generated randomly?
In principle you can do it either way. If you're pulling from a mining pool, they expect you to try every nonce and may consider it abusive if you only try some of them.

Quote
how can i add one to the nonce because "42a14695" has a alphabetical character
Please don't take this the wrong way, but if it seriously mystifies you how to increment a hexadecimal number, you have no business writing this kind of code. This is like asking how to add one to seven because "seven" contains a 'v'. How you choose to write a number to communicate with others has nothing to do with how you manipulate it internally. Whether I tell you the number is "seven", "7" or ". . . . . . .", you add one to it the same way. If this is at all mystifying to you, you really should start out with some *much* simpler coding tasks.

Quote
and can anybody tell me how to compare the hash with the target?
The same way you compare, say, 571 to 541. You start with the most significant unit and if they're the same, you keep going to less and less significant units until you find a difference. (The hundreds are the same, so try the tens. The tens are different, so the one with the higher tens place is bigger.) Same idea.

Quote
and how can i calculate my hash without (Version, Previous hash, Merkle root, Timestamp, "Bits", Nonce) in the bitcoin hashing algorithm here https://en.bitcoin.it/wiki/Block_hashing_algorithm  all of these are used..
You have to try billions of nonces. Anything not dependent on the nonce should be done just once. You take over right where the nonce comes in, so you don't need anything processed prior to that. You're not going to go hashing all those things that never change for each of your 4 billion nonces. That would be awful.
full member
Activity: 140
Merit: 100
September 20, 2012, 02:46:51 PM
#7
The guy basically wants to know the algorithm to calculate the hash and then see if it's < target. Likely to write his own miner, or write a miner for the community or just to satisfy the thirst for knowledge.

I suggest looking at the very simple example in this C program written by someone http://pastebin.com/n8UEGA86

even in this data the values for these :

Version : Block version number
Previous hash : Hash of the previous block
Merkle root : 256-bit hash based on all of the transactions
Timestamp : Current timestamp
"Bits" : Current target in compact format
Nonce : 32-bit number (starts at 0)


has been predefined i would like to know how to get them..

call the "getwork" method with the client's api

(run "bitcoind", then run "getcoind getwork" and decode the json you get.)



is there an example on how to call "getwork" from your program using the Bitcoin-Qt GUI's 127.0.0.1?
hero member
Activity: 728
Merit: 540
September 20, 2012, 02:34:28 PM
#6
The guy basically wants to know the algorithm to calculate the hash and then see if it's < target. Likely to write his own miner, or write a miner for the community or just to satisfy the thirst for knowledge.

I suggest looking at the very simple example in this C program written by someone http://pastebin.com/n8UEGA86

even in this data the values for these :

Version : Block version number
Previous hash : Hash of the previous block
Merkle root : 256-bit hash based on all of the transactions
Timestamp : Current timestamp
"Bits" : Current target in compact format
Nonce : 32-bit number (starts at 0)


has been predefined i would like to know how to get them..

call the "getwork" method with the client's api

(run "bitcoind", then run "getcoind getwork" and decode the json you get.)

full member
Activity: 140
Merit: 100
September 20, 2012, 02:28:43 PM
#5
The guy basically wants to know the algorithm to calculate the hash and then see if it's < target. Likely to write his own miner, or write a miner for the community or just to satisfy the thirst for knowledge.

I suggest looking at the very simple example in this C program written by someone http://pastebin.com/n8UEGA86

even in this data the values for these :

Version : Block version number
Previous hash : Hash of the previous block
Merkle root : 256-bit hash based on all of the transactions
Timestamp : Current timestamp
"Bits" : Current target in compact format
Nonce : 32-bit number (starts at 0)


has been predefined i would like to know how to get them..
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
September 20, 2012, 02:19:55 PM
#4
The guy basically wants to know the algorithm to calculate the hash and then see if it's < target. Likely to write his own miner, or write a miner for the community or just to satisfy the thirst for knowledge.

I suggest looking at the very simple example in this C program written by someone http://pastebin.com/n8UEGA86
full member
Activity: 140
Merit: 100
September 20, 2012, 01:58:16 PM
#3
i know how to add one to a number but i am asking that must the nonce be incremented or generated randomly?

how can i add one to the nonce because "42a14695" has a alphabetical character

and can anybody tell me how to compare the hash with the target?

and how can i calculate my hash without (Version, Previous hash, Merkle root, Timestamp, "Bits", Nonce) in the bitcoin hashing algorithm here https://en.bitcoin.it/wiki/Block_hashing_algorithm  all of these are used..

and how to submit the hash to Bitcoin-Qt?
legendary
Activity: 1596
Merit: 1012
Democracy is vulnerable to a 51% attack.
September 20, 2012, 01:47:13 PM
#2
can anyone explain How Can i find these:

Version : Block version number
Previous hash : Hash of the previous block
Merkle root : 256-bit hash based on all of the transactions
Timestamp : Current timestamp
"Bits" : Current target in compact format
Nonce : 32-bit number (starts at 0)
You don't need any of these but the nonce. The client will process these for you. And you have to find the nonce, if there is one, by trial and error.

Quote
and can anyone tell me how can i increment the nonce.
You don't know how to add one to a number? Seriously?

Quote
and how can i check that my hash is less that current target.
You don't know how to compare two numbers to see which is greater?

Quote
and how many zero's must be there in a hash to be a block?
The hash must be lower than the target.
full member
Activity: 140
Merit: 100
September 20, 2012, 01:44:46 PM
#1
can anyone explain How Can i find these:

Version : Block version number
Previous hash : Hash of the previous block
Merkle root : 256-bit hash based on all of the transactions
Timestamp : Current timestamp
"Bits" : Current target in compact format
Nonce : 32-bit number (starts at 0)


and can anyone tell me how can i increment the nonce.

and how can i check that my hash is less that current target.

and how to submit the hash to Bitcoin-Qt

and how many zero's must be there in a hash to be a block?
Jump to: