Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTAgreement Class Referenceabstract

#include <OTAgreement.hpp>

Inheritance diagram for opentxs::OTAgreement:
Collaboration diagram for opentxs::OTAgreement:

Public Member Functions

const OTStringGetConsideration () const
 
void SetMerchantSignedCopy (const OTString &strMerchantCopy)
 
const OTStringGetMerchantSignedCopy () const
 
EXPORT bool SetProposal (OTPseudonym &MERCHANT_NYM, const OTString &strConsideration, time64_t VALID_FROM=OT_TIME_ZERO, time64_t VALID_TO=OT_TIME_ZERO)
 
EXPORT bool Confirm (OTPseudonym &PAYER_NYM, OTPseudonym *pMERCHANT_NYM=nullptr, const OTIdentifier *p_id_MERCHANT_NYM=nullptr)
 
virtual bool VerifyAgreement (OTPseudonym &RECIPIENT_NYM, OTPseudonym &SENDER_NYM) const =0
 
virtual bool CompareAgreement (const OTAgreement &rhs) const
 
const OTIdentifierGetRecipientAcctID () const
 
const OTIdentifierGetRecipientUserID () const
 
void SetRecipientAcctID (const OTIdentifier &ACCT_ID)
 
void SetRecipientUserID (const OTIdentifier &USER_ID)
 
EXPORT int64_t GetRecipientClosingTransactionNoAt (uint32_t nIndex) const
 
EXPORT int32_t GetRecipientCountClosingNumbers () const
 
void AddRecipientClosingTransactionNo (const int64_t &lClosingTransactionNo)
 
EXPORT int64_t GetRecipientOpeningNum () const
 
EXPORT int64_t GetRecipientClosingNum () const
 
virtual bool CanRemoveItemFromCron (OTPseudonym &theNym)
 
virtual void HarvestOpeningNumber (OTPseudonym &theNym)
 
virtual EXPORT void HarvestClosingNumbers (OTPseudonym &theNym)
 
virtual bool ProcessCron ()
 
virtual bool HasTransactionNum (const int64_t &lInput) const
 
virtual void GetAllTransactionNumbers (OTNumList &numlistOutput) const
 
virtual bool VerifyNymAsAgent (OTPseudonym &theNym, OTPseudonym &theSignerNym, mapOfNyms *pmap_ALREADY_LOADED=nullptr) const
 
virtual bool VerifyNymAsAgentForAccount (OTPseudonym &theNym, OTAccount &theAccount) const
 
EXPORT bool SendNoticeToAllParties (bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &theServerID, const int64_t &lNewTransactionNumber, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr) const
 
 OTAgreement ()
 
 OTAgreement (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID)
 
 OTAgreement (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &SENDER_USER_ID, const OTIdentifier &RECIPIENT_ACCT_ID, const OTIdentifier &RECIPIENT_USER_ID)
 
virtual ~OTAgreement ()
 
void InitAgreement ()
 
virtual void Release ()
 
void Release_Agreement ()
 
virtual bool IsValidOpeningNumber (const int64_t &lOpeningNum) const
 
virtual EXPORT int64_t GetOpeningNumber (const OTIdentifier &theNymID) const
 
virtual int64_t GetClosingNumber (const OTIdentifier &theAcctID) const
 
virtual int32_t ProcessXMLNode (irr::io::IrrXMLReader *&xml)
 
virtual void UpdateContents ()
 
virtual bool SaveContractWallet (std::ofstream &ofs) const
 
- Public Member Functions inherited from opentxs::OTCronItem
 OTCronItem ()
 
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)
 
