Esempio n. 1
0
  private void parseAddress(String addressStr) throws AddressFormatException {
    List<CoinType> possibleTypes = GenericUtils.getPossibleTypes(addressStr);
    if (possibleTypes.contains(pocket.getCoinType())) {
      setAddress(new Address(pocket.getCoinType(), addressStr), true);
      sendAmountType = pocket.getCoinType();
    } else if (possibleTypes.size() == 1) {
      setAddress(new Address(possibleTypes.get(0), addressStr), true);
      sendAmountType = possibleTypes.get(0);
    } else {
      // This address string could be more that one coin type so first check if this address
      // comes from an account to determine the type.
      List<WalletAccount> possibleAccounts = application.getAccounts(possibleTypes);
      Address addressOfAccount = null;
      for (WalletAccount account : possibleAccounts) {
        Address testAddress = new Address(account.getCoinType(), addressStr);
        if (account.isAddressMine(testAddress)) {
          addressOfAccount = testAddress;
          break;
        }
      }

      if (addressOfAccount != null) {
        // If address is from an account don't show a dialog. The type should not change as
        // we know 100% that is correct one
        setAddress(addressOfAccount, false);
        sendAmountType = (CoinType) addressOfAccount.getParameters();
      } else {
        // As a last resort let the use choose the correct coin type
        showPayToDialog(addressStr);
      }
    }
  }