def do_wallet_generate(args): """Generate a new wallet.""" print("Generating new wallet...") w = Wallet() w.create_keys() w.save_key(args.filepath) print(f"New wallet successfully saved at {args.filepath}")
def test_save_and_load_key(self): # Create a temporary directory self.test_dir = tempfile.mkdtemp() self.test_file = path.join(self.test_dir, "test.pem") t = Wallet() t.create_keys() t.save_key(self.test_file) t2 = Wallet.load_keys(self.test_file) self.assertIsNotNone(t.get_address()) self.assertIsNotNone(t2.get_address()) self.assertEqual(t2.get_address(), t.get_address()) shutil.rmtree(self.test_dir)
def generate_wallet(self): """Generate a new wallet.""" w = Wallet() w.create_keys() first_free_count = 1 while True: path = f"webwallet_{first_free_count}.wallet" if not os.path.exists(path): break first_free_count += 1 # save wallet to disk w.save_key(path) # save wallet to memory self.wallets[path] = w