Update wallet.py

add sanity check