0

I'm aware that when the hash of the block header (block hash) is below the difficulty target, a block is deemed as validated.

But because I've never run a bitcoin node before (will soon), I had a few questions regarding the mining process.

1) When miners are running the BTC software, are they by default confirming transactions in the mem pool based on the highest fees, or are they allowed to choose which transactions they may validate?

2) If you have a higher hash rate, does this mean you can validate transactions quicker as well?

3) When a block is validated on average every 10 minutes, as set by the BTC protocol, are miners also trying to validate transactions too?

4) How are transactions validated?

1 Answer 1

1
  1. Miners can choose whatever transactions they wish to include in a block, as long as they are valid, but doing so may require them using custom software. As far as I'm aware, the Bitcoin Core software selects transactions by highest paying fee first.

  2. No. The hash rate is determined by specialized hardware (ASICs) which do not perform transaction validation. The hardware does not help with the validation of transactions because it would take longer to transfer the information to this hardware than to simply perform the hashing on the CPU. The bulk of the time in validating transactions is spent on signature validation anyway, which the ASICs do not do (although it would be possible to build one for this particular purpose).

    The mining ASICs are mainly more efficient than mining on the CPU is because they perform the hash algorithm on the same data many times, internally only updating a random number for each hash attempt and recalculating the merkle root.

  3. Miners validate all transactions as they come from the network just like every other network participant. Their bitcoin node will hold incoming transactions in the mempool, and the mining software will request a block template at regular intervals, containing all of the transactions which are to be included in the block. In a mining pool, the pool operator creates the block template and the miners work from that template, and validating themselves it is optional.

  4. This is quite a complex topic because every single aspect of a transaction needs validating, and the entire details are not defined in a document, but by the reference implementation (the satoshi client / bitcoin core).

    The key details are that:

    • All of the inputs to a transaction are checked to be unspent
    • The sum of the output amounts is less than the sum of the input amounts (with the difference being the transaction fee).
    • For each transaction input, the scriptSig from that input is pushed onto a stack, then the scriptPubKey from its matching transaction outpoint is evaluated with that stack. The script must evaluate to true for the transaction to be valid. The scriptSig will usually contain a public key and a signature, and the scriptPubKey will usually perform an OP_CHECKSIG, which tests that the SHA-256 of the entire transaction was signed by the private key matching the public key. (This itself is quite nuanced because the transaction must be stripped of the signature before it is signed or validated).

There are many finer details to the validation of transactions, which are mostly answered in existing questions on here, explained on the bitcoin wiki or in the BIPs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.