Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: konstantin718 on December 17, 2013, 04:01:18 AM



Title: Does the transaction order WITHIN blocks matter?
Post by: konstantin718 on December 17, 2013, 04:01:18 AM
Hi folks,

I've been reading up on the bitcoin protocol non-stop and have a couple of questions that I haven't been able to answer:

  • When a node assembles a new block to mine, how does it determine which transactions from the list of unconfirmed transactions to include in that block that it will mine?
  • When a node assembles a new block to mine, does the order of the transactions that it picks to be in the new block matter?  My guess is that it should but I couldn't find any literature confirming or denying that.  Can anyone explain?

Thank you!
Konstantin



Title: Re: Does the transaction order WITHIN blocks matter?
Post by: kjj on December 17, 2013, 04:22:51 AM
1.  The node uses whatever criteria it wishes to use when building the block.  The reference client prefers fees first, but tends to also include a few free transactions of high priority.  Also, (approximately) no one uses the reference client to build blocks for mining.

2.  Depends what you mean.  Different orderings will give different merkle tree hashes, so the header calculated for a given ordering is only valid for that one ordering.  But as long as the block matches the header, all valid* orderings are acceptable to the network.

* There are validity rules specific to order:  The generation transaction must be first, and the first transaction must be generation.  If transaction B spends transaction A and both are in the same block, A must come before B.  Why are these in a footnote?  I consider the generation transaction to not be in the permutable set, and UTXO->A->B in a single block is rare and unusual.