Soak the chilis in boiling water to soften while you prepare the other spice paste ingredients. Soak the tamarind in boiling water as well - around ⅓ cup (80ml) - and set aside.
Roughly chop the other spice paste ingredients - shallots, garlic, ginger, galangal and lemongrass and add all to a small food processor/blender. Depending on how strong your processor/blender is you may want to pre-chop them more or less. Save the green part from the lemongrass but trim the very end.
Drain the chilis, remove seeds if you prefer and roughly chop. Add the dry chilis and turmeric, if using, and blend everything together into a paste. If needed, scrape down the sides and blend again. It may not be completely smooth, but you want to avoid having large chunks.
Break up the soaked tamarind to try to get as much of it mixed into the water then strain to remove solids, pressing through as much as you can. Top up the tamarind water to ¾ cup (180ml).
Warm the oil in a medium pot/pan over a medium heat. Add the spice paste and cook, stirring now and then, for around 5 minutes until the paste is fragrant. Add the green part of the lemongrass, lime leaves and star anise and cook a minute.
Add the pieces of chicken and cook a minute or two each side to gently brown the meat (you just want more of a gentle color rather than a strong sear).
Add the coconut milk and tamarind water. Stir so that everything is well combined then bring the pot to a simmer.
Reduce the heat to a low simmer and cook, uncovered, turning the chicken now and then and stirring the sauce to ensure it isn't browning or sticking on the bottom. After around 40 minutes, you should see the oils separate and rise to the top with the rest of the sauce underneath. Add the sugar, and if needed add a little salt, if needed. At this point, cook for around 5 minutes more, meanwhile preparing the coconut.
As the chicken cooks, gently toast the desiccated coconut either under the broiler/grill or in a dry skillet until gently brown. Add this to the chicken and mix in. Remove the whole spices, scraping back any sauce stuck to them into the sauce. Serve chicken topped with the sauce over rice.