use of org.bcos.web3j.crypto.CipherException in project web3sdk by FISCO-BCOS.
the class WalletUpdater method run.
private void run(String walletFileLocation) {
File walletFile = new File(walletFileLocation);
Credentials credentials = getCredentials(walletFile);
console.printf("Wallet for address " + credentials.getAddress() + " loaded\n");
String newPassword = getPassword("Please enter a new wallet file password: ");
String destinationDir = getDestinationDir();
File destination = createDir(destinationDir);
try {
String walletFileName = WalletUtils.generateWalletFile(newPassword, credentials.getEcKeyPair(), destination, true);
console.printf("New wallet file " + walletFileName + " successfully created in: " + destinationDir + "\n");
} catch (CipherException | IOException e) {
exitError(e);
}
String delete = console.readLine("Would you like to delete your existing wallet file (Y/N)? [N]: ");
if (delete.toUpperCase().equals("Y")) {
if (!walletFile.delete()) {
exitError("Unable to remove wallet file\n");
} else {
console.printf("Deleted previous wallet file: %s\n", walletFile.getName());
}
}
}
use of org.bcos.web3j.crypto.CipherException in project web3sdk by FISCO-BCOS.
the class KeyImporter method createWalletFile.
private void createWalletFile(String privateKey) {
if (!WalletUtils.isValidPrivateKey(privateKey)) {
exitError("Invalid private key specified, must be " + PRIVATE_KEY_LENGTH_IN_HEX + " digit hex value");
}
Credentials credentials = Credentials.create(privateKey);
String password = getPassword("Please enter a wallet file password: ");
String destinationDir = getDestinationDir();
File destination = createDir(destinationDir);
try {
String walletFileName = WalletUtils.generateWalletFile(password, credentials.getEcKeyPair(), destination, true);
console.printf("Wallet file " + walletFileName + " successfully created in: " + destinationDir + "\n");
} catch (CipherException | IOException e) {
exitError(e);
}
}
use of org.bcos.web3j.crypto.CipherException in project web3sdk by FISCO-BCOS.
the class WalletCreator method run.
private void run() {
String password = getPassword("Please enter a wallet file password: ");
String destinationDir = getDestinationDir();
File destination = createDir(destinationDir);
try {
String walletFileName = WalletUtils.generateFullNewWalletFile(password, destination);
console.printf("Wallet file " + walletFileName + " successfully created in: " + destinationDir + "\n");
} catch (CipherException | IOException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchProviderException e) {
Console.exitError(e);
}
}
Aggregations