Search in sources :

Example 1 with BitcoinServer

use of org.opentransactions.otapi.BitcoinServer in project otapij by FellowTraveler.

the class StorageHelper method removeBitcoinServer.

private static boolean removeBitcoinServer(WalletData walletData, String serverID) {
    boolean status = false;
    for (int i = 0; i < walletData.GetBitcoinServerCount(); i++) {
        BitcoinServer btcServer = walletData.GetBitcoinServer(i);
        if (btcServer == null) {
            continue;
        }
        if (serverID.equals(btcServer.getServer_id())) {
            // Put logic for checking if accounts exist
            for (int j = 0; j < walletData.GetBitcoinAcctCount(); j++) {
                BitcoinAcct btcAcct = walletData.GetBitcoinAcct(j);
                if (btcAcct == null) {
                    continue;
                }
                if (serverID.equals(btcAcct.getServer_id())) {
                    walletData.RemoveBitcoinAcct(j);
                    if (otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat")) {
                        walletData = Helpers.getWalletData();
                        if (walletData == null) {
                            System.out.println("removeOtherTabServer After RemoveBitcoinAcct - walletData returns null");
                            return false;
                        }
                    }
                }
            }
            if (walletData == null) {
                System.out.println("removeOtherTabServer Before RemoveBitcoinServer - walletData returns null");
                return false;
            }
            walletData.RemoveBitcoinServer(i);
            status = otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat");
            System.out.println("removeOtherTabServer status otapi.StoreObject:" + status);
            break;
        }
    }
    return status;
}
Also used : BitcoinAcct(org.opentransactions.otapi.BitcoinAcct) BitcoinServer(org.opentransactions.otapi.BitcoinServer)

Example 2 with BitcoinServer

use of org.opentransactions.otapi.BitcoinServer in project otapij by FellowTraveler.

the class StorageHelper method addBitcoinServer.

//Other Tab
public static String addBitcoinServer(String label, String host, String user, String pwd, String port) {
    String serverID = Helpers.generateID();
    WalletData walletData = Helpers.getWalletData();
    if (walletData == null) {
        System.out.println("addBitcoinServer - walletData returns null");
        return null;
    }
    BitcoinServer btcServer = null;
    Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_BITCOIN_SERVER);
    if (storable != null) {
        btcServer = BitcoinServer.ot_dynamic_cast(storable);
        if (btcServer != null) {
            btcServer.setServer_host(host);
            btcServer.setBitcoin_password(pwd);
            btcServer.setBitcoin_username(user);
            btcServer.setServer_port(port);
            btcServer.setGui_label(label);
            btcServer.setServer_id(serverID);
            btcServer.setServer_type("Bitcoin");
            boolean status = walletData.AddBitcoinServer(btcServer);
            System.out.println("status walletData.AddBitcoinServer:" + status);
            status = otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat");
            System.out.println("status otapi.StoreObject:" + status);
            System.out.println("addBitcoinServer - serverID:" + serverID);
        }
    }
    return serverID;
}
Also used : BitcoinServer(org.opentransactions.otapi.BitcoinServer) WalletData(org.opentransactions.otapi.WalletData) Storable(org.opentransactions.otapi.Storable)

Example 3 with BitcoinServer

use of org.opentransactions.otapi.BitcoinServer in project otapij by FellowTraveler.

the class StorageHelper method editBitcoinServerLabel.

private static boolean editBitcoinServerLabel(WalletData walletData, String serverID, String newLabel) {
    boolean status = false;
    for (int i = 0; i < walletData.GetBitcoinServerCount(); i++) {
        BitcoinServer btcServer = walletData.GetBitcoinServer(i);
        if (btcServer == null) {
            continue;
        }
        if (serverID.equals(btcServer.getServer_id())) {
            btcServer.setGui_label(newLabel);
            status = otapi.StoreObject(walletData, "moneychanger", "gui_wallet.dat");
            System.out.println("editOtherTabServerLabel status otapi.StoreObject:" + status);
            break;
        }
    }
    return status;
}
Also used : BitcoinServer(org.opentransactions.otapi.BitcoinServer)

Example 4 with BitcoinServer

use of org.opentransactions.otapi.BitcoinServer in project otapij by FellowTraveler.

the class StorageHelper method getBitcoinServerList.

private static void getBitcoinServerList(WalletData walletData, HashMap dataMap) {
    long count = walletData.GetBitcoinServerCount();
    for (int i = 0; i < count; i++) {
        BitcoinServer btcServer = walletData.GetBitcoinServer(i);
        if (btcServer == null) {
            continue;
        }
        String[] data = new String[3];
        data[0] = btcServer.getGui_label();
        data[1] = "BitcoinAccount";
        data[2] = btcServer.getServer_id();
        dataMap.put(data[2], data);
    }
}
Also used : BitcoinServer(org.opentransactions.otapi.BitcoinServer)

Aggregations

BitcoinServer (org.opentransactions.otapi.BitcoinServer)4 BitcoinAcct (org.opentransactions.otapi.BitcoinAcct)1 Storable (org.opentransactions.otapi.Storable)1 WalletData (org.opentransactions.otapi.WalletData)1