Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTOffer.cpp
Go to the documentation of this file.
1 /************************************************************
2  *
3  * OTOffer.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 "trade/OTOffer.hpp"
136 #include "OTLog.hpp"
137 
138 #include <irrxml/irrXML.hpp>
139 
140 // Each instance of OTOffer represents a Bid or Ask. (A Market has a list of bid
141 // offers and a list of ask offers.)
142 
143 // Also allows for x == 1.
144 //
145 
146 namespace opentxs
147 {
148 
149 bool isPowerOfTen(const int64_t& x)
150 {
151  if (1 == x) return true;
152 
153  const int64_t lBase = 10;
154  int64_t lIt = lBase;
155 
156  for (int32_t i = 1; i < 23; i++) {
157  if (x == lIt) return true;
158  lIt *= lBase;
159  }
160 
161  return false;
162 }
163 
164 /*
165  Let's say you wanted to add an Offer to a Market. But you don't know
166  which market. There are different markets for different combinations
167  of asset and currency. There are also higher and lower level markets
168  for different trade minimums.
169 
170  The server has to be able to match up your Offer to the Right Market,
171  so that it can trade with similar offers.
172 
173  So in this method, I combine the Asset Type ID, the Currency Type ID,
174  and the minimum increment, and use them to generate a UNIQUE ID, which
175  will also be the same, given the same input.
176 
177  That is the ID I will use for looking up the offers on the market.
178  Basically it's the Market ID, and the Offer just has the SAME ID,
179  and that's how you match it up to the market.
180 
181  (This is analogous to how Transactions and Transaction Items have the
182  same transaction number.)
183 
184  THIS MEANS that the user cannot simply set his minimum increment to
185  a "divide-into equally" with the market minimum increment. Why not?
186  Because since his number will be different from the next guy, they
187  will calculate different IDs and thus end up on different markets.
188 
189  TODO: therefore the user MUST SUPPLY the EXACT SAME minimum increment
190  of the market he wishes to trade on. There's no other way. However,
191  I CAN allow the user to ALSO provide a second minimum, which must be
192  a multiple of the first.
193 
194  TODO: Should add this same method to the Market object as well.
195 
196 
197  To use OTOffer::GetIdentifier is simple:
198 
199  void blah (OTOffer& theOffer)
200  {
201  OTIdentifier MARKET_ID(theOffer); // the magic happens right here.
202 
203  // (Done.)
204  }
205  */
206 void OTOffer::GetIdentifier(OTIdentifier& theIdentifier) const
207 {
208  OTString strTemp, strAsset(GetAssetID()), strCurrency(GetCurrencyID());
209 
210  int64_t lScale = GetScale();
211 
212  // In this way we generate a unique ID that will always be consistent
213  // for the same asset ID, currency ID, and market scale.
214  strTemp.Format("ASSET TYPE:\n%s\nCURRENCY TYPE:\n%s\nMARKET SCALE:\n%lld\n",
215  strAsset.Get(), strCurrency.Get(), lScale);
216 
217  theIdentifier.CalculateDigest(strTemp);
218 }
219 
221 {
222  return (0 == GetPriceLimit());
223 }
224 
226 {
227  return (0 != GetPriceLimit());
228 }
229 
230 // return -1 if error, 0 if nothing, and 1 if the node was processed.
232 {
233  int32_t nReturnVal = 0;
234 
235  // Here we call the parent class first.
236  // If the node is found there, or there is some error,
237  // then we just return either way. But if it comes back
238  // as '0', then nothing happened, and we'll continue executing.
239  //
240  // -- Note you can choose not to call the parent if
241  // you don't want to use any of those xml tags.
242  // As I do below, in the case of OTAccount.
243  // if (nReturnVal = OTContract::ProcessXMLNode(xml))
244  // return nReturnVal;
245 
246  if (!strcmp("marketOffer", xml->getNodeName())) {
247  m_strVersion = xml->getAttributeValue("version");
248 
249  OTString strIsSelling;
250  strIsSelling = xml->getAttributeValue("isSelling");
251  if (strIsSelling.Compare("true"))
252  m_bSelling = true;
253  else
254  m_bSelling = false;
255 
256  m_strContractType.Set((m_bSelling ? "ASK" : "BID"));
257 
258  const OTString strServerID(xml->getAttributeValue("serverID")),
259  strAssetTypeID(xml->getAttributeValue("assetTypeID")),
260  strCurrencyTypeID(xml->getAttributeValue("currencyTypeID"));
261 
262  const OTIdentifier SERVER_ID(strServerID), ASSET_ID(strAssetTypeID),
263  CURRENCY_TYPE_ID(strCurrencyTypeID);
264 
265  SetServerID(SERVER_ID);
266  SetAssetID(ASSET_ID);
267  SetCurrencyID(CURRENCY_TYPE_ID);
268 
269  const OTString strScale = xml->getAttributeValue("marketScale");
270  const int64_t lScale = strScale.Exists() ? atol(strScale.Get())
271  : 0; // if it doesn't exist,
272  // the 0 here causes the
273  // below error to fire.
274 
275  if (!isPowerOfTen(lScale)) {
276  otOut << "OTOffer::ProcessXMLNode: Failure: marketScale *must* be "
277  "1, or a power of 10. Instead I got: " << lScale << ".\n";
278  return (-1);
279  }
280  else
281  SetScale(lScale);
282 
283  const OTString strPriceLimit = xml->getAttributeValue("priceLimit");
284  const int64_t lPriceLimit = strPriceLimit.Exists()
285  ? atol(strPriceLimit.Get())
286  : 0; // if it doesn't exist, the 0 here
287  // causes the below error to fire.
288 
289  // NOTE: Market Orders (new) have a 0 price, so this error condition was
290  // changed.
291  if (!strPriceLimit.Exists())
292  // if (lPriceLimit < 1)
293  {
294  otOut << "OTOffer::ProcessXMLNode: Failure: priceLimit *must* be "
295  "provided(" << lPriceLimit << ").\n";
296  return (-1);
297  }
298  else
299  SetPriceLimit(lPriceLimit);
300 
301  const OTString strTotal = xml->getAttributeValue("totalAssetsOnOffer");
302  const int64_t lTotal = strTotal.Exists() ? atol(strTotal.Get())
303  : 0; // if it doesn't exist,
304  // the 0 here causes the
305  // below error to fire.
306  if (lTotal < 1) {
307  otOut << "OTOffer::ProcessXMLNode: Failure: totalAssetsOnOffer "
308  "*must* be larger than 0. Instead I got: " << lTotal
309  << ".\n";
310  return (-1);
311  }
312  else
313  SetTotalAssetsOnOffer(lTotal);
314 
315  const OTString strFinished = xml->getAttributeValue("finishedSoFar");
316  const int64_t lFinished = strFinished.Exists()
317  ? atol(strFinished.Get())
318  : 0; // if it doesn't exist, the 0 here
319  // causes the below error to fire.
320  if (lFinished < 0) {
321  otOut << "OTOffer::ProcessXMLNode: Failure: finishedSoFar *must* "
322  "be 0 or larger. Instead I got: " << lFinished << ".\n";
323  return (-1);
324  }
325  else
326  SetFinishedSoFar(lFinished);
327 
328  const OTString strMinInc = xml->getAttributeValue("minimumIncrement");
329  const int64_t lMinInc = strMinInc.Exists() ? atol(strMinInc.Get())
330  : 0; // if it doesn't exist,
331  // the 0 here causes the
332  // below error to fire.
333  if ((lMinInc < 1) || (lMinInc > lTotal)) // Minimum increment cannot
334  // logically be higher than the
335  // total assets on offer...
336  {
337  otOut << "OTOffer::ProcessXMLNode: Failure: minimumIncrement "
338  "*must* be 1 or larger, \n"
339  "and must also be less than the total assets on offer. "
340  "Instead I got: " << lMinInc << ".\n";
341  return (-1);
342  }
343  else
344  SetMinimumIncrement(lMinInc);
345 
346  const OTString strTransNum = xml->getAttributeValue("transactionNum");
347  const int64_t lTransNum =
348  strTransNum.Exists() ? atol(strTransNum.Get()) : 0;
349 
350  SetTransactionNum(lTransNum);
351 
352  const OTString str_valid_from = xml->getAttributeValue("validFrom");
353  const OTString str_valid_to = xml->getAttributeValue("validTo");
354 
355  int64_t tValidFrom =
356  str_valid_from.Exists() ? str_valid_from.ToLong() : 0;
357  int64_t tValidTo = str_valid_to.Exists() ? str_valid_to.ToLong() : 0;
358 
359  if ((tValidTo < tValidFrom) && (tValidTo != 0)) {
360  otOut << "OTOffer::" << __FUNCTION__ << ": Failure: validTo date ("
361  << tValidFrom << ") cannot be earlier than "
362  "validFrom date (" << tValidTo << ").\n";
363  return (-1);
364  }
365 
368 
369  otLog4 << "\n\nOffer. Transaction Number: " << m_lTransactionNum
370  << "\n Valid From: " << tValidFrom << "\n Valid To: " << tValidTo
371  << "\n"
372  " AssetTypeID: " << strAssetTypeID
373  << "\n CurrencyTypeID: " << strCurrencyTypeID
374  << "\n ServerID: " << strServerID
375  << "\n"
376  " Price Limit: " << GetPriceLimit()
377  << ", Total Assets on Offer: " << GetTotalAssetsOnOffer()
378  << ", " << (m_bSelling ? "sold" : "bought")
379  << " so far: " << GetFinishedSoFar() << "\n "
380  " Scale: " << GetScale()
381  << ". Minimum Increment: " << GetMinimumIncrement()
382  << ". This offer is a" << (m_bSelling ? "n ASK" : " BID")
383  << ".\n";
384 
385  nReturnVal = 1;
386  }
387 
388  return nReturnVal;
389 }
390 
392 {
393  const OTString SERVER_ID(GetServerID()), ASSET_TYPE_ID(GetAssetID()),
394  CURRENCY_TYPE_ID(GetCurrencyID());
395 
396  const int64_t lFrom = OTTimeGetSecondsFromTime(GetValidFrom());
397  const int64_t lTo = OTTimeGetSecondsFromTime(GetValidTo());
398  const int64_t lPriceLimit = GetPriceLimit();
399  const int64_t lTotalAssetsOnOffer = GetTotalAssetsOnOffer();
400  const int64_t lFinishedSoFar = GetFinishedSoFar();
401  const int64_t lScale = GetScale();
402  const int64_t lMinimumIncrement = GetMinimumIncrement();
403  const int64_t lTransactionNum = GetTransactionNum();
404 
405  // I release this because I'm about to repopulate it.
407 
408  m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");
409 
411  "<marketOffer\n version=\"%s\"\n"
412  " isSelling=\"%s\"\n" // true or false.
413  " serverID=\"%s\"\n"
414  " assetTypeID=\"%s\"\n"
415  " currencyTypeID=\"%s\"\n"
416  " priceLimit=\"%lld\"\n"
417  " totalAssetsOnOffer=\"%lld\"\n"
418  " finishedSoFar=\"%lld\"\n"
419  " marketScale=\"%lld\"\n"
420  " minimumIncrement=\"%lld\"\n"
421  " transactionNum=\"%lld\"\n"
422  " validFrom=\"%" PRId64 "\"\n"
423  " validTo=\"%" PRId64 "\""
424  " />\n\n", // <=== the tag ends here.
425  m_strVersion.Get(),
426  (IsBid() ? "false" : "true"), SERVER_ID.Get(), ASSET_TYPE_ID.Get(),
427  CURRENCY_TYPE_ID.Get(), lPriceLimit, lTotalAssetsOnOffer,
428  lFinishedSoFar, lScale, lMinimumIncrement, lTransactionNum, lFrom, lTo);
429 
430  // m_xmlUnsigned.Concatenate("</marketOffer>\n"); // ^^^ Tag already
431  // ended above.
432 }
433 
435  bool bBuyingOrSelling, // True == SELLING, False == BUYING
436  const int64_t& lPriceLimit, // Per Minimum Increment... (Zero price means
437  // it's a market order.)
438  const int64_t& lTotalAssetsOffer, // Total assets available for sale or
439  // purchase.
440  const int64_t& lMinimumIncrement, // The minimum increment that must be
441  // bought or sold for each transaction
442  const int64_t& lTransactionNum, // The transaction number authorizing this
443  // trade.
444  const time64_t& VALID_FROM, // defaults to RIGHT NOW
445  const time64_t& VALID_TO) // defaults to 24 hours (a "Day Order")
446 {
447  m_bSelling = bBuyingOrSelling; // Bid or Ask?
448  SetTransactionNum(lTransactionNum);
449  SetTotalAssetsOnOffer(lTotalAssetsOffer); // 500 bushels for sale.
450 
451  m_strContractType.Set((m_bSelling ? "ASK" : "BID"));
452 
453  // Make sure minimum increment isn't bigger than total Assets.
454  // (If you pass them into this function as the same value, it's functionally
455  // a "FILL OR KILL" order.)
456  int64_t lRealMinInc = lMinimumIncrement;
457  if (lMinimumIncrement > lTotalAssetsOffer) // Once the total, minus finish
458  // so far, is smaller than the
459  // minimum increment,
460  lRealMinInc = lTotalAssetsOffer; // then the OTTrade object I am linked
461  // to will expire and remove me from
462  // the market.
463  // OR it could set the minimum increment to the remainder. But then need to
464  // calc price.
465 
466  SetMinimumIncrement(lRealMinInc); // Must sell in 50 bushel increments.
467  // (Perhaps on the 10-bushel market it
468  // will sell in 5 increments of 10.)
469  SetPriceLimit(lPriceLimit); // Won't sell for any less than $10 per
470  // increment. (Always get best market price.)
471  SetFinishedSoFar(0); // So far have already sold 350 bushels. Actual amount
472  // available is (total - finished).
473 
474  time64_t REAL_VALID_FROM = VALID_FROM;
475  time64_t REAL_VALID_TO = VALID_TO;
476 
477  if (OT_TIME_ZERO >= VALID_FROM) {
478  REAL_VALID_FROM =
479  OTTimeGetCurrentTime(); // This time is set to TODAY NOW
480  }
481 
482  if (OT_TIME_ZERO >= VALID_TO) {
483  // (All offers default to a "DAY ORDER" if valid dates not specified.)
484  REAL_VALID_TO = OTTimeAddTimeInterval(
485  REAL_VALID_FROM,
487  }
488 
489  SetValidFrom(REAL_VALID_FROM);
490  SetValidTo(REAL_VALID_TO);
491 
492  return true;
493 }
494 
495 // Note: m_tDateAddedToMarket is not saved in the Offer Contract, but OTMarket
496 // sets/saves/loads it.
497 //
498 time64_t OTOffer::GetDateAddedToMarket() const // Used in OTMarket::GetOfferList
499  // and GetNymOfferList.
500 {
501  return m_tDateAddedToMarket;
502 }
503 
504 void OTOffer::SetDateAddedToMarket(time64_t tDate) // Used in OTCron when
505  // adding/loading offers.
506 {
507  m_tDateAddedToMarket = tDate;
508 }
509 
511  : ot_super()
512  , m_tDateAddedToMarket(OT_TIME_ZERO)
513  , m_pTrade(nullptr)
514  , // No need to free m_pTrade, not responsible. Only here for convenience.
515  m_bSelling(false)
516  , m_lPriceLimit(0)
517  , m_lTransactionNum(0)
518  , m_lTotalAssetsOffer(0)
519  , m_lFinishedSoFar(0)
520  , m_lScale(1)
521  , // This must be 1 or greater. CANNOT be zero. Enforced.
522  m_lMinimumIncrement(
523  1) // This must be 1 or greater. CANNOT be zero. Enforced.
524 {
525  InitOffer();
526 }
527 
528 OTOffer::OTOffer(const OTIdentifier& SERVER_ID, const OTIdentifier& ASSET_ID,
529  const OTIdentifier& CURRENCY_ID, const int64_t& lScale)
530  : ot_super(SERVER_ID, ASSET_ID)
531  , m_tDateAddedToMarket(OT_TIME_ZERO)
532  , m_pTrade(nullptr)
533  , // No need to free m_pTrade, not responsible. Only here for convenience.
534  m_bSelling(false)
535  , m_lPriceLimit(0)
536  , m_lTransactionNum(0)
537  , m_lTotalAssetsOffer(0)
538  , m_lFinishedSoFar(0)
539  , m_lScale(1)
540  , // This must be 1 or greater. CANNOT be zero. Enforced.
541  m_lMinimumIncrement(
542  1) // This must be 1 or greater. CANNOT be zero. Enforced.
543 {
544  InitOffer();
545 
546  SetScale(lScale);
547 
548  m_CURRENCY_TYPE_ID = CURRENCY_ID;
549 }
550 
552 {
553  Release_Offer();
554 }
555 
557 {
558  // If there were any dynamically allocated objects, clean them up here.
560 }
561 
563 {
564  // If there were any dynamically allocated objects, clean them up here.
565  Release_Offer();
566 
567  ot_super::Release(); // since I've overridden the base class, I call it
568  // now...
569 
570  // Then I call this to re-initialize everything
571  InitOffer();
572 }
573 
575 {
577  "OFFER"); // in practice should never appear. BID/ASK will overwrite.
578 
579  // This pointer will get wiped anytime Release() is called... which means
580  // anytime LoadContractFromString()
581  // is called. For some objects, that screws them up because suddenly the
582  // pointer went nullptr when they needed it.
583  // In the case of this object, the pointer is reset whenever Cron processes,
584  // so this is safe. But in
585  // the case of other objects, it's better not to initialize the pointer
586  // here, but in the constructor instead.
587  // FYI. For example, OTCron has a pointer to m_pServerNym. LoadCron() and
588  // the pointer is nullptr. Can't have that!
589  // So I moved it to the constructor in that case.
590 
591  m_bSelling = false;
592  m_lPriceLimit = 0;
593  m_lTransactionNum = 0;
595  m_lFinishedSoFar = 0;
596  m_lMinimumIncrement = 1; // This must be 1 or greater. Enforced.
597  SetScale(1); // This must be 1 or greater. Enforced.
598 }
599 
600 bool OTOffer::SaveContractWallet(std::ofstream&) const
601 {
602  return true;
603 }
604 
605 } // namespace opentxs
int64_t m_lFinishedSoFar
Definition: OTOffer.hpp:216
void SetFinishedSoFar(const int64_t &lFinishedSoFar)
Definition: OTOffer.hpp:240
const int64_t & GetMinimumIncrement()
Definition: OTOffer.hpp:294
OTLOG_IMPORT OTLogStream otLog4
virtual EXPORT void Release()
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
Definition: OTOffer.cpp:231
EXPORT time64_t GetDateAddedToMarket() const
Definition: OTOffer.cpp:498
EXPORT bool CalculateDigest(const OTData &dataInput)
int64_t m_lTransactionNum
Definition: OTOffer.hpp:213
EXPORT bool MakeOffer(bool bBuyingOrSelling, const int64_t &lPriceLimit, const int64_t &lTotalAssetsOffer, const int64_t &lMinimumIncrement, const int64_t &lTransactionNum, const time64_t &VALID_FROM=OT_TIME_ZERO, const time64_t &VALID_TO=OT_TIME_ZERO)
Definition: OTOffer.cpp:434
time64_t GetValidTo() const
bool IsMarketOrder() const
Definition: OTOffer.cpp:220
void SetValidFrom(time64_t TIME_FROM)
const int64_t & GetScale() const
Definition: OTOffer.hpp:299
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
Definition: Common.hpp:238
EXPORT int64_t ToLong() const
Definition: OTString.cpp:702
void InitOffer()
Definition: OTOffer.cpp:574
const OTIdentifier & GetAssetID() const
bool IsLimitOrder() const
Definition: OTOffer.cpp:225
const OTIdentifier & GetCurrencyID() const
Definition: OTOffer.hpp:304
virtual void UpdateContents()
Definition: OTOffer.cpp:391
OTLOG_IMPORT OTLogStream otOut
void SetTransactionNum(const int64_t &lTransactionNum)
Definition: OTOffer.hpp:228
virtual void Release()
Definition: OTOffer.cpp:562
void SetCurrencyID(const OTIdentifier &CURRENCY_ID)
Definition: OTOffer.hpp:308
void SetValidTo(time64_t TIME_TO)
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
Definition: Common.hpp:215
void SetAssetID(const OTIdentifier &ASSET_ID)
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
int64_t time64_t
Definition: Common.hpp:209
EXPORT bool Exists() const
Definition: OTString.cpp:1035
virtual void GetIdentifier(OTIdentifier &theIdentifier) const
Definition: OTOffer.cpp:206
const int64_t & GetTotalAssetsOnOffer() const
Definition: OTOffer.hpp:286
const OTIdentifier & GetServerID() const
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
#define OT_TIME_DAY_IN_SECONDS
Definition: Common.hpp:176
time64_t GetValidFrom() const
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
const int64_t & GetFinishedSoFar() const
Definition: OTOffer.hpp:290
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
time64_t OTTimeGetCurrentTime()
Definition: Common.hpp:211
void Release_Offer()
Definition: OTOffer.cpp:556
EXPORT void SetDateAddedToMarket(time64_t tDate)
Definition: OTOffer.cpp:504
OTString m_strContractType
Definition: OTContract.hpp:178
const int64_t & GetTransactionNum() const
Definition: OTOffer.hpp:277
bool isPowerOfTen(const int64_t &x)
Definition: OTOffer.cpp:149
virtual bool SaveContractWallet(std::ofstream &ofs) const
Definition: OTOffer.cpp:600
void SetScale(const int64_t &lScale)
Definition: OTOffer.hpp:249
OTStringXML m_xmlUnsigned
Definition: OTContract.hpp:174
EXPORT const char * Get() const
Definition: OTString.cpp:1045
int64_t m_lTotalAssetsOffer
Definition: OTOffer.hpp:214
void SetServerID(const OTIdentifier &SERVER_ID)
void SetTotalAssetsOnOffer(const int64_t &lTotalAssets)
Definition: OTOffer.hpp:236
void SetMinimumIncrement(const int64_t &lMinIncrement)
Definition: OTOffer.hpp:244
void SetPriceLimit(const int64_t &lPriceLimit)
Definition: OTOffer.hpp:232
OTIdentifier m_CURRENCY_TYPE_ID
Definition: OTOffer.hpp:201
int64_t m_lPriceLimit
Definition: OTOffer.hpp:208
virtual EXPORT ~OTOffer()
Definition: OTOffer.cpp:551
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
#define OT_TIME_ZERO
Definition: Common.hpp:180
virtual EXPORT void Release()
Definition: OTData.cpp:257
EXPORT OTOffer()
Definition: OTOffer.cpp:510
virtual EXPORT void Release()
Definition: OTString.cpp:765
int64_t m_lMinimumIncrement
Definition: OTOffer.hpp:221
const int64_t & GetPriceLimit() const
Definition: OTOffer.hpp:282