A little tongue-in-cheek, it’s missing several practical elements but nevertheless here’s some filthy bash to mint sha256 coinbases in the least efficient way possible:
#!/usr/bin/env bash -eu
DESIRED_DIFFICULTY=1
GENERATED_NONCE_COUNT=0
while true
do
nonce=$(xxd -l16 -p /dev/urandom)
hash=$(printf $(printf "$nonce" | shasum -a 256))
diff_string=$(printf '%*s' "$DESIRED_DIFFICULTY" | tr ' ' 0)
if [[ "$hash" = "$diff_string"* ]]
then
printf '%s %s\n' "$nonce" "$hash"
[1]GENERATED_NONCE_COUNT=$GENERATED_NONCE_COUNT+1 fi
done
You’re welcome!
References
↑1 | GENERATED_NONCE_COUNT=$GENERATED_NONCE_COUNT+1 |
---|