net.bither.bitherj.crypto.KeyCrypterException Java Examples

The following examples show how to use net.bither.bitherj.crypto.KeyCrypterException. 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: PrivateKeyUtil.java    From bitherj with Apache License 2.0 6 votes vote down vote up
/**
 * will release key
 *
 * @param key
 * @param password
 * @return
 */
public static ECKey encrypt(ECKey key, CharSequence password) {
    KeyCrypter scrypt = new KeyCrypterScrypt();
    KeyParameter derivedKey = scrypt.deriveKey(password);
    ECKey encryptedKey = key.encrypt(scrypt, derivedKey);

    // Check that the encrypted key can be successfully decrypted.
    // This is done as it is a critical failure if the private key cannot be decrypted successfully
    // (all bitcoin controlled by that private key is lost forever).
    // For a correctly constructed keyCrypter the encryption should always be reversible so it is just being as cautious as possible.
    if (!ECKey.encryptionIsReversible(key, encryptedKey, scrypt, derivedKey)) {
        // Abort encryption
        throw new KeyCrypterException("The key " + key.toString() + " cannot be successfully decrypted after encryption so aborting wallet encryption.");
    }
    key.clearPrivateKey();
    return encryptedKey;
}
 
Example #2
Source File: HDAccountSendPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) Bither.getActionAddress();
    SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword());
    try {
        tx = account.newTx(toAddress, btcAmount, password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = LocaliserUtils.getString("send_failed");
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = LocaliserUtils.getString("password_wrong");
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                dp.dispose();
                new MessageDialog(m).showMsg();
            }
        });
    } finally {
        password.wipe();
    }
    if (tx != null) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #3
Source File: BCCAssetsHDAccountMonitoredActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    this.txs = null;
    HDAccount account = (HDAccount) address;
    try {
        txs = account.newForkTx(toAddress, btcAmount,outs, SplitCoin.BCC);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(BCCAssetsHDAccountMonitoredActivity.this, m);
            }
        });
    }

    if (this.txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #4
Source File: BCCAssetsDetectHDActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    txs = null;
    HDAccount account = (HDAccount) address;
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    try {
        txs = account.extractBcc(etAddress.getText().toString().trim(), getAmount(outs), outs, path, index, password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(BCCAssetsDetectHDActivity.this, m);
            }
        });
    } finally {
        password.wipe();
    }
    if (txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();

            }
        });
    }
}
 
Example #5
Source File: SplitBCCHDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    this.txs = null;
    HDAccount account = (HDAccount) address;
    try {
        txs = account.newForkTx(toAddress, btcAmount, splitCoin);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this, m);
            }
        });
    }

    if (this.txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #6
Source File: HDAccountSendPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) Bither.getActionAddress();
    SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword());
    try {
        tx = account.newTx(toAddress, btcAmount, password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = LocaliserUtils.getString("send_failed");
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = LocaliserUtils.getString("password_wrong");
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                dp.dispose();
                new MessageDialog(m).showMsg();
            }
        });
    } finally {
        password.wipe();
    }
    if (tx != null) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #7
Source File: SplitBCCHDAccountSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send(String...blockhash) {
    txs = null;
    HDAccount account = (HDAccount) address;
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    try {
        txs = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password, splitCoin,blockhash);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, m);
            }
        });
    } finally {
        password.wipe();
    }
    if (txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();

            }
        });
    }
}
 
