Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTRecord.cpp
Go to the documentation of this file.
1 /************************************************************
2 *
3 * OTRecord.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 "../core/stdafx.hpp"
134 
135 #include "OTRecord.hpp"
136 #include "OpenTransactions.hpp"
137 #include "OT_ME.hpp"
138 #include "OTAPI.hpp"
139 #include "OTAPI_Exec.hpp"
140 
141 #include "../ext/OTPayment.hpp"
142 
143 #include "../core/recurring/OTPaymentPlan.hpp"
144 #include "../core/OTLedger.hpp"
145 #include "../core/OTLog.hpp"
146 
147 #include <memory>
148 #include <algorithm>
149 
150 namespace opentxs
151 {
152 
153 bool OTRecord::FormatAmount(std::string& str_output) const
154 {
155  if (m_str_amount.empty() ||
156  m_str_asset_id.empty()) // Need these to do the formatting.
157  {
158  // otOut << __FUNCTION__ << ": Unable to format amount. Type: " <<
159  // m_str_type << " Amount:
160  // " << m_str_amount << " Asset: " << m_str_asset_id << "";
161  return false;
162  }
163  str_output = OTAPI_Wrap::It()->FormatAmount(
164  m_str_asset_id, OTAPI_Wrap::It()->StringToLong(m_str_amount));
165  return (!str_output.empty());
166 }
167 bool OTRecord::FormatMailSubject(std::string& str_output) const
168 {
169  str_output.clear();
170  if (IsMail()) {
171  if (!HasContents())
172  str_output = "(empty subject)";
173  else {
174  std::string str_temp_contents = GetContents();
175 
176  if (str_temp_contents.compare(0, 8, "Subject:") == 0) {
177  // Make the replacement.
178  str_temp_contents.replace(0, 8, "");
179  }
180  // Trim it, since there is probably a space after "Subject:"
181  // (Plus we want it trimmed anyway.)
182  std::string str_contents = OTString::trim(str_temp_contents);
183  // Cut the string at the first newline.
184  //
185  std::string::size_type pos_start = 0;
186  std::string::size_type pos = str_contents.find("\r\n", pos_start);
187 
188  if (std::string::npos == pos) // Didn't find anything.
189  pos = str_contents.find("\n", pos_start);
190  if (std::string::npos != pos) // We found a newline.
191  str_contents.erase(pos, std::string::npos);
192  // Trim it again, just for good measure.
193  str_output = OTString::trim(str_contents);
194  }
195  }
196  return (!str_output.empty());
197 }
198 bool OTRecord::FormatShortMailDescription(std::string& str_output) const
199 {
200  OTString strDescription;
201 
202  if (IsMail()) {
203  if (!HasContents())
204  strDescription.Set("(empty message)");
205  else {
206  std::string str_temp_contents = GetContents();
207  std::string str_contents = OTString::trim(str_temp_contents);
208 
209  if (str_contents.compare(0, 8, "Subject:") == 0) {
210  // Make the replacement.
211  str_contents.replace(0, 8, "");
212  }
213  bool bTruncated = false;
214 
215  if (str_contents.size() > 30) {
216  str_contents.erase(30, std::string::npos);
217  bTruncated = true;
218  }
219  // Replace any newlines with spaces...
220  //
221  std::replace(str_contents.begin(), str_contents.end(), '\r', ' ');
222  std::replace(str_contents.begin(), str_contents.end(), '\n', ' ');
223 
224  // str_contents.erase(std::remove(str_contents.begin(),
225  // str_contents.end(), '\n'), str_contents.end());
226  // str_contents.erase(std::remove(str_contents.begin(),
227  // str_contents.end(), '\r'), str_contents.end());
228  strDescription.Format("%s%s", OTString::trim(str_contents).c_str(),
229  bTruncated ? "..." : "");
230  }
231  }
232  str_output = strDescription.Get();
233  return (!str_output.empty());
234 }
235 bool OTRecord::FormatDescription(std::string& str_output) const
236 {
237  OTString strDescription, strStatus, strKind;
238 
239  if (IsRecord()) {
240  if (IsExpired())
241  strStatus = "(EXPIRED)"; // How to tell difference between
242  // instrument that processed successfully
243  // and THEN expired, versus one that
244  // expired before processing successfully?
245  // (See next comment.)
246  else if (IsInvoice())
247  strStatus = "(payment sent)"; // TODO: need an "invalid records" box
248  // for expired and canceled. Otherwise
249  // we may falsely assume "payment
250  // sent" when actually it expired. (We
251  // may also falsely assume payment
252  // expired when actually it was sent.)
253  // Solution is a new box.
254  else
255  strStatus = "";
256  // strStatus = "(record)";
257  }
258  else if (IsPending()) {
259  if (IsExpired())
260  strStatus = "(EXPIRED)";
261  else if (IsInvoice())
262  strStatus = "(unpaid)";
263  else if (!IsCash())
264  strStatus = "(pending)";
265  }
266  if (IsCanceled()) {
267  strStatus = "(CANCELED)";
268 
269  if (IsOutgoing() || IsReceipt()) strKind.Format("%s", "sent ");
270  }
271  else {
272  if (IsOutgoing())
273  strKind.Format(
274  "%s", ((IsPending() && !IsCash()) ? "outgoing " : "sent "));
275  else // incoming.
276  strKind.Format("%s", IsPending()
277  ? "incoming "
278  : (IsReceipt() ? "" : "received "));
279  }
280  OTString strTransNumForDisplay;
281 
282  if (!IsCash())
283  strTransNumForDisplay.Format(" #%ld", GetTransNumForDisplay());
284  if (IsRecord()) {
285  if (IsTransfer())
286  strDescription.Format("%s%s%s %s", strKind.Get(), "transfer",
287  strTransNumForDisplay.Get(), strStatus.Get());
288  else if (IsVoucher())
289  strDescription.Format("%s%s%s %s", strKind.Get(), "payment",
290  strTransNumForDisplay.Get(), strStatus.Get());
291  else if (IsReceipt()) {
292  std::string str_instrument_type;
293 
294  if (0 == GetInstrumentType().compare("transferReceipt"))
295  str_instrument_type = "transfer";
296  else if (0 == GetInstrumentType().compare("finalReceipt"))
297  str_instrument_type = "final receipt (closed)";
298  else if (0 == GetInstrumentType().compare("marketReceipt")) {
299  const int64_t lAmount =
300  OTAPI_Wrap::It()->StringToLong(m_str_amount);
301 
302  // I *think* successful trades have a negative amount -- we'll
303  // find out!
304  //
305  if (lAmount == 0)
306  str_instrument_type = "failed trade";
307  else {
308  str_instrument_type = "market trade (receipt)";
309  }
310  }
311  else if (0 == GetInstrumentType().compare("chequeReceipt")) {
312  const int64_t lAmount =
313  OTAPI_Wrap::It()->StringToLong(m_str_amount);
314 
315  // I paid OUT when this chequeReceipt came through. It must be a
316  // normal cheque that I wrote.
317  if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's
318  // because a canceled cheque has a 0 value.
319  str_instrument_type = "cheque";
320  else // I GOT PAID when this chequeReceipt came through. It must
321  // be an invoice I wrote, that someone paid.
322  {
323  if (IsCanceled())
324  str_instrument_type = "invoice";
325  else
326  str_instrument_type = "invoice (payment received)";
327  }
328  }
329  else if (0 == GetInstrumentType().compare("voucherReceipt")) {
330  str_instrument_type = "payment";
331  }
332  else if (0 == GetInstrumentType().compare("paymentReceipt")) {
333  const int64_t lAmount =
334  OTAPI_Wrap::It()->StringToLong(m_str_amount);
335 
336  if (!IsCanceled() && (lAmount > 0)) strKind.Set("received ");
337 
338  str_instrument_type = "recurring payment";
339  }
340 
341  strDescription.Format("%s%s%s %s", strKind.Get(),
342  str_instrument_type.c_str(),
343  strTransNumForDisplay.Get(), strStatus.Get());
344  }
345  else
346  strDescription.Format("%s%s%s %s", strKind.Get(),
347  GetInstrumentType().c_str(),
348  strTransNumForDisplay.Get(), strStatus.Get());
349  }
350  else {
351  if (IsTransfer())
352  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
353  "transfer", strTransNumForDisplay.Get());
354  else if (IsVoucher())
355  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
356  "payment", strTransNumForDisplay.Get());
357 
358  else if (IsReceipt()) {
359  std::string str_instrument_type;
360 
361  if (0 == GetInstrumentType().compare("transferReceipt")) {
362  if (IsCanceled())
363  str_instrument_type = "transfer";
364  else
365  str_instrument_type = "transfer (receipt)";
366  }
367  else if (0 == GetInstrumentType().compare("finalReceipt"))
368  str_instrument_type = "final receipt";
369  else if (0 == GetInstrumentType().compare("marketReceipt")) {
370  const int64_t lAmount =
371  OTAPI_Wrap::It()->StringToLong(m_str_amount);
372 
373  // I *think* marketReceipts have negative value. We'll just test
374  // for non-zero.
375  if (lAmount == 0)
376  str_instrument_type = "failed trade";
377  else
378  str_instrument_type = "market trade (receipt)";
379  }
380  else if (0 == GetInstrumentType().compare("chequeReceipt")) {
381  const int64_t lAmount =
382  OTAPI_Wrap::It()->StringToLong(m_str_amount);
383 
384  // I paid OUT when this chequeReceipt came through. It must be a
385  // normal cheque that I wrote.
386  if (lAmount <= 0) // Notice less than OR EQUAL TO 0 -- that's
387  // because a canceled cheque has a 0 value.
388  {
389  if (IsCanceled())
390  str_instrument_type = "cheque";
391  else
392  str_instrument_type = "cheque (receipt)";
393  }
394  else // I GOT PAID when this chequeReceipt came through. It
395  // must be an invoice I wrote, that someone paid.
396  {
397  if (IsCanceled())
398  str_instrument_type = "invoice";
399  else
400  str_instrument_type =
401  "sent invoice (receipt: payment received)";
402  }
403  }
404  else if (0 == GetInstrumentType().compare("voucherReceipt")) {
405  if (IsCanceled())
406  str_instrument_type = "payment";
407  else
408  str_instrument_type = "payment (receipt)";
409  }
410  else if (0 == GetInstrumentType().compare("paymentReceipt")) {
411  const int64_t lAmount =
412  OTAPI_Wrap::It()->StringToLong(m_str_amount);
413 
414  if (!IsCanceled() && (lAmount > 0)) strKind.Set("received ");
415 
416  str_instrument_type = "recurring payment (receipt)";
417  }
418 
419  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
420  str_instrument_type.c_str(),
421  strTransNumForDisplay.Get());
422  }
423  else
424  strDescription.Format("%s %s%s%s", strStatus.Get(), strKind.Get(),
425  GetInstrumentType().c_str(),
426  strTransNumForDisplay.Get());
427  }
428  str_output = strDescription.Get();
429  return (!str_output.empty());
430 }
432 {
433  if (!IsPaymentPlan()) return false;
434 
435  OTPaymentPlan thePlan;
436  const OTString strPlan(GetContents().c_str());
437 
438  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
439  return true;
440  return false;
441 }
442 
444 {
445  if (!IsPaymentPlan()) return false;
446 
447  OTPaymentPlan thePlan;
448  const OTString strPlan(GetContents().c_str());
449 
450  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
451  return true;
452  return false;
453 }
454 
456 {
457  if (!IsPaymentPlan()) return OT_TIME_ZERO;
458 
459  OTPaymentPlan thePlan;
460  const OTString strPlan(GetContents().c_str());
461 
462  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
463  return thePlan.GetInitialPaymentDate();
464  return OT_TIME_ZERO;
465 }
466 
468 {
469  if (!IsPaymentPlan()) return 0;
470 
471  OTPaymentPlan thePlan;
472  const OTString strPlan(GetContents().c_str());
473 
474  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasInitialPayment())
475  return thePlan.GetInitialPaymentAmount();
476  return 0;
477 }
478 
480 {
481  if (!IsPaymentPlan()) return OT_TIME_ZERO;
482 
483  OTPaymentPlan thePlan;
484  const OTString strPlan(GetContents().c_str());
485 
486  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
487  return thePlan.GetPaymentPlanStartDate();
488  return OT_TIME_ZERO;
489 }
490 
492 {
493  if (!IsPaymentPlan()) return OT_TIME_ZERO;
494 
495  OTPaymentPlan thePlan;
496  const OTString strPlan(GetContents().c_str());
497 
498  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
499  return thePlan.GetTimeBetweenPayments();
500  return OT_TIME_ZERO;
501 }
502 
504 {
505  if (!IsPaymentPlan()) return 0;
506 
507  OTPaymentPlan thePlan;
508  const OTString strPlan(GetContents().c_str());
509 
510  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
511  return thePlan.GetPaymentPlanAmount();
512  return 0;
513 }
514 
516 {
517  if (!IsPaymentPlan()) return 0;
518 
519  OTPaymentPlan thePlan;
520  const OTString strPlan(GetContents().c_str());
521 
522  if (thePlan.LoadContractFromString(strPlan) && thePlan.HasPaymentPlan())
523  return thePlan.GetMaximumNoPayments();
524  return 0;
525 }
527 {
528  return m_RecordType;
529 }
530 // For completed records (not pending.)
531 //
533 {
534  if (IsMail()) return true;
535 
536  if (!IsRecord()) return false;
537 
538  if (IsPending()) // This may be superfluous given the above 'if'
539  // statement.
540  return false;
541 
542  return true;
543 }
544 // For incoming, pending (not-yet-accepted) instruments.
545 //
547 {
548  // Commented out because a transferReceipt is in the inbox, but it
549  // represents an outgoing payment.
550  // if (IsOutgoing()) // If it's outgoing, then it's definitely not
551  // an incoming thing you can accept.
552  // return false;
553 
554  if (IsRecord()) // Records must be archived or deleted, not accepted
555  // or discarded.
556  return false;
557 
558  if (IsExpired()) return false;
559 
560  if (IsReceipt()) // It's NOT a record... If it's a receipt, then yes,
561  // we can accept it.
562  return true;
563 
564  if (IsMail()) // Can't "accept" mail, can only delete it.
565  return false;
566 
567  if (IsPending() && IsOutgoing()) // It's not a record, it's not
568  // a receipt. If it's pending,
569  // is it Outgoing pending? (Can
570  // only accept INCOMING
571  // pending, not outgoing.)
572  return false;
573 
574  return true;
575 }
576 // For INcoming, pending (not-yet-accepted) instruments.
577 //
579 {
580  if (IsOutgoing()) return false;
581 
582  if (!IsPending()) return false;
583 
584  if (IsMail()) return false;
585 
586  if (IsRecord()) // This may be superfluous given the above 'if'
587  // pending.
588  return false;
589 
590  if (IsReceipt()) // Receipts must be accepted, not discarded.
591  return false;
592 
593  if (OTRecord::Transfer == GetRecordType()) // All incoming, pending
594  // instruments EXCEPT
595  // transfer can be
596  // discarded.
597  return false;
598 
599  return true;
600 }
601 bool OTRecord::CanDiscardOutgoingCash() const // For OUTgoing cash. (No way to
602  // see if it's been accepted, so
603  // this lets you erase the record
604  // of sending it.)
605 {
606  if (!IsOutgoing()) return false;
607 
608  if (!IsPending()) return false;
609 
610  if (!IsCash()) return false;
611 
612  if (!(GetBoxIndex() >= 0)) return false;
613 
614  return true;
615 }
616 // For OUTgoing, pending (not-yet-accepted) instruments.
617 //
619 {
620  if (!IsOutgoing()) return false;
621 
622  if (IsCanceled()) // It's already canceled!
623  return false;
624 
625  if (!IsPending()) return false;
626 
627  if (IsMail()) return false;
628 
629  if (IsRecord()) // This may be superfluous given the above 'if'
630  // pending.
631  return false;
632 
633  if (IsReceipt()) // Receipts can't be canceled. (Probably
634  // superfluous.)
635  return false;
636 
637  if (OTRecord::Transfer == GetRecordType()) // All outgoing, pending
638  // instruments EXCEPT
639  // transfer can be
640  // canceled.
641  return false;
642 
643  return true;
644 }
645 
647 {
648  if (!CanDiscardOutgoingCash()) return false;
649  return OTAPI_Wrap::Nym_RemoveOutpaymentsByIndex(m_str_nym_id,
650  GetBoxIndex());
651 }
652 
653 // For completed records (not pending.)
654 //
656 {
657  if (!CanDeleteRecord()) return false;
658  if (!m_bIsSpecialMail &&
659  (m_str_server_id.empty() || m_str_nym_id.empty())) {
660  otErr << __FUNCTION__ << ": Error: missing server id ("
661  << m_str_server_id << ") or nym id (" << m_str_nym_id << ")\n";
662  return false;
663  }
664  std::string str_using_account;
665 
666  if ((OTRecord::Transfer == GetRecordType()) ||
668  if (m_str_account_id.empty()) {
669  otErr << __FUNCTION__
670  << ": Error: missing account id for transfer or receipt.\n";
671  return false;
672  }
673 
674  str_using_account = m_str_account_id;
675  }
676  else
677  str_using_account = m_str_nym_id; // For instruments.
678  switch (GetRecordType()) {
679  // Delete from in-mail or out-mail.
680  //
681  case OTRecord::Mail: {
682  // If it's a Bitmessage or any other "non-OT" mail, then we can't
683  // delete it here. We have to assume the client application is
684  // smart enough to check for this and perform the deletion itself.
685  // (Not all client apps will even support forms of mail other than
686  // OT mail.)
687  //
688  if (!m_bIsSpecialMail) {
689  if (m_bIsOutgoing) // outgoing mail
690  {
691  int32_t nCount = OTAPI_Wrap::GetNym_OutmailCount(m_str_nym_id);
692  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
693  const std::string str_contents(
695  nIndex));
696 
697  if (str_contents == m_str_contents) // found it.
698  {
700  m_str_nym_id, nIndex);
701  }
702  }
703  }
704  else // incoming mail
705  {
706  int32_t nCount = OTAPI_Wrap::GetNym_MailCount(m_str_nym_id);
707  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
708  const std::string str_contents(
710  nIndex));
711 
712  if (str_contents == m_str_contents) // found it.
713  {
714  return OTAPI_Wrap::Nym_RemoveMailByIndex(m_str_nym_id,
715  nIndex);
716  }
717  }
718  }
719  }
720  else
721  return true;
722 
723  return false;
724  } break;
725  case OTRecord::Transfer: // Delete from asset account recordbox.
726  case OTRecord::Receipt: // Delete from asset account recordbox.
727  case OTRecord::Instrument: // Delete from Nym's recordbox.
728  break;
729  default:
730  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
731  << "\n";
732  return false;
733  }
734  // The below section handles both the Nym's recordbox AND the Asset Account
735  // recordbox.
736  //
737  if (0 == m_lTransactionNum) {
738  otErr << __FUNCTION__
739  << ": Error: Transaction number is 0, in recordbox for "
740  "server id (" << m_str_server_id << "), nym id ("
741  << m_str_nym_id << "), acct id (" << str_using_account << ")\n";
742  return false;
743  }
744  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id),
745  theAcctID(str_using_account); // this last one sometimes contains NymID
746  // (see above.)
747 
748  OTLedger* pRecordbox =
749  OTAPI_Wrap::OTAPI()->LoadRecordBox(theServerID, theNymID, theAcctID);
750  std::unique_ptr<OTLedger> theRecordBoxAngel(pRecordbox);
751  if (nullptr == pRecordbox) {
752  otErr << __FUNCTION__ << ": Failed loading record box for server ID ("
753  << m_str_server_id << ") nymID "
754  "(" << m_str_nym_id << ") accountID ("
755  << str_using_account << ")\n";
756  return false;
757  }
758  // Find the receipt in the recordbox that correlates to this OTRecord.
759  //
760  int nIndex = pRecordbox->GetTransactionIndex(m_lTransactionNum);
761 
762  if ((-1) == nIndex) {
763  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
764  << m_lTransactionNum << " in recordbox "
765  "for server id (" << m_str_server_id
766  << "), nym id (" << m_str_nym_id << "), acct id ("
767  << str_using_account << ")\n";
768  return false;
769  }
770  // Accept it.
771  //
773  m_str_server_id, m_str_nym_id, str_using_account, nIndex,
774  false); // clear all = false. We're only clearing one record.
775 }
777 {
778  return AcceptIncomingTransferOrReceipt();
779 } // For incoming, pending (not-yet-accepted) transfers.
781 {
782  return AcceptIncomingTransferOrReceipt();
783 } // For incoming, (not-yet-accepted) receipts.
784 bool OTRecord::AcceptIncomingTransferOrReceipt() const
785 {
786  if (!CanAcceptIncoming()) return false;
787 
788  switch (GetRecordType()) {
789  // Accept transfer or receipt from asset account inbox.
790  //
791  case OTRecord::Transfer:
792  case OTRecord::Receipt: {
793  if (m_str_server_id.empty() || m_str_nym_id.empty() ||
794  m_str_account_id.empty()) {
795  otErr << __FUNCTION__ << ": Error: missing server id ("
796  << m_str_server_id << ") or nym id (" << m_str_nym_id
797  << ") or "
798  "acct id (" << m_str_account_id << ")\n";
799  return false;
800  }
801  if (0 == m_lTransactionNum) {
802  otErr << __FUNCTION__
803  << ": Error: Transaction number is 0, in asset "
804  "account inbox for server id (" << m_str_server_id
805  << "), nym id (" << m_str_nym_id << ")\n";
806  return false;
807  }
808  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id),
809  theAcctID(m_str_account_id);
810 
811  // Open the Nym's asset account inbox.
812  OTLedger* pInbox =
813  OTAPI_Wrap::OTAPI()->LoadInbox(theServerID, theNymID, theAcctID);
814  std::unique_ptr<OTLedger> theInboxAngel(pInbox);
815  if (nullptr == pInbox) {
816  otErr << __FUNCTION__
817  << ": Error: Unable to load asset account inbox for "
818  "server id (" << m_str_server_id << "), nym id ("
819  << m_str_nym_id << ")\n";
820  return false;
821  }
822  // Find the transfer/receipt therein that correlates to this OTRecord.
823  //
824  int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);
825 
826  if ((-1) == nIndex) {
827  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
828  << m_lTransactionNum << " in payment inbox "
829  "for server id (" << m_str_server_id
830  << "), nym id (" << m_str_nym_id << "), acct id ("
831  << m_str_account_id << ")\n";
832  return false;
833  }
834  // Accept it.
835  //
836  OTString strIndices;
837  strIndices.Format("%d", nIndex);
838  const std::string str_indices(strIndices.Get());
839 
840  OT_ME madeEasy;
841 
842  return madeEasy.accept_inbox_items(m_str_account_id, 0, str_indices);
843  } break;
844  default:
845  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
846  << "\n";
847  return false;
848  }
849 
850  return true;
851 }
852 // For incoming, pending (not-yet-accepted) instruments.
853 //
854 bool OTRecord::AcceptIncomingInstrument(const std::string& str_into_acct) const
855 {
856  if (!CanAcceptIncoming()) return false;
857 
858  switch (GetRecordType()) {
859  // Accept from Nym's payments inbox.
860  //
861  case OTRecord::Instrument: {
862  if (m_str_server_id.empty() || m_str_nym_id.empty()) {
863  otErr << __FUNCTION__ << ": Error: missing server id ("
864  << m_str_server_id << ") or nym id (" << m_str_nym_id
865  << ")\n";
866  return false;
867  }
868  if (0 == m_lTransactionNum) {
869  otErr << __FUNCTION__
870  << ": Error: Transaction number is 0, in payment "
871  "inbox for server id (" << m_str_server_id << "), nym id ("
872  << m_str_nym_id << ")\n";
873  return false;
874  }
875  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id);
876 
877  // Open the Nym's payments inbox.
878  OTLedger* pInbox =
879  OTAPI_Wrap::OTAPI()->LoadPaymentInbox(theServerID, theNymID);
880  std::unique_ptr<OTLedger> theInboxAngel(pInbox);
881  if (nullptr == pInbox) {
882  otErr << __FUNCTION__
883  << ": Error: Unable to load payment inbox for server "
884  "id (" << m_str_server_id << "), nym id (" << m_str_nym_id
885  << ")\n";
886  return false;
887  }
888  // Find the payment therein that correlates to this OTRecord.
889  //
890  int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);
891 
892  if ((-1) == nIndex) {
893  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
894  << m_lTransactionNum << " in "
895  "payment inbox for server id ("
896  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
897  return false;
898  }
899  // Accept it.
900  //
901  OTString strIndices;
902  strIndices.Format("%d", nIndex);
903  const std::string str_indices(strIndices.Get());
904 
905  OT_ME madeEasy;
906  if (!madeEasy.accept_from_paymentbox(str_into_acct, str_indices,
907  "ANY")) {
908  otErr << __FUNCTION__
909  << ": Error while trying to accept this instrument.\n";
910  return false;
911  }
912  } // case: instrument
913  break;
914  default:
915  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
916  << "\n";
917  return false;
918  }
919 
920  return true;
921 }
922 // For incoming, pending (not-yet-accepted) instruments.
923 //
925 {
926  if (!CanDiscardIncoming()) return false;
927 
928  switch (GetRecordType()) {
929  case OTRecord::Instrument: {
930  if (m_str_server_id.empty() || m_str_nym_id.empty()) {
931  otErr << __FUNCTION__ << ": Error: missing server id ("
932  << m_str_server_id << ") or nym id (" << m_str_nym_id
933  << ")\n";
934  return false;
935  }
936  if (0 == m_lTransactionNum) {
937  otErr << __FUNCTION__ << ": Error: Transaction number is 0, in "
938  "payment inbox for server id ("
939  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
940  return false;
941  }
942  const OTIdentifier theServerID(m_str_server_id), theNymID(m_str_nym_id);
943 
944  // Open the Nym's payments inbox.
945  OTLedger* pInbox =
946  OTAPI_Wrap::OTAPI()->LoadPaymentInbox(theServerID, theNymID);
947  std::unique_ptr<OTLedger> theInboxAngel(pInbox);
948  if (nullptr == pInbox) {
949  otErr << __FUNCTION__
950  << ": Error: Unable to load payment inbox for server id ("
951  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
952  return false;
953  }
954  // Find the payment therein that correlates to this OTRecord.
955  //
956  int nIndex = pInbox->GetTransactionIndex(m_lTransactionNum);
957 
958  if ((-1) == nIndex) {
959  otErr << __FUNCTION__ << ": Error: Unable to find transaction "
960  << m_lTransactionNum << " in "
961  "payment inbox for server id ("
962  << m_str_server_id << "), nym id (" << m_str_nym_id << ")\n";
963  return false;
964  }
965  // Accept it.
966  //
967  OTString strIndices;
968  strIndices.Format("%d", nIndex);
969  const std::string str_indices(strIndices.Get());
970 
971  OT_ME madeEasy;
972 
973  return madeEasy.discard_incoming_payments(m_str_server_id, m_str_nym_id,
974  str_indices);
975 
976  } // case: instrument
977  break;
978  default:
979  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
980  << "\n";
981  return false;
982  }
983 
984  return true;
985 }
987 {
988  return (OTRecord::Transfer == m_RecordType);
989 }
990 bool OTRecord::IsCash() const
991 {
992  return m_bIsCash;
993 }
995 {
996  return m_bIsInvoice;
997 }
998 bool OTRecord::IsCheque() const
999 {
1000  return m_bIsCheque;
1001 }
1003 {
1004  return m_bIsVoucher;
1005 }
1007 {
1008  return m_bIsSmartContract;
1009 }
1011 {
1012  return m_bIsPaymentPlan;
1013 }
1014 // For outgoing, pending (not-yet-accepted) instruments.
1015 //
1016 bool OTRecord::CancelOutgoing(std::string str_via_acct) const // This can
1017  // be
1018 // blank if it's a
1019 // cheque.
1020 {
1021  if (!CanCancelOutgoing()) return false;
1022 
1023  switch (GetRecordType()) {
1024  case OTRecord::Instrument: {
1025  if (m_str_nym_id.empty()) {
1026  otErr << __FUNCTION__ << ": Error: missing nym id (" << m_str_nym_id
1027  << ")\n";
1028  return false;
1029  }
1030 
1031  const OTIdentifier theNymID(m_str_nym_id);
1032  std::string str_using_acct;
1033 
1034  if (IsCheque()) {
1035  str_using_acct = m_str_account_id;
1036  }
1037  else {
1038  str_using_acct = str_via_acct;
1039  }
1040  if (str_using_acct.empty()) {
1041  otErr << __FUNCTION__ << ": Error: Missing account ID (FAILURE)\n";
1042  return false;
1043  }
1044  if (0 == m_lTransactionNum) {
1045  if (IsCash()) {
1046  // Maybe it's cash...
1047  std::string strOutpayment(
1049  m_str_nym_id, GetBoxIndex()));
1050 
1051  if (strOutpayment.empty()) {
1052  int32_t lIndex = GetBoxIndex();
1053  otErr << __FUNCTION__
1054  << ": Error: Blank outpayment at index " << lIndex
1055  << "\n";
1056  return false;
1057  }
1058  OTString strPayment(strOutpayment);
1059  OTPayment thePayment(strPayment);
1060 
1061  if (!thePayment.IsValid() || !thePayment.SetTempValues()) {
1062  int32_t lIndex = GetBoxIndex();
1063  otErr << __FUNCTION__
1064  << ": Error: Invalid outpayment at index " << lIndex
1065  << "\n";
1066  return false;
1067  }
1068  int64_t lTransNum = 0;
1069  thePayment.GetOpeningNum(lTransNum, theNymID);
1070  if (0 == lTransNum) // Found it.
1071  {
1072  int32_t lIndex = GetBoxIndex();
1073  OTString strIndices;
1074  strIndices.Format("%d", lIndex);
1075  const std::string str_indices(strIndices.Get());
1076  OT_ME madeEasy;
1077 
1078  return madeEasy.cancel_outgoing_payments(
1079  m_str_nym_id, str_using_acct, str_indices);
1080  }
1081  else {
1082  otErr << __FUNCTION__
1083  << ": Error: Transaction number is non-zero ("
1084  << lTransNum
1085  << "), for cash outgoing payment for nym id ("
1086  << m_str_nym_id << ")\n";
1087  return false;
1088  }
1089  } // IsCash()
1090  else {
1091  otErr << __FUNCTION__ << ": Error: Transaction number is 0, "
1092  "for non-cash outgoing payment for "
1093  "nym id (" << m_str_nym_id << ")\n";
1094  return false;
1095  }
1096  }
1097  // Find the payment in the Nym's outpayments box that correlates to this
1098  // OTRecord.
1099  //
1100  int32_t nCount = OTAPI_Wrap::GetNym_OutpaymentsCount(m_str_nym_id);
1101 
1102  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
1103  std::string strOutpayment(
1105  nIndex));
1106 
1107  if (strOutpayment.empty()) {
1108  otErr << __FUNCTION__ << ": Error: Blank outpayment at index "
1109  << nIndex << "\n";
1110  return false;
1111  }
1112  OTString strPayment(strOutpayment);
1113  OTPayment thePayment(strPayment);
1114 
1115  if (!thePayment.IsValid() || !thePayment.SetTempValues()) {
1116  otErr << __FUNCTION__ << ": Error: Invalid outpayment at index "
1117  << nIndex << "\n";
1118  return false;
1119  }
1120  int64_t lTransNum = 0;
1121  thePayment.GetOpeningNum(lTransNum, theNymID);
1122  if (lTransNum == m_lTransactionNum) // Found it.
1123  {
1124  OTString strIndices;
1125  strIndices.Format("%d", nIndex);
1126  const std::string str_indices(strIndices.Get());
1127  OT_ME madeEasy;
1128 
1129  return madeEasy.cancel_outgoing_payments(
1130  m_str_nym_id, str_using_acct, str_indices);
1131  }
1132  } // for
1133  } break;
1134  default:
1135  otErr << __FUNCTION__ << ": Unexpected type: " << GetInstrumentType()
1136  << "\n";
1137  return false;
1138  }
1139 
1140  return true;
1141 }
1143 {
1144  return m_lTransactionNum;
1145 } // Trans Num of receipt in the box. (Unless outpayment, contains number for
1146  // instrument.)
1147 void OTRecord::SetTransactionNum(int64_t lTransNum)
1148 {
1149  m_lTransactionNum = lTransNum;
1150 }
1152 {
1153  if (m_lTransNumForDisplay > 0) return m_lTransNumForDisplay;
1154 
1155  return m_lTransactionNum;
1156 }
1157 void OTRecord::SetTransNumForDisplay(int64_t lTransNum)
1158 {
1159  m_lTransNumForDisplay = lTransNum;
1160 }
1162 {
1163  m_bIsExpired = true;
1164 }
1166 {
1167  m_bIsCanceled = true;
1168 }
1169 bool OTRecord::IsMail() const
1170 {
1171  return OTRecord::Mail == GetRecordType();
1172 }
1174 {
1175  return m_bIsPending;
1176 }
1178 {
1179  return m_bIsOutgoing;
1180 }
1182 {
1183  return m_bIsRecord;
1184 }
1186 {
1187  return m_bIsReceipt;
1188 }
1190 {
1191  return !m_str_contents.empty();
1192 }
1193 bool OTRecord::HasMemo() const
1194 {
1195  return !m_str_memo.empty();
1196 }
1198 {
1199  return m_bIsExpired;
1200 }
1202 {
1203  return m_bIsCanceled;
1204 }
1205 const std::string& OTRecord::GetServerID() const
1206 {
1207  return m_str_server_id;
1208 }
1209 const std::string& OTRecord::GetAssetID() const
1210 {
1211  return m_str_asset_id;
1212 }
1213 const std::string& OTRecord::GetCurrencyTLA() const
1214 {
1215  return m_str_currency_tla;
1216 }
1217 const std::string& OTRecord::GetNymID() const
1218 {
1219  return m_str_nym_id;
1220 }
1221 const std::string& OTRecord::GetAccountID() const
1222 {
1223  return m_str_account_id;
1224 }
1225 const std::string& OTRecord::GetOtherNymID() const
1226 {
1227  return m_str_other_nym_id;
1228 }
1229 const std::string& OTRecord::GetOtherAccountID() const
1230 {
1231  return m_str_other_account_id;
1232 }
1233 const std::string& OTRecord::GetName() const
1234 {
1235  return m_str_name;
1236 }
1237 const std::string& OTRecord::GetDate() const
1238 {
1239  return m_str_date;
1240 }
1241 const std::string& OTRecord::GetAmount() const
1242 {
1243  return m_str_amount;
1244 }
1245 const std::string& OTRecord::GetInstrumentType() const
1246 {
1247  return m_str_type;
1248 }
1249 const std::string& OTRecord::GetMemo() const
1250 {
1251  return m_str_memo;
1252 }
1253 const std::string& OTRecord::GetContents() const
1254 {
1255  return m_str_contents;
1256 }
1258 {
1259  return m_bIsSpecialMail;
1260 }
1261 int32_t OTRecord::GetMethodID() const
1262 {
1263  return m_nMethodID;
1264 }
1265 const std::string& OTRecord::GetAddress() const
1266 {
1267  return m_str_my_address;
1268 }
1269 const std::string& OTRecord::GetOtherAddress() const
1270 {
1271  return m_str_other_address;
1272 }
1273 const std::string& OTRecord::GetMsgID() const
1274 {
1275  return m_str_msg_id;
1276 }
1277 const std::string& OTRecord::GetMsgType() const
1278 {
1279  return m_str_msg_type;
1280 }
1281 const std::string& OTRecord::GetMsgTypeDisplay() const
1282 {
1283  return m_str_msg_type_display;
1284 }
1285 void OTRecord::SetSpecialMail(bool bIsSpecial)
1286 {
1287  m_bIsSpecialMail = bIsSpecial;
1288 }
1289 void OTRecord::SetMethodID(int32_t nMethodID)
1290 {
1291  m_nMethodID = nMethodID;
1292 }
1293 void OTRecord::SetAddress(const std::string& str_Address)
1294 {
1295  m_str_my_address = str_Address;
1296 }
1297 void OTRecord::SetOtherAddress(const std::string& str_Address)
1298 {
1299  m_str_other_address = str_Address;
1300 }
1301 void OTRecord::SetMsgID(const std::string& str_id)
1302 {
1303  m_str_msg_id = str_id;
1304 }
1305 void OTRecord::SetMsgType(const std::string& str_type)
1306 {
1307  m_str_msg_type = str_type;
1308 }
1309 void OTRecord::SetMsgTypeDisplay(const std::string& str_type)
1310 {
1311  m_str_msg_type_display = str_type;
1312 }
1313 int32_t OTRecord::GetBoxIndex() const
1314 {
1315  return m_nBoxIndex;
1316 }
1317 void OTRecord::SetBoxIndex(int32_t nBoxIndex)
1318 {
1319  m_nBoxIndex = nBoxIndex;
1320 }
1321 void OTRecord::SetMemo(const std::string& str_memo)
1322 {
1323  m_str_memo = str_memo;
1324 }
1325 void OTRecord::SetOtherNymID(const std::string& str_ID)
1326 {
1327  m_str_other_nym_id = str_ID;
1328 }
1329 void OTRecord::SetOtherAccountID(const std::string& str_ID)
1330 {
1331  m_str_other_account_id = str_ID;
1332 }
1333 void OTRecord::SetContents(const std::string& str_contents)
1334 {
1335  m_str_contents = str_contents;
1336 
1337  if (!m_str_contents.empty() && (OTRecord::Instrument == GetRecordType())) {
1338  OTString strPayment(m_str_contents);
1339  OTPayment thePayment(strPayment);
1340 
1341  if (thePayment.IsValid() && thePayment.SetTempValues()) {
1342  switch (thePayment.GetType()) {
1343  case OTPayment::PURSE:
1344  m_bIsCash = true;
1345  break;
1346  case OTPayment::CHEQUE:
1347  m_bIsCheque = true;
1348  break;
1349  case OTPayment::VOUCHER:
1350  m_bIsVoucher = true;
1351  break;
1352  case OTPayment::INVOICE:
1353  m_bIsInvoice = true;
1354  break;
1356  m_bIsPaymentPlan = true;
1357  break;
1359  m_bIsSmartContract = true;
1360  break;
1361 
1362  default:
1363  break;
1364  }
1365  }
1366  }
1367 }
1369 {
1370  return m_ValidFrom;
1371 }
1373 {
1374  return m_ValidTo;
1375 }
1376 void OTRecord::SetDateRange(time64_t tValidFrom, time64_t tValidTo)
1377 {
1378  m_ValidFrom = tValidFrom;
1379  m_ValidTo = tValidTo;
1380  time64_t tCurrentTime = OTAPI_Wrap::GetTime();
1381  if ((tValidTo > OT_TIME_ZERO) && (tCurrentTime > tValidTo) && !IsMail() &&
1382  !IsRecord())
1383  SetExpired();
1384 }
1386 {
1387  return m_ValidFrom < rhs.m_ValidFrom;
1388 }
1389 OTRecord::OTRecord(const std::string& str_server_id,
1390  const std::string& str_asset_id,
1391  const std::string& str_currency_tla,
1392  const std::string& str_nym_id,
1393  const std::string& str_account_id,
1394  const std::string& str_name, const std::string& str_date,
1395  const std::string& str_amount, const std::string& str_type,
1396  bool bIsPending, bool bIsOutgoing, bool bIsRecord,
1397  bool bIsReceipt, OTRecordType eRecordType)
1398  : m_nBoxIndex(-1)
1399  , m_ValidFrom(OT_TIME_ZERO)
1400  , m_ValidTo(OT_TIME_ZERO)
1401  , m_str_server_id(str_server_id)
1402  , m_str_asset_id(str_asset_id)
1403  , m_str_currency_tla(str_currency_tla)
1404  , m_str_nym_id(str_nym_id)
1405  , m_str_account_id(str_account_id)
1406  , m_str_name(str_name)
1407  , m_str_date(str_date)
1408  , m_str_amount(str_amount)
1409  , m_str_type(str_type)
1410  , m_bIsSpecialMail(false)
1411  , m_nMethodID(0)
1412  , m_lTransactionNum(0)
1413  , m_lTransNumForDisplay(0)
1414  , m_bIsPending(bIsPending)
1415  , m_bIsOutgoing(bIsOutgoing)
1416  , m_bIsRecord(bIsRecord)
1417  , m_bIsReceipt(bIsReceipt)
1418  , m_bIsPaymentPlan(false)
1419  , m_bIsSmartContract(false)
1420  , m_bIsVoucher(false)
1421  , m_bIsCheque(false)
1422  , m_bIsInvoice(false)
1423  , m_bIsCash(false)
1424  , m_bIsExpired(false)
1425  , m_bIsCanceled(false)
1426  , m_RecordType(eRecordType)
1427 {
1428 }
1429 
1430 } // namespace opentxs
int32_t GetMaximumNoPayments() const
EXPORT bool HasPaymentPlan() const
Definition: OTRecord.cpp:443
const time64_t & GetTimeBetweenPayments() const
EXPORT const std::string & GetMsgType() const
Definition: OTRecord.cpp:1277
EXPORT int64_t GetPaymentPlanAmount() const
Definition: OTRecord.cpp:503
bool HasPaymentPlan() const
EXPORT OTLedger * LoadRecordBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool IsCheque() const
Definition: OTRecord.cpp:998
EXPORT const std::string & GetCurrencyTLA() const
Definition: OTRecord.cpp:1213
EXPORT time64_t GetValidFrom() const
Definition: OTRecord.cpp:1368
EXPORT int32_t GetMaximumNoPayments() const
Definition: OTRecord.cpp:515
const time64_t & GetInitialPaymentDate() const
EXPORT bool CanAcceptIncoming() const
Definition: OTRecord.cpp:546
EXPORT time64_t GetTimeBetweenPayments() const
Definition: OTRecord.cpp:491
EXPORT int64_t GetInitialPaymentAmount() const
Definition: OTRecord.cpp:467
EXPORT OTLedger * LoadInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool CanDeleteRecord() const
Definition: OTRecord.cpp:532
EXPORT bool discard_incoming_payments(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &INDICES) const
Definition: OT_ME.cpp:530
static EXPORT std::string GetNym_OutmailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:728
EXPORT void SetContents(const std::string &str_contents)
Definition: OTRecord.cpp:1333
EXPORT int64_t GetTransactionNum() const
Definition: OTRecord.cpp:1142
EXPORT void SetTransactionNum(int64_t lTransNum)
Definition: OTRecord.cpp:1147
EXPORT bool IsSpecialMail() const
Definition: OTRecord.cpp:1257
const int64_t & GetInitialPaymentAmount() const
EXPORT const std::string & GetOtherAddress() const
Definition: OTRecord.cpp:1269
static EXPORT OTAPI_Exec * It()
Definition: OTAPI.cpp:174
EXPORT bool DiscardOutgoingCash() const
Definition: OTRecord.cpp:646
EXPORT void SetSpecialMail(bool bIsSpecial=true)
Definition: OTRecord.cpp:1285
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
EXPORT bool IsMail() const
Definition: OTRecord.cpp:1169
static EXPORT bool ClearRecord(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const int32_t &nIndex, const bool &bClearAll)
Definition: OTAPI.cpp:1599
static EXPORT std::string GetNym_MailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:693
EXPORT OTLedger * LoadPaymentInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool IsOutgoing() const
Definition: OTRecord.cpp:1177
EXPORT int64_t StringToLong(const std::string &strNumber) const
Definition: OTAPI_Exec.cpp:286
int64_t time64_t
Definition: Common.hpp:209
EXPORT bool GetOpeningNum(int64_t &lOutput, const OTIdentifier &theNymID) const
Definition: OTPayment.cpp:744
EXPORT void SetExpired()
Definition: OTRecord.cpp:1161
EXPORT const std::string & GetMsgTypeDisplay() const
Definition: OTRecord.cpp:1281
EXPORT void SetDateRange(time64_t tValidFrom, time64_t tValidTo)
Definition: OTRecord.cpp:1376
EXPORT const std::string & GetAccountID() const
Definition: OTRecord.cpp:1221
EXPORT time64_t GetInitialPaymentDate() const
Definition: OTRecord.cpp:455
EXPORT bool IsCash() const
Definition: OTRecord.cpp:990
bool HasInitialPayment() const
EXPORT int32_t GetBoxIndex() const
Definition: OTRecord.cpp:1313
EXPORT void SetMsgTypeDisplay(const std::string &str_type)
Definition: OTRecord.cpp:1309
EXPORT bool FormatDescription(std::string &str_output) const
Definition: OTRecord.cpp:235
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:758
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
EXPORT time64_t GetValidTo() const
Definition: OTRecord.cpp:1372
EXPORT void SetTransNumForDisplay(int64_t lTransNum)
Definition: OTRecord.cpp:1157
EXPORT bool HasMemo() const
Definition: OTRecord.cpp:1193
EXPORT int32_t GetTransactionIndex(int64_t lTransactionNum)
Definition: OTLedger.cpp:1230
EXPORT void SetOtherAddress(const std::string &str_Address)
Definition: OTRecord.cpp:1297
EXPORT const std::string & GetOtherAccountID() const
Definition: OTRecord.cpp:1229
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
EXPORT OTRecordType GetRecordType() const
Definition: OTRecord.cpp:526
static EXPORT bool Nym_RemoveOutpaymentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:781
EXPORT bool FormatMailSubject(std::string &str_output) const
Definition: OTRecord.cpp:167
EXPORT bool FormatShortMailDescription(std::string &str_output) const
Definition: OTRecord.cpp:198
const time64_t & GetPaymentPlanStartDate() const
EXPORT bool IsTransfer() const
Definition: OTRecord.cpp:986
EXPORT void SetMemo(const std::string &str_memo)
Definition: OTRecord.cpp:1321
EXPORT bool HasInitialPayment() const
Definition: OTRecord.cpp:431
static EXPORT bool Nym_RemoveOutmailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:746
EXPORT void SetMsgID(const std::string &str_id)
Definition: OTRecord.cpp:1301
EXPORT bool IsRecord() const
Definition: OTRecord.cpp:1181
EXPORT const std::string & GetAmount() const
Definition: OTRecord.cpp:1241
EXPORT bool IsCanceled() const
Definition: OTRecord.cpp:1201
EXPORT bool SetTempValues()
Definition: OTPayment.cpp:196
static EXPORT int32_t GetNym_OutmailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:723
EXPORT time64_t GetPaymentPlanStartDate() const
Definition: OTRecord.cpp:479
EXPORT const std::string & GetMemo() const
Definition: OTRecord.cpp:1249
const int64_t & GetPaymentPlanAmount() const
EXPORT const char * Get() const
Definition: OTString.cpp:1045
EXPORT void SetOtherNymID(const std::string &str_ID)
Definition: OTRecord.cpp:1325
OTLOG_IMPORT OTLogStream otErr
EXPORT const std::string & GetAssetID() const
Definition: OTRecord.cpp:1209
EXPORT const std::string & GetDate() const
Definition: OTRecord.cpp:1237
EXPORT bool IsInvoice() const
Definition: OTRecord.cpp:994
EXPORT bool IsExpired() const
Definition: OTRecord.cpp:1197
EXPORT void SetBoxIndex(int32_t nBoxIndex)
Definition: OTRecord.cpp:1317
bool operator<(const OTRecord &rhs)
Definition: OTRecord.cpp:1385
EXPORT bool FormatAmount(std::string &str_output) const
Definition: OTRecord.cpp:153
EXPORT bool IsValid() const
Definition: OTPayment.hpp:301
EXPORT const std::string & GetMsgID() const
Definition: OTRecord.cpp:1273
EXPORT bool CanCancelOutgoing() const
Definition: OTRecord.cpp:618
EXPORT bool IsPaymentPlan() const
Definition: OTRecord.cpp:1010
EXPORT bool AcceptIncomingInstrument(const std::string &str_into_acct) const
Definition: OTRecord.cpp:854
EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT) const
EXPORT const std::string & GetContents() const
Definition: OTRecord.cpp:1253
EXPORT bool HasContents() const
Definition: OTRecord.cpp:1189
EXPORT const std::string & GetInstrumentType() const
Definition: OTRecord.cpp:1245
EXPORT bool CanDiscardIncoming() const
Definition: OTRecord.cpp:578
EXPORT bool IsPending() const
Definition: OTRecord.cpp:1173
EXPORT bool CanDiscardOutgoingCash() const
Definition: OTRecord.cpp:601
EXPORT bool IsReceipt() const
Definition: OTRecord.cpp:1185
EXPORT bool AcceptIncomingTransfer() const
Definition: OTRecord.cpp:776
static EXPORT OT_API * OTAPI()
Definition: OTAPI.cpp:244
EXPORT int32_t GetMethodID() const
Definition: OTRecord.cpp:1261
static EXPORT std::string & trim(std::string &str)
Definition: OTString.cpp:398
EXPORT bool DiscardIncoming() const
Definition: OTRecord.cpp:924
EXPORT void SetCanceled()
Definition: OTRecord.cpp:1165
static EXPORT std::string GetNym_OutpaymentsContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:763
EXPORT bool LoadContractFromString(const OTString &theStr)
EXPORT void SetMethodID(int32_t nMethodID)
Definition: OTRecord.cpp:1289
#define OT_TIME_ZERO
Definition: Common.hpp:180
EXPORT void SetAddress(const std::string &str_Address)
Definition: OTRecord.cpp:1293
EXPORT const std::string & GetOtherNymID() const
Definition: OTRecord.cpp:1225
EXPORT paymentType GetType() const
Definition: OTPayment.hpp:306
EXPORT bool AcceptIncomingReceipt() const
Definition: OTRecord.cpp:780
static EXPORT int32_t GetNym_MailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:688
EXPORT bool DeleteRecord() const
Definition: OTRecord.cpp:655
EXPORT int64_t GetTransNumForDisplay() const
Definition: OTRecord.cpp:1151
EXPORT const std::string & GetAddress() const
Definition: OTRecord.cpp:1265
EXPORT const std::string & GetName() const
Definition: OTRecord.cpp:1233
EXPORT const std::string & GetNymID() const
Definition: OTRecord.cpp:1217
EXPORT bool CancelOutgoing(std::string str_via_acct) const
Definition: OTRecord.cpp:1016
EXPORT bool IsVoucher() const
Definition: OTRecord.cpp:1002
static EXPORT bool Nym_RemoveMailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:711
EXPORT bool cancel_outgoing_payments(const std::string &NYM_ID, const std::string &ACCOUNT_ID, const std::string &INDICES) const
Definition: OT_ME.cpp:538
EXPORT const std::string & GetServerID() const
Definition: OTRecord.cpp:1205
EXPORT void SetMsgType(const std::string &str_type)
Definition: OTRecord.cpp:1305
OTRecord(const std::string &str_server_id, const std::string &str_asset_id, const std::string &str_currency_tla, const std::string &str_nym_id, const std::string &str_account_id, const std::string &str_name, const std::string &str_date, const std::string &str_amount, const std::string &str_type, bool bIsPending, bool bIsOutgoing, bool bIsRecord, bool bIsReceipt, OTRecordType eRecordType)
Definition: OTRecord.cpp:1389
EXPORT void SetOtherAccountID(const std::string &str_ID)
Definition: OTRecord.cpp:1329
EXPORT bool IsContract() const
Definition: OTRecord.cpp:1006