Nit: I can't help but notice that all calls to pwallet->IsSpent (apart from the one in the UI) construct a COutPoint object specifically to pass to the function. Maybe IsSpent(const uint256&, int n) would be more convenient.