tfixes suggested by BTcurious - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit c6dadba7b7d2f470a0eba83b944ce3902680694a DIR parent 71ff526ef472b953d068cbf6946eec960b7bfee4 HTML Author: ThomasV <thomasv@gitorious> Date: Thu, 10 Nov 2011 09:34:27 +0100 fixes suggested by BTcurious Diffstat: M client/electrum.py | 27 +++++++++++++++++++-------- M client/gui.py | 9 +++++---- 2 files changed, 24 insertions(+), 12 deletions(-) --- DIR diff --git a/client/electrum.py b/client/electrum.py t@@ -23,7 +23,7 @@ try: import ecdsa except: print "python-ecdsa does not seem to be installed. Try 'sudo easy_install ecdsa'" - exit(1) + sys.exit(1) try: import Crypto t@@ -215,9 +215,20 @@ def raw_tx( inputs, outputs, for_sig = None ): class InvalidPassword(Exception): pass -wallet_dir = os.environ["HOME"] + '/.bitcoin/' + +if "HOME" in os.environ: + wallet_dir = os.environ["HOME"] + '/.bitcoin/' +elif "LOCALAPPDATA" in os.environ: + wallet_dir = os.environ["LOCALAPPDATA"] + '/Bitcoin/' +elif "APPDATA" in os.environ: + wallet_dir = os.environ["APPDATA"] + '/Bitcoin/' +else: + print "No home directory found in environment variables." + raise + if not os.path.exists( wallet_dir ): os.mkdir( wallet_dir ) + wallet_path = wallet_dir + '/electrum.dat' class Wallet: t@@ -608,7 +619,7 @@ if __name__ == '__main__': known_commands = ['balance', 'sendtoaddress', 'password', 'getnewaddress', 'addresses', 'history', 'label', 'gui', 'all_addresses', 'gentx'] if cmd not in known_commands: print "Known commands:", ', '.join(known_commands) - exit(0) + sys.exit(0) wallet = Wallet() if cmd=='gui': t@@ -617,7 +628,7 @@ if __name__ == '__main__': gui = gui.BitcoinGUI(wallet) gui.main() wallet.save() - exit(0) + sys.exit(0) if not wallet.read(): t@@ -627,7 +638,7 @@ if __name__ == '__main__': password2 = getpass.getpass("Confirm password:") if password != password2: print "error" - exit(1) + sys.exit(1) else: password = None print "in order to use wallet encryption, please install pycrypto (sudo easy_install pycrypto)" t@@ -711,7 +722,7 @@ if __name__ == '__main__': label = ' '.join(sys.argv[3:]) except: print "syntax: label <tx_hash> <text>" - exit(1) + sys.exit(1) wallet.labels[tx] = label wallet.save() t@@ -722,7 +733,7 @@ if __name__ == '__main__': label = ' '.join(sys.argv[4:]) except: print "syntax: send <recipient> <amount> [label]" - exit(1) + sys.exit(1) r, h = wallet.send( to_address, amount, label, password, cmd=='sendtoaddress' ) print h t@@ -739,7 +750,7 @@ if __name__ == '__main__': private_keys = ast.literal_eval( wallet.pw_decode( wallet.private_keys, password) ) except: print "sorry" - exit(1) + sys.exit(1) new_password = getpass.getpass('New password:') if new_password == getpass.getpass('Confirm new password:'): wallet.use_encryption = (new_password != '') DIR diff --git a/client/gui.py b/client/gui.py t@@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import datetime -import thread, time, ast +import thread, time, ast, sys import pygtk pygtk.require('2.0') import gtk, gobject t@@ -73,7 +73,7 @@ def init_wallet(wallet): r = dialog.run() dialog.destroy() if r==2: - exit(1) + sys.exit(1) is_recovery = (r==1) t@@ -113,7 +113,7 @@ def init_wallet(wallet): thread.start_new_thread( recover_thread, ( wallet, dialog, None ) ) # no password r = dialog.run() dialog.destroy() - if r==gtk.RESPONSE_CANCEL: exit(1) + if r==gtk.RESPONSE_CANCEL: sys.exit(1) if not wallet.is_found: show_message("No transactions found for this seed") t@@ -223,7 +223,7 @@ def run_settings_dialog( wallet, is_create, is_recovery): seed = mnemonic.mn_decode( seed.split(' ') ) dialog.destroy() if r==gtk.RESPONSE_CANCEL: - if is_create: exit(1) + if is_create: sys.exit(1) else: return try: t@@ -233,6 +233,7 @@ def run_settings_dialog( wallet, is_create, is_recovery): if is_recovery: wallet.seed = seed wallet.gap_limit = int(gap) + wallet.save() except: pass