electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d92f1991a93d90da47ad2333d37d2a851b259d8c
parent c7311a1e7fea5211262ecfe7ac12d35e8601294a
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 12 Oct 2012 01:50:54 +0200

move prompt_password from wallet.py to main script

Diffstat:
Melectrum | 21+++++++++++++++++++--
Mlib/__init__.py | 2+-
Mlib/wallet.py | 19-------------------
Mupgrade.py | 6++----
4 files changed, 22 insertions(+), 26 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 )