use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class OpenTransactionAccount method createAssetAccount.
private boolean createAssetAccount(String serverID, String nymID, String assetID) {
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.CREATE_ASSET_ACCT, serverID, nymID, assetID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "CREATE_ASSET_ACCT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN createAssetAccount: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return false;
}
// ----------------------------------------------------------
String strNewAcctID = otapiJNI.OTAPI_Basic_Message_GetNewAcctID(strResponse);
otapiJNI.OTAPI_Basic_SetAccountWallet_Name(strNewAcctID, nymID, label);
// When you first create an asset account you need to get a copy of the outbox.
// (Or create an empty one, which would save us sending the message here. Todo.)
//
Utility.OTBool bWasMsgSent = new Utility.OTBool(false);
Helpers.getOutboxLowLevel(serverID, nymID, strNewAcctID, bWasMsgSent, true);
return true;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class OpenTransactionAccount method sendTransfer.
public boolean sendTransfer(String serverID, String nymID, String accountID, String amount, String note, String recepientAccountID) {
boolean isSuccess = false;
System.out.println("In sendTransfer serverID:" + serverID + " nymID:" + nymID + " acount ID:" + accountID);
// ---------------------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.SEND_TRANSFER, serverID, nymID, accountID, recepientAccountID, amount, note);
// <========================
String strResponse = OTAPI_Func.SendTransaction(theRequest, "SEND_TRANSFER");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("OTAPI_Func.SendTransaction() failed, in sendTransfer.");
return false;
}
return true;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class OpenTransactionAccount method deleteAccount.
@Override
public boolean deleteAccount(String accountID) throws Exception {
boolean deleteAccount = otapiJNI.OTAPI_Basic_Wallet_CanRemoveAccount(accountID);
if (!deleteAccount) {
System.out.println("deleteAccount: unable. There must still be open receipts, or a nonzero balance?");
return false;
}
// ----------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.DELETE_ASSET_ACCT, serverID, nymID, accountID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "DELETE_ASSET_ACCT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN deleteAccount: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return false;
}
// ----------------------------------------
// BY THIS POINT, we successfully deleted the account from the server.
// Now we just need to remove it from the wallet (todo).
// TODO
//deleteAccount = otapiJNI.OTAPI_Basic_Wallet_RemoveAccount(accountID) == 1 ? true : false;
System.out.println("IN deleteAccount: THIS IS THE SPOT WHERE, THE **DELETE ACCOUNT** MESSAGE TO THE SERVER WAS SUCCESSFUL, THREFORE WE CAN GO AHEAD AND DELETE THE LOCAL ONE AS WELL. (TODO.)");
return true;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class OpenTransactionAccount method showBasket.
public String showBasket(String serverID, String nymID, String assetID) throws InterruptedException {
if (!Utility.VerifyStringVal(otapiJNI.OTAPI_Basic_LoadAssetContract(assetID))) {
System.out.println("IN showBasket, OT_API_LoadAssetContract is null");
// ----------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_CONTRACT, serverID, nymID, assetID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_CONTRACT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN showBasket: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return null;
}
}
// ----------------------------------------
StringBuilder basket = new StringBuilder();
String minTransferAmt = otapiJNI.OTAPI_Basic_Basket_GetMinimumTransferAmount(assetID);
String assetName = otapiJNI.OTAPI_Basic_GetAssetType_Name(assetID);
System.out.println("showBasket --minTransferAmt:" + minTransferAmt + " assetName:" + assetName);
basket.append(minTransferAmt);
basket.append(" ");
basket.append(assetName);
basket.append(" == ");
int basketMemberCount = otapiJNI.OTAPI_Basic_Basket_GetMemberCount(assetID);
System.out.println("showBasket --basketMemberCount:" + basketMemberCount);
for (int i = 0; i < basketMemberCount; i++) {
String memberAssetID = otapiJNI.OTAPI_Basic_Basket_GetMemberType(assetID, i);
System.out.println("showBasket memberAssetID:" + memberAssetID);
if (Utility.VerifyStringVal(memberAssetID)) {
String minTransferAmtMember = otapiJNI.OTAPI_Basic_Basket_GetMemberMinimumTransferAmount(assetID, i);
System.out.println("showBasket minTransferAmtMember:" + minTransferAmtMember);
basket.append(minTransferAmtMember);
basket.append(" ");
basket.append(otapiJNI.OTAPI_Basic_GetAssetType_Name(memberAssetID));
if (i != basketMemberCount - 1) {
basket.append(", ");
}
}
}
System.out.println("showBasket -- basket.toString():" + basket.toString());
return basket.toString();
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class Basket method getAssetTypeNameForRegNym.
public static String getAssetTypeNameForRegNym(String assetTypeID, String serverID, String nymID) {
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_CONTRACT, serverID, nymID, assetTypeID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_CONTRACT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN getAssetTypeNameForRegNym: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return null;
}
return !Utility.VerifyStringVal(otapiJNI.OTAPI_Basic_GetAssetType_Name(assetTypeID)) ? "" : otapiJNI.OTAPI_Basic_GetAssetType_Name(assetTypeID);
}
Aggregations