Che cosa è la Proof of work? Come si mina un blocco?

Video completo su Bitcoin in Action!

In Action

Che cosa è la Proof of work? Come si mina un blocco?
$ bitcoin-cli getblock $(bitcoin-cli getblockhash 1773164){“hash”: “00000000000000eb74d096b83594d770f23d633e3a8b08813763489fbde7a0ef”,“confirmations”: 2,“strippedsize”: 1704,“size”: 2722,“weight”: 7834,“height”: 1773164,“version”: 545259520,“versionHex”: “20800000”,“merkleroot”: “75870dd46a503862af6fcf700be5e02e008db4521d96713bda51607ed05e2a18”,“tx”: [“5e68fb0018f65216db1f559437705350934451da086c0bc3e4073c0f2b8df4cc”,“64b3ceadb693d33be7cdc4233c4607d77d37effcf426c9ce75146bfb269a93dd”,“8f4ce2cfa530a5f3912d2c75be3b4d018da18037a68c6b2fac0415d09bdd39b3”,“9d67968905df317779d3c92b7e052fae96020ccbc68d3f77d40bca0f2e50449d”,“4684cbc6831af10960835cd0c10831a23eb90e736dab9e96229e45828ded2760”,“6f66bcfab129e6d3a5b18e3e9554d54178b415cb54ecf82e350cc24d63209eff”,“fc874f84759c9c4944037af4b3be02efd03c6436ebc8b8571519658de1e5580a”,“6d11edc6b84444206dd97f9924e8ca6b273b0bce9ea58218590a275a64da740a”,“370151706116ba9ae7bff77d9244a6a3e5401aadb43de221bf3f804386724c4d”,“5d6c8801705493612138d3addfb0b0b5a49cc5177b5f2cee370d4b765d3e37b2”],“time”: 1592919152,“mediantime”: 1592917919,“nonce”: 3940145976,“bits”: “1a01a5f2”,“difficulty”: 10178811.40698772,“chainwork”: “000000000000000000000000000000000000000000000160b51965fab057015d”,“nTx”: 10,“previousblockhash”: “00000000000001249b9a4e000135acecec2dcd7385eba54639ff962f3883e861”,“nextblockhash”: “0000000000000171c5c04355788d2531b349b55c6189e2e3719d2b5c82fa2026”}
$ bitcoin-cli getblocktemplate ‘{“rules”: [“segwit”]}’
$ bitcoin-cli getblocktemplate ‘{“rules”: [“segwit”]}’ | jq -r ‘.target’00000000000001a5f20000000000000000000000000000000000000000000000
$ ver=`printf 20800000 | tac -rs ..| tr -d ‘\n’`
$ prev=`printf 00000000000001249b9a4e000135acecec2dcd7385eba54639ff962f3883e861 | tac -rs .. | tr -d ‘\n’`
$ mkl=`printf 75870dd46a503862af6fcf700be5e02e008db4521d96713bda51607ed05e2a18 | tac -rs .. | tr -d ‘\n’`
$ time=`printf ‘%x\n’ 1592919152 | tac -rs .. | tr -d ‘\n’`
$ bits=`echo 1a01a5f2 | tac -rs .. | tr -d ‘\n’`
$ nonce=`printf ‘%x\n’ 3940145976 | tac -rs .. | tr -d ‘\n’`
$ printf $ver$prev$mkl$time$bits$nonce | xxd -r -p | sha256sum -b | xxd -r -p | sha256sum -b
$ printf efa0e7bd9f48633781088b3a3e633df270d79435b896d074eb00000000000000 | tac -rs ..00000000000000eb74d096b83594d770f23d633e3a8b08813763489fbde7a0ef
1a01a5f2
$ echo ‘ibase=16; 1A’ | bc26
01a5f20000000000000000000000000000000000000000000000
$ printf 01a5f20000000000000000000000000000000000000000000000 | wc -c52
$ BITS_10=”$(echo “obase=10; ibase=16; -u; $(echo 01a5f20000000000000000000000000000000000000000000000 | tr ‘[:lower:]’ ‘[:upper:]’)” |bc | sed -n 2p)”
$ echo $BITS_102648593653332025323234430866859553558338063400000453437554688
$ TARGET=”$(echo “obase=10; ibase=16; -u; $(echo 00000000000000eb74d096b83594d770f23d633e3a8b08813763489fbde7a0ef | tr ‘[:lower:]’ ‘[:upper:]’)” |bc | sed -n 2p)”
$ echo “$TARGET<$BITS_10”|bc1
$ test 00000000000000eb74d096b83594d770f23d633e3a8b08813763489fbde7a0ef = $(bitcoin-cli getblockhash 1773164) && echo sono uguali || echo sono diversi