bool DropFinalReceiptToNymbox (const OTIdentifier &USER_ID, const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
 
void HookActivationOnCron (OTPseudonym *pActivator, bool bForTheFirstTime=false)
 
void HookRemovalFromCron (OTPseudonym *pRemover, int64_t newTransactionNo)
 
bool IsFlaggedForRemoval () const
 
void FlagForRemoval ()
 
void SetCronPointer (OTCron &theCron)
 
void SetCreationDate (const time64_t &CREATION_DATE)
 
const time64_tGetCreationDate () const
 
EXPORT bool SetDateRange (time64_t VALID_FROM=OT_TIME_ZERO, time64_t VALID_TO=OT_TIME_ZERO)
 
void SetLastProcessDate (const time64_t &THE_DATE)
 
const time64_tGetLastProcessDate () const
 
void SetProcessInterval (const int64_t &THE_DATE)
 
const int64_t & GetProcessInterval () const
 
OTCronGetCron () const
 
void setServerNym (OTPseudonym *serverNym)
 
void setServerId (OTIdentifier *serverId)
 
EXPORT bool SaveCronReceipt ()
 
EXPORT bool SaveActiveCronReceipt (const OTIdentifier &theNymID)
 
virtual ~OTCronItem ()
 
void InitCronItem ()
 
void Release_CronItem ()
 
EXPORT bool GetCancelerID (OTIdentifier &theOutput) const
 
EXPORT bool IsCanceled () const
 
EXPORT bool CancelBeforeActivation (OTPseudonym &theCancelerNym)
 
EXPORT int64_t GetClosingTransactionNoAt (uint32_t nIndex) const
 
EXPORT int32_t GetCountClosingNumbers () const
 
EXPORT void AddClosingTransactionNo (const int64_t &lClosingTransactionNo)
 
EXPORT int64_t GetOpeningNum () const
 
EXPORT int64_t GetClosingNum () const
 
- Public Member Functions inherited from opentxs::OTTrackable
 OTTrackable ()
 
 OTTrackable (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID)
 
 OTTrackable (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &ACCT_ID, const OTIdentifier &USER_ID)
 
virtual ~OTTrackable ()
 
void InitTrackable ()
 
void Release_Trackable ()
 
int64_t GetTransactionNum () const
 
void SetTransactionNum (int64_t lTransactionNum)
 
const OTIdentifierGetSenderAcctID () const
 
const OTIdentifierGetSenderUserID () const
 
- Public Member Functions inherited from opentxs::OTInstrument
EXPORT OTInstrument ()
 
EXPORT OTInstrument (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID)
 
virtual EXPORT ~OTInstrument ()
 
void Release_Instrument ()
 
EXPORT bool VerifyCurrentDate ()
 
EXPORT bool IsExpired ()
 
time64_t GetValidFrom () const
 
time64_t GetValidTo () const
 
const OTIdentifierGetAssetID () const
 
const OTIdentifierGetServerID () const
 
void InitInstrument ()
 
- Public Member Functions inherited from opentxs::OTScriptable
virtual EXPORT void SetDisplayLabel (const std::string *pstrLabel=nullptr)
 
int32_t GetPartyCount () const
 
int32_t GetBylawCount () const
 
virtual EXPORT bool AddParty (OTParty &theParty)
 
virtual EXPORT bool AddBylaw (OTBylaw &theBylaw)
 
virtual EXPORT bool ConfirmParty (OTParty &theParty)
 
EXPORT OTPartyGetParty (std::string str_party_name) const
 
EXPORT OTBylawGetBylaw (std::string str_bylaw_name) const
 
EXPORT OTClauseGetClause (std::string str_clause_name) const
 
EXPORT OTPartyGetPartyByIndex (int32_t nIndex) const
 
EXPORT OTBylawGetBylawByIndex (int32_t nIndex) const
 
EXPORT OTPartyFindPartyBasedOnNymAsAgent (OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
 
EXPORT OTPartyFindPartyBasedOnNymAsAuthAgent (OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
 
OTPartyFindPartyBasedOnAccount (OTAccount &theAccount, OTPartyAccount **ppPartyAccount=nullptr) const
 
OTPartyFindPartyBasedOnNymIDAsAgent (const OTIdentifier &theNymID, OTAgent **ppAgent=nullptr) const
 
OTPartyFindPartyBasedOnNymIDAsAuthAgent (const OTIdentifier &theNymID, OTAgent **ppAgent=nullptr) const
 
OTPartyFindPartyBasedOnAccountID (const OTIdentifier &theAcctID, OTPartyAccount **ppPartyAccount=nullptr) const
 
OTAgentGetAgent (std::string str_agent_name) const
 
OTPartyAccountGetPartyAccount (std::string str_acct_name) const
 
OTPartyAccountGetPartyAccountByID (const OTIdentifier &theAcctID) const
 
EXPORT int32_t GetCountTransNumsNeededForAgent (std::string str_agent_name) const
 
bool VerifyPartyAuthorization (OTParty &theParty, OTPseudonym &theSignerNym, const OTString &strServerID, mapOfNyms *pmap_ALREADY_LOADED=nullptr, mapOfNyms *pmap_NEWLY_LOADED=nullptr, bool bBurnTransNo=false)
 
bool VerifyPartyAcctAuthorization (OTPartyAccount &thePartyAcct, OTPseudonym &theSignerNym, const OTString &strServerID, bool bBurnTransNo=false)
 
EXPORT bool VerifyThisAgainstAllPartiesSignedCopies ()
 
EXPORT bool AllPartiesHaveSupposedlyConfirmed ()
 
void RetrieveNymPointers (mapOfNyms &map_Nyms_Already_Loaded)
 
void ClearTemporaryPointers ()
 
bool GetHooks (std::string str_HookName, mapOfClauses &theResults)
 
OTClauseGetCallback (std::string str_CallbackName)
 
OTVariableGetVariable (std::string str_VarName)
 
bool IsDirty () const
 
bool IsDirtyImportant () const
 
void SetAsClean ()
 
EXPORT bool SendNoticeToAllParties (bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &theServerID, const int64_t &lNewTransactionNumber, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr) const
 
EXPORT bool CanExecuteClause (std::string str_party_name, std::string str_clause_name)
 
bool ExecuteCallback (OTClause &theCallbackClause, mapOfVariables &theParameters, OTVariable &varReturnVal)
 
virtual EXPORT void RegisterOTNativeCallsWithScript (OTScript &theScript)
 
virtual EXPORT bool Compare (OTScriptable &rhs) const
 
 OTScriptable ()
 
virtual ~OTScriptable ()
 
void UpdateContentsToString (OTString &strAppend, bool bCalculatingID) const
 
virtual EXPORT void CalculateContractID (OTIdentifier &newID) const
 
void Release_Scriptable ()
 
- Public Member Functions inherited from opentxs::OTContract
const char * GetHashType () const
 
void SetIdentifier (const OTIdentifier &theID)
 
EXPORT OTContract ()
 
EXPORT OTContract (const OTString &name, const OTString &foldername, const OTString &filename, const OTString &strID)
 
EXPORT OTContract (const OTString &strID)
 
EXPORT OTContract (const OTIdentifier &theID)
 
void Initialize ()
 
virtual EXPORT ~OTContract ()
 
EXPORT void Release_Contract ()
 
EXPORT void ReleaseSignatures ()
 
virtual EXPORT bool CreateContract (const OTString &strContract, const OTPseudonym &theSigner)
 
EXPORT bool InsertNym (const OTString &strKeyName, const OTString &strKeyValue)
 
EXPORT void GetName (OTString &strName) const
 
EXPORT void SetName (const OTString &strName)
 
virtual EXPORT bool VerifyContract ()
 
virtual EXPORT void GetIdentifier (OTIdentifier &theIdentifier) const
 
virtual EXPORT void GetIdentifier (OTString &theIdentifier) const
 
EXPORT void GetFilename (OTString &strFilename) const
 
EXPORT void GetFoldername (OTString &strFoldername) const
 
virtual EXPORT bool LoadContract ()
 
EXPORT bool LoadContract (const char *szFoldername, const char *szFilename)
 
EXPORT bool LoadContractFromString (const OTString &theStr)
 
bool LoadContractRawFile ()
 
EXPORT bool ParseRawFile ()
 
EXPORT bool SaveToContractFolder ()
 
EXPORT bool SaveContractRaw (OTString &strOutput) const
 
EXPORT bool RewriteContract (OTString &strOutput) const
 
EXPORT bool SaveContract ()
 
EXPORT bool SaveContract (const char *szFoldername, const char *szFilename)
 
virtual EXPORT void CreateContents ()
 
EXPORT void CreateInnerContents ()
 
virtual EXPORT bool SaveContents (std::ofstream &ofs) const
 
virtual EXPORT bool SaveContractWallet (OTString &strContents) const
 
virtual EXPORT bool DisplayStatistics (OTString &strContents) const
 
virtual EXPORT bool SaveContents (OTString &strContents) const
 
virtual EXPORT bool SignContract (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const char *szFoldername, const char *szFilename, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
virtual EXPORT bool VerifyContractID () const
 
virtual EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
virtual EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifyWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const char *szFoldername, const char *szFilename, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT const OTAsymmetricKeyGetContractPublicKey () const
 
EXPORT const OTPseudonymGetContractPublicNym () const
 

Static Public Member Functions

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)
 
- Static Public Member Functions inherited from opentxs::OTCronItem
static EXPORT OTCronItemNewCronItem (const OTString &strCronItem)
 
static EXPORT OTCronItemLoadCronReceipt (const int64_t &lTransactionNum)
 
static EXPORT OTCronItemLoadActiveCronReceipt (const int64_t &lTransactionNum, const OTIdentifier &serverID)
 
static EXPORT bool EraseActiveCronReceipt (const int64_t &lTransactionNum, const OTIdentifier &nymID, const OTIdentifier &serverID)
 
static EXPORT bool GetActiveCronTransNums (OTNumList &output, const OTIdentifier &nymID, const OTIdentifier &serverID)
 
- Static Public Member Functions inherited from opentxs::OTScriptable
static EXPORT OTScriptableInstantiateScriptable (const OTString &strInput)
 
static bool ValidateName (std::string str_name)
 
static std::string GetTime ()
 
- Static Public Member Functions inherited from opentxs::OTContract
static EXPORT bool DearmorAndTrim (const OTString &strInput, OTString &strOutput, OTString &strFirstLine)
 
static bool AddBookendsAroundContent (OTString &strOutput, const OTString &strContents, const OTString &strContractType, const OTString &strHashType, const listOfSignatures &listSignatures)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTString &strOutput)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTString &strOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool SkipToElement (irr::io::IrrXMLReader *&xml)
 
static bool SkipToTextField (irr::io::IrrXMLReader *&xml)
 
static bool SkipAfterLoadingField (irr::io::IrrXMLReader *&xml)
 
static EXPORT bool SignFlatText (OTString &strFlatText, const OTString &strContractType, const OTPseudonym &theSigner, OTString &strOutput)
 

Protected Member Functions

virtual void onFinalReceipt (OTCronItem &theOrigCronItem, const int64_t &lNewTransactionNumber, OTPseudonym &theOriginator, OTPseudonym *pRemover)
 
virtual void onRemovalFromCron ()
 
- Protected Member Functions inherited from opentxs::OTCronItem
 OTCronItem (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID)
 
 OTCronItem (const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &ACCT_ID, const OTIdentifier &USER_ID)
 
virtual void onActivate ()
 
void ClearClosingNumbers ()
 
- Protected Member Functions inherited from opentxs::OTTrackable
void SetSenderAcctID (const OTIdentifier &ACCT_ID)
 
void SetSenderUserID (const OTIdentifier &USER_ID)
 
- Protected Member Functions inherited from opentxs::OTInstrument
void SetValidFrom (time64_t TIME_FROM)
 
void SetValidTo (time64_t TIME_TO)
 
void SetAssetID (const OTIdentifier &ASSET_ID)
 
void SetServerID (const OTIdentifier &SERVER_ID)
 
- Protected Member Functions inherited from opentxs::OTContract
bool LoadContractXML ()
 

Protected Attributes

OTString m_strConsideration
 
OTString m_strMerchantSignedCopy
 
std::deque< int64_t > m_dequeRecipientClosingNumbers
 
- Protected Attributes inherited from opentxs::OTCronItem
std::deque< int64_t > m_dequeClosingNumbers
 
OTIdentifierm_pCancelerNymID
 
bool m_bCanceled
 
bool m_bRemovalFlag
 
- Protected Attributes inherited from opentxs::OTTrackable
int64_t m_lTransactionNum
 
OTIdentifier m_SENDER_ACCT_ID
 
OTIdentifier m_SENDER_USER_ID
 
- Protected Attributes inherited from opentxs::OTInstrument
OTIdentifier m_AssetTypeID
 
OTIdentifier m_ServerID
 
time64_t m_VALID_FROM
 
time64_t m_VALID_TO
 
- Protected Attributes inherited from opentxs::OTScriptable
mapOfParties m_mapParties
 
mapOfBylaws m_mapBylaws
 
bool m_bCalculatingID
 
bool m_bSpecifyAssetID
 
bool m_bSpecifyParties
 
OTString m_strLabel
 
- Protected Attributes inherited from opentxs::OTContract
OTString m_strName
 
OTString m_strFoldername
 
OTString m_strFilename
 
OTIdentifier m_ID
 
OTStringXML m_xmlUnsigned
 
OTString m_strRawFile
 
OTString m_strSigHashType
 
OTString m_strContractType
 
mapOfNyms m_mapNyms
 
listOfSignatures m_listSignatures
 
OTString m_strVersion
 
OTString m_strEntityShortName
 
OTString m_strEntityLongName
 
OTString m_strEntityEmail
 
OTString::Map m_mapConditions
 

Detailed Description

Definition at line 169 of file OTAgreement.hpp.

Constructor & Destructor Documentation

opentxs::OTAgreement::OTAgreement ( )

Definition at line 1457 of file OTAgreement.cpp.

1458  : ot_super()
1459 {
1460  InitAgreement();
1461 }
opentxs::OTAgreement::OTAgreement ( const OTIdentifier SERVER_ID,
const OTIdentifier ASSET_ID 
)

Definition at line 1463 of file OTAgreement.cpp.

1465  : ot_super(SERVER_ID, ASSET_ID)
1466 {
1467  InitAgreement();
1468 }
opentxs::OTAgreement::OTAgreement ( const OTIdentifier SERVER_ID,
const OTIdentifier ASSET_ID,
const OTIdentifier SENDER_ACCT_ID,
const OTIdentifier SENDER_USER_ID,
const OTIdentifier RECIPIENT_ACCT_ID,
const OTIdentifier RECIPIENT_USER_ID 
)

Definition at line 1470 of file OTAgreement.cpp.

1476  : ot_super(SERVER_ID, ASSET_ID, SENDER_ACCT_ID, SENDER_USER_ID)
1477 {
1478  InitAgreement();
1479 
1480  SetRecipientAcctID(RECIPIENT_ACCT_ID);
1481  SetRecipientUserID(RECIPIENT_USER_ID);
1482 }
void SetRecipientUserID(const OTIdentifier &USER_ID)
void SetRecipientAcctID(const OTIdentifier &ACCT_ID)
opentxs::OTAgreement::~OTAgreement ( )
virtual

Definition at line 1484 of file OTAgreement.cpp.

1485 {
1487 }

Member Function Documentation

void opentxs::OTAgreement::AddRecipientClosingTransactionNo ( const int64_t &  lClosingTransactionNo)

Definition at line 1012 of file OTAgreement.cpp.

1014 {
1015  m_dequeRecipientClosingNumbers.push_back(lClosingTransactionNo);
1016 }
std::deque< int64_t > m_dequeRecipientClosingNumbers
bool opentxs::OTAgreement::CanRemoveItemFromCron ( OTPseudonym theNym)
virtual

See if theNym has rights to remove this item from Cron.

Reimplemented from opentxs::OTCronItem.

Definition at line 1045 of file OTAgreement.cpp.

1046 {
1047  // You don't just go willy-nilly and remove a cron item from a market unless
1048  // you check first
1049  // and make sure the Nym who requested it actually has said number (or a
1050  // related closing number)
1051  // signed out to him on his last receipt...
1052  //
1053  if (true == ot_super::CanRemoveItemFromCron(theNym)) return true;
1054 
1055  const OTString strServerID(GetServerID());
1056 
1057  // Usually the Nym is the originator. (Meaning GetTransactionNum() on this
1058  // agreement
1059  // is still verifiable as an issued number on theNum, and belongs to him.)
1060  // In that case,
1061  // the above call will discover this, and return true.
1062  // In other cases, theNym has the right to Remove the item even though
1063  // theNym didn't originate it.
1064  // (Like if he is the recipient -- not the sender -- in a payment plan.) We
1065  // check such things
1066  // HERE in this function (see below.)
1067  //
1068  if (!theNym.CompareID(GetRecipientUserID())) {
1069  otOut << "OTAgreement::" << __FUNCTION__
1070  << " Weird: Nym tried to remove agreement (payment plan), even "
1071  "though he apparently wasn't the sender OR recipient.\n";
1072  return false;
1073  }
1074  else if (GetRecipientCountClosingNumbers() < 2) {
1075  otOut << "OTAgreement::" << __FUNCTION__
1076  << ": Weird: Recipient tried to remove agreement "
1077  "(or payment plan); expected 2 closing numbers to be "
1078  "available--that weren't."
1079  " (Found " << GetRecipientCountClosingNumbers() << ").\n";
1080  return false;
1081  }
1082 
1083  if (false ==
1084  theNym.VerifyIssuedNum(strServerID, GetRecipientClosingNum())) {
1085  otOut << "OTAgreement::" << __FUNCTION__ << ": Recipient Closing "
1086  "number didn't verify (for "
1087  "removal from cron).\n";
1088  return false;
1089  }
1090 
1091  // By this point, we KNOW theNym is the sender, and we KNOW there are the
1092  // proper number of transaction
1093  // numbers available to close. We also know that this cron item really was
1094  // on the cron object, since
1095  // that is where it was looked up from, when this function got called! So
1096  // I'm pretty sure, at this point,
1097  // to authorize removal, as long as the transaction num is still issued to
1098  // theNym (this check here.)
1099  //
1100  return theNym.VerifyIssuedNum(strServerID, GetRecipientOpeningNum());
1101 
1102  // Normally this will be all we need to check. The originator will have the
1103  // transaction
1104  // number signed-out to him still, if he is trying to close it. BUT--in some
1105  // cases, someone
1106  // who is NOT the originator can cancel. Like in a payment plan, the sender
1107  // is also the depositor,
1108  // who would normally be the person cancelling the plan. But technically,
1109  // the RECIPIENT should
1110  // also have the ability to cancel that payment plan. BUT: the transaction
1111  // number isn't signed
1112  // out to the RECIPIENT... In THAT case, the below VerifyIssuedNum() won't
1113  // work! In those cases,
1114  // expect that the special code will be in the subclasses override of this
1115  // function. (OTPaymentPlan::CanRemoveItem() etc)
1116 
1117  // P.S. If you override this function, MAKE SURE to call the parent
1118  // (OTCronItem::CanRemoveItem) first,
1119  // for the VerifyIssuedNum call above. Only if that fails, do you need to
1120  // dig deeper...
1121 }
EXPORT int32_t GetRecipientCountClosingNumbers() const
OTLOG_IMPORT OTLogStream otOut
virtual bool CanRemoveItemFromCron(OTPseudonym &theNym)
Definition: OTCronItem.cpp:700
EXPORT int64_t GetRecipientOpeningNum() const
const OTIdentifier & GetServerID() const
EXPORT int64_t GetRecipientClosingNum() const
const OTIdentifier & GetRecipientUserID() const
bool opentxs::OTAgreement::CompareAgreement ( const OTAgreement rhs) const
virtual

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1123 of file OTAgreement.cpp.

1124 {
1125  // Compare OTAgreement specific info here.
1126 
1127  if ((m_strConsideration.Compare(rhs.m_strConsideration)) &&
1128  (GetRecipientAcctID() == rhs.GetRecipientAcctID()) &&
1129  (GetRecipientUserID() == rhs.GetRecipientUserID()) &&
1130  // ( m_dequeClosingNumbers == rhs.m_dequeClosingNumbers ) && //
1131  // The merchant wouldn't know the customer's trans#s.
1132  // (Thus wouldn't expect them to be set in BOTH versions...)
1134  rhs.m_dequeRecipientClosingNumbers) &&
1135  // ( GetTransactionNum() == rhs.GetTransactionNum() ) && //
1136  // (commented out for same reason as above.)
1137  // ( GetSenderAcctID() == rhs.GetSenderAcctID() ) && //
1138  // Same here -- we should let the merchant leave these blank,
1139  // ( GetSenderUserID() == rhs.GetSenderUserID() ) && //
1140  // and then allow the customer to add them in his version,
1141  (GetAssetID() == rhs.GetAssetID()) && // (and this Compare function
1142  // still still verify it.)
1143  (GetServerID() == rhs.GetServerID()) &&
1144  (GetValidFrom() == rhs.GetValidFrom()) &&
1145  (GetValidTo() == rhs.GetValidTo()))
1146  return true;
1147 
1148  return false;
1149 }
time64_t GetValidTo() const
const OTIdentifier & GetAssetID() const
const OTIdentifier & GetServerID() const
time64_t GetValidFrom() const
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier & GetRecipientAcctID() const
std::deque< int64_t > m_dequeRecipientClosingNumbers
bool opentxs::OTAgreement::Confirm ( OTPseudonym PAYER_NYM,
OTPseudonym pMERCHANT_NYM = nullptr,
const OTIdentifier p_id_MERCHANT_NYM = nullptr 
)

Definition at line 1282 of file OTAgreement.cpp.

1284 {
1285 
1286  OTIdentifier id_PAYER_NYM;
1287  PAYER_NYM.GetIdentifier(id_PAYER_NYM);
1288 
1289  if (GetRecipientUserID() == GetSenderUserID()) {
1290  otOut << __FUNCTION__ << ": Error: Sender and recipient have the same "
1291  "Nym ID (not allowed.)\n";
1292  return false;
1293  }
1294  else if ((nullptr != p_id_MERCHANT_NYM) &&
1295  (GetRecipientUserID() != *p_id_MERCHANT_NYM)) {
1296  otOut << __FUNCTION__ << ": Merchant has wrong NymID (should be same "
1297  "as RecipientUserID.)\n";
1298  return false;
1299  }
1300  else if ((nullptr != pMERCHANT_NYM) &&
1301  (GetRecipientUserID() != pMERCHANT_NYM->GetConstID())) {
1302  otOut << __FUNCTION__ << ": Merchant has wrong NymID (should be same "
1303  "as RecipientUserID.)\n";
1304  return false;
1305  }
1306  else if (GetSenderUserID() != id_PAYER_NYM) {
1307  otOut << __FUNCTION__
1308  << ": Payer has wrong NymID (should be same as SenderUserID.)\n";
1309  return false;
1310  }
1311  else if (PAYER_NYM.GetTransactionNumCount(GetServerID()) <
1312  2) // Need opening and closing numbers (that's 2)...
1313  {
1314  otOut << __FUNCTION__ << ": Failure. You need at least 2 transaction "
1315  "numbers available to do this.\n";
1316  return false;
1317  }
1318  else if (GetRecipientCountClosingNumbers() < 2) {
1319  otOut << __FUNCTION__ << ": Failure. (The merchant was supposed to "
1320  "attach 2 transaction numbers.)\n";
1321  return false;
1322  }
1323 
1324  // This is the single reason why MERCHANT_NYM was even passed in here!
1325  // Supposedly merchant has already signed. Let's verify this!!
1326  //
1327  if ((nullptr != pMERCHANT_NYM) &&
1328  (false == VerifySignature(*pMERCHANT_NYM))) {
1329  otOut << __FUNCTION__ << ": Merchant's signature failed to verify.\n";
1330  return false;
1331  }
1332 
1333  // Now that we KNOW the merchant signed it... SAVE MERCHANT's COPY.
1334  // Let's save a copy of the one the merchant signed, before changing it and
1335  // re-signing it,
1336  // (to add my own transaction numbers...)
1337  //
1338  OTString strTemp;
1339  SaveContractRaw(strTemp);
1340  SetMerchantSignedCopy(strTemp);
1341 
1342  // The payer has to submit TWO transaction numbers in order to activate this
1343  // agreement...
1344  //
1345  OTString strServerID(GetServerID());
1346  int64_t lTransactionNumber = 0, lClosingTransactionNo = 0;
1347 
1348  if (false ==
1349  PAYER_NYM.GetNextTransactionNum(PAYER_NYM, strServerID,
1350  lTransactionNumber)) {
1351  otErr << __FUNCTION__
1352  << ": Error: Strangely unable to get a transaction number.\n";
1353  return false;
1354  }
1355  else if (false ==
1356  PAYER_NYM.GetNextTransactionNum(PAYER_NYM, strServerID,
1357  lClosingTransactionNo)) {
1358  otErr << __FUNCTION__ << ": Error: Strangely unable to get a closing "
1359  "transaction number.\n";
1360  PAYER_NYM.AddTransactionNum(PAYER_NYM, strServerID, lTransactionNumber,
1361  true); // bSave=true
1362  // (Since the first one was successful, we just put it back before
1363  // returning.)
1364  return false;
1365  }
1366 
1367  // At this point we now HAVE 2 transaction numbers (for payer / sender)...
1368  // We can't return without USING THEM or PUTTING THEM BACK.
1369  //
1370 
1371  SetTransactionNum(lTransactionNumber); // Set the Transaction Number
1373  lClosingTransactionNo); // and the Closing Number (both for sender)...
1374 
1375  // CREATION DATE was set in the Merchant's proposal, and it's RESET here in
1376  // the Confirm.
1377  // This way, (since we still have the original proposal) we can see BOTH
1378  // times.
1379  //
1380  time64_t CURRENT_TIME = OTTimeGetCurrentTime();
1381  // Set the Creation Date.
1382  SetCreationDate(CURRENT_TIME);
1383 
1384  otLog4 << __FUNCTION__ << "(): Success!\n";
1385 
1386  return true;
1387 }
OTLOG_IMPORT OTLogStream otLog4
EXPORT int32_t GetRecipientCountClosingNumbers() const
const OTIdentifier & GetSenderUserID() const
void SetMerchantSignedCopy(const OTString &strMerchantCopy)
OTLOG_IMPORT OTLogStream otOut
EXPORT bool SaveContractRaw(OTString &strOutput) const
int64_t time64_t
Definition: Common.hpp:209
void SetCreationDate(const time64_t &CREATION_DATE)
Definition: OTCronItem.hpp:264
const OTIdentifier & GetServerID() const
time64_t OTTimeGetCurrentTime()
Definition: Common.hpp:211
void SetTransactionNum(int64_t lTransactionNum)
OTLOG_IMPORT OTLogStream otErr
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTContract.cpp:818
const OTIdentifier & GetRecipientUserID() const
EXPORT void AddClosingTransactionNo(const int64_t &lClosingTransactionNo)
Definition: OTCronItem.cpp:693
bool opentxs::OTAgreement::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 
)
static

