141 #include <irrxml/irrXML.hpp>
147 char const*
const TypeStrings[] = {
176 "instrumentRejection",
214 return TypeStrings[transactionNumber];
219 int64_t& lNumberOfOrigin,
220 int64_t& lTransactionNum, int64_t& lInRefTo,
221 int64_t& lInRefDisplay,
time64_t& the_DATE_SIGNED,
223 int64_t& lAdjustment, int64_t& lDisplayValue,
224 int64_t& lClosingNum, int64_t& lRequestNum,
225 bool& bReplyTransSuccess,
OTNumList* pNumList)
228 const OTString strOrigin = xml->getAttributeValue(
"numberOfOrigin");
229 const OTString strTransNum = xml->getAttributeValue(
"transactionNum");
230 const OTString strInRefTo = xml->getAttributeValue(
"inReferenceTo");
231 const OTString strInRefDisplay = xml->getAttributeValue(
"inRefDisplay");
232 const OTString strDateSigned = xml->getAttributeValue(
"dateSigned");
236 otOut <<
"OTTransaction::LoadAbbreviatedRecord: Failure: missing "
237 "strTransNum (" << strTransNum <<
") or strInRefTo ("
238 << strInRefTo <<
") or strInRefDisplay (" << strInRefDisplay
239 <<
") or strDateSigned(" << strDateSigned
240 <<
") while loading abbreviated receipt. \n";
243 lTransactionNum = atol(strTransNum.
Get());
244 lInRefTo = atol(strInRefTo.
Get());
245 lInRefDisplay = atol(strInRefDisplay.
Get());
247 if (strOrigin.
Exists()) lNumberOfOrigin = atol(strOrigin.
Get());
251 strDateSigned.
Get());
256 xml->getAttributeValue(
"type");
259 if (strAbbrevType.
Exists()) {
263 otErr <<
"OTTransaction::LoadAbbreviatedRecord: Failure: "
264 "OTTransaction::error_state was the found type (based on "
265 "string " << strAbbrevType
266 <<
"), when loading abbreviated receipt for trans num: "
267 << lTransactionNum <<
" (In Reference To: " << lInRefTo
273 otOut <<
"OTTransaction::LoadAbbreviatedRecord: Failure: unknown "
274 "transaction type (" << strAbbrevType
276 "loading abbreviated receipt for trans num: "
277 << lTransactionNum <<
" (In Reference To: " << lInRefTo <<
") \n";
283 strHash = xml->getAttributeValue(
"receiptHash");
285 otOut <<
"OTTransaction::LoadAbbreviatedRecord: Failure: Expected "
286 "receiptHash while loading "
287 "abbreviated receipt for trans num: " << lTransactionNum
288 <<
" (In Reference To: " << lInRefTo <<
")\n";
296 const OTString strAbbrevAdjustment = xml->getAttributeValue(
"adjustment");
297 if (strAbbrevAdjustment.
Exists())
298 lAdjustment = atol(strAbbrevAdjustment.
Get());
300 const OTString strAbbrevDisplayValue =
301 xml->getAttributeValue(
"displayValue");
302 if (strAbbrevDisplayValue.
Exists())
303 lDisplayValue = atol(strAbbrevDisplayValue.
Get());
306 const OTString strRequestNum = xml->getAttributeValue(
"requestNumber");
308 if (!strRequestNum.
Exists()) {
309 otOut <<
"OTTransaction::LoadAbbreviatedRecord: Failed loading "
310 "abbreviated receipt: "
311 "expected requestNumber on replyNotice trans num: "
312 << lTransactionNum <<
" (In Reference To: " << lInRefTo
316 lRequestNum = atol(strRequestNum.
Get());
318 const OTString strTransSuccess = xml->getAttributeValue(
"transSuccess");
320 bReplyTransSuccess = strTransSuccess.Compare(
"true");
329 const OTString strAbbrevClosingNum =
330 xml->getAttributeValue(
"closingNum");
332 if (!strAbbrevClosingNum.
Exists()) {
333 otOut <<
"OTTransaction::LoadAbbreviatedRecord: Failed loading "
334 "abbreviated receipt: "
335 "expected closingNum on trans num: " << lTransactionNum
336 <<
" (In Reference To: " << lInRefTo <<
")\n";
339 lClosingNum = atol(strAbbrevClosingNum.
Get());
347 xml->getAttributeValue(
"totalListOfNumbers");
350 if (strNumbers.
Exists()) pNumList->Add(strNumbers);
363 const int32_t nBoxType,
364 const int64_t& lTransactionNum)
366 const int64_t lLedgerType =
static_cast<int64_t
>(nBoxType);
368 const OTString strServerID(SERVER_ID),
369 strUserOrAcctID(0 == lLedgerType ? USER_ID : ACCOUNT_ID);
375 OTString strFolder1name, strFolder2name, strFolder3name, strFilename;
378 strUserOrAcctID, strServerID, lTransactionNum,
379 "OTTransaction::VerifyBoxReceiptExists",
380 strFolder1name, strFolder2name, strFolder3name,
388 strFolder3name.
Get(), strFilename.
Get());
390 otWarn <<
"OTTransaction::" << (bExists ?
"(Already have this one)"
391 :
"(Need to download this one)")
392 <<
": " << __FUNCTION__ <<
": " << strFolder1name
401 const int64_t lLedgerType =
static_cast<int64_t
>(theLedger.
GetType());
416 otOut << __FUNCTION__ <<
": Unable to load box receipt "
419 "(Because argument 'theAbbrev' wasn't abbreviated.)\n";
426 OTString strFolder1name, strFolder2name, strFolder3name, strFilename;
429 lLedgerType, theAbbrev,
431 strFolder1name, strFolder2name, strFolder3name, strFilename))
437 strFolder3name.
Get(), strFilename.
Get())) {
439 <<
": Box receipt does not exist: " << strFolder1name
449 strFolder1name.
Get(),
450 strFolder2name.
Get(), strFolder3name.
Get(), strFilename.
Get()));
451 if (strFileContents.length() < 2) {
452 otErr << __FUNCTION__ <<
": Error reading file: " << strFolder1name
459 OTString strRawFile(strFileContents.c_str());
461 if (!strRawFile.Exists()) {
462 otErr << __FUNCTION__ <<
": Error reading file (resulting output "
463 "string is empty): " << strFolder1name
476 if (
nullptr == pTransType) {
477 otErr << __FUNCTION__ <<
": Error instantiating transaction "
478 "type based on strRawFile: " << strFolder1name
487 if (
nullptr == pBoxReceipt) {
488 otErr << __FUNCTION__
489 <<
": Error dynamic_cast from transaction "
490 "type to transaction, based on strRawFile: " << strFolder1name
495 pTransType =
nullptr;
508 otErr << __FUNCTION__ <<
": Failed verifying Box Receipt:\n"
514 pBoxReceipt =
nullptr;
518 otInfo << __FUNCTION__ <<
": Successfully loaded Box Receipt in:\n"
544 const int64_t& lTransactionNum,
545 const char* szCaller,
OTString& strFolder1name,
551 const char* pszFolder =
nullptr;
552 switch (lLedgerType) {
573 otErr <<
"OTTransaction::" << __FUNCTION__ <<
" " << szCaller
574 <<
": Error: unknown box type: " << lLedgerType
575 <<
". (This should never happen.)\n";
579 strFolder1name.
Set(pszFolder);
580 strFolder2name.
Set(strServerID);
581 strFolder3name.
Format(
"%s.r", strUserOrAcctID.
Get());
583 strFilename.
Format(
"%lld.rct", lTransactionNum);
592 const char* szCaller,
OTString& strFolder1name,
603 strFolder1name, strFolder2name,
604 strFolder3name, strFilename);
608 const char* szCaller,
OTString& strFolder1name,
612 int64_t lLedgerType = 0;
635 otErr <<
"OTTransaction::" << __FUNCTION__ <<
" " << szCaller
636 <<
": Error: unknown box type. "
637 "(This should never happen.)\n";
642 strFolder1name, strFolder2name,
643 strFolder3name, strFilename);
int32_t LoadAbbreviatedRecord(irr::io::IrrXMLReader *&xml, int64_t &lNumberOfOrigin, int64_t &lTransactionNum, int64_t &lInRefTo, int64_t &lInRefDisplay, time64_t &the_DATE_SIGNED, int &theType, OTString &strHash, int64_t &lAdjustment, int64_t &lDisplayValue, int64_t &lClosingNum, int64_t &lRequestNum, bool &bReplyTransSuccess, OTNumList *pNumList=nullptr)
EXPORT bool VerifyBoxReceiptExists(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nBoxType, const int64_t &lTransactionNum)
static EXPORT const OTString & PaymentInbox()
static EXPORT OTTransactionType * TransactionFactory(OTString strInput)
static EXPORT const OTString & ExpiredBox()
static EXPORT const char * PathSeparator()
OTLOG_IMPORT OTLogStream otOut
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
static EXPORT const OTString & Inbox()
static EXPORT const OTString & Nymbox()
EXPORT bool Exists() const
EXPORT void Format(const char *fmt,...)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
OTTransaction * LoadBoxReceipt(OTTransaction &theAbbrev, OTLedger &theLedger)
bool VerifyBoxReceipt(OTTransaction &theFullVersion)
static EXPORT const OTString & Outbox()
OTLOG_IMPORT OTLogStream otInfo
ledgerType GetType() const
static transactionType GetTypeFromString(const OTString &strType)
bool SetupBoxReceiptFilename(int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
virtual EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
OTLOG_IMPORT OTLogStream otWarn
EXPORT const char * Get() const
OTLOG_IMPORT OTLogStream otErr
EXPORT int64_t GetTransactionNum() const
bool IsAbbreviated() const
EXPORT const char * GetTransactionTypeString(int transactionNumber)
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
static EXPORT const OTString & RecordBox()
const OTIdentifier & GetRealServerID() const