Esempio n. 1
0
 @Override
 public int compareTo(AddressBalance another) {
   if (address.hasPrivKey() && !another.address.hasPrivKey()) {
     return 1;
   }
   if (!address.hasPrivKey() && another.address.hasPrivKey()) {
     return -1;
   }
   long gap = balance - another.balance;
   return gap == 0 ? 0 : (int) (gap / Math.abs(gap));
 }
 public void save() {
   View c = flContainer.getChildAt(0);
   if (c instanceof AddAddressPrivateKeyView) {
     List<Address> addresses = getPrivateKeyView().getAddresses();
     ArrayList<String> as = new ArrayList<String>();
     if (addresses.size() > 0) {
       for (Address address : addresses) {
         as.add(address.getAddress());
       }
       Intent intent = new Intent();
       intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, as);
       intent.putExtra(
           BitherSetting.INTENT_REF.ADD_PRIVATE_KEY_SUGGEST_CHECK_TAG, shouldSuggestCheck);
       setResult(Activity.RESULT_OK, intent);
       finish();
     }
   } else {
     return;
   }
 }
Esempio n. 3
0
  public static Check initCheckForPrivateKey(
      final Address address, final SecureCharSequence password) {
    String title =
        String.format(
            BitherApplication.mContext.getString(R.string.check_address_private_key_title),
            address.getShortAddress());
    Check check =
        new Check(
            title,
            new ICheckAction() {

              @Override
              public boolean check() {
                boolean result = new PasswordSeed(address).checkPassword(password);
                if (!result) {
                  try {
                    ECKey eckeyFromBackup =
                        BackupUtil.getEckeyFromBackup(address.getAddress(), password);
                    if (eckeyFromBackup != null) {
                      String encryptPrivateKey =
                          PrivateKeyUtil.getPrivateKeyString(eckeyFromBackup);
                      if (!Utils.isEmpty(encryptPrivateKey)) {
                        address.setEncryptPrivKey(encryptPrivateKey);
                        address.savePrivateKey();
                        result = true;
                      }
                    }
                  } catch (Exception e) {
                    e.printStackTrace();
                  } finally {
                    password.wipe();
                  }
                }
                return result;
              }
            });
    return check;
  }