Definition at line 271 of file OTAgreement.cpp.

278 {
279  OTLedger theLedger(USER_ID, USER_ID, SERVER_ID);
280 
281  // Inbox will receive notification of something ALREADY DONE.
282  //
283  bool bSuccessLoading = theLedger.LoadNymbox();
284 
285  if (true == bSuccessLoading)
286  bSuccessLoading = theLedger.VerifyAccount(theServerNym);
287  else
288  bSuccessLoading = theLedger.GenerateLedger(
289  USER_ID, SERVER_ID, OTLedger::nymbox, true); // bGenerateFile=true
290 
291  if (!bSuccessLoading) {
292  otErr << __FUNCTION__ << ": Failed loading or generating a nymbox. "
293  "(FAILED WRITING RECEIPT!!) \n";
294  return false;
295  }
296 
297  OTTransaction* pTransaction = OTTransaction::GenerateTransaction(
298  theLedger, OTTransaction::notice, lNewTransactionNumber);
299 
300  if (nullptr !=
301  pTransaction) // The above has an OT_ASSERT within, but I just
302  // like to check my pointers.
303  {
304  // The nymbox will get a receipt with the new transaction ID.
305  // That receipt has an "in reference to" field containing the original
306  // OTScriptable
307 
308  // Set up the transaction items (each transaction may have multiple
309  // items... but not in this case.)
310  //
311  OTItem* pItem1 =
313  OT_ASSERT(nullptr != pItem1); // This may be unnecessary, I'll have to
314  // check CreateItemFromTransaction. I'll
315  // leave it for now.
316 
317  pItem1->SetStatus(
318  bSuccessMsg ? OTItem::acknowledgement
319  : OTItem::rejection); // ACKNOWLEDGMENT or REJECTION ?
320 
321  //
322  // Here I make sure that the receipt (the nymbox notice) references the
323  // transaction number that the trader originally used to issue the cron
324  // item...
325  // This number is used to match up offers to trades, and used to track
326  // all cron items.
327  // (All Cron items require a transaction from the user to add them to
328  // Cron in the
329  // first place.)
330  //
331  pTransaction->SetReferenceToNum(lInReferenceTo);
332 
333  // The reference on the transaction probably contains a the original
334  // cron item or entity contract.
335  // Versus the updated item (which, if it exists, is stored on the pItem1
336  // just below.)
337  //
338  pTransaction->SetReferenceString(strReference);
339 
340  // The notice ITEM's NOTE probably contains the UPDATED SCRIPTABLE
341  // (usually a CRON ITEM. But maybe soon: Entity.)
342  if (nullptr != pstrNote) {
343  pItem1->SetNote(*pstrNote); // in markets, this is updated trade.
344  }
345 
346  // Nothing is special stored here so far for OTTransaction::notice, but
347  // the option is always there.
348  //
349  if (nullptr != pstrAttachment) {
350  pItem1->SetAttachment(*pstrAttachment);
351  }
352 
353  // sign the item
354  //
355  pItem1->SignContract(theServerNym);
356  pItem1->SaveContract();
357 
358  // the Transaction "owns" the item now and will handle cleaning it up.
359  pTransaction->AddItem(*pItem1);
360 
361  pTransaction->SignContract(theServerNym);
362  pTransaction->SaveContract();
363 
364  // Here the transaction we just created is actually added to the ledger.
365  theLedger.AddTransaction(*pTransaction);
366 
367  // Release any signatures that were there before (They won't
368  // verify anymore anyway, since the content has changed.)
369  theLedger.ReleaseSignatures();
370 
371  // Sign and save.
372  theLedger.SignContract(theServerNym);
373  theLedger.SaveContract();
374 
375  // TODO: Better rollback capabilities in case of failures here:
376 
377  OTIdentifier theNymboxHash;
378 
379  // Save nymbox to storage. (File, DB, wherever it goes.)
380  theLedger.SaveNymbox(&theNymboxHash);
381 
382  // Corresponds to the AddTransaction() call just above. These
383  // are stored in a separate file now.
384  //
385  pTransaction->SaveBoxReceipt(theLedger);
386 
387  // Update the NymboxHash (in the nymfile.)
388  //
389  const OTIdentifier ACTUAL_NYM_ID = USER_ID;
390  OTPseudonym theActualNym; // unused unless it's really not already
391  // loaded. (use pActualNym.)
392 
393  // We couldn't find the Nym among those already loaded--so we have to
394  // load
395  // it ourselves (so we can update its NymboxHash value.)
396 
397  if (nullptr == pActualNym) {
398  if (theServerNym.CompareID(ACTUAL_NYM_ID))
399  pActualNym = &theServerNym;
400 
401  else {
402  theActualNym.SetIdentifier(ACTUAL_NYM_ID);
403 
404  if (!theActualNym.LoadPublicKey()) // Note: this step
405  // may be unnecessary
406  // since we are only
407  // updating his
408  // Nymfile, not his
409  // key.
410  {
411  OTString strNymID(ACTUAL_NYM_ID);
412  otErr << __FUNCTION__
413  << ": Failure loading public key for Nym: "
414  << strNymID << ". "
415  "(To update his NymboxHash.) \n";
416  }
417  else if (theActualNym.VerifyPseudonym() && // this line may be
418  // unnecessary.
419  theActualNym.LoadSignedNymfile(
420  theServerNym)) // ServerNym here is not
421  // theActualNym's identity, but
422  // merely the signer on this file.
423  {
424  otLog3 << __FUNCTION__ << ": Loading actual Nym, since he "
425  "wasn't already loaded. (To "
426  "update his NymboxHash.)\n";
427  pActualNym = &theActualNym; // <=====
428  }
429  else {
430  OTString strNymID(ACTUAL_NYM_ID);
431  otErr << __FUNCTION__
432  << ": Failure loading or verifying Actual Nym public "
433  "key: " << strNymID
434  << ". "
435  "(To update his NymboxHash.)\n";
436  }
437  }
438  }
439 
440  // By this point we've made every possible effort to get the proper Nym
441  // loaded,
442  // so that we can update his NymboxHash appropriately.
443  //
444  if (nullptr != pActualNym) {
445  pActualNym->SetNymboxHashServerSide(theNymboxHash);
446  pActualNym->SaveSignedNymfile(theServerNym);
447  }
448 
449  // Really this true should be predicated on ALL the above functions
450  // returning true.
451  // Right?
452  //
453  return true; // Really this true should be predicated on ALL the above
454  // functions returning true. Right?
455  }
456  else
457  otErr << __FUNCTION__ << ": Failed trying to create Nymbox.\n";
458 
459  return false; // unreachable.
460 }
static EXPORT OTTransaction * GenerateTransaction(const OTIdentifier &theUserID, const OTIdentifier &theAccountID, const OTIdentifier &theServerID, transactionType theType, int64_t lTransactionNum=0)
OTLOG_IMPORT OTLogStream otLog3
static EXPORT OTItem * CreateItemFromTransaction(const OTTransaction &theOwner, OTItem::itemType theType, const OTIdentifier *pDestinationAcctID=nullptr)
Definition: OTItem.cpp:1451
#define OT_ASSERT(x)
Definition: Assert.hpp:150
OTLOG_IMPORT OTLogStream otErr
void opentxs::OTAgreement::GetAllTransactionNumbers ( OTNumList numlistOutput) const
virtual

