Java Code Examples for net.bither.bitherj.utils.Utils#compareString()

The following examples show how to use net.bither.bitherj.utils.Utils#compareString() . 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: HDAccount.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public boolean checkWithPassword(CharSequence password) {
    if (!hasPrivKey()) {
        return true;
    }
    try {
        decryptHDSeed(password);
        decryptMnemonicSeed(password);
        byte[] hdCopy = Arrays.copyOf(hdSeed, hdSeed.length);
        boolean hdSeedSafe = Utils.compareString(getFirstAddressFromDb(),
                getFirstAddressFromSeed(null));
        boolean mnemonicSeedSafe = Arrays.equals(seedFromMnemonic(mnemonicSeed), hdCopy);
        Utils.wipeBytes(hdCopy);
        wipeHDSeed();
        wipeMnemonicSeed();
        return hdSeedSafe && mnemonicSeedSafe;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 2
Source File: WalletMouseListener.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    if (this.singleWalletForm != null) {
        String activeAddress = null;
        if (Bither.getActionAddress() != null) {
            activeAddress = Bither.getActionAddress().getAddress();
        }
        if (!Utils.compareString(this.singleWalletForm.getOnlyName()
                , activeAddress)) {
            walletListPanel.selectWalletPanelByFilename(this.singleWalletForm.getOnlyName());
            Bither.getCoreController().fireDataChangedUpdateNow();
        }
        this.singleWalletForm.getPanel().requestFocusInWindow();

    }

}
 
Example 3
Source File: TxReceiver.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void notifyCoins(String address, final long amount,
                         boolean isReceived) {
    String contentText = address;
    if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
        contentText = BitherApplication.mContext.getString(R.string.address_group_hd);
    } else if (Utils.compareString(address, HDAccount.HDAccountMonitoredPlaceHolder)) {
        contentText = BitherApplication.mContext.getString(R.string.address_group_hd_monitored);
    }
    String title = UnitUtilWrapper.formatValue(amount) + " " + AppSharedPreference.getInstance().getBitcoinUnit().name();
    if (isReceived) {
        title = blockchainService.getString(R.string.feed_received_btc) + " " + title;
    } else {
        title = blockchainService.getString(R.string.feed_send_btc) + " " + title;
    }
    Intent intent = new Intent(blockchainService, HotActivity.class);
    intent.putExtra(BitherSetting.INTENT_REF.NOTIFICATION_ADDRESS, address);
    SystemUtil.nmNotifyOfWallet(nm, blockchainService,
            BitherSetting.NOTIFICATION_ID_COINS_RECEIVED, intent, title,
            contentText, R.drawable.ic_launcher, R.raw.coins_received);

}
 
Example 4
Source File: EnterpriseHDMSeed.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public boolean checkWithPassword(CharSequence password) {
    try {
        decryptHDSeed(password);
        decryptMnemonicSeed(password);
        byte[] hdCopy = Arrays.copyOf(hdSeed, hdSeed.length);
        boolean hdSeedSafe = Utils.compareString(getFirstAddressFromDb(),
                getFirstAddressFromSeed(null));
        boolean mnemonicSeedSafe = Arrays.equals(seedFromMnemonic(mnemonicSeed), hdCopy);
        Utils.wipeBytes(hdCopy);
        wipeHDSeed();
        wipeMnemonicSeed();
        return hdSeedSafe && mnemonicSeedSafe;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 5
Source File: TxNotificationCenter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static void notifyCoins(String address, final long amount,
                                boolean isReceived) {
    String contentText = address;
    if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
        contentText = LocaliserUtils.getString("add_hd_account_tab_hd");
    }
    String title = UnitUtil.formatValue(amount, UnitUtil.BitcoinUnit.BTC) + " " + UnitUtil.BitcoinUnit.BTC.name();
    if (isReceived) {
        title = LocaliserUtils.getString("feed_received_btc") + " " + title;
    } else {
        title = LocaliserUtils.getString("feed_send_btc") + " " + title;
    }
    final String msg = contentText + " \n" + title;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new MessageDialog(msg).showMsg();
        }
    });

}
 
Example 6
Source File: WalletMouseListener.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    if (this.singleWalletForm != null) {
        String activeAddress = null;
        if (Bither.getActionAddress() != null) {
            activeAddress = Bither.getActionAddress().getAddress();
        }
        if (!Utils.compareString(this.singleWalletForm.getOnlyName()
                , activeAddress)) {
            walletListPanel.selectWalletPanelByFilename(this.singleWalletForm.getOnlyName());
            Bither.getCoreController().fireDataChangedUpdateNow();
        }
        this.singleWalletForm.getPanel().requestFocusInWindow();

    }

}
 
Example 7
Source File: Check.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (o instanceof Check) {
        Check check = (Check) o;
        return Utils.compareString(getTitle(), check.getTitle());
    }
    return false;
}
 
Example 8
Source File: SelectTransportQRCodePanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public boolean resultValid(String result) {
    if (!Utils.compareString(result, lastResult)) {
        shake();
    }
    lastResult = result;
    QRCodeTransportPage page = QRCodeTransportPage
            .formatQrCodeTransport(result);
    if (page == null) {
        return false;
    }
    if (page.getCurrentPage() == pages.size()) {
        return true;
    }
    return false;
}
 
Example 9
Source File: Tx.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public long amountReceivedFrom(Address address) {
    long amount = 0;
    for (Out out : this.outs) {
        if (Utils.compareString(address.getAddress(), out.getOutAddress())) {
            amount += out.getOutValue();
        }
    }
    return amount;
}
 
Example 10
Source File: Tx.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public long deltaAmountFrom(Address address) {
    if (address instanceof HDAccount) {
        return deltaAmountFrom((HDAccount) address);
    }
    long receive = 0;
    for (Out out : this.outs) {
        if (Utils.compareString(address.getAddress(), out.getOutAddress())) {
            receive += out.getOutValue();
        }
    }
    long sent = AbstractDb.txProvider.sentFromAddress(getTxHash(), address.getAddress());
    return receive - sent;
}
 
Example 11
Source File: Address.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object o) {
    if (o instanceof Address) {
        Address other = (Address) o;
        return Utils.compareString(getAddress(), other.getAddress());
    }
    return false;
}
 
Example 12
Source File: FileUtil.java    From bither-android with Apache License 2.0 5 votes vote down vote up
/**
 * sdCard exist
 */
public static boolean existSdCardMounted() {
    String storageState = android.os.Environment.getExternalStorageState();
    if (Utils.isEmpty(storageState)) {
        return false;
    }
    return Utils.compareString(storageState,
            android.os.Environment.MEDIA_MOUNTED);
}
 
Example 13
Source File: Tx.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public String getFirstOutAddressOtherThanChange(String changeAddress) {
    if (getOuts().size() > 0) {
        if (isCoinBase()) {
            return getOuts().get(0).getOutAddress();
        }
        for (Out out : getOuts()) {
            if (!Utils.compareString(out.getOutAddress(), getFromAddress()) && !Utils
                    .compareString(out.getOutAddress(), changeAddress)) {
                return out.getOutAddress();
            }
        }
        return getOuts().get(0).getOutAddress();
    }
    return null;
}
 
Example 14
Source File: LocaliserUtils.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static boolean isChina() {
    String defaultCountry = Locale.getDefault().getCountry();
    if (Utils.compareString(defaultCountry, "CN") || Utils.compareString
            (defaultCountry, "cn")) {
        return true;
    } else {
        return false;
    }
}
 
Example 15
Source File: UserPreference.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void setDefault() {
    String defaultCountry = Locale.getDefault().getCountry();
    if (Utils.compareString(defaultCountry, "CN") || Utils.compareString
            (defaultCountry, "cn")) {
        setMarketType(MarketType.BTCCHINA);
    } else {
        setMarketType(MarketType.BITSTAMP);
    }
    String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
    if (Utils.compareString(currencyCode, "CNY")) {
        setExchangeCurrency(ExchangeUtil.Currency.CNY);
    } else if (Utils.compareString(currencyCode, "EUR")) {
        setExchangeCurrency(ExchangeUtil.Currency.EUR);
    } else if (Utils.compareString(currencyCode, "GBP")) {
        setExchangeCurrency(ExchangeUtil.Currency.GBP);
    } else if (Utils.compareString(currencyCode, "JPY")) {
        setExchangeCurrency(ExchangeUtil.Currency.JPY);
    } else if (Utils.compareString(currencyCode, "KRW")) {
        setExchangeCurrency(ExchangeUtil.Currency.KRW);
    } else if (Utils.compareString(currencyCode, "CAD")) {
        setExchangeCurrency(ExchangeUtil.Currency.CAD);
    } else if (Utils.compareString(currencyCode, "AUD")) {
        setExchangeCurrency(ExchangeUtil.Currency.AUD);
    } else {
        setExchangeCurrency(ExchangeUtil.Currency.USD);
    }
}
 
Example 16
Source File: PinCodeChangeActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntered(CharSequence code) {
    if (code == null || code.length() == 0) {
        return;
    }
    if (!passedOld) {
        if (p.checkPinCode(code)) {
            passedOld = true;
            pv.animateToNext();
            pv.setMessage(R.string.pin_code_setting_change_new_msg);
        } else {
            passedOld = false;
            pv.shakeToClear();
            DropdownMessage.showDropdownMessage(this,
                    R.string.pin_code_setting_change_old_wrong);
        }
        return;
    }
    if (firstPin == null) {
        firstPin = code;
        pv.animateToNext();
        pv.setMessage(R.string.pin_code_setting_change_new_repeat_msg);
    } else {
        if (Utils.compareString(firstPin.toString(), code.toString())) {
            p.setPinCode(code);
            finish();
            overridePendingTransition(0, R.anim.slide_out_right);
        } else {
            DropdownMessage.showDropdownMessage(this,
                    R.string.pin_code_setting_change_repeat_wrong);
            pv.setMessage(R.string.pin_code_setting_change_new_msg);
            pv.shakeToClear();
            firstPin = null;
        }
    }
}
 
Example 17
Source File: HDMKeychain.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public boolean isInRecovery() {
    return Utils.compareString(AbstractDb.addressProvider.getEncryptMnemonicSeed(hdSeedId),
            HDMKeychainRecover.RecoverPlaceHolder) ||
            Utils.compareString(AbstractDb.addressProvider.getEncryptHDSeed(hdSeedId),
                    HDMKeychainRecover.RecoverPlaceHolder) ||
            Utils.compareString(getFirstAddressFromDb(), HDMKeychainRecover.RecoverPlaceHolder);
}
 
Example 18
Source File: CheckFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public boolean isHDM() {
    return Utils.compareString(address, HDMKeychainAsAddressFaker);
}
 
Example 19
Source File: CheckFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public boolean isHDAccount() {
    return Utils.compareString(address, HDAccount.HDAccountPlaceHolder);
}
 
Example 20
Source File: CheckFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public boolean isHDAccountCold() {
    return Utils.compareString(address, HDAccount.HDAccountMonitoredPlaceHolder)
            && AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode
            .COLD;
}