Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OTAgent.cpp
Go to the documentation of this file.
1 /************************************************************
2  *
3  * OTAgent.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 "../recurring/OTAgreement.hpp"
136 #include "OTAgent.hpp"
137 #include "OTLog.hpp"
138 #include "OTParty.hpp"
139 #include "OTPartyAccount.hpp"
140 #include "OTPseudonym.hpp"
141 #include "OTSmartContract.hpp"
142 
143 #include <memory>
144 
145 // Have the agent try to verify his own signature against any contract.
146 //
147 // NOTE: This function assumes that you have already taken actions that would
148 // have loaded the Nym's pointer
149 // and placed it within this Agent. This is a low-level call and it expects that
150 // you have already been using
151 // calls such as HasAgent(), HasAuthorizingAgent(), LoadAuthorizingAgent(), etc.
152 // This function also assumes that once you are done, you will call
153 // ClearTemporaryPointers().
154 //
155 
156 namespace opentxs
157 {
158 
159 bool OTAgent::VerifySignature(const OTContract& theContract) const
160 {
161  // Only individual agents can sign for things, not groups (groups vote, they
162  // don't sign.)
163  // Thus, an individual can verify a signature, whereas a voting group would
164  // verify an election result (or whatever.)
165  //
166  if (!IsAnIndividual() || !DoesRepresentHimself()) {
167  otErr << "OTAgent::VerifySignature: Entities and roles are not yet "
168  "supported. Agent: " << m_strName << ".\n";
169  return false;
170  } // todo: when adding entities, this will change.
171 
172  // if (DoesRepresentAnEntity)
173  // {
174  // // The original version of a smartcontract might show that Frank,
175  // the Sales Director, signed it.
176  // // Years later, Frank is fired, and Jim is appointed to his former
177  // Role of sales director, in the same entity.
178  // // The original copy of the smart contract still contains Frank's
179  // signature, and thus we still need to load Frank
180  // // in order to verify that original signature. That's why we load
181  // Frank by the NymID stored there. He was the Nym
182  // // at the time, so that's the key we load.
183  // //
184  // // NEXT: What if JIM tries to verify the signature on the
185  // contract, even though FRANK was the original signer?
186  // // Should OTAgent be smart enough here to substitute Frank
187  // whenever Jim tries to verify? I argue no: this function is
188  // // too low-level. Plus it's backwards. If Jim tries to DO an
189  // action, THEN OT should be smart enough to verify that Jim
190  // // is in the proper Role and that Jim's signature is good enough
191  // to authorize actions. But if OT is verifying Frank's
192  // // signature on some old copy of something that Frank formerly
193  // signed, then this function should clearly tell me if Frank's
194  // // sig verified... or not.
195  // //
196  // // Therefore the "DoesRepresentAnEntity()" option is useless here,
197  // since we are verifying the same Nym's signature whether
198  // // he represents an entity or not.
199  // //
200  // }
201  // else
202  if (nullptr == m_pNym) {
203  OTString strTemp(theContract);
204  otErr << "OTAgent::VerifySignature: Attempted to verify signature on "
205  "contract, "
206  "but no Nym had ever been loaded for this agent:\n\n"
207  << strTemp << "\n\n";
208  return false;
209  }
210 
211  return theContract.VerifySignature(*m_pNym);
212 }
213 
214 // Low-level.
215 // Caller is responsible to delete.
216 // Don't call this unless you're sure the same Nym isn't already loaded, or
217 // unless
218 // you are prepared to compare the returned Nym with all the Nyms you already
219 // have loaded.
220 //
221 // This call may always fail for a specific agent, if the agent isn't a Nym
222 // (the agent could be a voting group.)
223 //
225 {
226  OTIdentifier theAgentNymID;
227  bool bNymID = GetNymID(theAgentNymID);
228 
229  if (bNymID) {
230  OTPseudonym* pNym = new OTPseudonym;
231  OT_ASSERT(nullptr != pNym);
232 
233  pNym->SetIdentifier(theAgentNymID);
234 
235  if (!pNym->LoadPublicKey()) {
236  OTString strNymID(theAgentNymID);
237  otErr << "OTAgent::LoadNym: Failure loading "
238  "agent's public key:\n" << strNymID << "\n";
239  delete pNym;
240  pNym = nullptr;
241  }
242  else if (pNym->VerifyPseudonym() &&
243  pNym->LoadSignedNymfile(theServerNym)) {
245  *pNym); // set this pointer in case I need it for later.
246  // also remember, caller is responsible to delete, so there's no
247  // guarantee the pointer
248  return pNym; // is any good. Then again, caller is also responsible
249  // to call ClearTemporaryPointers().
250  }
251  else {
252  OTString strNymID(theAgentNymID);
253  otErr << "OTAgent::LoadNym: Failure verifying agent's public key "
254  "or loading signed nymfile: " << strNymID << "\n";
255  delete pNym;
256  pNym = nullptr;
257  }
258  }
259  else
260  otErr << "OTAgent::LoadNym: Failure. Are you sure this agent IS a Nym "
261  "at all? \n";
262 
263  return nullptr;
264 }
265 
267  : m_bNymRepresentsSelf(false)
268  , m_bIsAnIndividual(false)
269  , m_pNym(nullptr)
270  , m_pForParty(nullptr)
271 {
272 }
273 
274 OTAgent::OTAgent(bool bNymRepresentsSelf, bool bIsAnIndividual,
275  const OTString& strName, const OTString& strNymID,
276  const OTString& strRoleID, const OTString& strGroupName)
277  : m_bNymRepresentsSelf(bNymRepresentsSelf)
278  , m_bIsAnIndividual(bIsAnIndividual)
279  , m_pNym(nullptr)
280  , m_pForParty(nullptr)
281  , m_strName(strName)
282  , m_strNymID(strNymID)
283  , m_strRoleID(strRoleID)
284  , m_strGroupName(strGroupName)
285 {
286 }
287 
288 OTAgent::OTAgent(std::string str_agent_name, OTPseudonym& theNym,
289  bool bNymRepresentsSelf)
290  /*IF false, then: ROLE parameter goes here.*/
291  : m_bNymRepresentsSelf(bNymRepresentsSelf),
292  m_bIsAnIndividual(true),
293  m_pNym(&theNym),
294  m_pForParty(nullptr),
295  m_strName(str_agent_name.c_str())
296 {
297  // Grab m_strNymID
298  OTIdentifier theNymID;
299  theNym.GetIdentifier(theNymID);
300  theNymID.GetString(m_strNymID);
301 
302  //
303 
304  if (!bNymRepresentsSelf) {
305  // Todo: if the Nym represents an Entity, then RoleID should
306  // be passed in, and set here. I WILL PROBABLY make that part into a
307  // SEPARATE CONSTRUCTOR.
308  // (Once I get around to adding Entities.)
309  //
310  otErr << "OTAgent::OTAgent: THIS HASN'T BEEN WRITTEN YET!!\n";
311  }
312 }
313 
314 void OTAgent::SetParty(OTParty& theOwnerParty) // This happens when the agent is
315  // added to the party.
316 {
317  m_pForParty = &theOwnerParty;
318 
319  // A Nym can only act as agent for himself or for an entity
320  // (never for another Nym. Start an entity if you want that.)
321  // If the owner party is a Nym, therefore this agent IS the Nym acting for
322  // himself.
323  // Whereas if the owner party were an entity, then this agent could be a Nym
324  // or a voting group.
325  // Since inside this block the owner party IS a Nym, not an entity, then the
326  // agent can therefore
327  // only be THAT Nym, acting as an agent for himself. Remember, a Nym cannot
328  // act as agent for
329  // another Nym. That is only possible by an agreement between them, and that
330  // agreement becomes
331  // the entity (therefore it's only possible using an entity.)
332  //
333  if (theOwnerParty.IsNym()) // Thus, this basically means the agent IS the
334  // party.
335  {
336  m_bNymRepresentsSelf = true;
337  m_bIsAnIndividual = true;
338 
339  bool bGetOwnerNymID = false;
340  const std::string str_owner_nym_id =
341  theOwnerParty.GetNymID(&bGetOwnerNymID);
342  m_strNymID.Set(bGetOwnerNymID ? str_owner_nym_id.c_str() : "");
343 
344  // Todo here, instead of copying the Owner's Nym ID like above, just
345  // make sure they match.
346  // Similarly, make sure that the RoleID or GroupName, whichever is
347  // relevant, is validated for the owner.
348  }
349 }
350 
352 {
353  m_pNym =
354  nullptr; // this pointer is not owned by this object, and is here for
355  // convenience only.
356  m_pForParty =
357  nullptr; // The agent probably has a pointer to the party it acts
358  // on behalf of.
359 }
360 
361 // If the agent is a Nym acting for himself, this will be true. Otherwise, if
362 // agent is a Nym acting in a role for an entity, or if agent is a voting group
363 // acting for the entity to which it belongs, either way, this will be false.
364 
366 {
367 
368  return m_bNymRepresentsSelf;
369 }
370 
371 // Whether the agent is a voting group acting for an entity, or is a Nym acting
372 // in a Role for an entity, this will be true either way. (Otherwise, if agent
373 // is a Nym acting for himself, then this will be false.)
374 
376 {
377  return !m_bNymRepresentsSelf;
378 }
379 
380 // Only one of these can be true:
381 //
382 // - Agent is either a Nym acting for himself or some entity,
383 // - or agent is a group acting for some entity.
384 
385 // Agent is an individual Nym. (Meaning either he IS ALSO the party and thus
386 // represents himself, OR he is an agent for an entity who is the party, and
387 // he's acting in a role for that entity.) If agent were a group, this would be
388 // false.
389 
391 {
392  return m_bIsAnIndividual;
393 }
394 
395 // OR: Agent is a voting group, which cannot take proactive or instant action,
396 // but only passive and delayed. Entity-ONLY. (A voting group cannot decide on
397 // behalf of individual, but only on behalf of the entity it belongs to.)
398 
399 bool OTAgent::IsAGroup() const
400 {
401  return !m_bIsAnIndividual;
402 }
403 
404 // A Nym cannot act as "agent" for another Nym.
405 // Nor can a Group act as "agent" for a Nym. Why not? Because:
406 //
407 // An entity is COMPOSED of its voting groups and its employee Nyms.
408 // These don't merely act "on behalf" of the entity, but in fact they comprise
409 // the entity.
410 // Therefore the entity can use voting groups and employee Nyms to make
411 // decisions BECAUSE
412 // IT **HAS** voting groups and employee nyms that it can use.
413 //
414 // Whereas an individual Nym is NOT composed of voting groups or employee Nyms.
415 // So how could
416 // he designate to act "on his behalf" something that does not even exist?
417 // So we must ask, how can another Nym, then, be appointed to act as my agent
418 // without some
419 // agreement designating him as such? And that agreement is the entity itself,
420 // which is nothing
421 // more than an agreement between several owners to designate agents to operate
422 // according to their
423 // interests.
424 
425 // To directly appoint one Nym to act on behalf of another, yet WITHOUT any
426 // agreement in place,
427 // is to behave as one is the same as the other. But still, who has the key? If
428 // both have absolutely
429 // access and rights to the same key, then why not just both keep a copy of it?
430 // In which case now
431 // it really IS only one Nym in reality, as well as in the software.
432 // But if one prefers to have his private key, and another his, then they will
433 // begin as separate and
434 // independent individuals. One Nym will not be found within the other as a
435 // int64_t-lost, under-developed
436 // twin!
437 // Just as reality enforces separate individuals, so does the software end up in
438 // the situation where
439 // two separate Nyms now wish to act with one as agent for the other. This wish
440 // is perfectly valid and
441 // can be accommodated, but logically the software cannot provide the same
442 // ONENESS of ACTUALLY SHARING
443 // THE PRIVATE KEY IN REAL LIFE (which allows the software to ACTUALLY only deal
444 // with a single key),
445 // as opposed to the oneness of "we have separate keys but we want to act in
446 // this way". There is oneness,
447 // and then there is oneness. OT is about contracts between Nyms, and therefore
448 // that is the mechanism
449 // for implementing ANY OTHER FORM OF AGENCY. Whether that agent is your "best
450 // man" or a board of voters,
451 // and whether the agent acts on behalf of you, or some corporation or
452 // democracy, either way, either his
453 // key is the same bits as your key, or they are separate keys in which case
454 // there is an agreement
455 // between them. Otherwise OT simply does not know which agents have
456 // authority--and which do not. This
457 // knowledge is necessary just for being able to function, and is imposed by the
458 // natural law.
459 
460 // IDEA: Have a factory for smart contracts, such that not only are different
461 // subclasses instantiated,
462 // but more usefully, common configurations such as new democracy, new
463 // corporation, new board-with-veto, etc.
464 //
465 
466 // For when the agent is an individual:
467 //
468 
469 // If IsIndividual(), then this is his own personal NymID,
470 // (whether he DoesRepresentHimself() or DoesRepresentAnEntity() -- either way).
471 // Otherwise if IsGroup(), this returns false.
472 //
473 bool OTAgent::GetNymID(OTIdentifier& theOutput) const
474 {
475  if (IsAnIndividual()) {
476  theOutput.SetString(m_strNymID);
477 
478  return true;
479  }
480 
481  return false;
482 }
483 
484 // IF IsIndividual() AND DoesRepresentAnEntity(), then this is his RoleID within
485 // that Entity. Otherwise, if IsGroup() or DoesRepresentHimself(), then this
486 // returns false.
487 
488 bool OTAgent::GetRoleID(OTIdentifier& theOutput) const
489 {
491  theOutput.SetString(m_strRoleID);
492 
493  return true;
494  }
495 
496  return false;
497 }
498 
499 // Notice if the agent is a voting group, then it has no signer. (Instead it
500 // will have an election.)
501 // That is why certain agents are unacceptable in certain scripts. They are
502 // PASSIVE.
503 //
504 // There is an "active" agent who has a signerID, but there is also a "passive"
505 // agent who only has
506 // a group name, and acts based on notifications and replies in the
507 // int64_t-term, versus being immediately
508 // able to act as part of the operation of a script.
509 //
510 // Basically if !IsIndividual(), then GetSignerID() will fail and thus anything
511 // needing that,
512 // as part of the script, would also therefore be impossible.
513 //
514 bool OTAgent::GetSignerID(OTIdentifier& theOutput) const
515 {
516  // If IsIndividual() and DoesRepresentAnEntity() then this returns
517  // GetRoleID().
518  // else if Individual() and DoesRepresentHimself() then this returns
519  // GetNymID().
520  // else (if IsGroup()) then return false;
521 
522  if (IsAnIndividual()) {
523  if (DoesRepresentAnEntity()) {
524  return GetRoleID(theOutput);
525  }
526  else // DoesRepresentHimself()
527  {
528  return GetNymID(theOutput);
529  }
530  }
531 
532  // else IsGroup()... unable to sign directly; must hold votes instead.
533  //
534  return false;
535 }
536 
538 {
539  OTIdentifier theAgentNymID;
540  bool bNymID = GetNymID(theAgentNymID);
541 
542  // If there's a NymID on this agent, and it matches theNymID...
543  //
544  if (bNymID && (theNymID == theAgentNymID)) return true;
545 
546  // TODO Entities...
547  //
548  return false;
549 }
550 
551 // See if theNym is a valid signer for this agent.
552 //
554 {
555  OTIdentifier theAgentNymID;
556  bool bNymID = GetNymID(theAgentNymID);
557 
558  // If there's a NymID on this agent, and it matches theNym's ID...
559  //
560  if (bNymID && theNym.CompareID(theAgentNymID)) {
561  // That means theNym *is* the Nym for this agent!
562  // We'll save his pointer, for future reference...
563  //
564  SetNymPointer(theNym);
565 
566  return true;
567  }
568 
569  // TODO Entity: Perhaps the original Nym was fired from his role... another
570  // Nym has now
571  // taken his place. In which case, the original Nym should be refused as a
572  // valid
573  // signer, and the new Nym should be allowed to sign in his place!
574  //
575  // This means if DoesRepresentAnEntity(), then I have to load the Role, and
576  // verify
577  // the Nym against that Role (which contains the updated status). Since I
578  // haven't
579  // coded Entities/Roles yet, then I don't have to do this just yet...
580  // Might even update the NymID on this agent, for updated copies of the
581  // agreement.
582  // (Obviously the original can't be changed...)
583  //
584 
585  return false;
586 }
587 
588 // For when the agent DoesRepresentAnEntity():
589 //
590 // Whether this agent IsGroup() (meaning he is a voting group that
591 // DoesRepresentAnEntity()),
592 // OR whether this agent is an individual acting in a role for an entity
593 // (IsIndividual() && DoesRepresentAnEntity())
594 // ...EITHER WAY, the agent DoesRepresentAnEntity(), and this function returns
595 // the ID of that Entity.
596 //
597 // Otherwise, if the agent DoesRepresentHimself(), then this returns false.
598 // I'm debating making this function private along with DoesRepresentHimself /
599 // DoesRepresentAnEntity().
600 //
601 bool OTAgent::GetEntityID(OTIdentifier& theOutput) const
602 {
603  // IF represents an entity, then this is its ID. Else fail.
604  //
605  if (DoesRepresentAnEntity() && (nullptr != m_pForParty) &&
606  m_pForParty->IsEntity()) {
607  bool bSuccessEntityID = false;
608  std::string str_entity_id = m_pForParty->GetEntityID(&bSuccessEntityID);
609 
610  if (bSuccessEntityID && (str_entity_id.size() > 0)) {
611  OTString strEntityID(str_entity_id.c_str());
612  theOutput.SetString(strEntityID);
613 
614  return true;
615  }
616  }
617 
618  return false;
619 }
620 
621 // Returns true/false whether THIS agent is the authorizing agent for his party.
622 //
624 {
625  if (nullptr == m_pForParty) return false;
626 
627  if (m_strName.Compare(m_pForParty->GetAuthorizingAgentName().c_str()))
628  return true;
629 
630  return false;
631 }
632 
633 // Returns the number of accounts, owned by this agent's party, that this agent
634 // is the authorized agent FOR.
635 //
637 {
638  if (nullptr == m_pForParty) {
639  otErr << "OTAgent::CountAuthorizedAccts: Error: m_pForParty was "
640  "nullptr.\n";
641  return 0; // Maybe should log here...
642  }
643 
644  return m_pForParty->GetAccountCount(m_strName.Get());
645 }
646 
647 // For when the agent is a voting group:
648 // If !IsGroup() aka IsIndividual(), then this will return false.
649 //
650 bool OTAgent::GetGroupName(OTString& strGroupName)
651 {
652  if (IsAGroup()) {
653  strGroupName.Set(m_strGroupName);
654 
655  return true;
656  }
657 
658  return false;
659 }
660 
661 // PARTY is either a NYM or an ENTITY. This returns ID for that Nym or Entity.
662 //
663 bool OTAgent::GetPartyID(OTIdentifier& theOutput) const
664 {
665  if (DoesRepresentHimself()) return GetNymID(theOutput);
666 
667  return GetEntityID(theOutput);
668 }
669 
670 void OTAgent::RetrieveNymPointer(mapOfNyms& map_Nyms_Already_Loaded)
671 {
672  const std::string str_agent_name(m_strName.Get());
673 
674  // We actually have a Nym pointer on this agent somehow (so let's add it to
675  // the list.)
676  //
677  if (nullptr != m_pNym) {
678  if (!m_strName.Exists()) // Whoaa!! Can't add it without the agent's
679  // name for the map!
680  {
681  otErr << "OTAgent::RetrieveNymPointers: Failed: m_strName is "
682  "empty!\n";
683  }
684  else if (map_Nyms_Already_Loaded.end() ==
685  map_Nyms_Already_Loaded.insert(
686  map_Nyms_Already_Loaded.begin(),
687  std::pair<std::string, OTPseudonym*>(str_agent_name,
688  m_pNym)))
689  otErr << "OTAgent::RetrieveNymPointer: Failed on insertion, as "
690  "though another nym were already "
691  "there with the same agent name! (" << m_strName << ")\n";
692  // (else it was inserted successfully.)
693  }
694  // else nothing, since it's normal that most of them are nullptr, even when
695  // one
696  // is goood.
697 }
698 
699 bool OTAgent::VerifyAgencyOfAccount(const OTAccount& theAccount) const
700 {
701  OTIdentifier theSignerID;
702 
703  if (!GetSignerID(theSignerID)) {
704  otErr << "OTAgent::VerifyAgencyOfAccount: ERROR: Entities and roles "
705  "haven't been coded yet.\n";
706  return false;
707  }
708 
709  return theAccount.VerifyOwnerByID(theSignerID); // todo when entities and
710  // roles come, won't this
711  // "just work", or do I also
712  // have to warn the acct
713  // whether it's a Nym or a
714  // Role being passed?
715 }
716 
718  mapOfNyms* pNymMap, const OTString& strServerID, OTPseudonym& theServerNym,
719  OTSmartContract& theSmartContract, const OTIdentifier& theAccountID,
720  const int64_t& lNewTransactionNumber, const int64_t& lClosingNumber,
721  const OTString& strOrigCronItem, OTString* pstrNote,
722  OTString* pstrAttachment)
723 {
724  // TODO: When entites and ROLES are added, this function may change a bit to
725  // accommodate them.
726  const char* szFunc = "OTAgent::DropFinalReceiptToInbox";
727 
728  OTIdentifier theAgentNymID;
729  bool bNymID = GetNymID(theAgentNymID);
730 
731  // Not all agents have Nyms. (Might be a voting group.)
732  // But in the case of Inboxes for asset accounts, shouldn't the agent be a
733  // Nym?
734  // Perhaps not... perhaps not... we shall see.
735 
736  if (true == bNymID) // therefore IsAnIndividual() is definitely true.
737  {
738  OTPseudonym* pNym = nullptr;
739  std::unique_ptr<OTPseudonym> theNymAngel;
740 
741  // If a list of pre-loaded Nyms was passed in, see if one of them is
742  // ours.
743  //
744  if (nullptr != pNymMap) {
745  const OTString strNymID(theAgentNymID);
746  OT_ASSERT(strNymID.Exists());
747 
748  auto ittt = pNymMap->find(strNymID.Get());
749 
750  if (pNymMap->end() != ittt) // found it!
751  {
752  pNym = ittt->second;
753  OT_ASSERT(nullptr != pNym);
754  }
755  }
756 
757  if (nullptr ==
758  pNym) // It wasn't on the list of already-loaded nyms that
759  // was passed in, so we have to load it.
760  {
761  // By this point we also know that pNym is NOT the server Nym, nor
762  // is it the
763  // Originator, nor pActingNym, nor pPartyNym, as they were all
764  // loaded already and
765  // were added to pNymMap, yet we didn't find the Nym we were looking
766  // for among them.
767  //
768  // (Therefore this is some new Nym, and doesn't need to be verified
769  // against those Nyms again,
770  // before loading it. Let's load it up!)
771  //
772  if (nullptr == (pNym = LoadNym(theServerNym)))
773  otErr << szFunc << ": Failed loading Nym.\n";
774  else
775  theNymAngel.reset(pNym); // CLEANUP :-)
776  }
777 
778  // I call this because LoadNym sets my internal Nym pointer to pNym, and
779  // then
780  // it goes out of scope before the end of this function and gets
781  // cleaned-up.
782  // Therefore, no point in letting this agent continue to point to bad
783  // memory...
784  //
786 
787  if ((nullptr != pNym) && (lClosingNumber > 0) &&
788  pNym->VerifyIssuedNum(strServerID,
789  lClosingNumber)) // <====================
790  {
791  return theSmartContract.DropFinalReceiptToInbox(
792  theAgentNymID, theAccountID, lNewTransactionNumber,
793  lClosingNumber, strOrigCronItem, pstrNote,
794  pstrAttachment); // pActualAcct=nullptr here. (This call will
795  // load
796  // the acct up and update its inbox hash.)
797  }
798  else
799  otErr << szFunc
800  << ": Error: pNym is nullptr, or lClosingNumber <=0, "
801  "or pNym->VerifyIssuedNum(strServerID, "
802  "lClosingNumber)) failed to verify.\n";
803  }
804  else
805  otErr << szFunc << ": No NymID available for this agent...\n";
806 
807  return false;
808 }
809 
811  OTSmartContract& theSmartContract, const int64_t& lNewTransactionNumber,
812  const OTString& strOrigCronItem, OTString* pstrNote,
813  OTString* pstrAttachment,
814  OTPseudonym* pActualNym) // IF the Nym was already loaded, then I
815  // HAD to pass it here. But it may not be
816  // here. Also: It may not be the right
817  // Nym, so need to check before actually
818  // using for anything.
819 {
820  OTIdentifier theAgentNymID;
821  bool bNymID = GetNymID(theAgentNymID);
822 
823  // Not all agents have Nyms. (Might be a voting group.)
824 
825  if (true == bNymID) {
826  OTPseudonym* pToActualNym = nullptr;
827 
828  if ((nullptr != pActualNym) && pActualNym->CompareID(theAgentNymID))
829  pToActualNym = pActualNym;
830 
831  return theSmartContract.DropFinalReceiptToNymbox(
832  theAgentNymID, lNewTransactionNumber, strOrigCronItem, pstrNote,
833  pstrAttachment, pToActualNym);
834  }
835 
836  // TODO: When entites and roles are added, this function may change a bit to
837  // accommodate them.
838 
839  return false;
840 }
841 
843  bool bSuccessMsg, // Added this so we can notify smart contract parties when
844  // it FAILS to activate.
845  OTPseudonym& theServerNym, const OTIdentifier& theServerID,
846  const int64_t& lNewTransactionNumber, const int64_t& lInReferenceTo,
847  const OTString& strReference, OTString* pstrNote, OTString* pstrAttachment,
848  OTPseudonym* pActualNym)
849 {
850  OTIdentifier theAgentNymID;
851  bool bNymID = GetNymID(theAgentNymID);
852 
853  // Not all agents have Nyms. (Might be a voting group.)
854 
855  if (true == bNymID) {
856  OTPseudonym* pToActualNym = nullptr;
857 
858  if ((nullptr != pActualNym) && pActualNym->CompareID(theAgentNymID))
859  pToActualNym = pActualNym;
860  else if ((nullptr != m_pNym) && m_pNym->CompareID(theAgentNymID))
861  pToActualNym = m_pNym;
862 
864  bSuccessMsg, theServerNym, theServerID, theAgentNymID,
865  lNewTransactionNumber, lInReferenceTo, strReference, pstrNote,
866  pstrAttachment, pToActualNym);
867  }
868 
869  // TODO: When entites and roles are added, this function may change a bit to
870  // accommodate them.
871 
872  return false;
873 }
874 
875 bool OTAgent::SignContract(OTContract& theInput) const
876 {
877  if (!IsAnIndividual() || !DoesRepresentHimself()) {
878  otErr << "OTAgent::SignContract: Entities and roles are not yet "
879  "supported. Agent: " << m_strName << ".\n";
880  return false;
881  } // todo: when adding entities, this will change.
882 
883  if (nullptr == m_pNym) {
884  otErr << "OTAgent::SignContract: Nym was nullptr while trying to sign "
885  "contract. Agent: " << m_strName << ".\n";
886  return false;
887  } // todo: when adding entities, this will change.
888 
889  return theInput.SignContract(*m_pNym);
890 }
891 
892 bool OTAgent::VerifyIssuedNumber(const int64_t& lNumber,
893  const OTString& strServerID)
894 {
895  // Todo: this function may change when entities / roles are added.
896  if (!IsAnIndividual() || !DoesRepresentHimself()) {
897  otErr << "OTAgent::VerifyIssuedNumber: Error: Entities and Roles are "
898  "not yet supported. Agent: " << m_strName << "\n";
899  return false;
900  }
901 
902  if (nullptr != m_pNym)
903  return m_pNym->VerifyIssuedNum(strServerID, lNumber);
904  else
905  otErr << "OTAgent::VerifyIssuedNumber: Error: m_pNym was nullptr. For "
906  "agent: " << m_strName << "\n";
907 
908  return false;
909 }
910 
911 bool OTAgent::VerifyTransactionNumber(const int64_t& lNumber,
912  const OTString& strServerID)
913 {
914  // Todo: this function may change when entities / roles are added.
915  if (!IsAnIndividual() || !DoesRepresentHimself()) {
916  otErr << "OTAgent::VerifyTransactionNumber: Error: Entities and Roles "
917  "are not yet supported. Agent: " << m_strName << "\n";
918  return false;
919  }
920 
921  if (nullptr != m_pNym)
922  return m_pNym->VerifyTransactionNum(strServerID, lNumber);
923  else
924  otErr << "OTAgent::VerifyTransactionNumber: Error: m_pNym was nullptr. "
925  "For agent: " << m_strName << "\n";
926 
927  return false;
928 }
929 
930 // Done
931 // ASSUMES m_pNym is set already -- doesn't bother loading the nym!
932 //
934  const int64_t& lNumber, const OTString& strServerID,
935  bool bSave, // Each agent's nym is used if pSignerNym is nullptr,
936  // whereas the server
937  OTPseudonym* pSignerNym) // uses this optional arg to substitute
938  // serverNym as signer.
939 {
940 
941  // Todo: this function may change when entities / roles are added.
942  //
943  if (!IsAnIndividual() || !DoesRepresentHimself()) {
944  otErr << __FUNCTION__
945  << ": Error: Entities and Roles are not yet supported. Agent: "
946  << m_strName << "\n";
947  return false;
948  }
949 
950  if (nullptr != m_pNym) {
951  // If a signer wasn't passed in (the server-side uses server nym to
952  // sign)
953  // then we use the Nym himself as his own signer (common to
954  // client-side.)
955  //
956  if (nullptr == pSignerNym) pSignerNym = m_pNym;
957 
958  const OTIdentifier theServerID(strServerID);
959 
960  // This won't "add it back" unless we're SURE he had it in the first
961  // place...
962  //
963  const bool bSuccess = m_pNym->ClawbackTransactionNumber(
964  theServerID, lNumber, bSave, pSignerNym);
965 
966  if (bSuccess) {
967  // The transaction is being removed from play, so we will remove it
968  // from this list.
969  // That is, when we called RemoveTransactionNumber, the number was
970  // being put into play
971  // until RemoveIssuedNumber is called to close it out. But now
972  // RemoveIssuedNumber won't
973  // ever be called, since we are harvesting it back for future use.
974  // Therefore the number
975  // is currently no longer in play, therefore we remove it from the
976  // list of open cron numbers.
977  //
978  std::set<int64_t>& theIDSet = m_pNym->GetSetOpenCronItems();
979  auto theSetIT = theIDSet.find(lNumber);
980 
981  if (theIDSet.end() != theSetIT) // IF it was there, THEN remove it.
982  // (Client doesn't even track these,
983  // though server does.)
984  theIDSet.erase(lNumber);
985 
986  return true;
987  }
988  else
989  otErr << __FUNCTION__ << ": Number (" << lNumber
990  << ") failed to verify for agent: " << m_strName
991  << " (Thus didn't bother 'adding it back'.)\n";
992  }
993  else
994  otErr << __FUNCTION__
995  << ": Error: m_pNym was nullptr. For agent: " << m_strName
996  << "\n";
997 
998  return false;
999 }
1000 
1001 // This means the transaction number has just been USED (and it now must stay
1002 // open/outstanding until CLOSED.)
1003 // Therefore we also add it to the set of open cron items, which the server
1004 // keeps track of (for opening AND closing numbers.)
1005 //
1006 bool OTAgent::RemoveTransactionNumber(const int64_t& lNumber,
1007  const OTString& strServerID,
1008  OTPseudonym& SIGNER_NYM, bool bSave)
1009 {
1010  // Todo: this function may change when entities / roles are added.
1011  if (!IsAnIndividual() || !DoesRepresentHimself()) {
1012  otErr << "OTAgent::" << __FUNCTION__
1013  << ": Error: Entities and Roles are not yet supported. Agent: "
1014  << m_strName << "\n";
1015  return false;
1016  }
1017 
1018  if (nullptr != m_pNym) {
1019  std::set<int64_t>& theIDSet =
1020  m_pNym->GetSetOpenCronItems(); // The transaction is now in play, so
1021  // we are going to add it to this
1022  // list.
1023  const bool bSuccess =
1024  m_pNym->RemoveTransactionNum(strServerID, lNumber); // Doesn't save.
1025 
1026  if (bSuccess) {
1027  theIDSet.insert(lNumber); // Since the Trans# is now in play, the
1028  // server records it as an open cron item.
1029 
1030  if (bSave) m_pNym->SaveSignedNymfile(SIGNER_NYM);
1031  }
1032  else
1033  otErr << "OTAgent::" << __FUNCTION__
1034  << ": Error, should never happen. (I'd assume you aren't "
1035  "removing numbers without verifying first if they're "
1036  "there.)\n";
1037  return bSuccess;
1038  }
1039  else
1040  otErr << "OTAgent::" << __FUNCTION__
1041  << ": Error: m_pNym was nullptr. For agent: " << m_strName
1042  << "\n";
1043 
1044  return false;
1045 }
1046 
1047 // This means the transaction number has just been CLOSED.
1048 // Therefore we remove it from the set of open cron items, which the server
1049 // keeps track of (for opening AND closing numbers.)
1050 //
1051 bool OTAgent::RemoveIssuedNumber(const int64_t& lNumber,
1052  const OTString& strServerID, bool bSave,
1053  OTPseudonym* pSignerNym)
1054 {
1055  // Todo: this function may change when entities / roles are added.
1056  if (!IsAnIndividual() || !DoesRepresentHimself()) {
1057  otErr << "OTAgent::" << __FUNCTION__
1058  << ": Error: Entities and Roles are not yet supported. Agent: "
1059  << m_strName << "\n";
1060  return false;
1061  }
1062 
1063  if (nullptr != m_pNym) {
1064  std::set<int64_t>& theIDSet =
1065  m_pNym->GetSetOpenCronItems(); // The transaction is being removed
1066  // from play, so we will remove it
1067  // from this list.
1068  const bool bSuccess =
1069  m_pNym->RemoveIssuedNum(strServerID, lNumber); // Doesn't save.
1070 
1071  if (bSuccess) {
1072  if (nullptr == pSignerNym) pSignerNym = m_pNym;
1073 
1074  // Since the Trans# is now out of play, the server removes it as an
1075  // open cron item.
1076  //
1077  auto theSetIT = theIDSet.find(lNumber);
1078 
1079  if (theIDSet.end() != theSetIT) // IF it was there, THEN remove it.
1080  // (Client doesn't even track these,
1081  // though server does.)
1082  theIDSet.erase(lNumber);
1083 
1084  if (bSave) m_pNym->SaveSignedNymfile(*pSignerNym);
1085  }
1086  else
1087  otErr << "OTAgent::" << __FUNCTION__
1088  << ": Error, should never happen. (I'd assume you aren't "
1089  "removing issued numbers without verifying first if "
1090  "they're there.)\n";
1091  return bSuccess;
1092  }
1093  else
1094  otErr << "OTAgent::" << __FUNCTION__
1095  << ": Error: m_pNym was nullptr. For agent: " << m_strName
1096  << "\n";
1097 
1098  return false;
1099 }
1100 
1101 // Done
1103  OTPartyAccount& thePartyAcct)
1104 {
1105  if (IsAnIndividual() && DoesRepresentHimself() && (nullptr != m_pNym)) {
1106  int64_t lTransactionNumber = 0;
1107  if (thePartyAcct.GetClosingTransNo() > 0) {
1108  otOut << "OTAgent::ReserveClosingTransNum: Failure: The account "
1109  "ALREADY has a closing transaction number "
1110  "set on it. Don't you want to save that first, before "
1111  "overwriting it?\n";
1112  return false;
1113  }
1114 
1115  if (m_pNym->GetTransactionNumCount(strServerID) <
1116  1) // Need a closing number...
1117  {
1118  otOut << "OTAgent::ReserveClosingTransNum: *** Failure *** Nym "
1119  "needs at least 1 transaction number available in order "
1120  "to do this.\n";
1121  return false;
1122  }
1123  else if (false ==
1124  m_pNym->GetNextTransactionNum(*m_pNym, strServerID,
1125  lTransactionNumber)) {
1126  otErr << "OTAgent::ReserveClosingTransNum: Error: Strangely, "
1127  "unable to get a transaction number, even though "
1128  "supposedly one was there.\n";
1129  return false;
1130  }
1131 
1132  // BELOW THIS POINT, TRANSACTION # HAS BEEN RESERVED, AND MUST BE
1133  // SAVED...
1134  // Any errors below this point will require this call before returning:
1135  // HarvestAllTransactionNumbers(strServerID);
1136  //
1137  thePartyAcct.SetClosingTransNo(lTransactionNumber);
1138  thePartyAcct.SetAgentName(m_strName);
1139 
1140  return true;
1141  }
1142  else // todo: when entities and roles are added... this function will
1143  // change.
1144  {
1145  otErr << "OTAgent::ReserveClosingTransNum: Either the Nym pointer "
1146  "isn't set properly, "
1147  "or you tried to use Entities when they haven't been coded "
1148  "yet. Agent: " << m_strName << " \n";
1149  }
1150 
1151  return false;
1152 }
1153 
1154 // Done
1156 {
1157  if (IsAnIndividual() && DoesRepresentHimself() && (nullptr != m_pNym)) {
1158  int64_t lTransactionNumber = 0;
1159  if (nullptr == m_pForParty) {
1160  otErr << "OTAgent::ReserveOpeningTransNum: Error: Party pointer "
1161  "was nullptr. SHOULD NEVER HAPPEN!!\n";
1162  return false;
1163  }
1164  if (m_pForParty->GetOpeningTransNo() > 0) {
1165  otOut << "OTAgent::ReserveOpeningTransNum: Failure: Party ALREADY "
1166  "had an opening transaction number "
1167  "set on it. Don't you want to save that first, before "
1168  "overwriting it?\n";
1169  return false;
1170  }
1171 
1172  if (m_pNym->GetTransactionNumCount(strServerID) <
1173  1) // Need opening number...
1174  {
1175  otOut << "OTAgent::ReserveOpeningTransNum: *** Failure *** Nym "
1176  "needs at least 1 transaction number available in order "
1177  "to do this.\n";
1178  return false;
1179  }
1180  else if (false ==
1181  m_pNym->GetNextTransactionNum(*m_pNym, strServerID,
1182  lTransactionNumber)) {
1183  otErr << "OTAgent::ReserveOpeningTransNum: Error: Strangely, "
1184  "unable to get a transaction number, even though "
1185  "supposedly one was there.\n";
1186  return false;
1187  }
1188 
1189  // BELOW THIS POINT, TRANSACTION # HAS BEEN RESERVED, AND MUST BE
1190  // SAVED...
1191  // Any errors below this point will require this call before returning:
1192  // HarvestAllTransactionNumbers(strServerID);
1193  //
1194  m_pForParty->SetOpeningTransNo(lTransactionNumber);
1195  m_pForParty->SetAuthorizingAgentName(m_strName.Get());
1196 
1197  return true;
1198  }
1199  else // todo: when entities and roles are added... this function will
1200  // change.
1201  {
1202  otErr << "OTAgent::ReserveOpeningTransNum: Either the Nym pointer "
1203  "isn't set properly, "
1204  "or you tried to use Entities when they haven't been coded "
1205  "yet. Agent: " << m_strName << " \n";
1206  }
1207 
1208  return false;
1209 }
1210 
1211 void OTAgent::Serialize(OTString& strAppend) const
1212 {
1213  // strAppend.Concatenate("<agent>\n\n");
1214 
1215  strAppend.Concatenate(
1216  "<agent\n name=\"%s\"\n"
1217  " doesAgentRepresentHimself=\"%s\"\n"
1218  " isAgentAnIndividual=\"%s\"\n"
1219  " nymID=\"%s\"\n"
1220  " roleID=\"%s\"\n"
1221  " groupName=\"%s\" />\n\n",
1222  m_strName.Get(), m_bNymRepresentsSelf ? "true" : "false",
1223  m_bIsAnIndividual ? "true" : "false", m_strNymID.Get(),
1224  m_strRoleID.Get(), m_strGroupName.Get());
1225 
1226  // strAppend.Concatenate("</agent>\n");
1227 }
1228 
1229 } // namespace opentxs
void SetAgentName(const OTString &strAgentName)
std::string GetNymID(bool *pBoolSuccess=nullptr) const
Definition: OTParty.cpp:541
void RetrieveNymPointer(mapOfNyms &map_Nyms_Already_Loaded)
Definition: OTAgent.cpp:670
bool DropServerNoticeToNymbox(bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &theServerID, const int64_t &lNewTransactionNumber, const int64_t &lInReferenceTo, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
Definition: OTAgent.cpp:842
bool DoesRepresentAnEntity() const
Definition: OTAgent.cpp:375
EXPORT bool ClawbackTransactionNumber(const OTIdentifier &theServerID, const int64_t &lTransClawback, bool bSave=false, OTPseudonym *pSIGNER_NYM=nullptr)
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
void ClearTemporaryPointers()
Definition: OTAgent.hpp:231
bool ReserveOpeningTransNum(const OTString &strServerID)
Definition: OTAgent.cpp:1155
bool VerifySignature(const OTContract &theContract) const
Definition: OTAgent.cpp:159
EXPORT bool GetNymID(OTIdentifier &theOutput) const
Definition: OTAgent.cpp:473
void SetNymPointer(OTPseudonym &theNym)
Definition: OTAgent.hpp:277
EXPORT bool VerifyOwnerByID(const OTIdentifier &nymId) const
Definition: OTAccount.cpp:472
bool IsAGroup() const
Definition: OTAgent.cpp:399
EXPORT bool VerifyIssuedNum(const OTString &strServerID, const int64_t &lTransNum) const
EXPORT bool GetNextTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t &lTransNum, bool bSave=true)
void SetAuthorizingAgentName(std::string str_agent_name)
Definition: OTParty.hpp:357
int32_t GetCountAuthorizedAccts()
Definition: OTAgent.cpp:636
bool IsEntity() const
Definition: OTParty.cpp:532
bool ReserveClosingTransNum(const OTString &strServerID, OTPartyAccount &thePartyAcct)
Definition: OTAgent.cpp:1102
bool GetSignerID(OTIdentifier &theOutput) const
Definition: OTAgent.cpp:514
bool GetRoleID(OTIdentifier &theOutput) const
Definition: OTAgent.cpp:488
OTLOG_IMPORT OTLogStream otOut
OTPseudonym * LoadNym(OTPseudonym &theServerNym)
Definition: OTAgent.cpp:224
bool VerifyTransactionNumber(const int64_t &lNumber, const OTString &strServerID)
Definition: OTAgent.cpp:911
std::map< std::string, OTPseudonym * > mapOfNyms
Definition: OTWallet.hpp:161
EXPORT bool IsValidSignerID(const OTIdentifier &theNymID)
Definition: OTAgent.cpp:537
bool IsNym() const
Definition: OTParty.cpp:526
EXPORT bool LoadSignedNymfile(OTPseudonym &SIGNER_NYM)
bool RemoveIssuedNumber(const int64_t &lNumber, const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
Definition: OTAgent.cpp:1051
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
std::string GetEntityID(bool *pBoolSuccess=nullptr) const
Definition: OTParty.cpp:556
EXPORT int32_t GetTransactionNumCount(const OTIdentifier &theServerID) const
EXPORT bool SignContract(OTContract &theInput) const
Definition: OTAgent.cpp:875
EXPORT bool VerifyPseudonym() const
bool GetEntityID(OTIdentifier &theOutput) const
Definition: OTAgent.cpp:601
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT void SetString(const char *szString)
EXPORT void SetIdentifier(const OTIdentifier &theIdentifier)
EXPORT bool IsValidSigner(OTPseudonym &theNym)
Definition: OTAgent.cpp:553
EXPORT bool LoadPublicKey()
bool DropFinalReceiptToInbox(const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, const int64_t &lNewTransactionNumber, const int64_t &lClosingNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTAccount *pActualAcct=nullptr)
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
EXPORT bool RemoveTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
void SetClosingTransNo(int64_t lTransNo)
bool VerifyIssuedNumber(const int64_t &lNumber, const OTString &strServerID)
Definition: OTAgent.cpp:892
bool DropFinalReceiptToInbox(mapOfNyms *pNymMap, const OTString &strServerID, OTPseudonym &theServerNym, OTSmartContract &theSmartContract, const OTIdentifier &theAccountID, const int64_t &lNewTransactionNumber, const int64_t &lClosingNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr)
Definition: OTAgent.cpp:717
bool GetGroupName(OTString &strGroupName)
Definition: OTAgent.cpp:650
EXPORT bool RemoveIssuedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
#define OT_ASSERT(x)
Definition: Assert.hpp:150
bool HarvestTransactionNumber(const int64_t &lNumber, const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
Definition: OTAgent.cpp:933
bool DoesRepresentHimself() const
Definition: OTAgent.cpp:365
EXPORT bool CompareID(const OTIdentifier &theIdentifier) const
bool DropFinalReceiptToNymbox(OTSmartContract &theSmartContract, const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
Definition: OTAgent.cpp:810
EXPORT const char * Get() const
Definition: OTString.cpp:1045
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
Definition: OTContract.cpp:484
const std::string & GetAuthorizingAgentName() const
Definition: OTParty.hpp:353
EXPORT bool IsAnIndividual() const
Definition: OTAgent.cpp:390
OTLOG_IMPORT OTLogStream otErr
bool GetPartyID(OTIdentifier &theOutput) const
Definition: OTAgent.cpp:663
void SetParty(OTParty &theOwnerParty)
Definition: OTAgent.cpp:314
bool VerifyAgencyOfAccount(const OTAccount &theAccount) const
Definition: OTAgent.cpp:699
void Serialize(OTString &strAppend) const
Definition: OTAgent.cpp:1211
EXPORT void GetString(OTString &theStr) const
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTContract.cpp:818
bool RemoveTransactionNumber(const int64_t &lNumber, const OTString &strServerID, OTPseudonym &SIGNER_NYM, bool bSave=true)
Definition: OTAgent.cpp:1006
int32_t GetAccountCount() const
Definition: OTParty.hpp:400
virtual ~OTAgent()
Definition: OTAgent.cpp:351
std::set< int64_t > & GetSetOpenCronItems()
int64_t GetOpeningTransNo() const
Definition: OTParty.hpp:295
int64_t GetClosingTransNo() const
bool DropFinalReceiptToNymbox(const OTIdentifier &USER_ID, const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
static EXPORT bool DropServerNoticeToNymbox(bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const int64_t &lNewTransactionNumber, const int64_t &lInReferenceTo, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
void SetOpeningTransNo(const int64_t &theNumber)
Definition: OTParty.hpp:299
bool IsAuthorizingAgentForParty()
Definition: OTAgent.cpp:623
EXPORT bool VerifyTransactionNum(const OTString &strServerID, const int64_t &lTransNum) const
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)