Search in sources :

Example 1 with BitcoinAcct

use of org.opentransactions.otapi.BitcoinAcct 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)

Aggregations

BitcoinAcct (org.opentransactions.otapi.BitcoinAcct)1 BitcoinServer (org.opentransactions.otapi.BitcoinServer)1