Do merkle root and txid duplicates check simultaneously

Move the txid duplicates check into BuildMerkleTree (where it can be done
without building a full txid set).