2
1
The Bitcoin client builds a merkle tree to represent the transactions, then includes the root of that tree in the block header.

But usually, the number of transactions is not a power of two. When that happens, how does the Bitcoin client represent the transactions in the tree?
If I wrote a custom mining client, which built a tree with a different "shape," (example below) what would happen?



3Small correction: when there are an odd number of elements in a level, the last one is hashed after appending it to itself. So usually hash6 of one level is H(hash12+hash13) of the level below, but it can be H(hash12+hash12) if hash12 is the last one. – Pieter Wuille – 2014-09-01T09:21:57.760
@PieterWuille Huh. I hadn't noticed that. +1 – Nick ODell – 2014-09-01T15:15:46.273