Preheat the oven to 180 C / Gas 4. Butter and flour a 20cm square cake tin. Sift the flour with the baking powder and salt; set aside.
Place the chocolate in a heatproof bowl, and place the bowl over a pan of hot water. Stir the chocolate gently until melted. Allow the chocolate to cool to room temperature.
Meanwhile, beat the butter with an electric mixer until softened. Beat in the vanilla extract and caster sugar until light and creamy. Add the eggs one at a time, beating at medium speed after each addition.
Gently stir the chocolate into the butter mixture until fully incorporated. Gradually beat in the flour mixture until the mixture is homogeneous. Stir in the walnuts. Pour into the prepared tin.
Bake in the preheated oven until a skewer inserted near the centre comes out clean, about 45 minutes. Allow to cool at least 10 minutes before serving.