added a method to both exchange model & client model

added counting returned needle method in exchange model, added generating new codes method in client model