public static Credentials loadCredentials(String password, String source) throws IOException, CipherException { return loadCredentials(password, new File(source)); }
private void testGeneratedNewWalletFile(String fileName) throws Exception { WalletUtils.loadCredentials(PASSWORD, new File(tempDir, fileName)); }
private Credentials loadWalletFile(File walletFile) { while (true) { char[] password = console.readPassword( "Please enter your existing wallet file password: "); String currentPassword = new String(password); try { return WalletUtils.loadCredentials(currentPassword, walletFile); } catch (CipherException e) { console.printf("Invalid password specified\n"); } catch (IOException e) { exitError("Unable to load wallet file: " + walletFile + "\n" + e.getMessage()); } } } }
private void testGenerateWalletFile(String fileName) throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, new File(tempDir, fileName)); assertThat(credentials, equalTo(CREDENTIALS)); }
@Test public void testLoadCredentialsFromString() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, WalletUtilsTest.class.getResource( "/keyfiles/" + "UTC--2016-11-03T05-55-06." + "340672473Z--ef678007d18427e6022059dbc264f27507cd1ffc").getFile()); assertThat(credentials, equalTo(CREDENTIALS)); }
@Test public void testLoadCredentialsFromFile() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, new File(WalletUtilsTest.class.getResource( "/keyfiles/" + "UTC--2016-11-03T05-55-06." + "340672473Z--ef678007d18427e6022059dbc264f27507cd1ffc") .getFile())); assertThat(credentials, equalTo(CREDENTIALS)); }
@Ignore // enable if users need to work with MyEtherWallet @Test public void testLoadCredentialsMyEtherWallet() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, new File(WalletUtilsTest.class.getResource( "/keyfiles/" + "UTC--2016-11-03T07-47-45." + "988Z--4f9c1a1efaa7d81ba1cabf07f2c3a5ac5cf4f818").getFile())); assertThat(credentials, equalTo( Credentials.create( "6ca4203d715e693279d6cd9742ad2fb7a3f6f4abe27a64da92e0a70ae5d859c9"))); }
public EthereumTestPaymentService(Web3j web3j, String walletPassword, String walletPath) throws IOException, CipherException { this.credentials = WalletUtils.loadCredentials(walletPassword, walletPath); this.web3j = web3j; }
public EthereumAuth(String walletPassword, String walletFilePath) throws Exception { walletCredentials = WalletUtils.loadCredentials(walletPassword, walletFilePath); }
public EthereumAuth(String walletPassword, File wallet) throws Exception { walletCredentials = WalletUtils.loadCredentials(walletPassword, wallet); }
/** * loadCredentials function is used to load the UTC-JSON file from a particular path. * @param password is used to access your UTC-JSON file. * @throws IOException * @throws CipherException */ public static void loadCredentials(String password) throws IOException, CipherException { credentials = WalletUtils.loadCredentials(password, Environment.getExternalStorageDirectory().getAbsolutePath() + "/UTC--2017-08-21T11-49-30.013Z--8c17ea160c092ae854f81580396ba570d9e62e24.json"); }
public PaperWallet(String passPhrase, File walletFile) { // check if provided file exists if(!walletFile.exists() || walletFile.isDirectory()) { System.err.println(String.format("%s file does not exist or is a directory", WALLET_ERROR)); } try { credentials = WalletUtils.loadCredentials(passPhrase, walletFile); } catch (Exception e) { System.err.println(String.format("%s failed to load credentials with provided password", WALLET_ERROR)); } }
private void unlockCredentials(String password, String fileSource) throws EthereumException { try { this.credentials = WalletUtils.loadCredentials(password, fileSource); } catch (IOException | CipherException e) { final String msg = "Error occurred while setting the user credentials for Ethereum. Reason: " + e.getMessage(); log.error(msg); throw new EthereumException(msg, e); } }
public EthereumAuth(String walletPassword, String walletFileName, ClassLoader classLoader) throws Exception { walletCredentials = WalletUtils.loadCredentials(walletPassword, EthereumUtils.createTmpFile(classLoader.getResourceAsStream(walletFileName))); }
public Credentials getCredentials(String passPhrase) throws Exception { if (credentials != null) { return credentials; } try { String fileWithPath = getFile().getAbsolutePath(); credentials = WalletUtils.loadCredentials(passPhrase, fileWithPath); return credentials; } catch (Exception e) { throw new Exception ("Failed to access credentials in file '" + getFile().getAbsolutePath() + "'", e); } }
/** * 导出私钥 * * @param keystorePath 账号的keystore路径 * @param password 密码 */ private static void exportPrivateKey(String keystorePath, String password) { try { Credentials credentials = WalletUtils.loadCredentials( password, keystorePath); BigInteger privateKey = credentials.getEcKeyPair().getPrivateKey(); System.out.println(privateKey.toString(16)); } catch (IOException | CipherException e) { e.printStackTrace(); } }