net.bither.bitherj.exception.PasswordException Java Examples
The following examples show how to use
net.bither.bitherj.exception.PasswordException.
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: Address.java From bitherj with Apache License 2.0 | 6 votes |
public List<byte[]> signHashes(List<byte[]> unsignedInHashes, CharSequence passphrase) throws PasswordException { ECKey key = PrivateKeyUtil.getECKeyFromSingleString(this.getFullEncryptPrivKey(), passphrase); if (key == null) { throw new PasswordException("do not decrypt eckey"); } KeyParameter assKey = key.getKeyCrypter().deriveKey(passphrase); List<byte[]> result = new ArrayList<byte[]>(); for (byte[] unsignedInHash : unsignedInHashes) { TransactionSignature signature = new TransactionSignature(key.sign(unsignedInHash, assKey), TransactionSignature.SigHash.ALL, false); result.add(ScriptBuilder.createInputScript(signature, key).getProgram()); } key.clearPrivateKey(); return result; }
Example #2
Source File: CompleteTransactionRunnable.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return LocaliserUtils.getString("password_wrong"); } else { return LocaliserUtils.getString("send_failed"); } }
Example #3
Source File: CompleteTransactionRunnable.java From bither-android with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return BitherApplication.mContext.getString(R.string.password_wrong); } else if (e != null && e instanceof HDMServerSignException) { return e.getMessage(); } else { return BitherApplication.mContext.getString(R.string.send_failed); } }
Example #4
Source File: CompleteTransactionRunnable.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return LocaliserUtils.getString("password_wrong"); } else { return LocaliserUtils.getString("send_failed"); } }
Example #5
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(LocaliserUtils.getString("hdm_reset_server_password_password_wrong_confirm"), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }); dialogConfirmTask.pack(); dialogConfirmTask.setVisible(true); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(LocaliserUtils.getString( "hdm_address_sign_tx_server_error")); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }
Example #6
Source File: HdmSendActivity.java From bither-android with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); runOnUiThread(new Runnable() { @Override public void run() { if (dp.isShowing()) { dp.dismiss(); } new DialogConfirmTask(HdmSendActivity.this, getString(R.string.hdm_reset_server_password_password_wrong_confirm), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }).show(); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(R.string .hdm_address_sign_tx_server_error); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }
Example #7
Source File: HDMAddress.java From bitherj with Apache License 2.0 | 4 votes |
@Override public List<byte[]> signHashes(List<byte[]> unsignedInHashes, CharSequence passphrase) throws PasswordException { throw new RuntimeException("hdm address can't sign transactions all by self"); }
Example #8
Source File: Address.java From bitherj with Apache License 2.0 | 4 votes |
public String signMessage(String msg, CharSequence passphrase) { ECKey key = PrivateKeyUtil.getECKeyFromSingleString(this.getFullEncryptPrivKey(), passphrase); if (key == null) { throw new PasswordException("do not decrypt eckey"); } KeyParameter assKey = key.getKeyCrypter().deriveKey(passphrase); String result = key.signMessage(msg, assKey); key.clearPrivateKey(); return result; }
Example #9
Source File: DesktopHDMAddress.java From bitherj with Apache License 2.0 | 4 votes |
@Override public List<byte[]> signHashes(List<byte[]> unsignedInHashes, CharSequence passphrase) throws PasswordException { throw new RuntimeException("hdm address can't sign transactions all by self"); }
Example #10
Source File: SendHDMBitcoinPanel.java From bither-desktop-java with Apache License 2.0 | 4 votes |
@Override public List<TransactionSignature> getOtherSignature(int addressIndex, CharSequence password, List<byte[]> unsignHash, Tx tx) { List<TransactionSignature> transactionSignatureList = new ArrayList<TransactionSignature>(); try { HDMBId hdmbId = HDMBId.getHDMBidFromDb(); byte[] decryptedPassword = hdmbId.decryptHDMBIdPassword(password); SignatureHDMApi signatureHDMApi = new SignatureHDMApi(HDMBId.getHDMBidFromDb() .getAddress(), addressIndex, decryptedPassword, unsignHash); signatureHDMApi.handleHttpPost(); List<byte[]> bytesList = signatureHDMApi.getResult(); for (byte[] bytes : bytesList) { TransactionSignature transactionSignature = new TransactionSignature(ECKey .ECDSASignature.decodeFromDER(bytes), TransactionSignature.SigHash .ALL, false); transactionSignatureList.add(transactionSignature); } } catch (Exception e) { if (e instanceof Http400Exception) { if (((Http400Exception) e).getErrorCode() == HttpSetting.PasswordWrong) { toChangePassword = false; final ReentrantLock lock = new ReentrantLock(); final Condition changePasswordCondition = lock.newCondition(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(LocaliserUtils.getString("hdm_reset_server_password_password_wrong_confirm"), new Runnable() { @Override public void run() { toChangePassword = true; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }, new Runnable() { @Override public void run() { toChangePassword = false; try { lock.lock(); changePasswordCondition.signal(); } finally { lock.unlock(); } } }); dialogConfirmTask.pack(); dialogConfirmTask.setVisible(true); } }); try { lock.lock(); changePasswordCondition.awaitUninterruptibly(); } finally { lock.unlock(); } if (!toChangePassword) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } resetServerPasswordUtil.setPassword(password); if (!resetServerPasswordUtil.changePassword()) { throw new CompleteTransactionRunnable.HDMSignUserCancelExcetion(); } return getOtherSignature(addressIndex, password, unsignHash, tx); } else { throw new CompleteTransactionRunnable.HDMServerSignException(LocaliserUtils.getString( "hdm_address_sign_tx_server_error")); } } else if (e instanceof KeyCrypterException) { throw new PasswordException("hdm password decrypting error"); } else { throw new RuntimeException(e); } } return transactionSignatureList; }