void OTOffer::UpdateContents() { const String NOTARY_ID(GetNotaryID()), INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), CURRENCY_TYPE_ID(GetCurrencyID()); // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); Tag tag("marketOffer"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("isSelling", formatBool(!IsBid())); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("currencyTypeID", CURRENCY_TYPE_ID.Get()); tag.add_attribute("priceLimit", formatLong(GetPriceLimit())); tag.add_attribute("totalAssetsOnOffer", formatLong(GetTotalAssetsOnOffer())); tag.add_attribute("finishedSoFar", formatLong(GetFinishedSoFar())); tag.add_attribute("marketScale", formatLong(GetScale())); tag.add_attribute("minimumIncrement", formatLong(GetMinimumIncrement())); tag.add_attribute("transactionNum", formatLong(GetTransactionNum())); tag.add_attribute("validFrom", formatTimestamp(GetValidFrom())); tag.add_attribute("validTo", formatTimestamp(GetValidTo())); std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
void OTTrade::UpdateContents() { // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); const String NOTARY_ID(GetNotaryID()), NYM_ID(GetSenderNymID()), INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), ASSET_ACCT_ID(GetSenderAcctID()), CURRENCY_TYPE_ID(GetCurrencyID()), CURRENCY_ACCT_ID(GetCurrencyAcctID()); Tag tag("trade"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("hasActivated", formatBool(hasTradeActivated_)); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("assetAcctID", ASSET_ACCT_ID.Get()); tag.add_attribute("currencyTypeID", CURRENCY_TYPE_ID.Get()); tag.add_attribute("currencyAcctID", CURRENCY_ACCT_ID.Get()); tag.add_attribute("nymID", NYM_ID.Get()); tag.add_attribute("completedNoTrades", formatInt(tradesAlreadyDone_)); tag.add_attribute("transactionNum", formatLong(m_lTransactionNum)); tag.add_attribute("creationDate", formatTimestamp(GetCreationDate())); tag.add_attribute("validFrom", formatTimestamp(GetValidFrom())); tag.add_attribute("validTo", formatTimestamp(GetValidTo())); // There are "closing" transaction numbers, used to CLOSE a transaction. // Often where Cron items are involved such as this payment plan, or in // baskets, // where many asset accounts are involved and require receipts to be closed // out. for (int32_t i = 0; i < GetCountClosingNumbers(); i++) { int64_t closingNumber = GetClosingTransactionNoAt(i); OT_ASSERT(closingNumber > 0); TagPtr tagClosing(new Tag("closingTransactionNumber")); tagClosing->add_attribute("value", formatLong(closingNumber)); tag.add_tag(tagClosing); } if (('<' == stopSign_) || ('>' == stopSign_)) { TagPtr tagStopOrder(new Tag("stopOrder")); tagStopOrder->add_attribute("hasActivated", formatBool(stopActivated_)); tagStopOrder->add_attribute("sign", formatChar(stopSign_)); tagStopOrder->add_attribute("price", formatLong(stopPrice_)); tag.add_tag(tagStopOrder); } if (marketOffer_.Exists()) { OTASCIIArmor ascOffer(marketOffer_); tag.add_tag("offer", ascOffer.Get()); } std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
void OTOffer::UpdateContents() { const OTString SERVER_ID(GetServerID()), ASSET_TYPE_ID(GetAssetID()), CURRENCY_TYPE_ID(GetCurrencyID()); const int64_t lFrom = OTTimeGetSecondsFromTime(GetValidFrom()); const int64_t lTo = OTTimeGetSecondsFromTime(GetValidTo()); const int64_t lPriceLimit = GetPriceLimit(); const int64_t lTotalAssetsOnOffer = GetTotalAssetsOnOffer(); const int64_t lFinishedSoFar = GetFinishedSoFar(); const int64_t lScale = GetScale(); const int64_t lMinimumIncrement = GetMinimumIncrement(); const int64_t lTransactionNum = GetTransactionNum(); // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0"); m_xmlUnsigned.Concatenate("<marketOffer\n version=\"%s\"\n" " isSelling=\"%s\"\n" // true or false. " serverID=\"%s\"\n" " assetTypeID=\"%s\"\n" " currencyTypeID=\"%s\"\n" " priceLimit=\"%lld\"\n" " totalAssetsOnOffer=\"%lld\"\n" " finishedSoFar=\"%lld\"\n" " marketScale=\"%lld\"\n" " minimumIncrement=\"%lld\"\n" " transactionNum=\"%lld\"\n" " validFrom=\"%" PRId64"\"\n" " validTo=\"%" PRId64"\"" " />\n\n", // <=== the tag ends here. m_strVersion.Get(), (IsBid() ? "false" : "true"), SERVER_ID.Get(), ASSET_TYPE_ID.Get(), CURRENCY_TYPE_ID.Get(), lPriceLimit, lTotalAssetsOnOffer, lFinishedSoFar, lScale, lMinimumIncrement, lTransactionNum, lFrom, lTo ); // m_xmlUnsigned.Concatenate("</marketOffer>\n"); // ^^^ Tag already ended above. }
void Cheque::UpdateContents() { String INSTRUMENT_DEFINITION_ID(GetInstrumentDefinitionID()), NOTARY_ID(GetNotaryID()), SENDER_ACCT_ID(GetSenderAcctID()), SENDER_NYM_ID(GetSenderNymID()), RECIPIENT_NYM_ID(GetRecipientNymID()), REMITTER_NYM_ID(GetRemitterNymID()), REMITTER_ACCT_ID(GetRemitterAcctID()); std::string from = formatTimestamp(GetValidFrom()); std::string to = formatTimestamp(GetValidTo()); // I release this because I'm about to repopulate it. m_xmlUnsigned.Release(); Tag tag("cheque"); tag.add_attribute("version", m_strVersion.Get()); tag.add_attribute("amount", formatLong(m_lAmount)); tag.add_attribute("instrumentDefinitionID", INSTRUMENT_DEFINITION_ID.Get()); tag.add_attribute("transactionNum", formatLong(GetTransactionNum())); tag.add_attribute("notaryID", NOTARY_ID.Get()); tag.add_attribute("senderAcctID", SENDER_ACCT_ID.Get()); tag.add_attribute("senderNymID", SENDER_NYM_ID.Get()); tag.add_attribute("hasRecipient", formatBool(m_bHasRecipient)); tag.add_attribute("recipientNymID", m_bHasRecipient ? RECIPIENT_NYM_ID.Get() : ""); tag.add_attribute("hasRemitter", formatBool(m_bHasRemitter)); tag.add_attribute("remitterNymID", m_bHasRemitter ? REMITTER_NYM_ID.Get() : ""); tag.add_attribute("remitterAcctID", m_bHasRemitter ? REMITTER_ACCT_ID.Get() : ""); tag.add_attribute("validFrom", from); tag.add_attribute("validTo", to); if (m_strMemo.Exists() && m_strMemo.GetLength() > 2) { OTASCIIArmor ascMemo(m_strMemo); tag.add_tag("memo", ascMemo.Get()); } std::string str_result; tag.output(str_result); m_xmlUnsigned.Concatenate("%s", str_result.c_str()); }
bool OTAgreement::Compare(const OTAgreement & rhs) const { // Compare OTAgreement specific info here. if ( ( m_strConsideration.Compare(rhs.m_strConsideration) ) && ( GetRecipientAcctID() == rhs.GetRecipientAcctID() ) && ( GetRecipientUserID() == rhs.GetRecipientUserID() ) && // ( m_dequeClosingNumbers == rhs.m_dequeClosingNumbers ) && // The merchant wouldn't know the customer's trans#s. // (Thus wouldn't expect them to be set in BOTH versions...) ( m_dequeRecipientClosingNumbers == rhs.m_dequeRecipientClosingNumbers ) && // ( GetTransactionNum() == rhs.GetTransactionNum() ) && // (commented out for same reason as above.) // ( GetSenderAcctID() == rhs.GetSenderAcctID() ) && // Same here -- we should let the merchant leave these blank, // ( GetSenderUserID() == rhs.GetSenderUserID() ) && // and then allow the customer to add them in his version, ( GetAssetID() == rhs.GetAssetID() ) && // (and this Compare function still still verify it.) ( GetServerID() == rhs.GetServerID() ) && ( GetValidFrom() == rhs.GetValidFrom() ) && ( GetValidTo() == rhs.GetValidTo() ) ) return true; return false; }
// return -1 if error, 0 if nothing, and 1 if the node was processed. int OTAgreement::ProcessXMLNode(irr::io::IrrXMLReader*& xml) { int nReturnVal = 0; // Here we call the parent class first. // If the node is found there, or there is some error, // then we just return either way. But if it comes back // as '0', then nothing happened, and we'll continue executing. // // -- Note you can choose not to call the parent if // you don't want to use any of those xml tags. // As I do below, in the case of OTAccount. if (0 != (nReturnVal = OTCronItem::ProcessXMLNode(xml))) return nReturnVal; // ------------------------------------------------- if (!strcmp("agreement", xml->getNodeName())) { m_strVersion = xml->getAttributeValue("version"); SetTransactionNum( atol(xml->getAttributeValue("transactionNum")) ); SetCreationDate( atoi(xml->getAttributeValue("creationDate"))); SetValidFrom( atoi(xml->getAttributeValue("validFrom"))); SetValidTo( atoi(xml->getAttributeValue("validTo"))); // --------------------- const OTString strServerID(xml->getAttributeValue("serverID")), strAssetTypeID(xml->getAttributeValue("assetTypeID")), strSenderAcctID(xml->getAttributeValue("senderAcctID")), strSenderUserID(xml->getAttributeValue("senderUserID")), strRecipientAcctID(xml->getAttributeValue("recipientAcctID")), strRecipientUserID(xml->getAttributeValue("recipientUserID")); const OTIdentifier SERVER_ID(strServerID), ASSET_ID(strAssetTypeID), SENDER_ACCT_ID(strSenderAcctID), SENDER_USER_ID(strSenderUserID), RECIPIENT_ACCT_ID(strRecipientAcctID), RECIPIENT_USER_ID(strRecipientUserID); SetServerID(SERVER_ID); SetAssetID(ASSET_ID); SetSenderAcctID(SENDER_ACCT_ID); SetSenderUserID(SENDER_USER_ID); SetRecipientAcctID(RECIPIENT_ACCT_ID); SetRecipientUserID(RECIPIENT_USER_ID); // --------------------- OTLog::vOutput(0, "\n\nAgreement. Transaction Number: %ld\n", m_lTransactionNum); OTLog::vOutput(1, " Creation Date: %d Valid From: %d\n Valid To: %d\n" " AssetTypeID: %s\n ServerID: %s\n" " senderAcctID: %s\n senderUserID: %s\n " " recipientAcctID: %s\n recipientUserID: %s\n ", GetCreationDate(), GetValidFrom(), GetValidTo(), strAssetTypeID.Get(), strServerID.Get(), strSenderAcctID.Get(), strSenderUserID.Get(), strRecipientAcctID.Get(), strRecipientUserID.Get()); nReturnVal = 1; } else if (!strcmp("consideration", xml->getNodeName())) { if (false == LoadEncodedTextField(xml, m_strConsideration)) { OTLog::Error("Error in OTPaymentPlan::ProcessXMLNode: consideration field without value.\n"); return (-1); // error condition } nReturnVal = 1; } else if (!strcmp("merchantSignedCopy", xml->getNodeName())) { if (false == LoadEncodedTextField(xml, m_strMerchantSignedCopy)) { OTLog::Error("Error in OTPaymentPlan::ProcessXMLNode: merchant_signed_copy field without value.\n"); return (-1); // error condition } nReturnVal = 1; } // ------------------------------------------- // std::deque<long> m_dequeRecipientClosingNumbers; // Numbers used for CLOSING a transaction. (finalReceipt.) else if (!strcmp("closingRecipientNumber", xml->getNodeName())) { OTString strClosingNumber = xml->getAttributeValue("value"); if (strClosingNumber.Exists()) { const long lClosingNumber = atol(strClosingNumber.Get()); this->AddRecipientClosingTransactionNo(lClosingNumber); } else { OTLog::Error("Error in OTAgreement::ProcessXMLNode: closingRecipientNumber field without value.\n"); return (-1); // error condition } nReturnVal = 1; } return nReturnVal; }