Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTAPI_Func Class Reference

#include <ot_otapi_ot.hpp>

Collaboration diagram for OTAPI_Func:

Public Member Functions

 OTAPI_Func ()
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_strParam)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_strParam, int64_t p_lData)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_strParam, const std::string &p_strData)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_nymID2, const std::string &p_strData, const std::string &p_strData2)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_accountID, const std::string &p_strParam, int64_t p_lData, const std::string &p_strData2)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_accountID, const std::string &p_strParam, const std::string &p_strData, int64_t p_lData2)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_accountID, const std::string &p_strParam, const std::string &p_strData, const std::string &p_strData2)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &p_assetID, const std::string &p_basket, const std::string &p_accountID, bool p_bBool, int32_t p_nTransNumsNeeded)
 
 OTAPI_Func (OTAPI_Func_Type theType, const std::string &p_serverID, const std::string &p_nymID, const std::string &assetAccountID, const std::string &currencyAcctID, const std::string &scale, const std::string &minIncrement, const std::string &quantity, const std::string &price, bool bSelling)
 
 ~OTAPI_Func ()
 
OT_OTAPI_OT void InitCustom ()
 
OT_OTAPI_OT int32_t Run () const
 
OT_OTAPI_OT std::string SendRequest (OTAPI_Func &theFunction, const std::string &IN_FUNCTION) const
 
OT_OTAPI_OT int32_t SendRequestLowLevel (OTAPI_Func &theFunction, const std::string &IN_FUNCTION) const
 
OT_OTAPI_OT std::string SendRequestOnce (OTAPI_Func &theFunction, const std::string &IN_FUNCTION, bool bIsTransaction, bool bWillRetryAfterThis, bool &bCanRetryAfterThis) const
 
OT_OTAPI_OT std::string SendTransaction (OTAPI_Func &theFunction, const std::string &IN_FUNCTION)
 
OT_OTAPI_OT std::string SendTransaction (OTAPI_Func &theFunction, const std::string &IN_FUNCTION, int32_t nTotalRetries) const
 

Static Public Member Functions

EXPORT static OT_OTAPI_OT void CopyVariables ()
 

Public Attributes

OTAPI_Func_Type funcType
 
std::string serverID
 
std::string nymID
 
std::string nymID2
 
std::string assetID
 
std::string assetID2
 
std::string accountID
 
std::string accountID2
 
std::string basket
 
std::string strData
 
std::string strData2
 
std::string strData3
 
std::string strData4
 
std::string strData5
 
bool bBool
 
int32_t nData
 
int64_t lData
 
time64_t tData
 
int32_t nTransNumsNeeded
 
int32_t nRequestNum
 

Detailed Description

Definition at line 257 of file ot_otapi_ot.hpp.

Constructor & Destructor Documentation

OTAPI_Func::OTAPI_Func ( )

Definition at line 190 of file ot_otapi_ot.cpp.

191 {
192  // otOut << "(Version of OTAPI_Func with 0 arguments.)\n";
193 
194  InitCustom();
195 }
OT_OTAPI_OT void InitCustom()
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID 
)

Definition at line 201 of file ot_otapi_ot.cpp.

203 {
204  // otOut << "(Version of OTAPI_Func with 3 arguments.)\n";
205 
206  InitCustom();
207 
208  string strError =
209  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
210  if (!VerifyStringVal(p_serverID)) {
211  otOut << strError << "p_serverID";
212  }
213  if (!VerifyStringVal(p_nymID)) {
214  otOut << strError << "p_nymID";
215  }
216 
217  funcType = theType;
218  serverID = p_serverID;
219  nymID = p_nymID;
220  nTransNumsNeeded = 1;
221  bBool = false;
222 }
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_OTAPI_OT void InitCustom()
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_strParam 
)

Definition at line 224 of file ot_otapi_ot.cpp.

226 {
227  // otOut << "(Version of OTAPI_Func with 4 arguments.)\n";
228 
229  InitCustom();
230 
231  string strError =
232  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
233  if (!VerifyStringVal(p_serverID)) {
234  otOut << strError << "p_serverID";
235  }
236  if (!VerifyStringVal(p_nymID)) {
237  otOut << strError << "p_nymID";
238  }
239  if (!VerifyStringVal(p_strParam)) {
240  otOut << strError << "p_strParam";
241  }
242 
243  funcType = theType;
244  serverID = p_serverID;
245  nymID = p_nymID;
246  nTransNumsNeeded = 1;
247  bBool = false;
248 
249  if (theType == ISSUE_BASKET) {
250  basket = p_strParam;
251  }
252  else if ((theType == GET_MINT) || (theType == GET_CONTRACT) ||
253  (theType == CREATE_ASSET_ACCT)) {
254  assetID = p_strParam;
255  }
256  else if (theType == CHECK_USER) {
257  nymID2 = p_strParam;
258  }
259  else if (theType == DELETE_ASSET_ACCT) {
260  accountID = p_strParam;
261  }
262  else if ((theType == ISSUE_ASSET_TYPE) ||
263  (theType == GET_MARKET_RECENT_TRADES) ||
264  (theType == QUERY_ASSET_TYPES)) {
265  strData = p_strParam;
266  }
267  else {
268  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func()\n";
269  }
270 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
std::string basket
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string assetID
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID2
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_strParam,
int64_t  p_lData 
)

Definition at line 322 of file ot_otapi_ot.cpp.

325 {
326  // otOut << "(Version of OTAPI_Func with 5 arguments.)\n";
327 
328  InitCustom();
329 
330  string strError =
331  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
332  if (!VerifyStringVal(p_serverID)) {
333  otOut << strError << "p_serverID \n";
334  }
335  if (!VerifyStringVal(p_nymID)) {
336  otOut << strError << "p_nymID \n";
337  }
338 
339  if (!VerifyStringVal(p_strParam)) {
340  otOut << strError << "p_strParam \n";
341  }
342 
343  funcType = theType;
344  serverID = p_serverID;
345  nymID = p_nymID;
346  nTransNumsNeeded = 1;
347  bBool = false;
348 
349  if (theType == WITHDRAW_CASH) {
350  accountID = p_strParam;
351  lData = p_lData;
352  }
353  else if (theType == GET_MARKET_OFFERS) {
354  strData = p_strParam;
355  lData = p_lData;
356  }
357  else {
358  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func()\n";
359  }
360 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
int64_t lData
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_strParam,
const std::string &  p_strData 
)

Definition at line 272 of file ot_otapi_ot.cpp.

