133 #include "../core/stdafx.hpp"
140 #include "../ext/OTPayment.hpp"
142 #include "../cash/Mint.hpp"
143 #include "../cash/Purse.hpp"
144 #include "../cash/Token.hpp"
146 #include "../basket/Basket.hpp"
148 #include "../core/recurring/OTPaymentPlan.hpp"
149 #include "../core/OTAccount.hpp"
150 #include "../core/OTAssetContract.hpp"
151 #include "../core/crypto/OTAsymmetricKey.hpp"
152 #include "../core/OTCheque.hpp"
153 #include "../core/crypto/OTEnvelope.hpp"
154 #include "../core/util/OTFolders.hpp"
155 #include "../core/OTLedger.hpp"
156 #include "../core/OTLog.hpp"
157 #include "../core/OTMessage.hpp"
158 #include "../core/crypto/OTNymOrSymmetricKey.hpp"
159 #include "../core/OTPayload.hpp"
160 #include "../core/OTPseudonym.hpp"
161 #include "../core/OTServerContract.hpp"
162 #include "../core/OTStorage.hpp"
163 #include "../core/trade/OTOffer.hpp"
164 #include "../core/trade/OTTrade.hpp"
165 #include "../core/util/StringUtils.hpp"
175 m_lMostRecentRequestNumber = lRequestNumber;
176 if ((-1) == lRequestNumber)
178 else if (0 == lRequestNumber)
181 const int32_t nRequestNum =
static_cast<int32_t
>(lRequestNumber);
183 if (lRequestNumber == nRequestNum)
205 const OTString strMessage(theMessage);
240 "OTClient::ProcessMessageOut: ASSERT: nullptr != m_pConnection\n");
251 "OTClient::ProcessInBuffer: ASSERT: nullptr != m_pConnection\n");
268 otLog4 << __FUNCTION__ <<
": Nymbox is empty.\n";
275 otErr << __FUNCTION__ <<
": Error: VerifyAccount() failed.\n";
285 const OTString strServerID(theServerID), strNymID(theNymID);
287 int64_t lHighestNum = 0;
291 const bool bGotHighestNum = pNym->
GetHighestNum(strServerID, lHighestNum);
329 int64_t lStoredTransactionNumber = 0;
353 processLedger.AddTransaction(*pAcceptTransaction);
371 std::set<int64_t> setNoticeNumbers;
393 otErr << __FUNCTION__ <<
": Error: Unexpected abbreviated receipt "
394 "in Nymbox, even after supposedly loading "
395 "all box receipts. (And it's not a "
396 "replyNotice, either!)\n";
417 pAcceptTransaction->
AddItem(*pAcceptItem);
431 <<
": Received an encrypted message in your Nymbox:\n"
432 << strRespTo <<
"\n";
474 pAcceptTransaction->
AddItem(*pAcceptItem);
488 <<
": Received an encrypted instrument in your Nymbox:\n"
489 << strRespTo <<
"\n";
502 pAcceptTransaction->
AddItem(*pAcceptItem);
556 std::set<int64_t> theNumbers;
557 theOutput.
Output(theNumbers);
561 for (
auto& it : theNumbers) {
562 const int64_t lValue = it;
566 <<
": OTTransaction::successNotice: This wasn't on "
567 "my tentative list (" << lValue
568 <<
"), I must have already processed it. (Or there "
569 "was dropped message when I did, or the server "
570 "is trying to slip me an old number.\n)";
572 setNoticeNumbers.insert(lValue);
581 pAcceptTransaction->
AddItem(*pAcceptItem);
641 "OTItem * pAcceptItem = "
642 "OTItem::CreateItemFromTransaction(*"
643 "pAcceptTransaction, OTItem::acceptNotice); for "
647 pAcceptTransaction->
AddItem(*pAcceptItem);
671 if ((
nullptr != pItem) &&
676 if (!strOriginalReply.
Exists()) {
677 otErr << __FUNCTION__ <<
": Error loading original "
678 "server reply message from "
679 "replyNotice. (It appears to "
680 "be zero length.)\n";
686 "OTClient::AcceptEntireNymbox: OTMessage "
687 "* pMessage = new OTMessage;");
692 otErr << __FUNCTION__
693 <<
": Failed loading original server reply "
694 "message from replyNotice:\n\n"
695 << strOriginalReply <<
"\n\n";
713 *pMessage, &theNymbox);
738 otOut << __FUNCTION__
739 <<
": the replyNotice item was either nullptr, or "
740 "rejected. (Unexpectedly on either count.)\n";
778 std::set<int64_t> theNumbers;
779 theNumlist.
Output(theNumbers);
781 for (
auto& it : theNumbers) {
782 const int64_t lTransactionNumber = it;
787 strServerID, lTransactionNumber))
791 otOut << __FUNCTION__ <<
": Attempted to accept a blank "
792 "transaction number that I "
793 "ALREADY HAD...(Skipping.)\n";
795 strServerID, lTransactionNumber))
802 otOut << __FUNCTION__
803 <<
": Attempted to accept a blank transaction number "
804 "that I ALREADY ACCEPTED (it's on my tentative "
805 "list already; Skipping.)\n";
806 else if (bGotHighestNum &&
807 (lTransactionNumber <= lHighestNum))
811 otOut << __FUNCTION__
812 <<
": Attempted to accept a blank transaction number "
813 "that I've HAD BEFORE, or at least, is <= to ones "
814 "I've had before. (Skipping...)\n";
816 theIssuedNym.
AddIssuedNum(strServerID, lTransactionNumber);
817 theBlankList.Add(lTransactionNumber);
826 pAcceptTransaction->
AddItem(*pAcceptItem);
873 <<
": **** Due to finding a finalReceipt, REMOVING "
874 "OPENING NUMBER FROM NYM: "
878 <<
": **** Noticed a finalReceipt, but Opening Number "
880 <<
" had ALREADY been removed from nym. \n";
918 pAcceptTransaction->
AddItem(*pAcceptItem);
920 pAcceptItem->SetReferenceToNum(
927 pAcceptItem->SignContract(*pNym);
928 pAcceptItem->SaveContract();
947 if (!setNoticeNumbers.empty()) {
970 for (
auto& it : setNoticeNumbers) {
971 const int64_t lNoticeNum = it;
977 *pNym, strServerID, lNoticeNum,
1021 int64_t lTemp = theIssuedNym.
GetIssuedNum(theServerID, i);
1045 bool bAddedTentative =
false;
1048 int64_t lTemp = theIssuedNym.
GetIssuedNum(theServerID, i);
1055 bAddedTentative =
true;
1065 pAcceptTransaction->
AddItem(*pBalanceItem);
1071 otErr << __FUNCTION__ <<
": This should never happen.\n";
1078 processLedger.SignContract(*pNym);
1079 processLedger.SaveContract();
1100 otErr << __FUNCTION__
1101 <<
": Error processing processNymbox command.\n";
1164 bool bSuccess =
false;
1167 const OTAccount* pAccount = &theAccount;
1169 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
1170 if (
nullptr == pOutbox) {
1171 otOut <<
"OTClient::AcceptEntireInbox: Failed loading outbox!\n";
1178 otOut <<
"OTClient::AcceptEntireInbox: no point wasting a transaction "
1179 "number in order to process an empty box\n";
1184 int64_t lStoredTransactionNumber = 0;
1187 lStoredTransactionNumber);
1188 if (!bGotTransNum) {
1189 otOut <<
"Error: No transaction numbers are available. Suggest "
1190 "requesting the server for a new one.\n";
1209 theInbox.
GetUserID(), theAccountID, theServerID,
1214 processLedger.AddTransaction(*pAcceptTransaction);
1224 int64_t lAdjustment = 0;
1288 pAcceptTransaction->
AddItem(*pAcceptItem);
1376 otWarn <<
"**** Due to finding a finalReceipt, "
1377 "REMOVING OPENING NUMBER FROM NYM: "
1380 otWarn <<
"**** Noticed a finalReceipt, but Opening "
1382 <<
" had ALREADY been removed from nym. \n";
1432 otErr <<
"OTClient::AcceptEntireInbox: final or basket "
1433 "receipt, trying to 'remove' an issued number ("
1435 <<
") that already wasn't on my issued list. (So "
1436 "what is this in my inbox, then? Maybe you need "
1437 "to download a fresh copy of it.)\n";
1445 *pAcceptTransaction,
1452 pAcceptTransaction->
AddItem(*pAcceptItem);
1480 std::unique_ptr<OTItem> pOriginalItem(
1482 strRespTo, theServerID,
1490 if (pOriginalItem) {
1493 pOriginalItem->GetStatus()))
1502 pAcceptTransaction->
AddItem(*pAcceptItem);
1518 pOriginalItem->GetNote(strNote);
1523 pOriginalItem->GetTransactionNum());
1542 (pOriginalItem->GetAmount());
1569 const int32_t nOriginalType = pOriginalItem->GetType();
1570 otErr <<
"Unrecognized item type (" << nOriginalType
1571 <<
") while processing inbox.\n(Only pending "
1572 "transfers, payment receipts, market "
1573 "receipts, cheque receipts, and transfer "
1574 "receipts are operational inbox items at this "
1579 otErr <<
"Error loading transaction item from string in "
1580 "OTClient::AcceptEntireInbox\n";
1592 std::unique_ptr<OTItem> pOriginalItem(
1594 strRespTo, theServerID,
1602 if (pOriginalItem) {
1610 pOriginalItem->GetType()) &&
1615 pOriginalItem->GetType()) &&
1622 pTransaction->
GetType()))))) {
1645 pOriginalItem->GetType())
1652 pOriginalItem->GetAttachment(strCheque);
1659 otErr <<
"OTClient::" << __FUNCTION__
1660 <<
": ERROR loading cheque or voucher "
1661 "from string:\n" << strCheque <<
"\n";
1673 otErr <<
"OTClient::" << __FUNCTION__
1674 <<
": cheque or voucher receipt, "
1675 "trying to 'remove' an issued "
1678 <<
") that already wasn't on my "
1679 "issued list. (So what is this in "
1680 "my inbox, then? Maybe need to "
1681 "download a fresh copy of it.)\n";
1689 *pAcceptTransaction,
1693 pAcceptTransaction->
AddItem(*pAcceptItem);
1704 ->GetTransactionNum());
1736 pOriginalItem->GetType())
1747 pOriginalItem->GetNumberOfOrigin()))
1748 otErr <<
"OTClient::" << __FUNCTION__
1749 <<
": transfer receipt, trying to "
1750 "'remove' an issued number ("
1751 << pOriginalItem->GetNumberOfOrigin()
1752 <<
") that already wasn't on my issued "
1753 "list. (So what is this in my inbox, "
1754 "then? Maybe need to download a fresh "
1759 pOriginalItem->GetNumberOfOrigin());
1763 *pAcceptTransaction,
1767 pAcceptTransaction->
AddItem(*pAcceptItem);
1776 pOriginalItem->GetTransactionNum());
1803 otErr <<
"OTClient::AcceptEntireInbox: Error: "
1804 "wrong pOriginalItem type.\n";
1808 const int32_t nOriginalType = pOriginalItem->GetType();
1809 otErr <<
"Unrecognized item type (" << nOriginalType
1810 <<
") while processing inbox.\n(Only pending "
1811 "transfers, payment receipts, market "
1812 "receipts, cheque receipts, and transfer "
1813 "receipts are operational inbox items at this "
1818 otErr <<
"Error loading transaction item from string in "
1819 "OTClient::AcceptEntireInbox\n";
1872 int64_t lTemp = theIssuedNym.
GetIssuedNum(theServerID, i);
1880 lAdjustment, *pAcceptTransaction, *pNym, *pAccount, *pOutbox);
1890 int64_t lTemp = theIssuedNym.
GetIssuedNum(theServerID, i);
1894 if (
nullptr != pBalanceItem)
1895 pAcceptTransaction->
AddItem(*pBalanceItem);
1901 otErr <<
"Should never happen.\n";
1908 processLedger.SignContract(*pNym);
1909 processLedger.SaveContract();
1931 otErr <<
"Error processing processInbox command in "
1932 "OTClient::AcceptEntireInbox\n";
1949 const int64_t& lTransNum,
1958 if (
nullptr == pTransType)
1959 otErr << __FUNCTION__ <<
": Error instantiating transaction type "
1960 "based on str_trans:\n" << str_trans
1968 const OTString strUserID(the_nym_id), strAcctID(the_nym_id);
1971 <<
": it's a transaction type but not a transaction: (for "
1972 << str_box_type <<
"):\n\n" << str_trans <<
"\n\n";
1974 pTransType =
nullptr;
1985 OTString strUserID(the_nym_id), strAcctID(the_nym_id);
1986 otOut << __FUNCTION__
1987 <<
": Unable to add the transaction to the "
1989 <<
" with user/acct IDs: " << strUserID <<
" / "
1990 << strAcctID <<
", and loading from string:\n\n"
1991 << str_trans <<
"\n\n";
2011 << __FUNCTION__ <<
": " << str_box_type
2012 <<
" Failed trying to SaveBoxReceipt. Contents:\n\n"
2013 << str_trans <<
"\n\n";
2067 strReceiptID(
"ID_NOT_SET_YET");
2079 OTLedger theLedger(USER_ID, ACCOUNT_ID, SERVER_ID);
2090 otErr <<
"ERROR loading ledger from message payload in "
2091 "OTClient::ProcessIncomingTransactions.\n";
2095 otLog3 <<
"Loaded ledger out of message payload.\n";
2101 OT_ASSERT_MSG(
nullptr != pTransaction,
"nullptr transaction pointer in "
2103 "UserCmdNotarizeTransactions\n");
2113 otInfo <<
"OTClient::ProcessIncomingTransactions: Skipping "
2114 "processing of server reply to transaction number "
2116 <<
" since the number isn't even issued to me. Usually this "
2117 "means that I ALREADY processed it, and we are now "
2118 "processing the nymbox notice for the same "
2144 switch (pTransaction->
GetType()) {
2153 if (
nullptr != pItemCash)
2155 else if (
nullptr != pItemVoucher)
2184 switch (pTransaction->
GetType()) {
2211 if ((
nullptr != pItem) &&
2223 std::unique_ptr<OTItem> pOriginalItem(
2224 (
nullptr == pTempTransType)
2226 : dynamic_cast<OTItem*>(pTempTransType));
2228 if (
nullptr != pOriginalItem) {
2232 pOriginalItem->GetAttachment(strBasket);
2234 if (strBasket.
Exists() &&
2238 *pNym, SERVER_ID,
true);
2240 otErr <<
"(atExchangeBasket) Error loading "
2241 "original basket request in "
2243 "ProcessIncomingTransactions\n";
2246 otErr <<
"(atExchangeBasket) Error loading "
2247 "original item from string in "
2248 "OTClient::ProcessIncomingTransactions\n";
2265 if ((
nullptr != pItem) &&
2285 std::unique_ptr<OTItem> pOriginalItem(
2286 (
nullptr == pTempTransType)
2288 : dynamic_cast<OTItem*>(pTempTransType));
2290 if (
nullptr != pOriginalItem) {
2294 pOriginalItem->GetReferenceToNum(),
2297 otErr <<
"(atCancelCronItem) Error removing "
2298 "issued number from user nym in "
2300 "ProcessIncomingTransactions\n";
2311 otErr << __FUNCTION__ <<
": (atCancelCronItem) "
2312 "Error loading original "
2313 "item from string.\n";
2337 if ((
nullptr != pItem) &&
2352 otErr << __FUNCTION__ <<
": Error removing issued "
2353 "number from user nym "
2354 "(for a transfer.)\n";
2370 const int64_t lNymOpeningNumber =
2373 if (
nullptr != pReplyItem) {
2383 std::unique_ptr<OTItem> pOriginalItem(
2384 (
nullptr == pTempTransType)
2386 : dynamic_cast<OTItem*>(pTempTransType));
2388 if (
nullptr != pOriginalItem) {
2390 pOriginalItem->GetAttachment(strCronItem);
2411 std::unique_ptr<OTCronItem> pCronItem(
2416 if (
nullptr != pCronItem)
2442 otErr << __FUNCTION__
2443 <<
": Error removing issued "
2444 "number from user nym (for a "
2466 pCronItem->HarvestClosingNumbers(
2501 pCronItem->SaveActiveCronReceipt(
2506 const int32_t nOutpaymentIndex =
2508 *pNym, lNymOpeningNumber);
2509 std::unique_ptr<OTMessage> theMessageAngel;
2511 if (nOutpaymentIndex >= 0) {
2516 if (
nullptr == pMsg) {
2517 otErr << __FUNCTION__
2518 <<
": Unable to find payment "
2519 "message in outpayment "
2520 "box based on index "
2521 << nOutpaymentIndex <<
".\n";
2524 const bool bRemovedOutpayment =
2530 theMessageAngel.reset(pMsg);
2531 if (bRemovedOutpayment)
2534 otErr << __FUNCTION__
2535 <<
": Failed trying to "
2536 "remove outpayment at "
2542 otErr << __FUNCTION__
2543 <<
": Unable to find "
2544 "payment instrument "
2601 strServerID.
Get(), strNymID.
Get());
2604 strServerID.
Get(), strNymID.
Get());
2611 bool bSuccessLoading1 =
2613 thePmntInbox.LoadPaymentInbox());
2614 bool bSuccessLoading2 =
2617 if (bExists1 && bSuccessLoading1)
2620 .VerifyContractID() &&
2621 thePmntInbox.VerifySignature(
2630 thePmntInbox.GenerateLedger(
2634 if (bExists2 && bSuccessLoading2)
2655 if (!bSuccessLoading1 ||
2656 !bSuccessLoading2) {
2659 <<
": while processing server "
2660 "reply containing rejection "
2661 "of cron item: WARNING: "
2662 "Unable to load, verify, or "
2663 "generate paymentInbox or "
2664 "recordBox, with IDs: "
2665 << strNymID <<
" / " << strNymID
2748 if (strInstrument.
Exists() &&
2756 const int32_t nTransCount =
2758 .GetTransactionCount();
2760 for (int32_t ii = (nTransCount - 1);
2766 std::unique_ptr<OTPayment>
2771 if (
nullptr == pPayment) {
2774 <<
": While looping "
2775 "payments inbox to "
2776 "remove a payment, "
2777 "unable to retrieve "
2780 <<
" (skipping.)\n";
2785 ->SetTempValues()) {
2788 <<
": While looping "
2789 "payments inbox to "
2790 "remove a payment, "
2791 "unable to set temp "
2792 "values for payment "
2794 <<
" (skipping.)\n";
2799 numlistIncomingPayment;
2802 ->GetAllTransactionNumbers(
2803 numlistIncomingPayment);
2806 numlistIncomingPayment)) {
2813 pTransPaymentInbox =
2815 .GetTransactionByIndex(
2819 pTransPaymentInbox);
2820 int64_t lPaymentTransNum =
2893 lPaymentTransNum)) {
2908 lPaymentTransNum)) {
2910 .ReleaseSignatures();
2918 .SavePaymentInbox()) {
2981 if (strInstrument.
Exists())
2995 std::unique_ptr<OTTransaction>
2996 theTransactionAngel(
3044 <<
" to record box "
3088 if (!pNewTransaction
3105 << strNewTransaction
3115 <<
": Failed while "
3116 "trying to generate "
3118 "order to add a new "
3120 "record box (for a "
3121 "payment instrument "
3124 "outpayments box): "
3125 << strNymID <<
"\n";
3138 otErr << __FUNCTION__
3139 <<
": Error loading cronitem from "
3140 "original item, from string:\n"
3141 << strOriginalItem <<
"\n";
3145 otErr << __FUNCTION__ <<
": Error loading original "
3146 "item from string:\n"
3147 << strOriginalItem <<
"\n\n";
3155 otErr << __FUNCTION__ <<
": wrong transaction type: "
3174 const OTString strServerID(SERVER_ID);
3179 if (
nullptr == pItem) {
3182 if (
nullptr != pItem)
3203 otErr << __FUNCTION__ <<
": Error saving transaction receipt "
3204 "(failed writing armored string):\n"
3207 << strReceiptFilename <<
"\n";
3210 if (
nullptr != pItem) {
3214 strReceiptFilename.
Format(
"%s.success", strReceiptID.
Get());
3216 strReceiptFilename.
Format(
"%s.fail", strReceiptID.
Get());
3220 strServerID.
Get(), strReceiptFilename.
Get());
3224 strReceiptFilename.
Format(
"%s.error", strReceiptID.
Get());
3226 otErr << __FUNCTION__
3227 <<
": Error saving transaction receipt, since pItem was "
3228 "nullptr: " << strReceiptFilename <<
"\n";
3232 strServerID.
Get(), strReceiptFilename.Get());
3247 <<
": Failed verifying server ownership of this transaction.\n";
3276 otOut <<
"TRANSACTION SUCCESS -- Server acknowledges dividend "
3280 otOut <<
"TRANSACTION FAILURE -- Server rejects dividend "
3313 <<
"TRANSACTION SUCCESS -- Server acknowledges deposit.\n";
3325 if ((
nullptr != pLedger) && pLedger->LoadPaymentInbox() &&
3326 pLedger->VerifyAccount(*pNym)) {
3336 OTItem* pOriginalItem =
nullptr;
3339 std::unique_ptr<OTTransactionType> pTransType(
3341 strOriginalDepositItem));
3343 if (
nullptr != pTransType) {
3345 dynamic_cast<OTItem*
>(pTransType.get());
3347 if (
nullptr != pOriginalItem) {
3352 bool bLoadContractFromString =
3355 if (!bLoadContractFromString) {
3356 otErr << __FUNCTION__
3357 <<
": ERROR loading cheque from string:\n"
3358 << strCheque <<
"\n";
3365 const int64_t lChequeTransNum =
3367 const int32_t nTransCount =
3368 pLedger->GetTransactionCount();
3370 for (int32_t ii = (nTransCount - 1); ii >= 0;
3375 std::unique_ptr<OTPayment> pPayment(
3378 int64_t lPaymentTransNum = 0;
3380 if ((
nullptr != pPayment) &&
3381 pPayment->SetTempValues() &&
3382 pPayment->GetTransactionNum(
3383 lPaymentTransNum) &&
3384 (lPaymentTransNum == lChequeTransNum)) {
3390 pLedger->GetTransactionByIndex(ii);
3392 int64_t lRemoveTransaction = 0;
3394 if (
nullptr != pTransaction) {
3396 strPmntInboxTransaction);
3397 lRemoveTransaction =
3402 pLedger->DeleteBoxReceipt(
3403 lRemoveTransaction)) {
3404 otErr << __FUNCTION__
3405 <<
": Failed trying to "
3407 "receipt for a cheque "
3408 "being removed from a "
3410 << lRemoveTransaction
3413 if (pLedger->RemoveTransaction(
3414 lRemoveTransaction)) {
3415 pLedger->ReleaseSignatures();
3416 pLedger->SignContract(*pNym);
3417 pLedger->SaveContract();
3420 ->SavePaymentInbox()) {
3421 otErr << __FUNCTION__
3422 <<
": Failure while "
3429 <<
": Removed cheque "
3431 "inbox. (Deposited "
3456 if (strPmntInboxTransaction.
Exists()) {
3467 bool bSuccessLoading =
3469 theRecordBox.LoadRecordBox());
3470 if (bExists && bSuccessLoading)
3473 .VerifyContractID() &&
3485 theRecordBox.GenerateLedger(
3494 if (!bSuccessLoading) {
3499 <<
": WARNING: Unable to "
3501 "generate recordBox, "
3502 "with IDs: " << strUserID
3503 <<
" / " << strAcctID
3533 strPmntInboxTransaction,
3535 lRemoveTransaction, *pNym,
3546 OTString strUserID(USER_ID), strAcctID(USER_ID);
3547 otWarn << __FUNCTION__ <<
": Unable to load or verify "
3548 "payments inbox: User "
3549 << strUserID <<
" / Acct " << strAcctID <<
"\n";
3554 otOut << __FUNCTION__
3555 <<
": TRANSACTION FAILURE -- Server rejects deposit.\n";
3607 otOut <<
"\nReceived voucher from server:\n\n" << strVoucher
3622 Purse thePurse(SERVER_ID);
3633 std::unique_ptr<Mint> pMint(
3645 Purse theWalletPurse(thePurse);
3661 bool bSuccess =
false;
3663 if ((
nullptr != pRequestPurse) && (
nullptr != pServerNym) &&
3664 pMint->LoadMint() && pMint->VerifyMint(*pServerNym)) {
3665 Token* pToken =
nullptr;
3666 while ((pToken = thePurse.
Pop(*pNym)) !=
nullptr) {
3669 Token* pOriginalToken = pRequestPurse->
Pop(*pNym);
3671 if (
nullptr == pOriginalToken) {
3672 otErr <<
"ERROR, processing withdrawal response, "
3673 "but couldn't find original token:"
3674 << strPurse <<
"\n";
3677 otWarn <<
"Retrieved signed token from purse, and "
3678 "have corresponding withdrawal request "
3679 "in wallet. Unblinding...\n\n";
3692 theWalletPurse.
Push(*pNym, *pToken);
3704 if (pOriginalToken) {
3705 delete pOriginalToken;
3706 pOriginalToken =
nullptr;
3715 if (
nullptr != pToken) {
3722 if (pOriginalToken) {
3723 delete pOriginalToken;
3724 pOriginalToken =
nullptr;
3740 otOut <<
"SUCCESSFULLY UNBLINDED token, and added the cash "
3741 "to the local purse, and saved.\n";
3783 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
3791 otErr << __FUNCTION__
3792 <<
": Error: Server reply signature failed to verify.\n";
3826 if (
nullptr == pSentMsg)
3830 <<
": FYI: no record of server reply in sent messages buffer. "
3831 "We must have already processed it, and then removed it, "
3832 "earlier. (Discarding.) Reply message:\n\n" << strReply
3858 bool bDirtyNym =
false;
3892 std::set<int64_t> numlist_ack_reply;
3896 for (
auto& it : numlist_ack_reply) {
3897 const int64_t lTempRequestNum = it;
3919 m_MessageBuffer.
Push(theReply);
3944 const std::string str_server(strServerID.Get());
3949 const bool bRecentHash =
3954 <<
": Failed getting NymboxHash (to store as 'recent "
3955 "hash') from Nym for server: " << str_server <<
"\n";
3986 const std::string str_server(strServerID.Get());
3991 const bool bRecentHash =
3996 <<
": Failed getting NymboxHash (to store as 'recent "
3997 "hash') from Nym for server: " << str_server <<
"\n";
4018 const bool bHasCredentials = (ascArmor.Exists() && ascArmor2.
Exists());
4019 if (bHasCredentials)
4025 ascArmor.GetString(strCredentialList);
4027 if (strCredentialList.
Exists()) {
4032 if (
nullptr == pMap)
4033 otOut << __FUNCTION__ <<
": Failed decoding StringMap "
4034 "object in @checkUser.\n";
4045 otErr << __FUNCTION__
4046 <<
": @checkUser: Failure loading nym "
4047 << strNymID2 <<
" from credential string.\n";
4059 otErr << __FUNCTION__ <<
": @checkUser: Loaded nym "
4060 << strNymID2 <<
" from credentials, but then it "
4061 "failed verifying.\n";
4068 std::string str_nym_id = strNymID2.Get();
4070 strFilename.
Format(
"%s.cred", str_nym_id.c_str());
4072 bool bStoredList =
false;
4074 if (ascArmor.Exists() &&
4075 ascArmor.WriteArmoredString(
4077 "CREDENTIAL LIST") &&
4084 otErr << __FUNCTION__
4085 <<
": Failed trying to armor or store "
4086 << strFilename <<
".\n";
4088 otOut <<
"@checkUser: Success saving public "
4089 "credential list for Nym: " << strNymID2
4091 for (
auto& it : theMap) {
4092 std::string str_cred_id = it.first;
4094 bool bStoredCredential =
false;
4097 if (ascLoopArmor.
Exists() &&
4107 if (!bStoredCredential)
4108 otErr << __FUNCTION__
4109 <<
": Failed trying to store "
4110 "credential " << str_cred_id
4111 <<
" for nym " << str_nym_id <<
".\n";
4114 <<
"@checkUser: Success saving public "
4115 "credential ID: " << str_cred_id
4125 else if (strPubkey.Exists()) {
4134 otOut <<
"@checkUser: (Deprecated.) Success saving public "
4135 "key file for Nym: " << strNymID2 <<
"\n";
4143 otOut <<
"Received server response to notarize Transactions message.\n";
4147 const std::string str_server(strServerID.Get());
4152 const bool bRecentHash =
4157 <<
": Failed getting NymboxHash (to store as 'recent "
4158 "hash') from Nym for server: " << str_server <<
"\n";
4182 otOut <<
"Received server response to Get Transaction Num message.\n";
4187 const std::string str_server(strServerID.Get());
4192 const bool bRecentHash =
4197 <<
": Failed getting NymboxHash (to store as 'recent "
4198 "hash') from Nym for server: " << str_server <<
"\n";
4210 otOut <<
"Received @getNymbox server response ("
4211 << (theReply.
m_bSuccess ?
"success" :
"failure") <<
")\n";
4221 OT_ASSERT_MSG(
nullptr == pNymbox,
"Nymbox pointer is expected to be "
4222 "nullptr here, since @getNymbox "
4223 "isn't dropped as a server "
4224 "replyNotice into the nymbox.");
4227 OTLedger theNymbox(USER_ID, USER_ID, SERVER_ID);
4230 const std::string str_server(strServerID.Get());
4236 const bool bNymboxHash =
4238 const bool bRecentHash =
4242 otErr <<
"Failed setting NymboxHash on Nym for server: "
4243 << str_server <<
"\n";
4246 <<
": Failed setting NymboxHash (to store as 'recent "
4247 "hash') from Nym for server: " << str_server <<
"\n";
4248 if (bNymboxHash || bRecentHash) {
4299 otErr <<
"OTClient::ProcessServerReply: Error loading or verifying "
4300 "nymbox during @getNymbox:\n\n" << strNymbox <<
"\n";
4308 otOut <<
"Received server response to getBoxReceipt request ("
4309 << (theReply.
m_bSuccess ?
"success" :
"failure") <<
")\n";
4316 OT_ASSERT_MSG(
nullptr == pNymbox,
"Nymbox pointer is expected to be "
4317 "nullptr here, since @getBoxReceipt "
4318 "isn't dropped as a server "
4319 "replyNotice into the nymbox.");
4324 bool bErrorCondition =
false;
4325 bool bSuccessLoading =
4336 otErr << __FUNCTION__
4337 <<
": @getBoxReceipt: Unknown box type: " << theReply.
m_lDepth
4339 bErrorCondition =
true;
4343 if (bSuccessLoading && !bErrorCondition)
4357 std::unique_ptr<OTTransactionType> pTransType;
4359 if (strTransType.
Exists())
4363 if (
nullptr == pTransType)
4364 otErr << __FUNCTION__
4365 <<
": @getBoxReceipt: Error instantiating transaction "
4366 "type based on decoded theReply.m_ascPayload:\n\n"
4367 << strTransType <<
"\n";
4372 if (
nullptr == pBoxReceipt)
4373 otErr << __FUNCTION__
4374 <<
": @getBoxReceipt: Error dynamic_cast from "
4375 "transaction type to transaction, based on "
4376 "decoded theReply.m_ascPayload:\n\n"
4377 << strTransType <<
"\n\n";
4379 otErr << __FUNCTION__
4380 <<
": @getBoxReceipt: Error: Box Receipt "
4384 : ((theReply.
m_lDepth == 1) ?
"inbox"
4386 <<
" fails VerifyAccount().\n";
4389 otErr << __FUNCTION__
4390 <<
": @getBoxReceipt: Error: Transaction Number "
4391 "doesn't match on the box receipt itself ("
4393 <<
"), versus the one listed in the reply message ("
4397 else if (pBoxReceipt->
GetUserID() != USER_ID) {
4399 otErr << __FUNCTION__
4400 <<
": @getBoxReceipt: Error: NymID doesn't match on "
4401 "the box receipt itself (" << strPurportedUserID
4402 <<
"), versus the one listed in the reply message ("
4427 if (!strServerID.Exists()) {
4428 otErr << __FUNCTION__
4429 <<
": strServerID doesn't Exist!\n";
4432 if (!strNymID.
Exists()) {
4433 otErr << __FUNCTION__
4434 <<
": strNymID dosn't Exist!\n";
4437 const bool bExists =
4439 strServerID.
Get(), strNymID.
Get());
4440 OTLedger thePmntInbox(USER_ID, USER_ID,
4442 bool bSuccessLoading =
4443 (bExists && thePmntInbox.LoadPaymentInbox());
4444 if (bExists && bSuccessLoading)
4446 (thePmntInbox.VerifyContractID() &&
4447 thePmntInbox.VerifySignature(*pNym));
4452 bSuccessLoading = thePmntInbox.GenerateLedger(
4458 if (!bSuccessLoading) {
4459 OTString strUserID(USER_ID), strAcctID(USER_ID);
4460 otOut << __FUNCTION__
4461 <<
": @getBoxReceipt: WARNING: Unable to "
4462 "load, verify, or generate paymentInbox, "
4463 "with IDs: " << strUserID <<
" / "
4464 << strAcctID <<
"\n";
4516 const int64_t lTransNum =
4525 USER_ID, strTransType,
"paymentInbox",
4526 lTransNum, *pNym, thePmntInbox);
4559 otErr << __FUNCTION__
4560 <<
": @getBoxReceipt(): Failed trying to "
4561 "SaveBoxReceipt. Contents:\n\n" << strTransType
4570 otErr << __FUNCTION__
4571 <<
": SHOULD NEVER HAPPEN: @getBoxReceipt: failure loading "
4572 "box, or verifying it. UserID: " << theReply.
m_strNymID
4588 OTString strServerID(SERVER_ID), strReply(theReply);
4594 const std::string str_server(strServerID.Get());
4599 const bool bRecentHash =
4604 <<
": Failed getting NymboxHash (to store as 'recent "
4605 "hash') from Nym for server: " << str_server <<
"\n";
4624 if (strOriginalMessage.
Exists() &&
4627 OTString strLedger, strReplyLedger;
4630 ACCOUNT_ID = USER_ID;
4632 OTLedger theLedger(USER_ID, ACCOUNT_ID, SERVER_ID),
4633 theReplyLedger(USER_ID, ACCOUNT_ID, SERVER_ID);
4638 if (!strLedger.
Exists()) {
4639 OTString strLogData(theOriginalMessage);
4640 otErr <<
"Strange: Received server acknowledgment ("
4642 <<
"), but found no request ledger within your original "
4643 "message:\n\n" << strLogData <<
"\n\n";
4645 else if (!strReplyLedger.
Exists()) {
4647 otOut <<
"Strange... received server acknowledgment ("
4649 <<
"), but found no reply ledger within:\n\n" << strReply
4652 else if (!theLedger.LoadLedgerFromString(strLedger)) {
4653 otErr <<
"Strange: Received server acknowledgment ("
4655 <<
"), but unable to load original request ledger from "
4656 "string:\n\n" << strLedger <<
"\n\n";
4658 else if (!theLedger.VerifySignature(*pNym)) {
4659 otErr <<
"Strange: Received server acknowledgment ("
4661 <<
"), but unable to verify your signature on the "
4662 "original request ledger:\n\n" << strLedger <<
"\n\n";
4666 <<
"Strange: Received server acknowledgment ("
4668 <<
"), but unable to load the reply ledger from string:\n\n"
4669 << strReplyLedger <<
"\n\n";
4672 otErr <<
"Strange: Received server acknowledgment ("
4674 <<
"), but unable to verify server's signature on the "
4675 "reply ledger within:\n\n" << strReplyLedger <<
"\n\n";
4717 if (
nullptr != pTransaction) {
4743 if (bIsSignedOut && (
nullptr != pReplyTransaction)) {
4745 OTLedger theInbox(USER_ID, ACCOUNT_ID, SERVER_ID);
4746 OTLedger theRecordBox(USER_ID, ACCOUNT_ID,
4763 "Was trying to load / verify Inbox.");
4764 bool bLoadedRecordBox =
false;
4777 for (
auto& it_bigloop :
4779 OTItem* pReplyItem = it_bigloop;
4781 "OTClient::ProcessServerReply: "
4782 "Pointer should not have been "
4792 switch (pReplyItem->
GetType()) {
4863 const int32_t nReplyItemType =
4869 otErr <<
"*** Unexpected reply item type ("
4871 <<
") in @processInbox, while "
4872 "processing server reply: "
4873 << strTheType <<
" \n";
4887 otWarn <<
"@processInbox reply item "
4888 << strTempTypeString
4889 <<
": status == FAILED\n";
4893 otWarn <<
"@processInbox reply item "
4894 << strTempTypeString
4895 <<
": status == SUCCESS\n";
4946 strProcessInboxItem);
4948 std::unique_ptr<OTItem> pProcessInboxItem(
4950 strProcessInboxItem, SERVER_ID,
4964 (pProcessInboxItem !=
nullptr)
4967 ->GetReferenceToNum())
4970 if (
nullptr == pItem) {
4971 otErr <<
"Unable to find original item in "
4972 "original processInbox "
4973 "transaction request, based on "
4997 otErr <<
"Wrong original item TYPE, on "
4998 "reply item's copy of original "
4999 "item, than what was expected "
5000 "based on reply item's type.\n";
5014 otWarn <<
"Checking client-side inbox for "
5015 "expected pending or receipt "
5020 switch (pReplyItem->
GetType()) {
5032 pServerTransaction =
5039 pServerTransaction =
5045 const int32_t nReplyItemType =
5051 otErr <<
"*** Unexpected reply item type ("
5053 <<
") in @processInbox, while "
5054 "processing server reply: "
5055 << strTheType <<
"\n";
5062 if (
nullptr == pServerTransaction) {
5063 otErr <<
"Unable to find the server's "
5064 "receipt, in my inbox, that my "
5065 "original processInbox's item was "
5072 bool bAddToRecordBox =
true;
5074 switch (pReplyItem->
GetType())
5113 std::unique_ptr<OTItem> pOriginalItem(
5115 strOriginalItem, SERVER_ID,
5117 ->GetReferenceToNum()));
5119 if (
nullptr != pOriginalItem) {
5165 pOriginalItem->GetAttachment(
5174 .LoadContractFromString(
5176 otErr <<
"ERROR loading cheque "
5179 "ProcessServerReply:\n"
5180 << strCheque <<
"\n";
5194 .GetTransactionNum(),
5206 int32_t lOutpaymentsIndex =
5210 .GetTransactionNum());
5212 if (lOutpaymentsIndex >
5226 lOutpaymentsIndex)) {
5257 pOriginalItem->GetType()) {
5261 ->GetNumberOfOrigin(),
5266 pOriginalItem->GetTypeString(
5267 strOriginalItemType);
5268 otErr <<
"OTClient::"
5269 "ProcessServerReply: "
5270 "Original item has wrong "
5271 "type, while accepting "
5273 << strOriginalItemType
5278 otErr <<
"OTClient::ProcessServerReply:"
5279 " Unable to load original "
5280 "item from string while "
5281 "accepting item receipt:\n"
5282 << strOriginalItem <<
"\n";
5315 if (
nullptr != pServerItem) {
5327 bool bLoadOfferFromString =
5330 bool bLoadTradeFromString =
5333 if (bLoadOfferFromString &&
5334 bLoadTradeFromString) {
5335 std::unique_ptr<OTDB::TradeDataNym>
5364 pData->completed_count =
5368 std::unique_ptr<OTAccount> pAccount(
5370 ACCOUNT_ID, SERVER_ID));
5374 pAccount->GetAssetTypeID());
5377 pAccount->GetAssetTypeID());
5386 int64_t lAssetsThisTrade =
5400 else if (bIsCurrency) {
5407 int64_t lCurrencyThisTrade =
5409 pData->currency_id =
5410 strCurrencyID.Get();
5411 pData->currency_paid =
5413 lCurrencyThisTrade);
5417 pData->date = to_string<time64_t>(
5422 const int64_t& lPriceLimit =
5424 pData->offer_price =
5425 to_string<int64_t>(lPriceLimit);
5426 const int64_t& lFinishedSoFar =
5428 pData->finished_so_far =
5435 std::unique_ptr<OTDB::TradeListNym>
5444 pList.reset(
dynamic_cast<
5454 if (
nullptr == pList) {
5456 <<
"Creating storage list "
5457 "of trade receipts for "
5458 "Nym: " << strUserID
5460 pList.reset(
dynamic_cast<
5464 STORED_OBJ_TRADE_LIST_NYM)));
5477 bool bWeFoundIt =
false;
5479 size_t nTradeDataNymCount =
5480 pList->GetTradeDataNymCount();
5482 for (
size_t nym_count = 0;
5483 nym_count < nTradeDataNymCount;
5486 pList->GetTradeDataNym(
5543 const int64_t lAmountSold =
5547 const int64_t lCurrencyPaid =
5583 pList->AddTradeDataNym(*pData);
5596 <<
": Failed storing list "
5597 "of trades for Nym. "
5600 <<
" Nym ID: " << strUserID
5615 <<
"OTClient::ProcessServerReply: "
5616 "Successfully removed finalReceipt "
5617 "with closing num: "
5635 otWarn <<
"**** Due to finding a "
5636 "finalReceipt, REMOVING "
5637 "OPENING NUMBER FROM NYM: "
5638 << pServerTransaction
5643 <<
"**** Noticed a finalReceipt, "
5644 "but Opening Number "
5645 << pServerTransaction
5647 <<
" had ALREADY been removed from "
5673 <<
"OTClient::ProcessServerReply: "
5674 "Successfully removed basketReceipt "
5675 "with closing num: "
5687 bAddToRecordBox =
false;
5690 otErr <<
"OTClient::ProcessServerReply: "
5691 "wrong reply item transaction "
5692 "type: " << strTempTypeString
5696 if (bAddToRecordBox) {
5697 if (!bLoadedRecordBox)
5701 (bRecordBoxExists &&
5703 if (bRecordBoxExists &&
5715 else if (!bLoadedRecordBox)
5718 ACCOUNT_ID, SERVER_ID,
5725 if (!bLoadedRecordBox) {
5728 <<
": while processing server "
5729 "reply to processInbox: "
5730 "WARNING: Unable to load, "
5731 "verify, or generate "
5732 "recordBox, with IDs: "
5733 << strNymID <<
" / "
5737 if (bLoadedRecordBox) {
5738 const OTString strServerTransaction(
5739 *pServerTransaction);
5742 std::unique_ptr<OTTransactionType>
5746 strServerTransaction));
5751 if (
nullptr != pNewTransaction) {
5759 <<
": Unable to add "
5763 <<
" to record box (still "
5764 "removing it from asset "
5777 pTransType.release();
5804 if (!pNewTransaction
5814 << strServerTransaction
5898 if ((
nullptr != pTransaction) &&
5899 (
nullptr != pReplyTransaction)) {
5906 if (
nullptr == pStatementItem) {
5908 <<
"Strange... found transaction in ledger in "
5910 <<
", but didn't find a transactionStatement "
5914 otOut <<
"Found the receipt you're talking about, "
5916 <<
", but the Server's Reply transaction "
5925 if (strMessageNym.
Exists() &&
5953 *pNym, theMessageNym,
true);
5961 otOut <<
"Strange... found transaction item in "
5963 <<
", but didn't find theMessageNym "
5973 OTLedger theNymbox(USER_ID, USER_ID, SERVER_ID);
5974 bool bLoadedNymbox =
false;
5979 bLoadedNymbox =
true;
5984 pNymbox = &theNymbox;
5996 "Was trying to load Nymbox.");
6005 for (
auto& it : pReplyTransaction->
GetItemList()) {
6008 "OTClient::ProcessServerReply: "
6009 "Pointer should not have been "
6014 switch (pReplyItem->
GetType()) {
6067 otErr << __FUNCTION__
6068 <<
": Unexpected replyItem:type while "
6069 "processing Nymbox: "
6070 << strTempTypeString <<
" \n";
6083 otWarn <<
"@processNymbox reply item "
6084 << strTempTypeString
6085 <<
": status == FAILED\n";
6089 otWarn <<
"@processNymbox reply item "
6090 << strTempTypeString
6091 <<
": status == SUCCESS\n";
6125 strProcessNymboxItem);
6127 std::unique_ptr<OTItem> pProcessNymboxItem(
6129 strProcessNymboxItem, SERVER_ID,
6141 OTItem* pItem = (pProcessNymboxItem !=
nullptr)
6144 ->GetReferenceToNum())
6147 if (
nullptr == pItem) {
6148 otErr << __FUNCTION__
6149 <<
": Unable to find original item in "
6150 "original processNymbox transaction "
6151 "request, based on reply item.\n";
6171 otErr << __FUNCTION__
6172 <<
": Wrong original item TYPE, on reply "
6173 "item's copy of original item, than "
6174 "what was expected based on reply "
6190 <<
": Checking client-side Nymbox for "
6191 "expected Nymbox item: "
6195 switch (pReplyItem->
GetType()) {
6207 otErr << __FUNCTION__
6208 <<
": Unexpected replyItem::type while "
6209 "processing Nymbox: "
6210 << strTempTypeString <<
" \n";
6214 if (
nullptr == pServerTransaction) {
6216 <<
": The original processNymbox item "
6217 "referred to trans number "
6219 <<
", but that receipt wasn't in my "
6220 "Nymbox. (We probably processed this "
6221 "server reply ALREADY, and now we're "
6222 "just seeing it again, since an "
6223 "extra copy was dropped into the "
6224 "Nymbox originally. It happens. "
6268 pServerTransaction->
GetType()) {
6407 std::unique_ptr<OTCronItem> pCronItem(
6420 const int64_t lNymOpeningNumber =
6421 pCronItem->GetOpeningNumber(
6423 const bool bCancelling =
6424 (pCronItem->IsCanceled() &&
6425 pCronItem->GetCancelerID(
6427 const bool bIsCancelerNym =
6431 const bool bIsActivatingNym =
6432 (pCronItem->GetOpeningNum() ==
6564 ->HarvestClosingNumbers(
6575 ->SaveActiveCronReceipt(
6599 const int32_t nOutpaymentIndex =
6603 std::unique_ptr<OTMessage>
6606 if (nOutpaymentIndex >= 0) {
6611 if (
nullptr == pMsg) {
6623 const bool bRemovedOutpayment =
6630 theMessageAngel.reset(
6656 if (bRemovedOutpayment)
6753 const bool bExists1 =
6760 const bool bExists2 =
6775 bool bSuccessLoading1 =
6778 .LoadPaymentInbox());
6779 bool bSuccessLoading2 =
6787 .VerifyContractID() &&
6835 if (!bSuccessLoading1 ||
6836 !bSuccessLoading2) {
6851 << strNymID <<
" / "
6852 << strNymID <<
"\n";
6984 const int32_t nTransCount =
6986 .GetTransactionCount();
7039 ->SetTempValues()) {
7073 numlistIncomingPayment;
7075 pPayment->GetAllTransactionNumbers(
7076 numlistIncomingPayment);
7078 if (numlistOutpayment
7080 numlistIncomingPayment))
7092 pTransPaymentInbox =
7094 .GetTransactionByIndex(
7098 pTransPaymentInbox);
7099 int64_t lPaymentTransNum =
7226 lPaymentTransNum)) {
7267 lPaymentTransNum)) {
7269 .ReleaseSignatures();
7277 .SavePaymentInbox()) {
7280 <<
": Failure while trying to save payment inbox.\n";
7285 <<
": Removed instrument from payment inbox.\nSaved payment inbox.\n";
7388 theTransactionAngel(
7503 if (!pNewTransaction
7535 << strNewTransaction
7591 otErr << __FUNCTION__
7592 <<
": Error loading cronitem "
7593 "from Nymbox receipt, "
7595 << strCronItem <<
"\n";
7612 <<
": Successfully removed finalReceipt "
7613 "from Nymbox with opening num: "
7621 otWarn <<
"**** Due to finding a "
7622 "finalReceipt, REMOVING OPENING "
7624 << pServerTransaction
7628 otWarn <<
"**** Noticed a finalReceipt, "
7629 "but Opening Number "
7630 << pServerTransaction
7632 <<
" had ALREADY been removed from "
7683 otErr <<
"Unexpected replyItem:type while "
7684 "processing Nymbox: "
7685 << strTempTypeString <<
" \n";
7722 if ((
nullptr != pTransaction) &&
7723 (
nullptr != pReplyTransaction)) {
7729 OTString strReceiptID(
"NOT_SET_YET");
7734 if (
nullptr == pReplyItem) {
7735 pReplyItem = pReplyTransaction->
GetItem(
7738 if (
nullptr != pReplyItem)
7755 strReceiptFilename.
Format(
"%s.success",
7756 strReceiptID.
Get());
7758 strReceiptFilename.
Format(
"%s.fail",
7759 strReceiptID.
Get());
7765 strFinal,
"TRANSACTION"))
7767 otErr <<
"OTClient::ProcessServerReply: Error saving "
7768 "transaction receipt (failed writing armored "
7772 <<
"\n Contents:\n" << strTransaction <<
"\n";
7776 if (
nullptr != pReplyItem) {
7779 strServerID.
Get(), strReceiptFilename.
Get());
7783 strReceiptFilename.
Format(
"%s.error",
7784 strReceiptID.
Get());
7786 otErr <<
"OTClient::ProcessServerReply: Error "
7787 "saving transaction receipt: "
7789 << strReceiptFilename <<
"\n";
7793 strServerID.
Get(), strReceiptFilename.Get());
7798 const OTString strTheLedger(theLedger),
7799 strTheReplyLedger(theReplyLedger);
7800 otOut <<
"Strange... found ledger in "
7802 <<
", but didn't find the right transaction type "
7803 "within.\n(pTransaction == "
7804 << ((
nullptr != pTransaction) ?
"NOT nullptr"
7806 <<
") && (pReplyTransaction == "
7807 << ((
nullptr != pReplyTransaction) ?
"NOT nullptr"
7809 <<
")\ntheLedger: \n\n" << strTheLedger
7810 <<
"\n\ntheReplyLedger:\n\n" << strTheReplyLedger
7816 otOut <<
"Strange... received server acknowledgment but 'in "
7817 "reference to' message was blank.\n";
7829 otOut <<
"Received server response to getAccountFiles message.\n";
7834 const bool bHasFiles = ascArmor.
Exists();
7840 if (
nullptr == pMap)
7841 otOut << __FUNCTION__ <<
": Failed decoding StringMap object "
7842 "in @getAccountFiles.\n";
7845 OTString strAccount, strInbox, strOutbox;
7846 auto it_account = theMap.find(
"account");
7847 auto it_inbox = theMap.find(
"inbox");
7848 auto it_outbox = theMap.find(
"outbox");
7849 if ((theMap.end() != it_account) &&
7850 (it_account->second.size() > 0))
7851 strAccount = it_account->second.c_str();
7852 if ((theMap.end() != it_inbox) && (it_inbox->second.size() > 0))
7853 strInbox = it_inbox->second.c_str();
7854 if ((theMap.end() != it_outbox) &&
7855 (it_outbox->second.size() > 0))
7856 strOutbox = it_outbox->second.c_str();
7857 if (strAccount.
Exists()) {
7859 std::unique_ptr<OTAccount> pAccount(
7860 new OTAccount(USER_ID, ACCOUNT_ID, SERVER_ID));
7863 pAccount->LoadContractFromString(strAccount) &&
7864 pAccount->VerifyAccount(*pServerNym)) {
7865 otInfo <<
"Saving updated account file to disk...\n";
7866 pAccount->ReleaseSignatures();
7876 pAccount->SignContract(*pNym);
7877 pAccount->SaveContract();
7878 pAccount->SaveAccount();
7884 if (
nullptr != pWallet) {
7891 const OTString strAcctID(ACCOUNT_ID);
7892 const std::string str_acct_id(strAcctID.
Get());
7895 const OTString strServerID(SERVER_ID);
7898 OTLedger theInbox(USER_ID, ACCOUNT_ID, SERVER_ID);
7927 otErr << __FUNCTION__
7928 <<
": Failed setting InboxHash on Nym "
7929 "for account: " << str_acct_id <<
"\n";
7962 otInfo <<
"*** Removing opening issued number ("
7964 <<
"), since finalReceipt found when "
7965 "retrieving asset account inbox. "
7972 otWarn <<
"**** Due to finding a "
7973 "finalReceipt, REMOVING OPENING "
7978 otWarn <<
"**** Noticed a finalReceipt, "
7979 "but Opening Number "
7981 <<
" had ALREADY been removed from "
8020 otErr << __FUNCTION__
8021 <<
": Error loading (from string) or verifying "
8022 "inbox:\n\n" << strInbox <<
"\n";
8025 if (strOutbox.
Exists()) {
8027 OTLedger theOutbox(USER_ID, ACCOUNT_ID, SERVER_ID);
8054 otErr << __FUNCTION__
8055 <<
": Failed setting OutboxHash on Nym "
8056 "for account: " << str_acct_id <<
"\n";
8075 otErr << __FUNCTION__
8076 <<
": Error loading (from string) or verifying "
8077 "outbox:\n\n" << strOutbox <<
"\n";
8093 std::unique_ptr<OTAccount> pAccount(
8094 new OTAccount(USER_ID, ACCOUNT_ID, SERVER_ID));
8096 if (pAccount && pAccount->LoadContractFromString(strAccount) &&
8097 pAccount->VerifyAccount(*pServerNym)) {
8098 otInfo <<
"Saving updated account file to disk...\n";
8099 pAccount->ReleaseSignatures();
8107 pAccount->SignContract(*pNym);
8108 pAccount->SaveContract();
8109 pAccount->SaveAccount();
8115 if (
nullptr != pWallet) {
8126 const OTString strServerID(SERVER_ID);
8128 otWarn <<
"Received server response to Get Inbox message.\n";
8134 OTLedger theInbox(USER_ID, ACCOUNT_ID, SERVER_ID);
8155 const OTString strAcctID(ACCOUNT_ID);
8156 const std::string str_acct_id(strAcctID.
Get());
8161 const bool bHash = pNym->
SetInboxHash(str_acct_id, THE_HASH);
8164 otErr <<
"Failed setting InboxHash on Nym for account: "
8165 << str_acct_id <<
"\n";
8197 otInfo <<
"*** Removing opening issued number ("
8199 <<
"), since finalReceipt found when getting asset "
8200 "account inbox. ***\n";
8205 otWarn <<
"**** Due to finding a finalReceipt, "
8206 "REMOVING OPENING NUMBER FROM NYM: "
8209 otWarn <<
"**** Noticed a finalReceipt, but Opening "
8211 <<
" had ALREADY been removed from nym. \n";
8257 otErr <<
"Error loading (from string) or verifying inbox:\n\n"
8258 << strInbox <<
"\n";
8268 otWarn <<
"Received server response to Get Outbox message.\n";
8279 OTLedger theOutbox(USER_ID, ACCOUNT_ID, SERVER_ID);
8297 const OTString strAcctID(ACCOUNT_ID);
8298 const std::string str_acct_id(strAcctID.
Get());
8303 const bool bHash = pNym->
SetOutboxHash(str_acct_id, THE_HASH);
8306 otErr <<
"Failed setting OutboxHash on Nym for account: "
8307 << str_acct_id <<
"\n";
8322 otErr <<
"Error loading (from string) or verifying outbox:\n\n"
8323 << strOutbox <<
"\n";
8357 if (
nullptr != pWallet) {
8367 pContract =
nullptr;
8376 std::unique_ptr<Mint> pMint(
8380 if (pMint->LoadContractFromString(strMint)) {
8381 otOut <<
"Saving mint file to disk...\n";
8389 strMarketDatafile.
Format(
"%s",
"market_data.bin");
8408 otErr <<
"Error erasing market list from market folder: "
8409 << strMarketDatafile <<
" \n";
8418 otErr <<
"ProcessServerReply: unable to decode ascii-armored "
8419 "payload in @getMarketList reply.\n";
8430 std::unique_ptr<OTDB::PackedBuffer> pBuffer(pPacker->
CreateBuffer());
8437 std::unique_ptr<OTDB::MarketList> pMarketList(
8438 dynamic_cast<OTDB::MarketList*>(
8441 bool bUnpacked = pPacker->
Unpack(*pBuffer, *pMarketList);
8444 otErr <<
"Process Server Reply: Failed unpacking data for "
8445 "@getMarketList.\n";
8452 strMarketDatafile.
Get());
8454 otErr <<
"Error storing market list to market folder: "
8455 << strMarketDatafile <<
" \n";
8465 strOfferDatafile.
Format(
"%s.bin", strMarketID.
Get());
8487 otErr <<
"Error erasing offers list from market folder: "
8488 << strOfferDatafile <<
" \n";
8497 otErr <<
"ProcessServerReply: unable to decode ascii-armored "
8498 "payload in @getMarketOffers reply.\n";
8509 std::unique_ptr<OTDB::PackedBuffer> pBuffer(pPacker->
CreateBuffer());
8516 std::unique_ptr<OTDB::OfferListMarket> pOfferList(
8517 dynamic_cast<OTDB::OfferListMarket*>(
8520 bool bUnpacked = pPacker->
Unpack(*pBuffer, *pOfferList);
8523 otErr <<
"Failed unpacking data for process server reply, "
8524 "@getMarketOffers.\n";
8536 otErr <<
"Error storing " << strOfferDatafile
8537 <<
" to market folder.\n";
8547 strTradeDatafile.
Format(
"%s.bin", strMarketID.
Get());
8569 otErr <<
"Error erasing recent trades list from market folder: "
8570 << strTradeDatafile <<
" \n";
8579 otErr <<
"ProcessServerReply: unable to decode ascii-armored "
8580 "payload in @getMarketRecentTrades reply.\n";
8591 std::unique_ptr<OTDB::PackedBuffer> pBuffer(pPacker->
CreateBuffer());
8598 std::unique_ptr<OTDB::TradeListMarket> pTradeList(
8599 dynamic_cast<OTDB::TradeListMarket*>(
8602 bool bUnpacked = pPacker->
Unpack(*pBuffer, *pTradeList);
8605 otErr <<
"Failed unpacking data for process server reply, "
8606 "@getMarketRecentTrades.\n";
8618 otErr <<
"Error storing " << strTradeDatafile
8619 <<
" to market folder.\n";
8644 strOfferDatafile.
Get());
8646 otErr <<
"Error erasing offers list from nyms folder: "
8647 << strOfferDatafile <<
" \n";
8656 otErr <<
"ProcessServerReply: unable to decode ascii-armored "
8657 "payload in @getNym_MarketOffers reply.\n";
8668 std::unique_ptr<OTDB::PackedBuffer> pBuffer(pPacker->
CreateBuffer());
8675 std::unique_ptr<OTDB::OfferListNym> pOfferList(
8676 dynamic_cast<OTDB::OfferListNym*>(
8679 bool bUnpacked = pPacker->
Unpack(*pBuffer, *pOfferList);
8682 otErr <<
"Failed unpacking data for process server reply, "
8683 "@getNym_MarketOffers.\n";
8692 strOfferDatafile.
Get());
8694 otErr <<
"Error storing " << strOfferDatafile
8695 <<
" to nyms folder.\n";
8707 const OTString strServerID(SERVER_ID);
8709 if (strOriginalMessage.
Exists() &&
8733 otOut <<
"Successfully DELETED Nym from Server: removed request "
8734 "number, plus all issued and transaction numbers for Nym "
8735 << theReply.
m_strNymID <<
" for Server " << strServerID
8739 otErr <<
"The server just for some reason tried to trick me into "
8740 "erasing my issued and transaction numbers for Nym "
8741 << theReply.
m_strNymID <<
", Server " << strServerID <<
".\n";
8753 const OTString strServerID(SERVER_ID);
8755 if (strOriginalMessage.
Exists() &&
8767 if (
nullptr != pDeletedAcct) {
8784 <<
" from Server: " << strServerID <<
".\n";
8787 otErr <<
"The server just for some reason tried to trick me into "
8789 <<
" on Server " << strServerID <<
".\n";
8803 pAccount =
new OTAccount(USER_ID, ACCOUNT_ID, SERVER_ID);
8843 pAccount =
new OTAccount(USER_ID, ACCOUNT_ID, SERVER_ID);
8917 OTString strNymID, strContractID, strServerID, strNymPublicKey,
8919 int64_t lRequestNumber = 0;
8926 if (
nullptr != pAccount) {
8930 otErr <<
"OTClient::ProcessUserCommand: "
8931 "pAccount->GetPurportedServerID() doesn't match "
8932 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
8938 bool bSendCommand =
false;
8939 int64_t lReturnValue = 0;
8942 switch (requestedCommand) {
8945 OTString strAuthentKey, strEncryptionKey;
8980 bSendCommand =
true;
8991 if (
nullptr == pMap)
8992 otErr << __FUNCTION__ <<
": Error: failed trying to load or create "
8993 "a STORED_OBJ_STRING_MAP.\n";
9006 const bool bAddedMaster =
9009 if (bAddedMaster && strMasterCredID.
Exists() &&
9011 otOut << __FUNCTION__
9012 <<
": Adding new keyCredential to master credential: "
9013 << strMasterCredID <<
"\n";
9017 const bool bAddedSubkey =
9025 otErr << __FUNCTION__ <<
": Failed trying to add new "
9026 "keyCredential to new Master "
9030 otErr << __FUNCTION__ <<
": Failed trying to add new "
9031 "master credential (for Nym who "
9032 "doesn't have one yet.)\n";
9037 if (strCredList.
Exists() && (!theMap.empty())) {
9039 const bool bSuccessEncoding = (str_Encoded.size() > 0);
9040 if (bSuccessEncoding) {
9044 str_Encoded.c_str());
9052 otErr << __FUNCTION__ <<
": Failed trying to assemble a "
9053 "createUserAccount message: This Nym has "
9054 "no credentials to use for registration. "
9055 "Convert this Nym first to the new "
9056 "credential system, then try again.\n";
9087 bSendCommand =
true;
9110 bSendCommand =
true;
9147 "%lld", lRequestNumber);
9170 bSendCommand =
true;
9171 lReturnValue = lRequestNumber;
9175 otOut <<
"Please enter a NymID (for recipient): ";
9182 otOut <<
"Enter recipient's public key:\n> ";
9185 char decode_buffer[200];
9188 decode_buffer[0] = 0;
9190 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin)) {
9191 theArmoredText.
Concatenate(
"%s\n", decode_buffer);
9198 }
while (strlen(decode_buffer) > 1);
9200 decode_buffer[0] =
'\0';
9203 otOut <<
"Please enter a plaintext message, terminate with ~ on a new "
9207 if (!fgets(decode_buffer,
sizeof(decode_buffer), stdin) &&
9208 decode_buffer[0] !=
'~') {
9212 }
while (decode_buffer[0] !=
'~');
9217 "%lld", lRequestNumber);
9235 if (theArmoredText.
Exists() && !pPubkey->SetPublicKey(theArmoredText)) {
9236 otOut <<
"Failed setting public key.\n";
9238 else if (strPlaintext.
Exists() &&
9239 theEnvelope.
Seal(*pPubkey, strPlaintext) &&
9249 bSendCommand =
true;
9250 lReturnValue = lRequestNumber;
9281 otOut <<
"Failed sealing envelope.\n";
9286 otOut <<
"Please enter a NymID: ";
9296 "%lld", lRequestNumber);
9317 bSendCommand =
true;
9318 lReturnValue = lRequestNumber;
9329 otOut <<
"Please enter currency contract, terminate with ~ on a new "
9331 char decode_buffer[200];
9334 if (!fgets(decode_buffer,
sizeof(decode_buffer), stdin) &&
9335 decode_buffer[0] !=
'~') {
9336 strSourceContract.
Concatenate(
"%s", decode_buffer);
9339 }
while (decode_buffer[0] !=
'~');
9382 "%lld", lRequestNumber);
9400 OTString strAssetContract(theAssetContract);
9410 bSendCommand =
true;
9411 lReturnValue = lRequestNumber;
9435 if (pContract->LoadContractFromString(strSourceContract) &&
9436 pContract->VerifyContract()) {
9440 if (
nullptr != (pWallet = m_pWallet)) {
9452 pContract =
nullptr;
9466 OTString strBasketInfo, strNymID(USER_ID);
9467 OTString str_BASKET_CONTRACT_ID, str_MAIN_ACCOUNT_ID, strTemp;
9470 otOut <<
"Enter the basket's Asset Type ID (aka Contract ID): ";
9471 str_BASKET_CONTRACT_ID.
OTfgets(std::cin);
9474 otOut <<
"Enter an ACCOUNT ID of yours for an account that has the "
9475 "same asset type: ";
9476 str_MAIN_ACCOUNT_ID.
OTfgets(std::cin);
9481 otOut <<
"Are you exchanging in or out? [in]: ";
9482 strDirection.
OTfgets(std::cin);
9484 const bool bDirection =
9489 OTString strContractPath(str_BASKET_CONTRACT_ID.
Get());
9490 std::unique_ptr<OTAssetContract> pContract(
9492 strContractPath, str_BASKET_CONTRACT_ID));
9495 if (pContract->LoadContract() && pContract->VerifyContract()) {
9502 if (pContract->GetBasketInfo().GetLength() &&
9511 (2 + theBasket.
Count())) {
9512 otOut << __FUNCTION__ <<
": Trying to exchange basket: you "
9513 "don't have enough transaction "
9514 "numbers to perform the "
9518 int64_t lStoredTransactionNumber = 0;
9520 theNym, strServerID,
9521 lStoredTransactionNumber);
9527 USER_ID, MAIN_ACCOUNT_ID, SERVER_ID,
9529 lStoredTransactionNumber);
9538 pTransaction->
AddItem(*pItem);
9551 std::unique_ptr<OTLedger> pInbox(
9553 std::unique_ptr<OTLedger> pOutbox(
9556 if (
nullptr == pInbox) {
9557 otOut <<
"Failed loading inbox!\n";
9562 lStoredTransactionNumber,
9565 else if (
nullptr == pOutbox) {
9566 otOut <<
"Failed loading outbox!\n";
9571 lStoredTransactionNumber,
9576 int32_t nTransferMultiple = 0;
9585 otOut <<
"The minimum transfer amount for this "
9588 <<
". You may only exchange in multiples of "
9589 "it.\nChoose any multiple [1]: ";
9591 nTransferMultiple = atoi(strTemp.
Get());
9593 if (nTransferMultiple <= 0) nTransferMultiple = 1;
9595 theRequestBasket.SetTransferMultiple(
9602 int64_t lClosingTransactionNo = 0;
9604 theNym, strServerID,
9605 lClosingTransactionNo);
9607 theRequestBasket.SetClosingNum(
9608 lClosingTransactionNo);
9614 for (int32_t i = 0; i < theBasket.
Count(); i++) {
9625 otOut <<
"\nBasket currency type (Asset Type) #"
9626 << (i + 1) <<
" is:\n"
9627 << str_SUB_CONTRACT_ID
9628 <<
"\n\nPlease enter your own existing "
9629 "Account ID of the same asset type: ";
9631 str_TEMP_ACCOUNT_ID.
OTfgets(std::cin);
9633 str_TEMP_ACCOUNT_ID);
9662 int64_t lSubClosingTransactionNo =
9666 theNym, strServerID,
9667 lSubClosingTransactionNo);
9668 theRequestBasket.AddRequestSubContract(
9670 lSubClosingTransactionNo);
9675 theRequestBasket.SetRequestAccountID(
9681 theRequestBasket.SignContract(theNym);
9682 theRequestBasket.SaveContractRaw(strBasketInfo);
9696 pInbox->GenerateBalanceStatement(
9699 *pTransaction, theNym, *pMainAccount,
9717 OTLedger theLedger(USER_ID, MAIN_ACCOUNT_ID,
9720 MAIN_ACCOUNT_ID, SERVER_ID,
9748 theNym, strServerID);
9765 const std::string str_server(strServerID.
Get());
9766 const bool bNymboxHash =
9773 otErr <<
"Failed getting NymboxHash from Nym "
9774 "for server: " << str_server <<
"\n";
9783 bSendCommand =
true;
9784 lReturnValue = lRequestNumber;
9788 otErr <<
"SUPPOSEDLY transaction numbers were "
9789 "available, but the call failed...\n";
9797 otOut <<
"Error loading basket info from asset contract. Are "
9798 "you SURE this is a basket currency?\n";
9802 otOut <<
"Failure loading or verifying " << strContractPath <<
"\n";
9810 otOut <<
"How many different asset types will compose this new basket? "
9813 int32_t nBasketCount = atoi(strTemp.
Get());
9814 if (0 >= nBasketCount) nBasketCount = 2;
9817 otOut <<
"If your basket has a minimum transfer amount of 100, you "
9818 "might have 2 or 3 sub-currencies,\nwith the first being a "
9819 "minimum of 2 gold, the second being a minimum of 50 dollars, "
9820 "and the\nthird being a minimum of 30 silver. In this "
9821 "example, 100 units of the basket currency is\ntransferrable "
9822 "in or out of the basket currency, in return for 2 gold, 50 "
9823 "dollars, and 30 silver.\nAs those are only the *minimum* "
9824 "amounts, you could also transfer (in or out) in *any* "
9825 "multiple of\nthose numbers.\n\n";
9826 otOut <<
"What is the minimum transfer amount for the basket currency "
9830 int64_t lMinimumTransferAmount = atoi(strTemp.
Get());
9831 if (0 == lMinimumTransferAmount) lMinimumTransferAmount = 100;
9835 Basket theBasket(nBasketCount, lMinimumTransferAmount);
9838 for (int32_t i = 0; i < nBasketCount; i++) {
9839 otOut <<
"Enter contract ID # " << (i + 1) <<
": ";
9847 otOut <<
"Enter minimum transfer amount for that asset type: ";
9851 lMinimumTransferAmount = atol(strTemp.
Get());
9855 theBasket.
AddSubContract(SUB_CONTRACT_ID, lMinimumTransferAmount);
9893 "%lld", lRequestNumber);
9915 bSendCommand =
true;
9916 lReturnValue = lRequestNumber;
9920 otOut <<
"Please enter an asset type (contract ID): ";
9929 "%lld", lRequestNumber);
9952 bSendCommand =
true;
9953 lReturnValue = lRequestNumber;
9959 if (
nullptr == pAccount) {
9960 otOut <<
"Please enter an asset Account ID (FROM acct): ";
9963 strFromAcct.
OTfgets(std::cin);
9965 if (strFromAcct.
GetLength() < 2)
return (-1);
9969 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
9975 strFromAcct.
Get())) !=
nullptr) {
9981 otErr <<
"Unable to transfer without a 'FROM' account. Try "
9982 "adding: --myacct ACCOUNT_ID\n";
9993 otErr <<
"OTClient::ProcessUserCommand: "
9994 "pAccount->GetPurportedServerID() doesn't match "
9995 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10001 if (
nullptr == pHisAcctID) {
10003 <<
"Enter Recipient's asset account ID (no partial IDs here): ";
10007 strRecipientAcct.
OTfgets(std::cin);
10009 if (strRecipientAcct.
GetLength() < 2)
return (-1);
10012 pHisAcctID->
GetString(strRecipientAcct);
10018 if (0 == lTransactionAmount) {
10019 otOut <<
"Please enter an amount: ";
10025 const int64_t lTotalAmount =
10026 (0 == lTransactionAmount)
10028 (atol(strAmount.
Exists() ? strAmount.
Get() :
"0"))
10029 : lTransactionAmount;
10031 OTIdentifier ACCT_FROM_ID(strFromAcct), USER_ID(theNym);
10033 int64_t lStoredTransactionNumber = 0;
10035 theNym, strServerID, lStoredTransactionNumber);
10040 if (bGotTransNum) {
10044 lStoredTransactionNumber);
10054 "Just testing the notes...blah blah blah blah blah blah");
10061 pTransaction->
AddItem(*pItem);
10065 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
10066 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
10068 if (
nullptr == pInbox) {
10069 otOut <<
"Failed loading inbox!\n";
10074 lStoredTransactionNumber,
10077 else if (
nullptr == pOutbox) {
10078 otOut <<
"Failed loading outbox!\n";
10083 lStoredTransactionNumber,
10103 OT_ASSERT(
nullptr != pOutboxTransaction);
10119 pOutbox->AddTransaction(
10120 *pOutboxTransaction);
10126 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
10127 atol(strAmount.
Get()) * (-1), *pTransaction, theNym,
10128 *pAccount, *pOutbox);
10133 pTransaction->
AddItem(*pBalanceItem);
10144 OTLedger theLedger(USER_ID, ACCT_FROM_ID, SERVER_ID);
10166 theNym.GetCurrentRequestNum(strServerID, lRequestNumber);
10168 "%lld", lRequestNumber);
10169 theNym.IncrementRequestNum(
10170 theNym, strServerID);
10185 const std::string str_server(strServerID.
Get());
10186 const bool bNymboxHash =
10187 theNym.GetNymboxHash(str_server, NYMBOX_HASH);
10192 otErr <<
"Failed getting NymboxHash from Nym for server: "
10193 << str_server <<
"\n";
10202 bSendCommand =
true;
10203 lReturnValue = lRequestNumber;
10208 otOut <<
"No transaction numbers were available. Suggest "
10209 "requesting the server for one.\n";
10216 otOut <<
"Please enter an Asset Type ID: ";
10220 strContractID.
OTfgets(std::cin);
10227 if (
nullptr != pTargetContract) {
10228 otOut <<
"Enter the new client-side \"name\" label for that asset "
10233 strNewName.
OTfgets(std::cin);
10235 pTargetContract->
SetName(strNewName);
10241 otOut <<
"No Asset Contract found with that ID. Try 'load'.\n";
10249 otOut <<
"Please enter a Server ID: ";
10253 strContractID.
OTfgets(std::cin);
10260 if (
nullptr != pTargetContract) {
10261 otOut <<
"Enter the new client-side \"name\" label for that "
10262 "transaction server: ";
10266 strNewName.
OTfgets(std::cin);
10268 pTargetContract->
SetName(strNewName);
10275 otOut <<
"No Server Contract found with that ID. Try 'load'.\n";
10283 otOut <<
"Please enter a Nym ID: ";
10293 if (
nullptr != pTargetNym) {
10294 otOut <<
"Enter the new client-side \"name\" label for that Nym: ";
10298 strNewName.
OTfgets(std::cin);
10314 otOut <<
"No Nym found with that ID. Try 'load'.\n";
10321 otOut <<
"Please enter an asset account ID: ";
10327 if (strAcctID.
GetLength() < 2)
return (-1);
10333 if (
nullptr != pTheAccount) {
10334 otOut <<
"Enter the new client-side \"name\" label for that "
10339 strNewName.
OTfgets(std::cin);
10341 pTheAccount->
SetName(strNewName);
10350 otOut <<
"No account found with that ID. Try 'load'.\n";
10359 "%lld", lRequestNumber);
10379 bSendCommand =
true;
10380 lReturnValue = lRequestNumber;
10387 if (
nullptr == pAccount) {
10388 otOut <<
"Please enter an asset Account ID (to get its INBOX): ";
10391 strFromAcct.
OTfgets(std::cin);
10393 if (strFromAcct.
GetLength() < 2)
return (-1);
10397 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
10403 strFromAcct.
Get())) !=
nullptr) {
10409 otErr <<
"Unable to download Inbox without an account ID. Try "
10410 "adding: --myacct ACCOUNT_ID\n";
10421 otErr <<
"OTClient::ProcessUserCommand: "
10422 "pAccount->GetPurportedServerID() doesn't match "
10423 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10436 "%lld", lRequestNumber);
10458 bSendCommand =
true;
10459 lReturnValue = lRequestNumber;
10466 if (
nullptr == pAccount) {
10467 otOut <<
"Please enter an asset Account ID (to get its OUTBOX): ";
10470 strFromAcct.
OTfgets(std::cin);
10472 if (strFromAcct.
GetLength() < 2)
return (-1);
10476 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
10482 strFromAcct.
Get())) !=
nullptr) {
10488 otErr <<
"Unable to download outbox without account ID. Try "
10489 "adding: --myacct ACCOUNT_ID\n";
10500 otErr <<
"OTClient::ProcessUserCommand: "
10501 "pAccount->GetPurportedServerID() doesn't match "
10502 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10515 "%lld", lRequestNumber);
10537 bSendCommand =
true;
10538 lReturnValue = lRequestNumber;
10573 OTLedger theNymbox(MY_NYM_ID, MY_NYM_ID, SERVER_ID);
10575 bool bSuccess =
false;
10576 bool bLoadedNymbox = theNymbox.
LoadNymbox();
10577 bool bVerifiedNymbox =
10581 if (!bLoadedNymbox)
10582 otOut <<
"OTClient::ProcessUserCommand::processEntireNymbox: "
10583 "Failed loading Nymbox: " << strNymID <<
" \n";
10584 else if (!bVerifiedNymbox)
10585 otOut <<
"OTClient::ProcessUserCommand::processEntireNymbox: "
10586 "Failed verifying Nymbox: " << strNymID <<
" \n";
10587 else if (!bIsEmpty)
10589 theNym, theMessage);
10593 otOut <<
"OTClient::ProcessUserCommand::processEntireNymbox: "
10594 "Nymbox (" << strNymID
10595 <<
") is empty (so, skipping processNymbox.)\n";
10597 otOut <<
"OTClient::ProcessUserCommand::processEntireNymbox: "
10598 "Failed trying to accept the entire Nymbox.\n";
10608 bSendCommand =
true;
10619 "%lld", lRequestNumber);
10633 const std::string str_server_id(strServerID.
Get());
10635 const bool bSuccess =
10648 bSendCommand =
true;
10649 lReturnValue = lRequestNumber;
10661 if (
nullptr == pAccount) {
10663 <<
"Please enter an asset Account ID (to PROCESS its INBOX): ";
10666 strFromAcct.
OTfgets(std::cin);
10668 if (strFromAcct.
GetLength() < 2)
return (-1);
10672 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
10678 strFromAcct.
Get())) !=
nullptr) {
10684 otErr <<
"Unable to process inbox without account ID. Try "
10685 "adding: --myacct ACCOUNT_ID\n";
10696 otErr <<
"OTClient::ProcessUserCommand: "
10697 "pAccount->GetPurportedServerID() doesn't match "
10698 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10706 OTLedger theInbox(MY_NYM_ID, theAccountID, SERVER_ID);
10708 bool bLoadedInbox = theInbox.
LoadInbox();
10710 bool bVerifiedInbox =
10715 bool bSuccess = (bLoadedInbox && bVerifiedInbox &&
10717 theNym, theMessage, *pAccount));
10728 bSendCommand =
true;
10731 otOut <<
"OTClient::processEntireInbox: Failure Inbox: Loading ("
10732 << (bLoadedInbox ?
"Success" :
"Failure") <<
"), verifying ("
10733 << (bVerifiedInbox ?
"Success" :
"Failure")
10734 <<
"), or accepting (" << (bSuccess ?
"Success" :
"Failure")
10735 <<
") entire Inbox.\n";
10746 if (
nullptr == pAccount) {
10748 <<
"Please enter an asset Account ID (to PROCESS its INBOX): ";
10751 strFromAcct.
OTfgets(std::cin);
10753 if (strFromAcct.
GetLength() < 2)
return (-1);
10757 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
10763 strFromAcct.
Get())) !=
nullptr) {
10769 otErr <<
"Unable to process inbox without account ID. Try "
10770 "adding: --myacct ACCOUNT_ID\n";
10781 otErr <<
"OTClient::ProcessUserCommand: "
10782 "pAccount->GetPurportedServerID() doesn't match "
10783 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10808 "%lld", lRequestNumber);
10824 const std::string str_server(strServerID.
Get());
10825 const bool bNymboxHash = theNym.
GetNymboxHash(str_server, NYMBOX_HASH);
10830 otErr <<
"Failed getting NymboxHash from Nym for server: "
10831 << str_server <<
"\n";
10840 bSendCommand =
true;
10841 lReturnValue = lRequestNumber;
10847 if (
nullptr == pAccount) {
10848 otOut <<
"Please enter an asset Account ID (to download its "
10849 "intermediary file): ";
10852 strFromAcct.
OTfgets(std::cin);
10854 if (strFromAcct.
GetLength() < 2)
return (-1);
10858 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
10864 strFromAcct.
Get())) !=
nullptr) {
10870 otErr <<
"Unable to download account without account ID. Try "
10871 "adding: --myacct ACCOUNT_ID\n";
10882 otErr <<
"OTClient::ProcessUserCommand: "
10883 "pAccount->GetPurportedServerID() doesn't match "
10884 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
10897 "%lld", lRequestNumber);
10919 bSendCommand =
true;
10920 lReturnValue = lRequestNumber;
10924 otOut <<
"Please enter an asset type ID: ";
10928 strAssetID.
OTfgets(std::cin);
10930 if (strAssetID.
GetLength() < 2)
return (-1);
10935 "%lld", lRequestNumber);
10957 bSendCommand =
true;
10958 lReturnValue = lRequestNumber;
10962 otOut <<
"Please enter an asset type ID: ";
10966 strAssetID.
OTfgets(std::cin);
10968 if (strAssetID.
GetLength() < 2)
return (-1);
10973 "%lld", lRequestNumber);
10995 bSendCommand =
true;
10996 lReturnValue = lRequestNumber;
11002 if (
nullptr == pAccount) {
11003 otOut <<
"Please enter an asset Account ID to deposit your tokens "
11007 strFromAcct.
OTfgets(std::cin);
11009 if (strFromAcct.
GetLength() < 2)
return (-1);
11013 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
11019 strFromAcct.
Get())) !=
nullptr) {
11025 otErr <<
"Unable to deposit tokens without an account. Try "
11026 "adding: --myacct ACCOUNT_ID\n";
11037 otErr <<
"OTClient::ProcessUserCommand: "
11038 "pAccount->GetPurportedServerID() doesn't match "
11039 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
11043 const OTIdentifier ACCT_FROM_ID(strFromAcct), USER_ID(theNym);
11045 Purse thePurse(SERVER_ID, CONTRACT_ID);
11049 int64_t lStoredTransactionNumber = 0;
11050 bool bGotTransNum =
false;
11052 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
11053 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
11055 if (
nullptr == pInbox) {
11056 otOut <<
"Failed loading inbox!\n";
11060 if (
nullptr == pOutbox) {
11061 otOut <<
"Failed loading outbox!\n";
11066 lStoredTransactionNumber);
11067 if (!bGotTransNum) {
11068 otOut <<
"No Transaction Numbers were available. Try requesting "
11069 "the server for a new one.\n";
11077 lStoredTransactionNumber,
11082 bool bSuccess =
false;
11087 lStoredTransactionNumber);
11094 OTString strNote(
"Deposit this cash, please!");
11097 otOut <<
"How many tokens would you like to deposit? ";
11099 strTokenCount.
OTfgets(std::cin);
11100 const int32_t nTokenCount = atoi(strTokenCount.
Get());
11103 theServerNymAsOwner(*pServerNym);
11105 for (int32_t nTokenIndex = 1; nTokenIndex <= nTokenCount;
11107 otOut <<
"Please enter plaintext token # " << nTokenIndex
11108 <<
"; terminate with ~ on a new line:\n> ";
11110 char decode_buffer[200];
11114 decode_buffer[0] = 0;
11116 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
11117 (decode_buffer[0] !=
'~')) {
11125 }
while (decode_buffer[0] !=
'~');
11132 std::unique_ptr<Token> pToken(
11136 if (
nullptr != pToken)
11149 pToken->ReassignOwnership(theNymAsOwner,
11150 theServerNymAsOwner)) {
11151 otErr <<
"Error re-assigning ownership of token (to "
11157 otLog3 <<
"Success re-assigning ownership of token (to "
11162 pToken->ReleaseSignatures();
11163 pToken->SignContract(theNym);
11164 pToken->SaveContract();
11166 thePurse.
Push(theServerNymAsOwner, *pToken);
11169 pItem->
SetAmount(lTemp + pToken->GetDenomination());
11173 otErr <<
"Error loading token from string.\n";
11195 pTransaction->
AddItem(*pItem);
11203 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
11204 pItem->
GetAmount(), *pTransaction, theNym, *pAccount, *pOutbox);
11220 OTLedger theLedger(USER_ID, ACCT_FROM_ID, SERVER_ID);
11240 theNym.GetCurrentRequestNum(strServerID, lRequestNumber);
11242 "%lld", lRequestNumber);
11243 theNym.IncrementRequestNum(theNym, strServerID);
11261 const std::string str_server(strServerID.
Get());
11262 const bool bNymboxHash =
11263 theNym.GetNymboxHash(str_server, NYMBOX_HASH);
11268 otErr <<
"Failed getting NymboxHash from Nym for server: "
11269 << str_server <<
"\n";
11278 bSendCommand =
true;
11279 lReturnValue = lRequestNumber;
11286 lStoredTransactionNumber,
11291 delete pTransaction;
11292 pTransaction =
nullptr;
11299 if (
nullptr == pAccount) {
11300 otOut <<
"Please enter an asset Account ID: ";
11303 strFromAcct.
OTfgets(std::cin);
11305 if (strFromAcct.
GetLength() < 2)
return (-1);
11309 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
11315 strFromAcct.
Get())) !=
nullptr) {
11321 otErr <<
"Unable to deposit without an account. Try adding: "
11322 "--myacct ACCOUNT_ID\n";
11333 otErr <<
"OTClient::ProcessUserCommand: "
11334 "pAccount->GetPurportedServerID() doesn't match "
11335 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
11341 const OTIdentifier ACCT_FROM_ID(strFromAcct), USER_ID(theNym);
11343 Purse thePurse(SERVER_ID, CONTRACT_ID);
11347 Purse theSourcePurse(thePurse);
11362 if (
nullptr == pMyAssetContract) {
11365 otOut <<
"Please enter a plaintext purse (of the same asset type "
11366 "as the account), \nand terminate with a ~ (tilde "
11367 "character) on a new line:\n> ";
11368 char decode_buffer[200];
11372 decode_buffer[0] = 0;
11374 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
11375 (decode_buffer[0] !=
'~')) {
11383 }
while (decode_buffer[0] !=
'~');
11387 otOut <<
"Failure trying to load purse from string provided by "
11399 bool bLoadedSourcePurse = theSourcePurse.
LoadPurse(
11400 strServerID.
Get(), strNymID.
Get(), strAssetTypeID.
Get());
11402 if (!bLoadedSourcePurse) {
11403 otOut <<
"Deposit purse: Failure trying to load purse from "
11404 "local storage:\nServer " << strServerID <<
" Nym "
11405 << strNymID <<
" Asset Type " << strAssetTypeID <<
"\n";
11409 otOut <<
"WARNING: This operation is very low-level. Once you "
11410 "deposit the purse in local storage,\nyou need to "
11411 "erase the purse file from local storage, since the "
11412 "tokens within it are\nall spent. (Otherwise, when "
11413 "you withdraw again, good tokens would be mixed in "
11414 "with\nthe spent ones, and then you'll have to sit "
11415 "there depositing them one-by-one, in order\nto sort "
11416 "it all out.\n (So just use the GUI and save yourself "
11417 "the trouble.)\n\nDeposit purse: using purse from "
11418 "local storage.\n Server " << strServerID <<
" Nym "
11419 << strNymID <<
" Asset Type " << strAssetTypeID <<
"\n";
11428 if (ASSET_TYPE_ID != CONTRACT_ID) {
11429 otOut <<
"Asset ID on purse didn't match asset ID on account. "
11430 "\nTry: --myacct ACCT_ID (to specify a different "
11431 "account.)\nTo use the purse in local storage, try: "
11432 "--mypurse ASSET_TYPE_ID\nFYI, if you PREFER to provide "
11433 "the purse from user input, OT *will* ask you to\ninput a "
11434 "purse when doing this, just as long as --mypurse is NOT "
11435 "provided. (And\nthat includes the defaultmypurse value "
11436 "stored in ~/.ot/command-line-ot.opt)\n\n";
11446 int64_t lStoredTransactionNumber = 0;
11447 bool bGotTransNum =
false;
11449 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
11450 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
11452 if (
nullptr == pInbox) {
11453 otOut <<
"Failed loading inbox!\n";
11457 if (
nullptr == pOutbox) {
11458 otOut <<
"Failed loading outbox!\n";
11463 lStoredTransactionNumber);
11464 if (!bGotTransNum) {
11465 otOut <<
"No Transaction Numbers were available. Try requesting "
11466 "the server for a new one.\n";
11474 lStoredTransactionNumber,
11479 bool bSuccess =
false;
11484 lStoredTransactionNumber);
11491 OTString strNote(
"Deposit this cash, please!");
11495 theServerNymAsOwner(*pServerNym);
11497 while (!theSourcePurse.
IsEmpty()) {
11498 std::unique_ptr<Token> pToken(theSourcePurse.
Pop(theNym));
11515 pToken->ReassignOwnership(theNymAsOwner,
11516 theServerNymAsOwner)) {
11517 otErr <<
"Error re-assigning ownership of token (to "
11523 otLog3 <<
"Success re-assigning ownership of token (to "
11528 pToken->ReleaseSignatures();
11529 pToken->SignContract(theNym);
11530 pToken->SaveContract();
11532 thePurse.
Push(theServerNymAsOwner,
11538 pToken->GetDenomination());
11542 otErr <<
"Error loading token from purse.\n";
11567 pTransaction->
AddItem(*pItem);
11575 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
11576 pItem->
GetAmount(), *pTransaction, theNym, *pAccount, *pOutbox);
11592 OTLedger theLedger(USER_ID, ACCT_FROM_ID, SERVER_ID);
11612 theNym.GetCurrentRequestNum(strServerID, lRequestNumber);
11614 "%lld", lRequestNumber);
11615 theNym.IncrementRequestNum(theNym, strServerID);
11633 const std::string str_server(strServerID.
Get());
11634 const bool bNymboxHash =
11635 theNym.GetNymboxHash(str_server, NYMBOX_HASH);
11640 otErr <<
"Failed getting NymboxHash from Nym for server: "
11641 << str_server <<
"\n";
11650 bSendCommand =
true;
11651 lReturnValue = lRequestNumber;
11657 lStoredTransactionNumber,
11662 delete pTransaction;
11663 pTransaction =
nullptr;
11671 if (
nullptr == pAccount) {
11672 otOut <<
"Please enter an asset Account ID (to deposit to): ";
11675 strFromAcct.
OTfgets(std::cin);
11677 if (strFromAcct.
GetLength() < 2)
return (-1);
11681 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
11687 strFromAcct.
Get())) !=
nullptr) {
11693 otErr <<
"Unable to deposit without an account. Try adding: "
11694 "--myacct ACCOUNT_ID\n";
11705 otErr <<
"OTClient::ProcessUserCommand: "
11706 "pAccount->GetPurportedServerID() doesn't match "
11707 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
11711 const OTIdentifier ACCT_FROM_ID(strFromAcct), USER_ID(theNym);
11713 OTCheque theCheque(SERVER_ID, CONTRACT_ID);
11715 otOut <<
"Please enter plaintext cheque, terminate with ~ on a new "
11718 char decode_buffer[200];
11722 decode_buffer[0] = 0;
11724 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
11725 (decode_buffer[0] !=
'~')) {
11733 }
while (decode_buffer[0] !=
'~');
11735 int64_t lStoredTransactionNumber = 0;
11737 theNym, strServerID, lStoredTransactionNumber);
11739 if (!bGotTransNum) {
11740 otOut <<
"No Transaction Numbers were available. Try requesting "
11741 "the server for a new one.\n";
11747 otOut <<
"This cheque is made out to the Nym: "
11749 <<
" (and that is NOT you, so you can't deposit it!)\n "
11750 "You are: " << strNymID <<
" \n";
11754 lStoredTransactionNumber,
11762 USER_ID, ACCT_FROM_ID, SERVER_ID,
11770 OTString strNote(
"Deposit this cheque, please!");
11787 pTransaction->
AddItem(*pItem);
11791 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
11792 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
11794 if (
nullptr == pInbox) {
11795 otOut <<
"Failed loading inbox!\n";
11800 lStoredTransactionNumber,
11803 else if (
nullptr == pOutbox) {
11804 otOut <<
"Failed loading outbox!\n";
11809 lStoredTransactionNumber,
11817 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
11818 theCheque.
GetAmount(), *pTransaction, theNym, *pAccount,
11824 pTransaction->
AddItem(*pBalanceItem);
11835 OTLedger theLedger(USER_ID, ACCT_FROM_ID, SERVER_ID);
11837 ACCT_FROM_ID, SERVER_ID,
11855 theNym.GetCurrentRequestNum(strServerID, lRequestNumber);
11857 "%lld", lRequestNumber);
11858 theNym.IncrementRequestNum(
11859 theNym, strServerID);
11875 const std::string str_server(strServerID.
Get());
11876 const bool bNymboxHash =
11877 theNym.GetNymboxHash(str_server, NYMBOX_HASH);
11883 <<
"Failed getting NymboxHash from Nym for server: "
11884 << str_server <<
"\n";
11893 bSendCommand =
true;
11894 lReturnValue = lRequestNumber;
11904 lStoredTransactionNumber,
11915 if (
nullptr == pAccount) {
11916 otOut <<
"This is like a banker's cheque, aka cashier's "
11917 "cheque.\nPlease enter an asset Account ID (FROM acct): ";
11920 strFromAcct.
OTfgets(std::cin);
11922 if (strFromAcct.
GetLength() < 2)
return (-1);
11926 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
11932 strFromAcct.
Get())) !=
nullptr) {
11938 otErr <<
"Unable to purchase voucher without a 'FROM' account. "
11939 "Try adding: --myacct ACCOUNT_ID\n";
11952 otErr <<
"OTClient::ProcessUserCommand: "
11953 "pAccount->GetPurportedServerID() doesn't match "
11954 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
11959 if (
nullptr == pHisNymID) {
11960 otOut <<
"Enter Recipient's Nym ID (full ID -- no partials here.) "
11961 "Blank IS allowed: ";
11965 strRecipientNym.
OTfgets(std::cin);
11981 if (0 == lTransactionAmount) {
11982 otOut <<
"Please enter an amount: ";
11988 const int64_t lTotalAmount =
11989 (0 == lTransactionAmount)
11991 (atol(strAmount.
Exists() ? strAmount.
Get() :
"0"))
11992 : lTransactionAmount;
11993 int64_t lWithdrawTransNum = 0, lVoucherTransNum = 0;
11996 lWithdrawTransNum);
11997 bool bGotTransNum2 =
12000 if (!bGotTransNum1 || !bGotTransNum2) {
12001 otOut << __FUNCTION__ <<
": Not enough Transaction Numbers were "
12002 "available. (Suggest requesting the "
12003 "server for more.)\n";
12014 otOut <<
"Enter a memo for your check: ";
12016 strChequeMemo.
OTfgets(std::cin);
12027 OTCheque theRequestVoucher(SERVER_ID, CONTRACT_ID);
12028 bool bIssueCheque = theRequestVoucher.
IssueCheque(
12029 lTotalAmount, lVoucherTransNum, VALID_FROM, VALID_TO,
12030 ACCOUNT_ID, MY_NYM_ID, strChequeMemo,
12031 (strRecipientNym.
GetLength() > 2) ? &(HIS_NYM_ID) :
nullptr);
12033 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
12034 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
12036 if (
nullptr == pInbox) {
12037 otOut <<
"Failed loading inbox!\n";
12046 else if (
nullptr == pOutbox) {
12047 otOut <<
"Failed loading outbox!\n";
12056 else if (bIssueCheque) {
12060 MY_NYM_ID, ACCOUNT_ID, SERVER_ID,
12068 OTString strNote(
"Withdraw Voucher: ");
12085 pTransaction->
AddItem(*pItem);
12092 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
12093 lTotalAmount * (-1), *pTransaction, theNym, *pAccount,
12096 if (
nullptr != pBalanceItem)
12097 pTransaction->
AddItem(*pBalanceItem);
12107 OTLedger theLedger(MY_NYM_ID, ACCOUNT_ID, SERVER_ID);
12131 "%lld", lRequestNumber);
12133 theNym, strServerID);
12148 const std::string str_server(strServerID.
Get());
12149 const bool bNymboxHash =
12155 otErr <<
"Failed getting NymboxHash from Nym for server: "
12156 << str_server <<
"\n";
12165 bSendCommand =
true;
12166 lReturnValue = lRequestNumber;
12195 if (
nullptr == pAccount) {
12196 otOut <<
"Please enter an Asset Account ID: ";
12199 strFromAcct.
OTfgets(std::cin);
12201 if (strFromAcct.
GetLength() < 2)
return (-1);
12205 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
12211 strFromAcct.
Get())) !=
nullptr) {
12217 otErr <<
"Unable to withdraw without account. Try adding: "
12218 "--myacct ACCOUNT_ID\n";
12229 otErr <<
"OTClient::ProcessUserCommand: "
12230 "pAccount->GetPurportedServerID() doesn't match "
12231 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
12236 if (0 == lTransactionAmount) {
12237 otOut <<
"Please enter an amount: ";
12243 const int64_t lTotalAmount =
12244 (0 == lTransactionAmount)
12246 (atol(strAmount.
Exists() ? strAmount.
Get() :
"0"))
12247 : lTransactionAmount;
12248 int64_t lAmount = lTotalAmount;
12251 const OTIdentifier ACCT_FROM_ID(strFromAcct), USER_ID(theNym);
12253 int64_t lStoredTransactionNumber = 0;
12254 bool bGotTransNum =
false;
12256 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(theNym));
12257 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(theNym));
12259 if (
nullptr == pInbox) {
12260 otOut <<
"Failed loading inbox!\n";
12263 else if (
nullptr == pOutbox) {
12264 otOut <<
"Failed loading outbox!\n";
12269 lStoredTransactionNumber);
12270 if (!bGotTransNum) {
12271 otOut <<
"No Transaction Numbers were available. Suggest "
12272 "requesting the server for a new one.\n";
12279 lStoredTransactionNumber);
12290 std::unique_ptr<Mint> pMint(
12293 if (pServerNym && pMint->LoadMint() &&
12295 Purse* pPurse =
new Purse(SERVER_ID, CONTRACT_ID);
12296 Purse* pPurseMyCopy =
new Purse(SERVER_ID, CONTRACT_ID);
12303 int64_t lTokenAmount = 0;
12304 while ((lTokenAmount = pMint->GetLargestDenomination(lAmount)) >
12306 lAmount -= lTokenAmount;
12313 std::unique_ptr<Token> pToken(
12315 *pPurse, theNym, *pMint, lTokenAmount));
12319 pToken->SignContract(theNym);
12320 pToken->SaveContract();
12327 pPurse->
Push(*pServerNym, *pToken);
12335 pToken->ReleaseSignatures();
12336 pToken->SetSavePrivateKeys();
12338 pToken->SignContract(theNym);
12339 pToken->SaveContract();
12341 pPurseMyCopy->
Push(theNym, *pToken);
12382 pTransaction->
AddItem(*pItem);
12390 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
12391 lTotalAmount * (-1), *pTransaction, theNym, *pAccount,
12408 OTLedger theLedger(USER_ID, ACCT_FROM_ID, SERVER_ID);
12430 "%lld", lRequestNumber);
12449 const std::string str_server(strServerID.
Get());
12450 const bool bNymboxHash =
12456 otErr <<
"Failed getting NymboxHash from Nym for server: "
12457 << str_server <<
"\n";
12466 bSendCommand =
true;
12467 lReturnValue = lRequestNumber;
12473 lStoredTransactionNumber,
12483 "%lld", lRequestNumber);
12497 const std::string str_server(strServerID.
Get());
12498 const bool bNymboxHash = theNym.
GetNymboxHash(str_server, NYMBOX_HASH);
12503 otErr <<
"Failed getting NymboxHash from Nym for server: "
12504 << str_server <<
"\n";
12513 bSendCommand =
true;
12514 lReturnValue = lRequestNumber;
12519 otOut <<
"You need at least 3 transaction numbers to do this (You "
12520 "don't have enough.)\n";
12523 int64_t lStoredTransactionNumber = 0,
12524 lClosingTransactionNoAssetAcct = 0,
12525 lClosingTransactionNoCurrencyAcct = 0;
12527 theNym, strServerID, lStoredTransactionNumber,
false);
12529 theNym, strServerID, lClosingTransactionNoAssetAcct,
false);
12531 theNym, strServerID, lClosingTransactionNoCurrencyAcct,
true);
12533 if (!bGotTransNum || !bGotClosingNumAssetAcct ||
12534 !bGotClosingNumCurrencyAcct) {
12535 otOut <<
"Strange... had enough transcation numbers, but error "
12536 "trying to get one (or both.)\n";
12540 lStoredTransactionNumber,
false);
12542 if (bGotClosingNumAssetAcct)
12544 lClosingTransactionNoAssetAcct,
12547 if (bGotClosingNumCurrencyAcct)
12549 lClosingTransactionNoCurrencyAcct,
12552 if (bGotTransNum || bGotClosingNumAssetAcct ||
12553 bGotClosingNumCurrencyAcct)
12557 OTString str_ASSET_TYPE_ID, str_CURRENCY_TYPE_ID,
12558 str_ASSET_ACCT_ID, str_CURRENCY_ACCT_ID;
12561 otOut <<
"Enter the Asset Type ID of the market you want to "
12563 str_ASSET_TYPE_ID.
OTfgets(std::cin);
12566 otOut <<
"Enter an ACCOUNT ID of yours for an account of the "
12567 "same asset type: ";
12568 str_ASSET_ACCT_ID.
OTfgets(std::cin);
12574 otOut <<
"Enter the Currency Type ID of the market you want to "
12576 str_CURRENCY_TYPE_ID.
OTfgets(std::cin);
12579 otOut <<
"Enter an ACCOUNT ID of yours, for an account of that "
12580 "same currency type: ";
12581 str_CURRENCY_ACCT_ID.
OTfgets(std::cin);
12586 int64_t lTotalAssetsOnOffer = 0, lMinimumIncrement = 0,
12589 otOut <<
"What is the market granularity (or 'scale')? [1]: ";
12592 int64_t lMarketScale = atol(strTemp.
Get());
12594 if (lMarketScale < 1) lMarketScale = 1;
12596 otOut <<
"What is the minimum increment per trade? (will be "
12597 "multiplied by the scale) [1]: ";
12600 lMinimumIncrement = atol(strTemp.
Get());
12602 lMinimumIncrement *= lMarketScale;
12605 if (lMinimumIncrement < 1) lMinimumIncrement = lMarketScale;
12607 otOut <<
"How many assets total do you have available for sale "
12608 "or purchase?\n(Will be multiplied by minimum "
12609 "increment) [1]: ";
12612 lTotalAssetsOnOffer = atol(strTemp.
Get());
12617 if (lTotalAssetsOnOffer < 1)
12618 lTotalAssetsOnOffer = lMinimumIncrement;
12621 otOut <<
"The Market Scale is: " << lMarketScale
12622 <<
"\nWhat is your price limit, in currency, PER "
12623 "SCALE of assets?\nThat is, what is the lowest "
12624 "amount of currency you'd sell for, (if "
12625 "selling)\nOr the highest amount you'd pay (if "
12626 "you are buying).\nAgain, PER SCALE: ";
12629 lPriceLimit = atol(strTemp.
Get());
12631 if (lPriceLimit < 1)
12632 otOut <<
"Price must be at least 1.\n\n";
12638 bool bBuyingOrSelling;
12640 otOut <<
"Are you in the market to buy the asset type, or to "
12642 strDirection.
OTfgets(std::cin);
12644 if (strDirection.
Compare(
"sell") ||
12645 strDirection.
Compare(
"Sell"))
12646 bBuyingOrSelling =
true;
12648 bBuyingOrSelling =
false;
12651 ASSET_TYPE_ID(str_ASSET_TYPE_ID),
12652 CURRENCY_TYPE_ID(str_CURRENCY_TYPE_ID),
12653 ASSET_ACCT_ID(str_ASSET_ACCT_ID),
12654 CURRENCY_ACCT_ID(str_CURRENCY_ACCT_ID);
12656 OTOffer theOffer(SERVER_ID, ASSET_TYPE_ID, CURRENCY_TYPE_ID,
12659 bool bCreateOffer = theOffer.
MakeOffer(
12662 lTotalAssetsOnOffer,
12666 lStoredTransactionNumber);
12670 if (bCreateOffer) {
12673 if (bCreateOffer) bCreateOffer = theOffer.
SaveContract();
12676 OTTrade theTrade(SERVER_ID, ASSET_TYPE_ID, ASSET_ACCT_ID,
12677 USER_ID, CURRENCY_TYPE_ID, CURRENCY_ACCT_ID);
12679 bool bIssueTrade = theTrade.
IssueTrade(theOffer);
12683 lClosingTransactionNoAssetAcct);
12685 lClosingTransactionNoCurrencyAcct);
12689 if (bIssueTrade) bIssueTrade = theTrade.
SaveContract();
12692 if (bCreateOffer && bIssueTrade) {
12696 USER_ID, ASSET_ACCT_ID, SERVER_ID,
12698 lStoredTransactionNumber);
12704 &CURRENCY_ACCT_ID);
12731 pTransaction->
AddItem(*pItem);
12740 OTItem* pStatementItem =
12747 pTransaction->
AddItem(*pStatementItem);
12759 OTLedger theLedger(USER_ID, ASSET_ACCT_ID, SERVER_ID);
12761 ASSET_ACCT_ID, SERVER_ID,
12781 "%lld", lRequestNumber);
12783 theNym, strServerID);
12799 const std::string str_server(strServerID.
Get());
12800 const bool bNymboxHash =
12807 <<
"Failed getting NymboxHash from Nym for server: "
12808 << str_server <<
"\n";
12817 bSendCommand =
true;
12818 lReturnValue = lRequestNumber;
12821 if (!bSendCommand) {
12825 lStoredTransactionNumber,
12828 lClosingTransactionNoAssetAcct,
12831 lClosingTransactionNoCurrencyAcct,
12841 otOut <<
"Is the contract a server contract, or an asset contract "
12844 strContractType.
OTfgets(std::cin);
12846 char cContractType =
's';
12847 bool bIsAssetContract = strContractType.
At(0, cContractType);
12849 if (bIsAssetContract) {
12850 if (
'S' == cContractType ||
's' == cContractType)
12851 bIsAssetContract =
false;
12855 <<
"Is the contract properly escaped already? (If escaped, all "
12856 "lines beginning with ----- will instead appear as - ----- "
12868 char cEscape =
'n';
12869 bool bEscaped = strEscape.
At(0, cEscape);
12872 if (
'N' == cEscape ||
'n' == cEscape) bEscaped =
false;
12875 otOut <<
"Please enter an unsigned asset contract; terminate with "
12879 char decode_buffer[200];
12883 decode_buffer[0] = 0;
12885 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
12886 (decode_buffer[0] !=
'~')) {
12887 if (!bEscaped && decode_buffer[0] ==
'-') {
12897 }
while (decode_buffer[0] !=
'~');
12904 ?
dynamic_cast<OTContract*
>(&theAssetContract)
12905 : dynamic_cast<OTContract*>(&theServerContract);
12916 otOut <<
".\n..\n...\n....\n.....\n......\n.......\n........\n....."
12918 "\n\nNEW CONTRACT ID: " << strNewID <<
"\n\n";
12920 std::cout << strContract << std::endl;
12929 if (
nullptr == pAccount) {
12930 otOut <<
"Please enter an Asset Account ID (to draw the cheque "
12934 strFromAcct.
OTfgets(std::cin);
12936 if (strFromAcct.
GetLength() < 2)
return (-1);
12940 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
12946 strFromAcct.
Get())) !=
nullptr) {
12952 otErr <<
"Unable to write cheque without account to draw from. "
12953 "On comand line, try adding: --myacct ACCOUNT_ID\n";
12966 otErr <<
"OTClient::ProcessUserCommand: "
12967 "pAccount->GetPurportedServerID() doesn't match "
12968 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
12974 if (
nullptr == pHisNymID) {
12975 otOut <<
"Enter Recipient's Nym ID (full ID -- no partials here.) "
12976 "Blank IS allowed: ";
12980 strRecipientNym.
OTfgets(std::cin);
12997 if (0 == lTransactionAmount) {
12998 otOut <<
"Please enter an amount: ";
13004 const int64_t lTotalAmount =
13005 (0 == lTransactionAmount)
13007 (atol(strAmount.
Exists() ? strAmount.
Get() :
"0"))
13008 : lTransactionAmount;
13020 int64_t lTransactionNumber = 0;
13024 lTransactionNumber)) {
13025 otOut <<
"Cheques are written offline, but you still need a "
13026 "transaction number\n(and you have none, currently.) Try "
13027 "using 'n' to request another transaction number.\n";
13035 otOut <<
"Enter a memo for your check: ";
13037 strChequeMemo.
OTfgets(std::cin);
13040 otOut <<
" 6 minutes == 360 Seconds\n10 minutes == 600 "
13041 "Seconds\n1 hour == 3600 Seconds\n1 day == "
13042 " 86400 Seconds\n30 days == 2592000 Seconds\n3 months "
13043 "== 7776000 Seconds\n6 months == 15552000 Seconds\n\n";
13045 int64_t lExpirationInSeconds =
13047 otOut <<
"How many seconds before cheque expires? (defaults to 1 hour: "
13048 << lExpirationInSeconds <<
"): ";
13052 if (strTemp.
GetLength() > 1) lExpirationInSeconds = atol(strTemp.
Get());
13057 otOut <<
"Cheque may be cashed STARTING date (defaults to now, in "
13058 "seconds) [" << VALID_FROM <<
"]: ";
13066 VALID_FROM, lExpirationInSeconds);
13068 bool bIssueCheque = theCheque.IssueCheque(
13069 lTotalAmount, lTransactionNumber, VALID_FROM, VALID_TO, ACCOUNT_ID,
13070 MY_NYM_ID, strChequeMemo,
13075 if (bIssueCheque) {
13076 theCheque.SignContract(theNym);
13077 theCheque.SaveContract();
13081 otOut <<
"\n\nOUTPUT (writeCheque):\n\n\n";
13084 std::cout << strCheque << std::endl;
13087 otOut <<
"Failed trying to issue the cheque!\n";
13102 if (
nullptr == pAccount) {
13104 <<
"You are the Merchant, proposing this payment plan so "
13105 "your customer can confirm it.\nAfter this command, use "
13106 "'confirm' (customer) to confirm it, and then activate "
13108 "using\n'plan' (customer) from the OT prompt, or "
13109 "'--activateplan' from the command line.\n\nEnter the "
13110 "Merchant's (your) Asset Account ID that the payments "
13114 strMerchantAcct.
OTfgets(std::cin);
13116 if (strMerchantAcct.
GetLength() < 2)
return -1;
13120 if ((pAccount = m_pWallet->
GetAccount(ACCOUNT_ID)) !=
nullptr) {
13126 strMerchantAcct.
Get())) !=
nullptr) {
13133 <<
"Unable to propose payment plan without account to "
13134 "pay to. Try adding: --myacct ACCOUNT_ID\n";
13147 otErr <<
"OTClient::ProcessUserCommand: "
13148 "pAccount->GetPurportedServerID() doesn't match "
13149 "SERVER_ID.\n(Try adding: --server SERVER_ID)\n";
13164 if (
nullptr == pHisAcctID) {
13165 otOut <<
"Enter Customer's Asset Account ID that payments will "
13166 "come FROM (no partials): ";
13170 strCustomerAcct.
OTfgets(std::cin);
13172 if (strCustomerAcct.
GetLength() < 2)
return -1;
13175 pHisAcctID->
GetString(strCustomerAcct);
13185 if (
nullptr == pHisNymID) {
13186 otOut <<
"Enter Customer's Nym ID (full ID -- no partials "
13191 strCustomerNym.
OTfgets(std::cin);
13193 if (strCustomerNym.
GetLength() < 2)
return -1;
13208 OTString strConsideration, strTemp;
13210 otOut <<
"Enter a memo describing consideration for the payment "
13212 strConsideration.
OTfgets(std::cin);
13230 <<
"Payment Plans are written offline, but you still need "
13232 "2 transaction numbers\n(and you don't, currently.) Try "
13233 "using 'n' to request another transaction number.\n";
13248 HIS_NYM_ID, MY_ACCT_ID, MY_NYM_ID);
13252 <<
" 6 minutes == 360 Seconds\n10 minutes == "
13254 "Seconds\n1 hour == 3600 Seconds\n1 day "
13256 " 86400 Seconds\n30 days == 2592000 Seconds\n3 "
13257 "months == 7776000 Seconds\n6 months == "
13258 "15552000 Seconds\n\n";
13260 int64_t lExpirationInSeconds =
13262 otOut <<
"How many seconds before payment plan expires? (defaults "
13264 "day: " << lExpirationInSeconds <<
"): ";
13269 lExpirationInSeconds = atol(strTemp.
Get());
13274 otOut <<
"Payment plan becomes valid for processing STARTING "
13275 "date\n(defaults to now, in seconds) [" << VALID_FROM
13284 VALID_FROM, lExpirationInSeconds);
13290 bool bSuccessSetAgreement = thePlan.SetProposal(
13291 theNym, strConsideration, VALID_FROM, VALID_TO);
13293 if (!bSuccessSetAgreement) {
13294 otOut <<
"Failed trying to set the proposal!\n";
13299 bool bSuccessSetInitialPayment =
true;
13302 bool bSuccessSetPaymentPlan =
13306 otOut <<
"What is the Initial Payment Amount, if any? [0]: ";
13309 int64_t lInitialPayment = atol(strTemp.
Get());
13311 if (lInitialPayment > 0) {
13315 otOut <<
"From the Start Date forward, how int64_t until the "
13316 "Initial Payment should charge?\n(defaults to one "
13318 "in seconds) [" << PAYMENT_DELAY <<
"]: ";
13322 if ((strTemp.
GetLength() > 1) && atol(strTemp.
Get()) > 0)
13325 bSuccessSetInitialPayment =
13326 thePlan.SetInitialPayment(lInitialPayment, PAYMENT_DELAY);
13329 if (!bSuccessSetInitialPayment) {
13330 otOut <<
"Failed trying to set the initial payment!\n";
13334 thePlan.HarvestClosingNumbers(
13340 otOut <<
"What is the regular payment amount, if any? [0]: ";
13343 int64_t lRegularPayment = atol(strTemp.
Get());
13345 if (lRegularPayment > 0)
13352 <<
"From the Start Date forward, how int64_t until the "
13353 "Regular Payments start?\n(defaults to two minutes, in "
13354 "seconds) [" << PAYMENT_DELAY <<
"]: ";
13358 if ((strTemp.
GetLength() > 1) && atol(strTemp.
Get()) > 0)
13364 otOut <<
"Once payments begin, how much time should elapse "
13366 "each payment?\n(defaults to thirty seconds) ["
13367 << PAYMENT_PERIOD <<
"]: ";
13371 if ((strTemp.
GetLength() > 1) && atol(strTemp.
Get()) > 0)
13377 otOut <<
"From start date, do you want the plan to expire "
13379 "certain maximum time?\n(defaults to 0 for no) ["
13380 << PLAN_LENGTH <<
"]: ";
13388 <<
"Should there be some maximum number of payments? (Zero "
13389 "for no maximum.) [0]: ";
13392 int32_t nMaxPayments = atoi(strTemp.
Get());
13394 bSuccessSetPaymentPlan = thePlan.SetPaymentPlan(
13395 lRegularPayment, PAYMENT_DELAY, PAYMENT_PERIOD, PLAN_LENGTH,
13399 if (!bSuccessSetPaymentPlan) {
13400 otOut <<
"Failed trying to set the payment plan!\n";
13404 thePlan.HarvestClosingNumbers(
13410 thePlan.SignContract(theNym);
13411 thePlan.SaveContract();
13416 <<
"\n\n(Make sure to have your Customer 'confirm' the payment "
13417 "plan, before he activates it at the server using the "
13419 "command in the OT prompt, or --activateplan at the "
13420 "command-line):\n\n";
13422 std::cout << strPlan << std::endl;
13431 <<
"(You are the customer, confirming a payment plan that the "
13432 "merchant has just sent you.)\n\n";
13437 <<
"Please enter plaintext payment plan. Terminate with ~ on a "
13440 char decode_buffer[200];
13444 decode_buffer[0] = 0;
13446 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
13447 (decode_buffer[0] !=
'~')) {
13455 }
while (decode_buffer[0] !=
'~');
13458 otOut <<
"Unable to load payment plan from string.\n";
13465 if (
nullptr == pCustomerNym) {
13466 otOut <<
"The customer Nym on this payment plan (you, "
13468 "wasn't found in the wallet. Try 'load'.\n";
13482 thePlan.
Confirm(*pCustomerNym, pMerchantNym,
13484 otOut <<
"Error while confirming payment plan. Sorry.\n";
13494 <<
"\n\nMake sure to submit the payment plan to the server, to "
13495 "activate it:\n\n";
13502 std::cout << strOutput << std::endl;
13513 otOut <<
"Please enter plaintext payment plan. Terminate with ~ on a "
13516 char decode_buffer[200];
13520 decode_buffer[0] = 0;
13522 if (!fgets(decode_buffer,
sizeof(decode_buffer) - 1, stdin) &&
13523 (decode_buffer[0] !=
'~')) {
13531 }
while (decode_buffer[0] !=
'~');
13538 if (
nullptr == pSenderAccount) {
13539 otOut <<
"There is no account loaded on this wallet with that "
13540 "sender acct ID, sorry.\n";
13542 if ((
nullptr != pAccount) && (pSenderAccount != pAccount)) {
13543 otOut <<
"This Payment Plan is already confirmed, yet now you "
13544 "try to activate it, and you \nhave supplied a "
13545 "different account ID than the one that originally "
13546 "confirmed it.\nPerhaps it's just an unfortunate "
13547 "default in your ~/.ot/command-line-ot.opt file.\nBe "
13548 "explicit, and use: --myacct <acct_id>\n";
13556 USER_ID, ACCOUNT_ID, SERVER_ID,
13570 pItem->SetAttachment(strPlan);
13574 pItem->SignContract(theNym);
13575 pItem->SaveContract();
13579 pTransaction->
AddItem(*pItem);
13587 OTItem* pStatementItem =
13593 pTransaction->
AddItem(*pStatementItem);
13604 OTLedger theLedger(USER_ID, ACCOUNT_ID, SERVER_ID);
13626 "%lld", lRequestNumber);
13628 theNym, strServerID);
13643 const std::string str_server(strServerID.
Get());
13644 const bool bNymboxHash =
13650 otErr <<
"Failed getting NymboxHash from Nym for server: "
13651 << str_server <<
"\n";
13660 lReturnValue = lRequestNumber;
13665 otOut <<
"Unable to load payment plan from string. Sorry.\n";
13729 if (m_pWallet && m_pWallet->
GetServer(0, SERVER_ID, SERVER_NAME)) {
13732 if (
nullptr != pServer) {
13735 strKEY_FILE, strKEY_PASSWORD);
13762 <<
"OTClient::InitClient: Already initialized. (Returning true.)\n";
13768 m_pWallet = &theWallet;
13774 : m_pWallet(nullptr)
13775 , m_bRunningAsScript(false)
13776 , m_lMostRecentRequestNumber(0)
13777 , m_pConnection(nullptr)
13778 , m_bInitialized(false)
EXPORT bool LoadInboxFromString(const OTString &strBox)
EXPORT int32_t GetIssuedNumCount(const OTIdentifier &theServerID) const
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT Storage * GetDefaultStorage()
EXPORT void GetReferenceString(OTString &theStr) const
OTASCIIArmor m_ascPayload2
EXPORT bool RemoveTransaction(int64_t lTransactionNum, bool bDeleteIt=true)
OTLOG_IMPORT OTLogStream otLog4
EXPORT void GetPublicCredentials(OTString &strCredList, OTString::Map *pmapCredFiles=nullptr) const
std::map< std::string, std::string > Map
void SetAmount(int64_t lAmount)
EXPORT OTItem * GenerateBalanceStatement(int64_t lAdjustment, const OTTransaction &theOwner, OTPseudonym &theNym, const OTAccount &theAccount, OTLedger &theOutbox)
EXPORT bool SetNymboxHash(const std::string &server_id, const OTIdentifier &theInput)
EXPORT bool SetFocusToServerAndNym(OTServerContract &theServerContract, OTPseudonym &theNym, TransportCallback *pCallback) const
static EXPORT OTAsymmetricKey * KeyFactory()
EXPORT Storable * CreateObject(StoredObjectType eType)
static EXPORT int64_t StringToLong(const std::string &number)
int32_t GetTransactionCount() const
EXPORT OTMessage * GetSentMessage(const int64_t &requestNum, const OTString &serverId, const OTString &nymId)
void ProcessDepositResponse(OTTransaction &theTransaction, const OTServerConnection &theConnection, const OTMessage &theReply) const
EXPORT bool Unpack(PackedBuffer &inBuf, Storable &outObj)
EXPORT bool SetPublicKey(const OTString &strKey, bool bEscaped=true)
bool SetFocus(OTPseudonym &theNym, OTServerContract &theServerContract, TransportCallback *pCallback)
static EXPORT OTTransaction * GenerateTransaction(const OTIdentifier &theUserID, const OTIdentifier &theAccountID, const OTIdentifier &theServerID, transactionType theType, int64_t lTransactionNum=0)
static EXPORT OTItem * CreateItemFromString(const OTString &strItem, const OTIdentifier &theServerID, int64_t lTransactionNumber)
int32_t CalcReturnVal(const int64_t &lRequestNumber)
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
EXPORT void SetNumberOfOrigin(int64_t lTransactionNum)
EXPORT void HarvestTransactionNumbers(const OTIdentifier &theServerID, OTPseudonym &SIGNER_NYM, OTPseudonym &theOtherNym, bool bSave=true)
int32_t GetCompletedCount()
const OTIdentifier & GetSenderUserID() const
static EXPORT Mint * MintFactory()
EXPORT OTItem * GenerateTransactionStatement(const OTTransaction &theOwner)
EXPORT bool LoadFromString(const OTString &strNym, OTString::Map *pMapCredentials=nullptr, OTString *pstrReason=nullptr, const OTPassword *pImportPassword=nullptr)
Token::tokenState GetState() const
EXPORT bool SetInboxHash(const std::string &acct_id, const OTIdentifier &theInput)
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
EXPORT OTAccount * GetAccountPartialMatch(std::string PARTIAL_ID)
static EXPORT const OTString & Pubcred()
EXPORT bool SaveOutbox(OTIdentifier *pOutboxHash=nullptr)
EXPORT bool RemoveSentMessage(const int64_t &requestNum, const OTString &serverId, const OTString &nymId)
EXPORT void GetAttachment(OTString &theStr) const
EXPORT bool MakeOffer(bool bBuyingOrSelling, const int64_t &lPriceLimit, const int64_t &lTotalAssetsOffer, const int64_t &lMinimumIncrement, const int64_t &lTransactionNum, const time64_t &VALID_FROM=OT_TIME_ZERO, const time64_t &VALID_TO=OT_TIME_ZERO)
EXPORT void SetAcknowledgments(OTPseudonym &theNym)
EXPORT bool LoadRecordBox()
std::string to_string(const T &t)
int64_t m_lTransactionNum
virtual EXPORT bool VerifyAccount(const OTPseudonym &theNym)
#define OT_TIME_HOUR_IN_SECONDS
EXPORT const OTIdentifier & GetAssetTypeID() const
int64_t GetTransactionNum() const
static EXPORT const OTString & PaymentInbox()
EXPORT bool Push(OTNym_or_SymmetricKey theOwner, const Token &theToken)
EXPORT OTAssetContract * GetAssetContract(const OTIdentifier &theContractID)
static EXPORT OTTransactionType * TransactionFactory(OTString strInput)
const int64_t & GetAmount() const
void ProcessPayDividendResponse(OTTransaction &theTransaction, const OTServerConnection &theConnection, const OTMessage &theReply) const
EXPORT bool SavePublicKey(const OTString &strPath) const
EXPORT bool DeleteBoxReceipt(OTLedger &theLedger)
EXPORT bool SaveContract()
EXPORT bool VerifyIssuedNum(const OTString &strServerID, const int64_t &lTransNum) const
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
EXPORT bool AddBlankNumbersToItem(const OTNumList &theAddition)
EXPORT void AddOutmail(OTMessage &theMessage)
int64_t GetMinimumTransfer() const
static EXPORT const char * PathSeparator()
EXPORT OTLedger * LoadOutbox(OTPseudonym &nym) const
virtual bool VerifyAccount(const OTPseudonym &theNym)
EXPORT bool GetNextTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t &lTransNum, bool bSave=true)
const OTIdentifier & GetAssetID() const
EXPORT bool GetAllTransactionNumbers(OTNumList &numlistOutput) const
EXPORT bool VerifyTentativeNum(const OTString &strServerID, const int64_t &lTransNum) const
static EXPORT const OTString & Nym()
EXPORT OTItem * GetItemInRefTo(int64_t lReference)
Purse * GetPendingWithdrawal() const
EXPORT bool SaveRecordBox()
EXPORT void AddPendingWithdrawal(const Purse &thePurse)
virtual EXPORT bool CreateContract(const OTString &strContract, const OTPseudonym &theSigner)
EXPORT void OTfgets(std::istream &ofs)
EXPORT const OTAsymmetricKey & GetPublicEncrKey() const
EXPORT bool SetPayment(const OTString &strPayment)
EXPORT int64_t GetTransactionNum(const OTIdentifier &theServerID, int32_t nIndex) const
EXPORT bool AddTransaction(OTTransaction &theTransaction)
OTLOG_IMPORT OTLogStream otOut
EXPORT void AddAssetContract(const OTAssetContract &theContract)
EXPORT void GetNumList(OTNumList &theOutput)
bool ProcessServerReply(OTMessage &theReply, OTLedger *pNymbox=nullptr)
EXPORT void GetNote(OTString &theStr) const
void SetNymName(const OTString &strName)
void load_str_trans_add_to_ledger(const OTIdentifier &the_nym_id, const OTString &str_trans, OTString str_box_type, const int64_t &lTransNum, OTPseudonym &the_nym, OTLedger &ledger)
OTLOG_IMPORT OTLogStream otLog3
bool RemoveTentativeNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
EXPORT void SetAttachment(const OTString &theStr)
const OTIdentifier & GetAssetID() const
EXPORT bool SaveContractRaw(OTString &strOutput) const
EXPORT bool GetAccount(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT uint32_t GetLength() const
EXPORT int32_t ProcessUserCommand(OT_CLIENT_CMD_TYPE requestedCommand, OTMessage &theMessage, OTPseudonym &theNym, const OTServerContract &theServer, const OTAccount *pAccount=nullptr, int64_t lTransactionAmount=0, OTAssetContract *pMyAssetContract=nullptr, const OTIdentifier *pHisNymID=nullptr, const OTIdentifier *pHisAcctID=nullptr)
EXPORT bool AddTentativeNum(const OTString &strServerID, const int64_t &lTransNum)
EXPORT bool AddNewSubkey(const OTIdentifier &idMasterCredential, int32_t nBits=1024, const OTString::Map *pmapPrivate=nullptr, const OTPasswordData *pPWData=nullptr, OTString *pstrNewID=nullptr)
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
EXPORT bool IssueTrade(OTOffer &offer, char stopSign=0, int64_t stopPrice=0)
bool HasRecipient() const
EXPORT void Concatenate(const char *arg,...)
EXPORT bool Seal(const OTPseudonym &theRecipient, const OTString &theInput)
static EXPORT const OTString & Inbox()
const int64_t & GetRequestNum() const
EXPORT bool WriteArmoredString(OTString &strOutput, const std::string str_type, bool bEscaped=false) const
OTServerConnection * m_pConnection
static EXPORT const OTString & Contract()
EXPORT int32_t GetTransactionNumCount(const OTIdentifier &theServerID) const
EXPORT void AddSentMessage(OTMessage &message)
bool ConnectToTheFirstServerOnList(const OTPseudonym &theNym, const OTString &strCA_FILE, const OTString &strKEY_FILE, const OTString &strKEY_PASSWORD) const
#define OT_TIME_SIX_MONTHS_IN_SECONDS
EXPORT Storable * QueryObject(StoredObjectType theObjectType, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool VerifyPseudonym() const
static EXPORT OTItem * CreateItemFromTransaction(const OTTransaction &theOwner, OTItem::itemType theType, const OTIdentifier *pDestinationAcctID=nullptr)
EXPORT bool SavePaymentInbox()
EXPORT void ReleaseSignatures()
EXPORT bool Exists() const
EXPORT bool SetString(const OTString &theData, bool bLineBreaks=true)
EXPORT std::string EncodeObject(Storable &theContents)
EXPORT void SetString(const char *szString)
EXPORT void SetIdentifier(const OTIdentifier &theIdentifier)
const char * GetTypeString() const
EXPORT void Format(const char *fmt,...)
EXPORT void Push(OTMessage &message)
EXPORT void ReleaseTransactions()
#define OT_TIME_DAY_IN_SECONDS
OTMessageOutbuffer & GetMessageOutbuffer()
EXPORT bool Connect(const OTPseudonym &, const OTServerContract &, const OTString &, const OTString &, const OTString &) const
EXPORT void SetReferenceString(const OTString &theStr)
EXPORT const OTPseudonym * GetContractPublicNym() const
EXPORT bool Compare(const char *compare) const
EXPORT bool GetHighestNum(const OTString &strServerID, int64_t &lHighestNum) const
static EXPORT Token * InstantiateAndGenerateTokenRequest(const Purse &thePurse, const OTPseudonym &theNym, Mint &theMint, int64_t lDenomination, int32_t nTokenCount=Token::GetMinimumPrototokenCount())
EXPORT OTItem * GetItem(OTItem::itemType theType)
EXPORT bool LoadOutboxFromString(const OTString &strBox)
OTNumList m_AcknowledgedReplies
void ProcessMessageOut(const char *buf, int32_t *pnExpectReply) const
EXPORT bool RemoveTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum)
const OTIdentifier & GetPurportedServerID() const
void SetIdentifier(const OTIdentifier &theID)
const int64_t & GetFinishedSoFar() const
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
time64_t OTTimeGetCurrentTime()
EXPORT bool LoadLedgerFromString(const OTString &theStr)
EXPORT bool AddTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t lTransNum, bool bSave)
bool ProcessInBuffer(const OTMessage &theServerReply) const
EXPORT OTPseudonym * GetNymByID(const OTIdentifier &NYM_ID)
virtual EXPORT bool ProcessToken(const OTPseudonym &theNym, Mint &theMint, Token &theRequest)=0
EXPORT bool GetPublicKey(OTASCIIArmor &strKey) const
EXPORT bool Confirm(OTPseudonym &PAYER_NYM, OTPseudonym *pMERCHANT_NYM=nullptr, const OTIdentifier *p_id_MERCHANT_NYM=nullptr)
bool AcceptEntireNymbox(OTLedger &theNymbox, const OTIdentifier &theServerID, const OTServerContract &theServerContract, OTPseudonym &theNym, OTMessage &theMessage)
OTServerContract * GetServerContract() const
EXPORT bool SaveExpiredBox()
EXPORT const OTAsymmetricKey & GetPublicAuthKey() const
EXPORT bool GetAsciiArmoredData(OTASCIIArmor &theArmoredText, bool bLineBreaks=true) const
int64_t GetAmount() const
void ProcessMessageOut(const char *buf, const int32_t *pnExpectReply)
EXPORT bool Output(std::set< int64_t > &theOutput) const
EXPORT bool GetCurrentRequestNum(const OTString &strServerID, int64_t &lReqNum) const
EXPORT int64_t GetClosingNum() const
EXPORT bool RemoveIssuedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
EXPORT bool RemoveAccount(const OTIdentifier &theTargetID)
EXPORT OTLedger * LoadInbox(OTPseudonym &nym) const
static EXPORT const OTString & Receipt()
bool InitClient(OTWallet &theWallet)
Need to call this before using.
EXPORT bool LoadNymboxFromString(const OTString &strBox)
EXPORT bool SetOutboxHash(const std::string &acct_id, const OTIdentifier &theInput)
EXPORT bool AddAcknowledgedNum(const OTString &strServerID, const int64_t &lRequestNum)
#define OT_ASSERT_MSG(x, s)
EXPORT bool RemoveAcknowledgedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lRequestNum, bool bSave)
OTPayment * GetInstrument(const OTPseudonym &theNym, const int32_t &nIndex, OTLedger &ledger)
EXPORT BasketItem * At(uint32_t nIndex)
static EXPORT OTLedger * GenerateLedger(const OTIdentifier &theUserID, const OTIdentifier &theAcctID, const OTIdentifier &theServerID, ledgerType theType, bool bCreateFile=false)
OTLOG_IMPORT OTLogStream otInfo
OTASCIIArmor m_ascInReferenceTo
ledgerType GetType() const
EXPORT bool GetData(OTData &theData, bool bLineBreaks=true) const
std::string currency_paid
EXPORT bool SaveWallet(const char *szFilename=nullptr)
static EXPORT bool EraseActiveCronReceipt(const int64_t &lTransactionNum, const OTIdentifier &nymID, const OTIdentifier &serverID)
virtual EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
bool AcceptEntireInbox(OTLedger &theInbox, const OTIdentifier &theServerID, const OTServerContract &theServerContract, OTPseudonym &theNym, const OTMessage &theMessage, const OTAccount &theAccount)
EXPORT bool SaveNymbox(OTIdentifier *pNymboxHash=nullptr)
EXPORT bool SetRecentHash(const std::string &server_id, const OTIdentifier &theInput)
const OTIdentifier & GetCurrencyID() const
EXPORT bool At(uint32_t index, char &c) const
OTWallet * GetWallet() const
static EXPORT const OTString & Market()
bool GetServerID(OTIdentifier &theID) const
EXPORT void SetNote(const OTString &theStr)
EXPORT bool GetNymboxHash(const std::string &server_id, OTIdentifier &theOutput) const
EXPORT bool IssueCheque(const int64_t &lAmount, const int64_t &lTransactionNum, const time64_t &VALID_FROM, const time64_t &VALID_TO, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &SENDER_USER_ID, const OTString &strMemo, const OTIdentifier *pRECIPIENT_USER_ID=nullptr)
EXPORT int64_t GetReferenceToNum() const
EXPORT bool SetTempValues()
EXPORT bool SaveBoxReceipt(int64_t lLedgerType)
OTLOG_IMPORT OTLogStream otWarn
void ProcessWithdrawalResponse(OTTransaction &theTransaction, const OTServerConnection &theConnection, const OTMessage &theReply) const
EXPORT void HarvestClosingNumbers(OTPseudonym &theNym, const OTIdentifier &theServerID, bool bSave=true)
EXPORT const char * Get() const
EXPORT bool EraseValueByKey(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT const void * GetPayloadPointer() const
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
transactionType GetType() const
int32_t GetItemCount() const
OTLOG_IMPORT OTLogStream otErr
void SetExchangingIn(bool bDirection)
OTItem::itemStatus GetStatus() const
#define OT_TIME_MINUTE_IN_SECONDS
EXPORT int64_t GetReceiptAmount()
virtual bool VerifyAccount(const OTPseudonym &theNym)
EXPORT OTPacker * GetPacker(PackType ePackType=OTDB_DEFAULT_PACKER)
EXPORT int64_t GetTransactionNum() const
std::map< std::string, std::string > the_map
void OnServerResponseToGetRequestNumber(int64_t lNewRequestNumber) const
EXPORT void SetReferenceToNum(int64_t lTransactionNum)
virtual PackedBuffer * CreateBuffer()=0
EXPORT bool VerifyAny(const OTNumList &rhs) const
EXPORT bool SavePurse(const char *szServerID=nullptr, const char *szUserID=nullptr, const char *szAssetTypeID=nullptr)
OTASCIIArmor m_ascPayload
bool IsAbbreviated() const
void ProcessIncomingTransactions(OTServerConnection &theConnection, OTMessage &theReply) const
OTPseudonym * GetNym() const
EXPORT const OTIdentifier & GetConstID() const
EXPORT bool RemoveOutpaymentsByIndex(int32_t nIndex, bool bDeleteIt=true)
int32_t GetOutpaymentsIndexByTransNum(const OTPseudonym &nym, int64_t lTransNum)
EXPORT void AddMail(OTMessage &theMessage)
EXPORT void GetString(OTString &theStr) const
OTIdentifier SUB_CONTRACT_ID
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier & GetSenderAcctID() const
const time64_t & GetLastProcessDate() const
virtual EXPORT bool VerifyContract()
virtual EXPORT bool VerifyContractID() const
EXPORT bool GetServer(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool LoadPurse(const char *szServerID=nullptr, const char *szUserID=nullptr, const char *szAssetTypeID=nullptr)
EXPORT bool SaveCredentialList()
static EXPORT Token * TokenFactory(OTString strInput)
EXPORT Storable * DecodeObject(StoredObjectType theObjectType, std::string strInput)
static EXPORT const OTString & RecordBox()
OTItem::itemType GetType() const
const OTIdentifier & GetUserID() const
EXPORT bool GetString(OTString &theData, bool bLineBreaks=true) const
int64_t OTTimeGetSecondsFromTime(time64_t time)
EXPORT void AddClosingTransactionNo(const int64_t &lClosingTransactionNo)
EXPORT bool LoadContractFromString(const OTString &theStr)
EXPORT bool StoreObject(Storable &theContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT int64_t GetIssuedNum(const OTIdentifier &theServerID, int32_t nIndex) const
EXPORT OTMessage * GetOutpaymentsByIndex(int32_t nIndex) const
EXPORT OTServerContract * GetServerContract(const OTIdentifier &SERVER_ID)
EXPORT bool SaveAccount()
void GetTypeString(OTString &strType) const
virtual EXPORT void CalculateContractID(OTIdentifier &newID) const
EXPORT size_t GetMasterCredentialCount() const
const OTIdentifier & GetRecipientUserID() const
OTString m_strNymPublicKey
EXPORT bool AddIssuedNum(const OTString &strServerID, const int64_t &lTransNum)
listOfItems & GetItemList()
EXPORT bool AddNewMasterCredential(OTString &strOutputMasterCredID, const OTString *pstrSourceForNymID=nullptr, int32_t nBits=1024, const OTString::Map *pmapPrivate=nullptr, const OTString::Map *pmapPublic=nullptr, const OTPasswordData *pPWData=nullptr, bool bChangeNymID=false)
static EXPORT OTAccount * LoadExistingAccount(const OTIdentifier &accountId, const OTIdentifier &serverId)
virtual EXPORT void Release()
EXPORT void AddSubContract(const OTIdentifier &SUB_CONTRACT_ID, int64_t lMinimumTransferAmount)
EXPORT bool VerifyAcknowledgedNum(const OTString &strServerID, const int64_t &lRequestNum) const
const OTIdentifier & GetRealServerID() const
EXPORT bool ProcessInBuffer(const OTMessage &) const
EXPORT bool UnRegisterAtServer(const OTString &strServerID)
static EXPORT OTCronItem * NewCronItem(const OTString &strCronItem)
EXPORT void AddItem(OTItem &theItem)
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)
EXPORT void AddAccount(const OTAccount &theAcct)
EXPORT int32_t Count() const
EXPORT OTTransaction * GetTransaction(OTTransaction::transactionType theType)
EXPORT void IncrementRequestNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID)
const int64_t & GetPriceLimit() const
EXPORT bool IsEmpty() const
EXPORT void SetName(const OTString &strName)
EXPORT const mapOfTransactions & GetTransactionMap() const
EXPORT bool SaveInbox(OTIdentifier *pInboxHash=nullptr)
EXPORT bool StoreObject(Storable &theContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT Token * Pop(OTNym_or_SymmetricKey theOwner)