Reimplemented from opentxs::OTTrackable.

Definition at line 482 of file OTAgreement.cpp.

483 {
484 
485  if (GetTransactionNum() > 0) numlistOutput.Add(GetTransactionNum());
486 
487  const size_t nSizeClosing = m_dequeClosingNumbers.size();
488 
489  for (size_t nIndex = 0; nIndex < nSizeClosing; ++nIndex) {
490  const int64_t lTemp = m_dequeClosingNumbers.at(nIndex);
491  if (lTemp > 0) numlistOutput.Add(lTemp);
492  }
493 
494  const size_t nSizeRecipient = m_dequeRecipientClosingNumbers.size();
495 
496  for (size_t nIndex = 0; nIndex < nSizeRecipient; ++nIndex) {
497  const int64_t lTemp = m_dequeRecipientClosingNumbers.at(nIndex);
498  if (lTemp > 0) numlistOutput.Add(lTemp);
499  }
500 }
int64_t GetTransactionNum() const
std::deque< int64_t > m_dequeRecipientClosingNumbers
std::deque< int64_t > m_dequeClosingNumbers
Definition: OTCronItem.hpp:169
int64_t opentxs::OTAgreement::GetClosingNumber ( const OTIdentifier theAcctID) const
virtual

Reimplemented from opentxs::OTCronItem.

Definition at line 970 of file OTAgreement.cpp.

971 {
972  const OTIdentifier& theRecipientAcctID = GetRecipientAcctID();
973 
974  if (theAcctID == theRecipientAcctID) return GetRecipientClosingNum();
975  // else...
976  return ot_super::GetClosingNumber(theAcctID);
977 }
EXPORT int64_t GetRecipientClosingNum() const
const OTIdentifier & GetRecipientAcctID() const
virtual int64_t GetClosingNumber(const OTIdentifier &theAcctID) const
const OTString& opentxs::OTAgreement::GetConsideration ( ) const
inline

Definition at line 203 of file OTAgreement.hpp.

204  {
205  return m_strConsideration;
206  }
const OTString& opentxs::OTAgreement::GetMerchantSignedCopy ( ) const
inline

Definition at line 211 of file OTAgreement.hpp.

212  {
214  }
OTString m_strMerchantSignedCopy
int64_t opentxs::OTAgreement::GetOpeningNumber ( const OTIdentifier theNymID) const
virtual

Reimplemented from opentxs::OTCronItem.

Definition at line 961 of file OTAgreement.cpp.

962 {
963  const OTIdentifier& theRecipientNymID = GetRecipientUserID();
964 
965  if (theNymID == theRecipientNymID) return GetRecipientOpeningNum();
966  // else...
967  return ot_super::GetOpeningNumber(theNymID);
968 }
virtual int64_t GetOpeningNumber(const OTIdentifier &theNymID) const
EXPORT int64_t GetRecipientOpeningNum() const
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier& opentxs::OTAgreement::GetRecipientAcctID ( ) const
inline

Definition at line 346 of file OTAgreement.hpp.

347  {
348  return m_RECIPIENT_ACCT_ID;
349  }
int64_t opentxs::OTAgreement::GetRecipientClosingNum ( ) const

Definition at line 986 of file OTAgreement.cpp.

987 {
988  return (GetRecipientCountClosingNumbers() > 1)
990  : 0; // todo stop hardcoding.
991 }
EXPORT int32_t GetRecipientCountClosingNumbers() const
EXPORT int64_t GetRecipientClosingTransactionNoAt(uint32_t nIndex) const
int64_t opentxs::OTAgreement::GetRecipientClosingTransactionNoAt ( uint32_t  nIndex) const

Definition at line 998 of file OTAgreement.cpp.

999 {
1000  OT_ASSERT_MSG(
1001  (nIndex < m_dequeRecipientClosingNumbers.size()),
1002  "OTAgreement::GetClosingTransactionNoAt: index out of bounds.");
1003 
1004  return m_dequeRecipientClosingNumbers.at(nIndex);
1005 }
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
std::deque< int64_t > m_dequeRecipientClosingNumbers
int32_t opentxs::OTAgreement::GetRecipientCountClosingNumbers ( ) const

Definition at line 1007 of file OTAgreement.cpp.

