move prompt_password from wallet.py to main script
This commit is contained in:
parent
c7311a1e7f
commit
d92f1991a9
21
electrum
21
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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue