Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ot_made_easy_ot.cpp
Go to the documentation of this file.
1 /************************************************************
2 *
3 * ot_made_easy_ot.cpp
4 *
5 */
6 
7 /************************************************************
8  -----BEGIN PGP SIGNED MESSAGE-----
9  Hash: SHA1
10 
11  * OPEN TRANSACTIONS
12  *
13  * Financial Cryptography and Digital Cash
14  * Library, Protocol, API, Server, CLI, GUI
15  *
16  * -- Anonymous Numbered Accounts.
17  * -- Untraceable Digital Cash.
18  * -- Triple-Signed Receipts.
19  * -- Cheques, Vouchers, Transfers, Inboxes.
20  * -- Basket Currencies, Markets, Payment Plans.
21  * -- Signed, XML, Ricardian-style Contracts.
22  * -- Scripted smart contracts.
23  *
24  * Copyright (C) 2010-2013 by "Fellow Traveler" (A pseudonym)
25  *
26  * EMAIL:
28  *
29  * BITCOIN: 1NtTPVVjDsUfDWybS4BwvHpG2pdS9RnYyQ
30  *
31  * KEY FINGERPRINT (PGP Key in license file):
32  * 9DD5 90EB 9292 4B48 0484 7910 0308 00ED F951 BB8E
33  *
34  * OFFICIAL PROJECT WIKI(s):
35  * https://github.com/FellowTraveler/Moneychanger
36  * https://github.com/FellowTraveler/Open-Transactions/wiki
37  *
38  * WEBSITE:
39  * http://www.OpenTransactions.org/
40  *
41  * Components and licensing:
42  * -- Moneychanger..A Java client GUI.....LICENSE:.....GPLv3
43  * -- otlib.........A class library.......LICENSE:...LAGPLv3
44  * -- otapi.........A client API..........LICENSE:...LAGPLv3
45  * -- opentxs/ot....Command-line client...LICENSE:...LAGPLv3
46  * -- otserver......Server Application....LICENSE:....AGPLv3
47  * Github.com/FellowTraveler/Open-Transactions/wiki/Components
48  *
49  * All of the above OT components were designed and written by
50  * Fellow Traveler, with the exception of Moneychanger, which
51  * was contracted out to Vicky C ([email protected]).
52  * The open-source community has since actively contributed.
53  *
54  * -----------------------------------------------------
55  *
56  * LICENSE:
57  * This program is free software: you can redistribute it
58  * and/or modify it under the terms of the GNU Affero
59  * General Public License as published by the Free Software
60  * Foundation, either version 3 of the License, or (at your
61  * option) any later version.
62  *
63  * ADDITIONAL PERMISSION under the GNU Affero GPL version 3
64  * section 7: (This paragraph applies only to the LAGPLv3
65  * components listed above.) If you modify this Program, or
66  * any covered work, by linking or combining it with other
67  * code, such other code is not for that reason alone subject
68  * to any of the requirements of the GNU Affero GPL version 3.
69  * (==> This means if you are only using the OT API, then you
70  * don't have to open-source your code--only your changes to
71  * Open-Transactions itself must be open source. Similar to
72  * LGPLv3, except it applies to software-as-a-service, not
73  * just to distributing binaries.)
74  *
75  * Extra WAIVER for OpenSSL, Lucre, and all other libraries
76  * used by Open Transactions: This program is released under
77  * the AGPL with the additional exemption that compiling,
78  * linking, and/or using OpenSSL is allowed. The same is true
79  * for any other open source libraries included in this
80  * project: complete waiver from the AGPL is hereby granted to
81  * compile, link, and/or use them with Open-Transactions,
82  * according to their own terms, as long as the rest of the
83  * Open-Transactions terms remain respected, with regard to
84  * the Open-Transactions code itself.
85  *
86  * Lucre License:
87  * This code is also "dual-license", meaning that Ben Lau-
88  * rie's license must also be included and respected, since
89  * the code for Lucre is also included with Open Transactions.
90  * See Open-Transactions/src/otlib/lucre/LUCRE_LICENSE.txt
91  * The Laurie requirements are light, but if there is any
92  * problem with his license, simply remove the Lucre code.
93  * Although there are no other blind token algorithms in Open
94  * Transactions (yet. credlib is coming), the other functions
95  * will continue to operate.
96  * See Lucre on Github: https://github.com/benlaurie/lucre
97  * -----------------------------------------------------
98  * You should have received a copy of the GNU Affero General
99  * Public License along with this program. If not, see:
100  * http://www.gnu.org/licenses/
101  *
102  * If you would like to use this software outside of the free
103  * software license, please contact FellowTraveler.
104  * (Unfortunately many will run anonymously and untraceably,
105  * so who could really stop them?)
106  *
107  * DISCLAIMER:
108  * This program is distributed in the hope that it will be
109  * useful, but WITHOUT ANY WARRANTY; without even the implied
110  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
111  * PURPOSE. See the GNU Affero General Public License for
112  * more details.
113 
114  -----BEGIN PGP SIGNATURE-----
115  Version: GnuPG v1.4.9 (Darwin)
116 
117  iQIcBAEBAgAGBQJRSsfJAAoJEAMIAO35UbuOQT8P/RJbka8etf7wbxdHQNAY+2cC
118  vDf8J3X8VI+pwMqv6wgTVy17venMZJa4I4ikXD/MRyWV1XbTG0mBXk/7AZk7Rexk
119  KTvL/U1kWiez6+8XXLye+k2JNM6v7eej8xMrqEcO0ZArh/DsLoIn1y8p8qjBI7+m
120  aE7lhstDiD0z8mwRRLKFLN2IH5rAFaZZUvj5ERJaoYUKdn4c+RcQVei2YOl4T0FU
121  LWND3YLoH8naqJXkaOKEN4UfJINCwxhe5Ke9wyfLWLUO7NamRkWD2T7CJ0xocnD1
122  sjAzlVGNgaFDRflfIF4QhBx1Ddl6wwhJfw+d08bjqblSq8aXDkmFA7HeunSFKkdn
123  oIEOEgyj+veuOMRJC5pnBJ9vV+7qRdDKQWaCKotynt4sWJDGQ9kWGWm74SsNaduN
124  TPMyr9kNmGsfR69Q2Zq/FLcLX/j8ESxU+HYUB4vaARw2xEOu2xwDDv6jt0j3Vqsg
125  x7rWv4S/Eh18FDNDkVRChiNoOIilLYLL6c38uMf1pnItBuxP3uhgY6COm59kVaRh
126  nyGTYCDYD2TK+fI9o89F1297uDCwEJ62U0Q7iTDp5QuXCoxkPfv8/kX6lS6T3y9G
127  M9mqIoLbIQ1EDntFv7/t6fUTS2+46uCrdZWbQ5RjYXdrzjij02nDmJAm2BngnZvd
128  kamH0Y/n11lCvo1oQxM+
129  =uSzz
130  -----END PGP SIGNATURE-----
131  **************************************************************/
132 
133 #include "ot_made_easy_ot.hpp"
134 #include "ot_otapi_ot.hpp"
135 #include "ot_utility_ot.hpp"
136 #include "../core/OTLog.hpp"
137 
138 #include <algorithm>
139 
140 // Returns:
141 // True if I have enough numbers, or if there was success getting more
142 // transaction numbers.
143 // False if I didn't have enough numbers, tried to get more, and failed
144 // somehow.
145 //
146 
147 using namespace opentxs;
148 using namespace std;
149 
151  const string& strMyServerID,
152  const string& strMyNymID)
153 {
154  Utility MsgUtil;
155  bool bReturnVal = true;
156 
157  // Make sure we have at least one transaction number (to write the
158  // cheque...)
159  //
160  int32_t nTransCount =
161  OTAPI_Wrap::GetNym_TransactionNumCount(strMyServerID, strMyNymID);
162 
163  if (nTransCount < nNumberNeeded) {
164  otOut << "insure_enough_nums: I don't have enough "
165  "transaction numbers. Grabbing more now...\n";
166 
167  MsgUtil.getTransactionNumbers(strMyServerID, strMyNymID, true);
168 
169  bool msgWasSent = false;
170  if (0 > MadeEasy::retrieve_nym(strMyServerID, strMyNymID, msgWasSent,
171  false)) {
172  otOut << "Error: cannot retrieve nym.\n";
173  return false;
174  }
175 
176  // Try again.
177  //
178  nTransCount =
179  OTAPI_Wrap::GetNym_TransactionNumCount(strMyServerID, strMyNymID);
180 
181  if (nTransCount < nNumberNeeded) {
182  otOut
183  << "insure_enough_nums: I still don't have enough transaction "
184  "numbers (I have " << nTransCount << ", but I need "
185  << nNumberNeeded
186  << ".)\n(Tried grabbing some, but failed somehow.)\n";
187  return false;
188  }
189  else {
190  bReturnVal = true;
191  }
192  }
193 
194  return bReturnVal;
195 }
196 
197 // REGISTER NYM AT SERVER (or download nymfile, if nym already registered.)
198 //
199 OT_MADE_EASY_OT string
200  MadeEasy::register_nym(const string& SERVER_ID, const string& NYM_ID)
201 {
202  OTAPI_Func ot_Msg;
203 
204  OTAPI_Func theRequest(CREATE_USER_ACCT, SERVER_ID, NYM_ID);
205  string strResponse = theRequest.SendRequest(theRequest, "CREATE_USER_ACCT");
206  int32_t nSuccess = VerifyMessageSuccess(strResponse);
207 
208  if (1 == nSuccess) {
209  Utility MsgUtil;
210 
211  // Use the getRequest command, thus insuring that the request number is
212  // in sync.
213  //
214  if (1 != MsgUtil.getRequestNumber(SERVER_ID, NYM_ID)) {
215  otOut << "\n Succeeded in register_nym, but strange: "
216  "then failed calling getRequest, to sync the "
217  "request number for the first time.\n";
218  return "";
219  }
220  }
221  else {
222  // maybe an invalid server ID or the server contract isn't available (do
223  // AddServerContract(..) first)
224  otOut << "Failed to register_nym.\n";
225  return "";
226  }
227 
228  return strResponse;
229 }
230 
231 // RETRIEVE NYM INTERMEDIARY FILES
232 
233 OT_MADE_EASY_OT int32_t
234  MadeEasy::retrieve_nym(const string& strServerID, const string& strMyNymID,
235  bool& bWasMsgSent, bool bForceDownload)
236 {
237 
238  Utility MsgUtil;
239 
240  if (1 != MsgUtil.getRequestNumber(strServerID, strMyNymID)) {
241  otOut << "\n Failed calling getRequest, to sync the "
242  "request number. (Finished.)\n";
243  return -1;
244  }
245  else // If it returns 1, we know for sure that the request number is in
246  // sync.
247  {
248  otOut << "\n\n SUCCESS syncronizing the request number.\n";
249  }
250 
251  int32_t nGetAndProcessNymbox = MsgUtil.getAndProcessNymbox_4(
252  strServerID, strMyNymID, bWasMsgSent, bForceDownload);
253 
254  return nGetAndProcessNymbox;
255 }
256 
257 // CHECK USER (download a public key)
258 //
259 OT_MADE_EASY_OT string MadeEasy::check_user(const string& SERVER_ID,
260  const string& NYM_ID,
261  const string& TARGET_NYM_ID)
262 {
263  OTAPI_Func ot_Msg;
264 
265  OTAPI_Func theRequest(CHECK_USER, SERVER_ID, NYM_ID, TARGET_NYM_ID);
266  string strResponse = theRequest.SendRequest(theRequest, "CHECK_USER");
267 
268  return strResponse;
269 }
270 
271 // CREATE NYM (pseudonym)
272 // returns new Nym ID
273 //
274 OT_MADE_EASY_OT string MadeEasy::create_nym(int32_t nKeybits,
275  const string& strNymIDSource,
276  const string& strAltLocation)
277 {
278  string strLocation = "OT_ME_create_nym";
279 
280  string strNymID = OTAPI_Wrap::CreateNym(
281  nKeybits, strNymIDSource, strAltLocation); // returns new Nym ID;
282 
283  if (!VerifyStringVal(strNymID)) {
284  otOut << strLocation
285  << ": Failed in OT_API_CreateNym(keybits == " << nKeybits
286  << ")\n";
287  }
288 
289  return strNymID;
290 }
291 
292 // ISSUE ASSET TYPE
293 //
294 OT_MADE_EASY_OT string MadeEasy::issue_asset_type(const string& SERVER_ID,
295  const string& NYM_ID,
296  const string& THE_CONTRACT)
297 {
298  OTAPI_Func ot_Msg;
299 
300  OTAPI_Func theRequest(ISSUE_ASSET_TYPE, SERVER_ID, NYM_ID, THE_CONTRACT);
301  string strResponse = theRequest.SendRequest(theRequest, "ISSUE_ASSET_TYPE");
302 
303  return strResponse;
304 }
305 
306 // ISSUE BASKET CURRENCY
307 //
308 OT_MADE_EASY_OT string MadeEasy::issue_basket_currency(const string& SERVER_ID,
309  const string& NYM_ID,
310  const string& THE_BASKET)
311 {
312  OTAPI_Func ot_Msg;
313 
314  OTAPI_Func theRequest(ISSUE_BASKET, SERVER_ID, NYM_ID, THE_BASKET);
315  string strResponse = theRequest.SendRequest(theRequest, "ISSUE_BASKET");
316 
317  return strResponse;
318 }
319 
320 // EXCHANGE BASKET CURRENCY
321 //
323  const string& SERVER_ID, const string& NYM_ID, const string& ASSET_TYPE,
324  const string& THE_BASKET, const string& ACCT_ID, bool IN_OR_OUT)
325 {
326  OTAPI_Func ot_Msg;
327 
328  int32_t nTransNumsNeeded =
329  (OTAPI_Wrap::Basket_GetMemberCount(THE_BASKET) + 1);
330 
331  OTAPI_Func theRequest(EXCHANGE_BASKET, SERVER_ID, NYM_ID, ASSET_TYPE,
332  THE_BASKET, ACCT_ID, IN_OR_OUT, nTransNumsNeeded);
333  string strResponse =
334  theRequest.SendTransaction(theRequest, "EXCHANGE_BASKET");
335 
336  return strResponse;
337 }
338 
339 // RETRIEVE CONTRACT
340 //
341 OT_MADE_EASY_OT string MadeEasy::retrieve_contract(const string& SERVER_ID,
342  const string& NYM_ID,
343  const string& CONTRACT_ID)
344 {
345  OTAPI_Func ot_Msg;
346 
347  OTAPI_Func theRequest(GET_CONTRACT, SERVER_ID, NYM_ID, CONTRACT_ID);
348  string strResponse = theRequest.SendRequest(theRequest, "GET_CONTRACT");
349 
350  return strResponse;
351 }
352 
353 // LOAD OR RETRIEVE CONTRACT
354 //
355 OT_MADE_EASY_OT string
356  MadeEasy::load_or_retrieve_contract(const string& SERVER_ID,
357  const string& NYM_ID,
358  const string& CONTRACT_ID)
359 {
360  OTAPI_Func ot_Msg;
361 
362  string strContract = OTAPI_Wrap::LoadAssetContract(CONTRACT_ID);
363 
364  if (!VerifyStringVal(strContract)) {
365  string strResponse = retrieve_contract(SERVER_ID, NYM_ID, CONTRACT_ID);
366 
367  if (1 == VerifyMessageSuccess(strResponse)) {
368  strContract = OTAPI_Wrap::LoadAssetContract(CONTRACT_ID);
369  }
370  }
371 
372  return strContract; // might be null.
373 }
374 
375 // CREATE ASSET ACCOUNT
376 //
377 OT_MADE_EASY_OT string MadeEasy::create_asset_acct(const string& SERVER_ID,
378  const string& NYM_ID,
379  const string& ASSET_TYPE_ID)
380 {
381  OTAPI_Func ot_Msg;
382 
383  OTAPI_Func theRequest(CREATE_ASSET_ACCT, SERVER_ID, NYM_ID, ASSET_TYPE_ID);
384  string strResponse =
385  theRequest.SendRequest(theRequest, "CREATE_ASSET_ACCT");
386 
387  return strResponse;
388 }
389 
390 OT_MADE_EASY_OT string MadeEasy::stat_asset_account(const string& ACCOUNT_ID)
391 {
392  string strName = OTAPI_Wrap::GetAccountWallet_Name(ACCOUNT_ID);
393  if (!VerifyStringVal(strName)) {
394  otOut << "\nstat_asset_account: Cannot find account wallet for: "
395  << ACCOUNT_ID << "\n";
396  return "";
397  }
398 
399  string strAssetID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(ACCOUNT_ID);
400  if (!VerifyStringVal(strAssetID)) {
401  otOut
402  << "\nstat_asset_account: Cannot cannot determine asset type for: "
403  << ACCOUNT_ID << "\n";
404  return "";
405  }
406 
407  string strNymID = OTAPI_Wrap::GetAccountWallet_NymID(ACCOUNT_ID);
408  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(ACCOUNT_ID);
409  int64_t lBalance = OTAPI_Wrap::GetAccountWallet_Balance(ACCOUNT_ID);
410  string strAssetTypeName = OTAPI_Wrap::GetAssetType_Name(strAssetID);
411  string strNymName = OTAPI_Wrap::GetNym_Name(strNymID);
412  string strServerName = OTAPI_Wrap::GetServer_Name(strServerID);
413 
414  return " Balance: " + OTAPI_Wrap::FormatAmount(strAssetID, lBalance) +
415  " (" + strName + ")\nAccount ID: " + ACCOUNT_ID + " ( " + strName +
416  " )\nAsset Type: " + strAssetID + " ( " + strAssetTypeName +
417  " )\nOwner Nym : " + strNymID + " ( " + strNymName +
418  " )\nServer : " + strServerID + " ( " + strServerName + " )";
419 }
420 
421 // DOWNLOAD ACCOUNT FILES (account balance, inbox, outbox, etc)
422 //
423 
424 // returns true/false
426  const string& SERVER_ID, const string& NYM_ID, const string& ACCOUNT_ID,
427  bool bForceDownload) // bForceDownload=false
428 {
429  Utility MsgUtil;
430 
431  bool bResponse = MsgUtil.getIntermediaryFiles(SERVER_ID, NYM_ID, ACCOUNT_ID,
432  bForceDownload);
433  return bResponse;
434 }
435 
436 // SEND TRANSFER -- TRANSACTION
437 
438 OT_MADE_EASY_OT string
439  MadeEasy::send_transfer(const string& SERVER_ID, const string& NYM_ID,
440  const string& ACCT_FROM, const string& ACCT_TO,
441  int64_t AMOUNT, const string& NOTE)
442 {
443  OTAPI_Func ot_Msg;
444 
445  OTAPI_Func theRequest(SEND_TRANSFER, SERVER_ID, NYM_ID, ACCT_FROM, ACCT_TO,
446  AMOUNT, NOTE);
447  string strResponse =
448  theRequest.SendTransaction(theRequest, "SEND_TRANSFER");
449 
450  return strResponse;
451 }
452 
453 // PROCESS INBOX -- TRANSACTION
454 
455 OT_MADE_EASY_OT string MadeEasy::process_inbox(const string& SERVER_ID,
456  const string& NYM_ID,
457  const string& ACCOUNT_ID,
458  const string& RESPONSE_LEDGER)
459 {
460  OTAPI_Func ot_Msg;
461 
462  OTAPI_Func theRequest(PROCESS_INBOX, SERVER_ID, NYM_ID, ACCOUNT_ID,
463  RESPONSE_LEDGER);
464  string strResponse =
465  theRequest.SendTransaction(theRequest, "PROCESS_INBOX");
466 
467  return strResponse;
468 }
469 
470 // load_public_key():
471 //
472 // Load a public key from local storage, and return it (or null).
473 //
474 OT_MADE_EASY_OT string
475  MadeEasy::load_public_encryption_key(const string& NYM_ID) // from local
476  // storage.
477 {
478  OTAPI_Func ot_Msg;
479 
480  otOut << "\nload_public_encryption_key: Trying to load public "
481  "key, assuming Nym isn't in the local wallet...\n";
482 
483  string strPubkey = OTAPI_Wrap::LoadPubkey_Encryption(
484  NYM_ID); // This version is for "other people";
485 
486  if (!VerifyStringVal(strPubkey)) {
487  otOut << "\nload_public_encryption_key: Didn't find the Nym (" << NYM_ID
488  << ") as an 'other' user, so next, checking to see if there's "
489  "a pubkey available for one of the local private Nyms...\n";
491  NYM_ID); // This version is for "the user sitting at the machine.";
492 
493  if (!VerifyStringVal(strPubkey)) {
494  otOut << "\nload_public_encryption_key: Didn't find "
495  "him as a local Nym either... returning nullptr.\n";
496  }
497  }
498  return strPubkey; // might be null.;
499 }
500 
501 // load_public_key():
502 //
503 // Load a public key from local storage, and return it (or null).
504 //
505 OT_MADE_EASY_OT string
506  MadeEasy::load_public_signing_key(const string& NYM_ID) // from local
507  // storage.
508 {
509  OTAPI_Func ot_Msg;
510 
511  string strPubkey = OTAPI_Wrap::LoadPubkey_Signing(
512  NYM_ID); // This version is for "other people";
513 
514  if (!VerifyStringVal(strPubkey)) {
516  NYM_ID); // This version is for "the user sitting at the machine.";
517  }
518  return strPubkey; // might be null.;
519 }
520 
521 //
522 // load_or_retrieve_pubkey()
523 //
524 // Load TARGET_NYM_ID from local storage.
525 // If not there, then retrieve TARGET_NYM_ID from server,
526 // using NYM_ID to send check_user request. Then re-load
527 // and return. (Might still return null.)
528 //
529 OT_MADE_EASY_OT string
530  MadeEasy::load_or_retrieve_encrypt_key(const string& SERVER_ID,
531  const string& NYM_ID,
532  const string& TARGET_NYM_ID)
533 {
534  OTAPI_Func ot_Msg;
535 
536  string strPubkey = load_public_encryption_key(TARGET_NYM_ID);
537 
538  if (!VerifyStringVal(strPubkey)) {
539  string strResponse = check_user(SERVER_ID, NYM_ID, TARGET_NYM_ID);
540 
541  if (1 == VerifyMessageSuccess(strResponse)) {
542  strPubkey = load_public_encryption_key(TARGET_NYM_ID);
543  }
544  }
545  return strPubkey; // might be null.
546 }
547 
548 OT_MADE_EASY_OT string
549  MadeEasy::load_or_retrieve_signing_key(const string& SERVER_ID,
550  const string& NYM_ID,
551  const string& TARGET_NYM_ID)
552 {
553  OTAPI_Func ot_Msg;
554 
555  string strPubkey = load_public_signing_key(TARGET_NYM_ID);
556 
557  if (!VerifyStringVal(strPubkey)) {
558  string strResponse = check_user(SERVER_ID, NYM_ID, TARGET_NYM_ID);
559 
560  if (1 == VerifyMessageSuccess(strResponse)) {
561  strPubkey = load_public_signing_key(TARGET_NYM_ID);
562  }
563  }
564  return strPubkey; // might be null.
565 }
566 
567 // SEND USER MESSAGE (requires recipient public key)
568 //
569 OT_MADE_EASY_OT string
570  MadeEasy::send_user_msg_pubkey(const string& SERVER_ID,
571  const string& NYM_ID,
572  const string& RECIPIENT_NYM_ID,
573  const string& RECIPIENT_PUBKEY,
574  const string& THE_MESSAGE)
575 {
576  OTAPI_Func ot_Msg;
577 
578  OTAPI_Func theRequest(SEND_USER_MESSAGE, SERVER_ID, NYM_ID,
579  RECIPIENT_NYM_ID, RECIPIENT_PUBKEY, THE_MESSAGE);
580  string strResponse =
581  theRequest.SendRequest(theRequest, "SEND_USER_MESSAGE");
582 
583  return strResponse;
584 }
585 
586 // SEND USER INSTRUMENT (requires recipient public key)
587 //
588 OT_MADE_EASY_OT string
589  MadeEasy::send_user_pmnt_pubkey(const string& SERVER_ID,
590  const string& NYM_ID,
591  const string& RECIPIENT_NYM_ID,
592  const string& RECIPIENT_PUBKEY,
593  const string& THE_INSTRUMENT)
594 {
595  OTAPI_Func ot_Msg;
596 
597  OTAPI_Func theRequest(SEND_USER_INSTRUMENT, SERVER_ID, NYM_ID,
598  RECIPIENT_NYM_ID, RECIPIENT_PUBKEY, THE_INSTRUMENT);
599  string strResponse =
600  theRequest.SendRequest(theRequest, "SEND_USER_INSTRUMENT");
601 
602  return strResponse;
603 }
604 
605 // SEND USER CASH (requires recipient public key)
606 //
608  const string& SERVER_ID, const string& NYM_ID,
609  const string& RECIPIENT_NYM_ID, const string& RECIPIENT_PUBKEY,
610  const string& THE_INSTRUMENT, const string& INSTRUMENT_FOR_SENDER)
611 {
612  OTAPI_Func ot_Msg;
613 
614  OTAPI_Func theRequest(SEND_USER_INSTRUMENT, SERVER_ID, NYM_ID,
615  RECIPIENT_NYM_ID, RECIPIENT_PUBKEY, THE_INSTRUMENT,
616  INSTRUMENT_FOR_SENDER);
617  string strResponse =
618  theRequest.SendRequest(theRequest, "SEND_USER_INSTRUMENT");
619 
620  return strResponse;
621 }
622 
623 // SEND USER MESSAGE (only requires recipient's ID, and retrieves pubkey
624 // automatically)
625 //
626 OT_MADE_EASY_OT string MadeEasy::send_user_msg(const string& SERVER_ID,
627  const string& NYM_ID,
628  const string& RECIPIENT_NYM_ID,
629  const string& THE_MESSAGE)
630 {
631  OTAPI_Func ot_Msg;
632 
633  string strRecipientPubkey =
634  load_or_retrieve_encrypt_key(SERVER_ID, NYM_ID, RECIPIENT_NYM_ID);
635 
636  if (!VerifyStringVal(strRecipientPubkey)) {
637  otOut << "OT_ME_send_user_msg: Unable to load or retrieve "
638  "public encryption key for recipient: " << RECIPIENT_NYM_ID
639  << "\n";
640  return strRecipientPubkey; // basically this means "return null".
641  }
642 
643  string strResponse = send_user_msg_pubkey(
644  SERVER_ID, NYM_ID, RECIPIENT_NYM_ID, strRecipientPubkey, THE_MESSAGE);
645 
646  return strResponse;
647 }
648 
649 // SEND USER PAYMENT (only requires recipient's ID, and retrieves pubkey
650 // automatically)
651 //
652 OT_MADE_EASY_OT string
653  MadeEasy::send_user_payment(const string& SERVER_ID, const string& NYM_ID,
654  const string& RECIPIENT_NYM_ID,
655  const string& THE_PAYMENT)
656 {
657  OTAPI_Func ot_Msg;
658 
659  string strRecipientPubkey =
660  load_or_retrieve_encrypt_key(SERVER_ID, NYM_ID, RECIPIENT_NYM_ID);
661 
662  if (!VerifyStringVal(strRecipientPubkey)) {
663  otOut << "OT_ME_send_user_payment: Unable to load or "
664  "retrieve public encryption key for recipient: "
665  << RECIPIENT_NYM_ID << "\n";
666  return strRecipientPubkey; // basically this means "return null".
667  }
668 
669  string strResponse = send_user_pmnt_pubkey(
670  SERVER_ID, NYM_ID, RECIPIENT_NYM_ID, strRecipientPubkey, THE_PAYMENT);
671 
672  return strResponse;
673 }
674 
675 // SEND USER CASH (only requires recipient's ID, and retrieves pubkey
676 // automatically)
677 //
678 OT_MADE_EASY_OT string MadeEasy::send_user_cash(const string& SERVER_ID,
679  const string& NYM_ID,
680  const string& RECIPIENT_NYM_ID,
681  const string& THE_PAYMENT,
682  const string& SENDERS_COPY)
683 {
684  OTAPI_Func ot_Msg;
685 
686  string strRecipientPubkey =
687  load_or_retrieve_encrypt_key(SERVER_ID, NYM_ID, RECIPIENT_NYM_ID);
688 
689  if (!VerifyStringVal(strRecipientPubkey)) {
690  otOut << "OT_ME_send_user_payment: Unable to load or "
691  "retrieve public encryption key for recipient: "
692  << RECIPIENT_NYM_ID << "\n";
693  return strRecipientPubkey; // basically this means "return null".
694  }
695 
696  string strResponse =
697  send_user_cash_pubkey(SERVER_ID, NYM_ID, RECIPIENT_NYM_ID,
698  strRecipientPubkey, THE_PAYMENT, SENDERS_COPY);
699 
700  return strResponse;
701 }
702 
703 // GET PAYMENT INSTRUMENT (from payments inbox, by index.)
704 //
706  const string& SERVER_ID, const string& NYM_ID, int32_t nIndex,
707  const string& PRELOADED_INBOX) // PRELOADED_INBOX is optional.
708 {
709  string strInstrument;
710  string strInbox =
711  VerifyStringVal(PRELOADED_INBOX)
712  ? PRELOADED_INBOX
714  SERVER_ID, NYM_ID); // Returns nullptr, or an inbox.
715 
716  if (!VerifyStringVal(strInbox)) {
717  otWarn << "\n\n get_payment_instrument: "
718  "OT_API_LoadPaymentInbox Failed. (Probably just "
719  "doesn't exist yet.)\n\n";
720  return "";
721  }
722 
723  int32_t nCount =
724  OTAPI_Wrap::Ledger_GetCount(SERVER_ID, NYM_ID, NYM_ID, strInbox);
725  if (0 > nCount) {
726  otOut
727  << "Unable to retrieve size of payments inbox ledger. (Failure.)\n";
728  return "";
729  }
730  if (nIndex > (nCount - 1)) {
731  otOut << "Index " << nIndex
732  << " out of bounds. (The last index is: " << (nCount - 1)
733  << ". The first is 0.)\n";
734  return "";
735  }
736 
737  strInstrument = OTAPI_Wrap::Ledger_GetInstrument(SERVER_ID, NYM_ID, NYM_ID,
738  strInbox, nIndex);
739  if (!VerifyStringVal(strInstrument)) {
740  otOut << "Failed trying to get payment instrument from payments box.\n";
741  return "";
742  }
743 
744  return strInstrument;
745 }
746 
747 // GET BOX RECEIPT
748 // Note: nBoxType is 0 for Nymbox, 1 for Inbox, and 2 for Outbox.
749 // Also, if nBoxType is 0 (nymbox) then you have to pass the NymID in the
750 // ACCT_ID
751 // argument, as well as the NYM_ID argument (you have to pass it twice...)
752 // Otherwise for inbox/outbox, pass the actual ACCT_ID there as normal.
753 //
754 OT_MADE_EASY_OT string
755  MadeEasy::get_box_receipt(const string& SERVER_ID, const string& NYM_ID,
756  const string& ACCT_ID, int32_t nBoxType,
757  const string& STR_TRANS_NUM)
758 {
759  OTAPI_Func ot_Msg;
760 
761  OTAPI_Func theRequest(GET_BOX_RECEIPT, SERVER_ID, NYM_ID, ACCT_ID,
762  to_string(nBoxType), STR_TRANS_NUM);
763  string strResponse = theRequest.SendRequest(theRequest, "GET_BOX_RECEIPT");
764 
765  return strResponse;
766 }
767 
768 // DOWNLOAD PUBLIC MINT
769 //
770 OT_MADE_EASY_OT string MadeEasy::retrieve_mint(const string& SERVER_ID,
771  const string& NYM_ID,
772  const string& ASSET_ID)
773 {
774  OTAPI_Func ot_Msg;
775 
776  OTAPI_Func theRequest(GET_MINT, SERVER_ID, NYM_ID, ASSET_ID);
777  string strResponse = theRequest.SendRequest(theRequest, "GET_MINT");
778 
779  return strResponse;
780 }
781 
782 // LOAD MINT (from local storage)
783 //
784 // To load a mint withOUT retrieving it from server, call:
785 //
786 // var strMint = OTAPI_Wrap::LoadMint(SERVER_ID, ASSET_ID);
787 // It returns the mint, or null.
788 
789 // LOAD MINT (from local storage).
790 // Also, if necessary, RETRIEVE it from the server first.
791 //
792 // Returns the mint, or null.
793 
794 OT_MADE_EASY_OT string MadeEasy::load_or_retrieve_mint(const string& SERVER_ID,
795  const string& NYM_ID,
796  const string& ASSET_ID)
797 {
798  string strResponse = check_user(SERVER_ID, NYM_ID, NYM_ID);
799  if (1 != VerifyMessageSuccess(strResponse)) {
800  otOut << "OT_ME_load_or_retrieve_mint: Cannot verify nym for IDs: \n";
801  otOut << " Server ID: " << SERVER_ID << "\n";
802  otOut << " Nym ID: " << NYM_ID << "\n";
803  otOut << " Asset ID: " << ASSET_ID << "\n";
804  return "";
805  }
806 
807  // HERE, WE MAKE SURE WE HAVE THE PROPER MINT...
808  //
809  // Download the public mintfile if it's not there, or if it's expired.
810  // Also load it up into memory as a string (just to make sure it works.)
811 
812  // expired or missing.
813  if (!OTAPI_Wrap::Mint_IsStillGood(SERVER_ID, ASSET_ID)) {
814  otWarn << "OT_ME_load_or_retrieve_mint: Mint file is "
815  "missing or expired. Downloading from "
816  "server...\n";
817 
818  string strResponse = retrieve_mint(SERVER_ID, NYM_ID, ASSET_ID);
819 
820  if (1 != VerifyMessageSuccess(strResponse)) {
821  otOut << "OT_ME_load_or_retrieve_mint: Unable to "
822  "retrieve mint for IDs: \n";
823  otOut << " Server ID: " << SERVER_ID << "\n";
824  otOut << " Nym ID: " << NYM_ID << "\n";
825  otOut << " Asset ID: " << ASSET_ID << "\n";
826  return "";
827  }
828 
829  if (!OTAPI_Wrap::Mint_IsStillGood(SERVER_ID, ASSET_ID)) {
830  otOut << "OT_ME_load_or_retrieve_mint: Retrieved "
831  "mint, but still 'not good' for IDs: \n";
832  otOut << " Server ID: " << SERVER_ID << "\n";
833  otOut << " Nym ID: " << NYM_ID << "\n";
834  otOut << " Asset ID: " << ASSET_ID << "\n";
835  return "";
836  }
837  }
838  // else // current mint IS available already on local storage (and not
839  // expired.)
840 
841  // By this point, the mint is definitely good, whether we had to download it
842  // or not.
843  // It's here, and it's NOT expired. (Or we would have returned already.)
844 
845  string strMint = OTAPI_Wrap::LoadMint(SERVER_ID, ASSET_ID);
846  if (!VerifyStringVal(strMint)) {
847  otOut << "OT_ME_load_or_retrieve_mint: Unable to load mint for IDs: \n";
848  otOut << " Server ID: " << SERVER_ID << "\n";
849  otOut << " Nym ID: " << NYM_ID << "\n";
850  otOut << " Asset ID: " << ASSET_ID << "\n";
851  }
852 
853  return strMint;
854 }
855 
856 // QUERY ASSET TYPES
857 //
858 // See if some asset types are issued on the server.
859 //
860 OT_MADE_EASY_OT string MadeEasy::query_asset_types(const string& SERVER_ID,
861  const string& NYM_ID,
862  const string& ENCODED_MAP)
863 {
864  OTAPI_Func ot_Msg;
865 
866  OTAPI_Func theRequest(QUERY_ASSET_TYPES, SERVER_ID, NYM_ID, ENCODED_MAP);
867  string strResponse =
868  theRequest.SendRequest(theRequest, "QUERY_ASSET_TYPES");
869 
870  return strResponse;
871 }
872 
873 // CREATE MARKET OFFER -- TRANSACTION
874 
876  const string& ASSET_ACCT_ID, const string& CURRENCY_ACCT_ID,
877  const string& scale, const string& minIncrement, const string& quantity,
878  const string& price, bool bSelling, const string& strLifespanInSeconds,
879  const string& strStopSign, const string& strActivationPrice)
880 {
881  OTAPI_Func ot_Msg;
882 
883  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(ASSET_ACCT_ID);
884  string strUserID = OTAPI_Wrap::GetAccountWallet_NymID(ASSET_ACCT_ID);
885 
886  OTAPI_Func theRequest(CREATE_MARKET_OFFER, strServerID, strUserID,
887  ASSET_ACCT_ID, CURRENCY_ACCT_ID, scale, minIncrement,
888  quantity, price, bSelling);
889 
890  // Cannot have more than 10 parameters in a function call, in this script.
891  // So I am forced to set the final parameters by hand, before sending the
892  // transaction:
893  //
894  if (VerifyStringVal(strLifespanInSeconds)) {
895  theRequest.tData =
896  OTTimeGetTimeFromSeconds(stoll(strLifespanInSeconds));
897  }
898 
899  if (VerifyStringVal(strStopSign)) {
900  theRequest.strData5 = strStopSign;
901  }
902 
903  if (VerifyStringVal(strActivationPrice)) {
904  theRequest.lData = stoll(strActivationPrice);
905  }
906 
907  string strResponse =
908  theRequest.SendTransaction(theRequest, "CREATE_MARKET_OFFER");
909 
910  return strResponse;
911 }
912 
913 // KILL MARKET OFFER -- TRANSACTION
914 //
915 OT_MADE_EASY_OT string MadeEasy::kill_market_offer(const string& SERVER_ID,
916  const string& NYM_ID,
917  const string& ASSET_ACCT_ID,
918  const string& STR_TRANS_NUM)
919 {
920  OTAPI_Func ot_Msg;
921 
922  OTAPI_Func theRequest(KILL_MARKET_OFFER, SERVER_ID, NYM_ID, ASSET_ACCT_ID,
923  STR_TRANS_NUM);
924  string strResponse =
925  theRequest.SendTransaction(theRequest, "KILL_MARKET_OFFER");
926 
927  return strResponse;
928 }
929 
930 // KILL PAYMENT PLAN (an active one that's already running) -- TRANSACTION
931 //
932 OT_MADE_EASY_OT string MadeEasy::kill_payment_plan(const string& SERVER_ID,
933  const string& NYM_ID,
934  const string& ACCT_ID,
935  const string& STR_TRANS_NUM)
936 {
937  OTAPI_Func ot_Msg;
938 
939  OTAPI_Func theRequest(KILL_PAYMENT_PLAN, SERVER_ID, NYM_ID, ACCT_ID,
940  STR_TRANS_NUM);
941  string strResponse =
942  theRequest.SendTransaction(theRequest, "KILL_PAYMENT_PLAN");
943 
944  return strResponse;
945 }
946 
947 // ACTIVATE SMART CONTRACT -- TRANSACTION
948 //
950  const string& SERVER_ID, const string& NYM_ID, const string& ACCT_ID,
951  const string& AGENT_NAME, const string& THE_SMART_CONTRACT)
952 {
953  OTAPI_Func ot_Msg;
954 
955  // int32_t OTAPI_Wrap::activateSmartContract(SERVER_ID, NYM_ID,
956  // THE_SMART_CONTRACT)
957 
958  OTAPI_Func theRequest(ACTIVATE_SMART_CONTRACT, SERVER_ID, NYM_ID, ACCT_ID,
959  AGENT_NAME, THE_SMART_CONTRACT);
960  string strResponse =
961  theRequest.SendTransaction(theRequest, "ACTIVATE_SMART_CONTRACT");
962 
963  return strResponse;
964 }
965 
966 // DEPOSIT PAYMENT PLAN -- TRANSACTION
967 //
968 OT_MADE_EASY_OT string
969  MadeEasy::deposit_payment_plan(const string& SERVER_ID,
970  const string& NYM_ID,
971  const string& THE_PAYMENT_PLAN)
972 {
973  OTAPI_Func ot_Msg;
974 
975  // NOTE: We have to include the account ID as well. Even though the API call
976  // itself
977  // doesn't need it (it retrieves it from the plan itself, as we are about to
978  // do here)
979  // we still have to provide the accountID for OTAPI_Func, which uses it to
980  // grab the
981  // intermediary files, as part of its automated sync duties. (FYI.)
982  //
983  string strSenderAcctID =
984  OTAPI_Wrap::Instrmnt_GetSenderAcctID(THE_PAYMENT_PLAN);
985 
986  // int32_t OTAPI_Wrap::depositPaymentPlan(SERVER_ID, NYM_ID,
987  // THE_PAYMENT_PLAN)
988  OTAPI_Func theRequest(DEPOSIT_PAYMENT_PLAN, SERVER_ID, NYM_ID,
989  strSenderAcctID, THE_PAYMENT_PLAN);
990  string strResponse =
991  theRequest.SendTransaction(theRequest, "DEPOSIT_PAYMENT_PLAN");
992  return strResponse;
993 }
994 
995 // CANCEL PAYMENT PLAN (an inactive one that hasn't been activated yet) --
996 // TRANSACTION
997 //
998 OT_MADE_EASY_OT string
999  MadeEasy::cancel_payment_plan(const string& SERVER_ID, const string& NYM_ID,
1000  const string& THE_PAYMENT_PLAN)
1001 {
1002  OTAPI_Func ot_Msg;
1003 
1004  // NOTE: We have to include the account ID as well. Even though the API call
1005  // itself
1006  // doesn't need it (it retrieves it from the plan itself, as we are about to
1007  // do here)
1008  // we still have to provide the accountID for OTAPI_Func, which uses it to
1009  // grab the
1010  // intermediary files, as part of its automated sync duties. (FYI.)
1011  //
1012  string strRecipientAcctID =
1013  OTAPI_Wrap::Instrmnt_GetRecipientAcctID(THE_PAYMENT_PLAN);
1014 
1015  // otOut << "\n\n DEBUGGING: NYM_ID: "+NYM_ID+"
1016  // strRecipientAcctID: "+strRecipientAcctID+" \n\n")
1017 
1018  // NOTE: Normally the SENDER (PAYER) is the one who deposits a payment plan.
1019  // But
1020  // in this case, the RECIPIENT (PAYEE) deposits it -- which means "Please
1021  // cancel this plan."
1022  // It SHOULD fail, since it's only been signed by the recipient, and not the
1023  // sender.
1024  // And that failure is what burns the transaction number on the plan, so
1025  // that it can
1026  // no longer be used.
1027  //
1028  // So how do we know the difference between an ACTUAL "failure" versus a
1029  // purposeful "failure" ?
1030  // Because if the failure comes from cancelling the plan, the server reply
1031  // transaction will have
1032  // IsCancelled() set to true.
1033  //
1034  // (Therefore theRequest.SendTransaction is smart enough to check for that.)
1035 
1036  OTAPI_Func theRequest(DEPOSIT_PAYMENT_PLAN, SERVER_ID, NYM_ID,
1037  strRecipientAcctID, THE_PAYMENT_PLAN);
1038  string strResponse =
1039  theRequest.SendTransaction(theRequest, "CANCEL_PAYMENT_PLAN");
1040  return strResponse;
1041 }
1042 
1043 // TRIGGER CLAUSE (on running smart contract) -- TRANSACTION
1044 //
1045 OT_MADE_EASY_OT string
1046  MadeEasy::trigger_clause(const string& SERVER_ID, const string& NYM_ID,
1047  const string& STR_TRANS_NUM,
1048  const string& CLAUSE_NAME, const string& STR_PARAM)
1049 {
1050  OTAPI_Func ot_Msg;
1051 
1052  // int32_t OTAPI_Wrap::triggerClause(const char* SERVER_ID,
1053  // const char * USER_ID,
1054  // const char * TRANSACTION_NUMBER,
1055  // const char * CLAUSE_NAME,
1056  // const char * STR_PARAM);
1057 
1058  OTAPI_Func theRequest(TRIGGER_CLAUSE, SERVER_ID, NYM_ID, STR_TRANS_NUM,
1059  CLAUSE_NAME, STR_PARAM);
1060  string strResponse = theRequest.SendRequest(theRequest, "TRIGGER_CLAUSE");
1061 
1062  return strResponse;
1063 }
1064 
1065 // WITHDRAW CASH -- TRANSACTION
1066 //
1067 OT_MADE_EASY_OT string
1068  MadeEasy::withdraw_cash(const string& SERVER_ID, const string& NYM_ID,
1069  const string& ACCT_ID, int64_t AMOUNT)
1070 {
1071  OTAPI_Func ot_Msg;
1072 
1073  OTAPI_Func theRequest(WITHDRAW_CASH, SERVER_ID, NYM_ID, ACCT_ID, AMOUNT);
1074  string strResponse =
1075  theRequest.SendTransaction(theRequest, "WITHDRAW_CASH");
1076 
1077  return strResponse;
1078 }
1079 
1080 // WITHDRAW VOUCHER -- TRANSACTION
1081 //
1082 OT_MADE_EASY_OT string
1083  MadeEasy::withdraw_voucher(const string& SERVER_ID, const string& NYM_ID,
1084  const string& ACCT_ID,
1085  const string& RECIP_NYM_ID,
1086  const string& STR_MEMO, int64_t AMOUNT)
1087 {
1088  OTAPI_Func ot_Msg;
1089 
1090  OTAPI_Func theRequest(WITHDRAW_VOUCHER, SERVER_ID, NYM_ID, ACCT_ID,
1091  RECIP_NYM_ID, STR_MEMO, AMOUNT);
1092  string strResponse =
1093  theRequest.SendTransaction(theRequest, "WITHDRAW_VOUCHER");
1094 
1095  return strResponse;
1096 }
1097 
1098 // PAY DIVIDEND -- TRANSACTION
1099 //
1100 OT_MADE_EASY_OT string
1101  MadeEasy::pay_dividend(const string& SERVER_ID, const string& NYM_ID,
1102  const string& SOURCE_ACCT_ID,
1103  const string& SHARES_ASSET_ID,
1104  const string& STR_MEMO, int64_t AMOUNT_PER_SHARE)
1105 {
1106  OTAPI_Func ot_Msg;
1107 
1108  OTAPI_Func theRequest(PAY_DIVIDEND, SERVER_ID, NYM_ID, SOURCE_ACCT_ID,
1109  SHARES_ASSET_ID, STR_MEMO, AMOUNT_PER_SHARE);
1110  string strResponse = theRequest.SendTransaction(theRequest, "PAY_DIVIDEND");
1111 
1112  return strResponse;
1113 }
1114 
1115 OT_MADE_EASY_OT string
1116  MadeEasy::deposit_cheque(const string& SERVER_ID, const string& NYM_ID,
1117  const string& ACCT_ID, const string& STR_CHEQUE)
1118 {
1119  OTAPI_Func ot_Msg;
1120 
1121  OTAPI_Func theRequest(DEPOSIT_CHEQUE, SERVER_ID, NYM_ID, ACCT_ID,
1122  STR_CHEQUE);
1123  string strResponse = theRequest.SendTransaction(
1124  theRequest, "DEPOSIT_CHEQUE"); // <========================;
1125 
1126  return strResponse;
1127 }
1128 
1129 OT_MADE_EASY_OT string
1130  MadeEasy::get_market_list(const string& SERVER_ID, const string& NYM_ID)
1131 {
1132  OTAPI_Func ot_Msg;
1133 
1134  OTAPI_Func theRequest(GET_MARKET_LIST, SERVER_ID, NYM_ID);
1135  string strResponse = theRequest.SendRequest(
1136  theRequest, "GET_MARKET_LIST"); // <========================;
1137 
1138  return strResponse;
1139 }
1140 
1141 // int32_t OTAPI_Wrap::getMarketOffers(const char* SERVER_ID,
1142 // const char * USER_ID,
1143 // const char * MARKET_ID,
1144 // const char * MAX_DEPTH)
1145 
1146 OT_MADE_EASY_OT string
1147  MadeEasy::get_market_offers(const string& SERVER_ID, const string& NYM_ID,
1148  const string& MARKET_ID, int64_t MAX_DEPTH)
1149 {
1150  OTAPI_Func ot_Msg;
1151 
1152  OTAPI_Func theRequest(GET_MARKET_OFFERS, SERVER_ID, NYM_ID, MARKET_ID,
1153  MAX_DEPTH);
1154  string strResponse = theRequest.SendRequest(
1155  theRequest, "GET_MARKET_OFFERS"); // <========================;
1156 
1157  return strResponse;
1158 }
1159 
1160 OT_MADE_EASY_OT string MadeEasy::get_nym_market_offers(const string& SERVER_ID,
1161  const string& NYM_ID)
1162 {
1163  OTAPI_Func ot_Msg;
1164 
1165  OTAPI_Func theRequest(GET_NYM_MARKET_OFFERS, SERVER_ID, NYM_ID);
1166  string strResponse = theRequest.SendRequest(
1167  theRequest, "GET_NYM_MARKET_OFFERS"); // <========================;
1168 
1169  return strResponse;
1170 }
1171 
1172 OT_MADE_EASY_OT string
1173  MadeEasy::get_market_recent_trades(const string& SERVER_ID,
1174  const string& NYM_ID,
1175  const string& MARKET_ID)
1176 {
1177  OTAPI_Func ot_Msg;
1178 
1179  OTAPI_Func theRequest(GET_MARKET_RECENT_TRADES, SERVER_ID, NYM_ID,
1180  MARKET_ID);
1181  string strResponse = theRequest.SendRequest(
1182  theRequest, "GET_MARKET_RECENT_TRADES"); // <========================;
1183 
1184  return strResponse;
1185 }
1186 
1187 OT_MADE_EASY_OT string
1188  MadeEasy::adjust_usage_credits(const string& SERVER_ID,
1189  const string& USER_NYM_ID,
1190  const string& TARGET_NYM_ID,
1191  const string& ADJUSTMENT)
1192 {
1193  OTAPI_Func ot_Msg;
1194 
1195  OTAPI_Func theRequest(ADJUST_USAGE_CREDITS, SERVER_ID, USER_NYM_ID,
1196  TARGET_NYM_ID, ADJUSTMENT);
1197  string strResponse = theRequest.SendRequest(
1198  theRequest, "ADJUST_USAGE_CREDITS"); // <========================;
1199 
1200  return strResponse;
1201 }
1202 
1203 // Imports a purse into the wallet.
1204 
1205 // NOTE: UNUSED currently.
1206 OT_MADE_EASY_OT bool MadeEasy::importCashPurse(const string& serverID,
1207  const string& nymID,
1208  const string& assetID,
1209  string& userInput, bool isPurse)
1210 {
1211  // otOut << "OT_ME_importCashPurse, serverID:" << serverID << "
1212  // nymID:" << nymID << " assetID:" << assetID);
1213  // otOut << "OT_ME_importCashPurse, userInput purse:" <<
1214  // userInput <<);
1215 
1216  if (!isPurse) // it's not a purse. Must be a
1217  // token, so let's create a purse
1218  // for it.
1219  {
1220  // otOut << "OT_ME_importCashPurse, isPurse:" +
1221  // isPurse)
1222 
1223  string purse = OTAPI_Wrap::CreatePurse(
1224  serverID, assetID, nymID, nymID); // nymID, nymID == owner, signer;
1225 
1226  if (!VerifyStringVal(purse)) {
1227  otOut << "OT_ME_importCashPurse: Error: "
1228  "OT_API_CreatePurse returned null\n";
1229  return false;
1230  }
1231  // otOut << "OT_ME_importCashPurse, OT_API_CreatePurse
1232  // return :" + purse);
1233 
1234  string newPurse = OTAPI_Wrap::Purse_Push(serverID, assetID, nymID,
1235  nymID, purse, userInput);
1236  if (!VerifyStringVal(newPurse)) {
1237  otOut << "OT_ME_importCashPurse: Error: "
1238  "OT_API_Purse_Push returned null\n";
1239  return false;
1240  }
1241  // otOut << "OT_ME_importCashPurse, OT_API_Purse_Push
1242  // returned :" + newPurse);
1243  userInput = newPurse;
1244  }
1245  // otOut << "OT_ME_importCashPurse, Before calling
1246  // OT_API_Wallet_ImportPurse, final purse:" + userInput);
1247  // otOut << "OT_ME_importCashPurse just before api ,
1248  // serverID:" + serverID + " nymID:" + nymID + " assetID:" + assetID);
1249 
1250  // Here we have either a purse that was passed in, or a purse that we
1251  // created so
1252  // we could add the token that was passed in. Either way, we have a purse
1253  // now, so
1254  // let's import it into the wallet.
1255  //
1256  return 1 ==
1257  OTAPI_Wrap::Wallet_ImportPurse(serverID, assetID, nymID, userInput);
1258 }
1259 
1260 // processCashPurse pops the selected tokens off of oldPurse, changes their
1261 // owner to recipientNymID,
1262 // and pushes them onto newPurse, owned by recipientNymID. Meanwhile any
1263 // unselected tokens are pushed
1264 // onto newPurseUnselectedTokens, owned by nymID, which is saved to local
1265 // storage (overwriting...)
1266 // newPurse is returned from this function.
1267 //
1268 // Thus, for example, if there's a problem depositing/exporting/exchanging
1269 // newPurse, then it needs
1270 // to be merged back into the old purse again, which is otherwise still missing
1271 // those tokens. (We
1272 // should keep a copy of them in the payments outbox or something like that, in
1273 // the meantime.)
1274 //
1275 // What is newPurseForSender for?
1276 // Sometimes when processCashPurse is called, a Nym is just removing tokens from
1277 // his purse so he can
1278 // deposit them into his own account. Meaning the "sender" Nym (who owns the
1279 // purse) is the same as the
1280 // "recipient" Nym (who owns the account.) In which case, newPurse (for
1281 // recipient) and newPurseForSender
1282 // will contain the exact same thing. But in the case where they are different
1283 // Nyms (like if I am
1284 // exporting these tokens from my purse in order to give them to someone else)
1285 // then I will want a copy
1286 // of the exported purse for the recipient, and a copy of the same exported
1287 // purse for the sender.
1288 // processCashPurse returns both of those for me. The reason is because
1289 // otherwise, if I just encrypted
1290 // some of my cash tokens to some external Nym, then only THAT Nym's private key
1291 // will ever open them up
1292 // again. Even if I have them in my outpayments box, I can never recover them
1293 // because I can never again
1294 // decrypt them. Therefore I make a special copy of the outgoing purse which is
1295 // encrypted to my own key,
1296 // and put that into my outpayments box instead of the one I sent to the
1297 // recipient (or including both
1298 // of them.) That way the cash can still be recovered if necessary, from my
1299 // outpayments box, and re-imported
1300 // back into my cash purse again.
1301 //
1303  string& newPurse, string& newPurseForSender, const string& serverID,
1304  const string& assetID, const string& nymID, string& oldPurse,
1305  const vector<string>& selectedTokens, const string& recipientNymID,
1306  bool bPWProtectOldPurse, bool bPWProtectNewPurse)
1307 {
1308  // By this point, we know that "selected tokens" has a size of 0, or MORE
1309  // THAN ONE. (But NOT 1 exactly.)
1310  // (At least, if this function was called by exportCashPurse.)
1311  string strLocation = "OT_ME_processCashPurse";
1312 
1313  // This block handles cases where NO TOKENS ARE SELECTED.
1314  //
1315  // (Meaning: "PROCESS" THEM ALL.)
1316  //
1317  if (selectedTokens.size() < 1) {
1318  // newPurse is created, OWNED BY RECIPIENT.
1319  //
1320  newPurse =
1321  (bPWProtectNewPurse
1322  ? OTAPI_Wrap::CreatePurse_Passphrase(serverID, assetID, nymID)
1323  : OTAPI_Wrap::CreatePurse(serverID, assetID, recipientNymID,
1324  nymID)); // recipientNymID is owner,
1325  // nymID is signer;
1326 
1327  if (!VerifyStringVal(newPurse)) {
1328  otOut << strLocation << ": "
1329  << (bPWProtectNewPurse ? "OT_API_CreatePurse_Passphrase"
1330  : "OT_API_CreatePurse")
1331  << " returned null\n";
1332  return false;
1333  }
1334 
1335  // We'll create an extra copy of the newPurse, which is encrypted to the
1336  // sender (instead of the recipient or
1337  // some passphrase.) We'll call it newPurseForSender. This way the
1338  // sender can later have the option to recover
1339  // the cash from his outbox.
1340  //
1341  newPurseForSender =
1342  OTAPI_Wrap::CreatePurse(serverID, assetID, nymID,
1343  nymID); // nymID is owner, nymID is signer;
1344 
1345  if (!VerifyStringVal(newPurseForSender)) {
1346  otOut << strLocation
1347  << ": Failure: OT_API_CreatePurse returned null\n";
1348  return false;
1349  }
1350 
1351  // Iterate through the OLD PURSE. (as tempOldPurse.)
1352  //
1353  int32_t count = OTAPI_Wrap::Purse_Count(serverID, assetID, oldPurse);
1354  string tempOldPurse = oldPurse;
1355 
1356  for (int32_t i = 0; i < count; ++i) {
1357  // Peek into TOKEN, from the top token on the stack. (And it's STILL
1358  // on top after this call.)
1359  //
1360  string token =
1361  OTAPI_Wrap::Purse_Peek(serverID, assetID, nymID, tempOldPurse);
1362 
1363  // Now pop the token off of tempOldPurse (our iterator for the old
1364  // purse).
1365  // Store updated copy of purse (sans token) into "str1".
1366  //
1367  string str1 =
1368  OTAPI_Wrap::Purse_Pop(serverID, assetID, nymID, tempOldPurse);
1369 
1370  if (!VerifyStringVal(token) || !VerifyStringVal(str1)) {
1371  otOut << strLocation
1372  << ": OT_API_Purse_Peek or OT_API_Purse_Pop "
1373  "returned null... SHOULD NEVER HAPPEN. "
1374  "Returning null.\n";
1375  return false;
1376  }
1377 
1378  // Since pop succeeded, copy the output to tempOldPurse
1379  // (for next iteration, in case any continues happen below.)
1380  // Now tempOldPurse contains what it did before, MINUS ONE TOKEN.
1381  // (The exported one.)
1382  //
1383  tempOldPurse = str1;
1384 
1385  string strSender = bPWProtectOldPurse ? oldPurse : nymID;
1386  string strRecipient =
1387  bPWProtectNewPurse ? newPurse : recipientNymID;
1388 
1389  string strSenderAsRecipient =
1390  nymID; // Used as the "owner" of newPurseForSender. (So the
1391  // sender can recover his sent coins that got encrypted
1392  // to someone else's key.);
1393 
1394  // Change the OWNER on token, from NymID to RECIPIENT.
1395  // (In this block, we change ALL the tokens in the purse.)
1396  //
1397  string exportedToken = OTAPI_Wrap::Token_ChangeOwner(
1398  serverID, assetID, token, nymID, // signer ID
1399  strSender, // old owner
1400  strRecipient); // new owner
1401  // If change failed, then continue.
1402  //
1403  if (!VerifyStringVal(exportedToken)) {
1404  otOut << strLocation << ": 1, OT_API_Token_ChangeOwner "
1405  "returned null...(should never "
1406  "happen) Returning null.\n";
1407  return false;
1408  }
1409 
1410  // SAVE A COPY FOR THE SENDER...
1411  //
1412  string retainedToken = OTAPI_Wrap::Token_ChangeOwner(
1413  serverID, assetID, token, nymID, // signer ID
1414  strSender, // old owner
1415  strSenderAsRecipient); // new owner
1416  // If change failed, then continue.
1417  //
1418  if (!VerifyStringVal(retainedToken)) {
1419  otOut << strLocation << ": 2, OT_API_Token_ChangeOwner "
1420  "returned null...(should never "
1421  "happen) Returning null.\n";
1422  return false;
1423  }
1424 
1425  // strSender = bPWProtectOldPurse ? "" : nymID // unused
1426  // here. not needed.
1427  strRecipient = bPWProtectNewPurse ? "" : recipientNymID;
1428 
1429  // PUSH the EXPORTED TOKEN (new owner) into the new purse (again,
1430  // recipient/newPurse is new owner) and save results in
1431  // "strPushedForRecipient".
1432  // Results are, FYI, newPurse+exportedToken.
1433  //
1434  string strPushedForRecipient = OTAPI_Wrap::Purse_Push(
1435  serverID, assetID, nymID, // server, asset, signer
1436  strRecipient, // owner is either nullptr (for password-protected
1437  // purse) or recipientNymID
1438  newPurse, exportedToken); // purse, token
1439 
1440  // If push failed, then continue.
1441  if (!VerifyStringVal(strPushedForRecipient)) {
1442  otOut << strLocation
1443  << ": OT_API_Purse_Push 1 returned null... "
1444  "(should never happen) Returning null.\n";
1445  return false;
1446  }
1447 
1448  // PUSH the RETAINED TOKEN (copy for original owner) into the
1449  // newPurseForSender and save results in "strPushedForRetention".
1450  // Results are, FYI, newPurseForSender+retainedToken.
1451  //
1452  string strPushedForRetention = OTAPI_Wrap::Purse_Push(
1453  serverID, assetID, nymID, // server, asset, signer
1454  strSenderAsRecipient, // This version of the purse is the
1455  // outgoing copy (for the SENDER's notes).
1456  // Thus strSenderAsRecipient.
1457  newPurseForSender, retainedToken); // purse, token
1458 
1459  // If push failed, then continue.
1460  if (!VerifyStringVal(strPushedForRetention)) {
1461  otOut << strLocation
1462  << ": OT_API_Purse_Push 2 returned null... "
1463  "(should never happen) Returning null.\n";
1464  return false;
1465  }
1466 
1467  // Since push succeeded, copy "strPushedForRecipient" (containing
1468  // newPurse +exportedToken) into newPurse.
1469  // Since push succeeded, copy "strPushedForRetention" (containing
1470  // newPurseForSender+retainedToken) into newPurseForSender.
1471  //
1472  newPurse = strPushedForRecipient;
1473  newPurseForSender = strPushedForRetention;
1474  } // for
1475 
1476  // Save tempOldPurse to local storage. (For OLD Owner.)
1477  // By now, all of the tokens have been popped off of this purse, so it
1478  // is EMPTY.
1479  // We're now saving the empty purse, since the user exported all of the
1480  // tokens.
1481  //
1482  // THERE MAYBE SHOULD BE AN EXTRA MODAL HERE, that says,
1483  // "Moneychanger will now save your purse, EMPTY, back to local storage.
1484  // Are you sure you want to do this?"
1485  //
1486 
1487  if (!bPWProtectOldPurse) // If old purse is NOT password-protected (that
1488  // is, it's encrypted to a Nym.)
1489  {
1490  if (!OTAPI_Wrap::SavePurse(serverID, assetID, nymID,
1491  tempOldPurse)) // if FAILURE.
1492  {
1493  // No error message if saving fails??
1494  // No modal?
1495  //
1496  // FT: adding log.
1497  otOut << strLocation << ": OT_API_SavePurse "
1498  "FAILED. SHOULD NEVER HAPPEN!!!!!!\n";
1499  return false;
1500  }
1501  }
1502  else // old purse IS password protected. (So return its updated
1503  // version.)
1504  {
1505  oldPurse = tempOldPurse; // We never cared about this with Nym-owned
1506  // old purse, since it saves to storage
1507  // anyway, in the above block. But now in
1508  // the case of password-protected purses,
1509  // we set the oldPurse to contain the new
1510  // version of itself (containing the tokens
1511  // that had been left unselected) so the
1512  // caller can do what he wills with it.;
1513  }
1514  }
1515 
1516  // Else, SPECIFIC TOKENS were selected, so process those only...
1517  //
1518  else {
1519  // otOut << "Tokens in Cash Purse being processed");
1520 
1521  // newPurseSelectedTokens is created (CORRECTLY) with recipientNymID as
1522  // owner. (Or with a symmetric key / passphrase.)
1523  // newPurseUnSelectedTokens is created (CORRECTLY) with NymID as owner.
1524  // (Unselected tokens aren't being exported...)
1525  //
1526  string newPurseUnSelectedTokens = OTAPI_Wrap::Purse_Empty(
1527  serverID, assetID, nymID,
1528  oldPurse); // Creates an empty copy of oldPurse.;
1529  string newPurseSelectedTokens =
1530  (bPWProtectNewPurse
1531  ? OTAPI_Wrap::CreatePurse_Passphrase(serverID, assetID, nymID)
1532  : OTAPI_Wrap::CreatePurse(serverID, assetID, recipientNymID,
1533  nymID)); // recipientNymID = owner,
1534  // nymID = signer;
1535  string newPurseSelectedForSender = OTAPI_Wrap::CreatePurse(
1536  serverID, assetID, nymID,
1537  nymID); // nymID = owner, nymID = signer. This is a copy of
1538  // newPurseSelectedTokens that's encrypted to the SENDER
1539  // (for putting in his outpayments box, so he can still
1540  // decrypt if necessary.);
1541 
1542  if (!VerifyStringVal(newPurseSelectedForSender)) {
1543  otOut << strLocation << ": OT_API_CreatePurse returned null\n";
1544  return false;
1545  }
1546  if (!VerifyStringVal(newPurseSelectedTokens)) {
1547  otOut << strLocation
1548  << ": OT_API_CreatePurse or "
1549  "OT_API_CreatePurse_Passphrase returned null\n";
1550  return false;
1551  }
1552  if (!VerifyStringVal((newPurseUnSelectedTokens))) {
1553  otOut << strLocation << ": OT_API_Purse_Empty returned null\n";
1554  return false;
1555  }
1556 
1557  // Iterate through oldPurse, using tempOldPurse as iterator.
1558  //
1559  int32_t count = OTAPI_Wrap::Purse_Count(serverID, assetID, oldPurse);
1560  string tempOldPurse = oldPurse;
1561 
1562  for (int32_t i = 0; i < count; ++i) {
1563  // Peek at the token on top of the stack.
1564  // (Without removing it.)
1565  //
1566  string token =
1567  OTAPI_Wrap::Purse_Peek(serverID, assetID, nymID, tempOldPurse);
1568 
1569  // Remove the top token from the stack, and return the updated stack
1570  // in "str1".
1571  //
1572  string str1 =
1573  OTAPI_Wrap::Purse_Pop(serverID, assetID, nymID, tempOldPurse);
1574 
1575  if (!VerifyStringVal(str1) || !VerifyStringVal(token)) {
1576  otOut << strLocation
1577  << ": OT_API_Purse_Peek or "
1578  "OT_API_Purse_Pop returned null... returning Null. "
1579  "(SHOULD NEVER HAPPEN.)\n";
1580  return false;
1581  }
1582 
1583  // Putting updated purse into iterator, so any subsequent continues
1584  // will work properly.
1585  //
1586  tempOldPurse = str1;
1587 
1588  // Grab the TokenID for that token. (Token still has OLD OWNER.)
1589  //
1590  string tokenID = OTAPI_Wrap::Token_GetID(serverID, assetID, token);
1591 
1592  if (!VerifyStringVal(tokenID)) {
1593  otOut << strLocation
1594  << ": OT_API_Token_GetID returned null... "
1595  "SHOULD NEVER HAPPEN. Returning now.\n";
1596  return false;
1597  }
1598 
1599  // At this point, we check TokenID (identifying the current token)
1600  // to see if it's on the SELECTED LIST.
1601  //
1602  if (find(selectedTokens.begin(), selectedTokens.end(), tokenID) !=
1603  selectedTokens.end()) // We ARE exporting
1604  // this token. (Its
1605  // ID was on the
1606  // list.)
1607  {
1608  // CHANGE OWNER from NYM to RECIPIENT
1609  // "token" will now contain the EXPORTED TOKEN, with the NEW
1610  // OWNER.
1611  //
1612  string strSender = bPWProtectOldPurse ? oldPurse : nymID;
1613  string strRecipient = bPWProtectNewPurse
1614  ? newPurseSelectedTokens
1615  : recipientNymID;
1616 
1617  string strSenderAsRecipient =
1618  nymID; // Used as the "owner" of newPurseSelectedForSender.
1619  // (So the sender can recover his sent coins that got
1620  // encrypted to someone else's key.);
1621 
1622  string exportedToken = OTAPI_Wrap::Token_ChangeOwner(
1623  serverID, assetID, token, // server, asset, token,;
1624  nymID, // signer nym
1625  strSender, // old owner
1626  strRecipient); // new owner
1627  if (!VerifyStringVal(exportedToken)) {
1628  otOut << strLocation << ": 1 OT_API_Token_ChangeOwner "
1629  "returned null... SHOULD NEVER "
1630  "HAPPEN. Returning now.\n";
1631  return false;
1632  }
1633 
1634  string retainedToken = OTAPI_Wrap::Token_ChangeOwner(
1635  serverID, assetID, token, // server, asset, token,;
1636  nymID, // signer nym
1637  strSender, // old owner
1638  strSenderAsRecipient); // new owner
1639  if (!VerifyStringVal(retainedToken)) {
1640  otOut << strLocation << ": 2 OT_API_Token_ChangeOwner "
1641  "returned null... SHOULD NEVER "
1642  "HAPPEN. Returning now.\n";
1643  return false;
1644  }
1645 
1646  // Push exported version of token into new purse for recipient
1647  // (for selected tokens.)
1648  //
1649  // strSender = bPWProtectOldPurse ? "" : nymID
1650  // // unused here. Not needed.
1651  strRecipient = bPWProtectNewPurse ? "" : recipientNymID;
1652 
1653  string strPushedForRecipient = OTAPI_Wrap::Purse_Push(
1654  serverID, assetID, nymID, // server, asset, signer;
1655  strRecipient, // owner is either nullptr (for
1656  // password-protected purse) or recipientNymID
1657  newPurseSelectedTokens, exportedToken); // purse, token
1658  if (!VerifyStringVal(strPushedForRecipient)) {
1659  otOut << strLocation
1660  << ": OT_API_Purse_Push "
1661  "newPurseSelectedTokens returned null... "
1662  "SHOULD NEVER HAPPEN (returning.)\n";
1663  return false;
1664  }
1665 
1666  // Done: push a copy of these into a purse for the original
1667  // owner as well, so he has his OWN copy
1668  // to save in his payments outbox (that HE can decrypt...) so if
1669  // the cash is lost, for example, he can still
1670  // recover it. If the recipient receives it and deposits it
1671  // correctly, the cash in your payment outbox is now
1672  // worthless and can be discarded, although its existence may be
1673  // valuable to you as a receipt.
1674  //
1675  string strPushedForRetention = OTAPI_Wrap::Purse_Push(
1676  serverID, assetID, nymID, // server, asset, signer;
1677  strSenderAsRecipient, newPurseSelectedForSender,
1678  retainedToken); // purse, token
1679  if (!VerifyStringVal(strPushedForRetention)) {
1680  otOut << strLocation
1681  << ": OT_API_Purse_Push "
1682  "newPurseSelectedForSender returned null... "
1683  "SHOULD NEVER HAPPEN (returning.)\n";
1684  return false;
1685  }
1686 
1687  newPurseSelectedTokens = strPushedForRecipient;
1688  newPurseSelectedForSender = strPushedForRetention;
1689 
1690  }
1691  else // The token, this iteration, is NOT being exported, but is
1692  // remaining with the original owner.
1693  {
1694  string strSender = bPWProtectOldPurse ? "" : nymID;
1695 
1696  string str = OTAPI_Wrap::Purse_Push(
1697  serverID, assetID, nymID, // server, asset, signer;
1698  strSender, // owner is either nullptr (for
1699  // password-protected
1700  // purse) or nymID
1701  newPurseUnSelectedTokens, token); // purse, token
1702  if (!VerifyStringVal(str)) {
1703  otOut << strLocation
1704  << ": OT_API_Purse_Push "
1705  "newPurseUnSelectedTokens returned null... "
1706  "SHOULD NEVER HAPPEN. Returning false.\n";
1707  return false;
1708  }
1709 
1710  newPurseUnSelectedTokens = str;
1711  }
1712  } // for
1713 
1714  if (!bPWProtectOldPurse) // If old purse is NOT password-protected (that
1715  // is, it's encrypted to a Nym.)
1716  {
1717  if (!OTAPI_Wrap::SavePurse(serverID, assetID, nymID,
1718  newPurseUnSelectedTokens)) // if FAILURE.
1719  {
1720  // No error message if saving fails??
1721  // No modal?
1722  //
1723  // FT: adding log.
1724  otOut << strLocation << ": OT_API_SavePurse "
1725  "FAILED. SHOULD NEVER HAPPEN!!!!!!\n";
1726  return false;
1727  }
1728  }
1729  else // old purse IS password protected. (So return its updated
1730  // version.)
1731  {
1732  oldPurse =
1733  newPurseUnSelectedTokens; // We never cared about this with
1734  // Nym-owned old purse, since it saves
1735  // to storage anyway, in the above
1736  // block. But now in the case of
1737  // password-protected purses, we set
1738  // the oldPurse to contain the new
1739  // version of itself (containing the
1740  // tokens that had been left
1741  // unselected) so the caller can do
1742  // what he wills with it.;
1743  }
1744 
1745  // The SELECTED tokens (with Recipient as owner of purse AND tokens
1746  // within) are returned as the "newPurse".
1747  // The SELECTED tokens (with Sender as owner of purse AND tokens within)
1748  // are returned as "newPurseForSender".
1749  //
1750  newPurse = newPurseSelectedTokens;
1751  newPurseForSender = newPurseSelectedForSender;
1752  }
1753 
1754  return true;
1755 }
1756 
1757 // Input: server ID, assetID, Nym of current owner, existing purse, list of
1758 // selected tokens, Nym of Recipient, and bool bPasswordProtected.
1759 // Returns: "new Purse"
1760 //
1761 OT_MADE_EASY_OT string
1762  MadeEasy::exportCashPurse(const string& serverID, const string& assetID,
1763  const string& nymID, const string& oldPurse,
1764  const vector<string>& selectedTokens,
1765  string& recipientNymID, bool bPasswordProtected,
1766  string& strRetainedCopy)
1767 {
1768  // otOut << "OT_ME_exportCashPurse starts, selectedTokens:" <<
1769  // selectedTokens << "\n";
1770  // Utility.setObj(null);
1771 
1772  if (!bPasswordProtected) {
1773  // If no recipient, then recipient == Nym.
1774  //
1775  if (!VerifyStringVal(recipientNymID) || (recipientNymID.size() == 0)) {
1776  otOut << "OT_ME_exportCashPurse: recipientNym empty--using NymID "
1777  "for recipient instead: " << nymID << "\n";
1778  recipientNymID = nymID;
1779  }
1780 
1781  if (!(recipientNymID == nymID)) {
1782  // Even though we don't use this variable after this point,
1783  // we've still done something important: loaded and possibly
1784  // downloaded the recipient Nym, so that later in this function
1785  // we can reference that recipientNymID in other calls and we know
1786  // it will work.
1787  //
1788  string recipientPubKey = load_or_retrieve_encrypt_key(
1789  serverID, nymID, recipientNymID); // this function handles
1790  // partial IDs for recipient.;
1791 
1792  if (!VerifyStringVal(recipientPubKey)) {
1793  otOut << "OT_ME_exportCashPurse: recipientPubKey is null\n";
1794  return "";
1795  }
1796  }
1797  }
1798 
1799  // By this point, we have verified that we can load the public key for the
1800  // recipient.
1801  // (IF the exported purse isn't meant to be password-protected.)
1802  //
1803  string token = "";
1804  string exportedToken = "";
1805  string exportedPurse = "";
1806 
1807  // Next I create another "newPurse" by calling this function.
1808  //
1809  string newPurse = ""; // for recipient;
1810  string newPurseForSender = "";
1811  string copyOfOldPurse = oldPurse;
1812  bool bSuccessProcess = processCashPurse(
1813  newPurse, newPurseForSender, serverID, assetID, nymID, copyOfOldPurse,
1814  selectedTokens, recipientNymID, false, bPasswordProtected);
1815 
1816  if (bSuccessProcess) {
1817  strRetainedCopy = newPurseForSender;
1818  }
1819 
1820  // Whatever is returned from that function, I return here also. Presumably a
1821  // purse...
1822  //
1823  return newPurse;
1824 }
1825 
1827  const string& serverID, const string& assetID, const string& nymID,
1828  const string& oldPurse, const vector<string>& selectedTokens,
1829  const string& accountID,
1830  bool bReimportIfFailure) // So we don't re-import a purse that wasn't
1831  // internal to begin with.
1832 {
1833  string recipientNymID = OTAPI_Wrap::GetAccountWallet_NymID(accountID);
1834  if (!VerifyStringVal(recipientNymID)) {
1835  otOut << "\ndepositCashPurse: Unable to find recipient Nym based on "
1836  "myacct. \n";
1837  return -1;
1838  }
1839 
1840  bool bPasswordProtected = OTAPI_Wrap::Purse_HasPassword(serverID, oldPurse);
1841 
1842  string newPurse; // being deposited.;
1843  string newPurseForSender = ""; // Probably unused in this case.;
1844  string copyOfOldPurse = oldPurse;
1845  bool bSuccessProcess = processCashPurse(
1846  newPurse, newPurseForSender, serverID, assetID, nymID, copyOfOldPurse,
1847  selectedTokens, recipientNymID, bPasswordProtected, false);
1848 
1849  if (!bSuccessProcess || !VerifyStringVal(newPurse)) {
1850  otOut << "OT_ME_depositCashPurse: new Purse is empty, after processing "
1851  "it for deposit. \n";
1852  return -1;
1853  }
1854 
1855  OTAPI_Func ot_Msg;
1856  OTAPI_Func theRequest(DEPOSIT_CASH, serverID, recipientNymID, accountID,
1857  newPurse);
1858  string strResponse = theRequest.SendTransaction(
1859  theRequest, "DEPOSIT_CASH"); // <========================;
1860 
1861  string strAttempt = "deposit_cash";
1862 
1863  // HERE, WE INTERPRET THE SERVER REPLY, WHETHER SUCCESS, FAIL, OR ERROR...
1864 
1865  int32_t nInterpretReply = InterpretTransactionMsgReply(
1866  serverID, recipientNymID, accountID, strAttempt, strResponse);
1867 
1868  if (1 == nInterpretReply) {
1869  // Download all the intermediary files (account balance, inbox, outbox,
1870  // etc)
1871  // since they have probably changed from this operation.
1872  //
1873  bool bRetrieved =
1874  retrieve_account(serverID, recipientNymID, accountID,
1875  true); // bForceDownload defaults to false.;
1876 
1877  otOut << "\nServer response (" << strAttempt
1878  << "): SUCCESS depositing cash!\n";
1879  otOut << string(bRetrieved ? "Success" : "Failed")
1880  << " retrieving intermediary files for account.\n";
1881  }
1882  else // failure. (so we re-import the cash, so as not to lose it...)
1883  {
1884 
1885  if (!bPasswordProtected && bReimportIfFailure) {
1886  bool importStatus = OTAPI_Wrap::Wallet_ImportPurse(
1887  serverID, assetID, recipientNymID, newPurse);
1888  otOut << "Since failure in OT_ME_depositCashPurse, "
1889  "OT_API_Wallet_ImportPurse called. Status of "
1890  "import: " << importStatus << "\n";
1891 
1892  if (!importStatus) {
1893  // Raise the alarm here that we failed depositing the purse, and
1894  // then we failed
1895  // importing it back into our wallet again.
1896  otOut << "Error: Failed depositing the cash purse, and then "
1897  "failed re-importing it back to wallet. Therefore YOU "
1898  "must copy the purse NOW and save it to a safe place! "
1899  "\n";
1900 
1901  cout << newPurse << "\n";
1902 
1903  otOut << "AGAIN: Be sure to copy the above purse "
1904  "to a safe place, since it FAILED to "
1905  "deposit and FAILED to re-import back "
1906  "into the wallet. \n";
1907  }
1908  }
1909  else {
1910  otOut << "Error: Failed depositing the cash purse. "
1911  "Therefore YOU must copy the purse NOW and "
1912  "save it to a safe place! \n";
1913 
1914  cout << newPurse << "\n";
1915 
1916  otOut << "AGAIN: Be sure to copy the above purse to a "
1917  "safe place, since it FAILED to deposit. \n";
1918  }
1919 
1920  return -1;
1921  }
1922 
1923  //
1924  // Return status to caller.
1925  //
1926  return nInterpretReply;
1927 }
1928 
1930  const string& serverID, const string& assetID, const string& nymID,
1931  string& oldPurse, const vector<string>& selectedTokens)
1932 {
1933  // Utility.setObj(null);
1934  // otOut << " Cash Purse exchange starts, selectedTokens:" +
1935  // selectedTokens + "\n")
1936 
1937  string newPurse;
1938  string newPurseForSender = ""; // Probably unused in this case.;
1939 
1940  bool bProcessSuccess = processCashPurse(
1941  newPurse, newPurseForSender, serverID, assetID, nymID, oldPurse,
1942  selectedTokens, nymID, false, false); // bIsPasswordProtected=false;
1943 
1944  if (bProcessSuccess && !VerifyStringVal(newPurse)) {
1945  otOut << "OT_ME_exchangeCashPurse: Before server OT_API_exchangePurse "
1946  "call, new Purse is empty. Returning false.\n";
1947  return false;
1948  }
1949 
1950  OTAPI_Func ot_Msg;
1951  OTAPI_Func theRequest(EXCHANGE_CASH, serverID, nymID, assetID, newPurse);
1952  string strResponse = theRequest.SendTransaction(
1953  theRequest, "EXCHANGE_CASH"); // <========================;
1954 
1955  if (!VerifyStringVal(strResponse)) {
1956  otOut << "IN OT_ME_exchangeCashPurse: theRequest.SendTransaction(() "
1957  "failed. (I give up.) \n";
1958 
1959  bool importStatus =
1960  OTAPI_Wrap::Wallet_ImportPurse(serverID, assetID, nymID, newPurse);
1961  otOut << "Since failure in OT_ME_exchangeCashPurse, "
1962  "OT_API_Wallet_ImportPurse called, status of import: "
1963  << string(importStatus ? "true" : "false") << "\n";
1964  if (!importStatus) {
1965  // Utility.setObj(newPurse)
1966  }
1967 
1968  return false;
1969  }
1970 
1971  // otOut << "OT_ME_exchangeCashPurse ends, status:
1972  // success.\n")
1973 
1974  return true;
1975 }
1976 
1977 OT_MADE_EASY_OT string
1978  MadeEasy::deposit_purse(const string& SERVER_ID, const string& NYM_ID,
1979  const string& ACCT_ID, const string& STR_PURSE)
1980 {
1981  OTAPI_Func ot_Msg;
1982 
1983  OTAPI_Func theRequest(DEPOSIT_CASH, SERVER_ID, NYM_ID, ACCT_ID, STR_PURSE);
1984  string strResponse = theRequest.SendTransaction(
1985  theRequest, "DEPOSIT_CASH"); // <========================;
1986 
1987  return strResponse;
1988 }
1989 
1990 /*
1991 
1992 DONE: create nym, register nym, issue asset type, send transfer, accept entire
1993 inbox, write cheque.
1994 
1995 Next ones: show purse, withdraw cash, deposit cash, withdraw voucher, deposit
1996 cheque.
1997 
1998 Need to add functions (like check_user above) for all of these:
1999 
2000 attr OTAPI_Func::CREATE_USER_ACCT (register nym)DONE
2001 attr OTAPI_Func::DELETE_USER_ACCT
2002 attr OTAPI_Func::CHECK_USER DONE
2003 attr OTAPI_Func::SEND_USER_MESSAGE DONE
2004 attr OTAPI_Func::ISSUE_ASSET_TYPE DONE
2005 attr OTAPI_Func::ISSUE_BASKET DONE
2006 attr OTAPI_Func::CREATE_ASSET_ACCT DONE
2007 attr OTAPI_Func::DELETE_ASSET_ACCT
2008 attr OTAPI_Func::EXCHANGE_BASKET DONE
2009 attr OTAPI_Func::PROCESS_INBOX DONE
2010 attr OTAPI_Func::DEPOSIT_CASH DONE
2011 attr OTAPI_Func::EXCHANGE_CASH
2012 attr OTAPI_Func::DEPOSIT_CHEQUE DONE
2013 attr OTAPI_Func::WITHDRAW_VOUCHER DONE
2014 attr OTAPI_Func::WITHDRAW_CASH DONE
2015 attr OTAPI_Func::PAY_DIVIDEND DONE
2016 attr OTAPI_Func::GET_CONTRACT DONE
2017 attr OTAPI_Func::SEND_TRANSFER DONE
2018 attr OTAPI_Func::GET_MARKET_LIST DONE
2019 attr OTAPI_Func::CREATE_MARKET_OFFER DONE
2020 attr OTAPI_Func::KILL_MARKET_OFFER DONE
2021 attr OTAPI_Func::KILL_PAYMENT_PLAN DONE
2022 attr OTAPI_Func::GET_NYM_MARKET_OFFERS DONE
2023 attr OTAPI_Func::GET_MARKET_OFFERS DONE
2024 attr OTAPI_Func::GET_MARKET_RECENT_TRADES
2025 attr OTAPI_Func::GET_MINT DONE
2026 attr OTAPI_Func::QUERY_ASSET_TYPES DONE
2027 attr OTAPI_Func::GET_BOX_RECEIPT DONE
2028 
2029 --- Activate Payment Plan
2030 
2031 ------ TANGENT -----------------------------------------
2032 Use cases that do not require a server message, and thus will have
2033 representative
2034 functions in ot_made_easy.ot EVEN WHEN there is no corresponding server message
2035 in ot.
2036 --- stat wallet DONE
2037 --- Stat cash purse DONE
2038 --- Stat account DONE
2039 --- Stat account inbox DONE
2040 --- Stat account outbox DONE
2041 --- Stat payment inbox DONE
2042 --- Stat record box DONE
2043 --- encode / decode DONE
2044 --- encrypt/decrypt DONE
2045 --- Password encrypt/decrypt DONE
2046 --- Sign / Verify DONE
2047 --- Create asset contract DONE
2048 --- Create server contract DONE
2049 --- Create symmetric key DONE
2050 --- Create pseudonym DONE
2051 --- Write cheque DONE
2052 --- Verify last acct receipt DONE
2053 --- Refresh (download latest) DONE
2054 --- Refresh Nym DONE
2055 --- Propose Payment Plan
2056 --- Confirm Payment Plan
2057 --- Balance DONE
2058 ---
2059 
2060 ------ END TANGENT -------------------------------------
2061 
2062 
2063 Here are parameters for the first group above.
2064 (They are called in OTAPI_Func, this code is from there):
2065 
2066 else if (funcType == DELETE_USER_ACCT)
2067 { OTAPI_Wrap::deleteUserAccount(serverID, nymID); }
2068 else if (funcType == GET_NYM_MARKET_OFFERS)
2069 { OTAPI_Wrap::getNym_MarketOffers(serverID, nymID); }
2070 else if (funcType == CREATE_ASSET_ACCT)
2071 { OTAPI_Wrap::createAssetAccount(serverID, nymID, assetID); }
2072 else if (funcType == DELETE_ASSET_ACCT)
2073 { OTAPI_Wrap::deleteAssetAccount(serverID, nymID, accountID); }
2074 else if (funcType == EXCHANGE_BASKET)
2075 { OTAPI_Wrap::exchangeBasket(serverID, nymID, assetID, basket, bBool); }
2076 else if (funcType == GET_CONTRACT)
2077 { OTAPI_Wrap::getContract(serverID, nymID, assetID); }
2078 else if (funcType == ISSUE_ASSET_TYPE)
2079 { OTAPI_Wrap::issueAssetType(serverID, nymID, strData); }
2080 else if (funcType == ISSUE_BASKET)
2081 { OTAPI_Wrap::issueBasket(serverID, nymID, basket); }
2082 else if (funcType == EXCHANGE_CASH)
2083 { OTAPI_Wrap::exchangePurse(serverID, assetID, nymID, strData); }
2084 else if (funcType == KILL_MARKET_OFFER)
2085 { OTAPI_Wrap::cancelMarketOffer(serverID, nymID, accountID, strData); }
2086 else if (funcType == PROCESS_INBOX)
2087 { OTAPI_Wrap::processInbox(serverID, nymID, accountID, strData); }
2088 else if (funcType == DEPOSIT_CASH)
2089 { OTAPI_Wrap::notarizeDeposit(serverID, nymID, accountID, strData); }
2090 else if (funcType == DEPOSIT_CHEQUE)
2091 { OTAPI_Wrap::depositCheque(serverID, nymID, accountID, strData); }
2092 else if (funcType == WITHDRAW_CASH)
2093 { OTAPI_Wrap::notarizeWithdrawal(serverID, nymID, accountID, strData); }
2094 else if (funcType == WITHDRAW_VOUCHER)
2095 { OTAPI_Wrap::withdrawVoucher(serverID, nymID, accountID, nymID2, strData,
2096 strData2); }
2097 else if (funcType == SEND_TRANSFER)
2098 { OTAPI_Wrap::notarizeTransfer(serverID, nymID, accountID, accountID2,
2099 strData, strData2); } // amount and note, for the last two.
2100 else if (funcType == GET_MARKET_LIST)
2101 { OTAPI_Wrap::getMarketList(serverID, nymID); }
2102 else if (funcType == GET_MARKET_OFFERS)
2103 { OTAPI_Wrap::getMarketOffers(serverID, nymID, strData, strData2); }
2104 else if (funcType == GET_MARKET_RECENT_TRADES)
2105 { OTAPI_Wrap::getMarketRecentTrades(serverID, nymID, strData); }
2106 else if (funcType == CREATE_MARKET_OFFER)
2107 { OTAPI_Wrap::issueMarketOffer(serverID, nymID, assetID, accountID, assetID2,
2108 accountID2,
2109 strData, strData2, strData3, strData4, bBool);
2110 }
2111 
2112 */
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:924
EXPORT static OT_MADE_EASY_OT std::string create_market_offer(const std::string &ASSET_ACCT_ID, const std::string &CURRENCY_ACCT_ID, const std::string &scale, const std::string &minIncrement, const std::string &quantity, const std::string &price, bool bSelling, const std::string &strLifespanInSeconds, const std::string &strStopSign, const std::string &strActivationPrice)
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT std::string Instrmnt_GetSenderAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:851
static EXPORT std::string LoadAssetContract(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1482
static EXPORT int32_t Basket_GetMemberCount(const std::string &BASKET_ASSET_TYPE_ID)
Definition: OTAPI.cpp:1985
static EXPORT bool SavePurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1821
EXPORT static OT_MADE_EASY_OT std::string get_payment_instrument(const std::string &SERVER_ID, const std::string &NYM_ID, int32_t nIndex, const std::string &PRELOADED_INBOX)
EXPORT OT_UTILITY_OT int32_t getAndProcessNymbox_4(const std::string &serverID, const std::string &nymID, bool &bWasMsgSent, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string retrieve_mint(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ID)
std::string to_string(const T &t)
EXPORT static OT_MADE_EASY_OT std::string register_nym(const std::string &SERVER_ID, const std::string &NYM_ID)
EXPORT static OT_MADE_EASY_OT int32_t depositCashPurse(const std::string &serverID, const std::string &assetID, const std::string &nymID, const std::string &oldPurse, const std::vector< std::string > &selectedTokens, const std::string &accountID, bool bReimportIfFailure)
static EXPORT std::string CreatePurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &SIGNER_ID)
Definition: OTAPI.cpp:1856
static EXPORT std::string LoadPubkey_Encryption(const std::string &USER_ID)
Definition: OTAPI.cpp:1445
static EXPORT std::string Purse_Empty(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1888
EXPORT static OT_MADE_EASY_OT std::string stat_asset_account(const std::string &ACCOUNT_ID)
static EXPORT std::string LoadPaymentInbox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1553
static EXPORT std::string Token_ChangeOwner(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN, const std::string &SIGNER_NYM_ID, const std::string &OLD_OWNER, const std::string &NEW_OWNER)
Definition: OTAPI.cpp:1924
EXPORT static OT_MADE_EASY_OT std::string send_user_pmnt_pubkey(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &RECIPIENT_PUBKEY, const std::string &THE_INSTRUMENT)
EXPORT static OT_MADE_EASY_OT std::string send_user_cash_pubkey(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &RECIPIENT_PUBKEY, const std::string &THE_INSTRUMENT, const std::string &INSTRUMENT_FOR_SENDER)
EXPORT static OT_MADE_EASY_OT std::string exportCashPurse(const std::string &serverID, const std::string &assetID, const std::string &nymID, const std::string &oldPurse, const std::vector< std::string > &selectedTokens, std::string &recipientNymID, bool bPasswordProtected, std::string &strRetainedCopy)
static EXPORT std::string Instrmnt_GetRecipientAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:863
EXPORT static OT_MADE_EASY_OT std::string send_user_msg_pubkey(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &RECIPIENT_PUBKEY, const std::string &THE_MESSAGE)
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string issue_asset_type(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_CONTRACT)
EXPORT static OT_MADE_EASY_OT std::string issue_basket_currency(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_BASKET)
EXPORT static OT_MADE_EASY_OT std::string withdraw_voucher(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &RECIP_NYM_ID, const std::string &STR_MEMO, int64_t AMOUNT)
EXPORT static OT_MADE_EASY_OT std::string withdraw_cash(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, int64_t AMOUNT)
EXPORT static OT_MADE_EASY_OT std::string retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
Definition: Common.hpp:215
time64_t tData
EXPORT static OT_MADE_EASY_OT std::string send_user_msg(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_MESSAGE)
EXPORT static OT_MADE_EASY_OT std::string get_box_receipt(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, int32_t nBoxType, const std::string &STR_TRANS_NUM)
EXPORT static OT_MADE_EASY_OT int32_t retrieve_nym(const std::string &strServerID, const std::string &strMyNymID, bool &bWasMsgSent, bool bForceDownload)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
static EXPORT int64_t GetAccountWallet_Balance(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1032
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT std::string Ledger_GetInstrument(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1649
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
static EXPORT std::string Purse_Push(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &SIGNER_ID, const std::string &OWNER_ID, const std::string &THE_PURSE, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1896
EXPORT static OT_MADE_EASY_OT std::string kill_market_offer(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ACCT_ID, const std::string &STR_TRANS_NUM)
static EXPORT std::string CreateNym(const int32_t &nKeySize, const std::string &NYM_ID_SOURCE, const std::string &ALT_LOCATION)
Definition: OTAPI.cpp:358
static EXPORT std::string LoadPubkey_Signing(const std::string &USER_ID)
Definition: OTAPI.cpp:1450
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_encrypt_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
EXPORT static OT_MADE_EASY_OT std::string trigger_clause(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &STR_TRANS_NUM, const std::string &CLAUSE_NAME, const std::string &STR_PARAM)
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
static EXPORT int32_t Purse_Count(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
returns a count of the number of cash tokens inside this purse.
Definition: OTAPI.cpp:1843
EXPORT static OT_MADE_EASY_OT std::string get_market_recent_trades(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &MARKET_ID)
OT_OTAPI_OT std::string SendTransaction(OTAPI_Func &theFunction, const std::string &IN_FUNCTION)
EXPORT static OT_MADE_EASY_OT std::string create_nym(int32_t nKeybits, const std::string &strNymIDSource, const std::string &strAltLocation)
EXPORT OT_UTILITY_OT int32_t getRequestNumber(const std::string &serverID, const std::string &nymID)
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
EXPORT static OT_MADE_EASY_OT bool exchangeCashPurse(const std::string &serverID, const std::string &assetID, const std::string &nymID, std::string &oldPurse, const std::vector< std::string > &selectedTokens)
#define OT_MADE_EASY_OT
EXPORT static OT_MADE_EASY_OT std::string create_asset_acct(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_TYPE_ID)
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_signing_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
EXPORT static OT_MADE_EASY_OT std::string exchange_basket_currency(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_TYPE, const std::string &THE_BASKET, const std::string &ACCT_ID, bool IN_OR_OUT)
EXPORT OT_UTILITY_OT bool getTransactionNumbers(const std::string &serverID, const std::string &nymID)
static EXPORT bool Wallet_ImportPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID, const std::string &THE_PURSE)
Should handle duplicates. Should load, merge, and save.
Definition: OTAPI.cpp:1907
EXPORT static OT_MADE_EASY_OT std::string load_public_signing_key(const std::string &NYM_ID)
EXPORT static OT_MADE_EASY_OT bool processCashPurse(std::string &newPurse, std::string &newPurseForSender, const std::string &serverID, const std::string &assetID, const std::string &nymID, std::string &oldPurse, const std::vector< std::string > &selectedTokens, const std::string &recipientNymID, bool bPWProtectOldPurse, bool bPWProtectNewPurse)
EXPORT static OT_MADE_EASY_OT std::string check_user(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT std::string deposit_purse(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &STR_PURSE)
static EXPORT std::string Purse_Pop(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_OR_SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1879
int64_t lData
static EXPORT bool Mint_IsStillGood(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1470
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string query_asset_types(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ENCODED_MAP)
EXPORT static OT_MADE_EASY_OT bool importCashPurse(const std::string &serverID, const std::string &nymID, const std::string &assetID, std::string &userInput, bool isPurse)
OTLOG_IMPORT OTLogStream otWarn
static EXPORT std::string LoadUserPubkey_Encryption(const std::string &USER_ID)
Definition: OTAPI.cpp:1455
EXPORT static OT_MADE_EASY_OT std::string pay_dividend(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &SOURCE_ACCT_ID, const std::string &SHARES_ASSET_ID, const std::string &STR_MEMO, int64_t AMOUNT_PER_SHARE)
EXPORT static OT_MADE_EASY_OT std::string send_user_cash(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT, const std::string &SENDERS_COPY)
EXPORT static OT_MADE_EASY_OT std::string load_public_encryption_key(const std::string &NYM_ID)
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_mint(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ID)
static EXPORT std::string LoadMint(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1476
EXPORT static OT_MADE_EASY_OT std::string get_market_offers(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &MARKET_ID, int64_t MAX_DEPTH)
static EXPORT int32_t GetNym_TransactionNumCount(const std::string &SERVER_ID, const std::string &NYM_ID)
Definition: OTAPI.cpp:888
static EXPORT std::string Token_GetID(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1935
EXPORT static OT_MADE_EASY_OT std::string deposit_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_PAYMENT_PLAN)
EXPORT static OT_MADE_EASY_OT std::string cancel_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_PAYMENT_PLAN)
static EXPORT std::string Purse_Peek(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1871
static EXPORT std::string LoadUserPubkey_Signing(const std::string &USER_ID)
Definition: OTAPI.cpp:1460
EXPORT OT_UTILITY_OT bool getIntermediaryFiles(const std::string &serverID, const std::string &nymID, const std::string &accountID)
EXPORT static OT_MADE_EASY_OT std::string get_nym_market_offers(const std::string &SERVER_ID, const std::string &NYM_ID)
EXPORT static OT_MADE_EASY_OT std::string deposit_cheque(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &STR_CHEQUE)
EXPORT static OT_MADE_EASY_OT std::string adjust_usage_credits(const std::string &SERVER_ID, const std::string &USER_NYM_ID, const std::string &TARGET_NYM_ID, const std::string &ADJUSTMENT)
EXPORT static OT_MADE_EASY_OT std::string send_transfer(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_FROM, const std::string &ACCT_TO, int64_t AMOUNT, const std::string &NOTE)
EXPORT static OT_MADE_EASY_OT std::string activate_smart_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &AGENT_NAME, const std::string &THE_SMART_CONTRACT)
OT_OTAPI_OT std::string SendRequest(OTAPI_Func &theFunction, const std::string &IN_FUNCTION) const
EXPORT static OT_MADE_EASY_OT std::string process_inbox(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, const std::string &RESPONSE_LEDGER)
EXPORT static OT_MADE_EASY_OT std::string get_market_list(const std::string &SERVER_ID, const std::string &NYM_ID)
std::string strData5
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
EXPORT static OT_MADE_EASY_OT std::string kill_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &STR_TRANS_NUM)
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
static EXPORT std::string CreatePurse_Passphrase(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &SIGNER_ID)
Definition: OTAPI.cpp:1864
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
static EXPORT bool Purse_HasPassword(const std::string &SERVER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1850