Update bitrpc.py

code refactored and repetition removed