Java Code Examples for net.bither.bitherj.qrcode.QRCodeUtil#getNewVersionEncryptPrivKey()
The following examples show how to use
net.bither.bitherj.qrcode.QRCodeUtil#getNewVersionEncryptPrivKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpgradeAddressUtil.java From bitherj with Apache License 2.0 | 5 votes |
private static List<Address> initPrivateKeyListByDesc() { List<Address> privKeyAddresses = new ArrayList<Address>(); File[] files = Utils.getPrivateDir().listFiles(); if (files != null) { for (File file : files) { if (file.getName().contains(Address.PUBLIC_KEY_FILE_NAME_SUFFIX)) { String content = Utils.readFile(file); String[] strings = content.split(Address.KEY_SPLIT_STRING); String address = file.getName().substring(0, file.getName().length() - Address.PUBLIC_KEY_FILE_NAME_SUFFIX.length()); String publicKey = strings[0]; int isSyncComplete = Integer.valueOf(strings[1]); long sortTime = Long.valueOf(strings[2]); boolean isFromXRandom = false; if (strings.length == 4) { isFromXRandom = Utils.compareString(strings[3], QRCodeUtil.XRANDOM_FLAG); } String privateKeyFullFileName = Utils.format(BitherjSettings .PRIVATE_KEY_FILE_NAME, Utils.getPrivateDir(), address); String encryptPrivate = QRCodeUtil.getNewVersionEncryptPrivKey(Utils.readFile(new File(privateKeyFullFileName))); encryptPrivate = PrivateKeyUtil.formatEncryptPrivateKeyForDb(encryptPrivate); Address add = new Address(address, Utils.hexStringToByteArray(publicKey), sortTime , isSyncComplete == 1, isFromXRandom, false, encryptPrivate); privKeyAddresses.add(add); } } if (privKeyAddresses.size() > 0) { Collections.sort(privKeyAddresses); } } return privKeyAddresses; }
Example 2
Source File: UpgradeAddressUtil.java From bitherj with Apache License 2.0 | 5 votes |
private static List<Address> initTrashListByDesc() { File[] files = Utils.getTrashDir().listFiles(); List<Address> trashAddresses = new ArrayList<Address>(); if (files != null) { for (File file : files) { if (file.getName().contains(Address.PUBLIC_KEY_FILE_NAME_SUFFIX)) { String content = Utils.readFile(file); String[] strings = content.split(Address.KEY_SPLIT_STRING); String address = file.getName().substring(0, file.getName().length() - Address.PUBLIC_KEY_FILE_NAME_SUFFIX.length()); String publicKey = strings[0]; int isSyncComplete = Integer.valueOf(strings[1]); long sortTime = Long.valueOf(strings[2]); boolean isFromXRandom = false; if (strings.length == 4) { isFromXRandom = Utils.compareString(strings[3], QRCodeUtil.XRANDOM_FLAG); } String privateKeyFullFileName = Utils.format(BitherjSettings .PRIVATE_KEY_FILE_NAME, Utils.getTrashDir(), address); String encryptPrivate = QRCodeUtil.getNewVersionEncryptPrivKey(Utils.readFile(new File(privateKeyFullFileName))); encryptPrivate = PrivateKeyUtil.formatEncryptPrivateKeyForDb(encryptPrivate); Address add = new Address(address, Utils.hexStringToByteArray(publicKey), sortTime , isSyncComplete == 1, isFromXRandom, true, encryptPrivate); add.setTrashed(true); trashAddresses.add(add); } } if (trashAddresses.size() > 0) { Collections.sort(trashAddresses); } } return trashAddresses; }
Example 3
Source File: ImportPrivateKey.java From bitherj with Apache License 2.0 | 5 votes |
private Address addECKey(ECKey ecKey) { String encryptedPrivateString; if (importPrivateKeyType == ImportPrivateKeyType.BitherQrcode) { encryptedPrivateString = QRCodeUtil.getNewVersionEncryptPrivKey(content); } else { ecKey = PrivateKeyUtil.encrypt(ecKey, password); encryptedPrivateString = PrivateKeyUtil.getEncryptedString(ecKey); } Address address = new Address(ecKey.toAddress(), ecKey.getPubKey(), encryptedPrivateString , false, ecKey.isFromXRandom()); if (AddressManager.getInstance().getWatchOnlyAddresses().contains(address)) { password.wipe(); importError(CAN_NOT_IMPORT_BITHER_COLD_PRIVATE_KEY); return null; } else if (AddressManager.getInstance().getPrivKeyAddresses().contains(address)) { password.wipe(); importError(PRIVATE_KEY_ALREADY_EXISTS); return null; } else { if (importPrivateKeyType == ImportPrivateKeyType.BitherQrcode) { PasswordSeed passwordSeed = PasswordSeed.getPasswordSeed(); if (passwordSeed != null && !passwordSeed.checkPassword(password)) { password.wipe(); importError(PASSWORD_IS_DIFFEREND_LOCAL); return null; } } else { password.wipe(); } return address; } }
Example 4
Source File: PasswordSeed.java From bitherj with Apache License 2.0 | 5 votes |
public String toPasswordSeedString() { try { String passwordSeedString = Base58.bas58ToHexWithAddress(this.address) + QRCodeUtil.QR_CODE_SPLIT + QRCodeUtil.getNewVersionEncryptPrivKey(this.keyStr); return passwordSeedString; } catch (AddressFormatException e) { throw new RuntimeException("passwordSeed address is format error ," + this.address); } }