Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTMessage.cpp
Go to the documentation of this file.
1 /************************************************************
2  *
3  * OTMessage.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 "stdafx.hpp"
134 
135 #include "OTMessage.hpp"
136 
137 #include "OTLedger.hpp"
138 #include "OTLog.hpp"
139 #include "OTPseudonym.hpp"
140 #include "OTStorage.hpp"
141 
142 #include <fstream>
143 
144 #include <irrxml/irrXML.hpp>
145 
146 // PROTOCOL DOCUMENT
147 
148 // --- This is the file that implements the entire message protocol.
149 // (Transactions are in a different file.)
150 
151 // true == success (even if nothing harvested.)
152 // false == error.
153 //
154 
155 namespace opentxs
156 {
157 
159  OTPseudonym& theNym,
160  bool bHarvestingForRetry, // false until positively asserted.
161  bool bReplyWasSuccess, // false until positively asserted.
162  bool bReplyWasFailure, // false until positively asserted.
163  bool bTransactionWasSuccess, // false until positively asserted.
164  bool bTransactionWasFailure) const // false until positively asserted.
165 {
166 
167  const OTIdentifier MSG_NYM_ID(m_strNymID), SERVER_ID(m_strServerID),
168  ACCOUNT_ID(m_strAcctID.Exists() ? m_strAcctID
169  : m_strNymID); // This may be
170  // unnecessary, but just
171  // in case.
172 
173  const OTString strLedger(m_ascPayload);
174 
175  OTLedger theLedger(MSG_NYM_ID, ACCOUNT_ID, SERVER_ID); // We're going to
176  // load a messsage
177  // ledger from *this.
178 
179  if (!strLedger.Exists() || !theLedger.LoadLedgerFromString(strLedger)) {
180  otErr << __FUNCTION__
181  << ": ERROR: Failed trying to load message ledger:\n\n"
182  << strLedger << "\n\n";
183  return false;
184  }
185  // theLedger is loaded up!
186  else {
187  // Let's iterate through the transactions inside, and harvest whatever
188  // we can...
189  //
190  for (auto& it : theLedger.GetTransactionMap()) {
191  OTTransaction* pTransaction = it.second;
192  OT_ASSERT(nullptr != pTransaction);
193 
194  // NOTE: You would ONLY harvest the transaction numbers if your
195  // request failed.
196  // Clearly you would never bother harvesting the numbers from a
197  // SUCCESSFUL request,
198  // because doing so would only put you out of sync. (This is the
199  // same reason why
200  // we DO harvest numbers from UNSUCCESSFUL requests--in order to
201  // stay in sync.)
202  //
203  // That having been said, an important distinction must be made
204  // between failed
205  // requests where "the message succeeded but the TRANSACTION
206  // failed", versus requests
207  // where the MESSAGE ITSELF failed (meaning the transaction itself
208  // never got a
209  // chance to run, and thus never had a chance to fail.)
210  //
211  // In the first case, you don't want to harvest the opening
212  // transaction number
213  // (the primary transaction number for that transaction) because
214  // that number was
215  // already burned when the transaction failed. Instead, you want to
216  // harvest "all
217  // the others" (the "closing" numbers.)
218  // But in the second case, you want to harvest the opening
219  // transaction number as well,
220  // since it is still good (because the transaction never ran.)
221  //
222  // (Therefore the below logic turns on whether or not the message
223  // was a success.)
224  //
225  // UPDATE: The logic is now all inside
226  // OTTransaction::Harvest...Numbers, you just have to tell it,
227  // when you call it, the state of certain things (message success,
228  // transaction success, etc.)
229  //
230 
231  pTransaction->HarvestOpeningNumber(
232  theNym, bHarvestingForRetry, bReplyWasSuccess, bReplyWasFailure,
233  bTransactionWasSuccess, bTransactionWasFailure);
234 
235  // We grab the closing numbers no matter what (whether message
236  // succeeded or failed.)
237  // It bears mentioning one more time that you would NEVER harvest in
238  // the first place unless
239  // your original request somehow failed. So this is more about WHERE
240  // the failure occurred (at
241  // the message level or the transaction level), not WHETHER one
242  // occurred.
243  //
244  pTransaction->HarvestClosingNumbers(
245  theNym, bHarvestingForRetry, bReplyWasSuccess, bReplyWasFailure,
246  bTransactionWasSuccess, bTransactionWasFailure);
247  }
248  } // else (ledger is loaded up.)
249 
250  return true;
251 }
252 
253 // So the message can get the list of numbers from the Nym, before sending,
254 // that should be listed as acknowledged that the server reply has already been
255 // seen for those request numbers.
256 // IMPORTANT NOTE: The Server ID is used to lookup the numbers from the Nym.
257 // Therefore,
258 // make sure that OTMessage::m_strServerID is set BEFORE calling this function.
259 // (It will
260 // ASSERT if you don't...)
261 //
263 {
265 
266  const OTIdentifier theServerID(m_strServerID);
267 
268  for (auto& it : theNym.GetMapAcknowledgedNum()) {
269  std::string strServerID = it.first;
270  dequeOfTransNums* pDeque = it.second;
271  OT_ASSERT(nullptr != pDeque);
272 
273  OTString OTstrServerID = strServerID.c_str();
274  const OTIdentifier theTempID(OTstrServerID);
275 
276  if (!(pDeque->empty()) &&
277  (theServerID == theTempID)) // only for the matching serverID.
278  {
279  for (uint32_t i = 0; i < pDeque->size(); i++) {
280  const int64_t lAckRequestNumber = pDeque->at(i);
281 
282  m_AcknowledgedReplies.Add(lAckRequestNumber);
283  }
284  break; // We found it! Might as well break out.
285  }
286  } // for
287 }
288 
289 // The framework (OTContract) will call this function at the appropriate time.
290 // OTMessage is special because it actually does something here, when most
291 // contracts
292 // are read-only and thus never update their contents.
293 // Messages, obviously, are different every time, and this function will be
294 // called
295 // just prior to the signing of the message, in OTContract::SignContract.
297 {
298  bool bFoundMessage = false;
299 
300  // I release this because I'm about to repopulate it.
302 
304 
305  m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");
307  "<OTmessage\n version=\"%s\"\n dateSigned=\"%lld\">\n\n",
309 
310  if (m_strCommand.Compare("getMarketList")) {
311  bFoundMessage = true;
312  m_xmlUnsigned.Concatenate("<%s\n"
313  " requestNum=\"%s\"\n"
314  " nymID=\"%s\"\n"
315  " serverID=\"%s\""
316  ">\n\n",
319 
320  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
321  }
322 
323  if (m_strCommand.Compare("@getMarketList")) {
324  bFoundMessage = true;
325  m_xmlUnsigned.Concatenate("<%s\n"
326  " requestNum=\"%s\"\n"
327  " success=\"%s\"\n"
328  " nymID=\"%s\"\n"
329  " serverID=\"%s\"\n"
330  " depth=\"%lld\""
331  ">\n\n",
333  (m_bSuccess ? "true" : "false"),
335  m_lDepth);
336 
337  if (m_bSuccess && (m_ascPayload.GetLength() > 2) && (m_lDepth > 0))
339  "<messagePayload>\n%s</messagePayload>\n\n",
340  m_ascPayload.Get());
341  else if (!m_bSuccess && (m_ascInReferenceTo.GetLength() > 2))
342  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
344 
345  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
346 
347  // std::cerr << m_xmlUnsigned << std::endl;
348  }
349 
350  if (m_strCommand.Compare("getMarketOffers")) {
351  bFoundMessage = true;
352  m_xmlUnsigned.Concatenate("<%s\n"
353  " requestNum=\"%s\"\n"
354  " nymID=\"%s\"\n"
355  " serverID=\"%s\"\n"
356  " marketID=\"%s\"\n" // stored in NymID2
357  " depth=\"%lld\""
358  ">\n\n",
361  m_strNymID2.Get(), // Storing Market ID
362  m_lDepth);
363 
364  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
365  }
366 
367  if (m_strCommand.Compare("@getMarketOffers")) {
368  bFoundMessage = true;
369  m_xmlUnsigned.Concatenate("<%s\n"
370  " requestNum=\"%s\"\n"
371  " success=\"%s\"\n"
372  " nymID=\"%s\"\n"
373  " serverID=\"%s\"\n"
374  " marketID=\"%s\"\n" // stored in NymID2
375  " depth=\"%lld\""
376  ">\n\n",
378  (m_bSuccess ? "true" : "false"),
380  m_strNymID2.Get(), // Storing Market ID
381  m_lDepth);
382 
383  if (m_bSuccess && (m_ascPayload.GetLength() > 2) && (m_lDepth > 0))
385  "<messagePayload>\n%s</messagePayload>\n\n",
386  m_ascPayload.Get());
387  else if (!m_bSuccess && (m_ascInReferenceTo.GetLength() > 2))
388  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
390 
391  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
392  }
393 
394  if (m_strCommand.Compare("getMarketRecentTrades")) {
395  bFoundMessage = true;
396  m_xmlUnsigned.Concatenate("<%s\n"
397  " requestNum=\"%s\"\n"
398  " nymID=\"%s\"\n"
399  " serverID=\"%s\"\n"
400  " marketID=\"%s\"" // stored in NymID2
401  ">\n\n",
404  m_strNymID2.Get() // Storing Market ID
405  );
406 
407  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
408  }
409 
410  if (m_strCommand.Compare("@getMarketRecentTrades")) {
411  bFoundMessage = true;
412  m_xmlUnsigned.Concatenate("<%s\n"
413  " requestNum=\"%s\"\n"
414  " success=\"%s\"\n"
415  " nymID=\"%s\"\n"
416  " serverID=\"%s\"\n"
417  " marketID=\"%s\"\n" // stored in NymID2
418  " depth=\"%lld\""
419  ">\n\n",
421  (m_bSuccess ? "true" : "false"),
423  m_strNymID2.Get(), // Storing Market ID
424  m_lDepth);
425 
426  if (m_bSuccess && (m_ascPayload.GetLength() > 2) && (m_lDepth > 0))
428  "<messagePayload>\n%s</messagePayload>\n\n",
429  m_ascPayload.Get());
430  else if (!m_bSuccess && (m_ascInReferenceTo.GetLength() > 2))
431  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
433 
434  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
435  }
436 
437  if (m_strCommand.Compare("getNym_MarketOffers")) {
438  bFoundMessage = true;
439  m_xmlUnsigned.Concatenate("<%s\n"
440  " requestNum=\"%s\"\n"
441  " nymID=\"%s\"\n"
442  " serverID=\"%s\""
443  ">\n\n",
446 
447  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
448  }
449 
450  if (m_strCommand.Compare("@getNym_MarketOffers")) {
451  bFoundMessage = true;
452  m_xmlUnsigned.Concatenate("<%s\n"
453  " requestNum=\"%s\"\n"
454  " success=\"%s\"\n"
455  " nymID=\"%s\"\n"
456  " serverID=\"%s\"\n"
457  " depth=\"%lld\""
458  ">\n\n",
460  (m_bSuccess ? "true" : "false"),
462  m_lDepth);
463 
464  if (m_bSuccess && (m_ascPayload.GetLength() > 2) && (m_lDepth > 0))
466  "<messagePayload>\n%s</messagePayload>\n\n",
467  m_ascPayload.Get());
468  else if (!m_bSuccess && (m_ascInReferenceTo.GetLength() > 2))
469  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
471 
472  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
473  }
474 
475  if (m_strCommand.Compare("checkServerID")) {
476  bFoundMessage = true;
477  m_xmlUnsigned.Concatenate("<%s\n"
478  " requestNum=\"%s\"\n"
479  " nymID=\"%s\"\n"
480  " serverID=\"%s\""
481  ">\n\n",
484 
486  "<publicAuthentKey>\n%s</publicAuthentKey>\n\n",
489  "<publicEncryptionKey>\n%s</publicEncryptionKey>\n\n",
490  m_strNymID2.Get());
491 
492  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
493  }
494 
495  if (m_strCommand.Compare("@checkServerID")) {
496  bFoundMessage = true;
497  m_xmlUnsigned.Concatenate("<%s\n"
498  " requestNum=\"%s\"\n"
499  " success=\"%s\"\n"
500  " nymID=\"%s\"\n"
501  " serverID=\"%s\""
502  ">\n\n",
504  (m_bSuccess ? "true" : "false"),
506 
507  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
508  }
509 
510  if (m_strCommand.Compare("createUserAccount")) {
511  bFoundMessage = true;
512  m_xmlUnsigned.Concatenate("<%s\n"
513  " requestNum=\"%s\"\n"
514  " nymID=\"%s\"\n"
515  " serverID=\"%s\""
516  ">\n\n",
519  if (m_ascPayload.Exists())
521  "<credentialList>\n%s</credentialList>\n\n",
522  m_ascPayload.Get());
523  if (m_ascPayload2.Exists())
524  m_xmlUnsigned.Concatenate("<credentials>\n%s</credentials>\n\n",
525  m_ascPayload2.Get());
526 
527  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
528  }
529 
530  if (m_strCommand.Compare("@createUserAccount")) {
531  bFoundMessage = true;
532  m_xmlUnsigned.Concatenate("<%s\n"
533  " requestNum=\"%s\"\n"
534  " success=\"%s\"\n"
535  " nymID=\"%s\"\n"
536  " serverID=\"%s\""
537  ">\n\n",
539  (m_bSuccess ? "true" : "false"),
541 
542  if (m_bSuccess && (m_ascPayload.GetLength() > 2))
543  m_xmlUnsigned.Concatenate("<nymfile>\n%s</nymfile>\n\n",
544  m_ascPayload.Get());
545 
546  if (m_ascInReferenceTo.GetLength() > 2)
547  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
549 
550  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
551  }
552 
553  if (m_strCommand.Compare("deleteUserAccount")) {
554  bFoundMessage = true;
555  m_xmlUnsigned.Concatenate("<%s\n"
556  " requestNum=\"%s\"\n"
557  " nymID=\"%s\"\n"
558  " serverID=\"%s\""
559  ">\n\n",
562 
563  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
564  }
565 
566  if (m_strCommand.Compare("@deleteUserAccount")) {
567  bFoundMessage = true;
568  m_xmlUnsigned.Concatenate("<%s\n"
569  " requestNum=\"%s\"\n"
570  " success=\"%s\"\n"
571  " nymID=\"%s\"\n"
572  " serverID=\"%s\""
573  ">\n\n",
575  (m_bSuccess ? "true" : "false"),
577 
578  if (m_ascInReferenceTo.GetLength() > 2)
579  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
581 
582  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
583  }
584 
585  if (m_strCommand.Compare("checkUser")) {
586  bFoundMessage = true;
587  m_xmlUnsigned.Concatenate("<%s\n"
588  " nymID=\"%s\"\n"
589  " nymID2=\"%s\"\n"
590  " requestNum=\"%s\"\n"
591  " serverID=\"%s\""
592  ">\n\n",
595  m_strServerID.Get());
596 
597  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
598  }
599 
600  if (m_strCommand.Compare("@checkUser")) {
601  // This means new-style credentials are being sent, not just the public
602  // key as before.
603  const bool bCredentials =
605 
606  bFoundMessage = true;
607  m_xmlUnsigned.Concatenate("<%s\n"
608  " requestNum=\"%s\"\n"
609  " success=\"%s\"\n"
610  " nymID=\"%s\"\n"
611  " nymID2=\"%s\"\n"
612  " hasCredentials=\"%s\"\n"
613  " serverID=\"%s\""
614  ">\n\n",
616  (m_bSuccess ? "true" : "false"),
618  (bCredentials ? "true" : "false"),
619  m_strServerID.Get());
620 
621  if (m_bSuccess) {
622  // Old style. (Deprecated.)
625  "<nymPublicKey>\n%s</nymPublicKey>\n\n",
627 
628  // New style:
629  if (bCredentials) {
631  "<credentialList>\n%s</credentialList>\n\n",
632  m_ascPayload.Get());
633  m_xmlUnsigned.Concatenate("<credentials>\n%s</credentials>\n\n",
634  m_ascPayload2.Get());
635  }
636  }
637  else
638  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
640 
641  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
642  }
643 
644  if (m_strCommand.Compare("usageCredits")) {
645  bFoundMessage = true;
646  m_xmlUnsigned.Concatenate("<%s\n"
647  " nymID=\"%s\"\n"
648  " nymID2=\"%s\"\n"
649  " requestNum=\"%s\"\n"
650  " adjustment=\"%lld\"\n"
651  " serverID=\"%s\""
652  ">\n\n",
656 
657  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
658  }
659 
660  if (m_strCommand.Compare("@usageCredits")) {
661  bFoundMessage = true;
662  m_xmlUnsigned.Concatenate("<%s\n"
663  " requestNum=\"%s\"\n"
664  " success=\"%s\"\n"
665  " nymID=\"%s\"\n"
666  " nymID2=\"%s\"\n"
667  " totalCredits=\"%lld\"\n"
668  " serverID=\"%s\""
669  ">\n\n",
671  (m_bSuccess ? "true" : "false"),
673  m_strServerID.Get());
674 
675  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
676  }
677 
678  // This one isn't part of the message protocol, but is used for outmail
679  // storage.
680  // (Because outmail isn't encrypted like the inmail is, since the Nymfile
681  // itself
682  // will soon be encrypted, and there's no need to be redundant also as well
683  // in addition on top of that.
684  //
685  if (m_strCommand.Compare("outmailMessage") ||
686  m_strCommand.Compare("outpaymentsMessage")) {
687  bFoundMessage = true;
688  m_xmlUnsigned.Concatenate("<%s\n"
689  " nymID=\"%s\"\n"
690  " nymID2=\"%s\"\n"
691  " requestNum=\"%s\"\n"
692  " serverID=\"%s\""
693  ">\n\n",
696  m_strServerID.Get());
697 
698  if (m_ascPayload.GetLength() > 2)
700  "<messagePayload>\n%s</messagePayload>\n\n",
701  m_ascPayload.Get());
702 
703  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
704  }
705 
706  if (m_strCommand.Compare("sendUserMessage")) {
707  bFoundMessage = true;
708  m_xmlUnsigned.Concatenate("<%s\n"
709  " nymID=\"%s\"\n"
710  " nymID2=\"%s\"\n"
711  " requestNum=\"%s\"\n"
712  " serverID=\"%s\""
713  ">\n\n",
716  m_strServerID.Get());
717 
718  if (m_ascPayload.GetLength() > 2)
720  "<messagePayload>\n%s</messagePayload>\n\n",
721  m_ascPayload.Get());
722 
723  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
724  }
725 
726  if (m_strCommand.Compare("@sendUserMessage")) {
727  bFoundMessage = true;
728  m_xmlUnsigned.Concatenate("<%s\n"
729  " requestNum=\"%s\"\n"
730  " success=\"%s\"\n"
731  " nymID=\"%s\"\n"
732  " nymID2=\"%s\"\n"
733  " serverID=\"%s\""
734  ">\n\n",
736  (m_bSuccess ? "true" : "false"),
738  m_strServerID.Get());
739 
740  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
741  }
742 
743  if (m_strCommand.Compare(
744  "sendUserInstrument") || // sendUserInstrument is sent from one user
745  // to the server, which then attaches that
746  // message as a payment, onto a transaction
747  // on the Nymbox of the recipient.
748  m_strCommand.Compare("payDividend")) // payDividend is not a normal user
749  // message. Rather, the sender uses
750  // notarizeTransactions to do a
751  // payDividend transaction. On the
752  // server side, this creates a new
753  // message of type "payDividend"
754  // for each recipient, in order to
755  // attach a voucher to it (for each
756  // recipient) and then that
757  // (artificially created
758  // payDividend msg) is added to the
759  // Nymbox of each recipient.
760  {
761  bFoundMessage = true;
762  m_xmlUnsigned.Concatenate("<%s\n"
763  " nymID=\"%s\"\n"
764  " nymID2=\"%s\"\n"
765  " requestNum=\"%s\"\n"
766  " serverID=\"%s\""
767  ">\n\n",
770  m_strServerID.Get());
771 
772  if (m_ascPayload.GetLength() > 2)
774  "<messagePayload>\n%s</messagePayload>\n\n",
775  m_ascPayload.Get());
776 
777  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
778  }
779 
780  if (m_strCommand.Compare("@sendUserInstrument")) {
781  bFoundMessage = true;
782  m_xmlUnsigned.Concatenate("<%s\n"
783  " requestNum=\"%s\"\n"
784  " success=\"%s\"\n"
785  " nymID=\"%s\"\n"
786  " nymID2=\"%s\"\n"
787  " serverID=\"%s\""
788  ">\n\n",
790  (m_bSuccess ? "true" : "false"),
792  m_strServerID.Get());
793 
794  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
795  }
796 
797  if (m_strCommand.Compare("getRequest")) {
798  bFoundMessage = true;
799  m_xmlUnsigned.Concatenate("<%s\n"
800  " nymID=\"%s\"\n"
801  " serverID=\"%s\"\n"
802  " requestNum=\"%s\""
803  ">\n\n",
806 
807  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
808  }
809 
810  // This is the ONE command where you see a request number coming back from
811  // the server.
812  // In all the other commands, it should be SENT to the server, not received
813  // from the server.
814  if (m_strCommand.Compare("@getRequest")) {
815  bFoundMessage = true;
817  "<%s\n" // command
818  " success=\"%s\"\n" // m_bSuccess
819  " nymID=\"%s\"\n"
820  " nymboxHash=\"%s\"\n"
821  " serverID=\"%s\"\n"
822  " newRequestNum=\"%lld\"\n"
823  " requestNum=\"%s\""
824  ">\n\n",
825  m_strCommand.Get(), (m_bSuccess ? "true" : "false"),
828 
829  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
830  }
831 
832  if (m_strCommand.Compare("issueAssetType")) {
833  bFoundMessage = true;
834  m_xmlUnsigned.Concatenate("<%s\n" // Command
835  " nymID=\"%s\"\n"
836  " serverID=\"%s\"\n"
837  " requestNum=\"%s\"\n"
838  " assetType=\"%s\""
839  ">\n\n",
842  m_strAssetID.Get());
843 
844  if (m_ascPayload.GetLength())
845  m_xmlUnsigned.Concatenate("<assetContract>\n%s</assetContract>\n\n",
846  m_ascPayload.Get());
847 
848  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
849  }
850 
851  if (m_strCommand.Compare("@issueAssetType")) {
852  bFoundMessage = true;
854  "<%s\n" // Command
855  " requestNum=\"%s\"\n"
856  " success=\"%s\"\n"
857  " accountID=\"%s\"\n" // the new issuer account ID
858  " nymID=\"%s\"\n"
859  " assetType=\"%s\"\n"
860  " serverID=\"%s\""
861  ">\n\n",
863  (m_bSuccess ? "true" : "false"), m_strAcctID.Get(),
865 
867  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
869 
871  m_xmlUnsigned.Concatenate("<issuerAccount>\n%s</issuerAccount>\n\n",
872  m_ascPayload.Get());
873 
874  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
875  }
876 
877  if (m_strCommand.Compare("queryAssetTypes")) {
878  bFoundMessage = true;
879  m_xmlUnsigned.Concatenate("<%s\n" // Command
880  " nymID=\"%s\"\n"
881  " serverID=\"%s\"\n"
882  " requestNum=\"%s\""
883  ">\n\n",
886 
887  if (m_ascPayload.GetLength())
888  m_xmlUnsigned.Concatenate("<stringMap>\n%s</stringMap>\n\n",
889  m_ascPayload.Get());
890 
891  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
892  }
893 
894  if (m_strCommand.Compare("@queryAssetTypes")) {
895  bFoundMessage = true;
896  m_xmlUnsigned.Concatenate("<%s\n" // Command
897  " requestNum=\"%s\"\n"
898  " success=\"%s\"\n"
899  " nymID=\"%s\"\n"
900  " serverID=\"%s\""
901  ">\n\n",
903  (m_bSuccess ? "true" : "false"),
905 
907  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
909 
911  m_xmlUnsigned.Concatenate("<stringMap>\n%s</stringMap>\n\n",
912  m_ascPayload.Get());
913 
914  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
915  }
916 
917  if (m_strCommand.Compare("issueBasket")) {
918  bFoundMessage = true;
919  m_xmlUnsigned.Concatenate("<%s\n" // Command
920  " nymID=\"%s\"\n"
921  " serverID=\"%s\"\n"
922  " requestNum=\"%s\""
923  ">\n\n",
926 
927  if (m_ascPayload.GetLength())
929  "<currencyBasket>\n%s</currencyBasket>\n\n",
930  m_ascPayload.Get());
931 
932  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
933  }
934 
935  if (m_strCommand.Compare("@issueBasket")) {
936  bFoundMessage = true;
938  "<%s\n" // Command
939  " requestNum=\"%s\"\n"
940  " success=\"%s\"\n"
941  " accountID=\"%s\"\n" // the new basket issuer account ID
942  " nymID=\"%s\"\n"
943  " assetType=\"%s\"\n" // the new Asset Type
944  " serverID=\"%s\""
945  ">\n\n",
947  (m_bSuccess ? "true" : "false"), m_strAcctID.Get(),
949 
951  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
953 
954  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
955  }
956 
957  if (m_strCommand.Compare("createAccount")) {
958  bFoundMessage = true;
959  m_xmlUnsigned.Concatenate("<%s\n" // Command
960  " nymID=\"%s\"\n"
961  " serverID=\"%s\"\n"
962  " requestNum=\"%s\"\n"
963  " assetType=\"%s\""
964  ">\n\n",
967  m_strAssetID.Get());
968 
969  // otErr << "DEBUG: Asset Type length: %d, Value:\n%s\n",
970  // m_strAssetID.GetLength(), m_strAssetID.Get());
971 
972  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
973  }
974 
975  if (m_strCommand.Compare("@createAccount")) {
976  bFoundMessage = true;
977  m_xmlUnsigned.Concatenate("<%s\n" // Command
978  " requestNum=\"%s\"\n"
979  " success=\"%s\"\n"
980  " accountID=\"%s\"\n"
981  " nymID=\"%s\"\n"
982  " serverID=\"%s\""
983  ">\n\n",
985  (m_bSuccess ? "true" : "false"),
987  m_strServerID.Get());
988 
990  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
992 
993  if (m_bSuccess && m_ascPayload.Exists())
994  m_xmlUnsigned.Concatenate("<newAccount>\n%s</newAccount>\n\n",
995  m_ascPayload.Get());
996 
997  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
998  }
999 
1000  if (m_strCommand.Compare("getBoxReceipt")) {
1001  bFoundMessage = true;
1003  "<%s\n" // Command
1004  " nymID=\"%s\"\n"
1005  " serverID=\"%s\"\n"
1006  " requestNum=\"%s\"\n"
1007  " transactionNum=\"%lld\"\n"
1008  " boxType=\"%s\"\n"
1009  " accountID=\"%s\"" // If retrieving box receipt for Nymbox, NymID
1010  // will appear in this variable.
1011  ">\n\n",
1014  (m_lDepth == 0)
1015  ? "nymbox"
1016  : ((m_lDepth == 1) ? "inbox" : "outbox"), // outbox is 2.
1017  m_strAcctID.Get());
1018 
1019  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1020  }
1021 
1022  if (m_strCommand.Compare("@getBoxReceipt")) {
1023  bFoundMessage = true;
1025  "<%s\n" // Command
1026  " requestNum=\"%s\"\n"
1027  " success=\"%s\"\n"
1028  " accountID=\"%s\"\n"
1029  " transactionNum=\"%lld\"\n"
1030  " boxType=\"%s\"\n"
1031  " nymID=\"%s\"\n"
1032  " serverID=\"%s\""
1033  ">\n\n",
1035  (m_bSuccess ? "true" : "false"), m_strAcctID.Get(),
1037  (m_lDepth == 0)
1038  ? "nymbox"
1039  : ((m_lDepth == 1) ? "inbox" : "outbox"), // outbox is 2.
1040  m_strNymID.Get(),
1041  m_strServerID.Get());
1042 
1044  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1046 
1048  m_xmlUnsigned.Concatenate("<boxReceipt>\n%s</boxReceipt>\n\n",
1049  m_ascPayload.Get());
1050 
1051  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1052  }
1053 
1054  if (m_strCommand.Compare("deleteAssetAccount")) {
1055  bFoundMessage = true;
1056  m_xmlUnsigned.Concatenate("<%s\n" // Command
1057  " nymID=\"%s\"\n"
1058  " serverID=\"%s\"\n"
1059  " requestNum=\"%s\"\n"
1060  " accountID=\"%s\""
1061  ">\n\n",
1064  m_strAcctID.Get());
1065 
1066  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1067  }
1068 
1069  if (m_strCommand.Compare("@deleteAssetAccount")) {
1070  bFoundMessage = true;
1071  m_xmlUnsigned.Concatenate("<%s\n" // Command
1072  " requestNum=\"%s\"\n"
1073  " success=\"%s\"\n"
1074  " accountID=\"%s\"\n"
1075  " nymID=\"%s\"\n"
1076  " serverID=\"%s\""
1077  ">\n\n",
1079  (m_bSuccess ? "true" : "false"),
1081  m_strServerID.Get());
1082 
1084  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1086 
1087  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1088  }
1089 
1090  // the Payload contains an ascii-armored OTLedger object.
1091  if (m_strCommand.Compare("notarizeTransactions")) {
1092  bFoundMessage = true;
1093  m_xmlUnsigned.Concatenate("<%s\n" // Command
1094  " nymID=\"%s\"\n"
1095  " nymboxHash=\"%s\"\n"
1096  " serverID=\"%s\"\n"
1097  " accountID=\"%s\"\n"
1098  " requestNum=\"%s\""
1099  " >\n\n",
1103 
1104  // I would check if this was empty, but it should never be empty...
1105  // famous last words.
1106  if (m_ascPayload.GetLength())
1107  m_xmlUnsigned.Concatenate("<accountLedger>\n%s</accountLedger>\n\n",
1108  m_ascPayload.Get());
1109 
1110  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1111  }
1112 
1113  // the Payload contains an ascii-armored OTLedger object.
1114  if (m_strCommand.Compare("@notarizeTransactions")) {
1115  bFoundMessage = true;
1116  m_xmlUnsigned.Concatenate("<%s\n" // Command
1117  " requestNum=\"%s\"\n"
1118  " success=\"%s\"\n"
1119  " nymID=\"%s\"\n"
1120  " serverID=\"%s\"\n"
1121  " accountID=\"%s\""
1122  " >\n\n",
1124  (m_bSuccess ? "true" : "false"),
1126  m_strAcctID.Get());
1127 
1129  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1131 
1132  // I would check if this was empty, but it should never be empty...
1133  // famous last words.
1134  if (m_ascPayload.GetLength())
1136  "<responseLedger>\n%s</responseLedger>\n\n",
1137  m_ascPayload.Get());
1138 
1139  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1140  }
1141 
1142  if (m_strCommand.Compare("getTransactionNum")) {
1143  bFoundMessage = true;
1144  m_xmlUnsigned.Concatenate("<%s\n" // Command
1145  " nymID=\"%s\"\n"
1146  " nymboxHash=\"%s\"\n"
1147  " serverID=\"%s\"\n"
1148  " requestNum=\"%s\""
1149  " >\n\n",
1152  m_strRequestNum.Get());
1153 
1154  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1155  }
1156 
1157  if (m_strCommand.Compare("@getTransactionNum")) {
1158  bFoundMessage = true;
1159  m_xmlUnsigned.Concatenate("<%s\n" // Command
1160  " requestNum=\"%s\"\n"
1161  " success=\"%s\"\n"
1162  " nymID=\"%s\"\n"
1163  " nymboxHash=\"%s\"\n"
1164  " serverID=\"%s\""
1165  " >\n\n",
1167  (m_bSuccess ? "true" : "false"),
1169  m_strServerID.Get());
1170 
1171  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1172  }
1173 
1174  if (m_strCommand.Compare("getNymbox")) {
1175  bFoundMessage = true;
1176  m_xmlUnsigned.Concatenate("<%s\n" // Command
1177  " nymID=\"%s\"\n"
1178  " serverID=\"%s\"\n"
1179  " requestNum=\"%s\""
1180  " >\n\n",
1183 
1184  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1185  }
1186 
1187  // the Payload contains an ascii-armored OTLedger object.
1188  if (m_strCommand.Compare("@getNymbox")) {
1189  bFoundMessage = true;
1190  m_xmlUnsigned.Concatenate("<%s\n" // Command
1191  " requestNum=\"%s\"\n"
1192  " success=\"%s\"\n"
1193  " nymID=\"%s\"\n"
1194  " nymboxHash=\"%s\"\n"
1195  " serverID=\"%s\""
1196  " >\n\n",
1198  (m_bSuccess ? "true" : "false"),
1200  m_strServerID.Get());
1201 
1203  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1205 
1206  // I would check if this was empty, but it should never be empty...
1207  // famous last words.
1209  m_xmlUnsigned.Concatenate("<nymboxLedger>\n%s</nymboxLedger>\n\n",
1210  m_ascPayload.Get());
1211 
1212  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1213  }
1214 
1215  // the Payload contains an ascii-armored OTLedger object.
1216  if (m_strCommand.Compare("getInbox")) {
1217  bFoundMessage = true;
1218  m_xmlUnsigned.Concatenate("<%s\n" // Command
1219  " nymID=\"%s\"\n"
1220  " serverID=\"%s\"\n"
1221  " accountID=\"%s\"\n"
1222  " requestNum=\"%s\""
1223  " >\n\n",
1226  m_strRequestNum.Get());
1227 
1228  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1229  }
1230 
1231  // the Payload contains an ascii-armored OTLedger object.
1232  if (m_strCommand.Compare("@getInbox")) {
1233  bFoundMessage = true;
1234  m_xmlUnsigned.Concatenate("<%s\n" // Command
1235  " requestNum=\"%s\"\n"
1236  " success=\"%s\"\n"
1237  " nymID=\"%s\"\n"
1238  " inboxHash=\"%s\"\n"
1239  " serverID=\"%s\"\n"
1240  " accountID=\"%s\""
1241  " >\n\n",
1243  (m_bSuccess ? "true" : "false"),
1246 
1248  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1250 
1251  // I would check if this was empty, but it should never be empty...
1252  // famous last words.
1254  m_xmlUnsigned.Concatenate("<inboxLedger>\n%s</inboxLedger>\n\n",
1255  m_ascPayload.Get());
1256 
1257  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1258  }
1259 
1260  // the Payload contains an ascii-armored OTLedger object.
1261  if (m_strCommand.Compare("getOutbox")) {
1262  bFoundMessage = true;
1263  m_xmlUnsigned.Concatenate("<%s\n" // Command
1264  " nymID=\"%s\"\n"
1265  " serverID=\"%s\"\n"
1266  " accountID=\"%s\"\n"
1267  " requestNum=\"%s\""
1268  " >\n\n",
1271  m_strRequestNum.Get());
1272 
1273  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1274  }
1275 
1276  // the Payload contains an ascii-armored OTLedger object.
1277  if (m_strCommand.Compare("@getOutbox")) {
1278  bFoundMessage = true;
1279  m_xmlUnsigned.Concatenate("<%s\n" // Command
1280  " requestNum=\"%s\"\n"
1281  " success=\"%s\"\n"
1282  " nymID=\"%s\"\n"
1283  " outboxHash=\"%s\"\n"
1284  " serverID=\"%s\"\n"
1285  " accountID=\"%s\""
1286  " >\n\n",
1288  (m_bSuccess ? "true" : "false"),
1291 
1293  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1295 
1296  // I would check if this was empty, but it should never be empty...
1297  // famous last words.
1299  m_xmlUnsigned.Concatenate("<outboxLedger>\n%s</outboxLedger>\n\n",
1300  m_ascPayload.Get());
1301 
1302  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1303  }
1304 
1305  if (m_strCommand.Compare("getAccount")) {
1306  bFoundMessage = true;
1307  m_xmlUnsigned.Concatenate("<%s\n" // Command
1308  " nymID=\"%s\"\n"
1309  " serverID=\"%s\"\n"
1310  " accountID=\"%s\"\n"
1311  " requestNum=\"%s\""
1312  " >\n\n",
1315  m_strRequestNum.Get());
1316 
1317  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1318  }
1319 
1320  // the Payload contains an ascii-armored OTAccount object.
1321  if (m_strCommand.Compare("@getAccount")) {
1322  bFoundMessage = true;
1323  m_xmlUnsigned.Concatenate("<%s\n" // Command
1324  " requestNum=\"%s\"\n"
1325  " success=\"%s\"\n"
1326  " nymID=\"%s\"\n"
1327  " serverID=\"%s\"\n"
1328  " accountID=\"%s\""
1329  " >\n\n",
1331  (m_bSuccess ? "true" : "false"),
1333  m_strAcctID.Get());
1334 
1336  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1338 
1339  // I would check if this was empty, but it should never be empty...
1340  // famous last words.
1342  m_xmlUnsigned.Concatenate("<assetAccount>\n%s</assetAccount>\n\n",
1343  m_ascPayload.Get());
1344 
1345  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1346  }
1347 
1348  if (m_strCommand.Compare("getAccountFiles")) {
1349  bFoundMessage = true;
1350  m_xmlUnsigned.Concatenate("<%s\n" // Command
1351  " nymID=\"%s\"\n"
1352  " serverID=\"%s\"\n"
1353  " accountID=\"%s\"\n"
1354  " requestNum=\"%s\""
1355  " >\n\n",
1358  m_strRequestNum.Get());
1359 
1360  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1361  }
1362 
1363  // the Payload contains a STRING_MAP containing the OTAccount,
1364  // plus the inbox and outbox for that acct..
1365  //
1366  if (m_strCommand.Compare("@getAccountFiles")) {
1367  bFoundMessage = true;
1368  m_xmlUnsigned.Concatenate("<%s\n" // Command
1369  " requestNum=\"%s\"\n"
1370  " success=\"%s\"\n"
1371  " inboxHash=\"%s\"\n"
1372  " outboxHash=\"%s\"\n"
1373  " nymID=\"%s\"\n"
1374  " serverID=\"%s\"\n"
1375  " accountID=\"%s\""
1376  " >\n\n",
1378  (m_bSuccess ? "true" : "false"),
1381  m_strAcctID.Get());
1382 
1384  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1386 
1387  // I would check if this was empty, but it should never be empty...
1388  // Famous last words.
1389  //
1391  m_xmlUnsigned.Concatenate("<acctFiles>\n%s</acctFiles>\n\n",
1392  m_ascPayload.Get());
1393 
1394  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1395  }
1396 
1397  if (m_strCommand.Compare("getContract")) {
1398  bFoundMessage = true;
1399  m_xmlUnsigned.Concatenate("<%s\n" // Command
1400  " nymID=\"%s\"\n"
1401  " serverID=\"%s\"\n"
1402  " assetType=\"%s\"\n"
1403  " requestNum=\"%s\""
1404  " >\n\n",
1407  m_strRequestNum.Get());
1408 
1409  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1410  }
1411 
1412  // the Payload contains an ascii-armored OTAssetContract object.
1413  if (m_strCommand.Compare("@getContract")) {
1414  bFoundMessage = true;
1415  m_xmlUnsigned.Concatenate("<%s\n" // Command
1416  " requestNum=\"%s\"\n"
1417  " success=\"%s\"\n"
1418  " nymID=\"%s\"\n"
1419  " serverID=\"%s\"\n"
1420  " assetType=\"%s\""
1421  " >\n\n",
1423  (m_bSuccess ? "true" : "false"),
1425  m_strAssetID.Get());
1426 
1428  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1430 
1431  // I would check if this was empty, but it should never be empty...
1432  // famous last words.
1434  m_xmlUnsigned.Concatenate("<assetContract>\n%s</assetContract>\n\n",
1435  m_ascPayload.Get());
1436 
1437  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1438  }
1439 
1440  if (m_strCommand.Compare("getMint")) {
1441  bFoundMessage = true;
1442  m_xmlUnsigned.Concatenate("<%s\n" // Command
1443  " nymID=\"%s\"\n"
1444  " serverID=\"%s\"\n"
1445  " assetType=\"%s\"\n"
1446  " requestNum=\"%s\""
1447  " >\n\n",
1450  m_strRequestNum.Get());
1451 
1452  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1453  }
1454 
1455  // the Payload contains an ascii-armored OTMint object.
1456  if (m_strCommand.Compare("@getMint")) {
1457  bFoundMessage = true;
1458  m_xmlUnsigned.Concatenate("<%s\n" // Command
1459  " requestNum=\"%s\"\n"
1460  " success=\"%s\"\n"
1461  " nymID=\"%s\"\n"
1462  " serverID=\"%s\"\n"
1463  " assetType=\"%s\""
1464  " >\n\n",
1466  (m_bSuccess ? "true" : "false"),
1468  m_strAssetID.Get());
1469 
1471  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1473 
1474  // I would check if this was empty, but it should never be empty...
1475  // famous last words.
1477  m_xmlUnsigned.Concatenate("<mint>\n%s</mint>\n\n",
1478  m_ascPayload.Get());
1479 
1480  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1481  }
1482 
1483  // the Payload contains an ascii-armored OTLedger object.
1484  if (m_strCommand.Compare("processInbox")) {
1485  bFoundMessage = true;
1486  m_xmlUnsigned.Concatenate("<%s\n" // Command
1487  " nymID=\"%s\"\n"
1488  " nymboxHash=\"%s\"\n"
1489  " serverID=\"%s\"\n"
1490  " accountID=\"%s\"\n"
1491  " requestNum=\"%s\""
1492  " >\n\n",
1496 
1497  // I would check if this was empty, but it should never be empty...
1498  // famous last words.
1499  if (m_ascPayload.GetLength())
1500  m_xmlUnsigned.Concatenate("<processLedger>\n%s</processLedger>\n\n",
1501  m_ascPayload.Get());
1502 
1503  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1504  }
1505 
1506  // the Payload contains an ascii-armored OTLedger object.
1507  if (m_strCommand.Compare("@processInbox")) {
1508  bFoundMessage = true;
1509  m_xmlUnsigned.Concatenate("<%s\n" // Command
1510  " requestNum=\"%s\"\n"
1511  " success=\"%s\"\n"
1512  " nymID=\"%s\"\n"
1513  " serverID=\"%s\"\n"
1514  " accountID=\"%s\""
1515  " >\n\n",
1517  (m_bSuccess ? "true" : "false"),
1519  m_strAcctID.Get());
1520 
1522  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1524 
1525  // I would check if this was empty, but it should never be empty...
1526  // famous last words.
1527  if (m_ascPayload.GetLength())
1529  "<responseLedger>\n%s</responseLedger>\n\n",
1530  m_ascPayload.Get());
1531 
1532  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1533  }
1534 
1535  // the Payload contains an ascii-armored OTLedger object.
1536  if (m_strCommand.Compare("processNymbox")) {
1537  bFoundMessage = true;
1538  m_xmlUnsigned.Concatenate("<%s\n" // Command
1539  " nymID=\"%s\"\n"
1540  " nymboxHash=\"%s\"\n"
1541  " serverID=\"%s\"\n"
1542  " requestNum=\"%s\""
1543  " >\n\n",
1546  m_strRequestNum.Get());
1547 
1548  // I would check if this was empty, but it should never be empty...
1549  // famous last words.
1550  if (m_ascPayload.GetLength())
1551  m_xmlUnsigned.Concatenate("<processLedger>\n%s</processLedger>\n\n",
1552  m_ascPayload.Get());
1553 
1554  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1555  }
1556 
1557  // the Payload contains an ascii-armored OTLedger object.
1558  if (m_strCommand.Compare("@processNymbox")) {
1559  bFoundMessage = true;
1560  m_xmlUnsigned.Concatenate("<%s\n" // Command
1561  " requestNum=\"%s\"\n"
1562  " success=\"%s\"\n"
1563  " nymID=\"%s\"\n"
1564  " serverID=\"%s\""
1565  " >\n\n",
1567  (m_bSuccess ? "true" : "false"),
1569 
1571  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1573 
1574  // I would check if this was empty, but it should never be empty...
1575  // famous last words.
1576  if (m_ascPayload.GetLength())
1578  "<responseLedger>\n%s</responseLedger>\n\n",
1579  m_ascPayload.Get());
1580 
1581  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1582  }
1583 
1584  if (m_strCommand.Compare("triggerClause")) {
1585  bFoundMessage = true;
1587  "<%s\n" // Command
1588  " nymID=\"%s\"\n"
1589  " nymboxHash=\"%s\"\n"
1590  " serverID=\"%s\"\n"
1591  " smartContractID=\"%lld\"\n" // <===
1592  " clauseName=\"%s\"\n" // <===
1593  " hasParam=\"%s\"\n" // <===
1594  " requestNum=\"%s\""
1595  " >\n\n",
1598  m_strNymID2.Get(), // clause name is stored here for this message.
1599  (m_ascPayload.Exists()) ? "true" : "false", m_strRequestNum.Get());
1600 
1601  if (m_ascPayload.Exists())
1602  m_xmlUnsigned.Concatenate("<parameter>\n%s</parameter>\n\n",
1603  m_ascPayload.Get());
1604 
1605  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1606  }
1607 
1608  // the Payload contains an ascii-armored OTMint object.
1609  if (m_strCommand.Compare("@triggerClause")) {
1610  bFoundMessage = true;
1611  m_xmlUnsigned.Concatenate("<%s\n" // Command
1612  " requestNum=\"%s\"\n"
1613  " success=\"%s\"\n"
1614  " nymID=\"%s\"\n"
1615  " serverID=\"%s\""
1616  " >\n\n",
1618  (m_bSuccess ? "true" : "false"),
1620 
1622  m_xmlUnsigned.Concatenate("<inReferenceTo>\n%s</inReferenceTo>\n\n",
1624 
1625  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1626  }
1627 
1628  if (!bFoundMessage) {
1629  m_xmlUnsigned.Concatenate("<%s\n" // Command
1630  " requestNum=\"%s\"\n"
1631  " success=\"false\"\n"
1632  " acctID=\"%s\"\n"
1633  " nymID=\"%s\"\n"
1634  " serverID=\"%s\""
1635  " ><!-- THIS IS AN INVALID MESSAGE -->\n\n",
1638  m_strServerID.Get());
1639 
1640  m_xmlUnsigned.Concatenate("</%s>\n\n", m_strCommand.Get());
1641  }
1642 
1643  // ACKNOWLEDGED REQUEST NUMBERS
1644  //
1645  // (For reducing the number of box receipts for replyNotices that must be
1646  // downloaded.)
1647  //
1648  // Client keeps a list of server replies he's already seen.
1649  // Server keeps a list of numbers the client has provided on HIS list
1650  // (server has removed those from Nymbox).
1651  //
1652  // (Each sends his respective list in every message.)
1653  //
1654  // Client removes any number he sees on the server's list.
1655  // Server removes any number he sees the client has also removed.
1656  //
1657 
1658  if (m_AcknowledgedReplies.Count() > 0) {
1659  OTString strAck;
1660  if (m_AcknowledgedReplies.Output(strAck) && strAck.Exists()) {
1661  const OTASCIIArmor ascTemp(strAck);
1662 
1663  if (ascTemp.Exists())
1664  m_xmlUnsigned.Concatenate("<ackReplies>\n%s</ackReplies>\n\n",
1665  ascTemp.Get());
1666  }
1667  }
1668 
1669  m_xmlUnsigned.Concatenate("</OTmessage>\n");
1670 }
1671 
1672 // Todo: consider leaving the request # inside all the server REPLIES, so they
1673 // are easier to match up to the requests. (Duh.)
1674 
1675 // return -1 if error, 0 if nothing, and 1 if the node was processed.
1677 {
1678  int32_t nReturnVal = 0;
1679 
1680  // Here we call the parent class first.
1681  // If the node is found there, or there is some error,
1682  // then we just return either way. But if it comes back
1683  // as '0', then nothing happened, and we'll continue executing.
1684  //
1685  // -- Note you can choose not to call the parent if
1686  // you don't want to use any of those xml tags.
1687  // As I do below, in the case of OTAccount.
1688  //
1689  // if (nReturnVal = OTContract::ProcessXMLNode(xml))
1690  // return nReturnVal;
1691 
1692  const OTString strNodeName(xml->getNodeName());
1693 
1694  OTString strSuccess; // Many blocks below use this string, and when they
1695  // declared it individually,
1696  // our stack frame got too big. So I'm moving it here, so they can all use
1697  // it, instead of declaring
1698  // so many different copies of it (nearly one for each block.)
1699  // Same with these:
1700 
1701  const char* pElementExpected;
1702 
1703  OTString strDepth;
1704  OTString strTransactionNum;
1705 
1706  if (strNodeName.Compare("ackReplies")) {
1707  if (!OTContract::LoadEncodedTextField(xml, strDepth)) {
1708  otErr << "Error in OTMessage::ProcessXMLNode: ackReplies field "
1709  "without value.\n";
1710  return (-1); // error condition
1711  }
1712 
1714 
1715  if (strDepth.Exists()) m_AcknowledgedReplies.Add(strDepth);
1716 
1717  nReturnVal = 1;
1718  }
1719  else if (strNodeName.Compare("acknowledgedReplies")) {
1720  otErr << "OTMessage::ProcessXMLNode: SKIPPING DEPRECATED FIELD: "
1721  "acknowledgedReplies\n";
1722 
1723  while (xml->getNodeType() != irr::io::EXN_ELEMENT_END) {
1724  xml->read();
1725  }
1726 
1727  nReturnVal = 1;
1728  }
1729  else if (strNodeName.Compare("OTmessage")) {
1730  m_strVersion = xml->getAttributeValue("version");
1731 
1732  OTString strDateSigned = xml->getAttributeValue("dateSigned");
1733 
1734  if (strDateSigned.Exists()) m_lTime = atol(strDateSigned.Get());
1735 
1736  otInfo << "\n===> Loading XML for Message into memory structures...\n";
1737 
1738  nReturnVal = 1;
1739  }
1740  else if (strNodeName.Compare("getMarketList")) {
1741  m_strCommand = xml->getNodeName(); // Command
1742  m_strNymID = xml->getAttributeValue("nymID");
1743  m_strServerID = xml->getAttributeValue("serverID");
1744  m_strRequestNum = xml->getAttributeValue("requestNum");
1745 
1746  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
1747  << "\nServerID: " << m_strServerID
1748  << "\nRequest #: " << m_strRequestNum << "\n";
1749 
1750  nReturnVal = 1;
1751  }
1752  else if (strNodeName.Compare("@getMarketList")) {
1753  // std::cerr << m_xmlUnsigned << std::endl;
1754 
1755  strSuccess = xml->getAttributeValue("success");
1756  if (strSuccess.Compare("true"))
1757  m_bSuccess = true;
1758  else
1759  m_bSuccess = false;
1760 
1761  m_strCommand = xml->getNodeName(); // Command
1762  m_strRequestNum = xml->getAttributeValue("requestNum");
1763  m_strNymID = xml->getAttributeValue("nymID");
1764  m_strServerID = xml->getAttributeValue("serverID");
1765 
1766  strDepth = xml->getAttributeValue("depth");
1767 
1768  if (strDepth.GetLength() > 0) m_lDepth = atol(strDepth.Get());
1769 
1770  const char* pElementExpected = nullptr;
1771  if (m_bSuccess && (m_lDepth > 0))
1772  pElementExpected = "messagePayload";
1773  else if (!m_bSuccess)
1774  pElementExpected = "inReferenceTo";
1775 
1776  if (nullptr != pElementExpected) {
1777  OTASCIIArmor ascTextExpected;
1778 
1779  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
1780  pElementExpected)) {
1781  otErr << "Error in OTMessage::ProcessXMLNode: "
1782  "Expected " << pElementExpected
1783  << " element with text field, for " << m_strCommand
1784  << ".\n";
1785  return (-1); // error condition
1786  }
1787 
1788  if (m_bSuccess)
1789  m_ascPayload.Set(ascTextExpected);
1790  else
1791  m_ascInReferenceTo.Set(ascTextExpected);
1792  }
1793 
1794  if (m_bSuccess)
1795  otWarn << "\nCommand: " << m_strCommand << " "
1796  << (m_bSuccess ? "SUCCESS" : "FAILED")
1797  << "\nNymID: " << m_strNymID
1798  << "\n ServerID: " << m_strServerID
1799  << "\n\n"; // m_ascPayload.Get()
1800  else
1801  otWarn << "\nCommand: " << m_strCommand << " "
1802  << (m_bSuccess ? "SUCCESS" : "FAILED")
1803  << "\nNymID: " << m_strNymID
1804  << "\n ServerID: " << m_strServerID
1805  << "\n\n"; // m_ascInReferenceTo.Get()
1806 
1807  nReturnVal = 1;
1808  }
1809  else if (strNodeName.Compare("getMarketOffers")) {
1810  m_strCommand = xml->getNodeName(); // Command
1811  m_strNymID = xml->getAttributeValue("nymID");
1812  m_strServerID = xml->getAttributeValue("serverID");
1813  m_strRequestNum = xml->getAttributeValue("requestNum");
1814  m_strNymID2 = xml->getAttributeValue("marketID");
1815 
1816  strDepth = xml->getAttributeValue("depth");
1817 
1818  if (strDepth.GetLength() > 0) m_lDepth = atol(strDepth.Get());
1819 
1820  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
1821  << "\nServerID: " << m_strServerID
1822  << "\n Market ID: " << m_strNymID2
1823  << "\n Request #: " << m_strRequestNum << "\n";
1824 
1825  nReturnVal = 1;
1826  }
1827  else if (strNodeName.Compare("@getMarketOffers")) {
1828  strSuccess = xml->getAttributeValue("success");
1829  if (strSuccess.Compare("true"))
1830  m_bSuccess = true;
1831  else
1832  m_bSuccess = false;
1833 
1834  m_strCommand = xml->getNodeName(); // Command
1835  m_strRequestNum = xml->getAttributeValue("requestNum");
1836  m_strNymID = xml->getAttributeValue("nymID");
1837  m_strServerID = xml->getAttributeValue("serverID");
1838  m_strNymID2 = xml->getAttributeValue("marketID");
1839 
1840  strDepth = xml->getAttributeValue("depth");
1841 
1842  if (strDepth.GetLength() > 0) m_lDepth = atol(strDepth.Get());
1843 
1844  const char* pElementExpected = nullptr;
1845  if (m_bSuccess && (m_lDepth > 0))
1846  pElementExpected = "messagePayload";
1847  else if (!m_bSuccess)
1848  pElementExpected = "inReferenceTo";
1849 
1850  if (nullptr != pElementExpected) {
1851  OTASCIIArmor ascTextExpected;
1852 
1853  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
1854  pElementExpected)) {
1855  otErr << "Error in OTMessage::ProcessXMLNode: "
1856  "Expected " << pElementExpected
1857  << " element with text field, for " << m_strCommand
1858  << ".\n";
1859  return (-1); // error condition
1860  }
1861 
1862  if (m_bSuccess)
1863  m_ascPayload.Set(ascTextExpected);
1864  else
1865  m_ascInReferenceTo = ascTextExpected;
1866  }
1867 
1868  if (m_bSuccess)
1869  otWarn << "\nCommand: " << m_strCommand << " "
1870  << (m_bSuccess ? "SUCCESS" : "FAILED")
1871  << "\nNymID: " << m_strNymID
1872  << "\n ServerID: " << m_strServerID
1873  << "\n MarketID: " << m_strNymID2
1874  << "\n\n"; // m_ascPayload.Get()
1875  else
1876  otWarn << "\nCommand: " << m_strCommand << " "
1877  << (m_bSuccess ? "SUCCESS" : "FAILED")
1878  << "\nNymID: " << m_strNymID
1879  << "\n ServerID: " << m_strServerID
1880  << "\n MarketID: " << m_strNymID2
1881  << "\n\n"; // m_ascInReferenceTo.Get()
1882 
1883  nReturnVal = 1;
1884  }
1885  else if (strNodeName.Compare("getMarketRecentTrades")) {
1886  m_strCommand = xml->getNodeName(); // Command
1887  m_strNymID = xml->getAttributeValue("nymID");
1888  m_strServerID = xml->getAttributeValue("serverID");
1889  m_strRequestNum = xml->getAttributeValue("requestNum");
1890  m_strNymID2 = xml->getAttributeValue("marketID");
1891 
1892  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
1893  << "\nServerID: " << m_strServerID
1894  << "\n Market ID: " << m_strNymID2
1895  << "\n Request #: " << m_strRequestNum << "\n";
1896 
1897  nReturnVal = 1;
1898  }
1899  else if (strNodeName.Compare("@getMarketRecentTrades")) {
1900  strSuccess = xml->getAttributeValue("success");
1901  if (strSuccess.Compare("true"))
1902  m_bSuccess = true;
1903  else
1904  m_bSuccess = false;
1905 
1906  m_strCommand = xml->getNodeName(); // Command
1907  m_strRequestNum = xml->getAttributeValue("requestNum");
1908  m_strNymID = xml->getAttributeValue("nymID");
1909  m_strServerID = xml->getAttributeValue("serverID");
1910  m_strNymID2 = xml->getAttributeValue("marketID");
1911 
1912  strDepth = xml->getAttributeValue("depth");
1913 
1914  if (strDepth.GetLength() > 0) m_lDepth = atol(strDepth.Get());
1915 
1916  const char* pElementExpected = nullptr;
1917  if (m_bSuccess && (m_lDepth > 0))
1918  pElementExpected = "messagePayload";
1919  else if (!m_bSuccess)
1920  pElementExpected = "inReferenceTo";
1921 
1922  if (nullptr != pElementExpected) {
1923  OTASCIIArmor ascTextExpected;
1924 
1925  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
1926  pElementExpected)) {
1927  otErr << "Error in OTMessage::ProcessXMLNode: "
1928  "Expected " << pElementExpected
1929  << " element with text field, for " << m_strCommand
1930  << ".\n";
1931  return (-1); // error condition
1932  }
1933 
1934  if (m_bSuccess)
1935  m_ascPayload.Set(ascTextExpected);
1936  else
1937  m_ascInReferenceTo = ascTextExpected;
1938  }
1939 
1940  if (m_bSuccess)
1941  otWarn << "\nCommand: " << m_strCommand << " "
1942  << (m_bSuccess ? "SUCCESS" : "FAILED")
1943  << "\nNymID: " << m_strNymID
1944  << "\n ServerID: " << m_strServerID
1945  << "\n MarketID: " << m_strNymID2
1946  << "\n\n"; // m_ascPayload.Get()
1947  else
1948  otWarn << "\nCommand: " << m_strCommand << " "
1949  << (m_bSuccess ? "SUCCESS" : "FAILED")
1950  << "\nNymID: " << m_strNymID
1951  << "\n ServerID: " << m_strServerID
1952  << "\n MarketID: " << m_strNymID2
1953  << "\n\n"; // m_ascInReferenceTo.Get()
1954 
1955  nReturnVal = 1;
1956  }
1957  else if (strNodeName.Compare("getNym_MarketOffers")) {
1958  m_strCommand = xml->getNodeName(); // Command
1959  m_strNymID = xml->getAttributeValue("nymID");
1960  m_strServerID = xml->getAttributeValue("serverID");
1961  m_strRequestNum = xml->getAttributeValue("requestNum");
1962 
1963  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
1964  << "\nServerID: " << m_strServerID
1965  << "\nRequest #: " << m_strRequestNum << "\n";
1966 
1967  nReturnVal = 1;
1968  }
1969  else if (strNodeName.Compare("@getNym_MarketOffers")) {
1970  strSuccess = xml->getAttributeValue("success");
1971  if (strSuccess.Compare("true"))
1972  m_bSuccess = true;
1973  else
1974  m_bSuccess = false;
1975 
1976  m_strCommand = xml->getNodeName(); // Command
1977  m_strRequestNum = xml->getAttributeValue("requestNum");
1978  m_strNymID = xml->getAttributeValue("nymID");
1979  m_strServerID = xml->getAttributeValue("serverID");
1980 
1981  strDepth = xml->getAttributeValue("depth");
1982 
1983  if (strDepth.GetLength() > 0) m_lDepth = atol(strDepth.Get());
1984 
1985  const char* pElementExpected = nullptr;
1986  if (m_bSuccess && (m_lDepth > 0))
1987  pElementExpected = "messagePayload";
1988  else if (!m_bSuccess)
1989  pElementExpected = "inReferenceTo";
1990 
1991  if (nullptr != pElementExpected) {
1992  OTASCIIArmor ascTextExpected;
1993 
1994  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
1995  pElementExpected)) {
1996  otErr << "Error in OTMessage::ProcessXMLNode: "
1997  "Expected " << pElementExpected
1998  << " element with text field, for " << m_strCommand
1999  << ".\n";
2000  return (-1); // error condition
2001  }
2002 
2003  if (m_bSuccess)
2004  m_ascPayload.Set(ascTextExpected);
2005  else
2006  m_ascInReferenceTo = ascTextExpected;
2007  }
2008 
2009  if (m_bSuccess)
2010  otWarn << "\nCommand: " << m_strCommand << " "
2011  << (m_bSuccess ? "SUCCESS" : "FAILED")
2012  << "\nNymID: " << m_strNymID
2013  << "\n ServerID: " << m_strServerID
2014  << "\n\n"; // m_ascPayload.Get()
2015  else
2016  otWarn << "\nCommand: " << m_strCommand << " "
2017  << (m_bSuccess ? "SUCCESS" : "FAILED")
2018  << "\nNymID: " << m_strNymID
2019  << "\n ServerID: " << m_strServerID
2020  << "\n\n"; // m_ascInReferenceTo.Get()
2021 
2022  nReturnVal = 1;
2023  }
2024  else if (strNodeName.Compare("checkServerID")) {
2025  m_strCommand = xml->getNodeName(); // Command
2026  m_strRequestNum = xml->getAttributeValue("requestNum");
2027  m_strNymID = xml->getAttributeValue("nymID");
2028  m_strServerID = xml->getAttributeValue("serverID");
2029 
2030  pElementExpected = "publicAuthentKey";
2031  OTASCIIArmor ascTextExpected;
2032 
2033  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2034  pElementExpected)) {
2035  otErr << "Error in OTMessage::ProcessXMLNode: "
2036  "Expected " << pElementExpected
2037  << " element with text field, for " << m_strCommand << ".\n";
2038  return (-1); // error condition
2039  }
2040 
2041  m_strNymPublicKey.Set(ascTextExpected);
2042 
2043  pElementExpected = "publicEncryptionKey";
2044  ascTextExpected.Release();
2045 
2046  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2047  pElementExpected)) {
2048  otErr << "Error in OTMessage::ProcessXMLNode: "
2049  "Expected " << pElementExpected
2050  << " element with text field, for " << m_strCommand << ".\n";
2051  return (-1); // error condition
2052  }
2053 
2054  m_strNymID2.Set(ascTextExpected);
2055 
2056  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2057  << "\nServerID: " << m_strServerID
2058  << "\n\n Public signing key:\n" << m_strNymPublicKey
2059  << "\nPublic encryption key:\n" << m_strNymID2 << "\n";
2060 
2061  nReturnVal = 1;
2062  }
2063  else if (strNodeName.Compare("@checkServerID")) {
2064  strSuccess = xml->getAttributeValue("success");
2065  if (strSuccess.Compare("true"))
2066  m_bSuccess = true;
2067  else
2068  m_bSuccess = false;
2069 
2070  m_strCommand = xml->getNodeName(); // Command
2071  m_strRequestNum = xml->getAttributeValue("requestNum");
2072  m_strNymID = xml->getAttributeValue("nymID");
2073  m_strServerID = xml->getAttributeValue("serverID");
2074 
2075  otWarn << "\nCommand: " << m_strCommand << "\nSuccess: " << strSuccess
2076  << "\nNymID: " << m_strNymID << "\n"
2077  "ServerID: " << m_strServerID
2078  << "\n\n";
2079 
2080  nReturnVal = 1;
2081  }
2082  else if (strNodeName.Compare("createUserAccount")) {
2083  m_strCommand = xml->getNodeName(); // Command
2084  m_strRequestNum = xml->getAttributeValue("requestNum");
2085  m_strNymID = xml->getAttributeValue("nymID");
2086  m_strServerID = xml->getAttributeValue("serverID");
2087 
2088  pElementExpected = "credentialList";
2089 
2091  pElementExpected)) {
2092  otErr << "Error in OTMessage::ProcessXMLNode: "
2093  "Expected " << pElementExpected
2094  << " element with text field, for " << m_strCommand << ".\n";
2095  return (-1); // error condition
2096  }
2097 
2098  pElementExpected = "credentials";
2099 
2101  pElementExpected)) {
2102  otErr << "Error in OTMessage::ProcessXMLNode: "
2103  "Expected " << pElementExpected
2104  << " element with text field, for " << m_strCommand << ".\n";
2105  return (-1); // error condition
2106  }
2107 
2108  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2109  << "\nServerID: " << m_strServerID << "\n";
2110 
2111  nReturnVal = 1;
2112  }
2113  else if (strNodeName.Compare("@createUserAccount")) {
2114  strSuccess = xml->getAttributeValue("success");
2115  if (strSuccess.Compare("true"))
2116  m_bSuccess = true;
2117  else
2118  m_bSuccess = false;
2119 
2120  m_strCommand = xml->getNodeName(); // Command
2121  m_strRequestNum = xml->getAttributeValue("requestNum");
2122  m_strNymID = xml->getAttributeValue("nymID");
2123  m_strServerID = xml->getAttributeValue("serverID");
2124 
2125  if (m_bSuccess) {
2126  pElementExpected = "nymfile";
2127  OTASCIIArmor& ascTextExpected = m_ascPayload;
2128 
2129  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2130  pElementExpected)) {
2131  otErr << "Error in OTMessage::ProcessXMLNode: "
2132  "Expected " << pElementExpected
2133  << " element with text field, for " << m_strCommand
2134  << ".\n";
2135  return (-1); // error condition
2136  }
2137  }
2138 
2139  pElementExpected = "inReferenceTo";
2140  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2141 
2142  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2143  pElementExpected)) {
2144  otErr << "Error in OTMessage::ProcessXMLNode: "
2145  "Expected " << pElementExpected
2146  << " element with text field, for " << m_strCommand << ".\n";
2147  return (-1); // error condition
2148  }
2149 
2150  otWarn << "\nCommand: " << m_strCommand << " "
2151  << (m_bSuccess ? "SUCCESS" : "FAILED")
2152  << "\nNymID: " << m_strNymID
2153  << "\nServerID: " << m_strServerID << "\n\n\n";
2154 
2155  nReturnVal = 1;
2156  }
2157  else if (strNodeName.Compare("deleteUserAccount")) {
2158  m_strCommand = xml->getNodeName(); // Command
2159  m_strNymID = xml->getAttributeValue("nymID");
2160  m_strServerID = xml->getAttributeValue("serverID");
2161  m_strRequestNum = xml->getAttributeValue("requestNum");
2162 
2163  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2164  << "\nServerID: " << m_strServerID << "\n\n";
2165 
2166  nReturnVal = 1;
2167  }
2168  else if (strNodeName.Compare("@deleteUserAccount")) {
2169  strSuccess = xml->getAttributeValue("success");
2170  if (strSuccess.Compare("true"))
2171  m_bSuccess = true;
2172  else
2173  m_bSuccess = false;
2174 
2175  m_strCommand = xml->getNodeName(); // Command
2176  m_strRequestNum = xml->getAttributeValue("requestNum");
2177  m_strNymID = xml->getAttributeValue("nymID");
2178  m_strServerID = xml->getAttributeValue("serverID");
2179 
2180  pElementExpected = "inReferenceTo";
2181  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2182 
2183  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2184  pElementExpected)) {
2185  otErr << "Error in OTMessage::ProcessXMLNode: "
2186  "Expected " << pElementExpected
2187  << " element with text field, for " << m_strCommand << ".\n";
2188  return (-1); // error condition
2189  }
2190 
2191  otWarn << "\nCommand: " << m_strCommand << " "
2192  << (m_bSuccess ? "SUCCESS" : "FAILED")
2193  << "\nNymID: " << m_strNymID
2194  << "\nServerID: " << m_strServerID << "\n\n\n";
2195 
2196  nReturnVal = 1;
2197  }
2198  else if (strNodeName.Compare("getRequest")) {
2199  m_strCommand = xml->getNodeName(); // Command
2200  m_strRequestNum = xml->getAttributeValue("requestNum");
2201  m_strNymID = xml->getAttributeValue("nymID");
2202  m_strServerID = xml->getAttributeValue("serverID");
2203 
2204  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2205  << "\nServerID: " << m_strServerID << "\n\n";
2206 
2207  nReturnVal = 1;
2208  }
2209  else if (strNodeName.Compare("@getRequest")) {
2210  strSuccess = xml->getAttributeValue("success");
2211  if (strSuccess.Compare("true"))
2212  m_bSuccess = true;
2213  else
2214  m_bSuccess = false;
2215 
2216  m_strCommand = xml->getNodeName(); // Command
2217  m_strRequestNum = xml->getAttributeValue("requestNum");
2218  m_strNymID = xml->getAttributeValue("nymID");
2219  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
2220  m_strServerID = xml->getAttributeValue("serverID");
2221 
2222  const OTString strNewRequestNum =
2223  xml->getAttributeValue("newRequestNum");
2225  strNewRequestNum.Exists() ? atol(strNewRequestNum.Get()) : 0;
2226 
2227  otWarn << "\nCommand: " << m_strCommand << " "
2228  << (m_bSuccess ? "SUCCESS" : "FAILED")
2229  << "\nNymID: " << m_strNymID << "\n"
2230  "ServerID: " << m_strServerID
2231  << "\nRequest Number: " << m_strRequestNum
2232  << " New Number: " << m_lNewRequestNum << "\n\n";
2233 
2234  nReturnVal = 1;
2235  }
2236  else if (strNodeName.Compare("outmailMessage") ||
2237  strNodeName.Compare("outpaymentsMessage")) {
2238  m_strCommand = xml->getNodeName(); // Command
2239  m_strNymID = xml->getAttributeValue("nymID");
2240  m_strNymID2 = xml->getAttributeValue("nymID2");
2241  m_strServerID = xml->getAttributeValue("serverID");
2242  m_strRequestNum = xml->getAttributeValue("requestNum");
2243 
2244  pElementExpected = "messagePayload";
2245  OTASCIIArmor& ascTextExpected = m_ascPayload;
2246 
2247  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2248  pElementExpected)) {
2249  otErr << "Error in OTMessage::ProcessXMLNode: "
2250  "Expected " << pElementExpected
2251  << " element with text field, for " << m_strCommand << ".\n";
2252  return (-1); // error condition
2253  }
2254 
2255  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2256  << "\nNymID2: " << m_strNymID2
2257  << "\nServerID: " << m_strServerID
2258  << "\nRequest #: " << m_strRequestNum << "\n";
2259 
2260  nReturnVal = 1;
2261  }
2262  else if (strNodeName.Compare("sendUserMessage")) {
2263  m_strCommand = xml->getNodeName(); // Command
2264  m_strNymID = xml->getAttributeValue("nymID");
2265  m_strNymID2 = xml->getAttributeValue("nymID2");
2266  m_strServerID = xml->getAttributeValue("serverID");
2267  m_strRequestNum = xml->getAttributeValue("requestNum");
2268 
2269  pElementExpected = "messagePayload";
2270  OTASCIIArmor& ascTextExpected = m_ascPayload;
2271 
2272  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2273  pElementExpected)) {
2274  otErr << "Error in OTMessage::ProcessXMLNode: "
2275  "Expected " << pElementExpected
2276  << " element with text field, for " << m_strCommand << ".\n";
2277  return (-1); // error condition
2278  }
2279 
2280  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2281  << "\nNymID2: " << m_strNymID2
2282  << "\nServerID: " << m_strServerID
2283  << "\nRequest #: " << m_strRequestNum << "\n";
2284 
2285  nReturnVal = 1;
2286  }
2287  else if (strNodeName.Compare("@sendUserMessage")) {
2288  strSuccess = xml->getAttributeValue("success");
2289  if (strSuccess.Compare("true"))
2290  m_bSuccess = true;
2291  else
2292  m_bSuccess = false;
2293 
2294  m_strCommand = xml->getNodeName(); // Command
2295  m_strRequestNum = xml->getAttributeValue("requestNum");
2296  m_strNymID = xml->getAttributeValue("nymID");
2297  m_strNymID2 = xml->getAttributeValue("nymID2");
2298  m_strServerID = xml->getAttributeValue("serverID");
2299 
2300  otWarn << "\nCommand: " << m_strCommand << " "
2301  << (m_bSuccess ? "SUCCESS" : "FAILED")
2302  << "\nNymID: " << m_strNymID << "\nNymID2: " << m_strNymID2
2303  << "\n"
2304  "ServerID: " << m_strServerID << "\n\n";
2305 
2306  nReturnVal = 1;
2307  }
2308  else if (strNodeName.Compare("sendUserInstrument") ||
2309  strNodeName.Compare("payDividend")) // not a real message. Used
2310  // by server when sending
2311  // vouchers to people.
2312  {
2313  m_strCommand = xml->getNodeName(); // Command
2314  m_strNymID = xml->getAttributeValue("nymID");
2315  m_strNymID2 = xml->getAttributeValue("nymID2");
2316  m_strServerID = xml->getAttributeValue("serverID");
2317  m_strRequestNum = xml->getAttributeValue("requestNum");
2318 
2319  pElementExpected = "messagePayload";
2320  OTASCIIArmor& ascTextExpected = m_ascPayload;
2321 
2322  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2323  pElementExpected)) {
2324  otErr << "Error in OTMessage::ProcessXMLNode: "
2325  "Expected " << pElementExpected
2326  << " element with text field, for " << m_strCommand << ".\n";
2327  return (-1); // error condition
2328  }
2329 
2330  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2331  << "\nNymID2: " << m_strNymID2
2332  << "\nServerID: " << m_strServerID
2333  << "\nRequest #: " << m_strRequestNum << "\n";
2334 
2335  nReturnVal = 1;
2336  }
2337  else if (strNodeName.Compare("@sendUserInstrument")) {
2338  strSuccess = xml->getAttributeValue("success");
2339  if (strSuccess.Compare("true"))
2340  m_bSuccess = true;
2341  else
2342  m_bSuccess = false;
2343 
2344  m_strCommand = xml->getNodeName(); // Command
2345  m_strRequestNum = xml->getAttributeValue("requestNum");
2346  m_strNymID = xml->getAttributeValue("nymID");
2347  m_strNymID2 = xml->getAttributeValue("nymID2");
2348  m_strServerID = xml->getAttributeValue("serverID");
2349 
2350  otWarn << "\nCommand: " << m_strCommand << " "
2351  << (m_bSuccess ? "SUCCESS" : "FAILED")
2352  << "\nNymID: " << m_strNymID << "\nNymID2: " << m_strNymID2
2353  << "\n"
2354  "ServerID: " << m_strServerID << "\n\n";
2355 
2356  nReturnVal = 1;
2357  }
2358  else if (strNodeName.Compare("usageCredits")) {
2359  m_strCommand = xml->getNodeName(); // Command
2360  m_strNymID = xml->getAttributeValue("nymID");
2361  m_strNymID2 = xml->getAttributeValue("nymID2");
2362  m_strServerID = xml->getAttributeValue("serverID");
2363  m_strRequestNum = xml->getAttributeValue("requestNum");
2364 
2365  OTString strAdjustment = xml->getAttributeValue("adjustment");
2366 
2367  if (strAdjustment.GetLength() > 0) m_lDepth = atol(strAdjustment.Get());
2368 
2369  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2370  << "\nNymID2: " << m_strNymID2
2371  << "\nServerID: " << m_strServerID
2372  << "\nRequest #: " << m_strRequestNum
2373  << "\nAdjustment: " << m_lDepth << "\n";
2374 
2375  nReturnVal = 1;
2376  }
2377  else if (strNodeName.Compare("@usageCredits")) {
2378  strSuccess = xml->getAttributeValue("success");
2379  if (strSuccess.Compare("true"))
2380  m_bSuccess = true;
2381  else
2382  m_bSuccess = false;
2383 
2384  m_strCommand = xml->getNodeName(); // Command
2385  m_strRequestNum = xml->getAttributeValue("requestNum");
2386  m_strNymID = xml->getAttributeValue("nymID");
2387  m_strNymID2 = xml->getAttributeValue("nymID2");
2388  m_strServerID = xml->getAttributeValue("serverID");
2389 
2390  OTString strTotalCredits = xml->getAttributeValue("totalCredits");
2391 
2392  if (strTotalCredits.GetLength() > 0)
2393  m_lDepth = atol(strTotalCredits.Get());
2394 
2395  otWarn << "\nCommand: " << m_strCommand << " "
2396  << (m_bSuccess ? "SUCCESS" : "FAILED")
2397  << "\nNymID: " << m_strNymID << "\nNymID2: " << m_strNymID2
2398  << "\n"
2399  "ServerID: " << m_strServerID
2400  << "\nTotal Credits: " << m_lDepth << " \n\n";
2401  nReturnVal = 1;
2402  }
2403  else if (strNodeName.Compare("checkUser")) {
2404  m_strCommand = xml->getNodeName(); // Command
2405  m_strNymID = xml->getAttributeValue("nymID");
2406  m_strNymID2 = xml->getAttributeValue("nymID2");
2407  m_strServerID = xml->getAttributeValue("serverID");
2408  m_strRequestNum = xml->getAttributeValue("requestNum");
2409 
2410  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
2411  << "\nNymID2: " << m_strNymID2
2412  << "\nServerID: " << m_strServerID
2413  << "\nRequest #: " << m_strRequestNum << "\n";
2414 
2415  nReturnVal = 1;
2416  }
2417  else if (strNodeName.Compare("@checkUser")) {
2418  strSuccess = xml->getAttributeValue("success");
2419  if (strSuccess.Compare("true"))
2420  m_bSuccess = true;
2421  else
2422  m_bSuccess = false;
2423 
2424  m_strCommand = xml->getNodeName(); // Command
2425  m_strRequestNum = xml->getAttributeValue("requestNum");
2426  m_strNymID = xml->getAttributeValue("nymID");
2427  m_strNymID2 = xml->getAttributeValue("nymID2");
2428  m_strServerID = xml->getAttributeValue("serverID");
2429 
2430  const OTString strHasCredentials(
2431  xml->getAttributeValue("hasCredentials"));
2432  const bool bHasCredentials = strHasCredentials.Compare("true");
2433 
2434  const char* pElementExpected = nullptr;
2435  if (m_bSuccess)
2436  pElementExpected = "nymPublicKey";
2437  else
2438  pElementExpected = "inReferenceTo";
2439 
2440  OTASCIIArmor ascTextExpected;
2441  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2442  pElementExpected)) {
2443  otErr << "Error in OTMessage::ProcessXMLNode: "
2444  "Expected " << pElementExpected
2445  << " element with text field, for " << m_strCommand << ".\n";
2446  return (-1); // error condition
2447  }
2448  if (m_bSuccess)
2449  m_strNymPublicKey.Set(ascTextExpected);
2450  else
2451  m_ascInReferenceTo = ascTextExpected;
2452 
2453  if (bHasCredentials) {
2454  pElementExpected = "credentialList";
2455  ascTextExpected.Release();
2456 
2457  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2458  pElementExpected)) {
2459  otErr << "Error in OTMessage::ProcessXMLNode: "
2460  "Expected " << pElementExpected
2461  << " element with text field, for " << m_strCommand
2462  << ".\n";
2463  return (-1); // error condition
2464  }
2465  m_ascPayload = ascTextExpected;
2466 
2467  pElementExpected = "credentials";
2468  ascTextExpected.Release();
2469 
2470  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2471  pElementExpected)) {
2472  otErr << "Error in OTMessage::ProcessXMLNode: "
2473  "Expected " << pElementExpected
2474  << " element with text field, for " << m_strCommand
2475  << ".\n";
2476  return (-1); // error condition
2477  }
2478  m_ascPayload2 = ascTextExpected;
2479  }
2480 
2481  if (m_bSuccess)
2482  otWarn << "\nCommand: " << m_strCommand << " "
2483  << (m_bSuccess ? "SUCCESS" : "FAILED")
2484  << "\nNymID: " << m_strNymID
2485  << "\nNymID2: " << m_strNymID2
2486  << "\n"
2487  "ServerID: " << m_strServerID << "\nNym2 Public Key:\n"
2488  << m_strNymPublicKey << "\n\n";
2489  else
2490  otWarn << "\nCommand: " << m_strCommand << " "
2491  << (m_bSuccess ? "SUCCESS" : "FAILED")
2492  << "\nNymID: " << m_strNymID
2493  << "\nNymID2: " << m_strNymID2
2494  << "\n"
2495  "ServerID: " << m_strServerID
2496  << "\n\n"; // m_ascInReferenceTo.Get()
2497 
2498  nReturnVal = 1;
2499  }
2500  else if (strNodeName.Compare("issueAssetType")) {
2501  m_strCommand = xml->getNodeName(); // Command
2502  m_strNymID = xml->getAttributeValue("nymID");
2503  m_strServerID = xml->getAttributeValue("serverID");
2504  m_strAssetID = xml->getAttributeValue("assetType");
2505  m_strRequestNum = xml->getAttributeValue("requestNum");
2506 
2507  pElementExpected = "assetContract";
2508  OTASCIIArmor& ascTextExpected = m_ascPayload;
2509 
2510  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2511  pElementExpected)) {
2512  otErr << "Error in OTMessage::ProcessXMLNode: "
2513  "Expected " << pElementExpected
2514  << " element with text field, for " << m_strCommand << ".\n";
2515  return (-1); // error condition
2516  }
2517 
2518  otWarn << "\nCommand: " << m_strCommand << " \nNymID: " << m_strNymID
2519  << "\n"
2520  "ServerID: " << m_strServerID
2521  << "\nRequest#: " << m_strRequestNum << "\nAsset Type:\n"
2522  << m_strAssetID << "\n\n";
2523 
2524  nReturnVal = 1;
2525  }
2526  else if (strNodeName.Compare("@issueAssetType")) {
2527  strSuccess = xml->getAttributeValue("success");
2528  if (strSuccess.Compare("true"))
2529  m_bSuccess = true;
2530  else
2531  m_bSuccess = false;
2532 
2533  m_strCommand = xml->getNodeName(); // Command
2534  m_strNymID = xml->getAttributeValue("nymID");
2535  m_strRequestNum = xml->getAttributeValue("requestNum");
2536  m_strServerID = xml->getAttributeValue("serverID");
2537  m_strAssetID = xml->getAttributeValue("assetType");
2538  m_strAcctID = xml->getAttributeValue("accountID");
2539 
2540  // If successful, we need to read 2 more things: inReferenceTo and
2541  // issuerAccount payload.
2542  // If failure, then we only need to read 1 thing: inReferenceTo
2543  // At this point, we do not send the REASON WHY if it failed.
2544 
2545  {
2546  pElementExpected = "inReferenceTo";
2547  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2548 
2549  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2550  pElementExpected)) {
2551  otErr << "Error in OTMessage::ProcessXMLNode: "
2552  "Expected " << pElementExpected
2553  << " element with text field, for " << m_strCommand
2554  << ".\n";
2555  return (-1); // error condition
2556  }
2557  }
2558 
2559  if (m_bSuccess) {
2560  pElementExpected = "issuerAccount";
2561  OTASCIIArmor& ascTextExpected = m_ascPayload;
2562 
2563  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2564  pElementExpected)) {
2565  otErr << "Error in OTMessage::ProcessXMLNode: "
2566  "Expected " << pElementExpected
2567  << " element with text field, for " << m_strCommand
2568  << ".\n";
2569  return (-1); // error condition
2570  }
2571  }
2572 
2573  // Did we find everything we were looking for?
2574  // If the "command responding to" isn't there,
2575  // OR if it was successful but the Payload isn't there, then failure.
2576  if (!m_ascInReferenceTo.GetLength() ||
2577  (m_bSuccess && !m_ascPayload.GetLength())) {
2578  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2579  "Expected issuerAccount and/or inReferenceTo elements "
2580  "with text fields in "
2581  "@issueAssetType reply\n";
2582  return (-1); // error condition
2583  }
2584 
2585  OTString acctContents(m_ascPayload);
2586  otWarn << "\nCommand: " << m_strCommand << " "
2587  << (m_bSuccess ? "SUCCESS" : "FAILED")
2588  << "\nNymID: " << m_strNymID << "\nAccountID: " << m_strAcctID
2589  << "\nAsset Type ID: " << m_strAssetID
2590  << "\n"
2591  "ServerID: " << m_strServerID << "\n\n";
2592  // "****New Account****:\n%s\n",
2593  // m_ascInReferenceTo.Get(),
2594  // acctContents.Get()
2595 
2596  nReturnVal = 1;
2597  }
2598  else if (strNodeName.Compare("queryAssetTypes")) {
2599  m_strCommand = xml->getNodeName(); // Command
2600  m_strNymID = xml->getAttributeValue("nymID");
2601  m_strServerID = xml->getAttributeValue("serverID");
2602  m_strRequestNum = xml->getAttributeValue("requestNum");
2603 
2604  pElementExpected = "stringMap";
2605  OTASCIIArmor& ascTextExpected = m_ascPayload;
2606 
2607  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2608  pElementExpected)) {
2609  otErr << "Error in OTMessage::ProcessXMLNode: "
2610  "Expected " << pElementExpected
2611  << " element with text field, for " << m_strCommand << ".\n";
2612  return (-1); // error condition
2613  }
2614 
2615  otWarn << "\nCommand: " << m_strCommand << " \nNymID: " << m_strNymID
2616  << "\n"
2617  "ServerID: " << m_strServerID
2618  << "\nRequest#: " << m_strRequestNum << "\n\n";
2619 
2620  nReturnVal = 1;
2621  }
2622  else if (strNodeName.Compare("@queryAssetTypes")) {
2623  strSuccess = xml->getAttributeValue("success");
2624  if (strSuccess.Compare("true"))
2625  m_bSuccess = true;
2626  else
2627  m_bSuccess = false;
2628 
2629  m_strCommand = xml->getNodeName(); // Command
2630  m_strNymID = xml->getAttributeValue("nymID");
2631  m_strRequestNum = xml->getAttributeValue("requestNum");
2632  m_strServerID = xml->getAttributeValue("serverID");
2633 
2634  // If successful, we need to read 2 more things: inReferenceTo and
2635  // issuerAccount payload.
2636  // If failure, then we only need to read 1 thing: inReferenceTo
2637  // At this point, we do not send the REASON WHY if it failed.
2638 
2639  {
2640  pElementExpected = "inReferenceTo";
2641  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2642 
2643  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2644  pElementExpected)) {
2645  otErr << "Error in OTMessage::ProcessXMLNode: "
2646  "Expected " << pElementExpected
2647  << " element with text field, for " << m_strCommand
2648  << ".\n";
2649  return (-1); // error condition
2650  }
2651  }
2652 
2653  if (m_bSuccess) {
2654  pElementExpected = "stringMap";
2655  OTASCIIArmor& ascTextExpected = m_ascPayload;
2656 
2657  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2658  pElementExpected)) {
2659  otErr << "Error in OTMessage::ProcessXMLNode: "
2660  "Expected " << pElementExpected
2661  << " element with text field, for " << m_strCommand
2662  << ".\n";
2663  return (-1); // error condition
2664  }
2665  }
2666 
2667  // Did we find everything we were looking for?
2668  // If the "command responding to" isn't there,
2669  // OR if it was successful but the Payload isn't there, then failure.
2670  if (!m_ascInReferenceTo.GetLength() ||
2671  (m_bSuccess && !m_ascPayload.GetLength())) {
2672  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2673  "Expected stringMap and/or inReferenceTo elements with "
2674  "text fields in "
2675  "@queryAssetTypes reply\n";
2676  return (-1); // error condition
2677  }
2678 
2679  otWarn << "\n Command: " << m_strCommand << " "
2680  << (m_bSuccess ? "SUCCESS" : "FAILED")
2681  << "\n NymID: " << m_strNymID
2682  << "\n ServerID: " << m_strServerID << "\n\n";
2683 
2684  nReturnVal = 1;
2685  }
2686  else if (strNodeName.Compare("createAccount")) {
2687  m_strCommand = xml->getNodeName(); // Command
2688  m_strNymID = xml->getAttributeValue("nymID");
2689  m_strServerID = xml->getAttributeValue("serverID");
2690  m_strAssetID = xml->getAttributeValue("assetType");
2691  m_strRequestNum = xml->getAttributeValue("requestNum");
2692 
2693  otWarn << "\nCommand: " << m_strCommand << " \nNymID: " << m_strNymID
2694  << "\n"
2695  "ServerID: " << m_strServerID
2696  << "\nRequest#: " << m_strRequestNum << "\nAsset Type:\n"
2697  << m_strAssetID << "\n\n";
2698 
2699  nReturnVal = 1;
2700  }
2701  else if (strNodeName.Compare("@createAccount")) {
2702  strSuccess = xml->getAttributeValue("success");
2703  if (strSuccess.Compare("true"))
2704  m_bSuccess = true;
2705  else
2706  m_bSuccess = false;
2707 
2708  m_strCommand = xml->getNodeName(); // Command
2709  m_strRequestNum = xml->getAttributeValue("requestNum");
2710  m_strNymID = xml->getAttributeValue("nymID");
2711  m_strServerID = xml->getAttributeValue("serverID");
2712  m_strAcctID = xml->getAttributeValue("accountID");
2713 
2714  // If successful, we need to read 2 more things: inReferenceTo and
2715  // issuerAccount payload.
2716  // If failure, then we only need to read 1 thing: inReferenceTo
2717  // At this point, we do not send the REASON WHY if it failed.
2718 
2719  {
2720  pElementExpected = "inReferenceTo";
2721  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2722 
2723  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2724  pElementExpected)) {
2725  otErr << "Error in OTMessage::ProcessXMLNode: "
2726  "Expected " << pElementExpected
2727  << " element with text field, for " << m_strCommand
2728  << ".\n";
2729  // return (-1); // error condition
2730  }
2731  }
2732 
2733  if (m_bSuccess) {
2734  pElementExpected = "newAccount";
2735  OTASCIIArmor& ascTextExpected = m_ascPayload;
2736 
2737  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2738  pElementExpected)) {
2739  otErr << "Error in OTMessage::ProcessXMLNode: "
2740  "Expected " << pElementExpected
2741  << " element with text field, for " << m_strCommand
2742  << ".\n";
2743  return (-1); // error condition
2744  }
2745  }
2746 
2747  // Did we find everything we were looking for?
2748  // If the "command responding to" isn't there,
2749  // OR if it was successful but the Payload isn't there, then failure.
2750  //
2751  if (m_bSuccess && !m_ascPayload.GetLength()) {
2752  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2753  "Expected newAccount element with text field, in "
2754  "@createAccount reply\n";
2755  return (-1); // error condition
2756  }
2757 
2758  otWarn << "\nCommand: " << m_strCommand << " "
2759  << (m_bSuccess ? "SUCCESS" : "FAILED")
2760  << "\nNymID: " << m_strNymID << "\nAccountID: " << m_strAcctID
2761  << "\n"
2762  "ServerID: " << m_strServerID << "\n\n";
2763  // "****New Account****:\n%s\n",
2764  // m_ascInReferenceTo.Get(),
2765  // acctContents.Get()
2766 
2767  nReturnVal = 1;
2768  }
2769  else if (strNodeName.Compare("getBoxReceipt")) {
2770  m_strCommand = xml->getNodeName(); // Command
2771  m_strNymID = xml->getAttributeValue("nymID");
2772  m_strServerID = xml->getAttributeValue("serverID");
2773  m_strAcctID = xml->getAttributeValue("accountID");
2774  m_strRequestNum = xml->getAttributeValue("requestNum");
2775 
2776  strTransactionNum = xml->getAttributeValue("transactionNum");
2778  strTransactionNum.Exists() ? atol(strTransactionNum.Get()) : 0;
2779 
2780  const OTString strBoxType = xml->getAttributeValue("boxType");
2781 
2782  if (strBoxType.Compare("nymbox"))
2783  m_lDepth = 0;
2784  else if (strBoxType.Compare("inbox"))
2785  m_lDepth = 1;
2786  else if (strBoxType.Compare("outbox"))
2787  m_lDepth = 2;
2788  else {
2789  m_lDepth = 0;
2790  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2791  "Expected boxType to be inbox, outbox, or nymbox, in "
2792  "getBoxReceipt\n";
2793  return (-1);
2794  }
2795 
2796  otWarn << "\n Command: " << m_strCommand
2797  << " \n NymID: " << m_strNymID
2798  << "\n AccountID: " << m_strAcctID
2799  << "\n"
2800  " ServerID: " << m_strServerID
2801  << "\n Request#: " << m_strRequestNum
2802  << " Transaction#: " << m_lTransactionNum << " boxType: "
2803  << ((m_lDepth == 0) ? "nymbox" : (m_lDepth == 1) ? "inbox"
2804  : "outbox")
2805  << "\n\n"; // outbox is 2.);
2806 
2807  nReturnVal = 1;
2808  }
2809  else if (strNodeName.Compare("@getBoxReceipt")) {
2810  strSuccess = xml->getAttributeValue("success");
2811  if (strSuccess.Compare("true"))
2812  m_bSuccess = true;
2813  else
2814  m_bSuccess = false;
2815 
2816  m_strCommand = xml->getNodeName(); // Command
2817  m_strRequestNum = xml->getAttributeValue("requestNum");
2818  m_strNymID = xml->getAttributeValue("nymID");
2819  m_strServerID = xml->getAttributeValue("serverID");
2820  m_strAcctID = xml->getAttributeValue("accountID");
2821 
2822  strTransactionNum = xml->getAttributeValue("transactionNum");
2824  strTransactionNum.Exists() ? atol(strTransactionNum.Get()) : 0;
2825 
2826  const OTString strBoxType = xml->getAttributeValue("boxType");
2827 
2828  if (strBoxType.Compare("nymbox"))
2829  m_lDepth = 0;
2830  else if (strBoxType.Compare("inbox"))
2831  m_lDepth = 1;
2832  else if (strBoxType.Compare("outbox"))
2833  m_lDepth = 2;
2834  else {
2835  m_lDepth = 0;
2836  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2837  "Expected boxType to be inbox, outbox, or nymbox, in "
2838  "@getBoxReceipt reply\n";
2839  return (-1);
2840  }
2841 
2842  // inReferenceTo contains the getBoxReceipt (original request)
2843  // At this point, we do not send the REASON WHY if it failed.
2844 
2845  {
2846  pElementExpected = "inReferenceTo";
2847  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2848 
2849  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2850  pElementExpected)) {
2851  otErr << "Error in OTMessage::ProcessXMLNode: "
2852  "Expected " << pElementExpected
2853  << " element with text field, for " << m_strCommand
2854  << ".\n";
2855  return (-1); // error condition
2856  }
2857  }
2858 
2859  if (m_bSuccess) {
2860  pElementExpected = "boxReceipt";
2861  OTASCIIArmor& ascTextExpected = m_ascPayload;
2862 
2863  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2864  pElementExpected)) {
2865  otErr << "Error in OTMessage::ProcessXMLNode: "
2866  "Expected " << pElementExpected
2867  << " element with text field, for " << m_strCommand
2868  << ".\n";
2869  return (-1); // error condition
2870  }
2871  }
2872 
2873  // Did we find everything we were looking for?
2874  // If the "command responding to" isn't there,
2875  // OR if it was successful but the Payload isn't there, then failure.
2876  if (!m_ascInReferenceTo.GetLength() ||
2877  (m_bSuccess && !m_ascPayload.GetLength())) {
2878  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2879  "Expected boxReceipt and/or inReferenceTo elements with "
2880  "text fields in "
2881  "@getBoxReceipt reply\n";
2882  return (-1); // error condition
2883  }
2884 
2885  otWarn << "\nCommand: " << m_strCommand << " "
2886  << (m_bSuccess ? "SUCCESS" : "FAILED")
2887  << "\nNymID: " << m_strNymID << "\nAccountID: " << m_strAcctID
2888  << "\n"
2889  "ServerID: " << m_strServerID << "\n\n";
2890  // "****New Account****:\n%s\n",
2891 
2892  nReturnVal = 1;
2893  }
2894  else if (strNodeName.Compare("deleteAssetAccount")) {
2895  m_strCommand = xml->getNodeName(); // Command
2896  m_strNymID = xml->getAttributeValue("nymID");
2897  m_strServerID = xml->getAttributeValue("serverID");
2898  m_strAcctID = xml->getAttributeValue("accountID");
2899  m_strRequestNum = xml->getAttributeValue("requestNum");
2900 
2901  otWarn << "\n Command: " << m_strCommand
2902  << " \n NymID: " << m_strNymID
2903  << "\n AccountID: " << m_strAcctID
2904  << "\n"
2905  " ServerID: " << m_strServerID
2906  << "\n Request#: " << m_strRequestNum << "\n\n";
2907 
2908  nReturnVal = 1;
2909  }
2910  else if (strNodeName.Compare("@deleteAssetAccount")) {
2911  strSuccess = xml->getAttributeValue("success");
2912  if (strSuccess.Compare("true"))
2913  m_bSuccess = true;
2914  else
2915  m_bSuccess = false;
2916 
2917  m_strCommand = xml->getNodeName(); // Command
2918  m_strRequestNum = xml->getAttributeValue("requestNum");
2919  m_strNymID = xml->getAttributeValue("nymID");
2920  m_strServerID = xml->getAttributeValue("serverID");
2921  m_strAcctID = xml->getAttributeValue("accountID");
2922 
2923  // inReferenceTo contains the deleteAssetAccount (original request)
2924  // At this point, we do not send the REASON WHY if it failed.
2925 
2926  {
2927  pElementExpected = "inReferenceTo";
2928  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
2929 
2930  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2931  pElementExpected)) {
2932  otErr << "Error in OTMessage::ProcessXMLNode: "
2933  "Expected " << pElementExpected
2934  << " element with text field, for " << m_strCommand
2935  << ".\n";
2936  return (-1); // error condition
2937  }
2938  }
2939 
2940  // Did we find everything we were looking for?
2941  // If the "command responding to" isn't there, then failure.
2942  if (!m_ascInReferenceTo.GetLength()) {
2943  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2944  "Expected inReferenceTo element with text fields in "
2945  "@deleteAssetAccount reply\n";
2946  return (-1); // error condition
2947  }
2948 
2949  otWarn << "\nCommand: " << m_strCommand << " "
2950  << (m_bSuccess ? "SUCCESS" : "FAILED")
2951  << "\nNymID: " << m_strNymID << "\nAccountID: " << m_strAcctID
2952  << "\n"
2953  "ServerID: " << m_strServerID << "\n\n";
2954  // "****New Account****:\n%s\n",
2955  // m_ascInReferenceTo.Get(),
2956  // acctContents.Get()
2957 
2958  nReturnVal = 1;
2959  }
2960  else if (strNodeName.Compare("issueBasket")) {
2961  m_strCommand = xml->getNodeName(); // Command
2962  m_strNymID = xml->getAttributeValue("nymID");
2963  m_strServerID = xml->getAttributeValue("serverID");
2964  m_strRequestNum = xml->getAttributeValue("requestNum");
2965 
2966  {
2967  pElementExpected = "currencyBasket";
2968  OTASCIIArmor& ascTextExpected = m_ascPayload;
2969 
2970  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
2971  pElementExpected)) {
2972  otErr << "Error in OTMessage::ProcessXMLNode: "
2973  "Expected " << pElementExpected
2974  << " element with text field, for " << m_strCommand
2975  << ".\n";
2976  return (-1); // error condition
2977  }
2978  }
2979 
2980  // Did we find everything we were looking for?
2981  // If the Payload isn't there, then failure.
2982  if (!m_ascPayload.GetLength()) {
2983  otErr << "Error in OTMessage::ProcessXMLNode:\n"
2984  "Expected currencyBasket element with text fields in "
2985  "issueBasket message\n";
2986  return (-1); // error condition
2987  }
2988 
2989  otWarn << "\nCommand: " << m_strCommand << " \nNymID: " << m_strNymID
2990  << "\n"
2991  "ServerID: " << m_strServerID
2992  << "\nRequest#: " << m_strRequestNum << "\n\n";
2993 
2994  nReturnVal = 1;
2995  }
2996  else if (strNodeName.Compare("@issueBasket")) {
2997  strSuccess = xml->getAttributeValue("success");
2998  if (strSuccess.Compare("true"))
2999  m_bSuccess = true;
3000  else
3001  m_bSuccess = false;
3002 
3003  m_strCommand = xml->getNodeName(); // Command
3004  m_strRequestNum = xml->getAttributeValue("requestNum");
3005  m_strNymID = xml->getAttributeValue("nymID");
3006  m_strAssetID = xml->getAttributeValue("assetType");
3007  m_strServerID = xml->getAttributeValue("serverID");
3008  m_strAcctID = xml->getAttributeValue("accountID");
3009 
3010  {
3011  pElementExpected = "inReferenceTo";
3012  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
3013 
3014  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3015  pElementExpected)) {
3016  otErr << "Error in OTMessage::ProcessXMLNode: "
3017  "Expected " << pElementExpected
3018  << " element with text field, for " << m_strCommand
3019  << ".\n";
3020  return (-1); // error condition
3021  }
3022  }
3023 
3024  // Did we find everything we were looking for?
3025  // If the "command responding to" isn't there,
3026  // OR if it was successful but the Payload isn't there, then failure.
3027  if (!m_ascInReferenceTo.GetLength()) {
3028  otErr << "Error in OTMessage::ProcessXMLNode:\n"
3029  "Expected inReferenceTo element with text fields in "
3030  "@issueBasket reply\n";
3031  return (-1); // error condition
3032  }
3033 
3034  otWarn << "\nCommand: " << m_strCommand << " "
3035  << (m_bSuccess ? "SUCCESS" : "FAILED")
3036  << "\nNymID: " << m_strNymID << "\nAccountID: " << m_strAcctID
3037  << "\nAssetTypeID: " << m_strAssetID
3038  << "\n"
3039  "ServerID: " << m_strServerID << "\n\n";
3040 
3041  nReturnVal = 1;
3042  }
3043  else if (strNodeName.Compare("getTransactionNum")) {
3044  m_strCommand = xml->getNodeName(); // Command
3045  m_strNymID = xml->getAttributeValue("nymID");
3046  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3047  m_strServerID = xml->getAttributeValue("serverID");
3048  m_strRequestNum = xml->getAttributeValue("requestNum");
3049 
3050  otWarn << "\n Command: " << m_strCommand
3051  << " \n NymID: " << m_strNymID
3052  << "\n"
3053  " ServerID: " << m_strServerID
3054  << "\n Request#: " << m_strRequestNum << "\n\n";
3055 
3056  nReturnVal = 1;
3057  }
3058  else if (strNodeName.Compare("@getTransactionNum")) {
3059  strSuccess = xml->getAttributeValue("success");
3060  if (strSuccess.Compare("true"))
3061  m_bSuccess = true;
3062  else
3063  m_bSuccess = false;
3064 
3065  m_strCommand = xml->getNodeName(); // Command
3066  m_strRequestNum = xml->getAttributeValue("requestNum");
3067  m_strNymID = xml->getAttributeValue("nymID");
3068  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3069  m_strServerID = xml->getAttributeValue("serverID");
3070 
3071  otWarn << "\n Command: " << m_strCommand << " "
3072  << (m_bSuccess ? "SUCCESS" : "FAILED")
3073  << "\n NymID: " << m_strNymID
3074  << "\n"
3075  " ServerID: " << m_strServerID << "\n\n";
3076 
3077  nReturnVal = 1;
3078  }
3079  else if (strNodeName.Compare("notarizeTransactions")) {
3080  m_strCommand = xml->getNodeName(); // Command
3081  m_strNymID = xml->getAttributeValue("nymID");
3082  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3083  m_strServerID = xml->getAttributeValue("serverID");
3084  m_strAcctID = xml->getAttributeValue("accountID");
3085  m_strRequestNum = xml->getAttributeValue("requestNum");
3086 
3087  {
3088  pElementExpected = "accountLedger";
3089  OTASCIIArmor& ascTextExpected = m_ascPayload;
3090 
3091  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3092  pElementExpected)) {
3093  otErr << "Error in OTMessage::ProcessXMLNode: "
3094  "Expected " << pElementExpected
3095  << " element with text field, for " << m_strCommand
3096  << ".\n";
3097  return (-1); // error condition
3098  }
3099  }
3100 
3101  otWarn << "\n Command: " << m_strCommand
3102  << " \n NymID: " << m_strNymID
3103  << "\n AccountID: " << m_strAcctID
3104  << "\n"
3105  " ServerID: " << m_strServerID
3106  << "\n Request#: " << m_strRequestNum << "\n\n";
3107 
3108  nReturnVal = 1;
3109  }
3110  else if (strNodeName.Compare("@notarizeTransactions")) {
3111  strSuccess = xml->getAttributeValue("success");
3112  if (strSuccess.Compare("true"))
3113  m_bSuccess = true;
3114  else
3115  m_bSuccess = false;
3116 
3117  m_strCommand = xml->getNodeName(); // Command
3118  m_strRequestNum = xml->getAttributeValue("requestNum");
3119  m_strNymID = xml->getAttributeValue("nymID");
3120  m_strServerID = xml->getAttributeValue("serverID");
3121  m_strAcctID = xml->getAttributeValue("accountID");
3122 
3123  // If successful or failure, we need to read 2 more things:
3124  // inReferenceTo and the responseLedger payload.
3125  // At this point, we do not send the REASON WHY if it failed.
3126 
3127  {
3128  pElementExpected = "inReferenceTo";
3129  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
3130 
3131  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3132  pElementExpected)) {
3133  otErr << "Error in OTMessage::ProcessXMLNode: "
3134  "Expected " << pElementExpected
3135  << " element with text field, for " << m_strCommand
3136  << ".\n";
3137  return (-1); // error condition
3138  }
3139  }
3140 
3141  {
3142  pElementExpected = "responseLedger";
3143  OTASCIIArmor& ascTextExpected = m_ascPayload;
3144 
3145  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3146  pElementExpected)) {
3147  otErr << "Error in OTMessage::ProcessXMLNode: "
3148  "Expected " << pElementExpected
3149  << " element with text field, for " << m_strCommand
3150  << ".\n";
3151  return (-1); // error condition
3152  }
3153  }
3154 
3155  // Did we find everything we were looking for?
3156  // If the "command responding to" isn't there, or the Payload isn't
3157  // there, then failure.
3159  otErr << "Error in OTMessage::ProcessXMLNode:\n"
3160  "Expected responseLedger and/or inReferenceTo elements "
3161  "with text fields in "
3162  "@notarizeTransactions reply\n";
3163  return (-1); // error condition
3164  }
3165 
3166  // OTString acctContents(m_ascPayload);
3167  otWarn << "\n Command: " << m_strCommand << " "
3168  << (m_bSuccess ? "SUCCESS" : "FAILED")
3169  << "\n NymID: " << m_strNymID
3170  << "\n AccountID: " << m_strAcctID
3171  << "\n ServerID: " << m_strServerID << "\n\n";
3172  // "****New Account****:\n%s\n",
3173  // m_ascInReferenceTo.Get(),
3174  // acctContents.Get()
3175 
3176  nReturnVal = 1;
3177  }
3178  else if (strNodeName.Compare("getInbox")) {
3179  m_strCommand = xml->getNodeName(); // Command
3180  m_strNymID = xml->getAttributeValue("nymID");
3181  m_strServerID = xml->getAttributeValue("serverID");
3182  m_strAcctID = xml->getAttributeValue("accountID");
3183  m_strRequestNum = xml->getAttributeValue("requestNum");
3184 
3185  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3186  << "\nServerID: " << m_strServerID
3187  << "\nAccountID: " << m_strAcctID
3188  << "\nRequest #: " << m_strRequestNum << "\n";
3189 
3190  nReturnVal = 1;
3191  }
3192  else if (strNodeName.Compare("getNymbox")) {
3193  m_strCommand = xml->getNodeName(); // Command
3194  m_strNymID = xml->getAttributeValue("nymID");
3195  m_strServerID = xml->getAttributeValue("serverID");
3196  m_strRequestNum = xml->getAttributeValue("requestNum");
3197 
3198  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3199  << "\nServerID: " << m_strServerID
3200  << "\nRequest #: " << m_strRequestNum << "\n";
3201 
3202  nReturnVal = 1;
3203  }
3204  else if (strNodeName.Compare("@getInbox")) {
3205  strSuccess = xml->getAttributeValue("success");
3206  if (strSuccess.Compare("true"))
3207  m_bSuccess = true;
3208  else
3209  m_bSuccess = false;
3210 
3211  m_strCommand = xml->getNodeName(); // Command
3212  m_strRequestNum = xml->getAttributeValue("requestNum");
3213  m_strNymID = xml->getAttributeValue("nymID");
3214  m_strServerID = xml->getAttributeValue("serverID");
3215  m_strAcctID = xml->getAttributeValue("accountID");
3216  m_strInboxHash = xml->getAttributeValue("inboxHash");
3217 
3218  const char* pElementExpected;
3219  if (m_bSuccess)
3220  pElementExpected = "inboxLedger";
3221  else
3222  pElementExpected = "inReferenceTo";
3223 
3224  OTASCIIArmor ascTextExpected;
3225 
3226  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3227  pElementExpected)) {
3228  otErr << "Error in OTMessage::ProcessXMLNode: "
3229  "Expected " << pElementExpected
3230  << " element with text field, for " << m_strCommand << ".\n";
3231  return (-1); // error condition
3232  }
3233 
3234  if (m_bSuccess)
3235  m_ascPayload = ascTextExpected;
3236  else
3237  m_ascInReferenceTo = ascTextExpected;
3238 
3239  otWarn << "\nCommand: " << m_strCommand << " "
3240  << (m_bSuccess ? "SUCCESS" : "FAILED")
3241  << "\nNymID: " << m_strNymID
3242  << "\nAccountID: " << m_strAcctID
3243  << "\n"
3244  "ServerID: " << m_strServerID << "\n\n";
3245 
3246  nReturnVal = 1;
3247  }
3248  else if (strNodeName.Compare("@getNymbox")) {
3249  strSuccess = xml->getAttributeValue("success");
3250  if (strSuccess.Compare("true"))
3251  m_bSuccess = true;
3252  else
3253  m_bSuccess = false;
3254 
3255  m_strCommand = xml->getNodeName(); // Command
3256  m_strRequestNum = xml->getAttributeValue("requestNum");
3257  m_strNymID = xml->getAttributeValue("nymID");
3258  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3259  m_strServerID = xml->getAttributeValue("serverID");
3260 
3261  const char* pElementExpected;
3262  if (m_bSuccess)
3263  pElementExpected = "nymboxLedger";
3264  else
3265  pElementExpected = "inReferenceTo";
3266 
3267  OTASCIIArmor ascTextExpected;
3268 
3269  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3270  pElementExpected)) {
3271  otErr << "Error in OTMessage::ProcessXMLNode: "
3272  "Expected " << pElementExpected
3273  << " element with text field, for " << m_strCommand << ".\n";
3274  return (-1); // error condition
3275  }
3276 
3277  if (m_bSuccess)
3278  m_ascPayload = ascTextExpected;
3279  else
3280  m_ascInReferenceTo = ascTextExpected;
3281 
3282  otWarn << "\nCommand: " << m_strCommand << " "
3283  << (m_bSuccess ? "SUCCESS" : "FAILED")
3284  << "\nNymID: " << m_strNymID << "\n"
3285  "ServerID: " << m_strServerID
3286  << "\n\n";
3287 
3288  nReturnVal = 1;
3289  }
3290  else if (strNodeName.Compare("getOutbox")) {
3291  m_strCommand = xml->getNodeName(); // Command
3292  m_strNymID = xml->getAttributeValue("nymID");
3293  m_strServerID = xml->getAttributeValue("serverID");
3294  m_strAcctID = xml->getAttributeValue("accountID");
3295  m_strRequestNum = xml->getAttributeValue("requestNum");
3296 
3297  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3298  << "\nServerID: " << m_strServerID
3299  << "\nAccountID: " << m_strAcctID
3300  << "\nRequest #: " << m_strRequestNum << "\n";
3301 
3302  nReturnVal = 1;
3303  }
3304  else if (strNodeName.Compare("@getOutbox")) {
3305  strSuccess = xml->getAttributeValue("success");
3306  if (strSuccess.Compare("true"))
3307  m_bSuccess = true;
3308  else
3309  m_bSuccess = false;
3310 
3311  m_strCommand = xml->getNodeName(); // Command
3312  m_strRequestNum = xml->getAttributeValue("requestNum");
3313  m_strNymID = xml->getAttributeValue("nymID");
3314  m_strServerID = xml->getAttributeValue("serverID");
3315  m_strAcctID = xml->getAttributeValue("accountID");
3316  m_strOutboxHash = xml->getAttributeValue("outboxHash");
3317 
3318  const char* pElementExpected;
3319  if (m_bSuccess)
3320  pElementExpected = "outboxLedger";
3321  else
3322  pElementExpected = "inReferenceTo";
3323 
3324  OTASCIIArmor ascTextExpected;
3325 
3326  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3327  pElementExpected)) {
3328  otErr << "Error in OTMessage::ProcessXMLNode: "
3329  "Expected " << pElementExpected
3330  << " element with text field, for " << m_strCommand << ".\n";
3331  return (-1); // error condition
3332  }
3333 
3334  if (m_bSuccess)
3335  m_ascPayload = ascTextExpected;
3336  else
3337  m_ascInReferenceTo = ascTextExpected;
3338 
3339  otWarn << "\nCommand: " << m_strCommand << " "
3340  << (m_bSuccess ? "SUCCESS" : "FAILED")
3341  << "\nNymID: " << m_strNymID
3342  << "\nAccountID: " << m_strAcctID
3343  << "\n"
3344  "ServerID: " << m_strServerID << "\n\n";
3345 
3346  nReturnVal = 1;
3347  }
3348  else if (strNodeName.Compare("getAccount")) {
3349  m_strCommand = xml->getNodeName(); // Command
3350  m_strNymID = xml->getAttributeValue("nymID");
3351  m_strServerID = xml->getAttributeValue("serverID");
3352  m_strAcctID = xml->getAttributeValue("accountID");
3353  m_strRequestNum = xml->getAttributeValue("requestNum");
3354 
3355  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3356  << "\nServerID: " << m_strServerID
3357  << "\nAccountID: " << m_strAcctID
3358  << "\nRequest #: " << m_strRequestNum << "\n";
3359 
3360  nReturnVal = 1;
3361  }
3362  else if (strNodeName.Compare("@getAccount")) {
3363  strSuccess = xml->getAttributeValue("success");
3364  if (strSuccess.Compare("true"))
3365  m_bSuccess = true;
3366  else
3367  m_bSuccess = false;
3368 
3369  m_strCommand = xml->getNodeName(); // Command
3370  m_strRequestNum = xml->getAttributeValue("requestNum");
3371  m_strNymID = xml->getAttributeValue("nymID");
3372  m_strServerID = xml->getAttributeValue("serverID");
3373  m_strAcctID = xml->getAttributeValue("accountID");
3374 
3375  const char* pElementExpected;
3376  if (m_bSuccess)
3377  pElementExpected = "assetAccount";
3378  else
3379  pElementExpected = "inReferenceTo";
3380 
3381  OTASCIIArmor ascTextExpected;
3382 
3383  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3384  pElementExpected)) {
3385  otErr << "Error in OTMessage::ProcessXMLNode: "
3386  "Expected " << pElementExpected
3387  << " element with text field, for " << m_strCommand << ".\n";
3388  return (-1); // error condition
3389  }
3390 
3391  if (m_bSuccess)
3392  m_ascPayload = ascTextExpected;
3393  else
3394  m_ascInReferenceTo = ascTextExpected;
3395 
3396  otWarn << "\nCommand: " << m_strCommand << " "
3397  << (m_bSuccess ? "SUCCESS" : "FAILED")
3398  << "\nNymID: " << m_strNymID
3399  << "\nAccountID: " << m_strAcctID
3400  << "\n"
3401  "ServerID: " << m_strServerID << "\n\n";
3402 
3403  nReturnVal = 1;
3404  }
3405  else if (strNodeName.Compare("getAccountFiles")) {
3406  m_strCommand = xml->getNodeName(); // Command
3407  m_strNymID = xml->getAttributeValue("nymID");
3408  m_strServerID = xml->getAttributeValue("serverID");
3409  m_strAcctID = xml->getAttributeValue("accountID");
3410  m_strRequestNum = xml->getAttributeValue("requestNum");
3411 
3412  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3413  << "\nServerID: " << m_strServerID
3414  << "\nAccountID: " << m_strAcctID
3415  << "\nRequest #: " << m_strRequestNum << "\n";
3416 
3417  nReturnVal = 1;
3418  }
3419  else if (strNodeName.Compare("@getAccountFiles")) {
3420  strSuccess = xml->getAttributeValue("success");
3421  if (strSuccess.Compare("true"))
3422  m_bSuccess = true;
3423  else
3424  m_bSuccess = false;
3425 
3426  m_strCommand = xml->getNodeName(); // Command
3427  m_strRequestNum = xml->getAttributeValue("requestNum");
3428  m_strNymID = xml->getAttributeValue("nymID");
3429  m_strServerID = xml->getAttributeValue("serverID");
3430  m_strAcctID = xml->getAttributeValue("accountID");
3431  m_strInboxHash = xml->getAttributeValue("inboxHash");
3432  m_strOutboxHash = xml->getAttributeValue("outboxHash");
3433 
3434  const char* pElementExpected;
3435  if (m_bSuccess)
3436  pElementExpected = "acctFiles";
3437  else
3438  pElementExpected = "inReferenceTo";
3439 
3440  OTASCIIArmor ascTextExpected;
3441 
3442  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3443  pElementExpected)) {
3444  otErr << "Error in OTMessage::ProcessXMLNode: "
3445  "Expected " << pElementExpected
3446  << " element with text field, for " << m_strCommand << ".\n";
3447  return (-1); // error condition
3448  }
3449 
3450  if (m_bSuccess)
3451  m_ascPayload = ascTextExpected;
3452  else
3453  m_ascInReferenceTo = ascTextExpected;
3454 
3455  otWarn << "\nCommand: " << m_strCommand << " "
3456  << (m_bSuccess ? "SUCCESS" : "FAILED")
3457  << "\nNymID: " << m_strNymID
3458  << "\nAccountID: " << m_strAcctID
3459  << "\n"
3460  "ServerID: " << m_strServerID << "\n\n";
3461 
3462  nReturnVal = 1;
3463  }
3464  else if (strNodeName.Compare("getContract")) {
3465  m_strCommand = xml->getNodeName(); // Command
3466  m_strNymID = xml->getAttributeValue("nymID");
3467  m_strServerID = xml->getAttributeValue("serverID");
3468  m_strAssetID = xml->getAttributeValue("assetType");
3469  m_strRequestNum = xml->getAttributeValue("requestNum");
3470 
3471  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3472  << "\nServerID: " << m_strServerID
3473  << "\nAsset Type: " << m_strAssetID
3474  << "\nRequest #: " << m_strRequestNum << "\n";
3475 
3476  nReturnVal = 1;
3477  }
3478  else if (strNodeName.Compare("@getContract")) {
3479  strSuccess = xml->getAttributeValue("success");
3480  if (strSuccess.Compare("true"))
3481  m_bSuccess = true;
3482  else
3483  m_bSuccess = false;
3484 
3485  m_strCommand = xml->getNodeName(); // Command
3486  m_strRequestNum = xml->getAttributeValue("requestNum");
3487  m_strNymID = xml->getAttributeValue("nymID");
3488  m_strServerID = xml->getAttributeValue("serverID");
3489  m_strAssetID = xml->getAttributeValue("assetType");
3490 
3491  const char* pElementExpected;
3492  if (m_bSuccess)
3493  pElementExpected = "assetContract";
3494  else
3495  pElementExpected = "inReferenceTo";
3496 
3497  OTASCIIArmor ascTextExpected;
3498 
3499  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3500  pElementExpected)) {
3501  otErr << "Error in OTMessage::ProcessXMLNode: "
3502  "Expected " << pElementExpected
3503  << " element with text field, for " << m_strCommand << ".\n";
3504  return (-1); // error condition
3505  }
3506 
3507  if (m_bSuccess)
3508  m_ascPayload = ascTextExpected;
3509  else
3510  m_ascInReferenceTo = ascTextExpected;
3511 
3512  otWarn << "\nCommand: " << m_strCommand << " "
3513  << (m_bSuccess ? "SUCCESS" : "FAILED")
3514  << "\nNymID: " << m_strNymID
3515  << "\nAsset Type ID: " << m_strAssetID
3516  << "\n"
3517  "ServerID: " << m_strServerID << "\n\n";
3518 
3519  nReturnVal = 1;
3520  }
3521  else if (strNodeName.Compare("getMint")) {
3522  m_strCommand = xml->getNodeName(); // Command
3523  m_strNymID = xml->getAttributeValue("nymID");
3524  m_strServerID = xml->getAttributeValue("serverID");
3525  m_strAssetID = xml->getAttributeValue("assetType");
3526  m_strRequestNum = xml->getAttributeValue("requestNum");
3527 
3528  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3529  << "\nServerID: " << m_strServerID
3530  << "\nAsset Type: " << m_strAssetID
3531  << "\nRequest #: " << m_strRequestNum << "\n";
3532 
3533  nReturnVal = 1;
3534  }
3535 
3536  // the Payload contains an ascii-armored OTMint object.
3537  else if (strNodeName.Compare("@getMint")) {
3538  strSuccess = xml->getAttributeValue("success");
3539  if (strSuccess.Compare("true"))
3540  m_bSuccess = true;
3541  else
3542  m_bSuccess = false;
3543 
3544  m_strCommand = xml->getNodeName(); // Command
3545  m_strRequestNum = xml->getAttributeValue("requestNum");
3546  m_strNymID = xml->getAttributeValue("nymID");
3547  m_strServerID = xml->getAttributeValue("serverID");
3548  m_strAssetID = xml->getAttributeValue("assetType");
3549 
3550  const char* pElementExpected;
3551  if (m_bSuccess)
3552  pElementExpected = "mint";
3553  else
3554  pElementExpected = "inReferenceTo";
3555 
3556  OTASCIIArmor ascTextExpected;
3557 
3558  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3559  pElementExpected)) {
3560  otErr << "Error in OTMessage::ProcessXMLNode: "
3561  "Expected " << pElementExpected
3562  << " element with text field, for " << m_strCommand << ".\n";
3563  return (-1); // error condition
3564  }
3565 
3566  if (m_bSuccess)
3567  m_ascPayload = ascTextExpected;
3568  else
3569  m_ascInReferenceTo = ascTextExpected;
3570 
3571  otWarn << "\nCommand: " << m_strCommand << " "
3572  << (m_bSuccess ? "SUCCESS" : "FAILED")
3573  << "\nNymID: " << m_strNymID
3574  << "\nAsset Type ID: " << m_strAssetID
3575  << "\n"
3576  "ServerID: " << m_strServerID << "\n\n";
3577 
3578  nReturnVal = 1;
3579  }
3580  else if (strNodeName.Compare("triggerClause")) {
3581  m_strCommand = xml->getNodeName(); // Command
3582  m_strNymID = xml->getAttributeValue("nymID");
3583  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3584  m_strServerID = xml->getAttributeValue("serverID");
3585  m_strNymID2 = xml->getAttributeValue("clauseName");
3586  m_strRequestNum = xml->getAttributeValue("requestNum");
3587  const OTString strHasParam = xml->getAttributeValue("hasParam");
3588 
3589  strTransactionNum = xml->getAttributeValue("smartContractID");
3590  if (strTransactionNum.Exists())
3591  m_lTransactionNum = atol(strTransactionNum.Get());
3592 
3593  if (strHasParam.Compare("true")) {
3594  pElementExpected = "parameter";
3595  OTASCIIArmor ascTextExpected;
3596 
3597  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3598  pElementExpected)) {
3599  otErr << "Error in OTMessage::ProcessXMLNode: "
3600  "Expected " << pElementExpected
3601  << " element with text field, for " << m_strCommand
3602  << ".\n";
3603  return (-1); // error condition
3604  }
3605  else
3606  m_ascPayload = ascTextExpected;
3607  }
3608 
3609  otWarn << "\nCommand: " << m_strCommand << "\nNymID: " << m_strNymID
3610  << "\nServerID: " << m_strServerID
3611  << "\nClause TransNum and Name: " << m_lTransactionNum
3612  << " / " << m_strNymID2 << " \n"
3613  "Request #: " << m_strRequestNum
3614  << "\n";
3615 
3616  nReturnVal = 1;
3617  }
3618  else if (strNodeName.Compare("@triggerClause")) {
3619  strSuccess = xml->getAttributeValue("success");
3620  if (strSuccess.Compare("true"))
3621  m_bSuccess = true;
3622  else
3623  m_bSuccess = false;
3624 
3625  m_strCommand = xml->getNodeName(); // Command
3626  m_strRequestNum = xml->getAttributeValue("requestNum");
3627  m_strNymID = xml->getAttributeValue("nymID");
3628  m_strServerID = xml->getAttributeValue("serverID");
3629 
3630  const char* pElementExpected = "inReferenceTo";
3631 
3632  OTASCIIArmor ascTextExpected;
3633 
3634  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3635  pElementExpected)) {
3636  otErr << "Error in OTMessage::ProcessXMLNode: "
3637  "Expected " << pElementExpected
3638  << " element with text field, for " << m_strCommand << ".\n";
3639  return (-1); // error condition
3640  }
3641 
3642  m_ascInReferenceTo = ascTextExpected;
3643 
3644  otWarn << "\nCommand: " << m_strCommand << " "
3645  << (m_bSuccess ? "SUCCESS" : "FAILED")
3646  << "\nNymID: " << m_strNymID
3647  << " ServerID: " << m_strServerID << "\n\n";
3648 
3649  nReturnVal = 1;
3650  }
3651  else if (strNodeName.Compare("processInbox")) {
3652  m_strCommand = xml->getNodeName(); // Command
3653  m_strNymID = xml->getAttributeValue("nymID");
3654  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3655  m_strServerID = xml->getAttributeValue("serverID");
3656  m_strAcctID = xml->getAttributeValue("accountID");
3657  m_strRequestNum = xml->getAttributeValue("requestNum");
3658 
3659  {
3660  pElementExpected = "processLedger";
3661  OTASCIIArmor& ascTextExpected = m_ascPayload;
3662 
3663  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3664  pElementExpected)) {
3665  otErr << "Error in OTMessage::ProcessXMLNode: "
3666  "Expected " << pElementExpected
3667  << " element with text field, for " << m_strCommand
3668  << ".\n";
3669  return (-1); // error condition
3670  }
3671  }
3672 
3673  otWarn << "\n Command: " << m_strCommand
3674  << " \n NymID: " << m_strNymID
3675  << "\n AccountID: " << m_strAcctID
3676  << "\n"
3677  " ServerID: " << m_strServerID
3678  << "\n Request#: " << m_strRequestNum << "\n\n";
3679 
3680  nReturnVal = 1;
3681  }
3682  else if (strNodeName.Compare("processNymbox")) {
3683  m_strCommand = xml->getNodeName(); // Command
3684  m_strNymID = xml->getAttributeValue("nymID");
3685  m_strNymboxHash = xml->getAttributeValue("nymboxHash");
3686  m_strServerID = xml->getAttributeValue("serverID");
3687  m_strRequestNum = xml->getAttributeValue("requestNum");
3688 
3689  {
3690  pElementExpected = "processLedger";
3691  OTASCIIArmor& ascTextExpected = m_ascPayload;
3692 
3693  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3694  pElementExpected)) {
3695  otErr << "Error in OTMessage::ProcessXMLNode: "
3696  "Expected " << pElementExpected
3697  << " element with text field, for " << m_strCommand
3698  << ".\n";
3699  return (-1); // error condition
3700  }
3701  }
3702 
3703  otWarn << "\n Command: " << m_strCommand
3704  << " \n NymID: " << m_strNymID
3705  << "\n"
3706  " ServerID: " << m_strServerID
3707  << "\n Request#: " << m_strRequestNum << "\n\n";
3708 
3709  nReturnVal = 1;
3710  }
3711  else if (strNodeName.Compare("@processInbox")) {
3712  strSuccess = xml->getAttributeValue("success");
3713  if (strSuccess.Compare("true"))
3714  m_bSuccess = true;
3715  else
3716  m_bSuccess = false;
3717 
3718  m_strCommand = xml->getNodeName(); // Command
3719  m_strRequestNum = xml->getAttributeValue("requestNum");
3720  m_strNymID = xml->getAttributeValue("nymID");
3721  m_strServerID = xml->getAttributeValue("serverID");
3722  m_strAcctID = xml->getAttributeValue("accountID");
3723 
3724  // If successful or failure, we need to read 2 more things:
3725  // inReferenceTo and the responseLedger payload.
3726  // At this point, we do not send the REASON WHY if it failed.
3727 
3728  {
3729  pElementExpected = "inReferenceTo";
3730  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
3731 
3732  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3733  pElementExpected)) {
3734  otErr << "Error in OTMessage::ProcessXMLNode: "
3735  "Expected " << pElementExpected
3736  << " element with text field, for " << m_strCommand
3737  << ".\n";
3738  return (-1); // error condition
3739  }
3740  }
3741 
3742  {
3743  pElementExpected = "responseLedger";
3744  OTASCIIArmor& ascTextExpected = m_ascPayload;
3745 
3746  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3747  pElementExpected)) {
3748  otErr << "Error in OTMessage::ProcessXMLNode: "
3749  "Expected " << pElementExpected
3750  << " element with text field, for " << m_strCommand
3751  << ".\n";
3752  return (-1); // error condition
3753  }
3754  }
3755 
3756  // Did we find everything we were looking for?
3757  // If the "command responding to" isn't there, or the Payload isn't
3758  // there, then failure.
3760  otErr << "Error in OTMessage::ProcessXMLNode:\n"
3761  "Expected responseLedger and/or inReferenceTo elements "
3762  "with text fields in "
3763  "@processInbox reply\n";
3764  return (-1); // error condition
3765  }
3766 
3767  otWarn << "\n Command: " << m_strCommand << " "
3768  << (m_bSuccess ? "SUCCESS" : "FAILED")
3769  << "\n NymID: " << m_strNymID
3770  << "\n AccountID: " << m_strAcctID
3771  << "\n ServerID: " << m_strServerID << "\n\n";
3772  // "****New Account****:\n%s\n",
3773 
3774  nReturnVal = 1;
3775  }
3776  else if (strNodeName.Compare("@processNymbox")) {
3777  strSuccess = xml->getAttributeValue("success");
3778  if (strSuccess.Compare("true"))
3779  m_bSuccess = true;
3780  else
3781  m_bSuccess = false;
3782 
3783  m_strCommand = xml->getNodeName(); // Command
3784  m_strRequestNum = xml->getAttributeValue("requestNum");
3785  m_strNymID = xml->getAttributeValue("nymID");
3786  m_strServerID = xml->getAttributeValue("serverID");
3787 
3788  // If successful or failure, we need to read 2 more things:
3789  // inReferenceTo and the responseLedger payload.
3790  // At this point, we do not send the REASON WHY if it failed.
3791 
3792  {
3793  pElementExpected = "inReferenceTo";
3794  OTASCIIArmor& ascTextExpected = m_ascInReferenceTo;
3795 
3796  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3797  pElementExpected)) {
3798  otErr << "Error in OTMessage::ProcessXMLNode: "
3799  "Expected " << pElementExpected
3800  << " element with text field, for " << m_strCommand
3801  << ".\n";
3802  return (-1); // error condition
3803  }
3804  }
3805 
3806  {
3807  pElementExpected = "responseLedger";
3808  OTASCIIArmor& ascTextExpected = m_ascPayload;
3809 
3810  if (!OTContract::LoadEncodedTextFieldByName(xml, ascTextExpected,
3811  pElementExpected)) {
3812  otErr << "Error in OTMessage::ProcessXMLNode: "
3813  "Expected " << pElementExpected
3814  << " element with text field, for " << m_strCommand
3815  << ".\n";
3816  return (-1); // error condition
3817  }
3818  }
3819 
3820  // Did we find everything we were looking for?
3821  // If the "command responding to" isn't there, or the Payload isn't
3822  // there, then failure.
3824  otErr << "Error in OTMessage::ProcessXMLNode:\n"
3825  "Expected responseLedger and/or inReferenceTo elements "
3826  "with text fields in "
3827  "@processNymbox reply\n";
3828  return (-1); // error condition
3829  }
3830 
3831  otWarn << "\n Command: " << m_strCommand << " "
3832  << (m_bSuccess ? "SUCCESS" : "FAILED")
3833  << "\n NymID: " << m_strNymID
3834  << "\n"
3835  " ServerID: " << m_strServerID << "\n\n";
3836  // "****New Account****:\n%s\n",
3837 
3838  nReturnVal = 1;
3839  }
3840 
3841  return nReturnVal;
3842 }
3843 
3844 // Most contracts do not override this function...
3845 // But OTMessage does, because every request sent to the server needs to be
3846 // signed.
3847 // And each new request is a new message, that requires a new signature, unlike
3848 // most
3849 // contracts, (that always stay the same after they are signed.)
3850 //
3851 // We need to update the m_xmlUnsigned member with the message members before
3852 // the
3853 // actual signing occurs. (Presumably this is the whole reason why the account
3854 // is being re-signed.)
3855 //
3856 // Normally, in other OTContract and derived classes, m_xmlUnsigned is read
3857 // from the file and then kept read-only, since contracts do not normally
3858 // change.
3859 // But as new messages are sent, they must be signed. This function insures that
3860 // the most up-to-date member contents are included in the request before it is
3861 // signed.
3862 //
3863 // Note: Above comment is slightly old. This override is now here only for the
3864 // purpose
3865 // of releasing the signatures. The other functionality is now handled by the
3866 // UpdateContents member, which is called by the framework, and otherwise empty
3867 // in
3868 // default, but child classes such as OTMessage and OTAccount override it to
3869 // save
3870 // their contents just before signing.
3871 // See OTMessage::UpdateContents near the top of this file for an example.
3872 //
3874  const OTPasswordData* pPWData)
3875 {
3876  // I release these, I assume, because a message only has one signer.
3877  ReleaseSignatures(); // Note: this might change with credentials. We might
3878  // require multiple signatures.
3879 
3880  // Use the authentication key instead of the signing key.
3881  //
3882  m_bIsSigned = OTContract::SignContractAuthent(theNym, pPWData);
3883 
3884  if (m_bIsSigned) {
3885  // otErr <<
3886  // "\n******************************************************\n"
3887  // "Contents of signed
3888  // message:\n\n%s******************************************************\n\n",
3889  // m_xmlUnsigned.Get());
3890  }
3891  else
3892  otWarn << "Failure signing message:\n" << m_xmlUnsigned << "";
3893 
3894  return m_bIsSigned;
3895 }
3896 
3897 // virtual (OTContract)
3899  const OTPasswordData* pPWData) const
3900 {
3901  // Messages, unlike many contracts, use the authentication key instead of
3902  // the signing key. This is because signing keys are meant for signing
3903  // legally
3904  // binding agreements, whereas authentication keys are used for message
3905  // transport
3906  // and for file storage. Since this is OTMessage specifically, used for
3907  // transport,
3908  // we have overridden sign and verify contract methods, to explicitly use
3909  // the
3910  // authentication key instead of the signing key. OTSignedFile should
3911  // probably be
3912  // the same way. (Maybe it already is, by the time you are reading this.)
3913  //
3914  return VerifySigAuthent(theNym, pPWData);
3915 }
3916 
3917 // Unlike other contracts, which do not change over time, and thus calculate
3918 // their ID
3919 // from a hash of the file itself, OTMessage objects are different every time.
3920 // Thus, we
3921 // cannot use a hash of the file to produce the Message ID.
3922 //
3923 // Message ID will probably become an important part of the protocol (to prevent
3924 // replay attacks..)
3925 // So I will end up using it. But for now, VerifyContractID will always return
3926 // true.
3927 //
3929 {
3930  return true;
3931 }
3932 
3934  : OTContract()
3935  , m_bIsSigned(false)
3936  , m_lNewRequestNum(0)
3937  , m_lDepth(0)
3938  , m_lTransactionNum(0)
3939  , m_bSuccess(false)
3940  , m_bBool(false)
3941  , m_lTime(0)
3942 
3943 {
3945 }
3946 
3948 {
3949 }
3950 
3951 // This actually saves to any file you want to pass it to.
3952 
3953 bool OTMessage::SaveContractWallet(std::ofstream& ofs) const
3954 {
3955  OTString strContract;
3956 
3957  if (SaveContractRaw(strContract)) {
3958  ofs << strContract;
3959 
3960  return true;
3961  }
3962  else {
3963  return false;
3964  }
3965 }
3966 
3967 } // namespace opentxs
int64_t m_lNewRequestNum
Definition: OTMessage.hpp:230
OTASCIIArmor m_ascPayload2
Definition: OTMessage.hpp:218
virtual bool SaveContractWallet(std::ofstream &ofs) const
Definition: OTMessage.cpp:3953
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
Definition: OTMessage.cpp:3873
OTString m_strAcctID
Definition: OTMessage.hpp:205
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTMessage.cpp:3898
OTString m_strInboxHash
Definition: OTMessage.hpp:196
bool HarvestClosingNumbers(OTPseudonym &theNym, bool bHarvestingForRetry, bool bReplyWasSuccess, bool bReplyWasFailure, bool bTransactionWasSuccess, bool bTransactionWasFailure)
EXPORT void SetAcknowledgments(OTPseudonym &theNym)
Definition: OTMessage.cpp:262
int64_t m_lTransactionNum
Definition: OTMessage.hpp:239
EXPORT void Release()
Definition: OTNumList.cpp:465
OTString m_strAssetID
Definition: OTMessage.hpp:203
EXPORT bool SaveContractRaw(OTString &strOutput) const
EXPORT uint32_t GetLength() const
Definition: OTString.cpp:1040
virtual EXPORT ~OTMessage()
Definition: OTMessage.cpp:3947
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
EXPORT void ReleaseSignatures()
Definition: OTContract.cpp:989
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
OTNumList m_AcknowledgedReplies
Definition: OTMessage.hpp:225
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
time64_t OTTimeGetCurrentTime()
Definition: Common.hpp:211
EXPORT bool LoadLedgerFromString(const OTString &theStr)
Definition: OTLedger.cpp:1752
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
OTString m_strNymID2
Definition: OTMessage.hpp:200
EXPORT bool Output(std::set< int64_t > &theOutput) const
Definition: OTNumList.cpp:430
std::deque< int64_t > dequeOfTransNums
#define OT_ASSERT(x)
Definition: Assert.hpp:150
bool HarvestOpeningNumber(OTPseudonym &theNym, bool bHarvestingForRetry, bool bReplyWasSuccess, bool bReplyWasFailure, bool bTransactionWasSuccess, bool bTransactionWasFailure)
EXPORT bool SignContractAuthent(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
Definition: OTContract.cpp:508
OTString m_strContractType
Definition: OTContract.hpp:178
OTLOG_IMPORT OTLogStream otInfo
OTString m_strOutboxHash
Definition: OTMessage.hpp:198
OTASCIIArmor m_ascInReferenceTo
Definition: OTMessage.hpp:211
EXPORT int32_t Count() const
Definition: OTNumList.cpp:460
virtual void UpdateContents()
Definition: OTMessage.cpp:296
OTString m_strServerID
Definition: OTMessage.hpp:191
OTStringXML m_xmlUnsigned
Definition: OTContract.hpp:174
OTLOG_IMPORT OTLogStream otWarn
OTString m_strNymboxHash
Definition: OTMessage.hpp:194
EXPORT const char * Get() const
Definition: OTString.cpp:1045
OTLOG_IMPORT OTLogStream otErr
OTString m_strRequestNum
Definition: OTMessage.hpp:207
OTASCIIArmor m_ascPayload
Definition: OTMessage.hpp:214
EXPORT bool HarvestTransactionNumbers(OTPseudonym &theNym, bool bHarvestingForRetry, bool bReplyWasSuccess, bool bReplyWasFailure, bool bTransactionWasSuccess, bool bTransactionWasFailure) const
Definition: OTMessage.cpp:158
OTString m_strCommand
Definition: OTMessage.hpp:189
mapOfTransNums & GetMapAcknowledgedNum()
virtual EXPORT bool VerifySigAuthent(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTContract.cpp:788
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
OTString m_strNymPublicKey
Definition: OTMessage.hpp:202
virtual EXPORT void Release()
Definition: OTString.cpp:765
virtual bool VerifyContractID() const
Definition: OTMessage.cpp:3928
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
Definition: OTMessage.cpp:1676
EXPORT const mapOfTransactions & GetTransactionMap() const
Definition: OTLedger.cpp:1160
static bool LoadEncodedTextFieldByName(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)