1008 {
1009  return static_cast<int32_t>(m_dequeRecipientClosingNumbers.size());
1010 }
std::deque< int64_t > m_dequeRecipientClosingNumbers
int64_t opentxs::OTAgreement::GetRecipientOpeningNum ( ) const

Definition at line 979 of file OTAgreement.cpp.

980 {
981  return (GetRecipientCountClosingNumbers() > 0)
983  : 0; // todo stop hardcoding.
984 }
EXPORT int32_t GetRecipientCountClosingNumbers() const
EXPORT int64_t GetRecipientClosingTransactionNoAt(uint32_t nIndex) const
const OTIdentifier& opentxs::OTAgreement::GetRecipientUserID ( ) const
inline

Definition at line 350 of file OTAgreement.hpp.

351  {
352  return m_RECIPIENT_USER_ID;
353  }
void opentxs::OTAgreement::HarvestClosingNumbers ( OTPseudonym theNym)
virtual

Reimplemented from opentxs::OTCronItem.

Definition at line 922 of file OTAgreement.cpp.

923 {
924  // Since we overrode the parent, we give it a chance to harvest also.
925  // If theNym is the sender, then his closing numbers will be harvested
926  // inside here. But what if the transaction was a success? The numbers
927  // will still be harvested, since they are still on the sender's issued
928  // list, but they should not have been harvested, regardless, since the
929  // transaction was a success and the server therefore has them marked as
930  // "used." So clearly you cannot just blindly call this function unless
931  // you know beforehand whether the message and transaction were a success.
932  //
934 
935  // The Nym is the original recipient. (If Compares true).
936  // FYI, if Nym is the original sender, then the above call will handle him.
937  //
938  // GetTransactionNum() is burned, but we can harvest the closing
939  // numbers from the "Closing" list, which is only for the sender's numbers.
940  // Subclasses will have to override this function for recipients, etc.
941  //
942  if (theNym.CompareID(GetRecipientUserID())) {
943  // otOut << "%s: Harvesting RECIPIENT...\n", __FUNCTION__);
944 
945  // This function will only "add it back" if it was really there in the
946  // first place.
947  // (Verifies it is on issued list first, before adding to available
948  // list.)
949  //
950  const bool bClawedBack = theNym.ClawbackTransactionNumber(
951  GetServerID(), GetRecipientClosingNum(), true); // bSave=true
952 
953  if (!bClawedBack) {
954  // otErr << "OTAgreement::HarvestClosingNumbers: Number
955  // (%lld) failed as issued. (Thus didn't bother 'adding it
956  // back'.)\n", GetRecipientClosingTransactionNoAt(i));
957  }
958  }
959 }
virtual void HarvestClosingNumbers(OTPseudonym &theNym)
const OTIdentifier & GetServerID() const
EXPORT int64_t GetRecipientClosingNum() const
const OTIdentifier & GetRecipientUserID() const
void opentxs::OTAgreement::HarvestOpeningNumber ( OTPseudonym theNym)
virtual

Reimplemented from opentxs::OTCronItem.

Definition at line 873 of file OTAgreement.cpp.

874 {
875  // since we overrode the parent, we give it a chance to harvest also.
876  // IF theNym is the original sender, the opening number will be harvested
877  // inside this call.
878  //
880 
881  // The Nym is the original recipient. (If Compares true).
882  // IN CASES where GetTransactionNum() isn't already burned, we can harvest
883  // it here.
884  //
885  if (theNym.CompareID(GetRecipientUserID())) {
886  // This function will only "add it back" if it was really there in the
887  // first place.
888  // (Verifies it is on issued list first, before adding to available
889  // list.)
890  //
891  const bool bClawedBack = theNym.ClawbackTransactionNumber(
892  GetServerID(), GetRecipientOpeningNum(), true); // bSave=true
893 
894  if (!bClawedBack) {
895  // otErr << "OTAgreement::HarvestOpeningNumber: Number
896  // (%lld) failed as issued. (Thus didn't bother 'adding it
897  // back'.)\n", GetRecipientOpeningNum());
898  }
899  }
900 
901  // NOTE: if the message failed (transaction never actually ran) then the
902  // sender AND recipient
903  // can both reclaim their opening numbers. But if the message SUCCEEDED and
904  // the transaction FAILED,
905  // then only the recipient can claim his opening number -- the sender's is
906  // already burned. So then,
907  // what if you mistakenly call this function and pass the sender, when that
908  // number is already burned?
909  // There's nothing this function can do, because we have no way of telling,
910  // from inside here,
911  // whether the message succeeded or not, and whether the transaction
912  // succeeded or not. Therefore,
913  // ==> we MUST rely on the CALLER to know this, and to avoid calling this
914  // function in the first place,
915  // if he's sitting on a sender with a failed transaction.
916 }
virtual void HarvestOpeningNumber(OTPseudonym &theNym)
EXPORT int64_t GetRecipientOpeningNum() const
const OTIdentifier & GetServerID() const
const OTIdentifier & GetRecipientUserID() const
bool opentxs::OTAgreement::HasTransactionNum ( const int64_t &  lInput) const
virtual

Reimplemented from opentxs::OTTrackable.

Definition at line 463 of file OTAgreement.cpp.

464 {
465  if (lInput == GetTransactionNum()) return true;
466 
467  const size_t nSizeClosing = m_dequeClosingNumbers.size();
468 
469  for (size_t nIndex = 0; nIndex < nSizeClosing; ++nIndex) {
470  if (lInput == m_dequeClosingNumbers.at(nIndex)) return true;
471  }
472 
473  const size_t nSizeRecipient = m_dequeRecipientClosingNumbers.size();
474 
475  for (size_t nIndex = 0; nIndex < nSizeRecipient; ++nIndex) {
476  if (lInput == m_dequeRecipientClosingNumbers.at(nIndex)) return true;
477  }
478 
479  return false;
480 }
int64_t GetTransactionNum() const
std::deque< int64_t > m_dequeRecipientClosingNumbers
std::deque< int64_t > m_dequeClosingNumbers
Definition: OTCronItem.hpp:169
void opentxs::OTAgreement::InitAgreement ( )

Definition at line 1489 of file OTAgreement.cpp.

1490 {
1491  m_strContractType = "AGREEMENT";
1492 }
OTString m_strContractType
Definition: OTContract.hpp:178
bool opentxs::OTAgreement::IsValidOpeningNumber ( const int64_t &  lOpeningNum) const
virtual

Reimplemented from opentxs::OTCronItem.

Definition at line 851 of file OTAgreement.cpp.

852 {
853  if (GetRecipientOpeningNum() == lOpeningNum) return true;
854 
855  return ot_super::IsValidOpeningNumber(lOpeningNum);
856 }
virtual bool IsValidOpeningNumber(const int64_t &lOpeningNum) const
EXPORT int64_t GetRecipientOpeningNum() const
void opentxs::OTAgreement::onFinalReceipt ( OTCronItem theOrigCronItem,
const int64_t &  lNewTransactionNumber,
OTPseudonym theOriginator,
OTPseudonym pRemover 
)
protectedvirtual

Reimplemented from opentxs::OTCronItem.

Definition at line 528 of file OTAgreement.cpp.

