For the soup:
2. Cover white beans with 4 cups of cold water and bring to a boil. Simmer for 2 minutes, turn off the heat, and let sit for an hour.
3. Drain the beans and put them into a saucepan. Cover with about 2 inches of cold water. Add the whole onion, garlic cloves and bay leaf and bring to a boil. Reduce the heat, add a pinch of salt and simmer until the beans are tender, but not falling apart. Remove the onion, garlic and bay leaf. Set the beans and their liquids aside.
4. Heat the olive oil in a soup pot and add the chopped onions. Cook over moderate heat for 10 minutes until tender. Add the minced garlic and a pinch of hot pepper and cook a minute longer. Add the tomatoes, beans and their liquid and simmer for two minutes. Set aside.
5. Put the shellfish in a pan with the white wine. Cover the pan, bring to a boil over high heat, and steam until shellfish are open. Remove the shellfish to a bowl. Strain the pan juices and add them to the soup pot. Remove the clams or mussels from shells and discard the shells. Heat the beans and add the shellfish. Adjust the seasoning. Thin with water or stock if needed. Serve with a dollop of pesto.