|
|
@ -27,7 +27,7 @@ from decimal import Decimal |
|
|
|
from wallet import format_satoshis |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval', 'gtk','qt'] |
|
|
|
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'restore', 'payto', 'sendtx', 'password', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval'] |
|
|
|
|
|
|
|
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands)) |
|
|
|
|
|
|
@ -88,12 +88,13 @@ if __name__ == '__main__': |
|
|
|
if cmd not in known_commands: |
|
|
|
cmd = 'help' |
|
|
|
|
|
|
|
if not wallet.read() and cmd not in ['help','create']: |
|
|
|
if not wallet.read() and cmd not in ['help','create','restore']: |
|
|
|
print "Wallet file not found." |
|
|
|
print "Type 'electrum.py create' to create a new wallet, or provide a path to a wallet with the -d option" |
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
if cmd == 'create': |
|
|
|
if cmd in ['create', 'restore']: |
|
|
|
import mnemonic |
|
|
|
if wallet.read(): |
|
|
|
print "remove the existing wallet first!" |
|
|
|
sys.exit(0) |
|
|
@ -110,27 +111,38 @@ if __name__ == '__main__': |
|
|
|
port = raw_input("port (default:%d):"%interface.port) |
|
|
|
fee = raw_input("fee (default:%s):"%( str(Decimal(wallet.fee)/100000000)) ) |
|
|
|
gap = raw_input("gap limit (default 5):") |
|
|
|
if fee: wallet.fee = float(fee) |
|
|
|
if host: interface.host = host |
|
|
|
if port: interface.port = int(port) |
|
|
|
if fee: wallet.fee = float(fee) |
|
|
|
if gap: wallet.gap_limit = int(gap) |
|
|
|
seed = raw_input("if you are restoring an existing wallet, enter the seed. otherwise just press enter: ") |
|
|
|
if seed: |
|
|
|
wallet.seed = seed |
|
|
|
|
|
|
|
if cmd == 'restore': |
|
|
|
seed = raw_input("seed:") |
|
|
|
try: |
|
|
|
seed.decode('hex') |
|
|
|
except: |
|
|
|
print "not hex, trying decode" |
|
|
|
seed = mnemonic.mn_decode( seed.split(' ') ) |
|
|
|
if not seed: |
|
|
|
print "no seed" |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
wallet.seed = str(seed) |
|
|
|
print "recovering wallet..." |
|
|
|
wallet.init_mpk( wallet.seed ) # not encrypted at this point |
|
|
|
wallet.synchronize() |
|
|
|
if wallet.is_found(): |
|
|
|
wallet.fill_addressbook() |
|
|
|
wallet.save() |
|
|
|
print "recovery successful" |
|
|
|
else: |
|
|
|
print "no wallet found" |
|
|
|
print "found no history for this wallet" |
|
|
|
else: |
|
|
|
wallet.new_seed(None) |
|
|
|
print "Your seed is", wallet.seed |
|
|
|
print "Please store it safely" |
|
|
|
# generate first key |
|
|
|
wallet.synchronize() |
|
|
|
print "Your wallet generation seed is: " + wallet.seed |
|
|
|
print "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet." |
|
|
|
print "Equivalently, your wallet seed can be stored and recovered with the following mnemonic code:" |
|
|
|
print "\""+' '.join(mnemonic.mn_encode(wallet.seed))+"\"" |
|
|
|
|
|
|
|
# check syntax |
|
|
|
if cmd in ['payto', 'mktx']: |
|
|
@ -146,7 +158,7 @@ if __name__ == '__main__': |
|
|
|
cmd = 'help' |
|
|
|
|
|
|
|
# open session |
|
|
|
if cmd not in ['password', 'mktx', 'history', 'label', 'contacts', 'help', 'validateaddress', 'signmessage', 'verifymessage', 'eval']: |
|
|
|
if cmd not in ['password', 'mktx', 'history', 'label', 'contacts', 'help', 'validateaddress', 'signmessage', 'verifymessage', 'eval', 'create']: |
|
|
|
interface.new_session(wallet.all_addresses(), wallet.electrum_version) |
|
|
|
interface.update_wallet(wallet) |
|
|
|
wallet.save() |
|
|
@ -198,8 +210,6 @@ if __name__ == '__main__': |
|
|
|
print "broadcast a transaction to the network. <tx> must be in hexadecimal" |
|
|
|
elif cmd2 == 'password': |
|
|
|
print "change your password" |
|
|
|
elif cmd2 == 'newaddress': |
|
|
|
print "create a new receiving address. password is needed." |
|
|
|
elif cmd2 == 'addresses': |
|
|
|
print "show your list of addresses. options: -a, -k, -b" |
|
|
|
elif cmd2 == 'history': |
|
|
@ -351,10 +361,6 @@ if __name__ == '__main__': |
|
|
|
r, h = wallet.sendtx( tx ) |
|
|
|
print h |
|
|
|
|
|
|
|
elif cmd == 'newaddress': |
|
|
|
s, a = wallet.get_new_address() |
|
|
|
print a |
|
|
|
|
|
|
|
elif cmd == 'password': |
|
|
|
try: |
|
|
|
seed = wallet.pw_decode( wallet.seed, password) |
|
|
|