Bitcoin Forum
September 27, 2018, 11:09:33 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: bitcoin generation using bash shell (poc)  (Read 1907 times)
sead
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
May 30, 2011, 01:35:57 PM
 #1

hi forum,

I tried to develop a bash shell based bitcoin miner poc for a better understanding
of the crypto stuff. Can someone please tell me how I can find out or compute
test or verification values (mindstate/data/hash1/target) - with a target match?
...still haven't figured out the verification details yet :)

I used the following versions of dependencies:
GNU bash, version 4.1.5
curl 7.21.0
OpenSSL 0.9.8o

(no target check yet - unproofed crypto!1)

Code:
#!/bin/bash
#
# bitcoin poc 0.1
#  by sead (1B91ZzpVrs7wq3pYdeDLFoKVWQuxPngZSk)
#
# deps: openssl, curl, xxd, bitcoind

i=0
rpcuser='username'
rpcpass='password'
getwork=`curl -s -u $rpcuser:$rpcpass -d '{"params": [], "method": "getwork", "id": "json"}' 127.0.0.1:8332`
mindstate=`echo $getwork | awk -F"[,|:|\"]" '{ print $8 }'`
data=`echo $getwork | awk -F"[,|:|\"]" '{ print $14 }'`
hash1=`echo $getwork |awk -F"[,|:|\"]" '{ print $20 }'`
target=`echo $getwork |awk -F"[,|:|\"]" '{ print $26 }'`

while [ $i -le $((16#ffffffff)) ]
 do
  h=`printf '%s%s%08x%s' $mindstate ${data:128:40} $i ${data:176} | xxd -r -p | openssl sha -sha256`
  printf '%s%s' $h $hash1 |  xxd -r -p | openssl sha -sha256

  i=$[$i+1]
done
1538089773
Hero Member
*
Offline Offline

Posts: 1538089773

View Profile Personal Message (Offline)

Ignore
1538089773
Reply with quote  #2

1538089773
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538089773
Hero Member
*
Offline Offline

Posts: 1538089773

View Profile Personal Message (Offline)

Ignore
1538089773
Reply with quote  #2

1538089773
Report to moderator
1538089773
Hero Member
*
Offline Offline

Posts: 1538089773

View Profile Personal Message (Offline)

Ignore
1538089773
Reply with quote  #2

1538089773
Report to moderator
DukeOfEarl
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
June 01, 2011, 07:51:55 PM
 #2

Did you get this working?
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!