532 {
533 
534  OTCron* pCron = GetCron();
535  OT_ASSERT(nullptr != pCron);
536 
537  OTPseudonym* pServerNym = pCron->GetServerNym();
538  OT_ASSERT(nullptr != pServerNym);
539 
540  const char* szFunc = "OTAgreement::onFinalReceipt";
541 
542  // The finalReceipt Item's ATTACHMENT contains the UPDATED Cron Item.
543  // (With the SERVER's signature on it!)
544  //
545  OTString strUpdatedCronItem(*this);
546  OTString* pstrAttachment = &strUpdatedCronItem;
547 
548  const OTString strOrigCronItem(theOrigCronItem);
549 
550  OTPseudonym theRecipientNym; // Don't use this... use the pointer just
551  // below.
552 
553  // The Nym who is actively requesting to remove a cron item will be passed
554  // in as pRemover.
555  // However, sometimes there is no Nym... perhaps it just expired and
556  // pRemover is nullptr.
557  // The originating Nym (if different than remover) is loaded up. Otherwise
558  // the originator
559  // pointer just pointers to *pRemover.
560  //
561  OTPseudonym* pRecipient = nullptr;
562 
563  if (pServerNym->CompareID(GetRecipientUserID())) {
564  pRecipient = pServerNym; // Just in case the recipient Nym is also the
565  // server Nym.
566  }
567  //
568  // If pRemover is NOT nullptr, and he has the Recipient's ID...
569  // then set the pointer accordingly.
570  //
571  else if ((nullptr != pRemover) &&
572  (true == pRemover->CompareID(GetRecipientUserID()))) {
573  pRecipient = pRemover; // <======== now both pointers are set (to same
574  // Nym). DONE!
575  }
576 
577  if (nullptr == pRecipient) {
578  // GetSenderUserID() should be the same on THIS (updated version of the
579  // same cron item)
580  // but for whatever reason, I'm checking the userID on the original
581  // version. Sue me.
582  //
583  const OTIdentifier NYM_ID(GetRecipientUserID());
584 
585  theRecipientNym.SetIdentifier(NYM_ID);
586 
587  if (!theRecipientNym.LoadPublicKey()) {
588  const OTString strNymID(NYM_ID);
589  otErr << szFunc << ": Failure loading Recipient's public key:\n"
590  << strNymID << "\n";
591  }
592  else if (theRecipientNym.VerifyPseudonym() &&
593  theRecipientNym.LoadSignedNymfile(*pServerNym)) // ServerNym
594  // here is
595  // merely the
596  // signer on
597  // this file.
598  {
599  pRecipient = &theRecipientNym; // <=====
600  }
601  else {
602  const OTString strNymID(NYM_ID);
603  otErr << szFunc << ": Failure verifying Recipient's public key or "
604  "loading signed nymfile: " << strNymID << "\n";
605  }
606  }
607 
608  // First, we are closing the transaction number ITSELF, of this cron item,
609  // as an active issued number on the originating nym. (Changing it to
610  // CLOSED.)
611  //
612  // Second, we're verifying the CLOSING number, and using it as the closing
613  // number
614  // on the FINAL RECEIPT (with that receipt being "InReferenceTo"
615  // GetTransactionNum())
616  //
617  const int64_t lRecipientOpeningNumber = GetRecipientOpeningNum();
618  const int64_t lRecipientClosingNumber = GetRecipientClosingNum();
619 
620  const int64_t lSenderOpeningNumber = theOrigCronItem.GetTransactionNum();
621 
622  const int64_t lSenderClosingNumber =
623  (theOrigCronItem.GetCountClosingNumbers() > 0)
624  ? theOrigCronItem.GetClosingTransactionNoAt(0)
625  : 0; // index 0 is closing number for sender, since
626  // GetTransactionNum() is his opening #.
627 
628  const OTString strServerID(GetServerID());
629 
630  OTPseudonym theActualNym; // unused unless it's really not already loaded.
631  // (use pActualNym.)
632 
633  //
634  if ((lSenderOpeningNumber > 0) &&
635  theOriginator.VerifyIssuedNum(strServerID, lSenderOpeningNumber)) {
636 
637  OTPseudonym* pActualNym = nullptr; // use this. DON'T use theActualNym.
638 
639  // The Nym (server side) stores a list of all opening and closing cron
640  // #s.
641  // So when the number is released from the Nym, we also take it off that
642  // list.
643  //
644  std::set<int64_t>& theIDSet = theOriginator.GetSetOpenCronItems();
645  theIDSet.erase(lSenderOpeningNumber);
646 
647  // the RemoveIssued call means the original transaction# (to find this
648  // cron item on cron) is now CLOSED.
649  // But the Transaction itself is still OPEN. How? Because the CLOSING
650  // number is still signed out.
651  // The closing number is also USED, since the NotarizePaymentPlan or
652  // NotarizeMarketOffer call, but it
653  // remains ISSUED, until the final receipt itself is accepted during a
654  // process inbox.
655  //
656  theOriginator.RemoveIssuedNum(*pServerNym, strServerID,
657  lSenderOpeningNumber,
658  false); // bSave=false
659  theOriginator.SaveSignedNymfile(*pServerNym);
660 
661  const OTIdentifier& ACTUAL_NYM_ID = GetSenderUserID();
662 
663  if ((nullptr != pServerNym) && pServerNym->CompareID(ACTUAL_NYM_ID))
664  pActualNym = pServerNym;
665  else if (theOriginator.CompareID(ACTUAL_NYM_ID))
666  pActualNym = &theOriginator;
667  else if ((nullptr != pRemover) && pRemover->CompareID(ACTUAL_NYM_ID))
668  pActualNym = pRemover;
669 
670  else // We couldn't find the Nym among those already loaded--so we have
671  // to load
672  { // it ourselves (so we can update its NymboxHash value.)
673  theActualNym.SetIdentifier(ACTUAL_NYM_ID);
674 
675  if (!theActualNym.LoadPublicKey()) // Note: this step may be
676  // unnecessary since we
677  // are only updating his
678  // Nymfile, not his key.
679  {
680  OTString strNymID(ACTUAL_NYM_ID);
681  otErr << szFunc
682  << ": Failure loading public key for Nym : " << strNymID
683  << ". "
684  "(To update his NymboxHash.) \n";
685  }
686  else if (theActualNym.VerifyPseudonym() && // this line may be
687  // unnecessary.
688  theActualNym.LoadSignedNymfile(
689  *pServerNym)) // ServerNym here is not theActualNym's
690  // identity, but merely the signer on
691  // this file.
692  {
693  otLog3
694  << szFunc
695  << ": Loading actual Nym, since he wasn't already loaded. "
696  "(To update his NymboxHash.)\n";
697  pActualNym = &theActualNym; // <=====
698  }
699  else {
700  OTString strNymID(ACTUAL_NYM_ID);
701  otErr
702  << szFunc
703  << ": Failure loading or verifying Actual Nym public key: "
704  << strNymID << ". "
705  "(To update his NymboxHash.)\n";
706  }
707  }
708 
709  if (!DropFinalReceiptToNymbox(GetSenderUserID(), lNewTransactionNumber,
710  strOrigCronItem, nullptr, pstrAttachment,
711  pActualNym)) {
712  otErr << szFunc
713  << ": Failure dropping sender final receipt into nymbox.\n";
714  }
715  }
716  else {
717  otErr << szFunc << ": Failure verifying sender's opening number.\n";
718  }
719 
720  if ((lSenderClosingNumber > 0) &&
721  theOriginator.VerifyIssuedNum(strServerID, lSenderClosingNumber)) {
722  // In this case, I'm passing nullptr for pstrNote, since there is no
723  // note.
724  // (Additional information would normally be stored in the note.)
725  //
726  if (false ==
728  GetSenderUserID(), GetSenderAcctID(), lNewTransactionNumber,
729  lSenderClosingNumber, // The closing transaction number to put
730  // on the receipt.
731  strOrigCronItem, nullptr,
732  pstrAttachment)) // pActualAcct=nullptr by default. (This call
733  // will
734  // load it up and update its inbox hash.)
735  otErr << szFunc
736  << ": Failure dropping receipt into sender's inbox.\n";
737 
738  // This part below doesn't happen until theOriginator ACCEPTS the final
739  // receipt (when processing his inbox.)
740  //
741  // theOriginator.RemoveIssuedNum(strServerID, lSenderClosingNumber,
742  // true); //bSave=false
743  }
744  else {
745  otErr << szFunc
746  << ": Failed verifying "
747  "lSenderClosingNumber=theOrigCronItem."
748  "GetClosingTransactionNoAt(0)>0 && "
749  "theOriginator.VerifyTransactionNum(lSenderClosingNumber)\n";
750  }
751 
752  //
753  if ((nullptr != pRecipient) && (lRecipientOpeningNumber > 0) &&
754  pRecipient->VerifyIssuedNum(strServerID, lRecipientOpeningNumber)) {
755  // The Nym (server side) stores a list of all opening and closing cron
756  // #s.
757  // So when the number is released from the Nym, we also take it off that
758  // list.
759  //
760  std::set<int64_t>& theIDSet = pRecipient->GetSetOpenCronItems();
761  theIDSet.erase(lRecipientOpeningNumber);
762 
763  // the RemoveIssued call means the original transaction# (to find this
764  // cron item on cron) is now CLOSED.
765  // But the Transaction itself is still OPEN. How? Because the CLOSING
766  // number is still signed out.
767  // The closing number is also USED, since the NotarizePaymentPlan or
768  // NotarizeMarketOffer call, but it
769  // remains ISSUED, until the final receipt itself is accepted during a
770  // process inbox.
771  //
772  pRecipient->RemoveIssuedNum(*pServerNym, strServerID,
773  lRecipientOpeningNumber,
774  false); // bSave=false
775  // pRecipient->SaveSignedNymfile(*pServerNym); // Moved lower.
776 
777  if (false ==
779  GetRecipientUserID(), lNewTransactionNumber, strOrigCronItem,
780  nullptr, pstrAttachment,
781  pRecipient)) // NymboxHash is updated here in pRecipient.
782  {
783  otErr
784  << szFunc
785  << ": Failure dropping recipient final receipt into nymbox.\n";
786  }
787 
788  // Saving both the Removed Issued Number, as well as the new NymboxHash.
789  // NOTE: Todo: if the NymboxHash WAS updated (as it should have been)
790  // then
791  // it was probably saved at that time. Below is therefore a redundant
792  // save.
793  // Need to fix by making certain objects savable and dirty, and then let
794  // them
795  // autosave before destruction, IF they are dirty.
796  //
797  pRecipient->SaveSignedNymfile(*pServerNym);
798  }
799  else {
800  otErr << szFunc
801  << ": Failed verifying "
802  "lRecipientClosingNumber="
803  "GetRecipientClosingTransactionNoAt(1)>0 && "
804  "pRecipient->VerifyTransactionNum(lRecipientClosingNumber) && "
805  "VerifyIssuedNum(lRecipientOpeningNumber)\n";
806  }
807 
808  //
809  if ((nullptr != pRecipient) && (lRecipientClosingNumber > 0) &&
810  pRecipient->VerifyIssuedNum(strServerID, lRecipientClosingNumber)) {
813  lNewTransactionNumber,
814  lRecipientClosingNumber, // The closing transaction
815  // number to put on the
816  // receipt.
817  strOrigCronItem, nullptr, pstrAttachment))
818  otErr << szFunc
819  << ": Failure dropping receipt into recipient's inbox.\n";
820 
821  // This part below doesn't happen until pRecipient ACCEPTs the final
822  // receipt (when processing his inbox.)
823  //
824  // pRecipient->RemoveIssuedNum(strServerID,
825  // lRecipientClosingNumber, true); //bSave=false
826  }
827  else {
828  otErr << szFunc
829  << ": Failed verifying "
830  "lRecipientClosingNumber="
831  "GetRecipientClosingTransactionNoAt(1)>0 && "
832  "pRecipient->VerifyTransactionNum(lRecipientClosingNumber) && "
833  "VerifyIssuedNum(lRecipientOpeningNumber)\n";
834  }
835 
836  // QUESTION: Won't there be Cron Items that have no asset account at all?
837  // In which case, there'd be no need to drop a final receipt, but I don't
838  // think
839  // that's the case, since you have to use a transaction number to get onto
840  // cron
841  // in the first place.
842 }
const OTIdentifier & GetSenderUserID() const
OTLOG_IMPORT OTLogStream otLog3
EXPORT int64_t GetRecipientOpeningNum() const
const OTIdentifier & GetServerID() const
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)
#define OT_ASSERT(x)
Definition: Assert.hpp:150
EXPORT int64_t GetRecipientClosingNum() const
OTLOG_IMPORT OTLogStream otErr
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier & GetSenderAcctID() const
const OTIdentifier & GetRecipientAcctID() const
bool DropFinalReceiptToNymbox(const OTIdentifier &USER_ID, const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
OTCron * GetCron() const
Definition: OTCronItem.hpp:293
void opentxs::OTAgreement::onRemovalFromCron ( )
protectedvirtual

Reimplemented from opentxs::OTCronItem.

Definition at line 858 of file OTAgreement.cpp.

859 {
860  // Not much needed here.
861  // Actually: Todo: (unless it goes in payment plan code) need to set
862  // receipts
863  // in inboxes, and close out the closing transaction numbers.
864  //
865 }
bool opentxs::OTAgreement::ProcessCron ( )
virtual

Reimplemented from opentxs::OTCronItem.

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1020 of file OTAgreement.cpp.

1021 {
1022  // END DATE --------------------------------
1023  // First call the parent's version (which this overrides) so it has
1024  // a chance to check its stuff. Currently it checks IsExpired().
1025  if (!ot_super::ProcessCron())
1026  return false; // It's expired or flagged--removed it from Cron.
1027 
1028  // START DATE --------------------------------
1029  // Okay, so it's NOT expired. But might not have reached START DATE yet...
1030  // (If not expired, yet current date is not verified, that means it hasn't
1031  // ENTERED the date range YET.)
1032  //
1033  if (!VerifyCurrentDate())
1034  return true; // The Trade is not yet valid, so we return. BUT, we return
1035  // true, so it will stay on Cron until it BECOMES valid.
1036 
1037  // Process my Agreement-specific stuff
1038  // below.--------------------------------
1039 
1040  return true;
1041 }
EXPORT bool VerifyCurrentDate()
virtual bool ProcessCron()
Definition: OTCronItem.cpp:769
int32_t opentxs::OTAgreement::ProcessXMLNode ( irr::io::IrrXMLReader *&  xml)
virtual

Reimplemented from opentxs::OTCronItem.

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1526 of file OTAgreement.cpp.

1527 {
1528  int32_t nReturnVal = 0;
1529 
1530  // Here we call the parent class first.
1531  // If the node is found there, or there is some error,
1532  // then we just return either way. But if it comes back
1533  // as '0', then nothing happened, and we'll continue executing.
1534  //
1535  // -- Note you can choose not to call the parent if
1536  // you don't want to use any of those xml tags.
1537  // As I do below, in the case of OTAccount.
1538  if (0 != (nReturnVal = ot_super::ProcessXMLNode(xml))) return nReturnVal;
1539 
1540  if (!strcmp("agreement", xml->getNodeName())) {
1541  m_strVersion = xml->getAttributeValue("version");
1542  SetTransactionNum(atol(xml->getAttributeValue("transactionNum")));
1543 
1544  const OTString strCreation = xml->getAttributeValue("creationDate");
1545  int64_t tCreation = strCreation.ToLong();
1546 
1548 
1549  const OTString str_valid_from = xml->getAttributeValue("validFrom");
1550  const OTString str_valid_to = xml->getAttributeValue("validTo");
1551 
1552  int64_t tValidFrom = str_valid_from.ToLong();
1553  int64_t tValidTo = str_valid_to.ToLong();
1554 
1557 
1558  const OTString strServerID(xml->getAttributeValue("serverID")),
1559  strAssetTypeID(xml->getAttributeValue("assetTypeID")),
1560  strSenderAcctID(xml->getAttributeValue("senderAcctID")),
1561  strSenderUserID(xml->getAttributeValue("senderUserID")),
1562  strRecipientAcctID(xml->getAttributeValue("recipientAcctID")),
1563  strRecipientUserID(xml->getAttributeValue("recipientUserID")),
1564  strCanceled(xml->getAttributeValue("canceled")),
1565  strCancelerUserID(xml->getAttributeValue("cancelerUserID"));
1566 
1567  if (strCanceled.Exists() && strCanceled.Compare("true")) {
1568  m_bCanceled = true;
1569 
1570  if (strCancelerUserID.Exists())
1571  m_pCancelerNymID->SetString(strCancelerUserID);
1572  // else log
1573  }
1574  else {
1575  m_bCanceled = false;
1577  }
1578 
1579  const OTIdentifier SERVER_ID(strServerID), ASSET_ID(strAssetTypeID),
1580  SENDER_ACCT_ID(strSenderAcctID), SENDER_USER_ID(strSenderUserID),
1581  RECIPIENT_ACCT_ID(strRecipientAcctID),
1582  RECIPIENT_USER_ID(strRecipientUserID);
1583 
1584  SetServerID(SERVER_ID);
1585  SetAssetID(ASSET_ID);
1586  SetSenderAcctID(SENDER_ACCT_ID);
1587  SetSenderUserID(SENDER_USER_ID);
1588  SetRecipientAcctID(RECIPIENT_ACCT_ID);
1589  SetRecipientUserID(RECIPIENT_USER_ID);
1590 
1591  otWarn << "\n\n" << (m_bCanceled ? "Canceled a" : "A")
1592  << "greement. Transaction Number: " << m_lTransactionNum << "\n";
1593 
1594  otInfo << " Creation Date: " << tCreation
1595  << " Valid From: " << tValidFrom << "\n Valid To: " << tValidTo
1596  << "\n"
1597  " AssetTypeID: " << strAssetTypeID
1598  << "\n ServerID: " << strServerID
1599  << "\n"
1600  " senderAcctID: " << strSenderAcctID
1601  << "\n senderUserID: " << strSenderUserID
1602  << "\n "
1603  " recipientAcctID: " << strRecipientAcctID
1604  << "\n recipientUserID: " << strRecipientUserID << "\n ";
1605 
1606  nReturnVal = 1;
1607  }
1608  else if (!strcmp("consideration", xml->getNodeName())) {
1609  if (false ==
1611  otErr << "Error in OTPaymentPlan::ProcessXMLNode: consideration "
1612  "field without value.\n";
1613  return (-1); // error condition
1614  }
1615 
1616  nReturnVal = 1;
1617  }
1618  else if (!strcmp("merchantSignedCopy", xml->getNodeName())) {
1619  if (false ==
1621  otErr << "Error in OTPaymentPlan::ProcessXMLNode: "
1622  "merchant_signed_copy field without value.\n";
1623  return (-1); // error condition
1624  }
1625 
1626  nReturnVal = 1;
1627  }
1628 
1629  // std::deque<int64_t> m_dequeRecipientClosingNumbers; // Numbers used
1630  // for CLOSING a transaction. (finalReceipt.)
1631  else if (!strcmp("closingRecipientNumber", xml->getNodeName())) {
1632  OTString strClosingNumber = xml->getAttributeValue("value");
1633 
1634  if (strClosingNumber.Exists()) {
1635  const int64_t lClosingNumber = atol(strClosingNumber.Get());
1636 
1637  AddRecipientClosingTransactionNo(lClosingNumber);
1638  }
1639  else {
1640  otErr << "Error in OTAgreement::ProcessXMLNode: "
1641  "closingRecipientNumber field without value.\n";
1642  return (-1); // error condition
1643  }
1644 
1645  nReturnVal = 1;
1646  }
1647 
1648  return nReturnVal;
1649 }
void SetRecipientUserID(const OTIdentifier &USER_ID)
void SetValidFrom(time64_t TIME_FROM)
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
void AddRecipientClosingTransactionNo(const int64_t &lClosingTransactionNo)
void SetValidTo(time64_t TIME_TO)
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
Definition: Common.hpp:215
void SetAssetID(const OTIdentifier &ASSET_ID)
OTString m_strMerchantSignedCopy
void SetRecipientAcctID(const OTIdentifier &ACCT_ID)
void SetCreationDate(const time64_t &CREATION_DATE)
Definition: OTCronItem.hpp:264
EXPORT void SetString(const char *szString)
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
void SetTransactionNum(int64_t lTransactionNum)
OTLOG_IMPORT OTLogStream otInfo
void SetSenderAcctID(const OTIdentifier &ACCT_ID)
OTLOG_IMPORT OTLogStream otWarn
void SetServerID(const OTIdentifier &SERVER_ID)
OTLOG_IMPORT OTLogStream otErr
OTIdentifier * m_pCancelerNymID
Definition: OTCronItem.hpp:177
void SetSenderUserID(const OTIdentifier &USER_ID)
virtual EXPORT void Release()
Definition: OTData.cpp:257
void opentxs::OTAgreement::Release ( void  )
virtual

Reimplemented from opentxs::OTCronItem.

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1509 of file OTAgreement.cpp.

1510 {
1512 
1513  ot_super::Release(); // since I've overridden the base class (OTCronItem),
1514  // so I call it now...
1515 
1516  // Then I call this to re-initialize everything
1517  InitAgreement();
1518 }
virtual void Release()
void opentxs::OTAgreement::Release_Agreement ( )

Definition at line 1494 of file OTAgreement.cpp.

1495 {
1496  // If there were any dynamically allocated objects, clean them up here.
1497  //
1498  m_RECIPIENT_ACCT_ID.Release();
1499  m_RECIPIENT_USER_ID.Release();
1500 
1503 
1505 }
OTString m_strMerchantSignedCopy
std::deque< int64_t > m_dequeRecipientClosingNumbers
virtual EXPORT void Release()
Definition: OTData.cpp:257
virtual EXPORT void Release()
Definition: OTString.cpp:765
bool opentxs::OTAgreement::SaveContractWallet ( std::ofstream &  ofs) const
virtual

Reimplemented from opentxs::OTInstrument.

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1651 of file OTAgreement.cpp.

1652 {
1653  return true;
1654 }
bool opentxs::OTAgreement::SendNoticeToAllParties ( bool  bSuccessMsg,
OTPseudonym theServerNym,
const OTIdentifier theServerID,
const int64_t &  lNewTransactionNumber,
const OTString strReference,
OTString pstrNote = nullptr,
OTString pstrAttachment = nullptr,
OTPseudonym pActualNym = nullptr 
) const

Definition at line 150 of file OTAgreement.cpp.

157 {
158  bool bSuccess =
159  true; // Success is defined as ALL parties receiving a notice
160 
161  OTPseudonym theRecipientNym; // Don't use this... use the pointer just
162  // below.
163  OTPseudonym* pRecipient = nullptr;
164 
165  if (theServerNym.CompareID(GetRecipientUserID())) {
166  pRecipient = &theServerNym; // Just in case the recipient Nym is also
167  // the server Nym.
168  }
169  else if ((nullptr != pActualNym) &&
170  pActualNym->CompareID(GetRecipientUserID())) {
171  pRecipient = pActualNym;
172  }
173 
174  if (nullptr == pRecipient) {
175  const OTIdentifier NYM_ID(GetRecipientUserID());
176  theRecipientNym.SetIdentifier(NYM_ID);
177 
178  if (!theRecipientNym.LoadPublicKey()) {
179  const OTString strNymID(NYM_ID);
180  otErr << __FUNCTION__
181  << ": Failure loading Recipient's public key: " << strNymID
182  << "\n";
183  return false;
184  }
185  else if (theRecipientNym.VerifyPseudonym() &&
186  theRecipientNym.LoadSignedNymfile(
187  theServerNym)) // ServerNym here is merely the signer on
188  // this file.
189  {
190  pRecipient = &theRecipientNym; // <=====
191  }
192  else {
193  const OTString strNymID(NYM_ID);
194  otErr << __FUNCTION__
195  << ": Failure verifying Recipient's public key or loading "
196  "signed nymfile: " << strNymID << "\n";
197  return false;
198  }
199  }
200  // BY THIS POINT, the Recipient Nym is definitely loaded up and we have
201  // a pointer to him (pRecipient.)
202 
203  OTPseudonym theSenderNym; // Don't use this... use the pointer just below.
204  OTPseudonym* pSender = nullptr;
205 
206  if (theServerNym.CompareID(GetSenderUserID())) {
207  pSender = &theServerNym; // Just in case the Sender Nym is also the
208  // server Nym.
209  }
210  else if ((nullptr != pActualNym) &&
211  pActualNym->CompareID(GetSenderUserID())) {
212  pSender = pActualNym;
213  }
214 
215  if (nullptr == pSender) {
216  const OTIdentifier NYM_ID(GetSenderUserID());
217  theSenderNym.SetIdentifier(NYM_ID);
218 
219  if (!theSenderNym.LoadPublicKey()) {
220  const OTString strNymID(NYM_ID);
221  otErr << __FUNCTION__
222  << ": Failure loading Sender's public key: " << strNymID
223  << "\n";
224  return false;
225  }
226  else if (theSenderNym.VerifyPseudonym() &&
227  theSenderNym.LoadSignedNymfile(theServerNym)) // ServerNym
228  // here is
229  // merely the
230  // signer on
231  // this file.
232  {
233  pSender = &theSenderNym; // <=====
234  }
235  else {
236  const OTString strNymID(NYM_ID);
237  otErr << __FUNCTION__ << ": Failure verifying Sender's public key "
238  "or loading signed nymfile: " << strNymID
239  << "\n";
240  return false;
241  }
242  }
243  // BY THIS POINT, the Sender Nym is definitely loaded up and we have
244  // a pointer to him (pSender.)
245 
246  // (pRecipient and pSender are both good pointers by this point.)
247 
248  // Sender
250  bSuccessMsg, // "success" notice? or "failure" notice?
251  theServerNym, theServerID, GetSenderUserID(), lNewTransactionNumber,
252  GetTransactionNum(), // in reference to
253  strReference, pstrNote, pstrAttachment, pSender))
254  bSuccess = false;
255  // Notice I don't break here -- I still allow it to try to notice ALL
256  // parties, even if one fails.
257 
258  // Recipient
260  bSuccessMsg, // "success" notice? or "failure" notice?
261  theServerNym, theServerID, GetRecipientUserID(),
262  lNewTransactionNumber,
263  GetRecipientOpeningNum(), // in reference to
264  strReference, pstrNote, pstrAttachment, pRecipient))
265  bSuccess = false;
266 
267  return bSuccess;
268 }
const OTIdentifier & GetSenderUserID() const
int64_t GetTransactionNum() const
EXPORT int64_t GetRecipientOpeningNum() const
OTLOG_IMPORT OTLogStream otErr
const OTIdentifier & GetRecipientUserID() const
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 opentxs::OTAgreement::SetMerchantSignedCopy ( const OTString strMerchantCopy)
inline

