// The trade stores a copy of the Offer in string form. // This function verifies that offer against the trade, // and also verifies the signature on the offer. // // The Nym's ID is compared to theOffer's SenderUserID, and then the Signature is checked // on the offer. It also compares the server ID, asset and currency IDs, transaction #, etc // between this trade and the offer, in order to fully verify the offer's authenticity. // bool OTTrade::VerifyOffer(OTOffer & theOffer) { // At this point, I have a working, loaded, model of the Offer. // Let's verify the thing. if (GetTransactionNum() != theOffer.GetTransactionNum()) { OTLog::Error("While verifying offer, failed matching transaction number.\n"); return false; } else if (GetServerID() != theOffer.GetServerID()) { OTLog::Error("While verifying offer, failed matching Server ID.\n"); return false; } else if (GetAssetID() != theOffer.GetAssetID()) { OTLog::Error("While verifying offer, failed matching asset type ID.\n"); return false; } else if (GetCurrencyID() != theOffer.GetCurrencyID()) { OTLog::Error("While verifying offer, failed matching currency type ID.\n"); return false; } // the Offer validates properly for this Trade. return true; }
// This is called by the client side. First you call MakeOffer() to set up the Offer, // then you call IssueTrade() and pass the Offer into it here. bool OTTrade::IssueTrade(OTOffer & theOffer, char cStopSign/*=0*/, long lStopPrice/*=0*/) { // Make sure the Stop Sign is within parameters (0, '<', or '>') if ((cStopSign == 0 ) || (cStopSign == '<') || (cStopSign == '>')) m_cStopSign = cStopSign; else { OTLog::vError("Bad data in Stop Sign while issuing trade: %c\n", cStopSign); return false; } // Make sure, if this IS a Stop order, that the price is within parameters and set. if ((m_cStopSign == '<') || (m_cStopSign == '>')) { if (0 >= lStopPrice) { OTLog::Error("Expected Stop Price for trade.\n"); return false; } m_lStopPrice = lStopPrice; } m_nTradesAlreadyDone = 0; SetCreationDate(time(NULL)); // This time is set to TODAY NOW (OTCronItem) // ------------------------------------------------------------------------ // Validate the Server ID, Asset Type ID, Currency Type ID, and Date Range. if ((GetServerID() != theOffer.GetServerID()) || (GetCurrencyID() != theOffer.GetCurrencyID()) || (GetAssetID() != theOffer.GetAssetID()) || (theOffer.GetValidFrom() < 0) || (theOffer.GetValidTo() < theOffer.GetValidFrom()) ) { return false; } // m_CURRENCY_TYPE_ID // This is already set in the constructors of this and the offer. (And compared.) // m_CURRENCY_ACCT_ID // This is already set in the constructor of this. // Set the (now validated) date range as per the Offer. SetValidFrom(theOffer.GetValidFrom()); SetValidTo(theOffer.GetValidTo()); // Get the transaction number from the Offer. SetTransactionNum(theOffer.GetTransactionNum()); // Save a copy of the offer, in XML form, here on this Trade. OTString strOffer(theOffer); m_strOffer.Set(strOffer); return true; }