Bitcoin Forum
April 17, 2014, 11:06:11 AM *
News: ♦♦ A bug in OpenSSL, used by Bitcoin-Qt/Bitcoin Core, could allow your bitcoins to be stolen. Immediately updating Bitcoin Core to 0.9.1 is required in some cases, especially if you're using 0.9.0. Download. More info.
The same bug also affected the forum. Changing your forum password is recommended.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Pseudo Code For Generating Bitcoins?  (Read 2940 times)
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile

Ignore
March 16, 2011, 01:16:23 AM
 #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?
1397732771
Hero Member
*
Offline Offline

Posts: 1397732771

View Profile Personal Message (Offline)

Ignore
1397732771
Reply with quote  #2

1397732771
Report to moderator
1397732771
Hero Member
*
Offline Offline

Posts: 1397732771

View Profile Personal Message (Offline)

Ignore
1397732771
Reply with quote  #2

1397732771
Report to moderator
1397732771
Hero Member
*
Offline Offline

Posts: 1397732771

View Profile Personal Message (Offline)

Ignore
1397732771
Reply with quote  #2

1397732771
Report to moderator
GAWMiners.com
ASIC Scrypt Miners
Guaranteed Satisfaction + Same-Day Shipping For FREE!
Simply Enter "freeshipping" at checkout

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1397732771
Hero Member
*
Offline Offline

Posts: 1397732771

View Profile Personal Message (Offline)

Ignore
1397732771
Reply with quote  #2

1397732771
Report to moderator
1397732771
Hero Member
*
Offline Offline

Posts: 1397732771

View Profile Personal Message (Offline)

Ignore
1397732771
Reply with quote  #2

1397732771
Report to moderator
grondilu
Hero Member
*****
Offline Offline

Activity: 1134


View Profile

Ignore
March 16, 2011, 01:51:11 AM
 #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.

gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile

Ignore
March 16, 2011, 02:22:53 AM
 #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?
Cryptoman
Hero Member
*****
Offline Offline

Activity: 726



View Profile

Ignore
March 16, 2011, 02:25:09 AM
 #4

A full shell script implementation of bitcoin: http://bitcointalk.org/index.php?topic=2461.0

"A small body of determined spirits fired by an unquenchable faith in their mission can alter the course of history." --Gandhi
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile

Ignore
March 16, 2011, 04:24:37 AM
 #5

Thanks Cryptoman! You've been quite a help to me today  Shocked
Viceroy
Sr. Member
****
Offline Offline

Activity: 434


View Profile

Ignore
April 25, 2013, 06: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://bitcointalk.org/index.php?topic=187667.0

Remember remember the 5th of November
Hero Member
*****
Offline Offline

Activity: 882

Remember me


View Profile

Ignore
April 25, 2013, 07: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://bitcointalk.org/index.php?topic=181981.0


BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!