Definition at line 207 of file OTAgreement.hpp.

208  {
209  m_strMerchantSignedCopy = strMerchantCopy;
210  }
OTString m_strMerchantSignedCopy
bool opentxs::OTAgreement::SetProposal ( OTPseudonym MERCHANT_NYM,
const OTString strConsideration,
time64_t  VALID_FROM = OT_TIME_ZERO,
time64_t  VALID_TO = OT_TIME_ZERO 
)

Definition at line 1155 of file OTAgreement.cpp.

1163 {
1164 
1165  OTIdentifier id_MERCHANT_NYM;
1166  MERCHANT_NYM.GetIdentifier(id_MERCHANT_NYM);
1167 
1168  if (GetRecipientUserID() != id_MERCHANT_NYM) {
1169  otOut << __FUNCTION__ << ": Merchant has wrong NymID (should be same "
1170  "as RecipientUserID.)\n";
1171  return false;
1172  }
1173  else if (GetRecipientUserID() == GetSenderUserID()) {
1174  otOut << __FUNCTION__ << ": Error: Sender and recipient have the same "
1175  "Nym ID (not allowed.)\n";
1176  return false;
1177  }
1178  else if (MERCHANT_NYM.GetTransactionNumCount(GetServerID()) <
1179  2) // Need opening and closing numbers (that's 2)...
1180  {
1181  otOut << __FUNCTION__ << ": Failure. You need at least 2 transaction "
1182  "numbers available to do this.\n";
1183  return false;
1184  }
1185 
1186  // Set the CREATION DATE
1187  //
1188  const time64_t CURRENT_TIME = OTTimeGetCurrentTime();
1189 
1190  // Set the Creation Date.
1191  SetCreationDate(CURRENT_TIME);
1192 
1193  // Putting this above here so I don't have to put the transaction numbers
1194  // back if this fails:
1195 
1196  // VALID_FROM
1197  //
1198  // The default "valid from" time is NOW.
1199  if (OT_TIME_ZERO >= VALID_FROM) // if it's 0 or less, set to current time.
1200  SetValidFrom(CURRENT_TIME);
1201  else // Otherwise use whatever was passed in.
1202  SetValidFrom(VALID_FROM);
1203 
1204  // VALID_TO
1205  //
1206  // The default "valid to" time is 0 (which means no expiration date / cancel
1207  // anytime.)
1208  if (OT_TIME_ZERO == VALID_TO) // VALID_TO is 0
1209  {
1210  SetValidTo(VALID_TO); // Keep it at zero then, so it won't expire.
1211  }
1212  else if (OT_TIME_ZERO < VALID_TO) // VALID_TO is ABOVE zero...
1213  {
1215  GetValidFrom(), OTTimeGetSecondsFromTime(VALID_TO))); // Set it to
1216  // itself +
1217  // valid_from.
1218  }
1219  else // VALID_TO is a NEGATIVE number... Error.
1220  {
1221  int64_t lValidTo = OTTimeGetSecondsFromTime(VALID_TO);
1222  otErr << __FUNCTION__ << ": Negative value for valid_to: " << lValidTo
1223  << "\n";
1224 
1225  return false;
1226  }
1227 
1228  // Since we'll be needing 2 transaction numbers to do this, let's grab
1229  // 'em...
1230  //
1231  OTString strServerID(GetServerID());
1232 
1233  int64_t lTransactionNumber = 0, lClosingTransactionNo = 0;
1234 
1235  if (MERCHANT_NYM.GetTransactionNumCount(GetServerID()) <
1236  2) // Need opening and closing numbers (that's 2)...
1237  {
1238  otOut << __FUNCTION__ << ": Failure. You need at least 2 transaction "
1239  "numbers available to do this.\n";
1240  return false;
1241  }
1242  else if (false ==
1243  MERCHANT_NYM.GetNextTransactionNum(MERCHANT_NYM, strServerID,
1244  lTransactionNumber)) {
1245  otErr << __FUNCTION__
1246  << ": Error: Strangely unable to get a transaction number.\n";
1247  return false;
1248  }
1249  else if (false ==
1250  MERCHANT_NYM.GetNextTransactionNum(MERCHANT_NYM, strServerID,
1251  lClosingTransactionNo)) {
1252  otErr << __FUNCTION__ << ": Error: Strangely unable to get a closing "
1253  "transaction number.\n";
1254  MERCHANT_NYM.AddTransactionNum(MERCHANT_NYM, strServerID,
1255  lTransactionNumber, true); // bSave=true
1256  // (Since the first one was successful, we just put it back before
1257  // returning.)
1258  return false;
1259  }
1260 
1261  // At this point we now have 2 transaction numbers...
1262  // We can't return without either USING THEM, or PUTTING THEM BACK.
1263  //
1264 
1265  // Set the Transaction Number and the Closing transaction number... (for
1266  // merchant / recipient.)
1267  //
1268  AddRecipientClosingTransactionNo(lTransactionNumber);
1269  AddRecipientClosingTransactionNo(lClosingTransactionNo);
1270  // (They just both go onto this same list.)
1271 
1272  // Set the Consideration memo...
1273  m_strConsideration.Set(strConsideration);
1274 
1275  otLog4 << "Successfully performed SetProposal.\n";
1276  return true;
1277 }
OTLOG_IMPORT OTLogStream otLog4
const OTIdentifier & GetSenderUserID() const
void SetValidFrom(time64_t TIME_FROM)
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
Definition: Common.hpp:238
void AddRecipientClosingTransactionNo(const int64_t &lClosingTransactionNo)
OTLOG_IMPORT OTLogStream otOut
void SetValidTo(time64_t TIME_TO)
int64_t time64_t
Definition: Common.hpp:209
void SetCreationDate(const time64_t &CREATION_DATE)
Definition: OTCronItem.hpp:264
const OTIdentifier & GetServerID() const
time64_t GetValidFrom() const
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
time64_t OTTimeGetCurrentTime()
Definition: Common.hpp:211
OTLOG_IMPORT OTLogStream otErr
const OTIdentifier & GetRecipientUserID() const
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
#define OT_TIME_ZERO
Definition: Common.hpp:180
void opentxs::OTAgreement::SetRecipientAcctID ( const OTIdentifier ACCT_ID)
inline

