Theory of an electron trap on a charged spacecraft