# Some questions about specifics on bitcoin mining

Most people mine bitcoin by launching a software on their PC or buying a special miner, both of which abstract out the nitty-gritty of how the mining process work. I am curious however about some potential issues with the nitty-gritty of the mining process. Feel free to skip to my question if you already know how it works:

As far as I know, this is how it works:

Given a string of hex values that is 1024 bit (or 256 hex values, or 128 bytes), let's say

``````0x000000020597ba1f0cd423b2a3abb0259a54ee5f783077a4ad45fb6200000218000000008348d1339e6797e2b15e9a3f2fb7da08768e99f02727e4227e02903e43a42b31511553101a051f3c00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000
``````

And a 256 bit (or 64 hex values, or 32 bytes) value known as the target

``````0x00000000FFFF0000000000000000000000000000000000000000000000000000
``````

We first byteswap each 32-bit chunk, so we end up with

``````0x020000001fba9705b223d40c25b0aba35fee549aa477307862fb45ad180200000000000033d14883e297679e3f9a5eb108dab72ff0998e7622e427273e90027e312ba443105315513c1f051a00000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280
``````

We read the last 64 bits (or 16 hex values or 8 bytes)

``````0x0000000000000280
``````

Which equals to 640 bits, or 80 bytes.

So we grab the first 640 bits (or 160 hex values, or 80 bytes) of byte-swapped string of hex values

``````0x020000001fba9705b223d40c25b0aba35fee549aa477307862fb45ad180200000000000033d14883e297679e3f9a5eb108dab72ff0998e7622e427273e90027e312ba443105315513c1f051a00000000
``````

We do not change the first 608 bits, but we keep on changing the last 32 bits (or also known as the nonce value) and put the new string of hex values into the SHA256 function

``````#scroll to right to see the last 8 bits incrementing

#    .. so on
``````

If we find a new_hash that is lower or equal to the target,

``````# one of the new_hash is
new_hash = 0x00000000fffe0000000000000000000000000000000000000000000000000000
# which is is lower than target
``````

then we have successfully found a nonce value (the 32 bits that we are changing) that satisfies the requirement, so we can submit it and earn a share, which I understand is a small chunk of reward to the miner when the actual full requirements are satisfied.

To be able to get a value lower than that target randomly, there will be a 1 in 4295032833 (4.3 billion) chance of succeeding.

The nonce value which we can change is 32 bit or 4294967296.

So the expected value of getting it right after trying every nonce value is (4294967296/4295032833), or basically 1.

But that is the expected value, there will be cases where every nonce value is tried and we still do not get to the target.

Question 1. How does software like NiceHash miner or other mining tools handle situations like this under the hood?

Here is another issue, it is going to take computers some time to try out every nonce value because there are 4 billion of them. Question 2: Is there a time limit to how long a miner can take to guess and check before the given work is no longer "accepted"?

And here is my 3rd one, the given target is not exactly sufficient in mining a full block, attaining it will instead earn miners a share. The system is implemented like this so that miners can share their reward proportional to the amount of computation they have performed.

Question 3: How much, usually, is each share reward is in US dollars? I am guessing it varies from pool to pool, but what would the financial value usually be at?

Also if there is something wrong with my own re-articulation of how bitcoin mining works, please let me know as well.

• Not a real answer, but just FYI, NiceHash does not mine BTC. It mines various altcoins (which can be mined without specialized hardware; the process is different for each) for the pool, credits your account for it after converting to BTC, and then lets you withdraw the BTC. Bitcoin itself cannot realistically be mined with generic-purpose hardware since 2013 or so. It's all specialized ASICs now. Aug 16, 2021 at 16:25

Question 1. How does software like NiceHash miner or other mining tools handle situations like this under the hood?

There's literally nothing to do in this case. If you don't find a nonce that works, then you have to try a new block.

Here is another issue, it is going to take computers some time to try out every nonce value because there are 4 billion of them. Question 2: Is there a time limit to how long a miner can take to guess and check before the given work is no longer "accepted"?

Realistic miners take a very tiny fraction of a second to try every possible nonce. It's so fast that working on a single block at a time is completely unrealistic and real miners will try several possible blocks at a time.

Typical mining pools will accept a share so long as it is turned into the pool before a new block is mined. That means that on average you have a ten minute window. A share turned in after a block is mined is called a "stale share". Under realistic conditions, they should be rare. Every ten minutes, right after a block is found, there's a window of a second or two in which a stale share might be turned in even if nothing goes wrong.

Question 3: How much, usually, is each share reward is in US dollars? I am guessing it varies from pool to pool, but what would the financial value usually be at?

A difficulty one share is essentially worthless. It takes only 4 billion hashes or so to generate a difficulty one share and realistic miners would generate so many of these that there is no way they could keep up and have to use much lower targets to generate a realistic number of shares. A single Bitmain S19 Pro miner produces 110 trillion hashes per second -- that's thousands of difficulty one shares per second.

The bitcoin network is currently getting around 100 quintillion hashes per second. Total mining revenue is about \$56 million per day. That makes the value of 4 billion hashes approximately 0.0000025 cents.