Toast the dry spices in a dry pan over low heat, stirring constantly, until fragrant and slightly darkened, about 8–10 minutes; remove and cool.
Grind the cooled toasted spices into a fine powder with a spice grinder or mortar and pestle and set aside.
Dry-roast the fresh aromatics (galangal, shallots, garlic, ginger, kaffir lime peel, lemongrass, and coriander roots) in the same pan with a pinch of salt over low heat until deeply aromatic and slightly charred; remove from heat.
If using, add the shrimp paste to the hot pan briefly and stir to release its aroma, then remove and let cool.
Blend the roasted aromatics (adding a little oil or water if needed) until smooth, then mix in the ground toasted spices and blend until fully combined to make the Massaman curry paste.
Heat the thick coconut milk in a large pot over medium heat until it just begins to boil, then add the Massaman curry paste and cook, stirring, until the oil separates and the paste is fragrant, about 5 minutes.
Stir in the sliced onions until slightly softened, then add the chicken pieces, coating them well with the paste.
Add the cubed potatoes and roasted cashews to the pot and stir to combine.
Pour in the thin coconut milk, lower the heat, and simmer gently, uncovered, for 45–60 minutes until the chicken is tender and the potatoes are cooked, stirring occasionally to prevent sticking.
Stir in the palm sugar, tamarind paste, fish sauce, and a pinch of salt; taste and adjust seasoning to balance sweet, sour, and salty flavors.
Serve the curry hot with steamed jasmine rice.