@Test public void importKeyStore() { Wallet wallet = WalletManager.importWalletFromKeystore( new Metadata(ChainType.ETHEREUM, Network.MAINNET, "name", "passwordHint"), V3Json, mPassword, true); assertEquals(wallet.verifyPassword(SampleKey.PASSWORD), false); assertEquals(wallet.verifyPassword(mPassword), true); assertEquals(wallet.getAddress(), address); assertEquals(wallet.hasMnemonic(), false); wallet.delete(mPassword); }
public static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite) { WalletKeystore importedKeystore = validateKeystore(keystoreContent, password); if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_KEYSTORE); String privateKey = NumericUtil.bytesToHex(importedKeystore.decryptCiphertext(password)); try { new PrivateKeyValidator(privateKey).validate(); } catch (TokenException ex) { if (Messages.PRIVATE_KEY_INVALID.equals(ex.getMessage())) { throw new TokenException(Messages.KEYSTORE_CONTAINS_INVALID_PRIVATE_KEY); } else { throw ex; } } return importWalletFromPrivateKey(metadata, privateKey, password, overwrite); }
WalletManager { public static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite) { WalletKeystore importedKeystore = validateKeystore(keystoreContent, password); if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_KEYSTORE); String privateKey = NumericUtil.bytesToHex(importedKeystore.decryptCiphertext(password)); try { new PrivateKeyValidator(privateKey).validate(); } catch (TokenException ex) { if (Messages.PRIVATE_KEY_INVALID.equals(ex.getMessage())) { throw new TokenException(Messages.KEYSTORE_CONTAINS_INVALID_PRIVATE_KEY); } else { throw ex; } } return importWalletFromPrivateKey(metadata, privateKey, password, overwrite); } }
WalletManager { public static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite) { WalletKeystore importedKeystore = validateKeystore(keystoreContent, password); if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_KEYSTORE); String privateKey = NumericUtil.bytesToHex(importedKeystore.decryptCiphertext(password)); try { new PrivateKeyValidator(privateKey).validate(); } catch (TokenException ex) { if (Messages.PRIVATE_KEY_INVALID.equals(ex.getMessage())) { throw new TokenException(Messages.KEYSTORE_CONTAINS_INVALID_PRIVATE_KEY); } else { throw ex; } } return importWalletFromPrivateKey(metadata, privateKey, password, overwrite); } private  WalletManager(); }
WalletManager { public static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite) { WalletKeystore importedKeystore = validateKeystore(keystoreContent, password); if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_KEYSTORE); String privateKey = NumericUtil.bytesToHex(importedKeystore.decryptCiphertext(password)); try { new PrivateKeyValidator(privateKey).validate(); } catch (TokenException ex) { if (Messages.PRIVATE_KEY_INVALID.equals(ex.getMessage())) { throw new TokenException(Messages.KEYSTORE_CONTAINS_INVALID_PRIVATE_KEY); } else { throw ex; } } return importWalletFromPrivateKey(metadata, privateKey, password, overwrite); } private  WalletManager(); static void changePassword(String id, String oldPassword, String newPassword); static String exportPrivateKey(String id, String password); static List<KeyPair> exportPrivateKeys(String id, String password); static MnemonicAndPath exportMnemonic(String id, String password); static String exportKeystore(String id, String password); static void removeWallet(String id, String password); static void clearKeystoreMap(); static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite); static Wallet importWalletFromPrivateKey(Metadata metadata, String prvKeyHex, String password, boolean overwrite); static Wallet importWalletFromPrivateKeys(Metadata metadata, String accountName, List<String> prvKeys, List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite); @Deprecated static Wallet importWalletFromPrivateKey(Metadata metadata, String accountName, String prvKeyHex, String password, boolean overwrite); static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite); static Wallet importWalletFromMnemonic(Metadata metadata, String mnemonic, String path, String password, boolean overwrite); static Wallet findWalletByPrivateKey(String chainType, String network, String privateKey, String segWit); static Wallet findWalletByKeystore(String chainType, String keystoreContent, String password); static Wallet findWalletByMnemonic(String chainType, String network, String mnemonic, String path, String segWit); static Wallet switchBTCWalletMode(String id, String password, String model); static Wallet setAccountName(String id, String accountName); static Wallet mustFindWalletById(String id); static Wallet findWalletByAddress(String type, String address); static void scanWallets(); }
WalletManager { public static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite) { WalletKeystore importedKeystore = validateKeystore(keystoreContent, password); if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_KEYSTORE); String privateKey = NumericUtil.bytesToHex(importedKeystore.decryptCiphertext(password)); try { new PrivateKeyValidator(privateKey).validate(); } catch (TokenException ex) { if (Messages.PRIVATE_KEY_INVALID.equals(ex.getMessage())) { throw new TokenException(Messages.KEYSTORE_CONTAINS_INVALID_PRIVATE_KEY); } else { throw ex; } } return importWalletFromPrivateKey(metadata, privateKey, password, overwrite); } private  WalletManager(); static void changePassword(String id, String oldPassword, String newPassword); static String exportPrivateKey(String id, String password); static List<KeyPair> exportPrivateKeys(String id, String password); static MnemonicAndPath exportMnemonic(String id, String password); static String exportKeystore(String id, String password); static void removeWallet(String id, String password); static void clearKeystoreMap(); static Wallet importWalletFromKeystore(Metadata metadata, String keystoreContent, String password, boolean overwrite); static Wallet importWalletFromPrivateKey(Metadata metadata, String prvKeyHex, String password, boolean overwrite); static Wallet importWalletFromPrivateKeys(Metadata metadata, String accountName, List<String> prvKeys, List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite); @Deprecated static Wallet importWalletFromPrivateKey(Metadata metadata, String accountName, String prvKeyHex, String password, boolean overwrite); static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite); static Wallet importWalletFromMnemonic(Metadata metadata, String mnemonic, String path, String password, boolean overwrite); static Wallet findWalletByPrivateKey(String chainType, String network, String privateKey, String segWit); static Wallet findWalletByKeystore(String chainType, String keystoreContent, String password); static Wallet findWalletByMnemonic(String chainType, String network, String mnemonic, String path, String segWit); static Wallet switchBTCWalletMode(String id, String password, String model); static Wallet setAccountName(String id, String accountName); static Wallet mustFindWalletById(String id); static Wallet findWalletByAddress(String type, String address); static void scanWallets(); static KeystoreStorage storage; }