275 {
276  // otOut << "(Version of OTAPI_Func with 5 arguments.)\n";
277 
278  InitCustom();
279 
280  string strError =
281  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
282  if (!VerifyStringVal(p_serverID)) {
283  otOut << strError << "p_serverID \n";
284  }
285  if (!VerifyStringVal(p_nymID)) {
286  otOut << strError << "p_nymID \n";
287  }
288 
289  if (!VerifyStringVal(p_strParam)) {
290  otOut << strError << "p_strParam \n";
291  }
292 
293  if (!VerifyStringVal(p_strData)) {
294  otOut << strError << "p_strData \n";
295  }
296 
297  funcType = theType;
298  serverID = p_serverID;
299  nymID = p_nymID;
300  nTransNumsNeeded = 1;
301  bBool = false;
302 
303  if ((theType == KILL_MARKET_OFFER) || (theType == KILL_PAYMENT_PLAN) ||
304  (theType == PROCESS_INBOX) || (theType == DEPOSIT_CASH) ||
305  (theType == DEPOSIT_CHEQUE) || (theType == DEPOSIT_PAYMENT_PLAN)) {
306  accountID = p_strParam;
307  strData = p_strData;
308  }
309  else if (theType == ADJUST_USAGE_CREDITS) {
310  nymID2 = p_strParam; // target nym ID
311  strData = p_strData; // adjustment (up or down.)
312  }
313  else if (theType == EXCHANGE_CASH) {
314  assetID = p_strParam;
315  strData = p_strData;
316  }
317  else {
318  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func()\n";
319  }
320 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string assetID
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID2
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_nymID2,
const std::string &  p_strData,
const std::string &  p_strData2 
)

Definition at line 362 of file ot_otapi_ot.cpp.

365 {
366  // otOut << "(Version of OTAPI_Func with 6 arguments.)\n";
367  InitCustom();
368 
369  string strError =
370  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
371  if (!VerifyStringVal(p_serverID)) {
372  otOut << strError << "p_serverID";
373  }
374  if (!VerifyStringVal(p_nymID)) {
375  otOut << strError << "p_nymID";
376  }
377  if (!VerifyStringVal(p_nymID2)) {
378  otOut << strError << "p_nymID2";
379  }
380  if (!VerifyStringVal(p_strData)) {
381  otOut << strError << "p_strData";
382  }
383  if (!VerifyStringVal(p_strData2)) {
384  otOut << strError << "p_strData2";
385  }
386 
387  funcType = theType;
388  serverID = p_serverID;
389  nymID = p_nymID;
390  nTransNumsNeeded = 1;
391  bBool = false;
392 
393  if ((theType == SEND_USER_MESSAGE) || (theType == SEND_USER_INSTRUMENT)) {
394  nymID2 = p_nymID2;
395  strData = p_strData;
396  strData2 = p_strData2;
397  }
398  else if (theType == TRIGGER_CLAUSE) {
399  strData = p_nymID2;
400  strData2 = p_strData;
401  strData3 = p_strData2;
402  }
403  else if (theType == ACTIVATE_SMART_CONTRACT) {
404 
405  accountID = p_nymID2; // the "official" asset account of the party
406  // activating the contract.;
407  strData = p_strData; // the agent's name for that party, as listed on
408  // the contract.;
409  strData2 = p_strData2; // the smart contract itself.;
410 
411  int32_t nNumsNeeded =
412  OTAPI_Wrap::SmartContract_CountNumsNeeded(p_strData2, p_strData);
413 
414  if (nNumsNeeded > 0) {
415  nTransNumsNeeded = nNumsNeeded;
416  }
417  }
418  else if (theType == GET_BOX_RECEIPT) {
419  accountID = p_nymID2; // accountID (inbox/outbox) or NymID (nymbox) is
420  // passed here.;
421  nData = stol(p_strData);
422  strData = p_strData2; // transaction number passed here as string;
423  }
424  else {
425  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func() "
426  "ERROR!!!!!!\n";
427  }
428 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
int32_t nData
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string strData2
std::string strData3
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID2
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_accountID,
const std::string &  p_strParam,
int64_t  p_lData,
const std::string &  p_strData2 
)

Definition at line 430 of file ot_otapi_ot.cpp.

434 {
435  // otOut << "(Version of OTAPI_Func with 7 arguments.)\n";
436 
437  InitCustom();
438 
439  string strError =
440  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
441  if (!VerifyStringVal(p_serverID)) {
442  otOut << strError << "p_serverID";
443  }
444  if (!VerifyStringVal(p_nymID)) {
445  otOut << strError << "p_nymID";
446  }
447  if (!VerifyStringVal(p_accountID)) {
448  otOut << strError << "p_accountID";
449  }
450  if (!VerifyStringVal(p_strParam)) {
451  otOut << strError << "p_strParam";
452  }
453 
454  funcType = theType;
455  serverID = p_serverID;
456  nymID = p_nymID;
457  nTransNumsNeeded = 1;
458  bBool = false;
459  accountID = p_accountID;
460 
461  if (theType == SEND_TRANSFER) {
462  if (!VerifyStringVal(p_strData2)) {
463  otOut << strError << "p_strData2";
464  }
465  accountID2 = p_strParam;
466  lData = p_lData; // int64_t Amount;
467  strData = p_strData2; // str Note;
468  }
469  else {
470  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func() "
471  "ERROR!!!!!!\n";
472  }
473 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
int64_t lData
std::string strData
std::string accountID2
OT_OTAPI_OT void InitCustom()
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_accountID,
const std::string &  p_strParam,
const std::string &  p_strData,
int64_t  p_lData2 
)

Definition at line 475 of file ot_otapi_ot.cpp.

479 {
480  // otOut << "(Version of OTAPI_Func with 7 arguments.)\n";
481 
482  InitCustom();
483 
484  string strError =
485  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
486  if (!VerifyStringVal(p_serverID)) {
487  otOut << strError << "p_serverID";
488  }
489  if (!VerifyStringVal(p_nymID)) {
490  otOut << strError << "p_nymID";
491  }
492  if (!VerifyStringVal(p_accountID)) {
493  otOut << strError << "p_accountID";
494  }
495  if (!VerifyStringVal(p_strParam)) {
496  otOut << strError << "p_strParam";
497  }
498 
499  funcType = theType;
500  serverID = p_serverID;
501  nymID = p_nymID;
502  nTransNumsNeeded = 1;
503  bBool = false;
504  accountID = p_accountID;
505 
506  if (theType == WITHDRAW_VOUCHER) {
507  if (!VerifyStringVal(p_strData)) {
508  otOut << strError << "p_strData";
509  }
510  nymID2 = p_strParam; // str Recipient Nym ID;
511  strData = p_strData; // str Memo;
512  lData = p_lData2; // int64_t Amount;
513  }
514  else if (theType == PAY_DIVIDEND) {
515  if (!VerifyStringVal(p_strData)) {
516  otOut << strError << "p_strData";
517  }
518  assetID = p_strParam; // str Shares Asset ID;
519  strData = p_strData; // str Memo;
520  lData = p_lData2; // int64_t Amount Per Share;
521  }
522  else {
523  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func() "
524  "ERROR!!!!!!\n";
525  }
526 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
int64_t lData
std::string assetID
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID2
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_accountID,
const std::string &  p_strParam,
const std::string &  p_strData,
const std::string &  p_strData2 
)