Definition at line 354 of file OTAgreement.hpp.

355  {
356  m_RECIPIENT_ACCT_ID = ACCT_ID;
357  }
void opentxs::OTAgreement::SetRecipientUserID ( const OTIdentifier USER_ID)
inline

Definition at line 358 of file OTAgreement.hpp.

359  {
360  m_RECIPIENT_USER_ID = USER_ID;
361  }
void opentxs::OTAgreement::UpdateContents ( )
virtual

Reimplemented from opentxs::OTTrackable.

Reimplemented in opentxs::OTPaymentPlan.

Definition at line 1520 of file OTAgreement.cpp.

1521 {
1522  // See OTPaymentPlan::UpdateContents.
1523 }
virtual bool opentxs::OTAgreement::VerifyAgreement ( OTPseudonym RECIPIENT_NYM,
OTPseudonym SENDER_NYM 
) const
pure virtual

Implemented in opentxs::OTPaymentPlan.

bool opentxs::OTAgreement::VerifyNymAsAgent ( OTPseudonym theNym,
OTPseudonym theSignerNym,
mapOfNyms pmap_ALREADY_LOADED = nullptr 
) const
virtual

Reimplemented from opentxs::OTScriptable.

Definition at line 509 of file OTAgreement.cpp.

512 {
513  return VerifySignature(theNym);
514 }
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTContract.cpp:818
bool opentxs::OTAgreement::VerifyNymAsAgentForAccount ( OTPseudonym theNym,
OTAccount theAccount 
) const
virtual

Reimplemented from opentxs::OTScriptable.

Definition at line 518 of file OTAgreement.cpp.

520 {
521  return theAccount.VerifyOwner(theNym);
522 }

Member Data Documentation

std::deque<int64_t> opentxs::OTAgreement::m_dequeRecipientClosingNumbers
protected

Definition at line 197 of file OTAgreement.hpp.

OTString opentxs::OTAgreement::m_strConsideration
protected

Definition at line 179 of file OTAgreement.hpp.

OTString opentxs::OTAgreement::m_strMerchantSignedCopy
protected

Definition at line 182 of file OTAgreement.hpp.


The documentation for this class was generated from the following files: