net.bither.bitherj.BitherjSettings Java Examples
The following examples show how to use
net.bither.bitherj.BitherjSettings.
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: CheckUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public static Check initCheckForHDMKeychain(final HDMKeychain keychain, final SecureCharSequence password) { String title = LocaliserUtils.getString("hdm_keychain_check_title_cold"); if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { title = LocaliserUtils.getString("hdm_keychain_check_title_hot"); } Check check = new Check(title, new ICheckAction() { @Override public boolean check() { boolean result = false; try { result = keychain.checkWithPassword(password); if (result) { result = keychain.checkSingularBackupWithPassword(password); } //TODO need to check backup here? } catch (Exception e) { e.printStackTrace(); } password.wipe(); return result; } }); return check; }
Example #2
Source File: MenuBar.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public MenuBar() { TxNotificationCenter.addTxListener(MenuBar.this); panelMain = new JPanel(); panelMain.setLayout(new BorderLayout()); panelMain.setOpaque(false); panelButton = getPanelButton(); panelMain.add(panelButton, BorderLayout.EAST); if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { panelInfo = getHotPanelInfo(); panelMain.add(panelInfo, BorderLayout.WEST); updateTickerInfo(); BitherTimer bitherTimer = new BitherTimer(MenuBar.this); bitherTimer.startTimer(); } else { panelInfo = getPanelColdInfo(); panelMain.add(panelInfo, BorderLayout.WEST); } }
Example #3
Source File: ChooseModeActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { DialogConfirmTask dialog = new DialogConfirmTask(ChooseModeActivity.this, getStyledConfirmString(getString(R.string.choose_mode_cold_confirm)), new Runnable() { @Override public void run() { stopService(new Intent(ChooseModeActivity.this, BlockchainService.class)); runOnUiThread(new Runnable() { @Override public void run() { modeSelected(BitherjSettings.AppMode.COLD); vColdWalletInitCheck.check(); ObjectAnimator animator = ObjectAnimator.ofFloat(new ShowHideView(new View[]{vColdExtra}, new View[]{rlWarm, vWarmBg}), "Progress", 1).setDuration(AnimHideDuration); animator.setInterpolator(new AccelerateDecelerateInterpolator()); vColdWalletInitCheck.prepareAnim(); animator.addListener(coldClickAnimListener); animator.start(); } }); } }); dialog.show(); }
Example #4
Source File: MainFrameUI.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public void updateHeader() { if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { return; } long finalEstimatedBalance = 0; for (Address address : AddressManager.getInstance().getAllAddresses()) { finalEstimatedBalance = finalEstimatedBalance + address.getBalance(); } if (AddressManager.getInstance().getHdAccount() != null) { finalEstimatedBalance = finalEstimatedBalance + AddressManager.getInstance().getHdAccount().getBalance(); } final long total = finalEstimatedBalance; if (EventQueue.isDispatchThread()) { updateHeaderOnSwingThread(total); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { updateHeaderOnSwingThread(total); } }); } }
Example #5
Source File: MenuBar.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public MenuBar() { TxNotificationCenter.addTxListener(MenuBar.this); panelMain = new JPanel(); panelMain.setLayout(new BorderLayout()); panelMain.setOpaque(false); panelButton = getPanelButton(); panelMain.add(panelButton, BorderLayout.EAST); if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { panelInfo = getHotPanelInfo(); panelMain.add(panelInfo, BorderLayout.WEST); updateTickerInfo(); BitherTimer bitherTimer = new BitherTimer(MenuBar.this); bitherTimer.startTimer(); } else { panelInfo = getPanelColdInfo(); panelMain.add(panelInfo, BorderLayout.WEST); } }
Example #6
Source File: TransactionsUtil.java From bitherj with Apache License 2.0 | 6 votes |
public static void getMyTxFromBither() throws Exception { if (AbstractApp.bitherjSetting.getAppMode() != BitherjSettings.AppMode.HOT) { return; } // TODO: web type int flag = AbstractApp.bitherjSetting.getApiConfig().value(); getTxForAddress(flag); if (AddressManager.getInstance().getHDAccountHot() != null) { getTxForHDAccount(AddressManager.getInstance().getHDAccountHot().getHdSeedId(), flag); } if(AddressManager.getInstance().hasHDAccountMonitored()){ getTxForHDAccountMoitored(AddressManager.getInstance().getHDAccountMonitored().getHdSeedId(), flag); } if (AddressManager.getInstance().hasDesktopHDMKeychain()) { DesktopHDMKeychain desktopHDMKeychain = AddressManager.getInstance().getDesktopHDMKeychains().get(0); getTxForDesktopHDM(desktopHDMKeychain, flag); } }
Example #7
Source File: HDMSeedPhrasPanel.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public HDMSeedPhrasPanel(List<String> worldList) { super(MessageKey.HDM_COLD_SEED_WORD_LIST, AwesomeIcon.BITBUCKET); worldString = ""; for (int i = 0; i < worldList.size(); i++) { if (i == worldList.size() - 1) { worldString += worldList.get(i); } else if ((i + 1) % 3 == 0) { worldString += worldList.get(i) + "-" + "\n"; } else { worldString += worldList.get(i) + "-"; } } if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { updateTitle(LocaliserUtils.getString("hdm_hot_seed_word_list")); } }
Example #8
Source File: DumpedPrivateKey.java From bitherj with Apache License 2.0 | 6 votes |
/** * Parses the given private key as created by the "dumpprivkey" Bitcoin C++ RPC. * * @param encoded The base58 encoded string. * @throws net.bither.bitherj.exception.AddressFormatException If the string is invalid or the header byte doesn't match the network params. */ public DumpedPrivateKey(String encoded) throws AddressFormatException { //todo string encoded byte[] tmp = Base58.decodeChecked(encoded); version = tmp[0] & 0xFF; bytes = new byte[tmp.length - 1]; System.arraycopy(tmp, 1, bytes, 0, tmp.length - 1); if (version != BitherjSettings.dumpedPrivateKeyHeader) throw new AddressFormatException("Mismatched version number, trying to cross networks? " + version + " vs " + BitherjSettings.dumpedPrivateKeyHeader); if (bytes.length == 33 && bytes[32] == 1) { compressed = true; bytes = Arrays.copyOf(bytes, 32); // Chop off the additional marker byte. } else if (bytes.length == 32) { compressed = false; } else { throw new AddressFormatException("Wrong number of bytes for a private key, not 32 or 33"); } }
Example #9
Source File: BitherTimer.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public void startTimer() { if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { return; } if (thread == null) { thread = new Thread(new Runnable() { @Override public void run() { while (!isStop) { getExchangeTicker(); try { Thread.sleep(1 * 60 * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }); thread.start(); } }
Example #10
Source File: OptionHotFragment.java From bither-android with Apache License 2.0 | 6 votes |
@Override public String getOptionName(int index) { BitherjSettings.TransactionFeeMode transactionFeeMode = getModeByIndex(index); switch (transactionFeeMode) { case TwentyX: return getString(R.string.setting_name_transaction_fee_20x); case TenX: return getString(R.string.setting_name_transaction_fee_10x); case Higher: return getString(R.string.setting_name_transaction_fee_higher); case High: return getString(R.string.setting_name_transaction_fee_high); case Low: return getString(R.string.setting_name_transaction_fee_low); case Lower: return getString(R.string.setting_name_transaction_fee_lower); default: return getString(R.string.setting_name_transaction_fee_normal); } }
Example #11
Source File: SendActivity.java From bither-android with Apache License 2.0 | 6 votes |
private void processIntent() { isDonate = false; Intent intent = getIntent(); if (intent.hasExtra(SelectAddressToSendActivity.INTENT_EXTRA_ADDRESS)) { String address = intent.getExtras().getString(SelectAddressToSendActivity .INTENT_EXTRA_ADDRESS); if (Utils.validBicoinAddress(address)) { if (Utils.compareString(address, BitherjSettings.DONATE_ADDRESS)) { isDonate = true; } etAddress.setText(address); long btc = intent.getExtras().getLong(SelectAddressToSendActivity .INTENT_EXTRA_AMOUNT, 0); if (btc > 0) { amountCalculatorLink.setBtcAmount(btc); } validateValues(); } } }
Example #12
Source File: BlockChain.java From bitherj with Apache License 2.0 | 6 votes |
public List<byte[]> getBlockLocatorArray() { // append 10 most recent block hashes, descending, then continue appending, doubling the step back each time, // finishing with the genesis block (top, -1, -2, -3, -4, -5, -6, -7, -8, -9, -11, -15, -23, -39, -71, -135, ..., 0) ArrayList<byte[]> locators = new ArrayList<byte[]>(); int step = 1, start = 0; Block b = this.lastBlock; while (b != null && b.getBlockNo() > 0) { locators.add(b.getBlockHash()); if (++start >= 10) step *= 2; for (int i = 0; b != null && i < step; i++) { b = AbstractDb.blockProvider.getMainChainBlock(b.getBlockPrev()); } } locators.add(BitherjSettings.GENESIS_BLOCK_HASH); return locators; }
Example #13
Source File: BlockchainService.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onCreate() { serviceCreatedAt = System.currentTimeMillis(); log.info(".onCreate()"); super.onCreate(); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); if (AppSharedPreference.getInstance().getAppMode() != BitherjSettings.AppMode.COLD) { tickReceiver = new TickReceiver(BlockchainService.this); txReceiver = new TxReceiver(BlockchainService.this, tickReceiver); receiverConnectivity(); registerReceiver(tickReceiver, new IntentFilter( Intent.ACTION_TIME_TICK)); registerReceiver(txReceiver, new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_BALANCE)); BroadcastUtil.sendBroadcastStartPeer(); } startMarkTimerTask(); }
Example #14
Source File: HdmSendActivity.java From bither-android with Apache License 2.0 | 6 votes |
private void processIntent() { isDonate = false; Intent intent = getIntent(); if (intent.hasExtra(SelectAddressToSendActivity.INTENT_EXTRA_ADDRESS)) { String address = intent.getExtras().getString(SelectAddressToSendActivity .INTENT_EXTRA_ADDRESS); if (Utils.validBicoinAddress(address)) { if (Utils.compareString(address, BitherjSettings.DONATE_ADDRESS)) { isDonate = true; } etAddress.setText(address); long btc = intent.getExtras().getLong(SelectAddressToSendActivity .INTENT_EXTRA_AMOUNT, 0); if (btc > 0) { amountCalculatorLink.setBtcAmount(btc); } validateValues(); } } }
Example #15
Source File: PeerUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private static synchronized void startPeerInBackground() { try { if (!peerCanRun) { return; } if (!UserPreference.getInstance().getDownloadSpvFinish()) { BlockUtil.dowloadSpvBlock(); } if (UserPreference.getInstance().getAppMode() != BitherjSettings.AppMode.COLD) { if (!UserPreference.getInstance().getBitherjDoneSyncFromSpv()) { if (!PeerManager.instance().isConnected()) { PeerManager.instance().start(); } } else { if (!AddressManager.getInstance().addressIsSyncComplete()) { TransactionsUtil.getMyTxFromBither(); } startPeerManager(); } } } catch (Exception e) { e.printStackTrace(); } }
Example #16
Source File: BitherTimer.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public void startTimer() { if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { return; } if (thread == null) { thread = new Thread(new Runnable() { @Override public void run() { while (!isStop) { getExchangeTicker(); try { Thread.sleep(1 * 60 * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }); thread.start(); } }
Example #17
Source File: BitherSetting.java From bither-android with Apache License 2.0 | 6 votes |
public static String getMarketName(BitherjSettings.MarketType marketType) { String name = ""; switch (marketType) { case BITSTAMP: name = BitherApplication.mContext .getString(R.string.market_name_bitstamp); break; case BITFINEX: name = BitherApplication.mContext .getString(R.string.market_name_bitfinex); break; case COINBASE: name = BitherApplication.mContext.getString(R.string.market_name_coinbase); break; default: name = BitherApplication.mContext .getString(R.string.market_name_bitstamp); break; } return name; }
Example #18
Source File: LogUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public static void printlnError(String str) { if (!BitherjSettings.LOG_DEBUG) { return; } if (Utils.isEmpty(str)) { return; } System.err.println(str); }
Example #19
Source File: AddressManager.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean isPrivateLimit() { int maxPrivateKey = AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode .COLD ? AbstractApp.bitherjSetting.watchOnlyAddressCountLimit() : AbstractApp.bitherjSetting.privateKeyOfHotCountLimit(); return AddressManager.getInstance().getPrivKeyAddresses() != null && AddressManager.getInstance().getPrivKeyAddresses().size() >= maxPrivateKey; }
Example #20
Source File: KeyUtil.java From bither-android with Apache License 2.0 | 5 votes |
public static void setHDAccount(HDAccount hdAccount) { if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { BackupUtil.backupColdKey(false); } else { AddressManager.getInstance().setHdAccountHot(hdAccount); BackupUtil.backupHotKey(); } }
Example #21
Source File: DialogAddressWithShowPrivateKey.java From bither-android with Apache License 2.0 | 5 votes |
public DialogAddressWithShowPrivateKey(Activity context, Address address, DialogAddressAlias.DialogAddressAliasDelegate aliasDelegate) { super(context); this.activity = context; this.address = address; this.aliasDelegate = aliasDelegate; setOnDismissListener(this); setContentView(R.layout.dialog_address_with_show_private_key); llOriginQRCode = (LinearLayout) findViewById(R.id.ll_origin_qr_code); llSignMessage = (LinearLayout) findViewById(R.id.ll_sign_message); findViewById(R.id.tv_view_show_private_key).setOnClickListener(this); findViewById(R.id.tv_private_key_qr_code_decrypted).setOnClickListener(this); findViewById(R.id.tv_private_key_qr_code_encrypted).setOnClickListener(this); findViewById(R.id.tv_private_key_qr_code_bip38).setOnClickListener(this); findViewById(R.id.tv_trash_private_key).setOnClickListener(this); findViewById(R.id.ll_address_alias).setOnClickListener(this); llOriginQRCode.setOnClickListener(this); llOriginQRCode.setVisibility(View.GONE); if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { llSignMessage.setVisibility(View.VISIBLE); llSignMessage.setOnClickListener(this); } else { llSignMessage.setVisibility(View.GONE); } findViewById(R.id.tv_close).setOnClickListener(this); dialogQr = new DialogFancyQrCode(context, address.getAddress(), false, true); dialogPrivateKey = new DialogPrivateKeyQrCode(context, address.getFullEncryptPrivKey(), address.getAddress()); if (aliasDelegate == null) { findViewById(R.id.ll_address_alias).setVisibility(View.GONE); } }
Example #22
Source File: CheckHeaderView.java From bither-android with Apache License 2.0 | 5 votes |
public void check() { if ((AddressManager.getInstance().getPrivKeyAddresses() == null || AddressManager.getInstance().getPrivKeyAddresses().size() == 0) && !AddressManager.getInstance().hasHDMKeychain() && !(AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD && AddressManager.getInstance().hasHDAccountCold()) && !(AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT && AddressManager.getInstance().hasHDAccountHot())) { DropdownMessage.showDropdownMessage((Activity) getContext(), R.string.private_key_is_empty); return; } DialogPassword dialog = new DialogPassword(getContext(), CheckHeaderView.this); dialog.show(); }
Example #23
Source File: DialogDonate.java From bither-android with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { int position; Class<?> target; if (address.address.isHDM()) { position = AddressManager.getInstance().getHdmKeychain().getAddresses().indexOf (address.address); target = HdmSendActivity.class; } else if (address.address.hasPrivKey()) { position = AddressManager.getInstance().getPrivKeyAddresses().indexOf(address.address); target = SendActivity.class; } else { position = AddressManager.getInstance().getWatchOnlyAddresses().indexOf(address.address); target = GenerateUnsignedTxActivity.class; } intent = new Intent(getContext(), target); intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, position); intent.putExtra(SelectAddressToSendActivity.INTENT_EXTRA_ADDRESS, BitherjSettings.DONATE_ADDRESS); intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_IS_HDM_KEY_PASS_VALUE_TAG, address.address.isHDM()); if (address.balance > BitherSetting.DONATE_AMOUNT) { intent.putExtra(SelectAddressToSendActivity.INTENT_EXTRA_AMOUNT, BitherSetting.DONATE_AMOUNT); } else { intent.putExtra(SelectAddressToSendActivity.INTENT_EXTRA_AMOUNT, address.balance); } dismiss(); }
Example #24
Source File: ChooseModeActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void initActivity() { setContentView(R.layout.activity_choose_mode); BitherjSettings.AppMode appMode = AppSharedPreference.getInstance().getAppMode(); if (appMode == null) { BitherApplication.getBitherApplication().startBlockchainService(); dowloadSpvBlock(); initView(); } else { if (appMode == BitherjSettings.AppMode.COLD) { vColdWalletInitCheck = (ColdWalletInitCheckView) findViewById(R.id .v_cold_wallet_init_check); if (vColdWalletInitCheck.check()) { gotoActivity(appMode); finish(); return; } else { initView(); configureColdWait(); } } else if (appMode == BitherjSettings.AppMode.HOT) { BitherApplication.getBitherApplication().startBlockchainService(); if (!AppSharedPreference.getInstance().getDownloadSpvFinish()) { initView(); dowloadSpvBlock(); configureWarmWait(); } else { gotoActivity(appMode); finish(); return; } } } }
Example #25
Source File: ChooseModeActivity.java From bither-android with Apache License 2.0 | 5 votes |
public void handleMessage(android.os.Message msg) { switch (msg.what) { case HandlerMessage.MSG_PREPARE: dialogUpgrade = new DialogUpgrade(ChooseModeActivity.this); dialogUpgrade.setMessage(getUpgradeString()); dialogUpgrade.setCancelable(false); dialogUpgrade.show(); break; case HandlerMessage.MSG_SUCCESS: if (dialogUpgrade != null) { dialogUpgrade.dismiss(); } setVersionCode(); initActivity(); if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) { dowloadSpvBlock(); } break; case HandlerMessage.MSG_FAILURE: if (dialogUpgrade != null) { dialogUpgrade.dismiss(); } break; default: break; } }
Example #26
Source File: PeerManager.java From bitherj with Apache License 2.0 | 5 votes |
private int getMaxPeerConnect() { if (AbstractApp.bitherjSetting.isApplicationRunInForeground()) { return BitherjSettings.MaxPeerConnections; } else { return BitherjSettings.MaxPeerBackgroundConnections; } }
Example #27
Source File: KeyUtil.java From bither-android with Apache License 2.0 | 5 votes |
public static void setHDKeyChain(HDMKeychain keyChain) { AddressManager.getInstance().setHDMKeychain(keyChain); if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { BackupUtil.backupColdKey(false); } else { BackupUtil.backupHotKey(); } }
Example #28
Source File: HDMKeychainHotUEntropyDialog.java From bither-desktop-java with Apache License 2.0 | 5 votes |
@Override void didSuccess(Object obj) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { quit(); Bither.refreshFrame(); if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { new MessageDialog(LocaliserUtils.getString("hdm_keychain_xrandom_final_confirm")).showMsg(); } } }); }
Example #29
Source File: AdvancePanel.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private JRadioButton getRbLow() { JRadioButton jRadioButton = new JRadioButton(); jRadioButton.setText(LocaliserUtils.getString("setting_name_transaction_fee_low")); jRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { UserPreference.getInstance().setTransactionFeeMode(BitherjSettings.TransactionFeeMode.Low); } }); return jRadioButton; }
Example #30
Source File: KeyUtil.java From bither-android with Apache License 2.0 | 5 votes |
public static List<Address> addPrivateKeyByRandomWithPassphras(BlockchainService service, IUEntropy iuEntropy, CharSequence password, int count) { if (service != null) { service.stopAndUnregister(); } List<Address> addressList = new ArrayList<Address>(); for (int i = 0; i < count; i++) { XRandom xRandom = new XRandom(iuEntropy); ECKey ecKey = ECKey.generateECKey(xRandom); ecKey = PrivateKeyUtil.encrypt(ecKey, password); Address address = new Address(ecKey.toAddress(), ecKey.getPubKey(), PrivateKeyUtil.getEncryptedString(ecKey), true, ecKey.isFromXRandom()); ecKey.clearPrivateKey(); addressList.add(address); AddressManager.getInstance().addAddress(address); } if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) { BackupUtil.backupColdKey(false); } else { BackupUtil.backupHotKey(); } if (service != null) { service.startAndRegister(); } return addressList; }