Пример #1
0
 public void add(String pubKey, String priKey, boolean online) {
   String key = pubKey.concat(priKey);
   if (!pCaches.containsKey(key)) {
     GregorianCalendar cal = new GregorianCalendar();
     cal.setTime(Calendar.getInstance().getTime());
     String date =
         String.format(
             "%04d-%02d-%02d",
             cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
     WalletItem walletItem = new WalletItem(date, priKey, "0.000000", "none");
     walletItem.setOnline(online);
     pCaches.put(key, walletItem);
   }
 }
Пример #2
0
 public String load(File file) throws Exception {
   synchronized (pCaches) {
     WalletSeed seed = new WalletSeed(LSystem.getAppPassword());
     String text = seed.load(file);
     StringTokenizer tokenizer = new StringTokenizer(text, LSystem.LS);
     String result = null;
     BigDecimal count = new BigDecimal("0");
     for (; tokenizer.hasMoreElements(); ) {
       result = tokenizer.nextToken();
       if (result != null && result.length() > 0) {
         String[] split = result.split(",");
         if (split.length > 4) {
           String date = split[0];
           String pubKey = split[1];
           String priKey = split[2];
           String amount = split[3];
           String status = split[4];
           RPAddress address = new RPAddress(pubKey, priKey);
           pubKey = new String(address.getPublic());
           priKey = new String(address.getPrivate());
           String key = pubKey.concat(priKey);
           if (!pCaches.containsKey(key)) {
             WalletItem walletItem = new WalletItem(date, priKey, amount, status);
             if (MathUtils.isNan(amount)) {
               count = count.add(new BigDecimal(amount));
             }
             pCaches.put(key, walletItem);
           }
         }
       }
       int res = count.intValue();
       if (res > 0) {
         amounts = String.valueOf(res);
       }
     }
     return text;
   }
 }