1. Could you explain why the hash is in "6b483045022100f57111d73ea20dc7d989bef2d8c4a2fc" and the example in the video is in "0000011000100100000001"? This is computer science. (I made the 01 string up.)
This is not computer science. This is mathematics.
Those are just two different ways of representing numbers.
The first "6b483045022100f57111d73ea20dc7d989bef2d8c4a2fc" is hexadecimal (or base
16). The second "0000011000100100000001" is binary (or base
2). The way you are probably most familiar with is decimal (or base
10).
Comparing:
base
10 -> base
2 -> base
16 0 -> 0 -> 0
1 -> 1 -> 1
2 -> 10 -> 2
3 -> 11 -> 3
4 -> 100 -> 4
5 -> 101 -> 5
6 -> 110 -> 6
7 -> 111 -> 7
8 -> 1000 -> 8
9 -> 1001 -> 9
10 -> 1010 -> a
11 -> 1011 -> b
12 -> 1100 -> c
13 -> 1101 -> d
14 -> 1110 -> e
15 -> 1111 -> f
16 -> 10000 -> 10
17 -> 10001 -> 11
and so on
Note that:
binary only has 2 digits to work with (0 and 1)
hexadecimal has 16 digits to work with (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f)
decimal has 10 digits to work with (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9)
2. How does one byte of info like "ab" translate into the "01" string?
Perhaps you'll recall from maths back when you were about 12 years old or so that our decimal numbering system can be represented as follows:
5462 = (5 X 10
3) + (4 X 10
2) + (6 X 10
1) + (2 X 10
0)
Noticing in the conversions that I showed you up above, "a" represents a decimal value of "10" and "b" represents a decimal value of "11", we can represent the base
16 number "ab" as:
ab = (10 X 16
1) + (11 X 16
0)
Therefore, in our common decimal system "ab" = 171
You can represent that same number in binary by figuring out which of the binary digits will work in the following formula to result in a value of 171:
(? X 2
8) + (? X 2
7) + (? X 2
6) + (? X 2
5) + (? X 2
4) + (? X 2
3) + (? X 2
2) + (? X 2
1) + (? X 2
0)
The answer is:
10101011
Conversion from hexadecimal to binary has this nice mathematical property that every 4 binary digits represents one hexadecimal digit, so if you look in my example above:
a = 1010
and
b = 1011
And looking at the conversion of ab you see that it is just those two values concatenated together.
3. When you said, "Once all those different nonce values have been tried, then the miner (or pool) needs to change something else in the block header. Typically this would either be the timestamp, or the first transaction in the block.", isn't the block header is just the nonce?
No. The block consists of a list of transactions and an 80 byte header with the following information:
- Version (4 bytes)
- Hash of previous block in the chain (32 bytes)
- Merkle root (32 bytes)
- Timestamp (4 bytes)
- Representation of the current difficuty target (4 bytes)
- Nonce (4 bytes)
It is this set of 80 bytes that the miners are hashing to see if they can find a hash result that is low enough.
Do you mean that if all the different 4294967296 nonce values have been tried and still cannot solve the block, it will include the timestamp or the first transaction into the hash?
I know this part is probably very technical.
The timestamp is ALWAYS included in the input to the hash. The Merkle Root is also ALWAYS included in the input to the hash.
Therefore, by changing the values of the first transaction (which would change the Merkle Root) or the timestamp, the input to the hash is changed for another 4294967296 possible nonce values.
4. Technically or mathematically, how does 4 bytes create 232, 4294967296 of combinations?
A byte consists of 8 bits. Each bit represents binary position. So a 4 byte number can be anything between:
00000000 00000000 00000000 00000000
and
11111111 11111111 11111111 11111111
You can start with a nonce value of
00000000 00000000 00000000 00000000
and then try
00000000 00000000 00000000 00000001
and then try
00000000 00000000 00000000 00000010
and then try
00000000 00000000 00000000 00000011
and then try
00000000 00000000 00000000 00000100
and then try
00000000 00000000 00000000 00000101
and so on until after 4294967296 tries you end up at:
11111111 11111111 11111111 11111111
At that point, any other combination of 32 1's and 0's will simply be a repeat of a number you already tried. To get a different 80 byte header, you'll need to change something else in the header. If something else in the header is different, then you can try all 4294967296 possible nonce values again and you'll get 4294967296 new hash results.
How to generate the same inputs in multiple transactions?
Make certain that they refer to the same previous unspent outputs.
In a layman term, the input hash would come from "Alice send 1 BTC out" and output hash would come from "Bob should receive 1 BTC"?
No.
In layman's terms...
Alice receives 2 BTC from Mike in a single transaction output.
Alice receives 0.75 BTC from Nancy in a single transaction output.
Alice receives 0.8 BTC from Oscar in a single transaction output.
(The total is 3.55 BTC, but alice actually has control over 3 separate currently unspent outputs).
Alice creates a transaction that spends the 0.75 BTC that she received from Nancy AND the 0.8 BTC that she received from Oscar (these are the inputs to the transaction).
The total value that these inputs have provided to the transaction is 1.55 BTC
Alice's transaction creates 2 outputs.
One of them is a 1 BTC output that requires a signature from the private key that is associated with Bob's bitcoin address.
The other is a 0.55 BTC output that requires a signature from a private key that Alice's wallet is storing internally.
Since the entire 1.55 BTC of value supplied by the inputs has been used up by the outputs, there is no remaining value for the miner to be able to assign to himself. There is no transaction fee.
Now, Alice decides to "submitted the same transaction (says pay Bob with 1BTC) with fee after the no-fee transaction was submitted"...
If Alice's new transaction...
Lists the 2 BTC output from Mike as an input
Lists 1 BTC output that requires a signature from the private key that is associated with Bob's bitcoin address as one output
Lists 0.99 BTC that requires a signature from a private key that Alice's wallet is storing internally as the other output.
Then this second transaction will have a 0.01 BTC transaction fee, and will pay Bob 1 BTC. However, both transactions to Bob can confirm. If they both do, then he will receive 1 BTC from each transaction.
On the other hand if Alice's new transaction...
Lists the 0.75 BTC output from Nancy as an input
Lists the 2 BTC output from Mike as an input
Lists 1 BTC output that requires a signature from the private key that is associated with Bob's bitcoin address as one output
Lists 1.74 BTC that requires a signature from a private key that Alice's wallet is storing internally as the other output.
Then this second transaction will have a 0.01 BTC transaction fee, and will pay Bob 1 BTC.
In this case, since the original 0-fee transaction AND this new 0.01 BTC fee transaction BOTH try to spend the 0.75 BTC output from Nancy, only one of those two transactions can confirm. Once one of them confirms, the other one becomes invalid and is discarded by all participants in the system. An output can only be spent as an input once in the blockchain. Once it is spent, any other transaction that tries to spend the same output is considered to be an invalid transaction by all participants in the system. Any block that contains such an invalid transaction would be an invalid block and would be discarded by all participants in the system (regardless of how long the chain is that contains that block).
6. Back to the "voting" issue. I read that the miners will continue on the longest chain when there are a split. The video you shared also demonstrate that when Alice try to double spend her money, two chains occurred and the miners would eventually accept the longest one. When this happened, what the temporary split happened, does Alice receive BTC reward from solving blocks in her own chain?
The only BTC that exist are the outputs in the transactions in the chain.
If Alice received BTC in a transaction in the "winning" chain, then she will get those BTC. If Alice does not receive BTC in a transaction in the "winning" chain, then she doesn't have bitcoins.