Java Code Examples for net.bither.bitherj.crypto.SecureCharSequence#length()

The following examples show how to use net.bither.bitherj.crypto.SecureCharSequence#length() . 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: SplitBccColdWalletSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
    btcAmount = getAmount(AbstractDb.txProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(), address.getAddress()));
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 2
Source File: SplitBCCHDAccountSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
        btcAmount = getAmount(AbstractDb.hdAccountAddressProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(),
                AddressManager.getInstance().getHDAccountHot().getHdSeedId()));
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 3
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void validateValues() {
    boolean isValidAmounts = false;

    final BigInteger amount = BigInteger.valueOf(amountCalculatorLink.getAmount());

    if (amount == null) {
    } else if (amount.signum() > 0) {
        isValidAmounts = true;
    } else {
    }
    String address = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(address);
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    boolean isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
            password.length() <= getResources().getInteger(R.integer.password_length_max);
    password.wipe();
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 4
Source File: SplitBCCHDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
        btcAmount = AddressManager.getInstance().getAmount(AbstractDb.
                hdAccountAddressProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(),AddressManager.getInstance()
                .getHDAccountMonitored().getHdSeedId()));
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 5
Source File: SplitBCCSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
protected void validateValues() {
    boolean isValidAmounts = false;
    btcAmount = getAmount(AbstractDb.txProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(), address.getAddress()));
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 6
Source File: BCCAssetsDetectHDActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
    btcAmount = getAmount(outs);
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(toAddress);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 7
Source File: DialogPassword.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    tvError.setVisibility(View.GONE);
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    if (etPasswordConfirm.getVisibility() == View.VISIBLE) {
        SecureCharSequence pc = new SecureCharSequence(etPasswordConfirm.getText());
        if (pc.length() > 0) {
            if (!Utils.validPassword(pc)) {
                etPasswordConfirm.setText(passwordConfirm);
            }
        }
        pc.wipe();
    }
    checkValid();
    password.wipe();
    passwordConfirm.wipe();
}
 
Example 8
Source File: DialogPasswordWithOther.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    tvError.setVisibility(View.GONE);
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    if (etPasswordConfirm.getVisibility() == View.VISIBLE) {
        SecureCharSequence pc = new SecureCharSequence(etPasswordConfirm.getText());
        if (pc.length() > 0) {
            if (!Utils.validPassword(pc)) {
                etPasswordConfirm.setText(passwordConfirm);
            }
        }
        pc.wipe();
    }
    checkValid();
    password.wipe();
    passwordConfirm.wipe();
}
 
Example 9
Source File: SendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void validateValues() {
    boolean isValidAmounts = false;

    final BigInteger amount = BigInteger.valueOf(amountCalculatorLink.getAmount());

    if (amount == null) {
    } else if (amount.signum() > 0) {
        isValidAmounts = true;
    } else {
    }
    String address = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(address);
    if (isColdSendBtc && isValidAddress && Utils.validBech32Address(address)) {
        isValidAddress = false;
        DropdownMessage.showDropdownMessage(this, R.string.cold_no_support_bc1_segwit_address);
        etAddress.setText("");
    }
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
            password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 10
Source File: BCCAssetsDetectHotActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
protected void validateValues() {
    boolean isValidAmounts = false;
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(toAddress);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 11
Source File: Utils.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public static SecureCharSequence formatHashFromCharSequence(@Nonnull final SecureCharSequence address, final int groupSize, final int lineSize) {
    int length = address.length();
    if (length % groupSize == 0) {
        length = length + length / groupSize - 1;
    } else {
        length = length + length / groupSize;
    }
    char[] chars = new char[length];
    for (int i = 0; i < length; i++) {
        if (i % (groupSize + 1) == groupSize) {
            if ((i + 1) % (lineSize + lineSize / groupSize) == 0) {
                chars[i] = '\n';
            } else {
                chars[i] = ' ';
            }
        } else {
            chars[i] = address.charAt(i - i / (groupSize + 1));
        }
    }
    return new SecureCharSequence(chars);
}
 
Example 12
Source File: BCCAssetsHotMonitoredActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
    btcAmount = getAmount(outs);
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(toAddress);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 13
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private void validateValues() {
    boolean isValidAmounts = false;

    String amtString = tfAmt.getText().trim();

    if (Utils.isNubmer(amtString)) {
        long btc = GenericUtils.toNanoCoins(amtString, 0).longValue();
        if (btc > 0) {
            isValidAmounts = true;
        } else {
        }
    }
    boolean isValidAddress = Utils.validBicoinAddress(tfAddress.getText().trim());
    SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword());
    boolean isValidPassword = Utils.validPassword(password) && password.length() >= BitherSetting.PASSWORD_LENGTH_MIN &&
            password.length() <= BitherSetting.PASSWORD_LENGTH_MAX;
    password.wipe();
    setOkEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example 14
Source File: SendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 15
Source File: DialogEditPassword.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    tvError.setVisibility(View.GONE);
    SecureCharSequence p = new SecureCharSequence(etNewPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etNewPassword.setText(passwordNew);
        }
    }
    p.wipe();
    SecureCharSequence pc = new SecureCharSequence(etNewPasswordConfirm.getText());
    if (pc.length() > 0) {
        if (!Utils.validPassword(pc)) {
            etNewPasswordConfirm.setText(passwordNewConfirm);
        }
    }
    pc.wipe();
    SecureCharSequence po = new SecureCharSequence(etOldPassword.getText());
    if (po.length() > 0) {
        if (!Utils.validPassword(po)) {
            etOldPassword.setText(passwordOld);
        }
    }
    po.wipe();
    checkValid();
    passwordOld.wipe();
    passwordNew.wipe();
    passwordNewConfirm.wipe();
}
 
Example 16
Source File: BCCAssetsDetectHotActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 17
Source File: SplitBCCSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 18
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    SecureCharSequence p = new SecureCharSequence(etPassword.getText());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            etPassword.setText(password);
        }
    }
    p.wipe();
    validateValues();
    password.wipe();
}
 
Example 19
Source File: PasswordPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent keyEvent) {

    SecureCharSequence p = new SecureCharSequence(newPassword.getPassword());
    if (p.length() > 0) {
        if (!Utils.validPassword(p)) {
            newPassword.setText(password.toString());
        }
    }
    p.wipe();
    if (repeatNewPassword.isVisible()) {
        SecureCharSequence pc = new SecureCharSequence(repeatNewPassword.getPassword());
        if (pc.length() > 0) {
            if (!Utils.validPassword(pc)) {
                repeatNewPassword.setText(passwordConfirm.toString());
            }
        }
        pc.wipe();
    }
    checkValid();
    if (password != null) {
        password.wipe();
    }
    if (passwordConfirm != null) {
        passwordConfirm.wipe();
    }

}
 
Example 20
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public CompleteTransactionRunnable(Address a, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher2) throws Exception {
    boolean isHDM = otherSigFetcher1 != null || otherSigFetcher2 != null;
    this.amount = amount;
    this.toAddress = toAddress;
    this.password = password;
    sigFetcher1 = otherSigFetcher1;
    sigFetcher2 = otherSigFetcher2;
    if (isHDM) {
        wallet = a;
        toSign = true;
    } else if (password == null || password.length() == 0) {
        wallet = a;
        toSign = false;
    } else {
        if (a.hasPrivKey()) {
            wallet = a;
        } else {
            throw new Exception("address not with private key");
        }
        toSign = true;
    }
    if (!Utils.isEmpty(changeAddress)) {
        this.changeAddress = changeAddress;
    } else {
        this.changeAddress = wallet.getAddress();
    }
}