net.bither.bitherj.core.HDMBId Java Examples

The following examples show how to use net.bither.bitherj.core.HDMBId. 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: HotAdvanceActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void configureHDMServerPasswordReset() {
    if (HDMBId.getHDMBidFromDb() == null) {
        btnHDMServerPasswordReset.setVisibility(View.GONE);
    } else {
        btnHDMServerPasswordReset.setVisibility(View.VISIBLE);
    }
}
 
Example #2
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 #3
Source File: IAddressProvider.java    From bitherj with Apache License 2.0 votes vote down vote up
HDMBId getHDMBId(); 
Example #4
Source File: IAddressProvider.java    From bitherj with Apache License 2.0 votes vote down vote up
void addAndUpdateHDMBId(HDMBId bitherId, String addressOfPS);