public SweepWalletTask(Handler handler, ServerClients serverClients, WalletAccount sendToAccount, SerializedKey key, @Nullable String keyPassword) { this.handler = handler; this.serverClients = serverClients; this.key = key; this.sendToAccount = sendToAccount; this.type = sendToAccount.getCoinType(); this.keyPassword = keyPassword; }
public CoinType getType() { if (accountOrCoinType instanceof CoinType) { return (CoinType) accountOrCoinType; } else if (accountOrCoinType instanceof WalletAccount) { return ((WalletAccount) accountOrCoinType).getCoinType(); } else { throw new IllegalStateException("No cointype available"); } } }
private void clearAddress(boolean clearTextField) { address = null; if (clearTextField) setSendToAddressText(null); sendAmountType = account.getCoinType(); addressTypeCanChange = false; }
public static int getIconRes(WalletAccount account) { return getIconRes(account.getCoinType()); }
/** * Get the current source and destination pair */ private String getPair() { return ShapeShift.getPair(sourceAccount.getCoinType(), destinationType); }
public static boolean is(CoinType myType, WalletAccount other) { return other != null && myType.equals(other.getCoinType()); }
public void setAccount(WalletAccount account) { this.type = account.getCoinType(); title.setText(account.getDescriptionOrCoinName()); icon.setImageResource(WalletUtils.getIconRes(account)); }
public void resetAccount(WalletAccount account) { BlockchainConnection connection = connections.get(account.getCoinType()); if (connection == null) return; connection.addEventListener(account); connection.resetConnection(); }
void startExchangeRates() { WalletAccount account = getAccount(lastAccountId); if (account != null) { Intent intent = new Intent(this, ExchangeRatesActivity.class); intent.putExtra(Constants.ARG_COIN_ID, account.getCoinType().getId()); startActivity(intent); } else { Toast.makeText(this, R.string.no_wallet_pocket_selected, Toast.LENGTH_LONG).show(); } }
public void startOrResetAccountAsync(WalletAccount account) { if (connections.containsKey(account.getCoinType())) { resetAccount(account); } else { startAsync(account); } } }
/** * Updates the exchange rate and limits for the specific market. * Note: if the current pair is different that the marketInfo pair, do nothing */ private void onMarketUpdate(ShapeShiftMarketInfo marketInfo) { if (address != null && marketInfo.isPair(account.getCoinType(), address.getType())) { this.marketInfo = marketInfo; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { if (args.containsKey(Constants.ARG_ACCOUNT_ID)) { String accountId = args.getString(Constants.ARG_ACCOUNT_ID); account = checkNotNull(application.getAccount(accountId)); } checkNotNull(account, "No account selected"); type = account.getCoinType(); } else { throw new RuntimeException("Must provide account ID"); } }
public void startAsync(WalletAccount account) { if (account == null) { log.warn("Provided wallet account is null, not doing anything"); return; } CoinType type = account.getCoinType(); BlockchainConnection connection = getConnection(type); connection.addEventListener(account); connection.startAsync(); }
@Override public boolean equals(WalletAccount other) { return other != null && getId().equals(other.getId()) && getCoinType().equals(other.getCoinType()); } }
/** * Check if the amount is valid */ private boolean isAmountValid(Value amount) { boolean isValid = amount != null && !amount.isDust(); if (isValid && amount.isOfType(sourceAccount.getCoinType())) { isValid = isAmountWithinLimits(amount); } return isValid; }
private void calculateNewBalance() { currentBalance = null; for (WalletAccount w : wallet.getAllAccounts()) { ExchangeRate rate = exchangeRates.get(w.getCoinType().getSymbol()); if (rate == null) { log.info("Missing exchange rate for {}, skipping...", w.getCoinType().getName()); continue; } if (currentBalance != null) { currentBalance = currentBalance.add(rate.rate.convert(w.getBalance())); } else { currentBalance = rate.rate.convert(w.getBalance()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The onCreateOptionsMenu is handled in com.openwallet.wallet.ui.AccountFragment setHasOptionsMenu(true); if (getArguments() != null) { accountId = getArguments().getString(Constants.ARG_ACCOUNT_ID); } //TODO pocket = application.getAccount(accountId); if (pocket == null) { Toast.makeText(getActivity(), R.string.no_such_pocket_error, Toast.LENGTH_LONG).show(); return; } type = pocket.getCoinType(); }
/** * Sets the destination account and makes a network call to ask about the new pair. * Note: this does not update the destination spinner, use * {@link #setDestinationSpinner(Object)} */ private void setDestination(WalletAccount account, boolean startNetworkTask) { setDestination(account.getCoinType(), false); destinationAccount = account; updateOptionsMenu(); if (startNetworkTask) { startMarketInfoTask(); if (pollTask != null) pollTask.updatePair(getPair()); } }
private void startOrStopMarketRatePolling() { if (address != null && !account.isType(address)) { String pair = ShapeShift.getPair(account.getCoinType(), address.getType()); if (timer == null) { startPolling(pair); } else { pollTask.updatePair(pair); } } else if (timer != null) { stopPolling(); } }
private void createNavDrawerItems() { navDrawerItems.clear(); NavDrawerItem.addItem(navDrawerItems, ITEM_SECTION_TITLE, getString(R.string.navigation_drawer_services)); NavDrawerItem.addItem(navDrawerItems, ITEM_TRADE, getString(R.string.title_activity_trade), R.drawable.trade, null); NavDrawerItem.addItem(navDrawerItems, ITEM_SECTION_TITLE, getString(R.string.navigation_drawer_wallet)); NavDrawerItem.addItem(navDrawerItems, ITEM_OVERVIEW, getString(R.string.title_activity_overview), R.drawable.ic_launcher, null); for (WalletAccount account : getAllAccounts()) { NavDrawerItem.addItem(navDrawerItems, ITEM_COIN, account.getDescriptionOrCoinName(), Constants.COINS_ICONS.get(account.getCoinType()), account.getId()); } }