135 #include "../recurring/OTAgreement.hpp"
167 otErr <<
"OTAgent::VerifySignature: Entities and roles are not yet "
168 "supported. Agent: " << m_strName <<
".\n";
202 if (
nullptr == m_pNym) {
204 otErr <<
"OTAgent::VerifySignature: Attempted to verify signature on "
206 "but no Nym had ever been loaded for this agent:\n\n"
207 << strTemp <<
"\n\n";
227 bool bNymID =
GetNymID(theAgentNymID);
237 otErr <<
"OTAgent::LoadNym: Failure loading "
238 "agent's public key:\n" << strNymID <<
"\n";
253 otErr <<
"OTAgent::LoadNym: Failure verifying agent's public key "
254 "or loading signed nymfile: " << strNymID <<
"\n";
260 otErr <<
"OTAgent::LoadNym: Failure. Are you sure this agent IS a Nym "
267 : m_bNymRepresentsSelf(false)
268 , m_bIsAnIndividual(false)
270 , m_pForParty(nullptr)
277 : m_bNymRepresentsSelf(bNymRepresentsSelf)
278 , m_bIsAnIndividual(bIsAnIndividual)
280 , m_pForParty(nullptr)
282 , m_strNymID(strNymID)
283 , m_strRoleID(strRoleID)
284 , m_strGroupName(strGroupName)
289 bool bNymRepresentsSelf)
291 : m_bNymRepresentsSelf(bNymRepresentsSelf),
292 m_bIsAnIndividual(true),
294 m_pForParty(nullptr),
295 m_strName(str_agent_name.c_str())
304 if (!bNymRepresentsSelf) {
310 otErr <<
"OTAgent::OTAgent: THIS HASN'T BEEN WRITTEN YET!!\n";
317 m_pForParty = &theOwnerParty;
333 if (theOwnerParty.
IsNym())
336 m_bNymRepresentsSelf =
true;
337 m_bIsAnIndividual =
true;
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() :
"");
368 return m_bNymRepresentsSelf;
377 return !m_bNymRepresentsSelf;
392 return m_bIsAnIndividual;
401 return !m_bIsAnIndividual;
540 bool bNymID =
GetNymID(theAgentNymID);
544 if (bNymID && (theNymID == theAgentNymID))
return true;
556 bool bNymID =
GetNymID(theAgentNymID);
560 if (bNymID && theNym.
CompareID(theAgentNymID)) {
607 bool bSuccessEntityID =
false;
608 std::string str_entity_id = m_pForParty->
GetEntityID(&bSuccessEntityID);
610 if (bSuccessEntityID && (str_entity_id.size() > 0)) {
611 OTString strEntityID(str_entity_id.c_str());
625 if (
nullptr == m_pForParty)
return false;
638 if (
nullptr == m_pForParty) {
639 otErr <<
"OTAgent::CountAuthorizedAccts: Error: m_pForParty was "
653 strGroupName.
Set(m_strGroupName);
672 const std::string str_agent_name(m_strName.
Get());
677 if (
nullptr != m_pNym) {
681 otErr <<
"OTAgent::RetrieveNymPointers: Failed: m_strName is "
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,
689 otErr <<
"OTAgent::RetrieveNymPointer: Failed on insertion, as "
690 "though another nym were already "
691 "there with the same agent name! (" << m_strName <<
")\n";
704 otErr <<
"OTAgent::VerifyAgencyOfAccount: ERROR: Entities and roles "
705 "haven't been coded yet.\n";
720 const int64_t& lNewTransactionNumber,
const int64_t& lClosingNumber,
726 const char* szFunc =
"OTAgent::DropFinalReceiptToInbox";
729 bool bNymID =
GetNymID(theAgentNymID);
739 std::unique_ptr<OTPseudonym> theNymAngel;
744 if (
nullptr != pNymMap) {
745 const OTString strNymID(theAgentNymID);
748 auto ittt = pNymMap->find(strNymID.
Get());
750 if (pNymMap->end() != ittt)
772 if (
nullptr == (pNym =
LoadNym(theServerNym)))
773 otErr << szFunc <<
": Failed loading Nym.\n";
775 theNymAngel.reset(pNym);
787 if ((
nullptr != pNym) && (lClosingNumber > 0) &&
792 theAgentNymID, theAccountID, lNewTransactionNumber,
793 lClosingNumber, strOrigCronItem, pstrNote,
800 <<
": Error: pNym is nullptr, or lClosingNumber <=0, "
801 "or pNym->VerifyIssuedNum(strServerID, "
802 "lClosingNumber)) failed to verify.\n";
805 otErr << szFunc <<
": No NymID available for this agent...\n";
811 OTSmartContract& theSmartContract,
const int64_t& lNewTransactionNumber,
821 bool bNymID =
GetNymID(theAgentNymID);
825 if (
true == bNymID) {
828 if ((
nullptr != pActualNym) && pActualNym->
CompareID(theAgentNymID))
829 pToActualNym = pActualNym;
832 theAgentNymID, lNewTransactionNumber, strOrigCronItem, pstrNote,
833 pstrAttachment, pToActualNym);
846 const int64_t& lNewTransactionNumber,
const int64_t& lInReferenceTo,
851 bool bNymID =
GetNymID(theAgentNymID);
855 if (
true == bNymID) {
858 if ((
nullptr != pActualNym) && pActualNym->
CompareID(theAgentNymID))
859 pToActualNym = pActualNym;
860 else if ((
nullptr != m_pNym) && m_pNym->
CompareID(theAgentNymID))
861 pToActualNym = m_pNym;
864 bSuccessMsg, theServerNym, theServerID, theAgentNymID,
865 lNewTransactionNumber, lInReferenceTo, strReference, pstrNote,
866 pstrAttachment, pToActualNym);
878 otErr <<
"OTAgent::SignContract: Entities and roles are not yet "
879 "supported. Agent: " << m_strName <<
".\n";
883 if (
nullptr == m_pNym) {
884 otErr <<
"OTAgent::SignContract: Nym was nullptr while trying to sign "
885 "contract. Agent: " << m_strName <<
".\n";
897 otErr <<
"OTAgent::VerifyIssuedNumber: Error: Entities and Roles are "
898 "not yet supported. Agent: " << m_strName <<
"\n";
902 if (
nullptr != m_pNym)
905 otErr <<
"OTAgent::VerifyIssuedNumber: Error: m_pNym was nullptr. For "
906 "agent: " << m_strName <<
"\n";
916 otErr <<
"OTAgent::VerifyTransactionNumber: Error: Entities and Roles "
917 "are not yet supported. Agent: " << m_strName <<
"\n";
921 if (
nullptr != m_pNym)
924 otErr <<
"OTAgent::VerifyTransactionNumber: Error: m_pNym was nullptr. "
925 "For agent: " << m_strName <<
"\n";
934 const int64_t& lNumber,
const OTString& strServerID,
944 otErr << __FUNCTION__
945 <<
": Error: Entities and Roles are not yet supported. Agent: "
946 << m_strName <<
"\n";
950 if (
nullptr != m_pNym) {
956 if (
nullptr == pSignerNym) pSignerNym = m_pNym;
964 theServerID, lNumber, bSave, pSignerNym);
979 auto theSetIT = theIDSet.find(lNumber);
981 if (theIDSet.end() != theSetIT)
984 theIDSet.erase(lNumber);
989 otErr << __FUNCTION__ <<
": Number (" << lNumber
990 <<
") failed to verify for agent: " << m_strName
991 <<
" (Thus didn't bother 'adding it back'.)\n";
994 otErr << __FUNCTION__
995 <<
": Error: m_pNym was nullptr. For agent: " << m_strName
1012 otErr <<
"OTAgent::" << __FUNCTION__
1013 <<
": Error: Entities and Roles are not yet supported. Agent: "
1014 << m_strName <<
"\n";
1018 if (
nullptr != m_pNym) {
1019 std::set<int64_t>& theIDSet =
1023 const bool bSuccess =
1027 theIDSet.insert(lNumber);
1033 otErr <<
"OTAgent::" << __FUNCTION__
1034 <<
": Error, should never happen. (I'd assume you aren't "
1035 "removing numbers without verifying first if they're "
1040 otErr <<
"OTAgent::" << __FUNCTION__
1041 <<
": Error: m_pNym was nullptr. For agent: " << m_strName
1052 const OTString& strServerID,
bool bSave,
1057 otErr <<
"OTAgent::" << __FUNCTION__
1058 <<
": Error: Entities and Roles are not yet supported. Agent: "
1059 << m_strName <<
"\n";
1063 if (
nullptr != m_pNym) {
1064 std::set<int64_t>& theIDSet =
1068 const bool bSuccess =
1072 if (
nullptr == pSignerNym) pSignerNym = m_pNym;
1077 auto theSetIT = theIDSet.find(lNumber);
1079 if (theIDSet.end() != theSetIT)
1082 theIDSet.erase(lNumber);
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";
1094 otErr <<
"OTAgent::" << __FUNCTION__
1095 <<
": Error: m_pNym was nullptr. For agent: " << m_strName
1106 int64_t lTransactionNumber = 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";
1118 otOut <<
"OTAgent::ReserveClosingTransNum: *** Failure *** Nym "
1119 "needs at least 1 transaction number available in order "
1125 lTransactionNumber)) {
1126 otErr <<
"OTAgent::ReserveClosingTransNum: Error: Strangely, "
1127 "unable to get a transaction number, even though "
1128 "supposedly one was there.\n";
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";
1158 int64_t lTransactionNumber = 0;
1159 if (
nullptr == m_pForParty) {
1160 otErr <<
"OTAgent::ReserveOpeningTransNum: Error: Party pointer "
1161 "was nullptr. SHOULD NEVER HAPPEN!!\n";
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";
1175 otOut <<
"OTAgent::ReserveOpeningTransNum: *** Failure *** Nym "
1176 "needs at least 1 transaction number available in order "
1182 lTransactionNumber)) {
1183 otErr <<
"OTAgent::ReserveOpeningTransNum: Error: Strangely, "
1184 "unable to get a transaction number, even though "
1185 "supposedly one was there.\n";
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";
1216 "<agent\n name=\"%s\"\n"
1217 " doesAgentRepresentHimself=\"%s\"\n"
1218 " isAgentAnIndividual=\"%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());
void SetAgentName(const OTString &strAgentName)
std::string GetNymID(bool *pBoolSuccess=nullptr) const
void RetrieveNymPointer(mapOfNyms &map_Nyms_Already_Loaded)
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)
bool DoesRepresentAnEntity() const
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()
bool ReserveOpeningTransNum(const OTString &strServerID)
bool VerifySignature(const OTContract &theContract) const
EXPORT bool GetNymID(OTIdentifier &theOutput) const
void SetNymPointer(OTPseudonym &theNym)
EXPORT bool VerifyOwnerByID(const OTIdentifier &nymId) const
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)
int32_t GetCountAuthorizedAccts()
bool ReserveClosingTransNum(const OTString &strServerID, OTPartyAccount &thePartyAcct)
bool GetSignerID(OTIdentifier &theOutput) const
bool GetRoleID(OTIdentifier &theOutput) const
OTLOG_IMPORT OTLogStream otOut
OTPseudonym * LoadNym(OTPseudonym &theServerNym)
bool VerifyTransactionNumber(const int64_t &lNumber, const OTString &strServerID)
std::map< std::string, OTPseudonym * > mapOfNyms
EXPORT bool IsValidSignerID(const OTIdentifier &theNymID)
EXPORT bool LoadSignedNymfile(OTPseudonym &SIGNER_NYM)
bool RemoveIssuedNumber(const int64_t &lNumber, const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
EXPORT void Concatenate(const char *arg,...)
std::string GetEntityID(bool *pBoolSuccess=nullptr) const
EXPORT int32_t GetTransactionNumCount(const OTIdentifier &theServerID) const
EXPORT bool SignContract(OTContract &theInput) const
EXPORT bool VerifyPseudonym() const
bool GetEntityID(OTIdentifier &theOutput) const
EXPORT bool Exists() const
EXPORT void SetString(const char *szString)
EXPORT void SetIdentifier(const OTIdentifier &theIdentifier)
EXPORT bool IsValidSigner(OTPseudonym &theNym)
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
EXPORT bool RemoveTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
void SetClosingTransNo(int64_t lTransNo)
bool VerifyIssuedNumber(const int64_t &lNumber, const OTString &strServerID)
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)
bool GetGroupName(OTString &strGroupName)
EXPORT bool RemoveIssuedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
bool HarvestTransactionNumber(const int64_t &lNumber, const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
bool DoesRepresentHimself() const
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)
EXPORT const char * Get() const
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
const std::string & GetAuthorizingAgentName() const
EXPORT bool IsAnIndividual() const
OTLOG_IMPORT OTLogStream otErr
bool GetPartyID(OTIdentifier &theOutput) const
void SetParty(OTParty &theOwnerParty)
bool VerifyAgencyOfAccount(const OTAccount &theAccount) const
void Serialize(OTString &strAppend) const
EXPORT void GetString(OTString &theStr) const
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
bool RemoveTransactionNumber(const int64_t &lNumber, const OTString &strServerID, OTPseudonym &SIGNER_NYM, bool bSave=true)
int32_t GetAccountCount() const
std::set< int64_t > & GetSetOpenCronItems()
int64_t GetOpeningTransNo() const
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)
bool IsAuthorizingAgentForParty()
EXPORT bool VerifyTransactionNum(const OTString &strServerID, const int64_t &lTransNum) const
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)