Definition at line 528 of file ot_otapi_ot.cpp.

532 {
533  // otOut << "(Version of OTAPI_Func with 7 arguments.)\n";
534 
535  InitCustom();
536 
537  string strError =
538  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
539  if (!VerifyStringVal(p_serverID)) {
540  otOut << strError << "p_serverID";
541  }
542  if (!VerifyStringVal(p_nymID)) {
543  otOut << strError << "p_nymID";
544  }
545  if (!VerifyStringVal(p_accountID)) {
546  otOut << strError << "p_accountID";
547  }
548  if (!VerifyStringVal(p_strParam)) {
549  otOut << strError << "p_strParam";
550  }
551 
552  funcType = theType;
553  serverID = p_serverID;
554  nymID = p_nymID;
555  nTransNumsNeeded = 1;
556  bBool = false;
557  accountID = p_accountID;
558 
559  if (theType == SEND_USER_INSTRUMENT) {
560  if (!VerifyStringVal(p_accountID)) {
561  otOut << strError << "p_accountID";
562  }
563  if (!VerifyStringVal(p_strParam)) {
564  otOut << strError << "p_strParam";
565  }
566  if (!VerifyStringVal(p_strData)) {
567  otOut << strError << "p_strData";
568  }
569  nymID2 = p_accountID; // Recipient Nym;
570  strData = p_strParam; // Recipient pubkey;
571  strData2 = p_strData; // Instrument for recipient.;
572  accountID =
573  p_strData2; // sender_instrument is attached here. (Optional.);
574  }
575  else {
576  otOut << "ERROR! WRONG TYPE passed to OTAPI_Func.OTAPI_Func() "
577  "ERROR!!!!!!\n";
578  }
579 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string strData2
std::string strData
OT_OTAPI_OT void InitCustom()
std::string nymID2
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  p_assetID,
const std::string &  p_basket,
const std::string &  p_accountID,
bool  p_bBool,
int32_t  p_nTransNumsNeeded 
)

Definition at line 581 of file ot_otapi_ot.cpp.

