133 #include "../core/stdafx.hpp"
143 #include "../ext/OTPayment.hpp"
145 #include "../core/OTAccount.hpp"
146 #include "../core/OTAssetContract.hpp"
147 #include "../core/OTLedger.hpp"
148 #include "../core/OTLog.hpp"
149 #include "../core/OTMessage.hpp"
150 #include "../core/OTPseudonym.hpp"
158 const std::string Instrument_TypeStrings[] = {
174 const std::string& GetTypeString(
int theType)
176 return Instrument_TypeStrings[theType];
184 #define MC_UI_TEXT_TO "To: %s"
185 #define MC_UI_TEXT_FROM "From: %s"
196 otErr << __FUNCTION__
197 <<
": ERROR:\nOTLookupCaller::setCallback() "
198 "MUST be called first, with an OTNameLookup-extended "
199 "class passed to it,\n"
200 "before then invoking this function (and passing that "
201 "OTLookupCaller as a parameter "
202 "into this function.)\n";
208 "OTRecordList::setAddrBookCaller(theCaller) now... "
210 "OT internally sets its pointer to the Java caller "
211 "object, which must have been passed in as a "
212 "parameter to this function.\n";
217 <<
": RESULT of call to OTRecordList::setAddrBookCaller: "
218 << (bSuccess ?
"SUCCESS" :
"FAILURE") <<
"";
243 const std::string*)
const
245 if (str_id.empty())
return "";
252 const std::string*,
const std::string*,
253 const std::string*)
const
255 if (str_id.empty())
return "";
271 otOut <<
"OTLookupCaller::~OTLookupCaller: (This should only "
272 "happen as the application is closing.)\n";
285 otOut <<
"OTLookupCaller::delCallback: WARNING: setting existing "
286 "callback object pointer to nullptr. "
287 "(This message doesn't trigger if it was already nullptr.)\n";
293 otOut <<
"OTLookupCaller::setCallback: Attempting to set the "
294 "OTNameLookup pointer...\n";
297 otOut <<
"OTLookupCaller::setCallback: ERROR: nullptr "
298 "OTNameLookup object passed in. (Returning.)\n";
306 otOut <<
"OTLookupCaller::setCallback: FYI, the OTNameLookup "
307 "pointer was set.\n";
312 return (
nullptr ==
_callback) ?
false :
true;
316 const std::string* p_server_id)
const
319 otWarn <<
"OTLookupCaller::GetNymName: FYI, Executing address "
320 "book callback...\n";
324 otOut <<
"OTLookupCaller::GetNymName: "
325 "WARNING: Failed attempt to trigger address book "
326 "callback, due to \"it hasn't been set yet.\"\n";
332 const std::string* p_nym_id,
333 const std::string* p_server_id,
334 const std::string* p_asset_id)
const
337 otWarn <<
"OTLookupCaller::GetAcctName: FYI, Executing address "
338 "book callback...\n";
343 otOut <<
"OTLookupCaller::GetAcctName: "
344 "WARNING: Failed attempt to trigger address book "
345 "callback, due to \"it hasn't been set yet.\"\n";
353 otWarn <<
"OTLookupCaller::GetAddressName: FYI, Executing "
354 "address book callback...\n";
358 otOut <<
"OTLookupCaller::GetAddressName: "
359 "WARNING: Failed attempt to trigger address book "
360 "callback, due to \"it hasn't been set yet.\"\n";
367 const std::string OTRecordList::s_blank(
"");
368 const std::string OTRecordList::s_message_type(
"message");
383 <<
": Attempting to set the address book caller... \n";
386 otErr << __FUNCTION__
387 <<
": ERROR: OTLookupCaller::setCallback() "
388 "MUST be called first, with an OTNameLookup-extended "
389 "object passed to it,\n"
390 "BEFORE calling this function with that OTLookupCaller. "
391 "(Returning false.)\n";
398 <<
": WARNING: Setting the address book caller again, even though "
399 "it was apparently ALREADY set... (Meaning Java has probably "
400 "erroneously called this twice, "
401 "possibly passing the same OTLookupCaller both times.)\n";
407 <<
": FYI, Successfully set the address book caller object from "
408 "Java (or from another SWIG language.) Returning true.\n";
432 m_servers.insert(m_servers.end(), str_id);
454 "Wallet was nullptr. Should never happen.");
455 const OTString strAssetTypeID(str_id);
457 std::string str_asset_name;
462 if (
nullptr != pAssetContract) {
467 if (str_asset_name.empty())
470 if (str_asset_name.empty())
475 if (str_asset_name.empty())
480 std::pair<std::string, std::string>(str_id, str_asset_name));
497 m_nyms.insert(m_nyms.end(), str_id);
514 m_accounts.insert(m_accounts.end(), str_id);
525 m_bAutoAcceptCheques = bVal;
529 m_bAutoAcceptReceipts = bVal;
533 m_bAutoAcceptTransfers = bVal;
537 m_bAutoAcceptCash = bVal;
542 return m_bAutoAcceptCheques;
546 return m_bAutoAcceptReceipts;
550 return m_bAutoAcceptTransfers;
554 return m_bAutoAcceptCash;
563 if (
nullptr == pWallet) {
564 otErr <<
"OTRecordList::" << __FUNCTION__
565 <<
": Error: Wallet is nullptr.\n";
570 if (m_bAutoAcceptCheques || m_bAutoAcceptCash) {
571 int32_t nNymIndex = -1;
572 for (
auto& it_nym : m_nyms) {
575 otOut <<
"======================================\n "
576 << __FUNCTION__ <<
": Beginning auto-accept loop through "
578 const std::string& str_nym_id(it_nym);
582 if (
nullptr == pNym)
continue;
587 int32_t nServerIndex = -1;
588 for (
auto& it_server : m_servers) {
590 const std::string& str_server_id(it_server);
595 const OTString strServerID(theServerID);
596 otOut << __FUNCTION__ <<
": Server " << nServerIndex
597 <<
", ID: " << strServerID.
Get() <<
"\n";
609 theServerID, theNymID)
612 std::unique_ptr<OTLedger> theInboxAngel(pInbox);
615 if (
nullptr != pInbox) {
616 int32_t nIndex = (-1);
621 otOut << __FUNCTION__
622 <<
": Incoming payment: " << nIndex <<
"\n";
623 const std::string* p_str_asset_type =
624 &OTRecordList::s_blank;
625 const std::string* p_str_asset_name =
626 &OTRecordList::s_blank;
627 std::string str_type;
631 std::unique_ptr<OTPayment> thePaymentAngel(pPayment);
635 otErr << __FUNCTION__
636 <<
": Payment retrieved from payments "
637 "inbox was nullptr. (It's abbreviated?) "
643 else if (pPayment->
IsValid() &&
649 const std::string str_inpmt_asset(
653 auto it_asset = m_assets.find(str_inpmt_asset);
654 if (it_asset != m_assets.end())
675 otErr << __FUNCTION__
676 <<
": Skipping: Incoming payment (we "
677 "don't care about asset "
678 << str_inpmt_asset.c_str() <<
")\n";
700 static_cast<int32_t
>(pPayment->
GetType());
702 str_type = GetTypeString(nType);
706 if ((m_bAutoAcceptCheques &&
707 ((0 == str_type.compare(
"cheque")) ||
708 (0 == str_type.compare(
"voucher")))) ||
709 (m_bAutoAcceptCash &&
710 (0 == str_type.compare(
"cash")))) {
711 otOut << __FUNCTION__
712 <<
": Adding to acceptance "
713 "list: pending incoming "
714 << str_type.c_str() <<
".\n";
715 thePaymentMap.insert(
716 std::pair<int32_t, OTPayment*>(
717 nIndex, thePaymentAngel.release()));
720 otOut << __FUNCTION__
721 <<
": Unknown instrument type: "
722 << str_type.c_str() <<
"\n";
725 otOut << __FUNCTION__
726 <<
": Failed in pPayment->IsValid "
727 "or pPayment->SetTempValues()\n";
732 <<
": Failed loading payments inbox. "
733 "(Probably just doesn't exist yet.)\n";
738 if (!thePaymentMap.empty()) {
739 for (mapOfPayments::reverse_iterator it =
740 thePaymentMap.rbegin();
741 it != thePaymentMap.rend();
745 int32_t lIndex = it->first;
747 if (
nullptr == pPayment) {
748 otErr << __FUNCTION__
749 <<
": Error: payment pointer was "
750 "nullptr! (Should never happen.) "
756 otErr << __FUNCTION__
757 <<
": Error: Failed while trying to "
758 "get payment string contents. "
766 std::string str_asset_type_id;
769 const OTString strAssetTypeID(paymentAssetType);
770 str_asset_type_id = strAssetTypeID.
Get();
772 if (str_asset_type_id.empty()) {
773 otErr << __FUNCTION__
774 <<
": Error: Failed while trying to "
775 "get asset type ID from payment. "
780 for (
auto& it_acct : m_accounts) {
781 const std::string& str_account_id(it_acct);
792 const std::string str_acct_type =
796 const OTString strAcctServerID(theAcctServerID);
797 const OTString strAcctAssetID(theAcctAssetID);
807 if ((theNymID == theAcctNymID) &&
809 str_server_id.c_str())) &&
811 str_asset_type_id.c_str())) &&
813 str_acct_type.compare(
"simple")))
821 strIndices.
Format(
"%d", lIndex);
822 const std::string str_indices(strIndices.
Get());
825 if (!madeEasy.accept_from_paymentbox(
826 str_account_id, str_indices,
"ANY")) {
827 otErr << __FUNCTION__
828 <<
": Error while trying to "
829 "accept this instrument.\n";
838 for (
auto& it : thePaymentMap) {
840 if (
nullptr != pPayment)
delete pPayment;
843 thePaymentMap.clear();
853 if (m_bAutoAcceptReceipts || m_bAutoAcceptTransfers) {
854 int32_t nAccountIndex = -1;
855 for (
auto& it_acct : m_accounts) {
857 if (0 == nAccountIndex)
858 otOut <<
"---------------------------------\n " << __FUNCTION__
860 "Beginning auto-accept loop through the "
861 "accounts in the wallet...\n";
863 const std::string& str_account_id(it_acct);
871 const OTString strServerID(theServerID);
872 const OTString strAssetID(theAssetID);
873 otOut <<
"------------\n" << __FUNCTION__
874 <<
": Account: " << nAccountIndex
875 <<
", ID: " << str_account_id.c_str() <<
"\n";
876 const std::string str_nym_id(strNymID.
Get());
877 const std::string str_server_id(strServerID.
Get());
878 const std::string str_asset_id(strAssetID.
Get());
892 auto it_nym = std::find(m_nyms.begin(), m_nyms.end(), str_nym_id);
894 std::find(m_servers.begin(), m_servers.end(), str_server_id);
895 auto it_asset = m_assets.find(str_asset_id);
896 if ((m_nyms.end() == it_nym) || (m_servers.end() == it_server) ||
897 (m_assets.end() == it_asset)) {
898 otOut << __FUNCTION__ <<
": Skipping an account ("
899 << str_account_id.c_str()
900 <<
") since its Nym, or Server, "
901 "or Asset Type wasn't on my list.\n";
916 theServerID, theNymID, theAccountID)
918 theServerID, theNymID, theAccountID);
919 std::unique_ptr<OTLedger> theInboxAngel(pInbox);
920 if (
nullptr == pInbox) {
921 otOut << __FUNCTION__ <<
": Skipping an account ("
922 << str_account_id.c_str()
924 "inbox failed to load (have you downloaded "
925 "the latest one?)\n";
929 const std::string str_inbox(strInbox.
Get());
930 bool bFoundAnyToAccept =
false;
931 std::string strResponseLedger;
932 int32_t nInboxIndex = -1;
936 if (0 == nInboxIndex)
939 <<
": Beginning loop through asset account INBOX...\n";
942 otOut << __FUNCTION__ <<
": Inbox index: " << nInboxIndex
944 const std::string str_type(
946 const bool bIsTransfer =
948 const bool bIsReceipt = !bIsTransfer;
949 if ((m_bAutoAcceptReceipts && bIsReceipt) ||
950 (m_bAutoAcceptTransfers && bIsTransfer)) {
951 otOut << __FUNCTION__ <<
": Auto-accepting: incoming "
952 << (bIsTransfer ?
"pending transfer" :
"receipt")
953 <<
" (str_type: " << str_type.c_str() <<
")\n";
957 if (!bFoundAnyToAccept) {
958 bFoundAnyToAccept =
true;
961 int32_t nNumberNeeded = 20;
966 str_server_id, str_nym_id)) {
967 otOut <<
"\n\nFailure: "
968 "make_sure_enough_trans_nums: "
969 "returned false. (Skipping inbox "
970 "for account " << str_account_id.c_str()
976 str_server_id, str_nym_id, str_account_id,
979 if (strResponseLedger.empty()) {
980 otOut <<
"\n\nFailure: "
981 "OT_API_Ledger_CreateResponse "
982 "returned nullptr. (Skipping inbox "
983 "for account " << str_account_id.c_str()
988 const OTString strTrans(*pBoxTrans);
989 const std::string str_trans(strTrans.
Get());
990 std::string strNEW_ResponseLEDGER =
992 str_server_id, str_nym_id, str_account_id,
993 strResponseLedger, str_trans,
997 if (strNEW_ResponseLEDGER.empty()) {
998 otOut <<
"\n\nFailure: "
999 "OT_API_Transaction_CreateResponse "
1000 "returned nullptr. (Skipping inbox for "
1001 "account " << str_account_id.c_str() <<
")\n";
1004 strResponseLedger = strNEW_ResponseLEDGER;
1010 if (bFoundAnyToAccept && !strResponseLedger.empty()) {
1011 std::string strFinalizedResponse =
1013 str_server_id, str_nym_id, str_account_id,
1016 if (strFinalizedResponse.empty()) {
1017 otOut <<
"\n\nFailure: "
1018 "OT_API_Ledger_FinalizeResponse returned "
1019 "nullptr. (Skipping inbox for account "
1020 << str_account_id.c_str() <<
")\n";
1030 str_server_id, str_nym_id, str_account_id,
1031 strFinalizedResponse);
1032 std::string strAttempt =
"process_inbox";
1035 str_server_id, str_nym_id, str_account_id, strAttempt,
1038 if (1 == nInterpretReply) {
1044 str_server_id, str_nym_id, str_account_id,
1047 otOut <<
"\n\nServer response (" << strAttempt.c_str()
1049 "processing/accepting inbox.\n";
1050 otOut << (bRetrieved ?
"Success" :
"Failed")
1051 <<
" retrieving intermediary files for account.\n";
1061 return j->operator<(*i);
1082 if (
nullptr == pWallet) {
1083 otErr <<
"OTRecordList::" << __FUNCTION__
1084 <<
": Error: Wallet is nullptr.\n";
1094 int32_t nNymIndex = -1;
1095 for (
auto& it_nym : m_nyms) {
1098 otOut <<
"=============== " << __FUNCTION__
1099 <<
": Beginning loop through Nyms...\n";
1100 const std::string& str_nym_id(it_nym);
1104 if (
nullptr == pNym)
continue;
1107 const int32_t nOutpaymentsCount =
1110 otOut <<
"--------\n" << __FUNCTION__ <<
": Nym " << nNymIndex
1111 <<
", nOutpaymentsCount: " << nOutpaymentsCount
1112 <<
", ID: " << strNymID.
Get() <<
"\n";
1113 for (int32_t nCurrentOutpayment = 0;
1114 nCurrentOutpayment < nOutpaymentsCount; ++nCurrentOutpayment) {
1115 otOut << __FUNCTION__
1116 <<
": Outpayment instrument: " << nCurrentOutpayment <<
"\n";
1119 str_nym_id, nCurrentOutpayment));
1120 std::string str_memo;
1124 otErr << __FUNCTION__
1125 <<
": Skipping: Unable to load outpayments "
1126 "instrument from string:\n" << strOutpayment.
Get()
1130 int64_t lAmount = 0;
1131 std::string str_amount;
1145 strTemp.
Format(
"%" PRId64
"", lAmount);
1146 str_amount = strTemp.
Get();
1149 const std::string* p_str_asset_type =
1150 &OTRecordList::s_blank;
1151 const std::string* p_str_asset_name =
1152 &OTRecordList::s_blank;
1153 std::string str_outpmt_asset;
1158 str_outpmt_asset = strTemp.
Get();
1159 auto it_asset = m_assets.find(str_outpmt_asset);
1160 if (it_asset != m_assets.end())
1165 p_str_asset_name = &(it_asset->second);
1175 otOut << __FUNCTION__
1176 <<
": Skipping outpayment (we don't care "
1177 "about asset type " << str_outpmt_asset.c_str()
1191 const std::string* p_str_account =
1192 &OTRecordList::s_blank;
1193 std::string str_outpmt_account;
1201 str_outpmt_account = strTemp.
Get();
1202 auto it_acct = std::find(m_accounts.begin(), m_accounts.end(),
1203 str_outpmt_account);
1204 if (it_acct != m_accounts.end())
1207 p_str_account = &(*it_acct);
1223 otOut << __FUNCTION__
1224 <<
": Skipping outpayment (we don't care "
1225 "about account " << str_outpmt_account.c_str()
1237 const std::string str_outpmt_server =
1239 str_nym_id, nCurrentOutpayment);
1240 const std::string str_outpmt_recipientID =
1242 str_nym_id, nCurrentOutpayment);
1249 auto it_server = std::find(m_servers.begin(), m_servers.end(),
1252 if (it_server != m_servers.end())
1265 std::string str_name;
1267 if (strName.Exists())
1271 str_outpmt_recipientID.c_str());
1273 str_name = strNameTemp.Get();
1275 if (theOutPayment.
GetMemo(strMemo)) {
1276 str_memo = strMemo.
Get();
1280 std::string str_date =
"0";
1287 strFrom.
Format(
"%" PRIu64
"", lFrom);
1288 str_date = strFrom.
Get();
1293 int32_t nType =
static_cast<int32_t
>(theOutPayment.
GetType());
1295 const std::string& str_type = GetTypeString(nType);
1298 otOut << __FUNCTION__
1299 <<
": ADDED: pending outgoing instrument (str_type: "
1300 << str_type.c_str() <<
")\n";
1303 *it_server, *p_str_asset_type, *p_str_asset_name,
1325 sp_Record->SetContents(strOutpayment.
Get());
1326 sp_Record->SetOtherNymID(str_outpmt_recipientID);
1327 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
1328 sp_Record->SetDateRange(tFrom, tTo);
1329 sp_Record->SetBoxIndex(nCurrentOutpayment);
1330 int64_t lTransNum = 0;
1332 sp_Record->SetTransactionNum(lTransNum);
1333 m_contents.push_back(sp_Record);
1338 otOut << __FUNCTION__
1339 <<
": Skipping outgoing instrument (we don't "
1340 "care about server " << str_outpmt_server.c_str()
1348 for (int32_t nCurrentMail = 0; nCurrentMail < nMailCount;
1350 otOut << __FUNCTION__ <<
": Mail index: " << nCurrentMail <<
"\n";
1353 const std::string str_mail_server =
1356 const std::string str_mail_senderID =
1365 std::find(m_servers.begin(), m_servers.end(), str_mail_server);
1367 if (it_server != m_servers.end())
1378 m_pLookup->
GetNymName(str_mail_senderID, &(*it_server))),
1380 std::string str_name;
1382 if (strName.Exists())
1386 str_mail_senderID.c_str());
1388 str_name = strNameTemp.Get();
1389 const std::string* p_str_asset_type =
1390 &OTRecordList::s_blank;
1391 const std::string* p_str_asset_name =
1392 &OTRecordList::s_blank;
1393 const std::string* p_str_account =
1394 &OTRecordList::s_blank;
1396 std::string str_amount;
1399 uint64_t lDate = pMsg->
m_lTime;
1401 strDate.
Format(
"%" PRIu64
"", lDate);
1402 const std::string str_date(strDate.
Get());
1405 otOut << __FUNCTION__ <<
": ADDED: incoming mail.\n";
1408 *it_server, *p_str_asset_type, *p_str_asset_name,
1422 str_amount, OTRecordList::s_message_type,
1430 str_nym_id, nCurrentMail));
1431 sp_Record->SetContents(strMail.
Get());
1432 sp_Record->SetOtherNymID(str_mail_senderID);
1433 sp_Record->SetBoxIndex(nCurrentMail);
1434 sp_Record->SetDateRange(
1437 m_contents.push_back(sp_Record);
1442 const int32_t nOutmailCount =
1444 for (int32_t nCurrentOutmail = 0; nCurrentOutmail < nOutmailCount;
1445 ++nCurrentOutmail) {
1446 otOut << __FUNCTION__ <<
": Outmail index: " << nCurrentOutmail
1450 const std::string str_mail_server =
1453 const std::string str_mail_recipientID =
1462 std::find(m_servers.begin(), m_servers.end(), str_mail_server);
1464 if (it_server != m_servers.end())
1475 m_pLookup->
GetNymName(str_mail_recipientID, &(*it_server))),
1477 std::string str_name;
1479 if (strName.Exists())
1483 str_mail_recipientID.c_str());
1485 str_name = strNameTemp.Get();
1486 const std::string* p_str_asset_type =
1487 &OTRecordList::s_blank;
1488 const std::string* p_str_asset_name =
1489 &OTRecordList::s_blank;
1490 const std::string* p_str_account =
1491 &OTRecordList::s_blank;
1493 std::string str_amount;
1496 uint64_t lDate = pMsg->
m_lTime;
1498 strDate.
Format(
"%" PRIu64
"", lDate);
1499 const std::string str_date(strDate.
Get());
1502 otOut << __FUNCTION__ <<
": ADDED: sent mail.\n";
1505 *it_server, *p_str_asset_type, *p_str_asset_name,
1519 str_amount, OTRecordList::s_message_type,
1528 sp_Record->SetContents(strOutmail.
Get());
1529 sp_Record->SetBoxIndex(nCurrentOutmail);
1530 sp_Record->SetOtherNymID(str_mail_recipientID);
1531 sp_Record->SetDateRange(
1534 m_contents.push_back(sp_Record);
1540 int32_t nServerIndex = -1;
1541 for (
auto& it_server : m_servers) {
1546 const OTString strServerID(theServerID);
1547 otOut << __FUNCTION__ <<
": Server " << nServerIndex
1548 <<
", ID: " << strServerID.
Get() <<
"\n";
1562 std::unique_ptr<OTLedger> theInboxAngel(pInbox);
1564 int32_t nIndex = (-1);
1566 if (
nullptr != pInbox) {
1571 otOut << __FUNCTION__ <<
": Incoming payment: " << nIndex
1573 std::string str_name;
1575 std::string str_sender_nym_id;
1576 std::string str_sender_acct_id;
1582 const OTString strSenderID(theSenderID);
1583 str_sender_nym_id = strSenderID.
Get();
1586 str_sender_nym_id, &it_server)),
1589 if (strName.Exists())
1594 str_sender_nym_id.c_str());
1596 str_name = strNameTemp.Get();
1602 const OTString strSenderID(theSenderID);
1603 str_sender_acct_id = strSenderID.
Get();
1607 std::string str_date =
1612 tValidFrom = tDateSigned;
1613 const uint64_t lDateSigned =
1616 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
1617 str_date = strDateSigned.
Get();
1619 const std::string* p_str_asset_type =
1620 &OTRecordList::s_blank;
1621 const std::string* p_str_asset_name =
1622 &OTRecordList::s_blank;
1623 std::string str_amount;
1624 std::string str_type;
1625 std::string str_memo;
1636 strTemp.
Format(
"%" PRId64
"", lAmount);
1637 str_amount = strTemp.
Get();
1646 std::unique_ptr<OTPayment> thePaymentAngel(pPayment);
1660 strTemp.
Format(
"%" PRId64
"", lAmount);
1661 str_amount = strTemp.
Get();
1672 const uint64_t lFrom =
1675 strFrom.
Format(
"%" PRIu64
"", lFrom);
1676 str_date = strFrom.
Get();
1679 if (pPayment->
GetMemo(strMemo)) {
1680 str_memo = strMemo.
Get();
1687 const std::string str_inpmt_asset(
1691 auto it_asset = m_assets.find(str_inpmt_asset);
1692 if (it_asset != m_assets.end())
1702 &(it_asset->second);
1713 otErr << __FUNCTION__
1714 <<
": Skipping: Incoming payment (we "
1715 "don't care about asset "
1716 << str_inpmt_asset.c_str() <<
")\n";
1720 if (str_sender_acct_id.empty() &&
1724 str_sender_acct_id = strTemp.
Get();
1744 static_cast<int32_t
>(pPayment->
GetType());
1746 str_type = GetTypeString(nType);
1747 int64_t lAmount = 0;
1751 strTemp.
Format(
"%" PRId64
"", lAmount);
1752 str_amount = strTemp.
Get();
1756 otOut << __FUNCTION__
1757 <<
": ADDED: pending incoming payment (str_type: "
1758 << str_type.c_str() <<
")\n";
1761 it_server, *p_str_asset_type, *p_str_asset_name,
1763 OTRecordList::s_blank,
1772 str_amount, str_type,
1781 if (strContents.
Exists())
1782 sp_Record->SetContents(strContents.
Get());
1783 sp_Record->SetDateRange(tValidFrom, tValidTo);
1784 sp_Record->SetBoxIndex(nIndex);
1785 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
1786 if (!str_sender_nym_id.empty())
1787 sp_Record->SetOtherNymID(str_sender_nym_id);
1788 if (!str_sender_acct_id.empty())
1789 sp_Record->SetOtherAccountID(str_sender_acct_id);
1790 sp_Record->SetTransNumForDisplay(
1792 sp_Record->SetTransactionNum(
1795 m_contents.push_back(sp_Record);
1801 <<
": Failed loading payments inbox. "
1802 "(Probably just doesn't exist yet.)\n";
1812 theServerID, theNymID, theNymID)
1816 std::unique_ptr<OTLedger> theRecordBoxAngel(pRecordbox);
1819 if (
nullptr != pRecordbox) {
1823 bool bOutgoing =
false;
1825 otOut << __FUNCTION__
1826 <<
": Payment RECORD index: " << nIndex <<
"\n";
1827 std::string str_name;
1830 std::string str_other_nym_id;
1831 std::string str_other_acct_id;
1838 const OTString strSenderID(theSenderID);
1839 const std::string str_sender_id(strSenderID.
Get());
1851 str_nym_id.compare(str_sender_id))
1864 const std::string str_recipient_id(
1865 strRecipientID.
Get());
1868 str_recipient_id, &it_server)),
1871 if (strName.Exists())
1878 str_recipient_id.c_str());
1880 str_name = strNameTemp.Get();
1881 str_other_nym_id = str_recipient_id;
1883 theRecipientAcctID)) {
1885 theRecipientAcctID);
1887 strRecipientAcctID.
Get();
1898 str_sender_id, &it_server)),
1901 if (strName.Exists())
1906 str_sender_id.c_str());
1908 str_name = strNameTemp.Get();
1909 str_other_nym_id = str_sender_id;
1914 str_other_acct_id = strSenderAcctID.
Get();
1923 const OTString strRecipientID(theRecipientID);
1924 const std::string str_recipient_id(
1925 strRecipientID.
Get());
1940 str_recipient_id, &it_server)),
1943 if (strName.Exists())
1949 str_recipient_id.c_str());
1951 str_name = strNameTemp.Get();
1952 str_other_nym_id = str_recipient_id;
1954 theRecipientAcctID)) {
1956 theRecipientAcctID);
1958 strRecipientAcctID.
Get();
1964 std::string str_date =
1969 tValidFrom = tDateSigned;
1970 const uint64_t lDateSigned =
1973 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
1974 str_date = strDateSigned.
Get();
1976 const std::string* p_str_asset_type =
1977 &OTRecordList::s_blank;
1978 const std::string* p_str_asset_name =
1979 &OTRecordList::s_blank;
1980 const std::string* p_str_account =
1981 &OTRecordList::s_blank;
1982 std::string str_amount;
1983 std::string str_type;
1984 std::string str_memo;
1995 strTemp.
Format(
"%" PRId64
"", lAmount);
1996 str_amount = strTemp.
Get();
2006 std::unique_ptr<OTPayment> thePaymentAngel(pPayment);
2018 strTemp.
Format(
"%" PRId64
"", lAmount);
2019 str_amount = strTemp.
Get();
2029 const uint64_t lFrom =
2032 strFrom.
Format(
"%" PRIu64
"", lFrom);
2033 str_date = strFrom.
Get();
2047 std::string str_outpmt_account =
2052 auto it_acct = std::find(
2053 m_accounts.begin(), m_accounts.end(),
2054 str_outpmt_account);
2060 p_str_account = &(*it_acct);
2069 otOut << __FUNCTION__
2070 <<
": Skipping 'sent payment' "
2071 "record. (We don't care about "
2073 << str_outpmt_account.c_str()
2103 if (str_other_acct_id.empty() &&
2107 str_other_acct_id = strTemp.
Get();
2121 const std::string str_inpmt_asset(
2125 auto it_asset = m_assets.find(str_inpmt_asset);
2126 if (it_asset != m_assets.end())
2136 &(it_asset->second);
2147 otErr << __FUNCTION__
2148 <<
": Skipping: Payment record (we "
2149 "don't care about asset type "
2150 << str_inpmt_asset.c_str() <<
")\n";
2171 if (pPayment->
GetMemo(strMemo)) {
2172 str_memo = strMemo.
Get();
2176 static_cast<int32_t
>(pPayment->
GetType());
2178 str_type = GetTypeString(nType);
2179 int64_t lAmount = 0;
2183 strTemp.
Format(
"%" PRId64
"", lAmount);
2184 str_amount = strTemp.
Get();
2188 otOut << __FUNCTION__ <<
": ADDED: Payment record "
2189 << (bOutgoing ?
"(sent)" :
"(received)")
2190 <<
" (str_type: " << str_type.c_str() <<
")\n";
2193 it_server, *p_str_asset_type, *p_str_asset_name,
2205 str_amount, str_type,
2213 if (strContents.
Exists())
2214 sp_Record->SetContents(strContents.
Get());
2215 sp_Record->SetDateRange(tValidFrom, tValidTo);
2216 sp_Record->SetBoxIndex(nIndex);
2217 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
2218 if (!str_other_nym_id.empty())
2219 sp_Record->SetOtherNymID(str_other_nym_id);
2220 if (!str_other_acct_id.empty())
2221 sp_Record->SetOtherAccountID(str_other_acct_id);
2222 sp_Record->SetTransNumForDisplay(
2224 sp_Record->SetTransactionNum(
2227 m_contents.push_back(sp_Record);
2233 <<
": Failed loading payments record box. "
2234 "(Probably just doesn't exist yet.)\n";
2247 std::unique_ptr<OTLedger> theExpiredBoxAngel(pExpiredbox);
2250 if (
nullptr != pExpiredbox) {
2254 bool bOutgoing =
false;
2256 otOut << __FUNCTION__
2257 <<
": Expired payment RECORD index: " << nIndex
2259 std::string str_name;
2262 std::string str_other_nym_id;
2263 std::string str_other_acct_id;
2270 const OTString strSenderID(theSenderID);
2271 const std::string str_sender_id(strSenderID.
Get());
2283 str_nym_id.compare(str_sender_id))
2296 const std::string str_recipient_id(
2297 strRecipientID.
Get());
2300 str_recipient_id, &it_server)),
2303 if (strName.Exists())
2310 str_recipient_id.c_str());
2312 str_name = strNameTemp.Get();
2313 str_other_nym_id = str_recipient_id;
2315 theRecipientAcctID)) {
2317 theRecipientAcctID);
2319 strRecipientAcctID.
Get();
2330 str_sender_id, &it_server)),
2333 if (strName.Exists())
2338 str_sender_id.c_str());
2340 str_name = strNameTemp.Get();
2341 str_other_nym_id = str_sender_id;
2346 str_other_acct_id = strSenderAcctID.
Get();
2355 const OTString strRecipientID(theRecipientID);
2356 const std::string str_recipient_id(
2357 strRecipientID.
Get());
2372 str_recipient_id, &it_server)),
2375 if (strName.Exists())
2381 str_recipient_id.c_str());
2383 str_name = strNameTemp.Get();
2384 str_other_nym_id = str_recipient_id;
2386 theRecipientAcctID)) {
2388 theRecipientAcctID);
2390 strRecipientAcctID.
Get();
2396 std::string str_date =
2401 tValidFrom = tDateSigned;
2402 const uint64_t lDateSigned =
2405 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
2406 str_date = strDateSigned.
Get();
2408 const std::string* p_str_asset_type =
2409 &OTRecordList::s_blank;
2410 const std::string* p_str_asset_name =
2411 &OTRecordList::s_blank;
2412 const std::string* p_str_account =
2413 &OTRecordList::s_blank;
2414 std::string str_amount;
2415 std::string str_type;
2416 std::string str_memo;
2427 strTemp.
Format(
"%" PRId64
"", lAmount);
2428 str_amount = strTemp.
Get();
2438 std::unique_ptr<OTPayment> thePaymentAngel(pPayment);
2450 strTemp.
Format(
"%" PRId64
"", lAmount);
2451 str_amount = strTemp.
Get();
2461 const uint64_t lFrom =
2464 strFrom.
Format(
"%" PRIu64
"", lFrom);
2465 str_date = strFrom.
Get();
2479 std::string str_outpmt_account =
2484 auto it_acct = std::find(
2485 m_accounts.begin(), m_accounts.end(),
2486 str_outpmt_account);
2492 p_str_account = &(*it_acct);
2503 <<
": Skipping 'sent payment' "
2504 "expired record. (We don't care "
2506 << str_outpmt_account.c_str()
2536 if (str_other_acct_id.empty() &&
2540 str_other_acct_id = strTemp.
Get();
2554 const std::string str_inpmt_asset(
2558 auto it_asset = m_assets.find(str_inpmt_asset);
2559 if (it_asset != m_assets.end())
2569 &(it_asset->second);
2582 <<
": Skipping: Expired payment record "
2583 "(we don't care about asset type "
2584 << str_inpmt_asset.c_str() <<
")\n";
2605 if (pPayment->
GetMemo(strMemo)) {
2606 str_memo = strMemo.
Get();
2610 static_cast<int32_t
>(pPayment->
GetType());
2612 str_type = GetTypeString(nType);
2613 int64_t lAmount = 0;
2617 strTemp.
Format(
"%" PRId64
"", lAmount);
2618 str_amount = strTemp.
Get();
2622 otOut << __FUNCTION__ <<
": ADDED: Expired payment record "
2623 << (bOutgoing ?
"(sent)" :
"(received)")
2624 <<
" (str_type: " << str_type.c_str() <<
")\n";
2627 it_server, *p_str_asset_type, *p_str_asset_name,
2639 str_amount, str_type,
2647 if (strContents.
Exists())
2648 sp_Record->SetContents(strContents.
Get());
2649 sp_Record->SetDateRange(tValidFrom, tValidTo);
2650 sp_Record->SetExpired();
2651 sp_Record->SetBoxIndex(nIndex);
2652 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
2653 if (!str_other_nym_id.empty())
2654 sp_Record->SetOtherNymID(str_other_nym_id);
2655 if (!str_other_acct_id.empty())
2656 sp_Record->SetOtherAccountID(str_other_acct_id);
2657 sp_Record->SetTransNumForDisplay(
2659 sp_Record->SetTransactionNum(
2662 m_contents.push_back(sp_Record);
2668 <<
": Failed loading expired payments box. "
2669 "(Probably just doesn't exist yet.)\n";
2676 otOut <<
"================ " << __FUNCTION__
2677 <<
": Looping through the accounts in the wallet...\n";
2678 int32_t nAccountIndex = -1;
2679 for (
auto& it_acct : m_accounts) {
2683 const std::string& str_account_id(it_acct);
2691 const OTString strServerID(theServerID);
2692 const OTString strAssetID(theAssetID);
2693 otOut <<
"------------\n" << __FUNCTION__
2694 <<
": Account: " << nAccountIndex
2695 <<
", ID: " << str_account_id.c_str() <<
"\n";
2696 const std::string str_nym_id(strNymID.
Get());
2697 const std::string str_server_id(strServerID.
Get());
2698 const std::string str_asset_id(strAssetID.
Get());
2699 const std::string* pstr_nym_id = &OTRecordList::s_blank;
2700 const std::string* pstr_server_id = &OTRecordList::s_blank;
2701 const std::string* pstr_asset_id = &OTRecordList::s_blank;
2702 const std::string* pstr_asset_name = &OTRecordList::s_blank;
2715 auto it_nym = std::find(m_nyms.begin(), m_nyms.end(), str_nym_id);
2717 std::find(m_servers.begin(), m_servers.end(), str_server_id);
2718 auto it_asset = m_assets.find(str_asset_id);
2719 if ((m_nyms.end() == it_nym) || (m_servers.end() == it_server) ||
2720 (m_assets.end() == it_asset)) {
2721 otOut << __FUNCTION__ <<
": Skipping an account ("
2722 << str_account_id.c_str()
2723 <<
") since its Nym, or Server, "
2724 "or Asset Type wasn't on my list.\n";
2729 pstr_nym_id = &(*it_nym);
2730 pstr_server_id = &(*it_server);
2731 pstr_asset_id = &(it_asset->first);
2732 pstr_asset_name = &(it_asset->second);
2745 theServerID, theNymID, theAccountID)
2747 theServerID, theNymID, theAccountID);
2748 std::unique_ptr<OTLedger> theInboxAngel(pInbox);
2751 if (
nullptr != pInbox) {
2752 int32_t nInboxIndex = -1;
2755 if (0 == nInboxIndex)
2758 <<
": Beginning loop through asset account INBOX...\n";
2761 otOut << __FUNCTION__ <<
": Inbox index: " << nInboxIndex
2763 bool bCanceled =
false;
2764 std::string str_name;
2766 std::string str_other_nym_id;
2767 std::string str_other_acct_id;
2768 std::string str_memo;
2773 if (pBoxTrans->
GetMemo(strMemo)) str_memo = strMemo.
Get();
2791 const OTString strSenderID(theSenderID);
2792 str_other_nym_id = strSenderID.
Get();
2794 const OTString strSenderAcctID(theSenderAcctID);
2795 const std::string str_sender_acct_id(
2796 strSenderAcctID.
Get());
2798 str_other_acct_id = str_sender_acct_id;
2802 str_other_nym_id.empty()
2804 : &str_other_nym_id,
2809 if (strName.Exists()) {
2812 str_name = strNameTemp.
Get();
2814 else if (!str_other_nym_id.empty()) {
2816 str_other_nym_id, &(*it_server))),
2819 if (strNymName.Exists()) {
2823 str_name = strNameTemp.
Get();
2826 if (str_name.empty()) {
2828 str_sender_acct_id.c_str());
2829 str_name = strNameTemp.
Get();
2835 const OTString strSenderID(theSenderID);
2836 const std::string str_sender_id(strSenderID.
Get());
2839 str_sender_id, &(*it_server))),
2842 if (strName.Exists())
2847 str_sender_id.c_str());
2849 str_name = strNameTemp.Get();
2850 str_other_nym_id = str_sender_id;
2857 if (strName.Exists())
2858 strNameTemp = strName;
2860 strNameTemp = str_account_id;
2862 str_name = strNameTemp.
Get();
2871 const OTString strRecipientID(theRecipientID);
2872 const std::string str_recipient_user_id(
2873 strRecipientID.
Get());
2876 str_recipient_user_id, &(*it_server))),
2879 if (strName.Exists())
2885 str_recipient_user_id.c_str());
2887 str_name = strNameTemp.Get();
2888 str_other_nym_id = str_recipient_user_id;
2890 theRecipientAcctID)) {
2892 theRecipientAcctID);
2893 str_other_acct_id = strRecipientAcctID.
Get();
2897 theRecipientAcctID)) {
2899 theRecipientAcctID);
2900 const std::string str_recipient_acct_id(
2901 strRecipientAcctID.
Get());
2904 str_recipient_acct_id,
2910 if (strName.Exists())
2916 str_recipient_acct_id.c_str());
2918 str_name = strNameTemp.Get();
2919 str_other_acct_id = str_recipient_acct_id;
2925 std::string str_date =
2930 tValidFrom = tDateSigned;
2931 const uint64_t lDateSigned =
2934 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
2935 str_date = strDateSigned.
Get();
2937 std::string str_amount;
2943 strTemp.
Format(
"%" PRId64
"", lAmount);
2944 str_amount = strTemp.
Get();
2946 const std::string str_type(
2948 otOut << __FUNCTION__ <<
": ADDED: incoming "
2950 ?
"pending transfer"
2951 :
"receipt") <<
" (str_type: " << str_type.c_str()
2955 *pstr_server_id, *pstr_asset_id, *pstr_asset_name,
2964 str_amount, str_type,
2965 (OTTransaction::pending ==
2967 (lAmount < 0) ?
true :
false,
2976 (OTTransaction::pending !=
2978 (OTTransaction::pending == pBoxTrans->
GetType())
2981 const OTString strContents(*pBoxTrans);
2982 sp_Record->SetContents(strContents.Get());
2983 sp_Record->SetDateRange(tValidFrom, tValidTo);
2984 sp_Record->SetBoxIndex(nInboxIndex);
2985 if (bCanceled) sp_Record->SetCanceled();
2986 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
2987 if (!str_other_nym_id.empty())
2988 sp_Record->SetOtherNymID(str_other_nym_id);
2989 if (!str_other_acct_id.empty())
2990 sp_Record->SetOtherAccountID(str_other_acct_id);
2991 sp_Record->SetTransNumForDisplay(
2994 m_contents.push_back(sp_Record);
3007 theServerID, theNymID, theAccountID)
3009 theServerID, theNymID, theAccountID);
3010 std::unique_ptr<OTLedger> theOutboxAngel(pOutbox);
3013 if (
nullptr != pOutbox) {
3014 int32_t nOutboxIndex = -1;
3017 if (0 == nOutboxIndex)
3020 <<
": Beginning loop through asset account OUTBOX...\n";
3023 otOut << __FUNCTION__ <<
": Outbox index: " << nOutboxIndex
3025 std::string str_name;
3027 std::string str_other_nym_id;
3028 std::string str_other_acct_id;
3029 std::string str_memo;
3036 const OTString strRecipientID(theRecipientID);
3037 const std::string str_recipient_id(
3038 strRecipientID.
Get());
3044 if (strName.Exists())
3049 str_recipient_id.c_str());
3051 str_name = strNameTemp.Get();
3052 str_other_nym_id = str_recipient_id;
3054 theRecipientAcctID)) {
3056 theRecipientAcctID);
3057 str_other_acct_id = strRecipientAcctID.
Get();
3061 theRecipientAcctID)) {
3062 const OTString strRecipientAcctID(theRecipientAcctID);
3063 const std::string str_recipient_acct_id(
3064 strRecipientAcctID.
Get());
3067 str_recipient_acct_id,
nullptr,
3072 if (strName.Exists())
3077 str_recipient_acct_id.c_str());
3079 str_name = strNameTemp.Get();
3080 str_other_acct_id = str_recipient_acct_id;
3085 if (pBoxTrans->
GetMemo(strMemo))
3086 str_memo = strMemo.
Get();
3099 std::string str_date =
3104 tValidFrom = tDateSigned;
3105 const uint64_t lDateSigned =
3108 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
3109 str_date = strDateSigned.
Get();
3111 std::string str_amount;
3120 strTemp.
Format(
"%" PRId64
"", lAmount);
3121 str_amount = strTemp.
Get();
3123 std::string str_type(
3125 if (0 == str_type.compare(
"pending")) str_type =
"transfer";
3126 otOut << __FUNCTION__ <<
": ADDED: "
3130 <<
" outgoing transfer (str_type: " << str_type.c_str()
3134 *pstr_server_id, *pstr_asset_id, *pstr_asset_name,
3143 str_amount, str_type,
3144 (OTTransaction::pending ==
3151 const OTString strContents(*pBoxTrans);
3152 sp_Record->SetContents(strContents.Get());
3153 sp_Record->SetDateRange(tValidFrom, tValidTo);
3154 sp_Record->SetBoxIndex(nOutboxIndex);
3155 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
3156 if (!str_other_nym_id.empty())
3157 sp_Record->SetOtherNymID(str_other_nym_id);
3158 if (!str_other_acct_id.empty())
3159 sp_Record->SetOtherAccountID(str_other_acct_id);
3160 sp_Record->SetTransNumForDisplay(
3163 m_contents.push_back(sp_Record);
3179 theServerID, theNymID, theAccountID)
3181 theServerID, theNymID, theAccountID);
3182 std::unique_ptr<OTLedger> theRecordBoxAngel(pRecordbox);
3185 if (
nullptr != pRecordbox) {
3186 int32_t nRecordIndex = -1;
3191 otOut << __FUNCTION__
3192 <<
": Account RECORD index: " << nRecordIndex <<
"\n";
3193 bool bOutgoing =
false;
3194 bool bCanceled =
false;
3195 std::string str_name;
3198 std::string str_other_nym_id;
3199 std::string str_other_acct_id;
3200 std::string str_memo;
3207 const OTString strSenderAcctID(theSenderAcctID);
3208 const std::string str_sender_acct_id(
3209 strSenderAcctID.
Get());
3221 str_account_id.compare(
3222 str_sender_acct_id))
3230 const bool bGotRecipientUserIDForDisplay =
3235 theRecipientAcctID)) {
3237 theRecipientAcctID);
3238 const std::string str_recip_acct_id(
3239 strRecipientAcctID.
Get());
3242 std::string str_recip_user_id(
"");
3244 if (bGotRecipientUserIDForDisplay) {
3246 strRecipientUserID);
3248 strRecipientUserID.Get();
3276 bGotRecipientUserIDForDisplay
3277 ? &str_recip_user_id
3283 if (strName.Exists())
3290 str_recip_acct_id.c_str());
3298 str_other_acct_id = str_recip_acct_id;
3300 if (bGotRecipientUserIDForDisplay) {
3301 const OTString strRecipientID(theRecipientID);
3302 const std::string str_recipient_id(
3303 strRecipientID.
Get());
3305 str_other_nym_id = str_recipient_id;
3307 if (str_name.empty()) {
3309 str_recipient_id, &(*it_server))),
3312 if (strName.Exists())
3319 str_recipient_id.c_str());
3321 str_name = strNameTemp.Get();
3334 const OTString strSenderUserID(theSenderID);
3335 str_other_nym_id = strSenderUserID.
Get();
3339 str_other_nym_id.empty()
3341 : &str_other_nym_id,
3346 if (strName.Exists())
3351 str_sender_acct_id.c_str());
3353 str_name = strNameTemp.
Get();
3354 str_other_acct_id = str_sender_acct_id;
3361 theRecipientAcctID)) {
3364 const OTString strRecipientID(theRecipientID);
3365 const std::string str_recipient_user_id(
3366 strRecipientID.
Get());
3368 str_other_nym_id = str_recipient_user_id;
3370 const OTString strRecipientAcctID(theRecipientAcctID);
3371 const std::string str_recipient_acct_id(
3372 strRecipientAcctID.
Get());
3375 str_account_id.compare(
3376 str_recipient_acct_id))
3387 str_recipient_acct_id,
3388 str_other_nym_id.empty()
3390 : &str_other_nym_id,
3395 if (strName.Exists())
3401 str_recipient_acct_id.c_str());
3403 str_name = strNameTemp.
Get();
3404 str_other_acct_id = str_recipient_acct_id;
3409 const OTString strSenderID(theSenderID);
3410 const std::string str_sender_id(strSenderID.
Get());
3422 str_nym_id.compare(str_sender_id))
3433 const OTString strRecipientID(theRecipientID);
3434 const std::string str_recipient_id(
3435 strRecipientID.
Get());
3438 str_recipient_id, &(*it_server))),
3441 if (strName.Exists())
3447 str_recipient_id.c_str());
3449 str_name = strNameTemp.Get();
3450 str_other_nym_id = str_recipient_id;
3452 theRecipientAcctID)) {
3454 theRecipientAcctID);
3456 strRecipientAcctID.
Get();
3468 str_sender_id, &(*it_server))),
3471 if (strName.Exists())
3476 str_sender_id.c_str());
3478 str_name = strNameTemp.Get();
3479 str_other_nym_id = str_sender_id;
3482 const OTString strSenderAcctID(theSenderAcctID);
3483 str_other_acct_id = strSenderAcctID.
Get();
3492 const OTString strRecipientID(theRecipientID);
3493 const std::string str_recipient_id(
3494 strRecipientID.
Get());
3497 str_nym_id.compare(str_recipient_id))
3509 str_recipient_id, &(*it_server))),
3512 if (strName.Exists())
3517 str_recipient_id.c_str());
3519 str_name = strNameTemp.Get();
3520 str_other_nym_id = str_recipient_id;
3522 theRecipientAcctID)) {
3524 theRecipientAcctID);
3525 str_other_acct_id = strRecipientAcctID.
Get();
3534 if (pBoxTrans->
GetMemo(strMemo)) str_memo = strMemo.
Get();
3539 std::string str_date =
3544 tValidFrom = tDateSigned;
3545 const uint64_t lDateSigned =
3548 strDateSigned.
Format(
"%" PRIu64
"", lDateSigned);
3549 str_date = strDateSigned.
Get();
3551 std::string str_amount;
3555 const std::string str_type(
3557 if (0 == str_type.compare(
"transferReceipt"))
3560 else if (0 == str_type.compare(
"pending"))
3580 strTemp.
Format(
"%" PRId64
"", lAmount);
3581 str_amount = strTemp.
Get();
3583 otOut << __FUNCTION__ <<
": ADDED: "
3586 : (bOutgoing ?
"sent" :
"received"))
3587 <<
" (asset account) record (str_type: "
3588 << str_type.c_str() <<
")\n";
3599 *pstr_server_id, *pstr_asset_id, *pstr_asset_name,
3609 str_amount, str_type,
3619 const OTString strContents(*pBoxTrans);
3620 sp_Record->SetContents(strContents.
Get());
3621 if (bCanceled) sp_Record->SetCanceled();
3622 sp_Record->SetDateRange(tValidFrom, tValidTo);
3623 sp_Record->SetBoxIndex(nRecordIndex);
3624 if (!str_memo.empty()) sp_Record->SetMemo(str_memo);
3625 if (!str_other_nym_id.empty())
3626 sp_Record->SetOtherNymID(str_other_nym_id);
3627 if (!str_other_acct_id.empty())
3628 sp_Record->SetOtherAccountID(str_other_acct_id);
3629 sp_Record->SetTransNumForDisplay(
3632 m_contents.push_back(sp_Record);
3661 std::sort(m_contents.begin(), m_contents.end(),
3670 const std::string& str_msg_id,
3672 bool bIsOutgoing, int32_t nMethodID,
3673 const std::string& str_contents,
3675 const std::string& str_address,
const std::string& str_other_address,
3676 const std::string& str_type,
const std::string& str_type_display,
3677 std::string str_my_nym_id,
time64_t tDate)
3679 const char* pToFrom =
3681 const std::string* p_str_server =
3682 &OTRecordList::s_blank;
3689 std::string str_other_name;
3691 if (!str_other_address.empty())
3694 std::string str_name(
"");
3696 if (!str_other_name.empty())
3697 strNameTemp.
Format(pToFrom, str_other_name.c_str());
3698 else if (!str_other_address.empty())
3699 strNameTemp.
Format(pToFrom, str_other_address.c_str());
3701 str_name = strNameTemp.
Get();
3702 const std::string* p_str_nym_id =
3703 &OTRecordList::s_blank;
3704 const std::string* p_str_asset_type =
3705 &OTRecordList::s_blank;
3706 const std::string* p_str_asset_name =
3707 &OTRecordList::s_blank;
3708 const std::string* p_str_account =
3709 &OTRecordList::s_blank;
3711 std::string str_amount;
3714 uint64_t lDate =
static_cast<uint64_t
>(tDate);
3716 strDate.
Format(
"%" PRIu64
"", lDate);
3717 const std::string str_date(strDate.
Get());
3726 if (!str_my_nym_id.empty()) {
3727 for (
auto& it_nym : m_nyms) {
3728 const std::string& str_nym_id(it_nym);
3730 if (0 == str_my_nym_id.compare(str_nym_id)) {
3731 p_str_nym_id = &str_nym_id;
3737 *p_str_server, *p_str_asset_type, *p_str_asset_name,
3748 str_date, str_amount, OTRecordList::s_message_type,
3753 sp_Record->SetSpecialMail();
3756 sp_Record->SetContents(str_contents.c_str());
3757 sp_Record->SetMsgID(str_msg_id);
3760 sp_Record->SetMethodID(nMethodID);
3761 sp_Record->SetAddress(str_address);
3762 sp_Record->SetOtherAddress(str_other_address);
3763 sp_Record->SetMsgType(str_type);
3764 sp_Record->SetMsgTypeDisplay(str_type_display);
3766 <<
": ADDED: " << (bIsOutgoing ?
"outgoing" :
"incoming")
3767 <<
" special mail.\n";
3769 m_contents.push_back(sp_Record);
3775 : m_pLookup(nullptr)
3777 , m_bAutoAcceptCheques(false)
3778 , m_bAutoAcceptReceipts(false)
3779 , m_bAutoAcceptTransfers(false)
3780 , m_bAutoAcceptCash(false)
3783 "Address Book Caller was nullptr! "
3784 "On app startup, did you forget to call "
3785 "OT_API_Set_AddrBookCallback ?\n");
3787 "Address Book Callback was nullptr! "
3788 "On app startup, did you forget to call "
3789 "OT_API_Set_AddrBookCallback ?\n");
3794 : m_pLookup(&theLookup)
3796 , m_bAutoAcceptCheques(false)
3797 , m_bAutoAcceptReceipts(false)
3798 , m_bAutoAcceptTransfers(false)
3799 , m_bAutoAcceptCash(false)
3810 m_pLookup =
nullptr;
3825 return m_contents.size();
3831 (nIndex < static_cast<int32_t>(m_contents.size())));
3832 m_contents.erase(m_contents.begin() + nIndex);
3839 (nIndex < static_cast<int32_t>(m_contents.size())));
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
EXPORT bool GetAmount(int64_t &lOutput) const
EXPORT bool DoesAcceptReceiptsAutomatically() const
virtual EXPORT ~OTNameLookup()
bool compare_records(shared_ptr_OTRecord i, shared_ptr_OTRecord j)
EXPORT bool GetSenderAcctIDForDisplay(OTIdentifier &theReturnID)
EXPORT bool GetValidFrom(time64_t &tOutput) const
EXPORT void SetServerID(std::string str_id)
EXPORT OTLedger * LoadRecordBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
static OTLookupCaller * s_pCaller
static bool setAddrBookCaller(OTLookupCaller &theCaller)
EXPORT OTLedger * LoadInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT const OTIdentifier & GetAssetTypeID() const
EXPORT void AddSpecialMsg(const std::string &str_msg_id, bool bIsOutgoing, int32_t nMethodID, const std::string &str_contents, const std::string &str_address, const std::string &str_other_address, const std::string &str_type, const std::string &str_type_display, std::string str_my_nym_id="", time64_t tDate=OT_TIME_ZERO)
EXPORT bool RemoveRecord(int32_t nIndex)
EXPORT OTAssetContract * GetAssetContract(const OTIdentifier &theContractID)
EXPORT char const * GetTypeString() const
EXPORT std::string Ledger_FinalizeResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER) const
EXPORT std::string Transaction_CreateResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &RESPONSE_LEDGER, const std::string &ORIGINAL_TRANSACTION, const bool &BOOL_DO_I_ACCEPT) const
static EXPORT std::string GetNym_OutmailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
std::weak_ptr< OTRecord > weak_ptr_OTRecord
EXPORT bool GetRecipientAcctIDForDisplay(OTIdentifier &theReturnID)
std::list< std::string > list_of_strings
EXPORT void AddAssetID(std::string str_id)
EXPORT std::string GetAddressName(const std::string &str_address) const
static EXPORT OTAPI_Exec * It()
EXPORT const OTString & GetCurrencyTLA() const
EXPORT OTWallet * GetWallet(const char *szFuncName=nullptr) const
OTLOG_IMPORT OTLogStream otOut
EXPORT OTLedger * LoadOutbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
OTLOG_IMPORT OTLogStream otLog3
EXPORT bool GetSenderUserIDForDisplay(OTIdentifier &theReturnID)
EXPORT bool GetAccount(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT void SetNymID(std::string str_id)
static EXPORT std::string GetNym_MailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
std::map< int32_t, OTPayment * > mapOfPayments
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
EXPORT bool GetAssetTypeID(OTIdentifier &theOutput) const
EXPORT OTLedger * LoadPaymentInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool GetOpeningNum(int64_t &lOutput, const OTIdentifier &theNymID) const
EXPORT int32_t InterpretTransactionMsgReply(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &str_Attempt, const std::string &str_Response) const
virtual EXPORT std::string GetAcctName(const std::string &str_id, const std::string *p_nym_id=nullptr, const std::string *p_server_id=nullptr, const std::string *p_asset_id=nullptr) const
static EXPORT std::string GetNym_OutmailRecipientIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
EXPORT bool Exists() const
const char * GetTypeString() const
EXPORT OTLedger * LoadPaymentInboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
EXPORT void Format(const char *fmt,...)
EXPORT bool DoesAcceptCashAutomatically() const
EXPORT const OTString & GetCurrencySymbol() const
EXPORT void ClearAssets()
EXPORT bool Compare(const char *compare) const
EXPORT void delCallback()
EXPORT bool GetMemo(OTString &strMemo)
EXPORT bool DoesAcceptChequesAutomatically() const
EXPORT void ClearContents()
const OTIdentifier & GetPurportedServerID() const
EXPORT void SetAssetID(std::string str_id)
virtual EXPORT std::string GetAddressName(const std::string &str_address) const
EXPORT bool GetPaymentContents(OTString &strOutput) const
EXPORT void AcceptReceiptsAutomatically(bool bVal=true)
EXPORT bool GetMemo(OTString &strOutput) const
EXPORT const list_of_strings & GetNyms() const
static EXPORT std::string GetNym_MailServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
EXPORT OTPseudonym * GetNymByID(const OTIdentifier &NYM_ID)
EXPORT void setCallback(OTNameLookup *cb)
EXPORT bool make_sure_enough_trans_nums(int32_t nNumberNeeded, const std::string &SERVER_ID, const std::string &NYM_ID) const
static EXPORT std::string GetNym_OutpaymentsRecipientIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
EXPORT OTMessage * GetOutmailByIndex(int32_t nIndex) const
EXPORT void SetAccountID(std::string str_id)
static EXPORT std::string GetNym_MailSenderIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
EXPORT void ClearServers()
#define OT_ASSERT_MSG(x, s)
virtual EXPORT std::string GetNymName(const std::string &str_id, const std::string *p_server_id=nullptr) const
OTPayment * GetInstrument(const OTPseudonym &theNym, const int32_t &nIndex, OTLedger &ledger)
EXPORT void AcceptTransfersAutomatically(bool bVal=true)
EXPORT void AddServerID(std::string str_id)
EXPORT std::shared_ptr< OTRecord > GetRecord(int32_t nIndex)
EXPORT void ClearAccounts()
time64_t GetDateSigned() const
EXPORT bool IsCancelled()
EXPORT bool SetTempValues()
static EXPORT int32_t GetNym_OutmailCount(const std::string &NYM_ID)
static EXPORT std::string GetNym_OutpaymentsServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
OTLOG_IMPORT OTLogStream otWarn
EXPORT int64_t GetReferenceNumForDisplay()
int64_t GetAbbrevDisplayAmount() const
EXPORT const char * Get() const
EXPORT OTNameLookup * getCallback()
transactionType GetType() const
EXPORT std::string GetNymName(const std::string &str_id, const std::string *p_server_id=nullptr) const
EXPORT bool GetSenderAcctIDForDisplay(OTIdentifier &theOutput) const
OTLOG_IMPORT OTLogStream otErr
EXPORT int64_t GetReceiptAmount()
EXPORT int64_t GetTransactionNum() const
EXPORT std::string Ledger_CreateResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &ORIGINAL_LEDGER) const
Creates a new 'response' ledger, set up with the right Server ID, etc,.
EXPORT bool GetValidTo(time64_t &tOutput) const
EXPORT OTLedger * LoadExpiredBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT void AcceptChequesAutomatically(bool bVal=true)
static EXPORT const char * textFrom()
EXPORT bool IsValid() const
bool IsAbbreviated() const
EXPORT OTLedger * LoadRecordBoxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload=false) const
EXPORT void AddAccountID(std::string str_id)
static EXPORT std::string GetNym_OutmailServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
EXPORT void GetString(OTString &theStr) const
EXPORT std::string GetAcctName(const std::string &str_id, const std::string *p_nym_id=nullptr, const std::string *p_server_id=nullptr, const std::string *p_asset_id=nullptr) const
std::shared_ptr< OTRecord > shared_ptr_OTRecord
EXPORT void AcceptCashAutomatically(bool bVal=true)
static EXPORT OT_API * OTAPI()
EXPORT int32_t size() const
EXPORT OTLedger * LoadExpiredBoxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
const OTIdentifier & GetUserID() const
int64_t OTTimeGetSecondsFromTime(time64_t time)
static EXPORT std::string GetNym_OutpaymentsContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
EXPORT bool DoesAcceptTransfersAutomatically() const
virtual EXPORT void Release()
EXPORT OTServerContract * GetServerContract(const OTIdentifier &SERVER_ID)
EXPORT paymentType GetType() const
EXPORT OTLedger * LoadInboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
static EXPORT int32_t GetNym_MailCount(const std::string &NYM_ID)
EXPORT OTLedger * LoadOutboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
static OTLookupCaller * getAddrBookCaller()
static EXPORT const char * textTo()
EXPORT bool PerformAutoAccept()
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
EXPORT bool isCallbackSet() const
EXPORT bool OT_API_Set_AddrBookCallback(OTLookupCaller &theCaller)
EXPORT OTMessage * GetMailByIndex(int32_t nIndex) const
EXPORT void AddNymID(std::string str_id)
EXPORT void SortRecords()
EXPORT std::string process_inbox(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, const std::string &RESPONSE_LEDGER) const
EXPORT bool GetRecipientUserIDForDisplay(OTIdentifier &theReturnID)
EXPORT const OTString & GetCurrencyName() const
EXPORT const mapOfTransactions & GetTransactionMap() const