Author

Topic: Pseudo Code For Generating Bitcoins? (Read 5191 times)

legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
April 25, 2013, 02:04:50 PM
#7
Hashing for blocks is done in two ways. Either learning the SHA256 algorithm and make use of the midstate to speed up computation, or something along those lines OR read the article on the block hashing algorithm which is basically doublesha256 of the block header, nothing too complex.

You can see the relevant code here from the genesis block generator I wrote https://bitcointalksearch.org/topic/ann-genesis-block-generator-181981

hero member
Activity: 924
Merit: 501
April 25, 2013, 01:55:29 PM
#6
Same question for litecoin.  

Has Anyone written pseudocode for mining litecoin?


Or willing to sell me an RTL for the same?    :-)

Here:
https://bitcointalksearch.org/topic/pseudo-code-for-generating-litecoins-187667
sr. member
Activity: 280
Merit: 252
March 15, 2011, 11:24:37 PM
#5
Thanks Cryptoman! You've been quite a help to me today  Shocked
hero member
Activity: 726
Merit: 500
sr. member
Activity: 280
Merit: 252
March 15, 2011, 09:22:53 PM
#3
Thanks for that grondilu, do you have the link to your original post on hand?

Is the "networking part" that's missing simply grabbing the next block "todo" from the network?

That is the part I am having trouble with mentally, is where/whom do I contact to download the block chain?
legendary
Activity: 1288
Merit: 1080
March 15, 2011, 08:51:11 PM
#2
I think you could use the code I wrote in my thread about a full shell script implementation of bitcoin:

Code:
bigEndianHex2littleEndianHex() {
local s=''
while read -n 2 char
do s=$char$s
done
echo $s
}

bitcoinHash() {
bigEndianHex2littleEndianHex |
xxd -p -r |
openssl dgst -sha256 -binary |
openssl dgst -sha256 -binary |
xxd -p -c 80 |
bigEndianHex2littleEndianHex
}

And then with the following data from the current block:

ver=1
prev_block=0000000000000000000000000000000000000000000000000000000000000000
mrkl_root=4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
bits=486604799

(this is the genesis "data")

You can create a next block by searching a nonce like this:

Code:
nonce=0

while
        time=$(date +%s)
        printf "%08x%08x%08x%064s%064s%08x" $nonce $bits $time $mrkl_root $prev_block $ver |
        bitcoinHash |
        grep "some test I don't know exactly"
do nonce=$(bc <<< "nonce + 1")
done

of course a lot is missing, especially the network part.

sr. member
Activity: 280
Merit: 252
March 15, 2011, 08:16:23 PM
#1
I am interested in trying to write my own open sourced miner. But have no idea where to start.

I have read through the forum quite a bit and asked a similar question before, but to no avail.

Can anybody provide some pseudo code for generating bitcoins?

I assume it goes something like...

Code:
$hashed_string_to_crack = grab_new_hash();
while($hashed_string_unknown === true) {
  //try to crack hash?
 
  if($hash_cracked) {
    $hashed_string_unkown = false;
  }
}
submit_cracked_hash_to_bitcoin_network($hash_cracked);
repeat;

Or am I better off just to examine the poclbm source code?
Jump to: