diff --git a/electrum b/electrum index 314d25e85..beec31c3f 100755 --- a/electrum +++ b/electrum @@ -36,9 +36,9 @@ except ImportError: sys.exit("Error: AES does not seem to be installed. Try 'sudo pip install slowaes'") try: - from lib import Wallet, WalletSynchronizer, format_satoshis, mnemonic, prompt_password, SimpleConfig, pick_random_server + from lib import Wallet, WalletSynchronizer, format_satoshis, mnemonic, SimpleConfig, pick_random_server except ImportError: - from electrum import Wallet, WalletSynchronizer, format_satoshis, mnemonic, prompt_password, SimpleConfig, pick_random_server + from electrum import Wallet, WalletSynchronizer, format_satoshis, mnemonic, SimpleConfig, pick_random_server from decimal import Decimal @@ -107,6 +107,23 @@ offline_commands = [ 'password', 'mktx', protected_commands = ['payto', 'password', 'mktx', 'seed', 'import','signmessage' ] +# get password routine +def prompt_password(prompt, confirm=True): + import getpass + if sys.stdin.isatty(): + password = getpass.getpass(prompt) + if password and confirm: + password2 = getpass.getpass("Confirm: ") + if password != password2: + sys.exit("Error: Passwords do not match.") + else: + password = raw_input(prompt) + if not password: + password = None + return password + + + if __name__ == '__main__': usage = "usage: %prog [options] command\nCommands: "+ (', '.join(known_commands)) diff --git a/lib/__init__.py b/lib/__init__.py index 2ca45e310..fcd444bb9 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -1,3 +1,3 @@ -from wallet import Wallet, format_satoshis, prompt_password +from wallet import Wallet, format_satoshis from interface import WalletSynchronizer, Interface, pick_random_server from simple_config import SimpleConfig diff --git a/lib/wallet.py b/lib/wallet.py index 027d98ca9..47e327b51 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -26,7 +26,6 @@ import operator import ast import threading import random -import getpass import aes import ecdsa @@ -158,24 +157,6 @@ def ASecretToSecret(key): ########### end pywallet functions ####################### -# get password routine -def prompt_password(prompt, confirm=True): - if sys.stdin.isatty(): - password = getpass.getpass(prompt) - - if password and confirm: - password2 = getpass.getpass("Confirm: ") - - if password != password2: - sys.exit("Error: Passwords do not match.") - - else: - password = raw_input(prompt) - - if not password: - password = None - - return password # URL decode _ud = re.compile('%([0-9a-hA-H]{2})', re.MULTILINE) diff --git a/upgrade.py b/upgrade.py index 473a4e7c8..1f17b1e5b 100644 --- a/upgrade.py +++ b/upgrade.py @@ -1,11 +1,9 @@ -import electrum, base64, ast, sys, os +import electrum, base64, ast, sys, os, getpass from version import SEED_VERSION try: - from lib import prompt_password from lib.util import print_error except ImportError: - from electrum import prompt_password from electrum.util import print_error if __name__ == "__main__": @@ -55,7 +53,7 @@ if __name__ == "__main__": DecodeAES = lambda secret, e: AES.new(secret).decrypt(base64.b64decode(e)).rstrip(PADDING) print "Please enter your password" - password = prompt_password("Password:") + password = getpass.getpass("Password:") secret = electrum.Hash(password) try: seed = DecodeAES( secret, wallet.seed )