Bitcoin mining consist of finding a nonce to add to previous block header and after 2x sha256 resulting in number lower than target.
Now my questis, where can I find previous mined block headers and solution nonce? Something that I check validity by myself.
My server is gone, so i'm no longer running bitcoin core, but isn't there a "getblockheader" parameter in bitcoin-cli?
EDIT: i'm currently using getblock.io (which is free for personal use)... I tested the getblockheader parameter, and it seems to work:
curl --location 'https://btc.getblock.io/mainnet/' \
--header 'x-api-key: my_api_key' \
--header 'Content-Type: application/json' \
--data ' {
"jsonrpc": "2.0",
"method": "getblockheader",
"params": [
"00000000000000000003db936a59e25354d7c9ad0b1922ae9430cf2643d0966f",
true
],
"id": "getblock.io"
}'
In reality, you'll have to combine this with the "getbestblockhash" parameter in order to get the hash of the block @ the tip of the chain... When you have this hash, plug it into the bitcoin-cli getblockheader command to get things like the merkleroot, time, nonce, bits,...
If you're not running a reference implementation of the node software (bitcoin core), and you don't want to use getblock.io, there's always
https://www.chainquery.com/bitcoin-cli/ aswell (which works without signing up, but you cannot automate using chainquery)