def create_wallet(): """ Create an electrum wallet if it does not exist :return: """ if not os.path.isfile(WALLET_FILE): print("Creating wallet") config = electrum.SimpleConfig() storage = WalletStorage(config.get_wallet_path()) passphrase = config.get('passphrase', '') seed = Mnemonic('en').make_seed() k = keystore.from_seed(seed, passphrase) k.update_password(None, None) storage.put('keystore', k.dump()) storage.put('wallet_type', 'standard') storage.put('use_encryption', False) storage.write() wallet = ElectrumWallet(storage) wallet.synchronize() print("Your wallet generation seed is:\n\"%s\"" % seed) print( "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet." ) wallet.storage.write() print("Wallet saved in '%s'" % wallet.storage.path) else: print("Wallet already present")