Browse Source

fixes suggested by BTcurious

283
ThomasV 13 years ago
parent
commit
c6dadba7b7
  1. 27
      client/electrum.py
  2. 9
      client/gui.py

27
client/electrum.py

@ -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
@ -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:
@ -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':
@ -617,7 +628,7 @@ if __name__ == '__main__':
gui = gui.BitcoinGUI(wallet)
gui.main()
wallet.save()
exit(0)
sys.exit(0)
if not wallet.read():
@ -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)"
@ -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()
@ -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
@ -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 != '')

9
client/gui.py

@ -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
@ -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)
@ -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")
@ -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:
@ -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

Loading…
Cancel
Save