예제 #1
0
  public void getBitcoinAccountList() throws Exception {
    System.out.println("getBitcoinAccountList strts ");
    btcClient = (BitcoinClient) btcClientMap.get(serverID);

    List accountsList = btcClient.getAccountList();

    for (int j = 0; j < accountsList.size(); j++) {

      String data[] = (String[]) accountsList.get(j);
      WalletData walletData = Utility.getWalletData();
      if (walletData == null) {
        System.out.println("getBitcoinAccountList - walletData returns null");
        return;
      }
      int count = (int) walletData.GetBitcoinAcctCount();
      BitcoinAcct btcAcct = null;
      boolean acctExists = false;

      for (int i = 0; i < count; i++) {
        acctExists = false;
        btcAcct = walletData.GetBitcoinAcct(i);
        if (btcAcct != null && btcAcct.getAcct_id().equals(data[0])) {
          acctExists = true;
          break;
        }
      }
      if (!acctExists) {
        Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_BITCOIN_ACCT);
        if (storable != null) {
          btcAcct = BitcoinAcct.ot_dynamic_cast(storable);
          if (btcAcct != null) {
            btcAcct.setGui_label(data[0]);
            btcAcct.setBitcoin_acct_name(data[0]);
            btcAcct.setAcct_id(data[0]);
            btcAcct.setServer_id(serverID);

            boolean status = walletData.AddBitcoinAcct(btcAcct);
            System.out.println("status walletData.AddBitcoinAcct:" + status);

            status = otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat");

            System.out.println("status otapi.StoreObject:" + status);
          }
        }
      }
      if (btcAcct != null) {
        key = btcAcct.getAcct_id();
        label = btcAcct.getGui_label();
        amount = data[1];
        accountList.put(key, new String[] {label, amount, type, key});
      }
    }
    System.out.println("getBitcoinAccountList ends ");
  }
예제 #2
0
 @Override
 public boolean editLabel(String accountID, String newLabel) {
   // Loop
   boolean status = false;
   WalletData walletData = Utility.getWalletData();
   if (walletData == null) {
     System.out.println("editLabel - walletData returns null");
     return false;
   }
   for (int i = 0; i < walletData.GetBitcoinAcctCount(); i++) {
     BitcoinAcct btcAcct = walletData.GetBitcoinAcct(i);
     if (btcAcct == null) continue;
     if (accountID.equals(btcAcct.getAcct_id())) {
       btcAcct.setGui_label(newLabel);
       status = otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat");
       System.out.println("Edit label status otapi.StoreObject:" + status);
       break;
     }
   }
   return status;
 }