1 import electrum, getpass, base64,ast,sys,os
2 from version import SEED_VERSION
7 if __name__ == "__main__":
11 # backward compatibility: look for wallet file in the default data directory
12 if "HOME" in os.environ:
13 wallet_dir = os.path.join( os.environ["HOME"], '.electrum')
14 elif "LOCALAPPDATA" in os.environ:
15 wallet_dir = os.path.join( os.environ["LOCALAPPDATA"], 'Electrum' )
16 elif "APPDATA" in os.environ:
17 wallet_dir = os.path.join( os.environ["APPDATA"], 'Electrum' )
19 raise BaseException("No home directory found in environment variables.")
20 path = os.path.join( wallet_dir, 'electrum.dat')
27 print "file not found", path
31 x = ast.literal_eval(data)
33 print "error: could not parse wallet"
36 # version <= 0.33 uses a tuple
38 seed_version, use_encryption, fee, host, port, blocks, seed, all_addresses, private_keys, change_indexes, status, history, labels, addressbook = x
40 print "walet path =",path
41 print "seed version =", seed_version
43 if seed_version == 1 and use_encryption:
44 # version 1 used pycrypto for wallet encryption
46 from Crypto.Cipher import AES
49 pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
50 EncodeAES = lambda secret, s: base64.b64encode(AES.new(secret).encrypt(pad(s)))
51 DecodeAES = lambda secret, e: AES.new(secret).decrypt(base64.b64decode(e)).rstrip(PADDING)
53 print "please enter your password"
54 password = getpass.getpass("Password:")
55 secret = electrum.Hash(password)
57 seed = DecodeAES( secret, wallet.seed )
58 private_keys = ast.literal_eval( DecodeAES( secret, wallet.private_keys ) )
63 s = repr( (seed_version, use_encryption, fee, host, port, blocks, seed, all_addresses, private_keys, change_indexes, status, history, labels, addressbook ))
67 print "Wallet is now unencrypted."
69 print """This wallet is deprecated.
70 Please create a new wallet, open the old wallet with Electrum 0.33, and send your coins to your new wallet.
71 We apologize for the inconvenience. We try to keep this kind of upgrades as rare as possible."""