I think you could use the code I wrote in my thread about a full shell script implementation of bitcoin:
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:
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.