def test_read_dictionary_from_file(self): some_dict = {"a":"b", "c":"d"} contents = json.dumps(some_dict) with open(self.wallet_path, "w") as f: contents = f.write(contents) storage = WalletStorage(self.wallet_path, manual_upgrades=True) self.assertEqual("b", storage.get("a")) self.assertEqual("d", storage.get("c"))
def test_read_dictionnary_from_file(self): some_dict = {"a":"b", "c":"d"} contents = repr(some_dict) with open(self.wallet_path, "w") as f: contents = f.write(contents) storage = WalletStorage(self.wallet_path) self.assertEqual("b", storage.get("a")) self.assertEqual("d", storage.get("c"))
def test_read_dictionnary_from_file(self): some_dict = {"a": "b", "c": "d"} contents = repr(some_dict) with open(self.wallet_path, "w") as f: contents = f.write(contents) storage = WalletStorage(self.wallet_path) self.assertEqual("b", storage.get("a")) self.assertEqual("d", storage.get("c"))
def init_cmdline(config_options, server): config = SimpleConfig(config_options) cmdname = config.get('cmd') cmd = known_commands[cmdname] if cmdname == 'signtransaction' and config.get('privkey'): cmd.requires_wallet = False cmd.requires_password = False if cmdname in ['payto', 'paytomany'] and config.get('unsigned'): cmd.requires_password = False if cmdname in ['payto', 'paytomany'] and config.get('broadcast'): cmd.requires_network = True # instantiate wallet for command-line storage = WalletStorage(config.get_wallet_path()) if cmd.requires_wallet and not storage.file_exists(): print_msg("Error: Wallet file not found.") print_msg( "Type 'electrum create' to create a new wallet, or provide a path to a wallet with the -w option" ) sys.exit(0) # important warning if cmd.name in ['getprivatekeys']: print_stderr("WARNING: ALL your private keys are secret.") print_stderr( "Exposing a single private key can compromise your entire wallet!") print_stderr( "In particular, DO NOT use 'redeem private key' services proposed by third parties." ) # commands needing password if (cmd.requires_wallet and storage.is_encrypted() and server is None)\ or (cmd.requires_password and (storage.get('use_encryption') or storage.is_encrypted())): if storage.is_encrypted_with_hw_device(): # this case is handled later in the control flow password = None elif config.get('password'): password = config.get('password') else: password = prompt_password('Password:'******'password'] = config_options.get('password') or password if cmd.name == 'password': new_password = prompt_password('New password:'******'new_password'] = new_password