585 {
586  // otOut << "(Version of OTAPI_Func with 8 arguments.)\n";
587 
588  InitCustom();
589 
590  string strError =
591  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
592  if (!VerifyStringVal(p_serverID)) {
593  otOut << strError << "p_serverID";
594  }
595  if (!VerifyStringVal(p_nymID)) {
596  otOut << strError << "p_nymID";
597  }
598  if (!VerifyStringVal(p_assetID)) {
599  otOut << strError << "p_assetID";
600  }
601  if (!VerifyStringVal(p_accountID)) {
602  otOut << strError << "p_accountID";
603  }
604  if (!VerifyStringVal(p_basket)) {
605  otOut << strError << "p_basket";
606  }
607 
608  funcType = theType;
609  serverID = p_serverID;
610  nymID = p_nymID;
611  nTransNumsNeeded = p_nTransNumsNeeded;
612  bBool = p_bBool;
613  assetID = p_assetID;
614  basket = p_basket;
615  accountID = p_accountID;
616 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
std::string basket
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string assetID
OT_OTAPI_OT void InitCustom()
std::string nymID
OTAPI_Func::OTAPI_Func ( OTAPI_Func_Type  theType,
const std::string &  p_serverID,
const std::string &  p_nymID,
const std::string &  assetAccountID,
const std::string &  currencyAcctID,
const std::string &  scale,
const std::string &  minIncrement,
const std::string &  quantity,
const std::string &  price,
bool  bSelling 
)

Definition at line 618 of file ot_otapi_ot.cpp.

623 {
624  // otOut << "(Version of OTAPI_Func with 10 arguments.)\n";
625 
626  InitCustom();
627 
628  string strError =
629  "ERROR! Empty string passed to OTAPI_Func.OTAPI_Func() as: ";
630  if (!VerifyStringVal(p_serverID)) {
631  otOut << strError << "p_serverID";
632  }
633  if (!VerifyStringVal(p_nymID)) {
634  otOut << strError << "p_nymID";
635  }
636  if (!VerifyStringVal(assetAccountID)) {
637  otOut << strError << "assetAccountID";
638  }
639  if (!VerifyStringVal(currencyAcctID)) {
640  otOut << strError << "currencyAcctID";
641  }
642  if (!VerifyStringVal(scale)) {
643  otOut << strError << "scale";
644  }
645  if (!VerifyStringVal(minIncrement)) {
646  otOut << strError << "minIncrement";
647  }
648  if (!VerifyStringVal(quantity)) {
649  otOut << strError << "quantity";
650  }
651  if (!VerifyStringVal(price)) {
652  otOut << strError << "price";
653  }
654 
655  funcType = theType;
656  serverID = p_serverID;
657  nymID = p_nymID;
658  accountID = assetAccountID;
659  accountID2 = currencyAcctID;
660 
661  strData = scale;
662  strData2 = minIncrement;
663  strData3 = quantity;
664  strData4 = price;
665 
666  strData5 = ""; // Will be set after this function is called, since there
667  // were too many arguments.
668 
669  bBool = bSelling;
670 
671  nTransNumsNeeded = 3; // An opening transaction number, plus another for
672  // each asset account, total of 3.
673 }
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
OTAPI_Func_Type funcType
std::string serverID
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string strData2
std::string strData3
std::string strData
std::string strData5
std::string accountID2
OT_OTAPI_OT void InitCustom()
std::string strData4
std::string nymID
OTAPI_Func::~OTAPI_Func ( )

Definition at line 197 of file ot_otapi_ot.cpp.

198 {
199 }

Member Function Documentation

OT_OTAPI_OT void OTAPI_Func::CopyVariables ( )
static

Definition at line 167 of file ot_otapi_ot.cpp.

168 {
169  Args = GetVariable("Args");
170  HisAcct = GetVariable("HisAcct");
171  HisNym = GetVariable("HisNym");
172  HisPurse = GetVariable("HisPurse");
173  MyAcct = GetVariable("MyAcct");
174  MyNym = GetVariable("MyNym");
175  MyPurse = GetVariable("MyPurse");
176  Server = GetVariable("Server");
177 }
std::string Server
std::string HisAcct
string GetVariable(const char *name)
std::string HisNym
std::string HisPurse
std::string MyPurse
std::string Args
std::string MyNym
std::string MyAcct
OT_OTAPI_OT void OTAPI_Func::InitCustom ( )

Definition at line 179 of file ot_otapi_ot.cpp.

180 {
181  bBool = false;
182  nData = 0;
183  lData = 0;
185  nTransNumsNeeded = 0;
186  nRequestNum = -1;
187  funcType = NO_FUNC;
188 }
int32_t nTransNumsNeeded
OTAPI_Func_Type funcType
time64_t tData
int32_t nData
int32_t nRequestNum
int64_t lData
#define OT_TIME_ZERO
Definition: Common.hpp:180
OT_OTAPI_OT int32_t OTAPI_Func::Run ( ) const

Definition at line 675 of file ot_otapi_ot.cpp.

676 {
677  // -1 means error, no message was sent.
678  // 0 means NO error, yet still no message was sent.
679  // >0 means (usually) the request number is being returned.
680  //
681  switch (funcType) {
682  case CHECK_USER:
683  return OTAPI_Wrap::checkUser(serverID, nymID, nymID2);
684  case CREATE_USER_ACCT:
685  return OTAPI_Wrap::createUserAccount(serverID, nymID);
686  case DELETE_USER_ACCT:
687  return OTAPI_Wrap::deleteUserAccount(serverID, nymID);
688  case SEND_USER_MESSAGE:
689  return OTAPI_Wrap::sendUserMessage(serverID, nymID, nymID2, strData,
690  strData2);
692  // accountID stores here the sender's copy of the instrument, which is
693  // used only in the case of a cash purse.
694  return OTAPI_Wrap::sendUserInstrument(serverID, nymID, nymID2, strData,
697  return OTAPI_Wrap::getNym_MarketOffers(serverID, nymID);
698  case CREATE_ASSET_ACCT:
699  return OTAPI_Wrap::createAssetAccount(serverID, nymID, assetID);
700  case DELETE_ASSET_ACCT:
701  return OTAPI_Wrap::deleteAssetAccount(serverID, nymID, accountID);
703  return OTAPI_Wrap::activateSmartContract(serverID, nymID, strData2);
704  case TRIGGER_CLAUSE:
705  return OTAPI_Wrap::triggerClause(serverID, nymID, stoll(strData),
706  strData2, strData3);
707  case EXCHANGE_BASKET:
708  return OTAPI_Wrap::exchangeBasket(serverID, nymID, assetID, basket,
709  bBool);
710  case GET_CONTRACT:
711  return OTAPI_Wrap::getContract(serverID, nymID, assetID);
712  case GET_MINT:
713  return OTAPI_Wrap::getMint(serverID, nymID, assetID);
714  case QUERY_ASSET_TYPES:
715  return OTAPI_Wrap::queryAssetTypes(serverID, nymID, strData);
716  case ISSUE_ASSET_TYPE:
717  return OTAPI_Wrap::issueAssetType(serverID, nymID, strData);
718  case ISSUE_BASKET:
719  return OTAPI_Wrap::issueBasket(serverID, nymID, basket);
720  case EXCHANGE_CASH:
721  return OTAPI_Wrap::exchangePurse(serverID, assetID, nymID, strData);
722  case KILL_MARKET_OFFER:
723  return OTAPI_Wrap::killMarketOffer(serverID, nymID, accountID,
724  stoll(strData));
725  case KILL_PAYMENT_PLAN:
726  return OTAPI_Wrap::killPaymentPlan(serverID, nymID, accountID,
727  stoll(strData));
728  case GET_BOX_RECEIPT:
729  return OTAPI_Wrap::getBoxReceipt(serverID, nymID, accountID, nData,
730  stoll(strData));
731  case PROCESS_INBOX:
732  return OTAPI_Wrap::processInbox(serverID, nymID, accountID, strData);
733  case DEPOSIT_CASH:
734  return OTAPI_Wrap::notarizeDeposit(serverID, nymID, accountID, strData);
735  case DEPOSIT_CHEQUE:
736  return OTAPI_Wrap::depositCheque(serverID, nymID, accountID, strData);
738  return OTAPI_Wrap::depositPaymentPlan(serverID, nymID, strData);
739  case WITHDRAW_CASH:
740  return OTAPI_Wrap::notarizeWithdrawal(serverID, nymID, accountID,
741  lData);
742  case WITHDRAW_VOUCHER:
743  return OTAPI_Wrap::withdrawVoucher(serverID, nymID, accountID, nymID2,
744  strData, lData);
745  case PAY_DIVIDEND:
746  return OTAPI_Wrap::payDividend(serverID, nymID, accountID, assetID,
747  strData, lData);
748  case SEND_TRANSFER:
749  return OTAPI_Wrap::notarizeTransfer(serverID, nymID, accountID,
751  case GET_MARKET_LIST:
752  return OTAPI_Wrap::getMarketList(serverID, nymID);
753  case GET_MARKET_OFFERS:
754  return OTAPI_Wrap::getMarketOffers(serverID, nymID, strData, lData);
756  return OTAPI_Wrap::getMarketRecentTrades(serverID, nymID, strData);
757  case CREATE_MARKET_OFFER:
758  return OTAPI_Wrap::issueMarketOffer(
759  accountID, accountID2, stoll(strData), stoll(strData2),
760  stoll(strData3), stoll(strData4), bBool, tData, strData5, lData);
762  return OTAPI_Wrap::usageCredits(serverID, nymID, nymID2,
763  stoll(strData));
764  default:
765  break;
766  }
767 
768  otOut << "ERROR! OTAPI_Func.Send() activated, with bad function type: "
769  << funcType << "\n";
770 
771  return -1;
772 }
std::string accountID
OTLOG_IMPORT OTLogStream otOut
std::string basket
OTAPI_Func_Type funcType
time64_t tData
int32_t nData
std::string serverID
int64_t lData
std::string strData2
std::string assetID
std::string strData3
std::string strData
std::string strData5
std::string accountID2
std::string strData4
std::string nymID2
std::string nymID
OT_OTAPI_OT string OTAPI_Func::SendRequest ( OTAPI_Func theFunction,
const std::string &  IN_FUNCTION 
) const

Definition at line 996 of file ot_otapi_ot.cpp.

998 {
999  Utility MsgUtil;
1000 
1001  bool bCanRetryAfterThis = false;
1002 
1003  string strResult = SendRequestOnce(theFunction, IN_FUNCTION, false, true,
1004  bCanRetryAfterThis);
1005 
1006  if (!VerifyStringVal(strResult) && bCanRetryAfterThis) {
1007  strResult = SendRequestOnce(theFunction, IN_FUNCTION, false, false,
1008  bCanRetryAfterThis);
1009  }
1010  return strResult;
1011 }
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_OTAPI_OT std::string SendRequestOnce(OTAPI_Func &theFunction, const std::string &IN_FUNCTION, bool bIsTransaction, bool bWillRetryAfterThis, bool &bCanRetryAfterThis) const
OT_OTAPI_OT int32_t OTAPI_Func::SendRequestLowLevel ( OTAPI_Func theFunction,
const std::string &  IN_FUNCTION 
) const

Definition at line 775 of file ot_otapi_ot.cpp.

777 {
778  Utility MsgUtil;
779  string strLocation = "OTAPI_Func::SendRequestLowLevel: " + IN_FUNCTION;
780 
781  OTAPI_Wrap::FlushMessageBuffer();
782 
783  int32_t nRun =
784  theFunction.Run(); // <===== ATTEMPT TO SEND THE MESSAGE HERE...;
785 
786  if (nRun == -1) // if the requestNumber returned by the send-attempt is -1,
787  // that means it DIDN'T SEND (error)
788  {
789  otOut << strLocation << ": Failed to send message due to error.\n";
790 
791  theFunction.nRequestNum = -1;
792  }
793  else if (nRun == 0) // if the requestNumber returned by the send-attempt
794  // is 0, it means no error, but nothing was sent.
795  // (Like processing an empty box.)
796  {
797  otOut << strLocation << ": Didn't send this message, but NO error "
798  "occurred, either. (For example, a request to "
799  "process an empty Nymbox will return 0, "
800  "meaning, nothing was sent, but also no error "
801  "occurred.)\n";
802 
803  theFunction.nRequestNum = 0;
804  }
805  else if (nRun == (-2)) // -2 is also possible at some future date. (If the
806  // request number won't fit in an int32_t, this is
807  // returned and then you can retrieve the actual
808  // number via a separate call.)
809  {
810  otOut << strLocation << ": ERROR, not supported. (-2 was returned.)\n";
811 
812  // TODO: Have an OT API call here, which retrieves the request number
813  // (It must be too large to fit into an integer, which is why this
814  // happened.)
815 
816  theFunction.nRequestNum = -1;
817  }
818  else {
819  theFunction.nRequestNum = nRun;
820  }
821 
822  // BY this point, we definitely have the request number, which means the
823  // message was actually SENT. (At least.) This also means we can use nRun
824  // later to query for a copy of that sent message (like if we need to
825  // clawback
826  // the transaction numbers from it later, once we confirm whether the server
827  // actually never got it.)
828  //
829  return theFunction.nRequestNum;
830 }
OTLOG_IMPORT OTLogStream otOut
OT_OTAPI_OT int32_t Run() const
int32_t nRequestNum
OT_OTAPI_OT string OTAPI_Func::SendRequestOnce ( OTAPI_Func theFunction,
const std::string &  IN_FUNCTION,
bool  bIsTransaction,
bool  bWillRetryAfterThis,
bool &  bCanRetryAfterThis 
) const

Definition at line 1013 of file ot_otapi_ot.cpp.

1018 {
1019  Utility MsgUtil;
1020  string strLocation = "OTAPI_Func::SendRequestOnce: " + IN_FUNCTION;
1021 
1022  bCanRetryAfterThis = false;
1023 
1024  string strReply = "";
1025  int32_t nlocalRequestNum = SendRequestLowLevel(
1026  theFunction, IN_FUNCTION); // <======== FIRST ATTEMPT!!!!!!;
1027 
1028  if ((nlocalRequestNum == -1) || (nlocalRequestNum == 0)) {
1029  return "";
1030  }
1031  else // 1 and default.
1032  {
1033  if (nlocalRequestNum < -1) {
1034  return "";
1035  }
1036 
1037  strReply = MsgUtil.ReceiveReplyLowLevel(
1038  theFunction.serverID, theFunction.nymID, nlocalRequestNum,
1039  IN_FUNCTION); // <==== Here we RECEIVE the REPLY...;
1040  }
1041 
1042  // Below this point, we definitely have a request number.
1043  // (But not yet necessarily a reply...)
1044  //
1045 
1046  // nlocalRequestNum is positive and contains the request number from
1047  // sending.
1048  //
1049  // nReplySuccess contains status of the REPLY to that sent message.
1050  // nReplySuccess contains:
1051  // 0 == FAILURE reply msg from server,
1052  // 1 == SUCCESS reply msg from server (transaction could be success or
1053  // fail.)
1054  // -1 == (ERROR)
1055  //
1056  // strReply contains the reply itself (or null.)
1057  //
1058  int32_t nReplySuccess = VerifyMessageSuccess(strReply);
1059 
1060  bool bMsgReplyError = (!VerifyStringVal(strReply) || (nReplySuccess < 0));
1061 
1062  bool bMsgReplySuccess = (!bMsgReplyError && (nReplySuccess > 0));
1063  bool bMsgReplyFailure = (!bMsgReplyError && (nReplySuccess == 0));
1064 
1065  bool bMsgTransSuccess;
1066  bool bMsgTransFailure;
1067 
1068  bool bMsgAnyError;
1069  bool bMsgAnyFailure;
1070 
1071  bool bMsgAllSuccess;
1072 
1073  // If you EVER are in a situation where you have to harvest numbers
1074  // back, it will ONLY be for transactions, not normal messages. (Those
1075  // are the only ones that USE transaction numbers.)
1076  //
1077  if (bIsTransaction) // This request contains a TRANSACTION...
1078  {
1079  int32_t nTransSuccess;
1080  int32_t nBalanceSuccess;
1081  if (bMsgReplySuccess) // If message was success, then let's see if the
1082  // transaction was, too.
1083  {
1084  nBalanceSuccess = OTAPI_Wrap::Message_GetBalanceAgreementSuccess(
1085  theFunction.serverID, theFunction.nymID, theFunction.accountID,
1086  strReply);
1087 
1088  if (nBalanceSuccess > 0) {
1089  // Sometimes a transaction is sent that is meant to "fail" in
1090  // order to cancel itself from ever being run in the future.
1091  // It's being cancelled. In that case, whether the server reply
1092  // itself is acknowledged or rejection, either way,
1093  // IsCancelled() will be set to TRUE.
1094  // This is used when cancelling a cheque, or a payment plan, or
1095  // a smart contract, so that it can never be activated at some
1096  // future time.
1097  //
1098  // Therefore when we see that IsCancelled is set to TRUE, we
1099  // interpret it as a "success" as far as the UI is concerned,
1100  // even though behind the scenes, it is still "rejected" and
1101  // transaction numbers were harvested from it.
1102  //
1103  int32_t nTransCancelled =
1104  OTAPI_Wrap::Message_IsTransactionCanceled(
1105  theFunction.serverID, theFunction.nymID,
1106  theFunction.accountID, strReply);
1107 
1108  // If it's not cancelled, then we assume it's a normal
1109  // transaction (versus a cancellation)
1110  // and we check for success/failure as normal...
1111  //
1112  if (1 != nTransCancelled) {
1113  nTransSuccess = OTAPI_Wrap::Message_GetTransactionSuccess(
1114  theFunction.serverID, theFunction.nymID,
1115  theFunction.accountID, strReply);
1116  }
1117  else // If it WAS cancelled, then for the UI we say "Success"
1118  // even though OT behind the scenes is harvesting as
1119  // though it failed.
1120  { // (Which is what we want to happen, in the case that a
1121  // cancellation was performed.)
1122  // This way, the UI won't go off doing a bunch of
1123  // unnecessary retries for a "failed" transaction.
1124  // (After all, if it was cancelled, then we know for a fact
1125  // that all future retries will fail anyway.)
1126  //
1127  nTransSuccess = 1;
1128  }
1129  }
1130  else {
1131  nTransSuccess = -1;
1132  }
1133  }
1134  else {
1135  nBalanceSuccess = -1;
1136  nTransSuccess = -1;
1137  }
1138  // All of these booleans (except "error") represent RECEIVED ANSWERS
1139  // from the server.
1140  // In other words, "failure" does not mean "failed to find message."
1141  // Rather, it means "DEFINITELY got a reply, and that reply says
1142  // status==failure."
1143  //
1144 
1145  bool bMsgBalanceError =
1146  (!VerifyStringVal(strReply) || (nBalanceSuccess < 0));
1147  bool bMsgBalanceSuccess =
1148  (!bMsgReplyError && !bMsgBalanceError && (nBalanceSuccess > 0));
1149  bool bMsgBalanceFailure =
1150  (!bMsgReplyError && !bMsgBalanceError && (nBalanceSuccess == 0));
1151 
1152  bool bMsgTransError =
1153  (!VerifyStringVal(strReply) || (nTransSuccess < 0));
1154  bMsgTransSuccess = (!bMsgReplyError && !bMsgBalanceError &&
1155  !bMsgTransError && (nTransSuccess > 0));
1156  bMsgTransFailure = (!bMsgReplyError && !bMsgBalanceError &&
1157  !bMsgTransError && (nTransSuccess == 0));
1158 
1159  bMsgAnyError = (bMsgReplyError || bMsgBalanceError || bMsgTransError);
1160  bMsgAnyFailure =
1161  (bMsgReplyFailure || bMsgBalanceFailure || bMsgTransFailure);
1162 
1163  bMsgAllSuccess =
1164  (bMsgReplySuccess && bMsgBalanceSuccess && bMsgTransSuccess);
1165 
1166  }
1167  else // it's NOT a transaction, but a normal message..
1168  {
1169  bMsgTransSuccess = false;
1170  bMsgTransFailure = false;
1171 
1172  bMsgAnyError = (bMsgReplyError);
1173  bMsgAnyFailure = (bMsgReplyFailure);
1174 
1175  bMsgAllSuccess = (bMsgReplySuccess);
1176  }
1177 
1178  // We know the message SENT. The above logic is about figuring out whether
1179  // the reply message,
1180  // the transaction inside it, and the balance agreement inside that
1181  // transaction, whether
1182  // any of those three things is a definite error, a definite failure, or a
1183  // definite success.
1184  // (Any one of those things could be true, OR NOT, and we can only act as if
1185  // they are, if we
1186  // have definitive proof in any of those cases.)
1187  //
1188  // The below logic is about what sort of REPLY we may have gotten (if
1189  // anything.)
1190  // Without a definite reply we cannot claw back. But the Nymbox can show us
1191  // this answer,
1192  // either now, or later...
1193  //
1194  if (bMsgAllSuccess) {
1195  // the Msg was a complete success, including the message
1196  // AND the transaction AND the balance agreement.
1197  // Therefore, there's DEFINITELY nothing to clawback.
1198  //
1199  // (Thus I RemoveSentMessage for the message, since
1200  // I'm totally done with it now. NO NEED TO HARVEST anything, either.)
1201  //
1202  // var nRemoved =
1203  // OTAPI_Wrap::RemoveSentMessage(Integer.toString(nlocalRequestNum),
1204  // theFunction.serverID, theFunction.nymID);
1205  //
1206  // NOTE: The above call is unnecessary, since a successful reply means
1207  // we already received the successful server reply, and OT's
1208  // "ProcessServerReply"
1209  // already removed the sent message from the sent buffer (so no need to
1210  // do that here.)
1211 
1212  // otOut << strLocation << ", SendRequestOnce():
1213  // OT_API_RemoveSentMessage: " + nRemoved);
1214 
1215  return strReply;
1216 
1217  }
1218  // In this case we want to grab the Nymbox and see if the replyNotice is
1219  // there.
1220  // If it IS, then OT server DEFINITELY replied to it (the MESSAGE was a
1221  // success,
1222  // whether the transaction inside of it was success or fail.) So we know
1223  // bMsgReplySuccess
1224  // is true, if we find a replyNotice.
1225  // From there, we can also check for transaction success.
1226  //
1227  else if (bMsgAnyError || bMsgAnyFailure) // let's resync, and clawback
1228  // whatever transaction numbers we
1229  // might have used on the
1230  // Request...
1231  {
1232  bool bWasGetReqSent = false;
1233  int32_t nGetRequest = MsgUtil.getRequestNumber(
1234  theFunction.serverID, theFunction.nymID,
1235  bWasGetReqSent); // <==== RE-SYNC ATTEMPT...;
1236 
1237  // GET REQUEST WAS A SUCCESS.
1238  //
1239  if (bWasGetReqSent && (nGetRequest > 0)) {
1240  bCanRetryAfterThis = true;
1241 
1242  // But--if it was a TRANSACTION, then we're not done syncing yet!
1243  //
1244  if (bIsTransaction) {
1245  bCanRetryAfterThis = false;
1246 
1247  //
1248  // Maybe we have an old Inbox or something.
1249  // NEW CODE HERE FOR DEBUGGING (THIS BLOCK)
1250  //
1251  bool bForceDownload = true;
1252  if (!MsgUtil.getIntermediaryFiles(
1253  theFunction.serverID, theFunction.nymID,
1254  theFunction.accountID, bForceDownload)) {
1255  otOut << strLocation << ", getIntermediaryFiles returned "
1256  "false. (After a failure to send "
1257  "the transaction. Thus, I give "
1258  "up.)\n";
1259  return "";
1260  }
1261 
1262  bool bWasFound = false;
1263  bool bWasSent = false;
1264 
1265  OTfourbool the_foursome = {bMsgReplySuccess, bMsgReplyFailure,
1266  bMsgTransSuccess, bMsgTransFailure};
1267 
1268  bForceDownload = false;
1269 
1270  int32_t nProcessNymboxResult = MsgUtil.getAndProcessNymbox_8(
1271  theFunction.serverID, theFunction.nymID, bWasSent,
1272  bForceDownload, nlocalRequestNum, bWasFound,
1273  bWillRetryAfterThis, the_foursome);
1274 
1275  // bHarvestingForRetry,// bHarvestingForRetry is INPUT, in the
1276  // case nlocalRequestNum needs to be harvested before a flush
1277  // occurs.
1278 
1279  // bMsgReplySuccess, // bMsgReplySuccess is INPUT, and is in
1280  // case nlocalRequestNum needs to be HARVESTED before a FLUSH
1281  // happens.
1282  // bMsgReplyFailure, // bMsgReplyFailure is INPUT, and is in
1283  // case nlocalRequestNum needs to be HARVESTED before a FLUSH
1284  // happens.
1285  // bMsgTransSuccess, // bMsgTransSuccess is INPUT, and is in
1286  // case nlocalRequestNum needs to be HARVESTED before a FLUSH
1287  // happens.
1288  // bMsgTransFailure) // Etc.
1289 
1290  // FIX: Add '(' and ')' here to silence warning. But where?
1291  if ((bWasSent && (1 == nProcessNymboxResult)) ||
1292  (!bWasSent &&
1293  (0 == nProcessNymboxResult))) // success processing Nymbox.
1294  {
1295  bCanRetryAfterThis = true;
1296  }
1297 
1298  // This means a request number was returned, since the
1299  // processNymbox failed,
1300  // and hasn't been properly harvested, so we either need to
1301  // harvest it for a re-try,
1302  // or flush it.
1303  //
1304  else if (bWasSent && (nProcessNymboxResult > 1)) {
1305  string strNymbox = OTAPI_Wrap::LoadNymboxNoVerify(
1306  theFunction.serverID,
1307  theFunction.nymID); // FLUSH SENT MESSAGES!!!! (AND
1308  // HARVEST.);
1309 
1310  if (VerifyStringVal(strNymbox)) {
1311  OTAPI_Wrap::FlushSentMessages(
1312  false, theFunction.serverID, theFunction.nymID,
1313  strNymbox);
1314  }
1315  }
1316  } // if (bIsTransaction)
1317 
1318  } // if getRequest was success.
1319  else {
1320  otOut << strLocation << ", Failure: Never got reply from server, "
1321  "so tried getRequest, and that failed too. "
1322  "(I give up.)\n";
1323 
1324  // Note: cannot harvest transaction nums here because I do NOT know
1325  // for sure
1326  // whether the server has replied to the message or not! (Not until
1327  // I successfully
1328  // download my Nymbox.) Therefore, do NOT harvest or flush, but hold
1329  // back and wait
1330  // until the next attempt does a successful getNymbox and THEN do a
1331  // "flush sent" after
1332  // that. (That's the time we'll know for SURE what happened to the
1333  // original reply.)
1334  //
1335  // (Therefore LEAVE the sent message in the sent queue.)
1336 
1337  return "";
1338  }
1339  } // else if (bMsgAnyError || bMsgAnyFailure)
1340 
1341  // Returning an empty string.
1342 
1343  return "";
1344 }
std::string accountID
OT_OTAPI_OT int32_t SendRequestLowLevel(OTAPI_Func &theFunction, const std::string &IN_FUNCTION) const
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
std::string serverID
EXPORT OT_UTILITY_OT int32_t getRequestNumber(const std::string &serverID, const std::string &nymID)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT OT_UTILITY_OT std::string ReceiveReplyLowLevel(const std::string &serverID17, const std::string &nymID, int32_t nRequestNumber8, const std::string &IN_FUNCTION)
EXPORT OT_UTILITY_OT int32_t getAndProcessNymbox_8(const std::string &serverID, const std::string &nymID, bool &bWasMsgSent, bool bForceDownload, int32_t nRequestNumber, bool &bFoundNymboxItem, bool bHarvestingForRetry, const OTfourbool &bMsgFoursome)
std::array< bool, 4 > OTfourbool
EXPORT OT_UTILITY_OT bool getIntermediaryFiles(const std::string &serverID, const std::string &nymID, const std::string &accountID)
std::string nymID
OT_OTAPI_OT string OTAPI_Func::SendTransaction ( OTAPI_Func theFunction,
const std::string &  IN_FUNCTION 
)

Definition at line 832 of file ot_otapi_ot.cpp.

834 {
835  int32_t nTotalRetries = 2;
836  return SendTransaction(theFunction, IN_FUNCTION, nTotalRetries);
837 }
OT_OTAPI_OT std::string SendTransaction(OTAPI_Func &theFunction, const std::string &IN_FUNCTION)
OT_OTAPI_OT string OTAPI_Func::SendTransaction ( OTAPI_Func theFunction,
const std::string &  IN_FUNCTION,
int32_t  nTotalRetries 
) const

Definition at line 839 of file ot_otapi_ot.cpp.

842 {
843  Utility MsgUtil;
844  string strLocation = "OTAPI_Func::SendTransaction: " + IN_FUNCTION;
845 
846  if (!MsgUtil.getIntermediaryFiles(theFunction.serverID, theFunction.nymID,
847  theFunction.accountID,
848  false)) // bForceDownload=false))
849  {
850  otOut << strLocation << ", getIntermediaryFiles returned false. (It "
851  "couldn't download files that it needed.)\n";
852  return "";
853  }
854 
855  // GET TRANSACTION NUMBERS HERE IF NECESSARY.
856  //
857  int32_t getnym_trnsnum_count = OTAPI_Wrap::GetNym_TransactionNumCount(
858  theFunction.serverID, theFunction.nymID);
859  int32_t configTxnCount = MsgUtil.getNbrTransactionCount();
860  bool b1 = (theFunction.nTransNumsNeeded > configTxnCount);
861  int32_t comparative = 0;
862 
863  if (b1) {
864  comparative = theFunction.nTransNumsNeeded;
865  }
866  else {
867  comparative = configTxnCount;
868  }
869 
870  if (getnym_trnsnum_count < comparative) {
871  otOut << strLocation << ", I don't have enough transaction numbers to "
872  "perform this transaction. Grabbing more "
873  "now...\n";
874  MsgUtil.setNbrTransactionCount(comparative);
875  MsgUtil.getTransactionNumbers(theFunction.serverID, theFunction.nymID);
876  MsgUtil.setNbrTransactionCount(configTxnCount);
877  }
878 
879  // second try
880  getnym_trnsnum_count =
881  OTAPI_Wrap::GetNym_TransactionNumCount(serverID, nymID);
882  if (getnym_trnsnum_count < comparative) {
883  otOut
884  << strLocation
885  << ", failure: MsgUtil.getTransactionNumbers. (Trying again...)\n";
886 
887  // (the final parameter, the 'false' is us telling getTransNumbers that
888  // it can skip the first call to getTransNumLowLevel)
889  //
890  MsgUtil.setNbrTransactionCount(comparative);
891  MsgUtil.getTransactionNumbers(serverID, nymID, false);
892  MsgUtil.setNbrTransactionCount(configTxnCount);
893  }
894 
895  // third try
896  getnym_trnsnum_count =
897  OTAPI_Wrap::GetNym_TransactionNumCount(serverID, nymID);
898  if (getnym_trnsnum_count < comparative) {
899  otOut
900  << strLocation
901  << ", failure: MsgUtil.getTransactionNumbers. (Trying again...)\n";
902 
903  // (the final parameter, the 'false' is us telling getTransNumbers that
904  // it can skip the first call to getTransNumLowLevel)
905  //
906  MsgUtil.setNbrTransactionCount(comparative);
907  MsgUtil.getTransactionNumbers(serverID, nymID, false);
908  MsgUtil.setNbrTransactionCount(configTxnCount);
909  }
910 
911  // Giving up, if still a failure by this point.
912  //
913  getnym_trnsnum_count = OTAPI_Wrap::GetNym_TransactionNumCount(
914  theFunction.serverID, theFunction.nymID);
915 
916  if (getnym_trnsnum_count < comparative) {
917  otOut
918  << strLocation
919  << ", third failure: MsgUtil.getTransactionNumbers. (Giving up.)\n";
920  return "";
921  }
922 
923  bool bCanRetryAfterThis = false;
924 
925  string strResult = SendRequestOnce(theFunction, IN_FUNCTION, true, true,
926  bCanRetryAfterThis);
927 
928  if (VerifyStringVal(strResult)) {
929  otOut << " Getting Intermediary files.. \n";
930 
931  if (!MsgUtil.getIntermediaryFiles(theFunction.serverID,
932  theFunction.nymID,
933  theFunction.accountID, true)) {
934  otOut << strLocation << ", getIntermediaryFiles returned false. "
935  "(After a success sending the transaction. "
936  "Strange...)\n";
937  return "";
938  }
939 
940  return strResult;
941  }
942 
943  //
944  // Maybe we have an old Inbox or something.
945  //
946 
947  // TODO!! SECURITY: This is where a GOOD CLIENT (vs. a test client)
948  // will verify these intermediary files against your LAST SIGNED RECEIPT,
949  // using OTAPI_Wrap::VerifySomethingorother().
950  // See verifyFiles() at the bottom of this file.
951  // Add some kind of warning Modal Dialog here, since it's actually
952  // normal for a NEW account (never had any receipts yet.) But for
953  // any other account, this should ALWAYS VERIFY!
954  //
955  // Another note: this should happen INSIDE the getIntermediaryFiles call
956  // itself,
957  // and all similar calls. You simply should not download those files,
958  // without verifying them also. Otherwise you could end up signing
959  // a future bad receipt, based on malicious, planted intermediary files.
960 
961  int32_t nRetries = nTotalRetries;
962 
963  while ((nRetries > 0) && !VerifyStringVal(strResult) &&
964  bCanRetryAfterThis) {
965  --nRetries;
966 
967  bool bWillRetryAfterThis = true;
968 
969  if ((nRetries == 0) || !bCanRetryAfterThis) {
970  bWillRetryAfterThis = false;
971  }
972 
973  strResult = SendRequestOnce(theFunction, IN_FUNCTION, true,
974  bWillRetryAfterThis, bCanRetryAfterThis);
975 
976  // In case of failure, we want to get these before we re-try.
977  // But in case of success, we also want to get these, so we can
978  // see the results of our success. So we get these either way...
979  //
980  if (VerifyStringVal(strResult)) {
981  if (!MsgUtil.getIntermediaryFiles(theFunction.serverID,
982  theFunction.nymID,
983  theFunction.accountID, true)) {
984  otOut << strLocation
985  << ", getIntermediaryFiles (loop) returned false even "
986  "after successfully sending the transaction.\n";
987  return "";
988  }
989  break;
990  }
991  }
992 
993  return strResult;
994 }
EXPORT OT_UTILITY_OT int32_t getNbrTransactionCount() const
std::string accountID
int32_t nTransNumsNeeded
OTLOG_IMPORT OTLogStream otOut
std::string serverID
EXPORT OT_UTILITY_OT bool getTransactionNumbers(const std::string &serverID, const std::string &nymID)
EXPORT OT_UTILITY_OT void setNbrTransactionCount(int32_t new_trans_dl)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_OTAPI_OT std::string SendRequestOnce(OTAPI_Func &theFunction, const std::string &IN_FUNCTION, bool bIsTransaction, bool bWillRetryAfterThis, bool &bCanRetryAfterThis) const
EXPORT OT_UTILITY_OT bool getIntermediaryFiles(const std::string &serverID, const std::string &nymID, const std::string &accountID)
std::string nymID

Member Data Documentation

std::string OTAPI_Func::accountID

Definition at line 266 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::accountID2

Definition at line 267 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::assetID

Definition at line 264 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::assetID2

Definition at line 265 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::basket

Definition at line 268 of file ot_otapi_ot.hpp.

bool OTAPI_Func::bBool

Definition at line 274 of file ot_otapi_ot.hpp.

OTAPI_Func_Type OTAPI_Func::funcType

Definition at line 260 of file ot_otapi_ot.hpp.

int64_t OTAPI_Func::lData

Definition at line 276 of file ot_otapi_ot.hpp.

int32_t OTAPI_Func::nData

Definition at line 275 of file ot_otapi_ot.hpp.

int32_t OTAPI_Func::nRequestNum

Definition at line 279 of file ot_otapi_ot.hpp.

int32_t OTAPI_Func::nTransNumsNeeded

Definition at line 278 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::nymID

Definition at line 262 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::nymID2

Definition at line 263 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::serverID

Definition at line 261 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::strData

Definition at line 269 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::strData2

Definition at line 270 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::strData3

Definition at line 271 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::strData4

Definition at line 272 of file ot_otapi_ot.hpp.

std::string OTAPI_Func::strData5

Definition at line 273 of file ot_otapi_ot.hpp.

time64_t OTAPI_Func::tData

Definition at line 277 of file ot_otapi_ot.hpp.


The documentation for this class was generated from the following files: