The code you're looking for is in CreateNewBlock.
The usual way transactions are added to a block is by sorting by priority. The priority of an input is the value being spent in the input multiplied by the number of confirmations it has. The priority of a transaction is the sum of all the priorities of the inputs. See this line:
dPriority += (double)...
you can find explanation here:
the issue was actually with OP_RETURN. What OP_RETURN used to do is it would skip to the end of the script so whatever was on the stack was interpreted for the final script result. So what you could do was create a scriptSig that was just
The code you're citing does not actually deal with difficulty. It deals with targets. The target is the maximum 256-bit value than the block hash is allowed to have.
The difficulty is defined as 2^208 * 65535 / target.
As for the book, that looks wrong indeed.
According to your debug.log file, txindex is not enabled:
2018-04-22 20:40:34 LoadBlockIndexDB: transaction index disabled
This indicates that your bitcoin.conf is incorrect. Make sure that your bitcoin.conf file's full filename is actually bitcoin.conf (not bitcoin.conf.txt or with some other extension).
I think the arrow from HMAC-SHA256 should point right to the child
public key. Am I right??
No, there are 3 derivation functions defined in BIP32 - Hierarchical Deterministic Wallets
Private parent key → private child key
Public parent key → public child key
Private parent key → public child key
The diagram above illustrates
1. Private ...
Seems to me that
... creating a Pay-to-Witness-Script-Hash (P2WSH) output that would
look like this:
means that this hash is an example not derived from the data above
There are 2^256 possible hashes and your source gives a target value of 238348*2^176, requiring more than 60 bits of leading zeros (61 in fact, plus the slightly stricter requirement that a valid hash must be smaller than the target value and not just start with the same number of leading zeros). In fact, the fraction of acceptable hashes out of all possible ...