Example #8
Source File: EnterpriseHDMSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    String changeTo = getChangeAddress();
    try {
        tx = address.buildTx(btcAmount, toAddress, changeTo == null ? address.getAddress() : changeTo);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(EnterpriseHDMSendActivity.this, m);
            }
        });
    }
    if (tx != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #9
Source File: HDAccount.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public void decryptMnemonicSeed(CharSequence password) throws KeyCrypterException {
    if (hdSeedId < 0) {
        return;
    }
    String encrypted = getEncryptedMnemonicSeed();
    if (!Utils.isEmpty(encrypted)) {
        mnemonicSeed = new EncryptedData(encrypted).decrypt(password);
    }
}
 
Example #10
Source File: HDAccountSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) address;
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    try {
        tx = account.newTx(toAddress, btcAmount, AppSharedPreference.getInstance().isSegwitAddressType(), password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(HDAccountSendActivity.this, m);
            }
        });
    } finally {
        password.wipe();
    }
    if (tx != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #11
Source File: PrivateKeyUtil.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public static String changePassword(String str, CharSequence oldpassword, CharSequence newPassword) {
    String[] strs = QRCodeUtil.splitOfPasswordSeed(str);
    if (strs.length != 3) {
        log.error("change Password: PrivateKeyFromString format error");
        return null;
    }

    byte[] temp = Utils.hexStringToByteArray(strs[2]);
    if (temp.length != KeyCrypterScrypt.SALT_LENGTH + 1 && temp.length != KeyCrypterScrypt.SALT_LENGTH) {
        log.error("decryption:  salt lenth is {} not {}", temp.length, KeyCrypterScrypt.SALT_LENGTH + 1);
        return null;
    }
    byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
    if (temp.length == KeyCrypterScrypt.SALT_LENGTH) {
        salt = temp;
    } else {
        System.arraycopy(temp, 1, salt, 0, salt.length);
    }
    KeyCrypterScrypt crypter = new KeyCrypterScrypt(salt);
    EncryptedPrivateKey epk = new EncryptedPrivateKey(Utils.hexStringToByteArray
            (strs[1]), Utils.hexStringToByteArray(strs[0]));

    byte[] decrypted = crypter.decrypt(epk, crypter.deriveKey(oldpassword));
    EncryptedPrivateKey encryptedPrivateKey = crypter.encrypt(decrypted, crypter.deriveKey(newPassword));
    byte[] newDecrypted = crypter.decrypt(encryptedPrivateKey, crypter.deriveKey(newPassword));
    if (!Arrays.equals(decrypted, newDecrypted)) {
        throw new KeyCrypterException("change Password, cannot be successfully decrypted after encryption so aborting wallet encryption.");
    }
    Utils.wipeBytes(decrypted);
    Utils.wipeBytes(newDecrypted);
    return Utils.bytesToHexString(encryptedPrivateKey.getEncryptedBytes())
            + QRCodeUtil.QR_CODE_SPLIT + Utils.bytesToHexString(encryptedPrivateKey.getInitialisationVector())
            + QRCodeUtil.QR_CODE_SPLIT + strs[2];

}
 
Example #12
Source File: DeterministicKey.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@Override
public DeterministicKey decrypt(KeyCrypter keyCrypter, KeyParameter aesKey) throws KeyCrypterException {
    checkNotNull(keyCrypter);
    // Check that the keyCrypter matches the one used to encrypt the keys, if set.
    if (this.keyCrypter != null && !this.keyCrypter.equals(keyCrypter))
        throw new KeyCrypterException("The keyCrypter being used to decrypt the key is different to the one that was used to encrypt it");
    BigInteger privKey = findOrDeriveEncryptedPrivateKey(keyCrypter, aesKey);
    DeterministicKey key = new DeterministicKey(childNumberPath, chainCode, privKey, parent);
    if (!Arrays.equals(key.getPubKey(), getPubKey()))
        throw new KeyCrypterException("Provided AES key is wrong");
    return key;
}
 
Example #13
Source File: DeterministicKey.java    From bitherj with Apache License 2.0 5 votes vote down vote up
private BigInteger findOrDeriveEncryptedPrivateKey(KeyCrypter keyCrypter, KeyParameter aesKey) {
    if (encryptedPrivateKey != null)
        return new BigInteger(1, keyCrypter.decrypt(encryptedPrivateKey, aesKey));
    // Otherwise we don't have it, but maybe we can figure it out from our parents. Walk up the tree looking for
    // the first key that has some encrypted private key data.
    DeterministicKey cursor = parent;
    while (cursor != null) {
        if (cursor.encryptedPrivateKey != null) break;
        cursor = cursor.parent;
    }
    if (cursor == null)
        throw new KeyCrypterException("Neither this key nor its parents have an encrypted private key");
    byte[] parentalPrivateKeyBytes = keyCrypter.decrypt(cursor.encryptedPrivateKey, aesKey);
    return derivePrivateKeyDownwards(cursor, parentalPrivateKeyBytes);
}
 
Example #14
Source File: AbstractHD.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public void decryptMnemonicSeed(CharSequence password) throws KeyCrypterException {
    if (hdSeedId < 0) {
        return;
    }
    String encrypted = getEncryptedMnemonicSeed();
    if (!Utils.isEmpty(encrypted)) {
        mnemonicSeed = new EncryptedData(encrypted).decrypt(password);
    }
}
 
Example #15
Source File: SendHDMBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@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 #16
Source File: HDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 4 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) address;
    try {
        boolean isSegwitChangeAddress = AppSharedPreference.getInstance().isSegwitAddressType();
        if (isSegwitChangeAddress) {
            if (address instanceof HDAccount && ((HDAccount) address).getExternalPub(AbstractHD.PathType.EXTERNAL_BIP49_PATH) == null) {
                isSegwitChangeAddress = false;
            }
        }
        tx = account.newTx(toAddress, btcAmount, isSegwitChangeAddress);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(HDAccountMonitoredSendActivity.this, m);
            }
        });
    }
    if (tx != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #17
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 4 votes vote down vote up
@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 #18
Source File: SendHDMBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@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;
}