@Test public void importMnemonic() { String m = "victory truck motion urge loyal supply pipe ship assume code where hub"; Wallet wallet = WalletManager.importWalletFromMnemonic( new Metadata(ChainType.ETHEREUM, Network.MAINNET, "name", "passwordHint"), m, BIP44Util.ETHEREUM_PATH, SampleKey.PASSWORD, true); assertEquals(wallet.getAddress(), "30ee43ceea07f72511eb8b94eb1cacc4e21f0239"); assertEquals(wallet.hasMnemonic(), true); m = "attack curtain frog balcony trash base twenty history cradle cruel illness attitude"; wallet = WalletManager.importWalletFromMnemonic( new Metadata(ChainType.BITCOIN, Network.TESTNET, "name", "passwordHint"), m, BIP44Util.BITCOIN_TESTNET_PATH, SampleKey.PASSWORD, true); assertEquals(wallet.getAddress(), "ms8xH9qe3rg4DPHJty5baTT8teTMQNsZFT"); assertEquals(wallet.hasMnemonic(), true); wallet.delete(SampleKey.PASSWORD); try { m = "attack curtain frog balcony trash base twenty history cradle cruel illness attitud"; wallet = WalletManager.importWalletFromMnemonic( new Metadata(ChainType.BITCOIN, Network.MAINNET, "name", "passwordHint"), m, BIP44Util.BITCOIN_MAINNET_PATH, SampleKey.PASSWORD, true); assertEquals("1", "2"); } catch (Exception ex) { assertEquals(ex.getMessage(), Messages.MNEMONIC_BAD_WORD); } }
public static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite) { if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_MNEMONIC); IMTKeystore keystore = null; List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" ")); MnemonicUtil.validateMnemonics(mnemonicCodes); switch (metadata.getChainType()) { case ChainType.ETHEREUM: keystore = V3MnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.BITCOIN: keystore = HDMnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.EOS: keystore = EOSKeystore.create(metadata, password, accountName, mnemonicCodes, path, permissions); } return persistWallet(keystore, overwrite); }
WalletManager { public static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite) { if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_MNEMONIC); IMTKeystore keystore = null; List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" ")); MnemonicUtil.validateMnemonics(mnemonicCodes); switch (metadata.getChainType()) { case ChainType.ETHEREUM: keystore = V3MnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.BITCOIN: keystore = HDMnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.EOS: keystore = EOSKeystore.create(metadata, password, accountName, mnemonicCodes, path, permissions); } return persistWallet(keystore, overwrite); } }
WalletManager { public static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite) { if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_MNEMONIC); IMTKeystore keystore = null; List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" ")); MnemonicUtil.validateMnemonics(mnemonicCodes); switch (metadata.getChainType()) { case ChainType.ETHEREUM: keystore = V3MnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.BITCOIN: keystore = HDMnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.EOS: keystore = EOSKeystore.create(metadata, password, accountName, mnemonicCodes, path, permissions); } return persistWallet(keystore, overwrite); } private  WalletManager(); }
WalletManager { public static Wallet importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite) { if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_MNEMONIC); IMTKeystore keystore = null; List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" ")); MnemonicUtil.validateMnemonics(mnemonicCodes); switch (metadata.getChainType()) { case ChainType.ETHEREUM: keystore = V3MnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.BITCOIN: keystore = HDMnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.EOS: keystore = EOSKeystore.create(metadata, password, accountName, mnemonicCodes, path, permissions); } return persistWallet(keystore, 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 importWalletFromMnemonic(Metadata metadata, @Nullable String accountName, String mnemonic, String path, @Nullable List<EOSKeystore.PermissionObject> permissions, String password, boolean overwrite) { if (metadata.getSource() == null) metadata.setSource(Metadata.FROM_MNEMONIC); IMTKeystore keystore = null; List<String> mnemonicCodes = Arrays.asList(mnemonic.split(" ")); MnemonicUtil.validateMnemonics(mnemonicCodes); switch (metadata.getChainType()) { case ChainType.ETHEREUM: keystore = V3MnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.BITCOIN: keystore = HDMnemonicKeystore.create(metadata, password, mnemonicCodes, path); break; case ChainType.EOS: keystore = EOSKeystore.create(metadata, password, accountName, mnemonicCodes, path, permissions); } return persistWallet(keystore, 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; }