// ----------------------------------------
// Make sure we have the proper asset contract for the withdrawal.
//
String assetContract = otapiJNI.OTAPI_Basic_LoadAssetContract(assetID);
if (!Utility.VerifyStringVal(assetContract)) {
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 withdrawCash: OTAPI_Func.SendRequest(GET_CONTRACT) failed. (I give up.) (Unable to find asset contract.)");
return false;
}
// ----------------------------------------
assetContract = otapiJNI.OTAPI_Basic_LoadAssetContract(assetID);
if (!Utility.VerifyStringVal(assetContract)) {
System.out.println("OT_API_LoadAssetContract returned null even after OT_API_getContract (Unable to find asset contract.)");
return false;
}
}
// ---------------------------------------------------------
// Download the public mintfile if it's not there, or if it's expired.
// Also load it up into memory as a string (just to make sure it works.)
// Then we can actually send the withdrawal transaction request. (Until
// then, why bother?)
//
String mintFile;
// expired or missing.
if (true != otapiJNI.OTAPI_Basic_Mint_IsStillGood(serverID, assetID))
{
// ----------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MINT, serverID, nymID, assetID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MINT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN withdrawCash: OTAPI_Func.SendRequest(GET_MINT) failed. (I give up.) (Unable to get mint.)");
return false;
}
// ----------------------------------------
mintFile = otapiJNI.OTAPI_Basic_LoadMint(serverID, assetID);
if (!Utility.VerifyStringVal(mintFile)) {
System.out.println("OT_API_LoadMint returned null even after OT_API_getMint (I give up.) (Unable to find mint.)");
return false;
}
}
else // current mint IS available already on local storage (and not expired.)
{
mintFile = otapiJNI.OTAPI_Basic_LoadMint(serverID, assetID);
if (!Utility.VerifyStringVal(mintFile)) {
System.out.println("OT_API_LoadMint returned null even after successful OT_API_Mint_IsStillGood (I give up.) (Unable to find mint.)");
return false;
}
}
// ---------------------------------------------------
// By this point, the mintfile is DEFINITELY good (available, not null,
// not expired, and loaded up.) Now we know for a fact that when the API
// call is made to withdraw cash, that it will find the mint properly.
//
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.WITHDRAW_CASH, serverID, nymID, accountID, amount);
String strResponse = OTAPI_Func.SendTransaction(theRequest, "WITHDRAW_CASH"); // <========================
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("OTAPI_Func.SendTransaction() failed, in withdrawCash.");
return false;