1
0

modified password input routines to allow for input through stdin

This commit is contained in:
Julian Tosh
2012-07-06 21:45:57 -07:00
parent b8c1c0c317
commit b615fe0c8c
3 changed files with 33 additions and 22 deletions

View File

@@ -1,3 +1,3 @@
from wallet import Wallet, format_satoshis
from wallet import Wallet, format_satoshis, prompt_password
from interface import WalletSynchronizer
from interface import TcpStratumInterface

View File

@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, base64, os, re, hashlib, copy, operator, ast, threading, random
import sys, base64, os, re, hashlib, copy, operator, ast, threading, random, getpass
import aes, ecdsa
from ecdsa.util import string_to_number, number_to_string
@@ -147,6 +147,26 @@ 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:
print "Error: Passwords do not match."
sys.exit(1)
else:
password = raw_input(prompt)
if not password:
password = None
return password
# URL decode
_ud = re.compile('%([0-9a-hA-H]{2})', re.MULTILINE)
urldecode = lambda x: _ud.sub(lambda m: chr(int(m.group(1), 16)), x)