133 #include "../core/stdafx.hpp"
143 #include "../ext/InstantiateContract.hpp"
144 #include "../ext/OTPayment.hpp"
145 #include "../ext/Socket_ZMQ4.hpp"
147 #include "../cash/Mint.hpp"
148 #include "../cash/Purse.hpp"
149 #include "../cash/Token.hpp"
151 #include "../basket/Basket.hpp"
153 #include "../core/recurring/OTPaymentPlan.hpp"
154 #include "../core/script/OTAgent.hpp"
155 #include "../core/script/OTBylaw.hpp"
156 #include "../core/script/OTParty.hpp"
157 #include "../core/script/OTPartyAccount.hpp"
158 #include "../core/script/OTSmartContract.hpp"
159 #include "../core/trade/OTTrade.hpp"
160 #include "../core/trade/OTOffer.hpp"
161 #include "../core/crypto/OTAsymmetricKey.hpp"
162 #include "../core/crypto/OTCachedKey.hpp"
163 #include "../core/crypto/OTCrypto.hpp"
164 #include "../core/crypto/OTEnvelope.hpp"
165 #include "../core/crypto/OTNymOrSymmetricKey.hpp"
166 #include "../core/crypto/OTPassword.hpp"
167 #include "../core/crypto/OTPasswordData.hpp"
168 #include "../core/crypto/OTSymmetricKey.hpp"
169 #include "../core/OTAssetContract.hpp"
170 #include "../core/OTCheque.hpp"
171 #include "../core/util/OTDataFolder.hpp"
172 #include "../core/util/OTFolders.hpp"
173 #include "../core/OTLedger.hpp"
174 #include "../core/OTLog.hpp"
175 #include "../core/OTMessage.hpp"
176 #include "../core/util/OTPaths.hpp"
177 #include "../core/OTPseudonym.hpp"
178 #include "../core/OTIdentifier.hpp"
179 #include "../core/OTPseudonym.hpp"
180 #include "../core/OTServerContract.hpp"
181 #include "../core/OTStorage.hpp"
183 #if defined(OT_KEYRING_FLATFILE)
184 #include "../core/OTKeyring.hpp"
197 #if defined(OPENTXS_HAVE_NETINET_IN_H)
199 #include <netinet/in.h>
203 #define CLIENT_DEFAULT_LATENCY_SEND_MS 200
204 #define CLIENT_DEFAULT_LATENCY_SEND_NO_TRIES 7
205 #define CLIENT_DEFAULT_LATENCY_RECEIVE_MS 200
206 #define CLIENT_DEFAULT_LATENCY_RECEIVE_NO_TRIES 7
207 #define CLIENT_DEFAULT_LATENCY_DELAY_AFTER 50
208 #define CLIENT_DEFAULT_IS_BLOCKING false
210 #define CLIENT_CONFIG_KEY "client"
211 #define CLIENT_DATA_DIR "client_data"
212 #define CLIENT_LOGFILE_FILENAME "log-client.log"
213 #define CLIENT_MASTER_KEY_TIMEOUT_DEFAULT 300
214 #define CLIENT_WALLET_FILENAME "wallet.xml"
215 #define CLIENT_USE_SYSTEM_KEYRING false
216 #define CLIENT_PASSWORD_FOLDER ""
217 #define CLIENT_PID_FILENAME "ot.pid"
232 int64_t lReferenceNum,
233 OTPayment** ppPaymentOut)
236 for (
auto& it : transactionsMap) {
237 OTTransaction* pTransaction = it.second;
241 pTransaction->GetType())
244 if (pTransaction->GetReferenceToNum() == lReferenceNum) {
249 pTransaction->GetReferenceString(strPayment);
251 if (!strPayment.Exists()) {
252 OTPayment* pPayment =
new OTPayment(strPayment);
255 if (pPayment->IsValid() && pPayment->SetTempValues())
259 otErr << __FUNCTION__ <<
": Error: Failed loading up "
260 "payment instrument from "
264 *ppPaymentOut =
nullptr;
268 otErr << __FUNCTION__ <<
": Error: Unexpected: payment "
269 "instrument was empty string, on "
270 "a paymentReceipt.\n";
280 bool VerifyBalanceReceipt(OTPseudonym& SERVER_NYM, OTPseudonym& THE_NYM,
281 const OTIdentifier& SERVER_ID,
282 const OTIdentifier& ACCT_ID)
284 OTIdentifier USER_ID(THE_NYM), SERVER_USER_ID(SERVER_NYM);
285 OTString strServerID(SERVER_ID), strReceiptID(ACCT_ID);
289 OTTransaction tranOut(SERVER_USER_ID, ACCT_ID, SERVER_ID);
291 OTString strFilename;
292 strFilename.Format(
"%s.success", strReceiptID.Get());
295 const char* szFolder2name = strServerID.Get();
296 const char* szFilename =
299 if (!
OTDB::Exists(szFolder1name, szFolder2name, szFilename)) {
300 otWarn <<
"Receipt file doesn't exist in "
301 "OTTransaction::VerifyBalanceReceipt.\n";
305 std::string strFileContents(
309 if (strFileContents.length() < 2) {
310 otErr <<
"OTTransaction::VerifyBalanceReceipt: Error reading file: "
316 OTString strTransaction(strFileContents.c_str());
318 if (!tranOut.LoadContractFromString(strTransaction)) {
319 otErr <<
"OTTransaction::VerifyBalanceReceipt: Unable to load balance "
325 OTTransaction* pTransaction =
nullptr;
326 std::unique_ptr<OTTransaction> theTransAngel;
328 if (tranOut.IsAbbreviated())
330 int64_t lBoxType = 0;
332 if (tranOut.Contains(
"nymboxRecord"))
334 else if (tranOut.Contains(
"inboxRecord"))
336 else if (tranOut.Contains(
"outboxRecord"))
338 else if (tranOut.Contains(
"paymentInboxRecord"))
340 else if (tranOut.Contains(
"recordBoxRecord"))
342 else if (tranOut.Contains(
"expiredBoxRecord"))
345 otErr <<
"OTTransaction::VerifyBalanceReceipt: Error loading from "
346 "abbreviated transaction: "
347 "unknown ledger type. (probably message but who knows.)\n";
352 if (
nullptr == pTransaction) {
353 otErr <<
"OTTransaction::VerifyBalanceReceipt: Error loading from "
354 "abbreviated transaction: "
355 "failed loading box receipt.";
359 theTransAngel.reset(pTransaction);
362 pTransaction = &tranOut;
364 if (!pTransaction->VerifySignature(SERVER_NYM)) {
365 otErr <<
"OTTransaction::VerifyBalanceReceipt: Unable to verify "
366 "SERVER_NYM signature on balance statement:\n "
375 return pTransaction->VerifyBalanceReceipt(SERVER_NYM, THE_NYM);
381 bool OT_API::bInitOTApp =
false;
383 bool OT_API::bCleanupOTApp =
false;
400 : m_bIsPidOpen(false)
401 , m_strPidFilePath(
"")
413 otErr << __FUNCTION__ <<
": strPidFilePath is OPEN, MUST CLOSE BEFORE "
414 "OPENING A NEW ONE!\n";
418 if (!strPidFilePath.
Exists()) {
419 otErr << __FUNCTION__ <<
": strPidFilePath is Empty!\n";
423 otErr << __FUNCTION__ <<
": strPidFilePath is Too Short! ("
424 << strPidFilePath <<
")\n";
428 otWarn << __FUNCTION__ <<
": Using Pid File: " << strPidFilePath <<
"\n";
429 m_strPidFilePath = strPidFilePath;
448 std::ifstream pid_infile(m_strPidFilePath.Get());
453 if (pid_infile.is_open())
455 uint32_t old_pid = 0;
456 pid_infile >> old_pid;
461 const uint64_t lPID = old_pid;
463 <<
"\n\n\nIS OPEN-TRANSACTIONS ALREADY RUNNING?\n\n"
464 "I found a PID (" << lPID
465 <<
") in the data lock file, located at: "
466 << m_strPidFilePath <<
"\n\n"
467 "If the OT process with PID " << lPID
468 <<
" is truly not running "
470 "then just erase that file and restart.\nThis is "
473 "up during AppCleanup / AppShutdown. (Or should be.)\n";
475 m_bIsPidOpen =
false;
488 uint64_t the_pid = 0;
491 the_pid = GetCurrentProcessId();
498 std::ofstream pid_outfile(m_strPidFilePath.Get());
500 if (pid_outfile.is_open()) {
501 pid_outfile << the_pid;
506 otErr <<
"Failed trying to open data locking file (to store "
507 "PID " << the_pid <<
"): " << m_strPidFilePath <<
"\n";
508 m_bIsPidOpen =
false;
518 <<
": strPidFilePath is CLOSED, WHY CLOSE A PID IF NONE IS OPEN!\n";
521 if (!m_strPidFilePath.Exists()) {
522 otErr << __FUNCTION__ <<
": m_strPidFilePath is Empty!\n";
533 std::ofstream pid_outfile(m_strPidFilePath.Get());
535 if (pid_outfile.is_open()) {
536 uint32_t the_pid = 0;
537 pid_outfile << the_pid;
539 m_bIsPidOpen =
false;
542 otErr <<
"Failed trying to open data locking file (to wipe PID "
543 "back to 0): " << m_strPidFilePath <<
"\n";
560 if (!OT_API::bInitOTApp) {
565 otOut <<
"\n\nWelcome to Open Transactions -- version "
568 otWarn <<
"(transport build: OTMessage -> OTEnvelope -> ZMQ )\n";
572 #if defined(OT_SIGNAL_HANDLING)
584 OT_API::bInitOTApp =
true;
588 otErr << __FUNCTION__
589 <<
": ERROR: This function can only be called once.\n";
597 if (!OT_API::bInitOTApp) {
598 otErr << __FUNCTION__ <<
": WARNING: Never Successfully called: "
599 <<
"OT_API::InitCTX()"
601 OT_API::bInitOTApp =
true;
605 if (!OT_API::bCleanupOTApp) {
619 otErr << __FUNCTION__
620 <<
": ERROR: This function can only be called once.\n";
628 , m_bInitialized(false)
629 , m_pTransportCallback(nullptr)
632 , m_strWalletFilename(
"")
633 , m_strWalletFilePath(
"")
634 , m_strConfigFilename(
"")
635 , m_strConfigFilePath(
"")
649 if (
nullptr != m_pSocket)
delete m_pSocket;
652 if (
nullptr != m_pTransportCallback)
delete m_pTransportCallback;
653 m_pTransportCallback =
nullptr;
654 if (
nullptr != m_pWallet)
delete m_pWallet;
656 if (
nullptr != m_pClient)
delete m_pClient;
666 if (
nullptr != m_pPid)
delete m_pPid;
687 if (
true == m_bInitialized) {
691 "OT_API::Init(): Error! Data path not set!");
693 otErr << __FUNCTION__
694 <<
": OTAPI was already initialized. (Skipping) and using "
695 "path: " << strDataPath <<
"\n";
700 otErr << __FUNCTION__ <<
": Unable to Init data folders";
704 static bool bConstruct =
false;
708 m_pWallet =
new OTWallet;
709 m_pClient =
new OTClient;
713 otErr << __FUNCTION__ <<
": Unable to Load Config File!";
722 OTString strDataPath =
"";
726 bool bExists =
false, bIsNew =
false;
732 OTString strPIDPath =
"";
735 if (bGetDataFolderSuccess) m_pPid->
OpenPid(strPIDPath);
737 m_bInitialized =
false;
751 otWarn << __FUNCTION__ <<
": Success invoking OTDB::InitDefaultStorage";
754 otWarn << __FUNCTION__ <<
": m_pClient->InitClient() was already "
755 "initialized. (Skipping.)\n";
757 m_bInitialized = m_pClient->
InitClient(*m_pWallet);
760 <<
": Success invoking m_pClient->InitClient() \n";
762 otErr << __FUNCTION__
763 <<
": Failed invoking m_pClient->InitClient()\n";
765 return m_bInitialized;
768 otErr << __FUNCTION__ <<
": Failed invoking OTDB::InitDefaultStorage\n";
772 bool OT_API::Cleanup()
788 if (m_strWalletFilename.
Exists()) {
789 strPath = m_strWalletFilename;
802 m_strWalletFilename = strPath;
811 if (
nullptr != pTransportCallback) {
812 m_pTransportCallback = pTransportCallback;
821 if (
nullptr != m_pTransportCallback) {
822 return m_pTransportCallback;
834 OTString strConfigPath, strConfigFilename;
849 if (!p_Config->Load()) {
850 otOut << __FUNCTION__
851 <<
": Note: Unable to Load Config. Creating a new file: "
852 << strConfigFilename <<
"\n";
853 if (!p_Config->
Reset())
return false;
854 if (!p_Config->Save())
return false;
857 if (!p_Config->
Reset())
return false;
860 if (!p_Config->Load()) {
861 otErr << __FUNCTION__
862 <<
": Error: Unable to load config file: " << strConfigFilename
863 <<
" It should exist, as we just saved it!\n";
871 p_Config->
CheckSet_long(
"logging",
"log_level", 0, lValue, bIsNewKey);
886 otWarn <<
"Using Wallet: " << strValue <<
"\n";
891 const char* szComment =
893 ";; For sending and receiving:\n"
894 ";; blocking=true (usually not recommended) means OT will hang on "
896 ";; call, and wait indefinitely until the send or receive has "
897 "actually occurred.\n"
898 ";; IF BLOCKING IS FALSE (normal, default):\n"
899 ";; - no_tries is the number of times OT will try to send or "
900 "receive a message.\n"
901 ";; - ms is the number of milliseconds it will wait between each "
903 ";; UPDATE: send_ms and receive_ms now DOUBLE after each failed "
904 "attempt! (up to 3 tries)\n"
905 ";; Meaning that after 3 tries, it's already waited over 21 "
906 "seconds trying to get\n"
908 ";; send_delay_after happens after EVERY SINGLE server "
909 "request/reply, which can be\n"
910 ";; multiple times per use case. (They can add up quick...)\n";
917 if (
nullptr == m_pSocket) {
928 m_pSocket->
Init(socketDefaults, p_Config);
935 const char* szComment =
936 "; master_key_timeout is how int64_t the master key will be in "
937 "memory until a thread wipes it out.\n"
938 "; 0 : means you have to type your password EVERY time OT uses a "
939 "private key. (Even multiple times in a single function.)\n"
940 "; 300 : means you only have to type it once per 5 minutes.\n"
941 "; -1 : means you only type it once PER RUN (popular for "
948 bIsNewKey, szComment);
954 bool bValue, bIsNewKey;
962 bool bValue, bIsNewKey;
967 #if defined(OT_KEYRING_FLATFILE)
977 OTKeyring::FlatFile_SetPasswordFolder(strValue.
Get());
978 otOut <<
" **DANGEROUS!** Using password folder: " << strValue
986 if (!p_Config->Save()) {
987 otErr << __FUNCTION__ <<
": Error! Unable to save updated Config!!!\n";
992 if (!p_Config->
Reset())
return false;
994 if (
nullptr != p_Config)
delete p_Config;
1003 if (!m_bInitialized) {
1004 otErr << __FUNCTION__
1005 <<
": Not initialized; call OT_API::Init first.\n";
1010 bool bExists = strFilename.
Exists();
1012 otErr << __FUNCTION__ <<
": strFilename dose not exist!\n";
1018 "OT_API::SetWalletFilename: strFilename does not exist.\n");
1020 "OT_API::SetWalletFilename: strFilename is too short.\n");
1023 otOut << __FUNCTION__ <<
": Setting Wallet Filename... \n";
1027 if (strFilename.
Compare(strWalletFilename)) {
1028 otWarn << __FUNCTION__ <<
": Wallet Filename: " << strFilename
1029 <<
" is same as in configuration. (skipping)\n";
1033 strWalletFilename.
Set(strWalletFilename);
1043 if (!p_Config->Load()) {
1044 otOut << __FUNCTION__
1045 <<
": Note: Unable to Load Config. Creating a new file: "
1046 << strConfigFilePath <<
"\n";
1047 if (!p_Config->
Reset())
return false;
1048 if (!p_Config->Save())
return false;
1051 if (!p_Config->
Reset())
return false;
1054 if (!p_Config->Load()) {
1055 otErr << __FUNCTION__
1056 <<
": Error: Unable to load config file: " << strConfigFilePath
1057 <<
" It should exist, as we just saved it!\n";
1064 p_Config->
Set_str(
"wallet",
"wallet_filename", strWalletFilename,
1065 bNewOrUpdated,
"; Wallet updated\n");
1071 if (!p_Config->Save()) {
1072 otErr << __FUNCTION__ <<
": Error! Unable to save updated Config!!!\n";
1077 if (!p_Config->
Reset())
return false;
1079 otOut << __FUNCTION__ <<
": Updated Wallet filename: " << strWalletFilename
1087 return (
nullptr != m_pWallet) ?
true :
false;
1093 "Not initialized; call OT_API::Init first.\n");
1096 "Default Storage not Initialized; call OT_API::Init first.\n");
1099 bool bGetWalletFilenameSuccess =
1103 bGetWalletFilenameSuccess,
1104 "OT_API::GetWalletFilename failed, wallet filename isn't set!");
1107 otInfo <<
"m_pWallet->LoadWallet() with: " << strWalletFilename <<
"\n";
1108 bool bSuccess = m_pWallet->
LoadWallet(strWalletFilename.Get());
1112 <<
": Success invoking m_pWallet->LoadWallet() with filename: "
1113 << strWalletFilename <<
"\n";
1115 otErr << __FUNCTION__
1116 <<
": Failed invoking m_pWallet->LoadWallet() with filename: "
1117 << strWalletFilename <<
"\n";
1144 otErr << __FUNCTION__ <<
": Error: OT_API is not Initialized!\n";
1147 if (
nullptr == m_pClient) {
1148 otErr << __FUNCTION__ <<
": Error: m_pClient is a nullptr!\n";
1152 otErr << __FUNCTION__ <<
": Error: m_pConnection is a nullptr!\n";
1156 if (
nullptr == pNym) {
1157 otErr << __FUNCTION__ <<
": Error: pNym is a nullptr!\n";
1160 if (
nullptr == m_pSocket) {
1161 otErr << __FUNCTION__ <<
": Error: m_Socket is a nullptr!\n";
1164 if (
nullptr == m_pSocket->
GetMutex()) {
1165 otErr << __FUNCTION__ <<
": Error: m_Socket is a nullptr!\n";
1169 otErr << __FUNCTION__ <<
": Error: m_Socket is not Initialized!\n";
1172 std::lock_guard<std::mutex> lock(*m_pSocket->
GetMutex());
1173 int32_t nServerPort = 0;
1177 theServerContract.
GetConnectInfo(strServerHostname, nServerPort)) {
1178 otErr << __FUNCTION__
1179 <<
": Failed retrieving connection info from server contract.\n";
1183 strConnectPath.
Format(
"tcp://%s:%d", strServerHostname.
Get(), nServerPort);
1187 if (ascEnvelope.
Exists()) {
1193 bool bSuccessSending =
1194 m_pSocket->
Send(ascEnvelope, strConnectPath);
1196 if (!bSuccessSending) {
1197 otErr << __FUNCTION__
1198 <<
": Failed, even with error correction and retries, "
1199 "while trying to send message to server.";
1203 bool bSuccessReceiving =
1204 m_pSocket->
Receive(strRawServerReply);
1206 if (!bSuccessReceiving || !strRawServerReply.
Exists()) {
1207 otErr << __FUNCTION__
1208 <<
": Failed trying to receive expected reply "
1213 const bool bLoaded =
1214 strRawServerReply.
Exists() &&
1217 bool bRetrievedReply =
false;
1219 otErr << __FUNCTION__
1220 <<
": Failed trying to load OTASCIIArmor "
1221 "object from string:\n\n" << strRawServerReply
1224 else if (strRawServerReply.Contains(
1232 theServerEnvelope.
Open(*pNym, strServerReply);
1235 otErr << __FUNCTION__
1236 <<
": Failed: while setting "
1237 "OTASCIIArmor'd string into an "
1259 else if (strRawServerReply.Contains(
"MESSAGE"))
1265 bRetrievedReply = ascServerReply.
GetString(strServerReply);
1268 otErr << __FUNCTION__
1269 <<
": Error: Unknown reply type received from "
1270 "server. (Expected envelope or message.)\n"
1271 "\n\n PERHAPS YOU ARE RUNNING AN OLD VERSION "
1272 "OF THE SERVER ????? \n\n";
1277 if (bRetrievedReply && strServerReply.
Exists() &&
1286 if (
nullptr != pServerReply)
delete pServerReply;
1287 pServerReply =
nullptr;
1289 otErr << __FUNCTION__
1290 <<
": Error loading server reply from string:\n\n"
1291 << strRawServerReply <<
"\n\n";
1303 if (
nullptr != pWallet)
return pWallet->
GetNymCount();
1340 if (
nullptr != pWallet)
return pWallet->
GetNym(iIndex, NYM_ID, NYM_NAME);
1350 if (
nullptr != pWallet)
return pWallet->
GetServer(iIndex, THE_ID, THE_NAME);
1360 if (
nullptr != pWallet)
1361 return pWallet->
GetAssetType(iIndex, THE_ID, THE_NAME);
1371 if (
nullptr != pWallet)
1372 return pWallet->
GetAccount(iIndex, THE_ID, THE_NAME);
1380 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
1381 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
1383 if (
nullptr == pWallet)
1384 otOut << szFunc <<
": -- The Wallet is not loaded.\n";
1389 const char* szFunc)
const
1392 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
1397 if (
nullptr != pWallet) {
1399 if ((
nullptr == pNym) &&
1400 (
nullptr != szFunc))
1403 otWarn << __FUNCTION__ <<
" " << szFunc
1404 <<
": No Nym found in wallet with ID: " << strID <<
"\n";
1412 const char* szFunc)
const
1415 if (
nullptr != pWallet) {
1417 if ((
nullptr == pContract) &&
1418 (
nullptr != szFunc))
1421 otWarn << __FUNCTION__ <<
" " << szFunc
1422 <<
": No server contract found "
1423 "in wallet with ID: " << strID <<
"\n";
1431 const char* szFunc)
const
1434 if (
nullptr != pWallet) {
1436 if ((
nullptr == pContract) &&
1437 (
nullptr != szFunc))
1440 otWarn << __FUNCTION__ <<
" " << szFunc
1441 <<
": No asset contract "
1442 "found in wallet with ID: " << strID <<
"\n";
1450 const char* szFunc)
const
1453 if (
nullptr != pWallet) {
1455 if ((
nullptr == pAcct) &&
1456 (
nullptr != szFunc))
1459 otWarn << __FUNCTION__ <<
" " << szFunc
1460 <<
": No account found in "
1461 "wallet with ID: " << strID <<
"\n";
1469 const char* szFuncName)
const
1471 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
1479 const std::string PARTIAL_ID,
const char* szFuncName)
const
1481 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
1483 if (
nullptr != pWallet)
1490 const std::string PARTIAL_ID,
const char* szFuncName)
const
1492 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
1494 if (
nullptr != pWallet)
1501 const char* szFuncName)
const
1503 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
1515 const std::string str_id_source,
1516 const std::string str_alt_location)
const
1518 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
1526 otErr << __FUNCTION__ <<
": Failure: nKeySize must be one of: "
1527 "1024, 2048, 4096, 8192. (" << nKeySize
1528 <<
" was passed...)\n";
1533 if (
nullptr == pWallet)
return nullptr;
1538 pNym->
GenerateNym(nKeySize,
true, str_id_source, str_alt_location)) {
1539 otErr << __FUNCTION__ <<
": Failed trying to generate Nym.\n";
1557 otErr << __FUNCTION__
1558 <<
": Error: Failed in pWallet->ConvertNymToCachedKey \n";
1571 const OTString& STR_NEW_NAME)
const
1575 if (
nullptr == pWallet)
return false;
1579 if (
nullptr == pContract)
return false;
1582 if (!STR_NEW_NAME.
Exists())
1583 otOut <<
"OT_API::SetAssetType_Name: Bad: name is empty.\n";
1585 pContract->
SetName(STR_NEW_NAME);
1598 const OTString& STR_NEW_NAME)
const
1602 if (
nullptr == pWallet)
return false;
1606 if (
nullptr == pContract)
return false;
1609 if (!STR_NEW_NAME.
Exists())
1610 otOut << __FUNCTION__ <<
": Bad: name is empty.\n";
1612 pContract->
SetName(STR_NEW_NAME);
1623 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
1627 GetNym(NYM_ID, __FUNCTION__);
1628 if (
nullptr == pNym)
return false;
1631 const OTString strServerID(SERVER_ID);
1699 if (!bInitialized) {
1700 otErr << __FUNCTION__
1701 <<
": Not initialized; call OT_API::Init first.\n";
1706 if (
nullptr == pWallet)
return false;
1708 OTString strReason(
"Enter existing wallet master passphrase");
1712 const bool bGotOldPassphrase =
1713 (ptrMasterKey && ptrMasterKey->IsGenerated() &&
1714 ptrMasterKey->GetMasterPassword(ptrMasterKey, old_passphrase,
1718 std::list<OTPseudonym*>* m_plist_nyms;
1722 ot_change_pw(std::list<OTPseudonym*>& list_nyms)
1723 : m_plist_nyms(&list_nyms)
1728 if (
nullptr != m_plist_nyms) {
1729 while (!m_plist_nyms->empty())
1731 auto it = m_plist_nyms->begin();
1737 m_plist_nyms->erase(it);
1742 std::list<OTPseudonym*> list_nyms;
1745 ot_change_pw the_cleanup(list_nyms);
1748 bool bAtLeastOneNymHasCredentials =
false;
1749 bool bSuccessLoading =
1755 for (int32_t iii = 0; iii < nNymCount; ++iii) {
1759 const bool bGotNym = pWallet->
GetNym(iii, NYM_ID, NYM_NAME);
1783 if (
nullptr == pNym)
1787 bSuccessLoading =
false;
1791 list_nyms.push_back(pNym);
1795 bAtLeastOneNymHasCredentials =
true;
1798 if (!bSuccessLoading) {
1799 otErr << __FUNCTION__
1800 <<
": Error: Failed to load all the private Nyms. Wrong "
1801 "passphrase? (Aborting operation.)\n";
1810 OTPasswordData thePWData(
"Enter existing wallet master passphrase");
1824 if (bAtLeastOneNymHasCredentials)
1831 bool bSuccessReEncrypting =
true;
1832 for (
auto& it : list_nyms) {
1856 bSuccessReEncrypting =
false;
1863 if (!bSuccessReEncrypting)
1867 <<
": Failed trying to re-encrypt Nym's private credentials.\n";
1888 strReason.
Set(
"Choose a new passphrase: ");
1902 const bool bRegenerate =
1903 sharedPtr->GetMasterPassword(sharedPtr, new_passphrase, strReason.
Get(),
1907 otErr << __FUNCTION__ <<
": Error: Failed while trying to regenerate "
1908 "master key, in call: "
1909 "OTCachedKey::It()->GetMasterPassword. "
1910 "(Setting it back to the old "
1913 otErr << __FUNCTION__
1914 <<
": Error: Failed while trying to restore master "
1916 "OTCachedKey::It()->GetMasterPassword. (While "
1917 "setting it back to the old one.)\n"
1918 "Original value: \n" << ascBackup <<
"\n";
1942 bool bSuccessResaving =
1946 for (
auto& it : list_nyms) {
1949 bool bSaved =
false;
1967 bool bSavedCredentials =
false;
1971 &thePWData, &theTempPassword);
1975 bSavedCredentials =
true;
1976 OTString strNymID, strCredList, strOutput;
1982 strFilename.
Format(
"%s.cred", strNymID.
Get());
1987 "CREDENTIAL LIST") &&
1991 strFilename.
Get())) {
1992 otErr << __FUNCTION__
1993 <<
": After converting credentials to "
1994 "new master key, failure trying to "
1996 "credential list for Nym: " << strNymID
1998 bSavedCredentials =
false;
2002 for (
auto& it : mapCredFiles) {
2003 std::string str_cred_id = it.first;
2007 if (ascLoopArmor.
Exists() &&
2015 strNymID.
Get(), str_cred_id)) {
2016 otErr << __FUNCTION__
2017 <<
": After converting "
2018 "credentials to new master key, "
2019 "failure trying to store private "
2020 "credential for Nym: " << strNymID
2022 bSavedCredentials =
false;
2027 bSaved = bImported && bSavedCredentials;
2038 if (!bSaved) bSuccessResaving =
false;
2040 if (!bSuccessResaving)
2045 otErr << __FUNCTION__
2046 <<
": ERROR: Failed re-saving Nym (into new Master "
2047 "Key.) It's possible "
2048 "some Nyms are already saved on the new key, while "
2049 "others are still stuck "
2050 "on the old key!! Therefore, asserting now. OLD KEY "
2051 "was:\n" << ascBackup <<
"\n\n NEW KEY is: " << ascBackup2
2055 OT_FAIL_MSG(
"ASSERT while trying to change wallet's master key and "
2066 if (bGotOldPassphrase) {
2069 otErr << __FUNCTION__
2071 "pWallet->ChangePassphrasesOnExtraKeys "
2073 "(Continuing, but your extra symmetric keys "
2075 "may be messed up!)\n";
2092 bool bLoaded =
false;
2103 otErr << __FUNCTION__ <<
": Failed saving wallet \n";
2118 <<
": ERROR: Failed saving or re-loading Wallet (with new "
2120 "Asserting now. OLD KEY was:\n" << ascBackup
2121 <<
"\n\n NEW KEY is: " << ascBackup2 <<
"\n";
2124 OT_FAIL_MSG(
"ASSERT while trying to save and re-load wallet "
2125 "with new master key and passphrase.\n");
2128 otOut <<
"\nSuccess changing master passphrase for wallet!\n";
2138 if (!bInitialized) {
2139 otErr << __FUNCTION__
2140 <<
": Not initialized; call OT_API::Init first.\n";
2144 otErr << __FUNCTION__ <<
": Null: SERVER_ID passed in!\n";
2151 for (int32_t i = 0; i < nCount; i++) {
2160 if (SERVER_ID == purportedServerID) {
2161 OTString strPurportedServerID(purportedServerID),
2162 strSERVER_ID(SERVER_ID);
2163 otOut << __FUNCTION__ <<
": Unable to remove server contract "
2164 << strSERVER_ID <<
" from wallet, because Account "
2165 << strPurportedServerID <<
" uses it.\n";
2174 for (int32_t i = 0; i < nNymCount; i++) {
2181 OTString strNymID(nymID), strSERVER_ID(SERVER_ID);
2182 otOut << __FUNCTION__ <<
": Unable to remove server contract "
2183 << strSERVER_ID <<
" "
2184 "from wallet, because Nym " << strNymID
2185 <<
" is registered "
2186 "there. (Delete that first...)\n";
2203 if (!bInitialized) {
2204 otErr << __FUNCTION__
2205 <<
": Not initialized; call OT_API::Init first.\n";
2210 otErr << __FUNCTION__ <<
": Null: ASSET_ID passed in!\n";
2217 for (int32_t i = 0; i < nCount; i++) {
2225 if (ASSET_ID == theTYPE_ID) {
2226 OTString strASSET_ID(ASSET_ID), strTYPE_ID(theTYPE_ID);
2228 otOut << __FUNCTION__ <<
": Unable to remove asset contract "
2229 << strASSET_ID <<
" from wallet: Account " << strTYPE_ID
2250 if (!bInitialized) {
2251 otErr << __FUNCTION__
2252 <<
": Not initialized; call OT_API::Init first.\n";
2257 otErr << __FUNCTION__ <<
": Null: NYM_ID passed in!\n";
2262 if (
nullptr == pNym)
return false;
2269 for (int32_t i = 0; i < nCount; i++) {
2278 if (theNYM_ID.IsEmpty()) {
2279 otErr << __FUNCTION__ <<
": Bug in OT_API_Wallet_CanRemoveNym / "
2280 "OT_API_GetAccountWallet_NymID\n";
2285 if (NYM_ID == theNYM_ID) {
2286 otOut << __FUNCTION__
2287 <<
": Nym cannot be removed because there are "
2288 "still accounts in the wallet for that Nym.\n";
2298 for (int32_t i = 0; i < nServerCount; i++) {
2308 otOut << __FUNCTION__
2309 <<
": Nym cannot be removed because there "
2310 "are still servers in the wallet that "
2311 "the Nym is registered at.\n";
2335 if (!bInitialized) {
2336 otErr << __FUNCTION__
2337 <<
": Not initialized; call OT_API::Init first.\n";
2342 otErr << __FUNCTION__ <<
": Null: ACCOUNT_ID passed in!\n";
2346 const OTString strAccountID(ACCOUNT_ID);
2350 if (
nullptr == pAccount)
return false;
2353 otOut << __FUNCTION__
2354 <<
": Account balance MUST be zero in order to close "
2355 "an asset account: " << strAccountID <<
".\n";
2358 bool BOOL_RETURN_VALUE =
false;
2365 std::unique_ptr<OTLedger> pInbox(
2367 std::unique_ptr<OTLedger> pOutbox(
2370 if (
nullptr == pInbox) {
2371 otOut << __FUNCTION__
2372 <<
": Failure calling OT_API::LoadInbox.\n Account ID: "
2373 << strAccountID <<
"\n";
2375 else if (
nullptr == pOutbox) {
2376 otOut << __FUNCTION__
2377 <<
": Failure calling OT_API::LoadOutbox.\n Account ID: "
2378 << strAccountID <<
"\n";
2380 else if ((pInbox->GetTransactionCount() > 0) ||
2381 (pOutbox->GetTransactionCount() > 0)) {
2382 otOut << __FUNCTION__
2383 <<
": Failure: You cannot remove an asset account if "
2384 "there are inbox/outbox items still waiting to be "
2388 BOOL_RETURN_VALUE =
true;
2390 return BOOL_RETURN_VALUE;
2402 if (!bInitialized) {
2403 otErr << __FUNCTION__
2404 <<
": Not initialized; call OT_API::Init first.\n";
2409 otErr << __FUNCTION__ <<
": Null: ASSET_ID passed in!\n";
2430 if (
nullptr == m_pWallet) {
2431 otErr << __FUNCTION__ <<
": No wallet found...\n";
2437 otOut << __FUNCTION__ <<
": Removed server contract from the wallet: "
2453 if (!bInitialized) {
2454 otErr << __FUNCTION__
2455 <<
": Not initialized; call OT_API::Init first.\n";
2460 otErr << __FUNCTION__ <<
": Null: ASSET_ID passed in!\n";
2467 if (
nullptr == m_pWallet) {
2468 otErr << __FUNCTION__ <<
": No wallet found...!\n";
2474 otOut << __FUNCTION__ <<
": Removed asset contract from the wallet: "
2490 if (!bInitialized) {
2491 otErr << __FUNCTION__
2492 <<
": Not initialized; call OT_API::Init first.\n";
2497 otErr << __FUNCTION__ <<
": Null: ACCOUNT_ID passed in!\n";
2517 if (
nullptr == m_pWallet) {
2518 otErr << __FUNCTION__ <<
": No wallet found...!\n";
2523 otOut << __FUNCTION__
2524 <<
": Success erasing Nym from wallet: " <<
OTString(NYM_ID)
2530 otOut << __FUNCTION__
2531 <<
": Failure erasing Nym from wallet: " <<
OTString(NYM_ID)
2547 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
2551 OTPasswordData thePWDataSave(
"Create new passphrase for exported Nym.");
2556 if (
nullptr == pNym)
return false;
2557 std::string str_nym_name(pNym->GetNymName().Get());
2559 pNym->GetIdentifier(strID);
2560 std::string str_nym_id(strID.Get());
2567 const bool bHasCredentials = (pNym->GetMasterCredentialCount() > 0);
2571 bool bSavedCert =
false;
2572 if (!bHasCredentials) {
2576 bSavedCert = pNym->Savex509CertAndPrivateKeyToString(strCertfile,
2586 const bool bReEncrypted = pNym->ReEncryptPrivateCredentials(
2593 std::unique_ptr<OTDB::Storable> pStorable(
2597 if (
nullptr == pMap)
2598 otErr << __FUNCTION__
2599 <<
": Error: failed trying to load or create a "
2600 "STORED_OBJ_STRING_MAP.\n";
2606 pNym->GetPrivateCredentials(strCredList, &theMap);
2610 if (strCredList.
Exists() && (!theMap.empty())) {
2612 const bool bSuccessEncoding = (str_Encoded.size() > 0);
2613 if (bSuccessEncoding) {
2617 str_Encoded.c_str());
2628 otErr << __FUNCTION__
2629 <<
": Failed while saving Nym's private cert, or private "
2630 "credentials, to string.\n"
2631 "Reason I was doing this: \""
2636 const bool bSavedNym = pNym->SavePseudonym(strNymfile);
2639 otErr << __FUNCTION__
2640 <<
": Failed while calling "
2641 "pNym->SavePseudonym(strNymfile) (to string)\n";
2654 std::unique_ptr<OTDB::Storable> pStorable(
2659 if (
nullptr == pMap) {
2660 otErr << __FUNCTION__ <<
": Error: failed trying to load or create a "
2661 "STORED_OBJ_STRING_MAP.\n";
2665 theMap[
"id"] = str_nym_id;
2666 theMap[
"name"] = str_nym_name;
2667 theMap[
"nymfile"] = strNymfile.
Get();
2669 if (strCertfile.
Exists()) theMap[
"certfile"] = strCertfile.
Get();
2671 if (ascCredList.
Exists()) theMap[
"credlist"] = ascCredList.
Get();
2673 if (ascCredentials.
Exists()) theMap[
"credentials"] = ascCredentials.
Get();
2677 bool bReturnVal = (str_Encoded.size() > 0);
2681 ascTemp.
Set(str_Encoded.c_str());
2684 strOutput,
"EXPORTED NYM"
2706 if (
nullptr == pWallet)
return false;
2710 ascArmor, FILE_CONTENTS);
2711 if (!bLoadedArmor || !ascArmor.
Exists()) {
2712 otErr << __FUNCTION__
2713 <<
": Failure loading string into OTASCIIArmor object:\n\n"
2714 << FILE_CONTENTS <<
"\n\n";
2717 std::unique_ptr<OTDB::Storable> pStorable(
2721 if (
nullptr == pMap) {
2722 otOut << __FUNCTION__
2723 <<
": Failed decoding StringMap object while trying "
2724 "to import Nym:\n" << FILE_CONTENTS <<
"\n";
2727 std::map<std::string, std::string>& theMap = pMap->
the_map;
2739 if (theMap.end() == theMap.find(
"id"))
2742 otOut << __FUNCTION__
2743 <<
": Unable to find 'id' field while trying to import Nym:\n"
2744 << FILE_CONTENTS <<
"\n";
2747 if (theMap.end() == theMap.find(
"name"))
2750 otOut << __FUNCTION__
2751 <<
": Unable to find 'name' field while trying to import Nym:\n"
2752 << FILE_CONTENTS <<
"\n";
2755 if (theMap.end() == theMap.find(
"nymfile"))
2758 otOut << __FUNCTION__
2759 <<
": Unable to find 'nymfile' field while trying to "
2760 "import Nym:\n" << FILE_CONTENTS <<
"\n";
2763 if ((theMap.end() == theMap.find(
"certfile")) &&
2764 (theMap.end() == theMap.find(
"credlist")))
2769 otOut << __FUNCTION__
2770 <<
": Unable to find a 'certfile' nor a 'credlist' "
2771 "field while trying to import Nym:\n" << FILE_CONTENTS <<
"\n";
2780 const OTString strNymName(theMap[
"name"].c_str());
2782 if (
nullptr != pNymID) pNymID->
SetString(theMap[
"id"].c_str());
2784 otErr << __FUNCTION__
2785 <<
": Error: NYM_ID passed in is empty; returning false";
2791 theNymID,
true, __FUNCTION__));
2793 if (
nullptr != pNym)
2795 otOut << __FUNCTION__
2796 <<
": Tried to import a Nym that's already in wallet: "
2797 << theMap[
"id"] <<
"\n";
2806 pNym->SetNymName(strNymName);
2818 OTString strDisplay(
"Enter passphrase for the Nym being imported.");
2825 std::unique_ptr<OTPassword> pExportPassphrase(
2828 if (
nullptr == pExportPassphrase) {
2829 otErr << __FUNCTION__ <<
": Failed in GetPassphraseFromUser.\n";
2847 bool bIfNymLoadKeys =
false;
2849 "(ImportNym) To import this Nym, what is its passphrase? ");
2851 "(ImportNym) What is your wallet's master passphrase? ");
2855 auto it_credlist = theMap.find(
"credlist");
2856 auto it_credentials = theMap.find(
"credentials");
2857 bool bHasCredentials =
false;
2860 if (theMap.end() != it_credlist) {
2863 if (it_credlist->second.size() > 0) {
2864 ascCredList.
Set(it_credlist->second.c_str());
2869 if (strCredList.
Exists() &&
2870 (theMap.end() != it_credentials))
2873 if (it_credentials->second.size() > 0) {
2874 ascCredentials.
Set(it_credentials->second.c_str());
2875 std::unique_ptr<OTDB::Storable> pPrivateStorable(
2877 ascCredentials.
Get()));
2880 if (
nullptr == pPrivateMap) {
2881 otOut << __FUNCTION__
2882 <<
": Failed decoding StringMap object.\n";
2890 pNym->LoadFromString(strCredList, &thePrivateMap,
2892 pExportPassphrase.get())) {
2893 otErr << __FUNCTION__ <<
": Failure loading nym "
2894 << strNymID <<
" from credential string.\n";
2899 bIfNymLoadKeys =
true;
2900 bHasCredentials =
true;
2907 else if (theMap.end() != theMap.find(
"certfile")) {
2908 const OTString strCert(theMap[
"certfile"]);
2909 bIfNymLoadKeys = pNym->Loadx509CertAndPrivateKeyFromString(
2910 strCert, &thePWDataLoad, pExportPassphrase.get());
2923 if (bIfNymLoadKeys && pNym->VerifyPseudonym()) {
2928 if (bHasCredentials &&
2929 !pNym->ReEncryptPrivateCredentials(
true, &thePWDataLoad,
2930 pExportPassphrase.get()))
2935 <<
": Failed trying to re-encrypt Nym's private credentials.\n";
2940 const OTString strNymfile(theMap[
"nymfile"]);
2942 bool bConverted =
false;
2943 const bool bLoaded =
2944 (strNymfile.
Exists() && pNym->LoadFromString(strNymfile));
2958 pWallet->
AddNym(*(pNym.release()));
2964 otErr << __FUNCTION__
2965 <<
": Failed while calling "
2966 "pWallet->ConvertNymToCachedKey(*pNym)\n";
2973 otErr << __FUNCTION__ <<
": Failed loading nymfile from string.\n";
2977 if (bLoaded && bConverted)
2981 if (!pNym->SaveSignedNymfile(*pNym)) {
2982 otErr << __FUNCTION__
2983 <<
": Error: Failed calling SaveSignedNymfile.\n";
2989 otErr << __FUNCTION__
2990 <<
": Error: Failed to save (updated) wallet.\n";
2998 otErr << __FUNCTION__
2999 <<
": Failed loading or verifying keys|credentials|pseudonym.\n";
3024 if (
nullptr == pWallet)
return false;
3034 std::unique_ptr<OTPseudonym> pNym(
new OTPseudonym);
3036 if (DISPLAY_NAME.
Exists()) pNym->SetNymName(DISPLAY_NAME);
3046 OTPasswordData thePWData(
"To import this Cert, what is its passphrase? ");
3047 const bool bIfNymLoadKeys =
3048 pNym->Loadx509CertAndPrivateKeyFromString(FILE_CONTENTS, &thePWData);
3055 if (bIfNymLoadKeys && pNym->SetIdentifierByPubkey()) {
3056 if (
nullptr != pNymID) *pNymID = pNym->GetConstID();
3061 if (
nullptr != pTempNym)
3063 const OTString strNymID(pNym->GetConstID());
3064 otOut << __FUNCTION__
3065 <<
": Tried to import the Cert for a Nym that's "
3066 "already in wallet: " << strNymID <<
"\n";
3071 pWallet->
AddNym(*(pNym.release()));
3076 otErr << __FUNCTION__ <<
": Failed while calling "
3077 "pWallet->ConvertNymToCachedKey(*pNym)\n";
3080 pNym->SaveSignedNymfile(*pNym);
3087 otErr << __FUNCTION__
3088 <<
": Failed loading or verifying key from cert string.\n";
3096 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
3100 "Need Wallet Master passphrase to export any Cert.");
3101 OTPasswordData thePWDataSave(
"Create new passphrase for exported Cert.");
3106 if (
nullptr == pNym)
return false;
3115 const bool bSavedCert =
3116 pNym->Savex509CertAndPrivateKeyToString(strCertfile, &strReasonToSave);
3123 otErr << __FUNCTION__
3124 <<
": Failed while calling "
3125 "pNym->Savex509CertAndPrivateKeyToString(strCertfile, "
3129 if (strCertfile.
Exists()) {
3145 const bool bSuccess = tempNewList.Add(theNewNumbers);
3149 theList.Add(tempNewList);
3158 OTNumList tempNewList(theList), tempOldList(theOldNumbers);
3160 while (tempOldList.
Count() > 0) {
3165 if (!tempNewList.Remove(lPeek))
return false;
3169 theList.Add(tempNewList);
3178 OTNumList theTempQuery(theQueryNumbers);
3180 while (theTempQuery.
Count() > 0) {
3185 if (!theList.
Verify(lPeek))
return false;
3196 return theList.
Verify(theQueryNumbers);
3201 return theList.
Count();
3230 bool bLineBreaks)
const
3233 bool bSuccess = ascArmor.
SetString(strPlaintext, bLineBreaks);
3238 strOutput,
"ENCODED TEXT"
3258 bool bLineBreaks)
const
3262 ascArmor, strEncoded);
3263 if (!bLoadedArmor || !ascArmor.
Exists()) {
3264 otErr << __FUNCTION__
3265 <<
": Failure loading string into OTASCIIArmor object:\n\n"
3266 << strEncoded <<
"\n\n";
3270 const bool bSuccess = ascArmor.
GetString(strOutput, bLineBreaks);
3299 if (
nullptr == pRecipientNym)
return false;
3301 bool bSuccess = theEnvelope.
Seal(*pRecipientNym, strPlaintext);
3308 strOutput,
"ENCRYPTED TEXT"
3344 if (
nullptr == pRecipientNym)
return false;
3348 ascCiphertext, strCiphertext);
3349 if (!bLoadedArmor || !ascCiphertext.
Exists()) {
3350 otErr << __FUNCTION__
3351 <<
": Failure loading string into OTASCIIArmor object:\n\n"
3352 << strCiphertext <<
"\n\n";
3357 return theEnvelope.
Open(*pRecipientNym, strOutput);
3372 theSignerNymID,
false, __FUNCTION__);
3373 if (
nullptr == pNym)
return false;
3376 if (!strInput.
Exists()) {
3377 otOut << __FUNCTION__
3378 <<
": Empty contract passed in. (Returning false.)\n";
3381 if (!strContractType.
Exists()) {
3382 otOut << __FUNCTION__
3383 <<
": Empty contract type passed in. (Returning false.)\n";
3412 theSignerNymID,
false, __FUNCTION__);
3413 if (
nullptr == pNym)
return false;
3416 if (!strContract.
Exists()) {
3417 otOut << __FUNCTION__
3418 <<
": Empty contract passed in. (Returning false.)\n";
3422 std::unique_ptr<OTContract> pContract(
3425 if (
nullptr == pContract)
3428 if (
nullptr == pContract)
3429 pContract.reset(::InstantiateContract(strContract));
3431 if (
nullptr == pContract) {
3432 otOut << __FUNCTION__ <<
": I tried my best. "
3433 "Unable to instantiate contract passed in:\n\n"
3434 << strContract <<
"\n\n";
3438 pContract->ReleaseSignatures();
3439 pContract->SignContract(*pNym);
3440 pContract->SaveContract();
3442 pContract->SaveContractRaw(strOutput);
3467 theSignerNymID,
false, __FUNCTION__);
3468 if (
nullptr == pNym)
return false;
3471 if (!strContract.
Exists()) {
3472 otOut << __FUNCTION__
3473 <<
": Empty contract passed in. (Returning false.)\n";
3477 std::unique_ptr<OTContract> pContract(
3480 if (
nullptr == pContract)
3483 if (
nullptr == pContract)
3484 pContract.reset(::InstantiateContract(strContract));
3486 if (
nullptr == pContract) {
3487 otOut << __FUNCTION__
3488 <<
": I tried my best. Unable to instantiate contract "
3489 "passed in:\n\n" << strContract <<
"\n\n";
3497 pContract->SignContract(*pNym);
3498 pContract->SaveContract();
3500 pContract->SaveContractRaw(strOutput);
3525 GetOrLoadNym(theSignerNymID,
false, __FUNCTION__,
3527 if (
nullptr == pNym)
return false;
3530 if (!strContract.Exists()) {
3531 otOut <<
"OT_API::VerifySignature: Empty contract passed in. "
3532 "(Returning false.)\n";
3537 std::unique_ptr<OTContract> theAngel;
3539 if (
nullptr == pContract)
3542 if (
nullptr == pContract)
3545 if (
nullptr == pContract) pContract = ::InstantiateContract(strContract);
3547 if (
nullptr == pContract) {
3548 otOut <<
"OT_API::VerifySignature: I tried my best. Unable to "
3549 "instantiate contract passed in:\n\n" << strContract <<
"\n\n";
3557 if (
nullptr != ppContract) *ppContract = pContract;
3560 theAngel.reset(pContract);
3580 OTString strSignerNymID(theSignerNymID);
3581 otOut <<
"OT_API::VerifySignature: For Nym (" << strSignerNymID
3583 "verify signature on contract passed in:\n\n" << strContract
3605 const bool bSuccess =
3612 std::unique_ptr<OTContract> theAngel(pContract);
3635 USER_ID,
false, __FUNCTION__);
3636 if (
nullptr == pNym)
return false;
3641 if (
nullptr == pServer)
return false;
3645 if (
nullptr == pServerNym) {
3646 otErr <<
"OT_API::VerifyAccountReceipt: should never happen. "
3647 "pServerNym is nullptr.\n";
3650 return VerifyBalanceReceipt(*pServerNym, *pNym, SERVER_ID, ACCOUNT_ID);
3662 SIGNER_NYM_ID,
false, __FUNCTION__);
3663 if (
nullptr == pNym)
return false;
3668 "OT_API::Create_SmartContract: ASSERT "
3669 "while trying to instantiate blank smart "
3672 otOut <<
"OT_API::Create_SmartContract: Failed trying to set date "
3696 SIGNER_NYM_ID,
false, __FUNCTION__);
3697 if (
nullptr == pNym)
return false;
3700 std::unique_ptr<OTScriptable> pContract(
3702 if (
nullptr == pContract) {
3703 otOut << __FUNCTION__ <<
": Error loading smart contract:\n\n"
3704 << THE_CONTRACT <<
"\n\n";
3707 const std::string str_party_name(PARTY_NAME.
Get()),
3708 str_agent_name(AGENT_NAME.
Get());
3710 OTParty* pParty = pContract->GetParty(str_party_name);
3712 if (
nullptr != pParty) {
3713 otOut << __FUNCTION__ <<
": Failure: Party already exists. \n";
3717 pParty =
new OTParty(str_party_name.c_str(),
true ,
3719 str_agent_name.c_str(),
3723 if (!pContract->AddParty(*pParty))
3725 otOut << __FUNCTION__
3726 <<
": Failed while trying to add party: " << PARTY_NAME <<
" \n";
3733 pContract->ReleaseSignatures();
3734 pContract->SignContract(*pNym);
3735 pContract->SaveContract();
3737 pContract->SaveContractRaw(strOutput);
3755 SIGNER_NYM_ID,
false, __FUNCTION__);
3756 if (
nullptr == pNym)
return false;
3759 std::unique_ptr<OTScriptable> pContract(
3761 if (
nullptr == pContract) {
3762 otOut <<
"OT_API::SmartContract_AddAccount: Error loading "
3763 "smart contract:\n\n" << THE_CONTRACT <<
"\n\n";
3766 const std::string str_party_name(PARTY_NAME.
Get());
3768 OTParty* pParty = pContract->GetParty(str_party_name);
3770 if (
nullptr == pParty) {
3771 otOut <<
"OT_API::SmartContract_AddAccount: Failure: Party "
3772 "doesn't exist. \n";
3775 const std::string str_name(ACCT_NAME.
Get()),
3776 str_asset_id(ASSET_TYPE_ID.
Get());
3778 if (
nullptr != pParty->GetAccount(str_name)) {
3779 otOut <<
"OT_API::SmartContract_AddAccount: Failed adding: "
3780 "account is already there with that name (" << str_name
3782 "party: " << str_party_name <<
" \n";
3785 const OTString strAgentName, strAcctName(str_name.c_str()), strAcctID,
3786 strAssetTypeID(str_asset_id.c_str());
3789 pParty->AddAccount(strAgentName, strAcctName, strAcctID, strAssetTypeID,
3791 otOut <<
"OT_API::SmartContract_AddAccount: Failed trying to "
3792 "add account (" << str_name <<
") to party: " << str_party_name
3798 pContract->ReleaseSignatures();
3799 pContract->SignContract(*pNym);
3800 pContract->SaveContract();
3802 pContract->SaveContractRaw(strOutput);
3813 int32_t nReturnValue = 0;
3814 const std::string str_agent_name(AGENT_NAME.Get());
3815 std::unique_ptr<OTScriptable> pContract(
3818 if (
nullptr == pContract) {
3819 otOut <<
"OT_API::SmartContract_CountNumsNeeded: Error loading "
3820 "smart contract. \n";
3821 return nReturnValue;
3831 nReturnValue = pContract->GetCountTransNumsNeededForAgent(str_agent_name);
3832 return nReturnValue;
3844 SIGNER_NYM_ID,
false, __FUNCTION__);
3845 if (
nullptr == pNym)
return false;
3850 if (
nullptr == pAccount)
return false;
3853 std::unique_ptr<OTScriptable> pScriptable(
3855 if (
nullptr == pScriptable) {
3856 otOut << __FUNCTION__ <<
": Error loading smart contract:\n\n"
3857 << THE_CONTRACT <<
"\n\n";
3862 if (
nullptr == pContract) {
3863 otOut << __FUNCTION__
3864 <<
": Failure casting to Smart Contract. "
3865 "Are you SURE it's a smart contract? Contents:\n"
3866 << THE_CONTRACT <<
"\n";
3869 const std::string str_party_name(PARTY_NAME.
Get());
3871 if (
nullptr == pParty) {
3872 otOut << __FUNCTION__
3873 <<
": Failure: Party doesn't exist: " << PARTY_NAME <<
" \n";
3880 if (
nullptr != pDupeAcct)
3882 otOut << __FUNCTION__ <<
": Failed, since a duplicate account ID ("
3883 << ACCT_ID <<
") was already found on this contract. (Server "
3884 "disallows, sorry.)\n";
3889 const std::string str_name(ACCT_NAME.
Get());
3895 otOut << __FUNCTION__
3896 <<
": Failed: No account found on contract with name: "
3897 << str_name <<
" \n";
3903 pPartyAcct->GetAssetTypeID());
3909 if (theExpectedAssetTypeID != theActualAssetTypeID) {
3910 const OTString strAssetTypeID(theActualAssetTypeID);
3911 otOut << __FUNCTION__
3912 <<
": Failed, since the asset type ID of the account ("
3913 << strAssetTypeID <<
") does not match what was expected ("
3914 << pPartyAcct->GetAssetTypeID()
3915 <<
") according to this contract.\n";
3931 const OTString strNymID(SIGNER_NYM_ID);
3932 otOut << __FUNCTION__ <<
": Failed, since this nym (" << strNymID
3933 <<
") isn't the owner of this account (" << str_name <<
").\n";
3972 otOut << __FUNCTION__
3973 <<
": Failure: The smart contract has a different "
3974 "server ID on it already (" << strServer1
3975 <<
") than the one "
3976 "that goes with this account (server " << strServer2
3977 <<
", for account " << ACCT_ID <<
")\n";
3985 pPartyAcct->SetAcctID(ACCT_ID.
Get());
3986 pPartyAcct->SetAgentName(AGENT_NAME.
Get());
4006 NYM_ID,
false, __FUNCTION__);
4007 if (
nullptr == pNym)
return false;
4010 std::unique_ptr<OTScriptable> pContract(
4013 if (
nullptr == pContract) {
4014 otOut << __FUNCTION__ <<
": Error loading smart contract:\n\n"
4015 << THE_CONTRACT <<
"\n\n";
4018 const std::string str_party_name(PARTY_NAME.Get());
4022 if (
nullptr == pParty) {
4023 otOut << __FUNCTION__ <<
": Failure: Party (" << str_party_name
4024 <<
") doesn't exist, so how can you confirm it?\n";
4028 pParty->GetPartyName(),
4030 pParty->GetAuthorizingAgentName());
4034 if (!pParty->CopyAcctsToConfirmingParty(*pNewParty)) {
4035 otOut << __FUNCTION__
4036 <<
": Failed while trying to copy accounts, while "
4037 "confirming party: " << PARTY_NAME <<
" \n";
4039 pNewParty =
nullptr;
4049 otOut << __FUNCTION__
4050 <<
": Failed while trying to confirm party: " << PARTY_NAME
4053 pNewParty =
nullptr;
4064 strOutput.Release();
4072 const OTString strInstrument(*pContract);
4103 const char* BYLAW_LANGUAGE =
"chai";
4105 SIGNER_NYM_ID,
false, __FUNCTION__);
4106 if (
nullptr == pNym)
return false;
4109 std::unique_ptr<OTScriptable> pContract(
4111 if (
nullptr == pContract) {
4112 otOut <<
"OT_API::SmartContract_AddBylaw: Error loading smart "
4113 "contract:\n\n" << THE_CONTRACT <<
"\n\n";
4116 const std::string str_bylaw_name(BYLAW_NAME.
Get()),
4117 str_language(BYLAW_LANGUAGE);
4119 OTBylaw* pBylaw = pContract->GetBylaw(str_bylaw_name);
4121 if (
nullptr != pBylaw) {
4122 otOut <<
"OT_API::SmartContract_AddBylaw: Failure: Bylaw "
4123 "already exists: " << BYLAW_NAME <<
" \n";
4126 pBylaw =
new OTBylaw(str_bylaw_name.c_str(), str_language.c_str());
4129 if (!pContract->AddBylaw(*pBylaw))
4131 otOut <<
"OT_API::SmartContract_AddBylaw: Failed while trying "
4132 "to add bylaw: " << BYLAW_NAME <<
" \n";
4139 pContract->ReleaseSignatures();
4140 pContract->SignContract(*pNym);
4141 pContract->SaveContract();
4143 pContract->SaveContractRaw(strOutput);
4164 SIGNER_NYM_ID,
false, __FUNCTION__);
4165 if (
nullptr == pNym)
return false;
4168 std::unique_ptr<OTScriptable> pContract(
4170 if (
nullptr == pContract) {
4171 otOut <<
"OT_API::SmartContract_AddHook: Error loading smart "
4172 "contract:\n\n" << THE_CONTRACT <<
"\n\n";
4175 const std::string str_bylaw_name(BYLAW_NAME.
Get());
4177 OTBylaw* pBylaw = pContract->GetBylaw(str_bylaw_name);
4179 if (
nullptr == pBylaw) {
4180 otOut <<
"OT_API::SmartContract_AddHook: Failure: Bylaw "
4181 "doesn't exist: " << str_bylaw_name <<
" \n";
4184 const std::string str_name(HOOK_NAME.
Get()), str_clause(CLAUSE_NAME.
Get());
4186 if (!pBylaw->AddHook(str_name, str_clause)) {
4187 otOut <<
"OT_API::SmartContract_AddHook: Failed trying to add "
4188 "hook (" << str_name <<
", clause " << str_clause
4189 <<
") to bylaw: " << str_bylaw_name <<
" \n";
4194 pContract->ReleaseSignatures();
4195 pContract->SignContract(*pNym);
4196 pContract->SaveContract();
4198 pContract->SaveContractRaw(strOutput);
4217 SIGNER_NYM_ID,
false, __FUNCTION__);
4218 if (
nullptr == pNym)
return false;
4221 std::unique_ptr<OTScriptable> pContract(
4223 if (
nullptr == pContract) {
4224 otOut <<
"OT_API::SmartContract_AddCallback: Error loading "
4225 "smart contract:\n\n" << THE_CONTRACT <<
"\n\n";
4228 const std::string str_bylaw_name(BYLAW_NAME.
Get());
4230 OTBylaw* pBylaw = pContract->GetBylaw(str_bylaw_name);
4232 if (
nullptr == pBylaw) {
4233 otOut <<
"OT_API::SmartContract_AddCallback: Failure: Bylaw "
4234 "doesn't exist: " << str_bylaw_name <<
" \n";
4237 const std::string str_name(CALLBACK_NAME.
Get()),
4238 str_clause(CLAUSE_NAME.
Get());
4240 if (
nullptr != pBylaw->GetCallback(str_name)) {
4241 otOut <<
"OT_API::SmartContract_AddCallback: Failure: "
4242 "Callback (" << str_name
4243 <<
") already exists on bylaw: " << str_bylaw_name <<
" \n";
4246 if (!pBylaw->AddCallback(str_name.c_str(), str_clause.c_str())) {
4247 otOut <<
"OT_API::SmartContract_AddCallback: Failed trying to "
4248 "add callback (" << str_name <<
", clause " << str_clause
4249 <<
") to bylaw: " << str_bylaw_name <<
" \n";
4254 pContract->ReleaseSignatures();
4255 pContract->SignContract(*pNym);
4256 pContract->SaveContract();
4258 pContract->SaveContractRaw(strOutput);
4276 SIGNER_NYM_ID,
false, __FUNCTION__);
4277 if (
nullptr == pNym)
return false;
4280 std::unique_ptr<OTScriptable> pContract(
4282 if (
nullptr == pContract) {
4283 otOut <<
"OT_API::SmartContract_AddClause: Error loading "
4284 "smart contract:\n\n" << THE_CONTRACT <<
"\n\n";
4287 const std::string str_bylaw_name(BYLAW_NAME.
Get());
4289 OTBylaw* pBylaw = pContract->GetBylaw(str_bylaw_name);
4291 if (
nullptr == pBylaw) {
4292 otOut <<
"OT_API::SmartContract_AddClause: Failure: Bylaw "
4293 "doesn't exist: " << str_bylaw_name
4294 <<
" \n Input contract: \n\n" << THE_CONTRACT <<
"\n\n";
4297 const std::string str_name(CLAUSE_NAME.
Get()), str_code(SOURCE_CODE.
Get());
4299 if (
nullptr != pBylaw->GetClause(str_name)) {
4300 otOut <<
"OT_API::SmartContract_AddClause: Failed adding: "
4301 "clause is already there with that name (" << str_name
4303 "bylaw: " << str_bylaw_name <<
" \n";
4306 if (!pBylaw->AddClause(str_name.c_str(), str_code.c_str())) {
4307 otOut <<
"OT_API::SmartContract_AddClause: Failed trying to "
4308 "add clause (" << str_name <<
") to bylaw: " << str_bylaw_name
4314 pContract->ReleaseSignatures();
4315 pContract->SignContract(*pNym);
4316 pContract->SaveContract();
4318 pContract->SaveContractRaw(strOutput);
4342 SIGNER_NYM_ID,
false, __FUNCTION__);
4343 if (
nullptr == pNym)
return false;
4346 std::unique_ptr<OTScriptable> pContract(
4348 if (
nullptr == pContract) {
4349 otOut <<
"OT_API::SmartContract_AddVariable: Error loading "
4350 "smart contract:\n\n" << THE_CONTRACT <<
"\n\n";
4353 const std::string str_bylaw_name(BYLAW_NAME.
Get());
4355 OTBylaw* pBylaw = pContract->GetBylaw(str_bylaw_name);
4357 if (
nullptr == pBylaw) {
4358 otOut <<
"OT_API::SmartContract_AddVariable: Failure: Bylaw "
4359 "doesn't exist: " << str_bylaw_name <<
" \n";
4362 const std::string str_name(VAR_NAME.
Get()), str_access(VAR_ACCESS.
Get()),
4363 str_type(VAR_TYPE.
Get()), str_value(VAR_VALUE.
Get());
4365 if (
nullptr != pBylaw->GetVariable(str_name)) {
4366 otOut <<
"OT_API::SmartContract_AddVariable: Failure: "
4367 "Variable (" << str_name
4368 <<
") already exists on bylaw: " << str_bylaw_name <<
" \n";
4373 if (str_access.compare(
"constant") == 0)
4375 else if (str_access.compare(
"persistent") == 0)
4377 else if (str_access.compare(
"important") == 0)
4381 if (str_type.compare(
"bool") == 0)
4383 else if (str_type.compare(
"integer") == 0)
4385 else if (str_type.compare(
"string") == 0)
4389 otOut <<
"OT_API::SmartContract_AddVariable: Failed due to bad "
4390 "variable type or bad access type. \n";
4393 bool bAdded =
false;
4397 const bool bValue = (str_value.compare(
"true") == 0);
4398 bAdded = pBylaw->AddVariable(str_name, bValue, theAccess);
4401 const int32_t nValue = atoi(str_value.c_str());
4402 bAdded = pBylaw->AddVariable(str_name, nValue, theAccess);
4405 bAdded = pBylaw->AddVariable(str_name, str_value, theAccess);
4410 OT_FAIL_MSG(
"Should never happen. You aren't seeing this.");
4415 otOut <<
"OT_API::SmartContract_AddVariable: Failed trying to "
4416 "add variable (" << str_name
4417 <<
") to bylaw: " << str_bylaw_name <<
" \n";
4422 pContract->ReleaseSignatures();
4423 pContract->SignContract(*pNym);
4424 pContract->SaveContract();
4426 pContract->SaveContractRaw(strOutput);
4437 const OTString& NYM_NEW_NAME)
const
4441 if (
nullptr == pWallet)
return false;
4447 if ((
nullptr == pNym) || (
nullptr == pSignerNym))
return false;
4452 if (!NYM_NEW_NAME.
Exists())
4453 otOut <<
"OT_API::SetNym_Name: Empty name (bad).\n";
4462 otErr << __FUNCTION__
4463 <<
": Failed while trying to save wallet.\n";
4480 const OTString& ACCT_NEW_NAME)
const
4484 if (
nullptr == pWallet)
return false;
4487 SIGNER_NYM_ID,
false, __FUNCTION__);
4488 if (
nullptr == pSignerNym)
return false;
4491 if (
nullptr == pAccount)
return false;
4492 if (!ACCT_NEW_NAME.
Exists())
4494 otOut <<
"OT_API::SetAccount_Name: New name is empty (bad).\n";
4497 otInfo <<
"Saving updated account file to disk...\n";
4498 pAccount->
SetName(ACCT_NEW_NAME);
4506 <<
"OT_API::SetAccount_Name: Failed doing this: if "
4507 "(pAccount->SignContract(*pSignerNym) "
4508 "&& pAccount->SaveContract() && pAccount->SaveAccount())\n";
4516 const char* szFuncName)
const
4519 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
4530 GetNym(NYM_ID, szFuncName);
4539 const char* szFuncName,
4544 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
4556 GetNym(NYM_ID, szFuncName);
4560 if (
nullptr == pPWData) pPWData = &thePWData;
4630 bool bHarvestingForRetry,
4631 bool bReplyWasSuccess,
4632 bool bReplyWasFailure,
4633 bool bTransactionWasSuccess,
4634 bool bTransactionWasFailure)
const
4637 USER_ID,
false, __FUNCTION__);
4638 if (
nullptr == pNym)
return false;
4641 return theMsg.HarvestTransactionNumbers(
4642 *pNym, bHarvestingForRetry, bReplyWasSuccess, bReplyWasFailure,
4643 bTransactionWasSuccess, bTransactionWasFailure);
4685 const OTString& THE_CRON_ITEM)
const
4688 NYM_ID,
false, __FUNCTION__);
4689 if (
nullptr == pNym)
return false;
4692 std::unique_ptr<OTCronItem> pCronItem(
4694 if (
nullptr == pCronItem) {
4695 otOut << __FUNCTION__
4696 <<
": Error loading the cron item (a cron item is a "
4697 "smart contract, or some other recurring transaction such "
4698 "as a market offer, or a payment plan.) Contents:\n\n"
4699 << THE_CRON_ITEM <<
"\n\n";
4702 pCronItem->HarvestClosingNumbers(*pNym);
4729 const OTString& THE_CRON_ITEM)
const
4732 NYM_ID,
false, __FUNCTION__);
4733 if (
nullptr == pNym)
return false;
4736 std::unique_ptr<OTCronItem> pCronItem(
4738 if (
nullptr == pCronItem) {
4739 otOut << __FUNCTION__
4740 <<
": Error loading the cron item (a cron item is a "
4741 "smart contract, or some other recurring transaction such "
4742 "as a market offer, or a payment plan.) "
4743 "Contents:\n\n" << THE_CRON_ITEM <<
"\n\n";
4746 pCronItem->HarvestOpeningNumber(*pNym);
4750 pCronItem->HarvestClosingNumbers(*pNym);
4761 const char* szFuncName)
const
4764 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
4769 if (
nullptr == pWallet)
return nullptr;
4785 const OTIdentifier& NYM_ID,
bool bChecking,
const char* szFuncName,
4789 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
4794 if (
nullptr == pWallet)
return nullptr;
4795 if (NYM_ID.
IsEmpty())
return nullptr;
4802 NYM_ID, bChecking, szFuncName,
4803 nullptr == pPWData ? &thePWData : pPWData, pImportPassword);
4815 const char* szFuncName,
4819 otErr << __FUNCTION__ <<
": NYM_ID is empty!";
4824 if (
nullptr == pWallet)
return nullptr;
4832 return pWallet->
GetOrLoadNym(NYM_ID, bChecking, szFuncName,
4833 nullptr == pPWData ? &thePWData : pPWData);
4842 const char* szFuncName)
const
4844 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
4846 if (
nullptr == pWallet)
return nullptr;
4858 const char* szFuncName)
const
4860 const char* szFunc = (
nullptr != szFuncName) ? szFuncName : __FUNCTION__;
4862 if (
nullptr == pNym)
return nullptr;
4875 const OTIdentifier& SERVER_ID,
const int64_t& CHEQUE_AMOUNT,
4882 if (
nullptr == pNym)
return nullptr;
4887 if (
nullptr == pAccount)
return nullptr;
4901 int64_t lTransactionNumber =
4906 otOut << __FUNCTION__
4907 <<
": User attempted to write a cheque, but had no "
4908 "transaction numbers.\n";
4916 "OT_API::WriteCheque: Error allocating memory in the OT API.");
4920 CHEQUE_AMOUNT, lTransactionNumber, VALID_FROM, VALID_TO, SENDER_ACCT_ID,
4921 SENDER_USER_ID, CHEQUE_MEMO, pRECIPIENT_USER_ID);
4922 if (!bIssueCheque) {
4923 otErr << __FUNCTION__ <<
": Failure calling OTCheque::IssueCheque().\n";
4940 const OTString strInstrument(*pCheque);
4944 const OTString strNymID(SENDER_USER_ID);
4949 if (
nullptr != pRECIPIENT_USER_ID) {
4950 const OTString strNymID2(*pRECIPIENT_USER_ID);
5004 const OTString& PLAN_CONSIDERATION,
5009 const int64_t& INITIAL_PAYMENT_AMOUNT,
5010 const time64_t& INITIAL_PAYMENT_DELAY,
5012 const int64_t& PAYMENT_PLAN_AMOUNT,
5013 const time64_t& PAYMENT_PLAN_DELAY,
5014 const time64_t& PAYMENT_PLAN_PERIOD,
5018 int32_t PAYMENT_PLAN_MAX_PAYMENTS
5022 RECIPIENT_USER_ID,
false, __FUNCTION__);
5023 if (
nullptr == pNym)
return nullptr;
5027 GetOrLoadAccount(*pNym, RECIPIENT_ACCT_ID, SERVER_ID, __FUNCTION__);
5028 if (
nullptr == pAccount)
return nullptr;
5033 SENDER_USER_ID, RECIPIENT_ACCT_ID, RECIPIENT_USER_ID);
5035 "OT_API::ProposePaymentPlan: Error allocating "
5036 "memory in the OT API for new "
5037 "OTPaymentPlan.\n");
5040 bool bSuccessSetProposal =
5041 pPlan->
SetProposal(*pNym, PLAN_CONSIDERATION, VALID_FROM, VALID_TO);
5047 const OTString strServerID(SERVER_ID);
5049 if (!bSuccessSetProposal) {
5050 otOut << __FUNCTION__ <<
": Failed trying to set the proposal.\n";
5057 bool bSuccessSetInitialPayment =
true;
5059 bool bSuccessSetPaymentPlan =
5061 if ((INITIAL_PAYMENT_AMOUNT > 0) &&
5066 INITIAL_PAYMENT_AMOUNT, INITIAL_PAYMENT_DELAY);
5068 if (!bSuccessSetInitialPayment) {
5069 otOut << __FUNCTION__
5070 <<
": Failed trying to set the initial payment.\n";
5086 if (PAYMENT_PLAN_AMOUNT > 0)
5095 PAYMENT_DELAY = PAYMENT_PLAN_DELAY;
5101 PAYMENT_PERIOD = PAYMENT_PLAN_PERIOD;
5106 PLAN_LENGTH = PAYMENT_PLAN_LENGTH;
5107 int32_t nMaxPayments =
5110 if (PAYMENT_PLAN_MAX_PAYMENTS > 0)
5111 nMaxPayments = PAYMENT_PLAN_MAX_PAYMENTS;
5112 bSuccessSetPaymentPlan =
5114 PAYMENT_PERIOD, PLAN_LENGTH, nMaxPayments);
5116 if (!bSuccessSetPaymentPlan) {
5117 otOut << __FUNCTION__ <<
": Failed trying to set the payment plan.\n";
5133 const OTString strInstrument(*pPlan);
5137 const OTString strNymID(RECIPIENT_USER_ID), strNymID2(SENDER_USER_ID);
5177 SENDER_USER_ID,
false, __FUNCTION__);
5178 if (
nullptr == pNym)
return false;
5183 if (
nullptr == pAccount)
return false;
5186 std::unique_ptr<OTPseudonym> pMerchantNym(
5202 thePlan.
Confirm(*pNym, pMerchantNym.get(), &RECIPIENT_USER_ID);
5214 const OTString strServerID(SERVER_ID);
5217 otOut << __FUNCTION__ <<
": Failed trying to confirm the agreement.\n";
5230 const OTString strInstrument(thePlan);
5234 const OTString strNymID(SENDER_USER_ID), strNymID2(RECIPIENT_USER_ID);
5263 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5264 const OTString strReason((
nullptr == pstrDisplay)
5265 ?
"Loading purse from local storage."
5266 : pstrDisplay->
Get());
5268 const OTString strServerID(SERVER_ID);
5270 const OTString strAssetTypeID(ASSET_ID);
5274 if (
nullptr == pNym)
return nullptr;
5275 Purse* pPurse =
new Purse(SERVER_ID, ASSET_ID, USER_ID);
5277 "Error allocating memory in the OT API.");
5283 strAssetTypeID.
Get())) {
5290 otOut << __FUNCTION__ <<
": Failed verifying purse.\n";
5293 otInfo << __FUNCTION__ <<
": Failed loading purse.\n";
5304 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5306 otOut << __FUNCTION__
5307 <<
": Failure: This purse is password-protected (exported) "
5308 "and cannot be saved inside the wallet without first "
5309 "re-importing it.\n";
5311 else if ((THE_PURSE.
GetServerID() != SERVER_ID) ||
5313 otOut << __FUNCTION__ <<
": Error: Wrong server or asset ID passed in, "
5314 "considering the purse that was passed.\n";
5317 const OTString strServerID(SERVER_ID);
5318 const OTString strAssetTypeID(ASSET_ID);
5321 strAssetTypeID.
Get()))
5324 const OTString strPurse(THE_PURSE);
5325 otOut << __FUNCTION__ <<
": Failed saving purse:\n\n" << strPurse <<
"\n\n";
5337 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5338 Purse* pPurse =
new Purse(SERVER_ID, ASSET_ID, OWNER_ID);
5340 "Error allocating memory in the OT API.");
5357 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5358 Purse* pPurse =
new Purse(SERVER_ID, ASSET_ID);
5360 "Error allocating memory in the OT API.");
5367 otErr <<
"OT_API::CreatePurse_Passphrase: "
5368 "pPurse->GenerateInternalKey() returned false. (Failure.)\n";
5385 bool bForEncrypting,
5394 const OTString* pstrDisplay2)
const
5396 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5397 const bool bDoesOwnerIDExist =
5401 (
nullptr == pstrDisplay1)
5402 ?
"Enter the master passphrase for your wallet. "
5403 "(LoadPurseAndOwnerFromString)"
5404 : pstrDisplay1->Get());
5406 (
nullptr == pstrDisplay2)
5407 ?
"Enter the passphrase for this purse. "
5408 "(LoadPurseAndOwnerFromString)"
5409 : pstrDisplay2->Get());
5412 if (bDoesOwnerIDExist) {
5415 ? GetOrLoadNym(*pOWNER_ID,
false, __FUNCTION__, &thePWData1)
5416 : GetOrLoadPrivateNym(
5417 *pOWNER_ID,
false, __FUNCTION__,
5419 if (
nullptr == pOwnerNym)
return nullptr;
5427 if (strPurse.Exists() && thePurse.LoadContractFromString(strPurse)) {
5428 const bool bNymIDIncludedInPurse = thePurse.IsNymIDIncluded();
5431 if (thePurse.GetServerID() != theServerID)
5432 otErr << __FUNCTION__ <<
": Failed: ServerID doesn't match.\n";
5433 else if (thePurse.GetAssetID() != theAssetTypeID)
5434 otErr << __FUNCTION__ <<
": Failed: AssetTypeID doesn't match.\n";
5435 else if (bNymIDIncludedInPurse && !thePurse.GetNymID(idPurseNym))
5436 otErr << __FUNCTION__
5437 <<
": Failed trying to get the NymID from the "
5438 "purse (though one WAS apparently present.)\n";
5439 else if (bNymIDIncludedInPurse && !bDoesOwnerIDExist) {
5440 const OTString strPurseNymID(idPurseNym);
5441 otErr << __FUNCTION__
5442 <<
": Error: The purse is owned by a NymID, but no "
5443 "NymID was passed into "
5444 "this function.\nNym who owns the purse: " << strPurseNymID
5447 else if (bNymIDIncludedInPurse &&
5448 !(pOwnerNym->GetConstID() == idPurseNym)) {
5449 const OTString strPurseNymID(idPurseNym),
5450 strNymActuallyPassed(pOwnerNym->GetConstID());
5451 otErr << __FUNCTION__
5452 <<
": Error: the API call mentions Nym A, but the "
5453 "purse is actually owned by Nym B.\nNym A: "
5454 << strNymActuallyPassed <<
"\nNym B: " << strPurseNymID
5457 else if (!bDoesOwnerIDExist && !thePurse.IsPasswordProtected())
5458 otErr << __FUNCTION__
5459 <<
": Failed: The USER_ID was nullptr, which is only allowed "
5460 "for a password-protected purse. (And this purse is NOT "
5461 "password-protected.) Please provide a USER_ID.\n";
5470 else if (thePurse.IsPasswordProtected())
5476 const bool bGotPassphrase = thePurse.GetPassphrase(
5477 thePassword, thePWData2.GetDisplayString());
5479 if (!bGotPassphrase)
5480 otOut << __FUNCTION__
5481 <<
": Authentication failed, or otherwise failed "
5482 "retrieving secret from user.\n";
5497 else if (bDoesOwnerIDExist)
5500 *pOwnerNym, pstrDisplay1);
5505 otErr << __FUNCTION__
5506 <<
": Failed: The purse is not password-protected, "
5507 "but rather, is locked by a Nym. "
5508 "However, no USER_ID was passed in! Please supply a "
5510 "to open this purse.\n";
5514 otOut << __FUNCTION__ <<
": Failure loading purse from string:\n"
5515 << strPurse <<
"\n";
5547 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5549 : pstrDisplay->
Get());
5555 otErr << __FUNCTION__
5556 <<
": Failed trying to get the NymID from the "
5557 "purse (though one WAS apparently present.)\n";
5576 if (
nullptr == pActualOwnerID) {
5577 otErr << __FUNCTION__
5578 <<
": Failed: The purse is encrypted to a "
5579 "specific Nym (not a passphrase) "
5580 "but that Nym is not specified in the purse, nor "
5581 "was it passed into this "
5582 "function. (Failure. Unable to access purse.)\n";
5590 *pActualOwnerID,
false, __FUNCTION__,
5592 if (
nullptr == pOwnerNym) {
5593 const OTString strAttemptedID(*pActualOwnerID);
5594 otErr << __FUNCTION__
5595 <<
": Failed: The purse is encrypted to a specific NymID "
5596 "(not a passphrase) which was either specified inside "
5598 "or wasn't specified so we guessed the user ID. "
5600 "then failed loading that Nym: " << strAttemptedID
5602 "(Failure. Unable to access purse.)\n";
5614 *pOwnerNym, pstrDisplay);
5626 thePassword, thePWData.GetDisplayString());
5628 if (!bGotPassphrase)
5629 otOut << __FUNCTION__
5630 <<
": Authentication failed, or otherwise failed "
5631 "retrieving secret from user.\n";
5646 otErr << __FUNCTION__ <<
": Failed: Somehow this purse is not "
5647 "password-protected, nor "
5648 "is it Nym-protected. (This error should "
5649 "never actually happen.)\n";
5653 otOut << __FUNCTION__ <<
": Failure loading purse from string:\n"
5654 << strPurse <<
"\n";
5682 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5684 (
nullptr == pstrDisplay)
5685 ?
"Enter your master passphrase for your wallet. (Purse_Peek)"
5686 : pstrDisplay->
Get());
5688 (
nullptr == pstrDisplay)
5689 ?
"Enter the passphrase for this purse. (Purse_Peek)"
5690 : pstrDisplay->
Get());
5692 Purse thePurse(SERVER_ID, ASSET_TYPE_ID);
5715 SERVER_ID, ASSET_TYPE_ID, THE_PURSE, thePurse, thePassword,
5717 pOWNER_ID, &strReason1, &strReason2));
5718 if (
nullptr == pOwner)
5720 Token* pToken =
nullptr;
5722 if (thePurse.IsEmpty())
5723 otOut << __FUNCTION__ <<
": Failed attempt to peek; purse is empty.\n";
5725 pToken = thePurse.Peek(*pOwner);
5727 if (
nullptr == pToken)
5728 otOut << __FUNCTION__
5729 <<
": Failed peeking a token from a "
5730 "purse that supposedly had tokens on it...\n";
5764 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5766 (
nullptr == pstrDisplay)
5767 ?
"Enter your master passphrase for your wallet. (Purse_Pop)"
5768 : pstrDisplay->
Get());
5770 (
nullptr == pstrDisplay)
5771 ?
"Enter the passphrase for this purse. (Purse_Pop)"
5772 : pstrDisplay->
Get());
5774 std::unique_ptr<Purse> pPurse(
new Purse(SERVER_ID, ASSET_TYPE_ID));
5798 SERVER_ID, ASSET_TYPE_ID, THE_PURSE, *pPurse, thePassword,
5800 pOWNER_ID, &strReason1, &strReason2));
5801 if (
nullptr == pOwner)
5803 Purse* pReturnPurse =
nullptr;
5805 if (pPurse->IsEmpty())
5806 otOut << __FUNCTION__ <<
": Failed attempt to pop; purse is empty.\n";
5808 std::unique_ptr<Token> pToken(pPurse->Pop(*pOwner));
5810 if (
nullptr == pToken)
5811 otOut << __FUNCTION__
5812 <<
": Failed popping a token from a "
5813 "purse that supposedly had tokens on it...\n";
5815 pReturnPurse = pPurse.release();
5818 return pReturnPurse;
5830 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5831 const OTString strReason((
nullptr == pstrDisplay)
5832 ?
"Making an empty copy of a cash purse."
5833 : pstrDisplay->
Get());
5837 if (
nullptr == pPurse) {
5838 otOut << __FUNCTION__
5839 <<
": Error: THE_PURSE is an empty string. Please pass a "
5840 "real purse when calling this function.\n";
5843 pPurse->ReleaseTokens();
5872 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5874 (
nullptr == pstrDisplay)
5875 ?
"Enter your master passphrase for your wallet. (Purse_Push)"
5876 : pstrDisplay->
Get());
5878 (
nullptr == pstrDisplay)
5879 ?
"Enter the passphrase for this purse. (Purse_Push)"
5880 : pstrDisplay->
Get());
5882 if (!THE_PURSE.
Exists()) {
5883 otOut << __FUNCTION__ <<
": Purse does not exist.\n";
5886 else if (!THE_TOKEN.
Exists()) {
5887 otOut << __FUNCTION__ <<
": Token does not exist.\n";
5891 std::unique_ptr<Token> pToken(
5894 if (
nullptr == pToken)
5896 otOut << __FUNCTION__
5897 <<
": Unable to instantiate or load token from string:\n\n"
5898 << THE_TOKEN <<
"\n\n";
5901 std::unique_ptr<Purse> pPurse(
new Purse(SERVER_ID, ASSET_TYPE_ID));
5924 SERVER_ID, ASSET_TYPE_ID, THE_PURSE, *pPurse, thePassword,
5926 pOWNER_ID, &strReason1, &strReason2));
5927 if (
nullptr == pOwner)
5929 Purse* pReturnPurse =
nullptr;
5931 const bool bPushed = pPurse->Push(*pOwner, *pToken);
5934 otOut << __FUNCTION__ <<
": Failed pushing a token onto a purse.\n";
5936 pReturnPurse = pPurse.release();
5938 return pReturnPurse;
5959 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
5960 OTString strPurseReason((
nullptr == pstrDisplay)
5961 ?
"Enter passphrase for purse being imported."
5962 : pstrDisplay->
Get());
5968 SIGNER_ID,
false, __FUNCTION__,
5970 if (
nullptr == pNym)
return false;
5973 std::unique_ptr<Purse> pNewPurse(
new Purse(SERVER_ID, ASSET_TYPE_ID));
5994 THE_PURSE, *pNewPurse, thePassword,
6004 if (
nullptr == pNewOwner)
6006 std::unique_ptr<Purse> pOldPurse(
6007 LoadPurse(SERVER_ID, ASSET_TYPE_ID, SIGNER_ID));
6009 if (
nullptr == pOldPurse)
6012 pOldPurse.reset(
new Purse(SERVER_ID, ASSET_TYPE_ID, SIGNER_ID));
6014 else if (!pOldPurse->VerifySignature(*pNym)) {
6017 <<
": Failed to verify signature on old purse. (Very strange...)\n";
6024 if (pOldPurse->GetServerID() != pNewPurse->GetServerID()) {
6025 otOut << __FUNCTION__
6026 <<
": Failure: ServerIDs don't match between these two purses.\n";
6029 else if (pOldPurse->GetAssetID() != pNewPurse->GetAssetID()) {
6030 otOut << __FUNCTION__
6031 <<
": Failure: AssetIDs don't match between these two purses.\n";
6045 if (pOldPurse->Merge(*pNym,
6050 pOldPurse->ReleaseSignatures();
6051 pOldPurse->SignContract(*pNym);
6052 pOldPurse->SaveContract();
6053 return SavePurse(SERVER_ID, ASSET_TYPE_ID, SIGNER_ID, *pOldPurse);
6059 pNewOwner->GetIdentifier(strNymID2);
6060 otOut << __FUNCTION__ <<
": (OldNymID: " << strNymID1
6061 <<
".) (New Owner ID: " << strNymID2 <<
".) Failure merging new "
6062 "purse:\n\n" << THE_PURSE
6093 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
6095 (
nullptr == pstrDisplay)
6096 ?
"Enter your wallet's master passphrase. (Token_ChangeOwner.)"
6097 : pstrDisplay->
Get());
6099 (
nullptr == pstrDisplay)
6100 ?
"Enter the passphrase for this purse. (Token_ChangeOwner.)"
6101 : pstrDisplay->
Get());
6104 SIGNER_NYM_ID,
false, __FUNCTION__,
6106 if (
nullptr == pSignerNym)
return nullptr;
6115 std::unique_ptr<Purse> theOldPurseAngel;
6119 std::unique_ptr<OTNym_or_SymmetricKey> theOldOwnerAngel;
6120 std::unique_ptr<Purse> theNewPurseAngel;
6124 std::unique_ptr<OTNym_or_SymmetricKey> theNewOwnerAngel;
6125 const bool bOldOwnerIsPurse = OLD_OWNER.
Contains(
"PURSE");
6126 const bool bNewOwnerIsPurse = NEW_OWNER.
Contains(
"PURSE");
6127 if (!bOldOwnerIsPurse)
6131 oldOwnerNymID,
false, __FUNCTION__,
6136 if (
nullptr == pOldNym)
return nullptr;
6139 theOldOwnerAngel.reset(pOldOwner);
6146 Purse* pOldPurse =
new Purse(SERVER_ID, ASSET_TYPE_ID);
6148 theOldPurseAngel.reset(pOldPurse);
6150 OLD_OWNER, *pOldPurse, theOldPassword,
6167 theOldOwnerAngel.reset(pOldOwner);
6168 if (
nullptr == pOldOwner)
6171 if (!bNewOwnerIsPurse)
6177 if (
nullptr == pNewNym)
return nullptr;
6180 theNewOwnerAngel.reset(pNewOwner);
6186 Purse* pNewPurse =
new Purse(SERVER_ID, ASSET_TYPE_ID);
6188 theNewPurseAngel.reset(pNewPurse);
6190 NEW_OWNER, *pNewPurse, theNewPassword,
6210 theNewOwnerAngel.reset(pNewOwner);
6211 if (
nullptr == pNewOwner)
6217 std::unique_ptr<Token> pToken(
6221 pToken->ReassignOwnership(*pOldOwner,
6224 otErr << __FUNCTION__ <<
": Error re-assigning ownership of token.\n";
6228 <<
": Success re-assigning ownership of token.\n";
6230 pToken->ReleaseSignatures();
6231 pToken->SignContract(*pSignerNym);
6232 pToken->SaveContract();
6234 return pToken.release();
6248 const OTString strServerID(SERVER_ID);
6249 const OTString strAssetTypeID(ASSET_ID);
6251 if (
nullptr == pServerContract)
return nullptr;
6253 if (
nullptr == pServerNym) {
6254 otErr << __FUNCTION__
6255 <<
": Failed trying to get contract public Nym for ServerID: "
6256 << strServerID <<
" \n";
6261 "OT_API::LoadMint: Error allocating memory in the OT API");
6264 otOut << __FUNCTION__
6267 << strAssetTypeID <<
"\n";
6282 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
6288 otErr <<
"OT_API::LoadServerContract: File does not exist: "
6294 strServerID, strFoldername, strFilename, strServerID);
6296 "Error allocating memory for Server "
6297 "Contract in OT_API::LoadServerContract\n");
6302 otOut <<
"OT_API::LoadServerContract: Unable to load or "
6303 "verify server contract. (Maybe it's just not there, "
6304 "and needs to be downloaded.) Server ID: " << strServerID
6307 pContract =
nullptr;
6318 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
6324 otErr <<
"OT_API::LoadAssetContract: File does not exist: "
6330 strAssetTypeID, strFoldername, strFilename, strAssetTypeID);
6332 "Error allocating memory for Asset "
6333 "Contract in OT_API::LoadAssetContract\n");
6338 otOut <<
"OT_API::LoadAssetContract: Unable to load or verify "
6339 "asset contract (Maybe it's just not there, and "
6340 "needs to be downloaded.) Asset ID: " << strAssetTypeID
6343 pContract =
nullptr;
6365 if (
nullptr == pWallet)
return nullptr;
6368 if (
nullptr == pNym)
return nullptr;
6371 return pWallet->
LoadAccount(*pNym, ACCOUNT_ID, SERVER_ID, __FUNCTION__);
6382 if (
nullptr == pNym)
return nullptr;
6388 "OT_API::LoadNymbox: Error allocating memory in the OT API.");
6395 otOut <<
"OT_API::LoadNymbox: Unable to load or verify nymbox: "
6396 << strUserID <<
"\n";
6417 if (
nullptr == pNym)
return nullptr;
6424 "OT_API::LoadNymboxNoVerify: Error allocating memory in the OT API.");
6431 otOut <<
"OT_API::LoadNymboxNoVerify: Unable to load nymbox: "
6432 << strUserID <<
"\n";
6448 if (
nullptr == pNym)
return nullptr;
6454 "OT_API::LoadInbox: Error allocating memory in the OT API.");
6461 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6462 otWarn <<
"OT_API::LoadInbox: Unable to load or verify inbox: "
6463 << strAcctID <<
"\n For user: " << strUserID <<
"\n";
6486 if (
nullptr == pNym)
return nullptr;
6493 "OT_API::LoadInboxNoVerify: Error allocating memory in the OT API.");
6500 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6501 otWarn <<
"OT_API::LoadInboxNoVerify: Unable to load inbox: "
6502 << strAcctID <<
"\n For user: " << strUserID <<
"\n";
6518 if (
nullptr == pNym)
return nullptr;
6524 "OT_API::LoadOutbox: Error allocating memory in the OT API.");
6532 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6534 otWarn <<
"OT_API::LoadOutbox: Unable to load or verify "
6535 "outbox: " << strAcctID <<
"\n For user: " << strUserID
6560 if (
nullptr == pNym)
return nullptr;
6567 "OT_API::LoadOutboxNoVerify: Error allocating memory in the OT API.");
6575 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6576 otWarn <<
"OT_API::LoadOutboxNoVerify: Unable to load outbox: "
6577 << strAcctID <<
"\n For user: " << strUserID <<
"\n";
6589 if (
nullptr == pNym)
return nullptr;
6596 "OT_API::LoadPaymentInbox: Error allocating memory in the OT API.");
6602 OTString strUserID(USER_ID), strAcctID(USER_ID);
6603 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6604 <<
" / " << strAcctID <<
"\n";
6615 if (
nullptr == pNym)
return nullptr;
6620 OT_ASSERT_MSG(
nullptr != pLedger,
"OT_API::LoadPaymentInboxNoVerify: Error "
6621 "allocating memory in the OT API.");
6627 OTString strUserID(USER_ID), strAcctID(USER_ID);
6628 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6629 <<
" / " << strAcctID <<
"\n";
6643 if (
nullptr == pNym)
return nullptr;
6651 "OT_API::LoadRecordBox: Error allocating memory in the OT API.");
6656 bool bVerified =
false;
6660 if (bLoaded && bVerified)
6663 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6664 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6665 <<
" / " << strAcctID <<
"\n";
6677 if (
nullptr == pNym)
return nullptr;
6682 OT_ASSERT_MSG(
nullptr != pLedger,
"OT_API::LoadRecordBoxNoVerify: Error "
6683 "allocating memory in the OT API.");
6689 OTString strUserID(USER_ID), strAcctID(ACCOUNT_ID);
6690 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6691 <<
" / " << strAcctID <<
"\n";
6704 if (
nullptr == pNym)
return nullptr;
6712 "OT_API::LoadExpiredBox: Error allocating memory in the OT API.");
6717 bool bVerified =
false;
6721 if (bLoaded && bVerified)
6725 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6737 if (
nullptr == pNym)
return nullptr;
6742 OT_ASSERT_MSG(
nullptr != pLedger,
"OT_API::LoadExpiredBoxNoVerify: Error "
6743 "allocating memory in the OT API.");
6750 otWarn << __FUNCTION__ <<
": Unable to load or verify: " << strUserID
6760 bool bClearAll)
const
6763 OTPseudonym* pNym = GetOrLoadPrivateNym(USER_ID,
false, __FUNCTION__);
6764 if (
nullptr == pNym)
return false;
6767 std::unique_ptr<OTLedger> pExpiredBox(LoadExpiredBox(SERVER_ID, USER_ID));
6768 if (
nullptr == pExpiredBox) {
6772 if (
nullptr == pExpiredBox) {
6773 otErr << __FUNCTION__
6774 <<
": Unable to load or create expired box (and thus "
6775 "unable to do anything with it.)\n";
6791 if ((nIndex < 0) || (nIndex >= nTransCount)) {
6792 otErr << __FUNCTION__
6793 <<
": Index out of bounds (highest allowed index for this "
6794 "expired box is " << nTransCount - 1 <<
".)\n";
6798 bool bRemoved =
false;
6800 if (
nullptr != pTransaction) {
6804 otErr << __FUNCTION__
6805 <<
": Failed trying to delete the box receipt for a "
6806 "transaction being removed from a expired box: "
6807 << lTransactionNum <<
"\n";
6819 const int32_t nTemp =
static_cast<int32_t
>(nIndex);
6820 otOut << __FUNCTION__
6821 <<
": Failed trying to clear an expired record from "
6822 "the expired box at index: " << nTemp <<
"\n";
7034 bool bSaveCopy)
const
7037 if (
nullptr == pNym)
return false;
7044 std::unique_ptr<OTLedger> theRecordBoxAngel;
7045 std::unique_ptr<OTLedger> theExpiredBoxAngel;
7049 theRecordBoxAngel.reset(pRecordBox);
7050 theExpiredBoxAngel.reset(pExpiredBox);
7051 if (
nullptr == pRecordBox) {
7054 if (
nullptr == pRecordBox) {
7055 otErr << __FUNCTION__
7056 <<
": Unable to load or create record box "
7057 "(and thus unable to do anything with it.)\n";
7060 theRecordBoxAngel.reset(pRecordBox);
7062 if (
nullptr == pExpiredBox) {
7065 if (
nullptr == pExpiredBox) {
7066 otErr << __FUNCTION__
7067 <<
": Unable to load or create expired box"
7068 "(and thus unable to do anything with it.)\n";
7071 theExpiredBoxAngel.reset(pExpiredBox);
7074 pActualBox = pRecordBox;
7076 std::unique_ptr<OTLedger> thePaymentBoxAngel;
7078 bool bIsExpired =
false;
7082 std::unique_ptr<OTTransaction> theTransactionAngel;
7085 std::unique_ptr<OTMessage> theMessageAngel;
7087 bool bRemoved =
false, bNeedToSaveTheNym =
false;
7091 thePaymentBoxAngel.reset(pPaymentInbox);
7092 if (
nullptr == pPaymentInbox) {
7093 otErr << __FUNCTION__
7094 <<
": Unable to load payment inbox "
7095 "(and thus unable to do anything with it.)\n";
7099 otErr << __FUNCTION__
7100 <<
": Unable to find transaction in payment inbox "
7101 "based on index " << nIndex <<
". (Out of bounds.)\n";
7106 if (
nullptr == pTransaction) {
7107 otErr << __FUNCTION__
7108 <<
": Unable to find transaction in payment inbox "
7109 "based on index " << nIndex <<
".\n";
7112 std::unique_ptr<OTPayment> pPayment(
7115 pPayment->IsExpired(bIsExpired);
7117 if (bIsExpired) pActualBox = pExpiredBox;
7123 otErr << __FUNCTION__
7124 <<
": Failed trying to delete the box receipt for a "
7125 "transaction being removed from the payment inbox: "
7126 << lTransactionNum <<
"\n";
7129 lTransactionNum,
false);
7134 theTransactionAngel.reset(
7152 otErr << __FUNCTION__
7153 <<
": Unable to find payment in outpayment box based "
7154 "on index " << nIndex <<
". (Out of bounds.)\n";
7159 if (
nullptr == pMessage) {
7160 otErr << __FUNCTION__
7161 <<
": Unable to find payment message in outpayment "
7162 "box based on index " << nIndex <<
".\n";
7167 otErr << __FUNCTION__
7168 <<
": Unable to find payment instrument in outpayment "
7169 "message at index " << nIndex <<
".\n";
7179 if (bIsExpired) pActualBox = pExpiredBox;
7182 int64_t lPaymentOpeningNum = 0;
7183 int64_t lPaymentTransNum = 0;
7196 otErr << __FUNCTION__
7197 <<
": Should never happen! "
7198 "Failed to get transaction num from payment "
7199 "RIGHT AFTER succeeded getting opening "
7207 bool bIsRecurring =
false;
7211 bIsRecurring =
true;
7212 lPaymentTransNum = lPaymentOpeningNum;
7263 bool bShouldHarvestPayment =
false;
7264 bool bNeedToLoadAssetAcctInbox =
false;
7267 bool bPaymentSenderIsNym =
false;
7268 bool bFromAcctIsAvailable =
false;
7270 bPaymentSenderIsNym =
7273 bFromAcctIsAvailable =
7277 bPaymentSenderIsNym =
7280 bFromAcctIsAvailable =
7283 if (bPaymentSenderIsNym ||
7295 const OTString strServerID(SERVER_ID);
7307 strServerID, lPaymentTransNum))
7311 otErr << __FUNCTION__
7312 <<
": Error: Why on earth is this "
7313 "transaction number (" << lPaymentTransNum
7314 <<
") on an outgoing "
7315 "payment instrument, if it's still on my "
7316 "'Tentative' list? If I haven't even "
7317 "signed out that number, how did I send "
7318 "an instrument to someone else with that "
7377 bShouldHarvestPayment =
true;
7383 bNeedToLoadAssetAcctInbox =
true;
7403 bShouldHarvestPayment =
7410 bNeedToLoadAssetAcctInbox =
7485 otOut << __FUNCTION__
7486 <<
": This outpayment isn't expired "
7487 "yet, and the transaction number "
7488 "(" << lPaymentTransNum
7489 <<
") is still signed out. "
7490 "(Skipping moving it to record box "
7491 "-- it will be moved automatically "
7492 "once you cancel the transaction "
7493 "or the recipient deposits it.)\n";
7505 bShouldHarvestPayment =
7510 bNeedToLoadAssetAcctInbox =
7734 bShouldHarvestPayment =
7740 bNeedToLoadAssetAcctInbox =
7763 otOut << __FUNCTION__
7764 <<
": This outpayment isn't expired yet.\n";
7769 bool bFoundReceiptInInbox =
false;
7779 if (bNeedToLoadAssetAcctInbox &&
7780 (bFromAcctIsAvailable || bIsRecurring)) {
7781 bool bIsSmartContract =
false;
7783 std::unique_ptr<OTTrackable> pTrackable(
7785 if (
nullptr == pTrackable) {
7788 otErr << __FUNCTION__
7789 <<
": Failed instantiating OTPayment "
7790 "containing:\n" << strPaymentContents
7797 if (
nullptr != pSmartContract) {
7798 bIsSmartContract =
true;
7803 else if (
nullptr != pPlan) {
7821 otErr << __FUNCTION__
7822 <<
": ERROR: Should never happen: "
7823 "USER_ID didn't match this "
7824 "payment plan for sender OR "
7826 "(Expected one or the other.)\n";
7829 if (bIsSmartContract)
7834 const int32_t nPartyCount =
7837 for (int32_t nCurrentParty = 0;
7838 nCurrentParty < nPartyCount; ++nCurrentParty) {
7842 if (
nullptr != pParty) {
7843 const int32_t nAcctCount =
7846 for (int32_t nCurrentAcct = 0;
7847 nCurrentAcct < nAcctCount;
7852 if (
nullptr != pPartyAcct) {
7870 USER_ID, theAcctID, SERVER_ID);
7873 bSuccessLoadingSenderInbox =
7878 if (bSuccessLoadingSenderInbox) {
7883 if (GetPaymentReceipt(
7885 .GetTransactionMap(),
7890 lPaymentTransNum)) {
7891 bFoundReceiptInInbox =
true;
7907 if (bFoundReceiptInInbox)
break;
7914 OTLedger theSenderInbox(USER_ID, theSenderAcctID,
7917 const bool bSuccessLoadingSenderInbox =
7920 if (bSuccessLoadingSenderInbox) {
7938 if (
nullptr != pChequeReceipt) {
7939 bFoundReceiptInInbox =
true;
7944 else if (GetPaymentReceipt(
7946 lPaymentTransNum,
nullptr) ||
7950 bFoundReceiptInInbox =
true;
7967 if (bShouldHarvestPayment &&
7968 ((!bNeedToLoadAssetAcctInbox) ||
7969 (bNeedToLoadAssetAcctInbox && !bFoundReceiptInInbox))) {
7972 if (
nullptr != pSmartContract) {
7976 else if (
nullptr != pPlan) {
7982 SERVER_ID, lPaymentTransNum,
false);
7985 bNeedToSaveTheNym =
true;
8022 else if (bSaveCopy && (
nullptr != pActualBox) &&
8066 otErr << __FUNCTION__
8067 <<
": Failed trying to get 'valid to' from purse.\n";
8071 if (bSaveCopy && (
nullptr != pActualBox) &&
8072 (lPaymentTransNum > 0)) {
8079 if (
nullptr != pNewTransaction)
8092 pTransaction = pNewTransaction;
8094 theTransactionAngel.reset(pTransaction);
8099 otErr << __FUNCTION__
8100 <<
": Failed while trying to generate "
8101 "transaction in order to "
8102 "add a new transaction (for a payment "
8103 "instrument from the outpayments box) "
8104 "to Record Box: " << strUserID <<
"\n";
8113 theMessageAngel.reset(
8130 if (bSaveCopy && (
nullptr != pActualBox) && (
nullptr != pTransaction)) {
8136 otErr << __FUNCTION__ <<
": Unable to add transaction "
8138 <<
" to record box (after "
8139 "tentatively removing from payment "
8140 << (bIsInbox ?
"inbox" :
"outbox")
8141 <<
", an action that is now canceled.)\n";
8147 theTransactionAngel.release();
8172 const bool bSavedInbox =
8175 otOut <<
"/n" << __FUNCTION__
8176 <<
": Unable to Save PaymentInbox./n";
8182 bNeedToSaveTheNym =
true;
8184 if (bNeedToSaveTheNym) {
8189 otErr << __FUNCTION__ <<
": Unable to remove from payment "
8190 << (bIsInbox ?
"inbox" :
"outbox") <<
" based on index " << nIndex
8201 int32_t nIndex,
bool bClearAll)
const
8203 OTPseudonym* pNym = GetOrLoadPrivateNym(USER_ID,
false, __FUNCTION__);
8204 if (
nullptr == pNym)
return false;
8207 std::unique_ptr<OTLedger> pRecordBox(
8208 LoadRecordBox(SERVER_ID, USER_ID, ACCOUNT_ID));
8209 if (
nullptr == pRecordBox) {
8213 if (
nullptr == pRecordBox) {
8214 otErr << __FUNCTION__
8215 <<
": Unable to load or create record box "
8216 "(and thus unable to do anything with it.)\n";
8232 if ((nIndex < 0) || (nIndex >= nTransCount)) {
8233 otOut << __FUNCTION__
8234 <<
": Index out of bounds (highest allowed index for "
8235 "this record box is " << nTransCount - 1 <<
".)\n";
8239 bool bRemoved =
false;
8241 if (
nullptr != pTransaction) {
8245 otErr << __FUNCTION__
8246 <<
": Failed trying to delete the box receipt for a "
8247 "transaction being removed from a record box: "
8248 << lTransactionNum <<
"\n";
8260 const int32_t nTemp =
static_cast<int32_t
>(nIndex);
8261 otOut << __FUNCTION__
8262 <<
": Failed trying to clear a record from the record "
8263 "box at index: " << nTemp <<
"\n";
8277 OT_ASSERT_MSG(m_bInitialized,
"Not initialized; call OT_API::Init first.");
8279 otErr <<
"OT_API::ResyncNymWithServer: Error: Expected a Nymbox, "
8280 "but you passed in a " << theNymbox.
GetTypeString() <<
".\n";
8285 otErr <<
"OT_API::ResyncNymWithServer: Error: NymID of Nym (" << id1
8287 "doesn't match NymID on (supposedly) his own Nymbox "
8288 "(" << id2 <<
").\n";
8316 "Not initialized; call OT_API::Init first.");
8318 "OT_API::PopMessageBuffer: lRequestNumber is less than 1.");
8320 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
8329 "Not initialized; call OT_API::Init first.");
8353 "Not initialized; call OT_API::Init first.");
8355 "OT_API::GetSentMessage: lRequestNumber is less than 1.");
8357 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
8360 lRequestNumber, strServerID, strNymID);
8368 "Not initialized; call OT_API::Init first.");
8370 "OT_API::RemoveSentMessage: lRequestNumber is less than 1.");
8372 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
8375 lRequestNumber, strServerID, strNymID);
8446 "Not initialized; call OT_API::Init first.");
8448 GetNym(USER_ID, __FUNCTION__);
8449 if (
nullptr == pNym)
return;
8452 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
8453 if ((THE_NYMBOX.
GetUserID() != USER_ID) ||
8455 const OTString strLedger(THE_NYMBOX);
8456 otErr << __FUNCTION__ <<
": Failure, Bad input data: UserID ("
8457 << strNymID <<
") or ServerID "
8459 <<
") failed to match Nymbox:\n\n" << strLedger <<
"\n\n";
8483 if (
nullptr != pMessage)
8515 &strServerID, &strNymID, pNym,
8516 &bHarvestingForRetry);
8522 const int64_t& lRequestNumber)
const
8525 if (
nullptr == pNym)
return false;
8533 const OTString strServerID(SERVER_ID);
8547 GetAssetType(BASKET_ASSET_TYPE_ID, __FUNCTION__);
8548 if (
nullptr == pContract)
return false;
8559 if (theBasket.
Count() > 0)
return true;
8577 if (
nullptr == pContract)
return 0;
8588 return theBasket.
Count();
8607 if (
nullptr == pContract)
return false;
8617 if ((nIndex >= theBasket.
Count()) || (nIndex < 0)) {
8618 otErr <<
"OT_API::GetBasketMemberType: Index out of bounds: "
8625 "Bad index in OT_API::GetBasketMemberType");
8641 const OTIdentifier& BASKET_ASSET_TYPE_ID, int32_t nIndex)
const
8647 if (
nullptr == pContract)
return 0;
8657 if ((nIndex >= theBasket.
Count()) || (nIndex < 0)) {
8658 otErr <<
"OT_API::GetBasketMemberMinimumTransferAmount: Index "
8659 "out of bounds: " << nIndex <<
"\n";
8667 "Bad index in OT_API::GetBasketMemberMinimumTransferAmount.");
8673 otErr <<
"OT_API::GetBasketMemberMinimumTransferAmount: Failed "
8674 "loading basket info from basket asset contract.\n";
8691 if (
nullptr == pContract)
return 0;
8716 int64_t MINIMUM_TRANSFER)
const
8719 OTPseudonym* pNym = GetOrLoadPrivateNym(USER_ID,
false, __FUNCTION__);
8720 if (
nullptr == pNym)
return nullptr;
8723 int64_t lMinimumTransferAmount = 10;
8725 if (MINIMUM_TRANSFER > 0) lMinimumTransferAmount = MINIMUM_TRANSFER;
8726 Basket* pBasket =
new Basket(0, lMinimumTransferAmount);
8727 OT_ASSERT_MSG(
nullptr != pBasket,
"OT_API::GenerateBasketCreation: Error "
8728 "allocating memory in the OT API");
8743 int64_t MINIMUM_TRANSFER)
const
8746 if (
nullptr == pNym)
return false;
8752 if (
nullptr == pContract)
return false;
8773 if (
nullptr == pNym)
return (-1);
8777 if (
nullptr == pServer)
return (-1);
8780 OTString strServerID(SERVER_ID), strNymID(USER_ID);
8783 int64_t lRequestNumber = 0;
8788 "%ld", lRequestNumber);
8829 int32_t TRANSFER_MULTIPLE)
const
8832 USER_ID,
false, __FUNCTION__);
8833 if (
nullptr == pNym)
return nullptr;
8838 if (
nullptr == pContract)
return nullptr;
8843 if (
nullptr == pAccount)
return nullptr;
8847 const OTString strAcctID(BASKET_ASSET_ACCT_ID),
8848 strAcctTypeID(BASKET_ASSET_TYPE_ID);
8849 otOut <<
"OT_API::GenerateBasketExchange: Wrong asset type ID "
8850 "on account " << strAcctID <<
" (expected type to be "
8851 << strAcctTypeID <<
")\n";
8859 int32_t nTransferMultiple = 1;
8861 if (TRANSFER_MULTIPLE > 0) nTransferMultiple = TRANSFER_MULTIPLE;
8865 Basket* pRequestBasket =
nullptr;
8878 otOut <<
"OT_API::GenerateBasketExchange: you don't have "
8879 "enough transaction numbers to perform the "
8886 "OT_API::GenerateBasketExchange: Error allocating "
8887 "memory in the OT API");
8896 BASKET_ASSET_ACCT_ID);
8906 otOut <<
"OT_API::GenerateBasketExchange: Error loading "
8907 "basket info from asset contract. "
8908 "Are you SURE this is a basket currency?\n";
8911 return pRequestBasket;
8923 USER_ID,
false, __FUNCTION__);
8924 if (
nullptr == pNym)
return false;
8928 if (
nullptr == pContract)
return false;
8933 if (
nullptr == pAccount)
return false;
8937 otOut <<
"OT_API::AddBasketExchangeItem: you need at least one "
8938 "transaction number to add this exchange item.\n";
8942 const OTString strAssetTypeID(ASSET_TYPE_ID), strAcctID(ASSET_ACCT_ID);
8943 otOut <<
"OT_API::AddBasketExchangeItem: Wrong asset type ID "
8944 "on account " << strAcctID <<
" (expected to find asset type "
8945 << strAssetTypeID <<
")\n";
8951 const OTString strServerID(SERVER_ID);
8953 int64_t lSubClosingTransactionNo = 0;
8958 lSubClosingTransactionNo))
8961 lSubClosingTransactionNo);
8970 otErr <<
"OT_API::AddBasketExchangeItem: Failed getting next "
8971 "transaction number. \n";
9113 bool bExchangeInOrOut
9117 USER_ID,
false, __FUNCTION__);
9118 if (
nullptr == pNym)
return (-1);
9123 if (
nullptr == pServer)
return (-1);
9126 if (
nullptr == pContract)
return (-1);
9129 const OTString strServerID(SERVER_ID), strUserID(USER_ID);
9133 Basket theBasket, theRequestBasket;
9142 SERVER_ID, __FUNCTION__);
9143 if (
nullptr == pAccount)
return (-1);
9156 otOut <<
"OT_API::exchangeBasket: you don't have enough "
9157 "transaction numbers to perform the exchange.\n";
9160 int64_t lStoredTransactionNumber = 0;
9162 *pNym, strServerID, lStoredTransactionNumber);
9167 std::unique_ptr<OTLedger> pInbox(pAccount->LoadInbox(*pNym));
9168 std::unique_ptr<OTLedger> pOutbox(pAccount->LoadOutbox(*pNym));
9170 if (
nullptr == pInbox) {
9171 otOut <<
"OT_API::exchangeBasket: Failed loading inbox!\n";
9176 lStoredTransactionNumber,
9179 else if (
nullptr == pOutbox) {
9180 otOut <<
"OT_API::exchangeBasket: Failed loading outbox!\n";
9185 lStoredTransactionNumber,
9193 USER_ID, BASKET_ASSET_ACCT_ID, SERVER_ID,
9195 lStoredTransactionNumber);
9204 pTransaction->
AddItem(*pItem);
9213 int64_t lClosingTransactionNo =
9217 lClosingTransactionNo));
9221 lClosingTransactionNo);
9248 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
9251 *pTransaction, *pNym, *pAccount,
9258 pTransaction->
AddItem(*pBalanceItem);
9269 OTLedger theLedger(USER_ID, BASKET_ASSET_ACCT_ID,
9272 BASKET_ASSET_ACCT_ID, SERVER_ID,
9293 int64_t lRequestNumber = 0;
9296 "%ld", lRequestNumber);
9298 *pNym, strServerID);
9309 BASKET_ASSET_ACCT_ID.GetString(theMessage.
m_strAcctID);
9313 const std::string str_server(strServerID.Get());
9314 const bool bNymboxHash =
9319 otErr <<
"Failed getting NymboxHash from Nym for "
9320 "server: " << str_server <<
"\n";
9331 m_pTransportCallback);
9347 USER_ID,
false, __FUNCTION__);
9348 if (
nullptr == pNym)
return (-1);
9353 if (
nullptr == pServer)
return (-1);
9357 const int32_t nMaxCount = 50;
9360 if (nCount > nMaxCount) {
9361 otOut <<
"OT_API::getTransactionNumber: Failure: That Nym already has "
9362 "more than " << nMaxCount
9363 <<
" transaction numbers signed out. (Use those first.)\n";
9377 if (0 < nReturnValue) {
9379 m_pTransportCallback);
9382 return nReturnValue;
9385 otErr <<
"OT_API::getTransactionNumber: Error processing "
9386 "getTransactionNumber command. Return value: " << nReturnValue
9395 const int64_t& AMOUNT)
const
9399 if (
nullptr == pWallet)
return (-1);
9401 USER_ID,
false, __FUNCTION__);
9402 if (
nullptr == pNym)
return (-1);
9407 if (
nullptr == pServer)
return (-1);
9411 if (
nullptr == pAccount)
return (-1);
9415 OTString strContractID, strServerID(SERVER_ID);
9419 strContractID.
Get())) {
9420 otErr <<
"OT_API::notarizeWithdrawal: File does not exist: "
9429 const int64_t lTotalAmount = AMOUNT;
9430 int64_t lAmount = lTotalAmount;
9432 OTString strNymID(USER_ID), strFromAcct(ACCT_ID);
9434 int64_t lStoredTransactionNumber = 0;
9435 bool bGotTransNum =
false;
9436 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(*pNym));
9437 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
9439 if (
nullptr == pInbox) {
9440 otOut << __FUNCTION__ <<
": Error: Failed loading inbox!\n";
9443 if (
nullptr == pOutbox) {
9444 otOut << __FUNCTION__ <<
": Error: Failed loading outbox!\n";
9449 lStoredTransactionNumber);
9450 if (!bGotTransNum) {
9451 otOut << __FUNCTION__ <<
": Next Transaction Number Available: Suggest "
9452 "requesting the server for a new one.\n";
9459 lStoredTransactionNumber);
9472 if ((
nullptr != pServerNym) && pMint->LoadMint() &&
9474 int64_t lRequestNumber = 0;
9475 Purse* pPurse =
new Purse(SERVER_ID, CONTRACT_ID, SERVER_USER_ID);
9476 Purse* pPurseMyCopy =
new Purse(SERVER_ID, CONTRACT_ID, USER_ID);
9483 int64_t lTokenAmount = 0;
9484 while ((lTokenAmount = pMint->GetLargestDenomination(lAmount)) > 0) {
9485 lAmount -= lTokenAmount;
9493 std::unique_ptr<Token> pToken(
9495 *pPurse, *pNym, *pMint, lTokenAmount));
9499 pToken->SignContract(*pNym);
9500 pToken->SaveContract();
9507 pPurse->
Push(*pServerNym, *pToken);
9513 pToken->ReleaseSignatures();
9514 pToken->SetSavePrivateKeys();
9516 pToken->SignContract(*pNym);
9517 pToken->SaveContract();
9519 pPurseMyCopy->
Push(*pNym, *pToken);
9547 pPurseMyCopy =
nullptr;
9554 pTransaction->
AddItem(*pItem);
9560 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
9561 lTotalAmount * (-1), *pTransaction, *pNym, *pAccount, *pOutbox);
9563 if (
nullptr != pBalanceItem)
9565 pTransaction->
AddItem(*pBalanceItem);
9574 OTLedger theLedger(USER_ID, ACCT_ID, SERVER_ID);
9595 "%ld", lRequestNumber);
9612 const std::string str_server(strServerID.
Get());
9613 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
9617 otErr <<
"Failed getting NymboxHash from Nym for server: "
9618 << str_server <<
"\n";
9629 m_pTransportCallback);
9649 "Depositing a cash purse. Enter passphrase for the purse.");
9651 "Depositing a cash purse. Enter master passphrase for wallet.");
9653 USER_ID,
false, __FUNCTION__,
9655 if (
nullptr == pNym)
return (-1);
9660 if (
nullptr == pServer)
return (-1);
9664 if (
nullptr == pAccount)
return (-1);
9674 OTString strServerID(SERVER_ID), strNymID(USER_ID), strFromAcct(ACCT_ID);
9678 Purse thePurse(SERVER_ID, CONTRACT_ID, SERVER_USER_ID);
9680 int64_t lStoredTransactionNumber = 0;
9681 bool bGotTransNum =
false;
9682 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(*pNym));
9683 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
9685 if (
nullptr == pInbox) {
9686 otOut << __FUNCTION__ <<
": Error: Failed loading inbox!\n";
9689 if (
nullptr == pOutbox) {
9690 otOut << __FUNCTION__ <<
": Error: Failed loading outbox!\n";
9695 lStoredTransactionNumber);
9696 if (!bGotTransNum) {
9697 otOut << __FUNCTION__ <<
": Next Transaction Number Available: Suggest "
9698 "requesting the server for a new one.\n";
9702 if (
nullptr == pServerNym)
OT_FAIL;
9704 bool bSuccess =
false;
9709 lStoredTransactionNumber);
9734 Purse theSourcePurse(thePurse);
9736 std::unique_ptr<OTNym_or_SymmetricKey> pPurseOwner(
9738 THE_PURSE, theSourcePurse, thePassword,
9747 if (
nullptr != pPurseOwner) {
9750 while (!theSourcePurse.
IsEmpty()) {
9751 Token* pToken = theSourcePurse.
Pop(*pPurseOwner);
9753 if (
nullptr != pToken) {
9767 theServerNymAsOwner))
9769 otErr <<
"OT_API::notarizeDeposit: Error re-assigning "
9770 "ownership of token (to server.)\n";
9777 otLog3 <<
"OT_API::notarizeDeposit: Success "
9778 "re-assigning ownership of token (to "
9787 thePurse.
Push(theServerNymAsOwner, *pToken);
9796 otErr <<
"Error loading token from purse.\n";
9802 int64_t lRequestNumber = 0;
9818 pTransaction->
AddItem(*pItem);
9825 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
9826 pItem->
GetAmount(), *pTransaction, *pNym, *pAccount, *pOutbox);
9828 if (
nullptr != pBalanceItem)
9830 pTransaction->
AddItem(*pBalanceItem);
9839 OTLedger theLedger(USER_ID, ACCT_ID, SERVER_ID);
9857 pNym->GetCurrentRequestNum(strServerID, lRequestNumber);
9859 "%ld", lRequestNumber);
9860 pNym->IncrementRequestNum(*pNym, strServerID);
9876 const std::string str_server(strServerID.Get());
9877 const bool bNymboxHash = pNym->GetNymboxHash(str_server, NYMBOX_HASH);
9881 otErr <<
"Failed getting NymboxHash from Nym for server: "
9882 << str_server <<
"\n";
9893 m_pTransportCallback);
9902 delete pTransaction;
9903 pTransaction =
nullptr;
9930 const int64_t& AMOUNT_PER_SHARE)
const
9936 GetOrLoadPrivateNym(ISSUER_USER_ID,
false,
9938 if (
nullptr == pNym)
return (-1);
9942 GetServer(SERVER_ID, __FUNCTION__);
9943 if (
nullptr == pServer)
return (-1);
9946 GetOrLoadAccount(*pNym, DIVIDEND_FROM_ACCT_ID, SERVER_ID, __FUNCTION__);
9947 if (
nullptr == pDividendSourceAccount)
return (-1);
9951 SHARES_ASSET_TYPE_ID, __FUNCTION__);
9952 if (
nullptr == pSharesContract)
return (-1);
9955 GetWallet(__FUNCTION__);
9956 if (
nullptr == pWallet)
return (-1);
9960 if (
nullptr == pSharesIssuerAcct) {
9961 otErr << __FUNCTION__
9962 <<
": Failure: Unable to find issuer account for the "
9963 "shares asset type. Are you sure you're the issuer?\n";
9966 const OTIdentifier SHARES_ISSUER_ACCT_ID(*pSharesIssuerAcct);
9967 if (!pDividendSourceAccount->
VerifyOwner(*pNym)) {
9968 otErr << __FUNCTION__
9969 <<
": Failure: Nym doesn't verify as owner of the source "
9970 "account for the dividend payout.\n";
9974 otErr << __FUNCTION__
9975 <<
": Failure: Nym doesn't verify as owner of issuer "
9976 "account for the shares (the shares we're paying the dividend "
9981 "Assert (strange): issuer account should never have a "
9982 "higher-than-zero balance.\n");
9985 otErr << __FUNCTION__
9986 <<
": Failure: There are no shares issued for that asset type. "
9987 "(Therefore you cannot pay any dividend...)\n";
9990 const int64_t lAmountPerShare = AMOUNT_PER_SHARE;
9992 if (lAmountPerShare <= 0) {
9993 otErr << __FUNCTION__
9994 <<
": Failure: The amount per share must be larger than zero.\n";
10006 const int64_t lTotalCostOfDividend =
10007 ((-1) * pSharesIssuerAcct->
GetBalance()) * lAmountPerShare;
10011 if (pDividendSourceAccount->
GetBalance() < lTotalCostOfDividend) {
10012 otErr << __FUNCTION__ <<
": Failure: There's not enough ("
10014 <<
") in the source "
10015 "account, to cover the total cost of the dividend ("
10016 << lTotalCostOfDividend <<
".)\n";
10021 OTString strServerID(SERVER_ID), strNymID(ISSUER_USER_ID),
10022 strFromAcct(DIVIDEND_FROM_ACCT_ID);
10024 int64_t lStoredTransactionNumber = 0;
10026 lStoredTransactionNumber);
10028 if (bGotTransNum) {
10043 SERVER_ID, SHARES_ASSET_TYPE_ID);
10046 bool bIssueCheque = theRequestVoucher.
IssueCheque(
10048 lStoredTransactionNumber,
10051 VALID_FROM, VALID_TO, SHARES_ISSUER_ACCT_ID, ISSUER_USER_ID,
10071 std::unique_ptr<OTLedger> pInbox(
10072 pDividendSourceAccount->
LoadInbox(*pNym));
10073 std::unique_ptr<OTLedger> pOutbox(
10076 if (
nullptr == pInbox) {
10077 otOut << __FUNCTION__ <<
": Failed loading inbox for acct "
10078 << strFromAcct <<
"\n";
10083 lStoredTransactionNumber,
10086 else if (
nullptr == pOutbox) {
10087 otOut << __FUNCTION__ <<
": Failed loading outbox for acct "
10088 << strFromAcct <<
"\n";
10093 lStoredTransactionNumber,
10096 else if (!bIssueCheque) {
10100 lStoredTransactionNumber,
10106 ISSUER_USER_ID, DIVIDEND_FROM_ACCT_ID, SERVER_ID,
10112 pItem->
SetAmount(lTotalCostOfDividend);
10117 OTString strNote(
"Pay Dividend: ");
10127 OTString strVoucher(theRequestVoucher);
10136 pTransaction->
AddItem(*pItem);
10143 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
10144 lTotalCostOfDividend * (-1), *pTransaction, *pNym,
10145 *pDividendSourceAccount, *pOutbox);
10167 if (
nullptr != pBalanceItem)
10178 OTLedger theLedger(ISSUER_USER_ID, DIVIDEND_FROM_ACCT_ID,
10194 int64_t lRequestNumber = 0;
10199 "%ld", lRequestNumber);
10217 const std::string str_server(strServerID.Get());
10218 const bool bNymboxHash =
10223 otErr << __FUNCTION__
10224 <<
": Failed getting NymboxHash from Nym for server: "
10225 << str_server <<
"\n";
10235 m_pClient->SetFocusToServerAndNym(*pServer, *pNym,
10236 m_pTransportCallback);
10237 m_pClient->ProcessMessageOut(theMessage);
10239 return m_pClient->CalcReturnVal(lRequestNumber);
10243 otOut << __FUNCTION__
10244 <<
": No Transaction Numbers were available. "
10245 "Suggest requesting the server for a new one.\n";
10255 const int64_t& AMOUNT)
const
10258 USER_ID,
false, __FUNCTION__);
10259 if (
nullptr == pNym)
return (-1);
10264 if (
nullptr == pServer)
return (-1);
10268 if (
nullptr == pAccount)
return (-1);
10278 const int64_t lAmount = AMOUNT;
10280 OTString strServerID(SERVER_ID), strNymID(USER_ID), strFromAcct(ACCT_ID);
10282 int64_t lWithdrawTransNum = 0, lVoucherTransNum = 0;
10284 bool bGotTransNum1 =
10286 bool bGotTransNum2 =
10289 if (!bGotTransNum1 || !bGotTransNum2) {
10290 otOut << __FUNCTION__
10291 <<
": Not enough Transaction Numbers were available. "
10292 "(Suggest requesting the server for more.)\n";
10303 const OTString strChequeMemo(CHEQUE_MEMO);
10304 const OTString strRecipientUserID(RECIPIENT_USER_ID);
10314 OTCheque theRequestVoucher(SERVER_ID, CONTRACT_ID);
10315 bool bIssueCheque = theRequestVoucher.
IssueCheque(
10316 lAmount, lVoucherTransNum, VALID_FROM, VALID_TO, ACCT_ID, USER_ID,
10318 (strRecipientUserID.
GetLength() > 2) ? &(RECIPIENT_USER_ID) :
nullptr);
10319 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(*pNym));
10320 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
10322 if (
nullptr == pInbox) {
10323 otOut <<
"OT_API::" << __FUNCTION__
10324 <<
": Failed loading inbox for acct " << strFromAcct <<
"\n";
10332 else if (
nullptr == pOutbox) {
10333 otOut <<
"OT_API::" << __FUNCTION__
10334 <<
": Failed loading outbox for acct " << strFromAcct <<
"\n";
10342 else if (!bIssueCheque) {
10353 lWithdrawTransNum);
10366 OTString strVoucher(theRequestVoucher);
10374 pTransaction->
AddItem(*pItem);
10380 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
10381 lAmount * (-1), *pTransaction, *pNym, *pAccount, *pOutbox);
10383 if (
nullptr != pBalanceItem)
10384 pTransaction->
AddItem(*pBalanceItem);
10392 OTLedger theLedger(USER_ID, ACCT_ID, SERVER_ID);
10407 int64_t lRequestNumber = 0;
10412 "%ld", lRequestNumber);
10429 const std::string str_server(strServerID.Get());
10430 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
10434 otErr << __FUNCTION__
10435 <<
": Failed getting NymboxHash from Nym for server: "
10436 << str_server <<
"\n";
10447 m_pTransportCallback);
10520 USER_ID,
false, __FUNCTION__);
10521 if (
nullptr == pNym)
return false;
10526 if (
nullptr == pServer)
return false;
10530 if (
nullptr == pAccount)
return false;
10541 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
10543 OTCheque theCheque(SERVER_ID, CONTRACT_ID);
10546 otOut << __FUNCTION__ <<
": Unable to load cheque from string. Sorry. "
10547 "Cheque contents:\n\n" << THE_CHEQUE <<
"\n\n";
10550 else if ((theCheque.
GetServerID() == SERVER_ID) &&
10568 otOut << __FUNCTION__
10569 <<
": Failed attempt to claw back a transaction number that "
10570 "wasn't signed out to pNym in the first place. "
10571 "Cheque contents:\n\n" << THE_CHEQUE <<
"\n\n";
10576 otOut << __FUNCTION__
10577 <<
": Unable to verify cheque's server ID, asset type "
10578 "ID, user ID, or acct ID. Sorry. "
10579 "Cheque contents:\n\n" << THE_CHEQUE <<
"\n\n";
10596 USER_ID,
false, __FUNCTION__);
10597 if (
nullptr == pNym)
return (-1);
10602 if (
nullptr == pServer)
return (-1);
10606 if (
nullptr == pAccount)
return (-1);
10614 int64_t lRequestNumber = 0;
10616 OTString strServerID(SERVER_ID), strNymID(USER_ID), strDepositAcct(ACCT_ID);
10618 OTCheque theCheque(SERVER_ID, CONTRACT_ID);
10620 int64_t lStoredTransactionNumber = 0;
10622 lStoredTransactionNumber);
10625 otOut << __FUNCTION__ <<
": No transaction numbers were available. "
10626 "Try requesting the server for a new one.\n";
10628 otOut << __FUNCTION__
10629 <<
": Unable to load cheque from string. Sorry. Contents:\n\n"
10630 << THE_CHEQUE <<
"\n\n";
10637 otOut << __FUNCTION__ <<
": ServerID on cheque (" << strChequeServerID
10639 "match serverID where it's being deposited to (" << strServerID
10646 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(*pNym));
10648 if (
nullptr == pInbox) {
10649 otOut << __FUNCTION__ <<
": Failed loading inbox for acct "
10650 << strDepositAcct <<
"\n";
10654 lStoredTransactionNumber,
10662 bool bCancellingCheque =
false;
10670 if (bCancellingCheque)
10673 if (bCancellingCheque)
10684 if (!bCancellingCheque) {
10687 otOut << __FUNCTION__
10688 <<
": Cannot cancel this cheque. Either the "
10689 "signature fails to verify,\n"
10690 "or the transaction number is already closed "
10691 "out. (Failure.) Cheque contents:\n\n" << THE_CHEQUE
10697 lStoredTransactionNumber,
10709 if (
nullptr != pChequeReceipt)
10713 otOut << __FUNCTION__
10714 <<
": Cannot cancel this cheque. There is "
10718 <<
" for it in the inbox. "
10719 "(Failure.) Cheque contents:\n\n" << THE_CHEQUE
10724 lStoredTransactionNumber,
10736 if (bCancellingCheque && !theCheque.
HasRemitter()) {
10746 std::unique_ptr<OTTransaction> pTransaction(
10749 lStoredTransactionNumber));
10756 OTString strNote(bCancellingCheque
10757 ?
"Cancel this cheque, please!"
10758 :
"Deposit this cheque, please!");
10772 pTransaction->AddItem(*pItem);
10774 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
10776 if (
nullptr == pOutbox) {
10777 otOut <<
"OT_API::depositCheque: Failed loading outbox for acct "
10778 << strDepositAcct <<
"\n";
10782 lStoredTransactionNumber,
10790 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
10791 theCheque.
GetAmount(), *pTransaction, *pNym, *pAccount,
10797 pTransaction->AddItem(
10804 pTransaction->SignContract(*pNym);
10805 pTransaction->SaveContract();
10808 OTLedger theLedger(USER_ID, ACCT_ID, SERVER_ID);
10816 pTransaction.release();
10827 pNym->GetCurrentRequestNum(strServerID, lRequestNumber);
10829 "%ld", lRequestNumber);
10830 pNym->IncrementRequestNum(*pNym, strServerID);
10847 const std::string str_server(strServerID.Get());
10848 const bool bNymboxHash =
10849 pNym->GetNymboxHash(str_server, NYMBOX_HASH);
10853 otErr <<
"Failed getting NymboxHash from Nym for server: "
10854 << str_server <<
"\n";
10865 m_pTransportCallback);
10887 const OTString& THE_PAYMENT_PLAN)
const
10891 if (
nullptr == pServer)
return (-1);
10894 USER_ID,
false, __FUNCTION__);
10895 if (
nullptr == pNym)
return (-1);
10900 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
10904 int64_t lRequestNumber = 0;
10909 otErr << __FUNCTION__
10910 <<
": Error: attempted to cancel (pre-emptively, "
10911 "before activation) a payment plan "
10912 "that was already set as canceled.\n";
10918 otErr << __FUNCTION__
10919 <<
": Error: attempted to cancel (pre-emptively, "
10920 "before activation) a payment plan, "
10921 "but the attempt somehow failed.\n";
10939 const OTString strDepositAcct(DEPOSITOR_ACCT_ID);
10942 if (
nullptr == pAccount)
return (-1);
10980 pTransaction->
AddItem(*pItem);
10987 OTItem* pStatementItem =
10993 pTransaction->
AddItem(*pStatementItem);
11001 OTLedger theLedger(USER_ID, DEPOSITOR_ACCT_ID, SERVER_ID);
11021 "%ld", lRequestNumber);
11038 const std::string str_server(strServerID.Get());
11039 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
11043 otErr <<
"Failed getting NymboxHash from Nym for server: "
11044 << str_server <<
"\n";
11055 m_pTransportCallback);
11061 otOut <<
"Unable to load payment plan from string, or verify it. "
11076 const int64_t& lTransactionNum,
11081 USER_ID,
false, __FUNCTION__);
11082 if (
nullptr == pNym)
return (-1);
11087 if (
nullptr == pServer)
return (-1);
11090 int64_t lRequestNumber = 0;
11092 OTString strServerID(SERVER_ID), strNymID(USER_ID);
11097 "%ld", lRequestNumber);
11116 if ((
nullptr != pStrParam) && (pStrParam->
Exists()))
11120 const std::string str_server(strServerID.Get());
11121 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
11125 otErr <<
"Failed getting NymboxHash from Nym for server: " << str_server
11144 const OTString& THE_SMART_CONTRACT)
const
11147 USER_ID,
false, __FUNCTION__);
11148 if (
nullptr == pNym)
return (-1);
11153 if (
nullptr == pServer)
return (-1);
11157 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
11160 int64_t lRequestNumber = 0;
11164 if (
nullptr == pParty) {
11165 otOut << __FUNCTION__
11166 <<
": Failure: USER_ID *IS* a valid Nym, but that "
11167 "Nym is not the authorizing agent for any "
11168 "of the parties on this contract. Try calling "
11169 "ConfirmParty() first.\n";
11219 otOut <<
"Not all parties to smart contract are "
11220 "confirmed. Treating this as a request for "
11221 "cancelation...\n";
11224 otErr << __FUNCTION__
11225 <<
": Error: attempted to cancel (pre-emptively, "
11226 "before activation) a smart contract "
11227 "that was already set as canceled.\n";
11234 otErr << __FUNCTION__
11235 <<
": Error: attempted to cancel (pre-emptively, "
11236 "before activation) a smart contract, "
11237 "but the attempt somehow failed.\n";
11242 otOut << __FUNCTION__
11243 <<
": Failed. The server ID passed in doesn't "
11244 "match the one on the contract itself.\n";
11248 otOut << __FUNCTION__
11249 <<
": Failed. The activating Nym must not only be "
11250 "the authorizing agent for one of the parties, "
11251 "but must also be the authorized agent for one of "
11252 "that party's asset accounts. That party must have "
11253 "at least one asset account "
11254 "for this reason. (See code comment below this "
11255 "message, in the code.)\n";
11320 const std::string str_agent_name(pAgent->
GetName().
Get());
11323 if (
nullptr == pAcct) {
11324 otOut << __FUNCTION__
11325 <<
": Failed. The activating Nym must not only be "
11326 "the authorizing agent for one of the parties, "
11327 "but must also be the authorized agent for one of "
11328 "that party's asset accounts. That party must have "
11329 "at least one asset account "
11330 "for this reason. (See code comment above this "
11331 "message, in the code.)\n";
11334 const OTString& strAcctID = pAcct->GetAcctID();
11336 if (!strAcctID.
Exists()) {
11337 otOut << __FUNCTION__
11338 <<
": Failed. The Account ID is blank for asset acct ("
11339 << pAcct->GetName() <<
") for party ("
11341 <<
"). Did you confirm this account, before trying to "
11342 "activate this contract?\n";
11347 const int64_t lClosingTransNo = pAcct->GetClosingTransNo();
11349 if ((lOpeningTransNo <= 0) || (lClosingTransNo <= 0)) {
11350 otOut << __FUNCTION__ <<
": Failed. Opening Transaction # ("
11351 << lOpeningTransNo <<
") or "
11352 "Closing # (" << lClosingTransNo
11353 <<
") were invalid "
11354 "for asset acct (" << pAcct->GetName() <<
") for party ("
11357 "confirm this account and party, before trying to "
11358 "activate this contract?\n";
11362 otOut << __FUNCTION__ <<
": Failed. Opening Transaction # ("
11363 << lOpeningTransNo <<
") wasn't "
11364 "valid/issued to this Nym, "
11365 "for asset acct (" << pAcct->GetName()
11366 <<
") for party (" << pParty->
GetPartyName() <<
") on server "
11369 <<
"). Did you confirm this account and party, "
11370 "before trying to activate this contract?\n";
11374 otOut << __FUNCTION__ <<
": Failed. Closing Transaction # ("
11375 << lClosingTransNo <<
") wasn't "
11376 "issued to this Nym, "
11377 "for asset acct (" << pAcct->GetName()
11380 "confirm this account and party, "
11381 "before trying to activate this contract?\n";
11412 otErr << __FUNCTION__
11413 <<
": Failed re-signing contract, after calling "
11414 "PrepareToActivate().\n";
11419 const OTString strContract(theContract);
11434 pItem->SetAttachment(strContract);
11437 pItem->SignContract(*pNym);
11438 pItem->SaveContract();
11441 pTransaction->
AddItem(*pItem);
11447 OTItem* pStatementItem =
11453 pTransaction->
AddItem(*pStatementItem);
11460 OTLedger theLedger(USER_ID, theAcctID, SERVER_ID);
11478 "%ld", lRequestNumber);
11492 const std::string str_server(strServerID.Get());
11493 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
11496 otErr << __FUNCTION__
11497 <<
": Failed getting NymboxHash from Nym for server: "
11498 << str_server <<
"\n";
11508 m_pTransportCallback);
11514 otOut << __FUNCTION__
11515 <<
": Unable to load smart contract from string:\n\n"
11516 << THE_SMART_CONTRACT <<
"\n\n";
11576 const int64_t& lTransactionNum)
const
11582 USER_ID,
false, __FUNCTION__);
11583 if (
nullptr == pNym)
return (-1);
11587 GetServer(SERVER_ID, __FUNCTION__);
11588 if (
nullptr == pServer)
return (-1);
11592 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
11595 otOut <<
"OT_API::cancelCronItem: At least 1 Transaction Number is "
11596 "necessary to cancel any cron item. "
11597 "Try requesting the server for more numbers (you are low.)\n";
11600 int64_t lStoredTransactionNumber = 0;
11602 *pNym, strServerID, lStoredTransactionNumber,
true);
11605 otErr <<
"OT_API::cancelCronItem: Supposedly there was a "
11606 "transaction number available, but the call\n"
11609 int64_t lRequestNumber = 0;
11611 OTString str_ASSET_ACCT_ID(ASSET_ACCT_ID);
11616 lStoredTransactionNumber);
11622 "Error allocating memory in the OT API");
11637 pTransaction->
AddItem(*pItem);
11643 OTItem* pStatementItem =
11649 pTransaction->
AddItem(*pStatementItem);
11657 OTLedger theLedger(USER_ID, ASSET_ACCT_ID, SERVER_ID);
11677 "%ld", lRequestNumber);
11694 const std::string str_server(strServerID.Get());
11695 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
11699 otErr <<
"Failed getting NymboxHash from Nym for server: "
11700 << str_server <<
"\n";
11710 m_pClient->SetFocusToServerAndNym(*pServer, *pNym,
11711 m_pTransportCallback);
11712 m_pClient->ProcessMessageOut(theMessage);
11714 return m_pClient->CalcReturnVal(lRequestNumber);
11726 const int64_t& MARKET_SCALE,
11728 const int64_t& MINIMUM_INCREMENT,
11730 const int64_t& TOTAL_ASSETS_ON_OFFER,
11733 const int64_t& PRICE_LIMIT,
11734 bool bBuyingOrSelling,
11737 int64_t ACTIVATION_PRICE)
const
11741 USER_ID,
false, __FUNCTION__);
11742 if (
nullptr == pNym)
return (-1);
11746 GetServer(SERVER_ID, __FUNCTION__);
11747 if (
nullptr == pServer)
return (-1);
11750 GetOrLoadAccount(*pNym, ASSET_ACCT_ID, SERVER_ID, __FUNCTION__);
11751 if (
nullptr == pAssetAccount)
return (-1);
11754 GetOrLoadAccount(*pNym, CURRENCY_ACCT_ID, SERVER_ID, __FUNCTION__);
11755 if (
nullptr == pCurrencyAccount)
return (-1);
11759 if (ASSET_TYPE_ID == CURRENCY_TYPE_ID) {
11760 otOut << __FUNCTION__
11761 <<
": The asset account and currency account cannot "
11762 "have the same asset type ID. (You can't, for "
11763 "example, trade dollars against other dollars. Why "
11764 "bother trading them in the first place?)\n";
11768 const OTString strServerID(SERVER_ID), strNymID(USER_ID);
11770 otOut << __FUNCTION__
11771 <<
": At least 3 Transaction Numbers are necessary to "
11772 "issue a market offer. "
11773 "Try requesting the server for more (you are low.)\n";
11776 int64_t lStoredTransactionNumber = 0, lAssetAcctClosingNo = 0,
11777 lCurrencyAcctClosingNo = 0;
11779 *pNym, strServerID, lStoredTransactionNumber,
false);
11781 *pNym, strServerID, lAssetAcctClosingNo,
11784 *pNym, strServerID, lCurrencyAcctClosingNo,
true);
11785 if (!bGotTransNum || !bGotAssetClosingNum || !bGotCurrencyClosingNum) {
11786 otErr << __FUNCTION__
11787 <<
": Supposedly there were 3 transaction numbers "
11788 "available, but the call(s)\n"
11789 "still failed. (Re-adding back to Nym, and failing out "
11790 "of this function.)\n";
11793 lStoredTransactionNumber,
11795 if (bGotAssetClosingNum)
11798 if (bGotCurrencyClosingNum)
11801 if (bGotTransNum || bGotAssetClosingNum || bGotCurrencyClosingNum)
11805 const time64_t VALID_FROM = GetTime();
11813 : tLifespanInSeconds));
11814 int64_t lTotalAssetsOnOffer = 1, lMinimumIncrement = 1,
11816 lMarketScale = 1, lActivationPrice = 0;
11817 if (TOTAL_ASSETS_ON_OFFER > 0)
11818 lTotalAssetsOnOffer =
11819 TOTAL_ASSETS_ON_OFFER;
11820 if (MARKET_SCALE > 0)
11821 lMarketScale = MARKET_SCALE;
11822 if (MINIMUM_INCREMENT > 0)
11823 lMinimumIncrement = MINIMUM_INCREMENT;
11824 if (PRICE_LIMIT > 0)
11825 lPriceLimit = PRICE_LIMIT;
11827 char cStopSign = 0;
11829 if ((ACTIVATION_PRICE > 0) &&
11830 ((
'<' == STOP_SIGN) || (
'>' == STOP_SIGN))) {
11831 cStopSign = STOP_SIGN;
11832 lActivationPrice = ACTIVATION_PRICE;
11834 lMinimumIncrement *= lMarketScale;
11838 OTString strOfferType(
"market order");
11840 if (lPriceLimit > 0) strOfferType =
"limit order";
11842 if (0 != cStopSign) {
11843 if (lPriceLimit > 0)
11844 strOfferType.
Format(
"stop limit order, at threshhold: %c%ld",
11845 cStopSign, lActivationPrice);
11847 strOfferType.
Format(
"stop order, at threshhold: %c%ld",
11848 cStopSign, lActivationPrice);
11853 if (lPriceLimit > 0) strPrice.
Format(
"Price: %ld\n", lPriceLimit);
11855 otOut <<
"Placing market offer " << lStoredTransactionNumber
11856 <<
", type: " << (bBuyingOrSelling ?
"selling" :
"buying") <<
", "
11857 << strOfferType <<
"\n" << strPrice
11858 <<
"Assets for sale/purchase: " << lTotalAssetsOnOffer
11860 "In minimum increments of: " << lMinimumIncrement
11862 "At market of scale: " << lMarketScale
11867 OTOffer theOffer(SERVER_ID, ASSET_TYPE_ID, CURRENCY_TYPE_ID,
11869 OTTrade theTrade(SERVER_ID, ASSET_TYPE_ID, ASSET_ACCT_ID, USER_ID,
11870 CURRENCY_TYPE_ID, CURRENCY_ACCT_ID);
11873 bool bCreateOffer = theOffer.
MakeOffer(
11876 lTotalAssetsOnOffer,
11879 lStoredTransactionNumber,
11885 bool bIssueTrade =
false;
11887 if (bCreateOffer) {
11889 if (bCreateOffer) {
11891 if (bCreateOffer) {
11893 theOffer, cStopSign,
11909 if (bIssueTrade) bIssueTrade = theTrade.
SaveContract();
11914 if (bCreateOffer && bIssueTrade) {
11915 int64_t lRequestNumber = 0;
11916 OTString str_ASSET_ACCT_ID(ASSET_ACCT_ID);
11921 lStoredTransactionNumber);
11936 OT_ASSERT_MSG(
nullptr != pItem,
"OT_API::issueMarketOffer: Error "
11937 "allocating memory in the OT API");
11953 pTransaction->
AddItem(*pItem);
11960 OTItem* pStatementItem =
11976 OTLedger theLedger(USER_ID, ASSET_ACCT_ID, SERVER_ID);
11996 "%ld", lRequestNumber);
12014 const std::string str_server(strServerID.Get());
12015 const bool bNymboxHash =
12020 otErr << __FUNCTION__ <<
": Failed getting NymboxHash from Nym "
12021 "for server: " << str_server <<
"\n";
12031 m_pClient->SetFocusToServerAndNym(*pServer, *pNym,
12032 m_pTransportCallback);
12033 m_pClient->ProcessMessageOut(theMessage);
12035 return m_pClient->CalcReturnVal(lRequestNumber);
12039 otOut << __FUNCTION__
12040 <<
": Unable to create offer or issue trade. Sorry.\n";
12046 lStoredTransactionNumber,
12051 *pNym, strServerID, lCurrencyAcctClosingNo,
12076 USER_ID,
false, __FUNCTION__);
12077 if (
nullptr == pNym)
return (-1);
12082 if (
nullptr == pServer)
return (-1);
12088 int64_t lRequestNumber = 0;
12091 "%ld", lRequestNumber);
12130 const int64_t& lDepth)
const
12133 USER_ID,
false, __FUNCTION__);
12134 if (
nullptr == pNym)
return (-1);
12139 if (
nullptr == pServer)
return (-1);
12143 OTString strServerID(SERVER_ID), strMarketID(MARKET_ID);
12146 int64_t lRequestNumber = 0;
12149 "%ld", lRequestNumber);
12198 USER_ID,
false, __FUNCTION__);
12199 if (
nullptr == pNym)
return (-1);
12204 if (
nullptr == pServer)
return (-1);
12208 OTString strServerID(SERVER_ID), strMarketID(MARKET_ID);
12210 int64_t lRequestNumber = 0;
12213 "%ld", lRequestNumber);
12255 USER_ID,
false, __FUNCTION__);
12256 if (
nullptr == pNym)
return (-1);
12261 if (
nullptr == pServer)
return (-1);
12268 int64_t lRequestNumber = 0;
12271 "%ld", lRequestNumber);
12306 const int64_t& AMOUNT,
12310 if (
nullptr == pNym)
return (-1);
12315 if (
nullptr == pServer)
return (-1);
12319 if (
nullptr == pAccount)
return (-1);
12323 const int64_t lAmount = AMOUNT;
12325 OTString strServerID(SERVER_ID), strNymID(USER_ID), strFromAcct(ACCT_FROM),
12326 strToAcct(ACCT_TO);
12328 int64_t lStoredTransactionNumber = 0;
12330 lStoredTransactionNumber);
12332 if (bGotTransNum) {
12336 lStoredTransactionNumber);
12353 pTransaction->
AddItem(*pItem);
12355 std::unique_ptr<OTLedger> pInbox(pAccount->
LoadInbox(*pNym));
12356 std::unique_ptr<OTLedger> pOutbox(pAccount->
LoadOutbox(*pNym));
12358 if (
nullptr == pInbox) {
12359 otOut <<
"OT_API::notarizeTransfer: Failed loading inbox for acct: "
12360 << strFromAcct <<
"\n";
12364 lStoredTransactionNumber,
12367 else if (
nullptr == pOutbox) {
12368 otOut <<
"OT_API::notarizeTransfer: Failed loading outbox "
12369 "for acct: " << strFromAcct <<
"\n";
12373 lStoredTransactionNumber,
12377 int64_t lRequestNumber = 0;
12392 OT_ASSERT(
nullptr != pOutboxTransaction);
12407 pOutbox->AddTransaction(*pOutboxTransaction);
12416 OTItem* pBalanceItem = pInbox->GenerateBalanceStatement(
12417 lAmount * (-1), *pTransaction, *pNym, *pAccount, *pOutbox);
12432 OTLedger theLedger(USER_ID, ACCT_FROM, SERVER_ID);
12452 "%ld", lRequestNumber);
12470 const std::string str_server(strServerID.Get());
12471 const bool bNymboxHash =
12476 otErr <<
"Failed getting NymboxHash from Nym for server: "
12477 << str_server <<
"\n";
12488 m_pTransportCallback);
12495 otOut <<
"No transaction numbers were available. Suggest "
12496 "requesting the server for one.\n";
12511 if (
nullptr == pNym)
return (-1);
12516 if (
nullptr == pServer)
return (-1);
12519 int64_t lRequestNumber = 0;
12521 OTString strServerID(SERVER_ID), strNymID(USER_ID);
12526 "%ld", lRequestNumber);
12559 if (
nullptr == pNym)
return (-1);
12564 if (
nullptr == pServer)
return (-1);
12568 if (
nullptr == pAccount)
return (-1);
12571 int64_t lRequestNumber = 0;
12573 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCT_ID);
12578 "%ld", lRequestNumber);
12613 if (
nullptr == pNym)
return (-1);
12618 if (
nullptr == pServer)
return (-1);
12622 if (
nullptr == pAccount)
return (-1);
12625 int64_t lRequestNumber = 0;
12627 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCT_ID);
12632 "%ld", lRequestNumber);
12671 if (
nullptr == pNym)
return (-1);
12677 if (
nullptr == pServer)
return (-1);
12680 bool bSuccess =
false;
12681 int32_t nReceiptCount = (-1);
12682 int32_t nRequestNum = (-1);
12683 bool bIsEmpty =
true;
12690 OTLedger theNymbox(USER_ID, USER_ID, SERVER_ID);
12692 bool bLoadedNymbox = theNymbox.
LoadNymbox();
12693 bool bVerifiedNymbox =
12696 if (!bLoadedNymbox)
12697 otOut <<
"OT_API::processNymbox: Failed loading Nymbox: "
12698 << strNymID <<
" \n";
12699 else if (!bVerifiedNymbox)
12700 otOut <<
"OT_API::processNymbox: Failed verifying Nymbox: "
12701 << strNymID <<
" \n";
12704 bIsEmpty = (nReceiptCount < 1);
12708 theNymbox, SERVER_ID, theServer, theNym, theMessage);
12712 otWarn <<
"OT_API::processNymbox: Nymbox (" << strNymID
12714 "empty (so, skipping processNymbox.)\n";
12719 otOut <<
"OT_API::processNymbox: Failed trying to "
12720 "accept the entire Nymbox. (And no, it's "
12722 nReceiptCount = (-1);
12728 const OTString strServerID(SERVER_ID);
12729 const std::string str_server(strServerID.
Get());
12730 const bool bNymboxHash =
12735 otErr <<
"Failed getting NymboxHash from Nym for server: "
12736 << str_server <<
"\n";
12758 m_pTransportCallback);
12761 return nRequestNum;
12764 else if (!bIsEmpty)
12765 otErr <<
"Error performing processNymbox command in "
12766 "OT_API::processNymbox\n";
12768 return nReceiptCount;
12774 const OTString& ACCT_LEDGER)
const
12777 if (
nullptr == pNym)
return (-1);
12782 if (
nullptr == pServer)
return (-1);
12786 if (
nullptr == pAccount)
return (-1);
12789 int64_t lRequestNumber = 0;
12791 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCT_ID);
12796 "%ld", lRequestNumber);
12817 const std::string str_server(strServerID.Get());
12818 const bool bNymboxHash = pNym->
GetNymboxHash(str_server, NYMBOX_HASH);
12822 otErr <<
"Failed getting NymboxHash from Nym for server: " << str_server
12841 const OTString& THE_CONTRACT)
const
12844 if (
nullptr == pWallet)
return (-1);
12846 if (
nullptr == pNym)
return (-1);
12851 if (
nullptr == pServer)
return (-1);
12856 std::string str_Trim(THE_CONTRACT.
Get());
12858 OTString strTrimContract(str_Trim2.c_str());
12861 if (!theAssetContract.LoadContractFromString(strTrimContract)) {
12862 otOut << __FUNCTION__
12863 <<
": Failed trying to load asset contract from string:\n\n"
12864 << strTrimContract <<
"\n\n";
12868 theAssetContract.CalculateContractID(newID);
12869 theAssetContract.SetIdentifier(newID);
12871 int64_t lRequestNumber = 0;
12873 OTString strServerID(SERVER_ID), strNymID(USER_ID);
12878 "%ld", lRequestNumber);
12892 OTString strAssetContract(theAssetContract);
12923 otOut << __FUNCTION__
12924 <<
": Failed(2) trying to load asset contract "
12925 "from string:\n\n" << strTrimContract <<
"\n\n";
12928 otOut << __FUNCTION__ <<
": Failed verifying asset contract:\n\n"
12929 << strTrimContract <<
"\n\n";
12942 pContract =
nullptr;
12947 m_pTransportCallback);
12961 if (
nullptr == pNym)
return (-1);
12966 if (
nullptr == pServer)
return (-1);
12969 int64_t lRequestNumber = 0;
12971 OTString strServerID(SERVER_ID), strNymID(USER_ID),
12972 strAssetTypeID(ASSET_ID);
12977 "%ld", lRequestNumber);
13011 if (
nullptr == pNym)
return (-1);
13016 if (
nullptr == pServer)
return (-1);
13020 if (
nullptr == pAssetContract)
return (-1);
13023 int64_t lRequestNumber = 0;
13025 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13026 strAssetTypeID(ASSET_ID);
13031 "%ld", lRequestNumber);
13152 if (
nullptr == pNym)
return (-1);
13157 if (
nullptr == pServer)
return (-1);
13160 int64_t lRequestNumber = 0;
13162 OTString strServerID(SERVER_ID), strNymID(USER_ID);
13167 "%ld", lRequestNumber);
13201 if (
nullptr == pNym)
return (-1);
13206 if (
nullptr == pServer)
return (-1);
13210 if (
nullptr == pAssetContract)
return (-1);
13213 int64_t lRequestNumber = 0;
13215 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13216 strAssetTypeID(ASSET_ID);
13221 "%ld", lRequestNumber);
13255 if (
nullptr == pNym)
return (-1);
13260 if (
nullptr == pServer)
return (-1);
13264 if (
nullptr == pAccount)
return (-1);
13268 int64_t lRequestNumber = 0;
13270 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCOUNT_ID);
13275 "%ld", lRequestNumber);
13310 const int64_t& lTransactionNum)
const
13314 SERVER_ID, USER_ID,
13326 const int64_t& lTransactionNum)
const
13329 if (
nullptr == pNym)
return (-1);
13334 if (
nullptr == pServer)
return (-1);
13336 if (USER_ID != ACCOUNT_ID)
13341 if (
nullptr == pAccount)
return (-1);
13352 int64_t lRequestNumber = 0;
13354 const OTString strServerID(SERVER_ID), strNymID(USER_ID),
13355 strAcctID(ACCOUNT_ID);
13360 "%ld", lRequestNumber);
13374 theMessage.
m_lDepth =
static_cast<int64_t
>(nBoxType);
13397 USER_ID,
false, __FUNCTION__);
13398 if (
nullptr == pNym)
return (-1);
13403 if (
nullptr == pServer)
return (-1);
13407 if (
nullptr == pAccount)
return (-1);
13411 int64_t lRequestNumber = 0;
13413 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCT_ID);
13418 "%ld", lRequestNumber);
13452 USER_ID,
false, __FUNCTION__);
13453 if (
nullptr == pNym)
return (-1);
13458 if (
nullptr == pServer)
return (-1);
13462 if (
nullptr == pAccount)
return (-1);
13466 int64_t lRequestNumber = 0;
13468 OTString strServerID(SERVER_ID), strNymID(USER_ID), strAcctID(ACCT_ID);
13473 "%ld", lRequestNumber);
13506 USER_ID,
false, __FUNCTION__);
13507 if (
nullptr == pNym)
return (-1);
13512 if (
nullptr == pServer)
return (-1);
13519 if (0 < nReturnValue) {
13521 m_pTransportCallback);
13524 return nReturnValue;
13527 otErr <<
"Error processing getRequest command in OT_API::getRequest\n";
13535 int64_t lAdjustment)
const
13538 USER_ID,
false, __FUNCTION__);
13539 if (
nullptr == pNym)
return (-1);
13544 if (
nullptr == pServer)
return (-1);
13547 int64_t lRequestNumber = 0;
13549 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13550 strNymID2(USER_ID_CHECK);
13555 "%ld", lRequestNumber);
13569 theMessage.
m_lDepth = lAdjustment;
13592 USER_ID,
false, __FUNCTION__);
13593 if (
nullptr == pNym)
return (-1);
13598 if (
nullptr == pServer)
return (-1);
13601 int64_t lRequestNumber = 0;
13603 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13604 strNymID2(USER_ID_CHECK);
13609 "%ld", lRequestNumber);
13643 const OTString& THE_MESSAGE)
const
13646 USER_ID,
false, __FUNCTION__);
13647 if (
nullptr == pNym)
return (-1);
13652 if (
nullptr == pServer)
return (-1);
13655 int64_t lRequestNumber = 0;
13657 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13658 strNymID2(USER_ID_RECIPIENT);
13663 "%ld", lRequestNumber);
13681 int32_t nReturnValue = -1;
13683 if (!pPubkey->SetPublicKey(RECIPIENT_PUBKEY)) {
13684 otOut <<
"OT_API::sendUserMessage: Failed setting public key.\n";
13686 else if (THE_MESSAGE.
Exists() &&
13687 theEnvelope.
Seal(*pPubkey, THE_MESSAGE) &&
13698 m_pTransportCallback);
13727 otOut <<
"OT_API::sendUserMessage: Failed sealing envelope.\n";
13729 return nReturnValue;
13747 const OTPayment* pINSTRUMENT_FOR_SENDER)
const
13761 USER_ID,
false, __FUNCTION__);
13762 if (
nullptr == pNym)
return (-1);
13766 GetServer(SERVER_ID, __FUNCTION__);
13767 if (
nullptr == pServer)
return (-1);
13770 int32_t nReturnValue = -1;
13771 int64_t lRequestNumber = 0;
13773 OTString strServerID(SERVER_ID), strNymID(USER_ID),
13774 strNymID2(USER_ID_RECIPIENT);
13775 OTString strInstrument, strInstrumentForSender;
13776 const bool bGotPaymentContents =
13777 THE_INSTRUMENT.GetPaymentContents(strInstrument);
13778 const bool bGotSenderPmntCnts =
13779 (
nullptr == pINSTRUMENT_FOR_SENDER)
13781 : pINSTRUMENT_FOR_SENDER->GetPaymentContents(
13782 strInstrumentForSender);
13785 if (!THE_INSTRUMENT.IsPurse()) {
13797 int64_t lTempTransNum = 0;
13798 bool bGotTransNum =
13799 THE_INSTRUMENT.GetOpeningNum(lTempTransNum, USER_ID);
13800 int32_t lOutpaymentsIndex =
13804 if (lOutpaymentsIndex > (-1))
13810 lOutpaymentsIndex))
13813 otErr << __FUNCTION__
13814 <<
": Error calling RemoveOutpaymentsByIndex for Nym: "
13815 << strNymID <<
"\n";
13825 otOut << __FUNCTION__
13826 <<
": FYI, didn't remove an older copy of the "
13827 "instrument from the payments outbox, "
13828 "since I couldn't find it in there.\n";
13831 std::unique_ptr<OTMessage> pMessage(
new OTMessage);
13842 if (USER_ID != USER_ID_RECIPIENT) {
13846 "%ld", lRequestNumber);
13863 otOut << __FUNCTION__
13864 <<
": Failed setting public key from string ===>"
13865 << RECIPIENT_PUBKEY <<
"<===\n";
13867 else if (bGotPaymentContents &&
13868 theEnvelope.
Seal(*pPubkey, strInstrument) &&
13895 m_pClient->SetFocusToServerAndNym(*pServer, *pNym,
13896 m_pTransportCallback);
13897 m_pClient->ProcessMessageOut(theMessage);
13898 nReturnValue = m_pClient->CalcReturnVal(lRequestNumber);
13901 otOut << __FUNCTION__ <<
": Failed sealing envelope.\n";
13926 "%ld", lRequestNumber);
13936 return nReturnValue;
13969 USER_ID,
false, __FUNCTION__);
13970 if (
nullptr == pNym)
return (-1);
13975 if (
nullptr == pServer)
return (-1);
13982 if (0 < nReturnValue) {
13984 m_pTransportCallback);
13987 return nReturnValue;
13990 otErr <<
"OT_API::createUserAccount: Error in "
13991 "m_pClient->ProcessUserCommand() \n";
14000 USER_ID,
false, __FUNCTION__);
14001 if (
nullptr == pNym)
return (-1);
14006 if (
nullptr == pServer)
return (-1);
14013 if (0 < nReturnValue) {
14015 m_pTransportCallback);
14018 return nReturnValue;
14021 otErr <<
"Error processing deleteUserAccount command in "
14022 "OT_API::deleteUserAccount\n";
14031 USER_ID,
false, __FUNCTION__);
14032 if (
nullptr == pNym)
return (-1);
14037 if (
nullptr == pServer)
return (-1);
14044 if (0 < nReturnValue) {
14046 m_pTransportCallback);
14049 return nReturnValue;
14052 otErr <<
"Error processing checkServerID command in "
14053 "OT_API::checkServerID\n";
EXPORT bool ResyncNymWithServer(OTPseudonym &theNym, const OTLedger &theNymbox, const OTPseudonym &theMessageNym) const
static EXPORT OTCrypto * It()
EXPORT bool GetNym(int32_t iIndex, OTIdentifier &NYM_ID, OTString &NYM_NAME)
static EXPORT const OTString & Mint()
EXPORT int32_t NumList_Count(const OTNumList &theList) const
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT OTPseudonym * GetOrLoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr)
static EXPORT void Cleanup()
EXPORT int32_t deleteUserAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool VerifyAccountReceipt(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool AddSignature(const OTIdentifier &theSignerNymID, const OTString &strContract, OTString &strOutput) const
EXPORT bool RemoveTransaction(int64_t lTransactionNum, bool bDeleteIt=true)
std::map< std::string, std::string > Map
EXPORT bool Wallet_RemoveNym(const OTIdentifier &NYM_ID) const
#define CLIENT_MASTER_KEY_TIMEOUT_DEFAULT
EXPORT bool Wallet_CanRemoveAssetType(const OTIdentifier &ASSET_ID) const
void SetAmount(int64_t lAmount)
EXPORT Purse * CreatePurse(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &OWNER_ID) const
EXPORT bool SetAccount_Name(const OTIdentifier &ACCT_ID, const OTIdentifier &SIGNER_NYM_ID, const OTString &ACCT_NEW_NAME) const
EXPORT bool Encrypt(const OTIdentifier &theRecipientNymID, const OTString &strPlaintext, OTString &strOutput) const
EXPORT bool GetPassphrase(OTPassword &theOutput, const char *szDisplay=nullptr)
EXPORT bool SetFocusToServerAndNym(OTServerContract &theServerContract, OTPseudonym &theNym, TransportCallback *pCallback) const
static EXPORT OTAsymmetricKey * KeyFactory()
static EXPORT OTPseudonym * LoadPublicNym(const OTIdentifier &NYM_ID, const OTString *pstrName=nullptr, const char *szFuncName=nullptr)
EXPORT bool SetWallet(const OTString &strFilename)
EXPORT Storable * CreateObject(StoredObjectType eType)
int32_t GetTransactionCount() const
EXPORT int32_t issueBasket(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTString &BASKET_INFO) const
EXPORT OTMessage * GetSentMessage(const int64_t &requestNum, const OTString &serverId, const OTString &nymId)
EXPORT void AddAssetContract(const OTAssetContract &theContract) const
EXPORT bool SmartContract_AddClause(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &BYLAW_NAME, const OTString &CLAUSE_NAME, const OTString &SOURCE_CODE, OTString &strOutput) const
static EXPORT bool InitOTApp()
EXPORT OTAccount * GetOrLoadAccount(const OTPseudonym &theNym, const OTIdentifier &ACCT_ID, const OTIdentifier &SERVER_ID, const char *szFuncName=nullptr)
EXPORT bool GetRemitterAcctID(OTIdentifier &theOutput) const
static EXPORT OTTransaction * GenerateTransaction(const OTIdentifier &theUserID, const OTIdentifier &theAccountID, const OTIdentifier &theServerID, transactionType theType, int64_t lTransactionNum=0)
EXPORT bool AddBasketExchangeItem(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, Basket &theBasket, const OTIdentifier &ASSET_TYPE_ID, const OTIdentifier &ASSET_ACCT_ID) const
EXPORT int32_t GetAccountCount()
const OTIdentifier & GetRequestAccountID()
EXPORT const char * GetDisplayString() const
int32_t CalcReturnVal(const int64_t &lRequestNumber)
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
EXPORT bool IsNymIDIncluded() const
static EXPORT bool CleanupOTApp()
EXPORT int32_t getMarketOffers(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &MARKET_ID, const int64_t &lDepth) const
EXPORT bool ChangePassphrasesOnExtraKeys(const OTPassword &oldPassphrase, const OTPassword &newPassphrase)
EXPORT int32_t cancelCronItem(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ASSET_ACCT_ID, const int64_t &lTransactionNum) const
static EXPORT bool DoesCertfileExist(const OTString &strNymID)
EXPORT std::string GetPartyName(bool *pBoolSuccess=nullptr) const
EXPORT int32_t createAssetAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ASSET_ID) const
EXPORT bool IsCanceled() const
EXPORT OTPseudonym * GetOrLoadNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr) const
EXPORT void AddRequestSubContract(const OTIdentifier &SUB_CONTRACT_ID, const OTIdentifier &SUB_ACCOUNT_ID, const int64_t &lClosingTransactionNo)
EXPORT bool VerifyBoxReceiptExists(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nBoxType, const int64_t &lTransactionNum)
EXPORT bool GetConnectInfo(OTString &strHostname, int32_t &nPort) const
const OTIdentifier & GetSenderUserID() const
static EXPORT Mint * MintFactory()
EXPORT OTItem * GenerateTransactionStatement(const OTTransaction &theOwner)
EXPORT bool SavePurse(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &USER_ID, Purse &THE_PURSE) const
EXPORT bool ClawbackTransactionNumber(const OTIdentifier &theServerID, const int64_t &lTransClawback, bool bSave=false, OTPseudonym *pSIGNER_NYM=nullptr)
EXPORT OTLedger * LoadRecordBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool Wallet_RemoveAssetType(const OTIdentifier &ASSET_ID) const
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
EXPORT OTAccount * GetAccountPartialMatch(std::string PARTIAL_ID)
EXPORT bool IsPasswordProtected() const
EXPORT bool RemoveSentMessage(const int64_t &requestNum, const OTString &serverId, const OTString &nymId)
EXPORT bool SetProposal(OTPseudonym &MERCHANT_NYM, const OTString &strConsideration, time64_t VALID_FROM=OT_TIME_ZERO, time64_t VALID_TO=OT_TIME_ZERO)
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 bool SmartContract_AddCallback(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &BYLAW_NAME, const OTString &CALLBACK_NAME, const OTString &CLAUSE_NAME, OTString &strOutput) const
EXPORT void SetAcknowledgments(OTPseudonym &theNym)
EXPORT int64_t GetBasketMinimumTransferAmount(const OTIdentifier &BASKET_ASSET_TYPE_ID) const
EXPORT OTParty * FindPartyBasedOnNymAsAuthAgent(OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
static EXPORT bool GetConfigFilePath(OTString &strConfigFilePath)
EXPORT bool LoadRecordBox()
EXPORT OTLedger * LoadNymboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool HasContext() const
EXPORT int32_t queryAssetTypes(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTASCIIArmor &ENCODED_MAP) const
int64_t m_lTransactionNum
virtual EXPORT bool VerifyAccount(const OTPseudonym &theNym)
EXPORT bool Decode(const OTString &strEncoded, OTString &strOutput, bool bLineBreaks=true) const
EXPORT bool Wallet_CanRemoveServer(const OTIdentifier &SERVER_ID) const
EXPORT OTLedger * LoadInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT const OTIdentifier & GetAssetTypeID() const
EXPORT int32_t checkServerID(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
int64_t GetTransactionNum() const
EXPORT int32_t issueMarketOffer(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ASSET_ACCT_ID, const OTIdentifier &CURRENCY_ACCT_ID, const int64_t &MARKET_SCALE, const int64_t &MINIMUM_INCREMENT, const int64_t &TOTAL_ASSETS_ON_OFFER, const int64_t &PRICE_LIMIT, bool bBuyingOrSelling, time64_t tLifespanInSeconds=OT_TIME_DAY_IN_SECONDS, char STOP_SIGN=0, int64_t ACTIVATION_PRICE=0) const
EXPORT bool Push(OTNym_or_SymmetricKey theOwner, const Token &theToken)
EXPORT bool DeleteBoxReceipt(const int64_t &lTransactionNum)
EXPORT OTAssetContract * GetAssetContract(const OTIdentifier &theContractID)
EXPORT int32_t GetServerCount() const
EXPORT time64_t GetTime() const
static EXPORT OTTransactionType * TransactionFactory(OTString strInput)
EXPORT int64_t GetBalance() const
const int64_t & GetAmount() const
EXPORT char const * GetTypeString() const
EXPORT bool SetNym_Name(const OTIdentifier &NYM_ID, const OTIdentifier &SIGNER_NYM_ID, const OTString &NYM_NEW_NAME) const
#define CLIENT_CONFIG_KEY
EXPORT int64_t GetBasketMemberMinimumTransferAmount(const OTIdentifier &BASKET_ASSET_TYPE_ID, int32_t nIndex) const
EXPORT int32_t notarizeTransfer(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_FROM, const OTIdentifier &ACCT_TO, const int64_t &AMOUNT, const OTString &NOTE) const
EXPORT bool SaveContract()
#define CLIENT_DEFAULT_LATENCY_RECEIVE_MS
static EXPORT OTScriptable * InstantiateScriptable(const OTString &strInput)
EXPORT bool VerifyIssuedNum(const OTString &strServerID, const int64_t &lTransNum) const
EXPORT Purse * CreatePurse_Passphrase(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID) const
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
EXPORT void AddOutmail(OTMessage &theMessage)
int64_t GetMinimumTransfer() const
#define OTDB_DEFAULT_PACKER
EXPORT int32_t getMarketRecentTrades(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &MARKET_ID) const
static EXPORT const char * PathSeparator()
virtual void HarvestOpeningNumber(OTPseudonym &theNym)
EXPORT bool AllPartiesHaveSupposedlyConfirmed()
EXPORT OTLedger * LoadOutbox(OTPseudonym &nym) const
EXPORT OTPseudonym * CreateNym(int32_t nKeySize=1024, const std::string str_id_source="", const std::string str_alt_location="") const
EXPORT bool SmartContract_AddParty(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &PARTY_NAME, const OTString &AGENT_NAME, OTString &strOutput) const
EXPORT bool Create_SmartContract(const OTIdentifier &SIGNER_NYM_ID, time64_t VALID_FROM, time64_t VALID_TO, OTString &strOutput) const
EXPORT bool GetNextTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t &lTransNum, bool bSave=true)
EXPORT int32_t getMint(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ASSET_ID) const
EXPORT int32_t payDividend(const OTIdentifier &SERVER_ID, const OTIdentifier &ISSUER_USER_ID, const OTIdentifier &DIVIDEND_FROM_ACCT_ID, const OTIdentifier &SHARES_ASSET_TYPE_ID, const OTString &DIVIDEND_MEMO, const int64_t &AMOUNT_PER_SHARE) const
const OTIdentifier & GetAssetID() const
EXPORT int32_t getInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID) const
EXPORT bool VerifyMint(const OTPseudonym &theOperator)
EXPORT bool VerifyTentativeNum(const OTString &strServerID, const int64_t &lTransNum) const
EXPORT int32_t processInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const OTString &ACCT_LEDGER) const
EXPORT void AddServerContract(const OTServerContract &theContract)
static EXPORT bool SetLogLevel(const int32_t &nLogLevel)
EXPORT bool SaveRecordBox()
EXPORT bool VerifySignature(const OTString &strContract, const OTIdentifier &theSignerNymID, OTContract **ppContract=nullptr) const
EXPORT void AddPendingWithdrawal(const Purse &thePurse)
EXPORT bool GetTransactionNum(int64_t &lOutput) const
EXPORT bool SetServer_Name(const OTIdentifier &SERVER_ID, const OTString &STR_NEW_NAME) const
EXPORT bool DoesBoxReceiptExist(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nBoxType, const int64_t &lTransactionNum) const
EXPORT TransportCallback * GetTransportCallback() const
EXPORT OTWallet * GetWallet(const char *szFuncName=nullptr) const
EXPORT int32_t activateSmartContract(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTString &THE_SMART_CONTRACT) const
EXPORT OTTrackable * Instantiate() const
EXPORT bool AddBasketCreationItem(const OTIdentifier &USER_ID, Basket &theBasket, const OTIdentifier &ASSET_TYPE_ID, int64_t MINIMUM_TRANSFER) const
EXPORT bool SmartContract_AddBylaw(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &BYLAW_NAME, OTString &strOutput) const
EXPORT bool InitDefaultStorage(StorageType eStoreType, PackType ePackType)
EXPORT bool AddTransaction(OTTransaction &theTransaction)
EXPORT void GetPrivateCredentials(OTString &strCredList, OTString::Map *pmapCredFiles=nullptr)
EXPORT OTPseudonym * GetNymByIDPartialMatch(std::string PARTIAL_ID)
OTLOG_IMPORT OTLogStream otOut
EXPORT void AddAssetContract(const OTAssetContract &theContract)
EXPORT bool Encode(const OTString &strPlaintext, OTString &strOutput, bool bLineBreaks=true) const
EXPORT int32_t GetBasketMemberCount(const OTIdentifier &BASKET_ASSET_TYPE_ID) const
bool ProcessServerReply(OTMessage &theReply, OTLedger *pNymbox=nullptr)
EXPORT bool Wallet_ChangePassphrase() const
#define OT_TIME_MONTH_IN_SECONDS
EXPORT OTPseudonym * GetOrLoadNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr)
EXPORT int32_t depositCheque(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const OTString &THE_CHEQUE) const
EXPORT bool Wallet_ImportNym(const OTString &FILE_CONTENTS, OTIdentifier *pNymID=nullptr) const
EXPORT OTLedger * LoadOutbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool HarvestClosingNumbers(const OTIdentifier &SERVER_ID, const OTIdentifier &NYM_ID, const OTString &THE_CRON_ITEM) const
void SetNymName(const OTString &strName)
EXPORT bool ReEncryptPrivateCredentials(bool bImporting, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr)
OTLOG_IMPORT OTLogStream otLog3
EXPORT void SetAttachment(const OTString &theStr)
const OTIdentifier & GetAssetID() const
EXPORT bool Wallet_ExportCert(const OTIdentifier &NYM_ID, OTString &strOutput) const
EXPORT int32_t withdrawVoucher(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const OTIdentifier &RECIPIENT_USER_ID, const OTString &CHEQUE_MEMO, const int64_t &AMOUNT) const
EXPORT void AddOutpayments(OTMessage &theMessage)
static EXPORT Purse * PurseFactory(OTString strInput)
EXPORT bool ClearExpired(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, int32_t nIndex, bool bClearAll=false) const
EXPORT bool SaveContractRaw(OTString &strOutput) const
EXPORT bool Peek(int64_t &lPeek) const
const OTIdentifier & GetRemitterAcctID() const
EXPORT bool GetAccount(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT uint32_t GetLength() const
EXPORT bool GetAssetType(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME) 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 SetAsciiArmoredData(const OTASCIIArmor &theArmoredText, bool bLineBreaks=true)
EXPORT OTPseudonym * LoadPublicNym(const OTIdentifier &NYM_ID, const char *szFuncName=nullptr) const
EXPORT OTAccount * GetIssuerAccount(const OTIdentifier &theAssetTypeID)
EXPORT int32_t GetAssetTypeCount()
EXPORT OTLedger * LoadPaymentInbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool IssueTrade(OTOffer &offer, char stopSign=0, int64_t stopPrice=0)
EXPORT bool IsInitialized() const
EXPORT OTAccount * LoadAssetAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool Open(const OTPseudonym &theRecipient, OTString &theOutput, const OTPasswordData *pPWData=nullptr)
EXPORT bool NumList_Remove(OTNumList &theList, const OTNumList &theOldNumbers) const
EXPORT void Concatenate(const char *arg,...)
EXPORT bool Seal(const OTPseudonym &theRecipient, const OTString &theInput)
EXPORT OTPseudonym * GetOrLoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr) const
EXPORT bool DiscardCheque(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const OTString &THE_CHEQUE) const
EXPORT OTAgent * GetAuthorizedAgent()
EXPORT bool GetOpeningNum(int64_t &lOutput, const OTIdentifier &theNymID) const
EXPORT std::mutex * GetMutex()
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 Token * Token_ChangeOwner(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTString &THE_TOKEN, const OTIdentifier &SIGNER_NYM_ID, const OTString &OLD_OWNER, const OTString &NEW_OWNER, const OTString *pstrDisplay=nullptr) const
void OpenPid(const OTString &strPidFilePath)
EXPORT bool SignContract(OTContract &theInput) const
EXPORT OTMessage * PopMessageBuffer(const int64_t &lRequestNumber, const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
void SetTransferMultiple(int32_t nTransferMultiple)
#define OT_TIME_SIX_MONTHS_IN_SECONDS
static EXPORT bool IsInitialized()
EXPORT int32_t getRequest(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool RemoveSentMessage(const int64_t &lRequestNumber, const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool HarvestAllNumbers(const OTIdentifier &SERVER_ID, const OTIdentifier &NYM_ID, const OTString &THE_CRON_ITEM) const
EXPORT Purse * Purse_Empty(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTString &THE_PURSE, const OTString *pstrDisplay=nullptr) const
static EXPORT OTItem * CreateItemFromTransaction(const OTTransaction &theOwner, OTItem::itemType theType, const OTIdentifier *pDestinationAcctID=nullptr)
#define CLIENT_DEFAULT_LATENCY_DELAY_AFTER
EXPORT bool SavePaymentInbox()
EXPORT void ReleaseSignatures()
EXPORT bool Exists() const
EXPORT bool SetString(const OTString &theData, bool bLineBreaks=true)
EXPORT bool VerifyAndRetrieveXMLContents(const OTString &strContract, const OTIdentifier &theSignerNymID, OTString &strOutput)
Verify and Retrieve XML Contents.
EXPORT bool SetPaymentPlan(const int64_t &lPaymentAmount, time64_t tTimeUntilPlanStart=OT_TIME_MONTH_IN_SECONDS, time64_t tBetweenPayments=OT_TIME_MONTH_IN_SECONDS, time64_t tPlanLength=OT_TIME_ZERO, int32_t nMaxPayments=0)
static EXPORT std::shared_ptr< OTCachedKey > It(OTIdentifier *pIdentifier=nullptr)
EXPORT bool RemoveAssetContract(const OTIdentifier &theTargetID)
EXPORT bool SmartContract_AddHook(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &BYLAW_NAME, const OTString &HOOK_NAME, const OTString &CLAUSE_NAME, OTString &strOutput) const
EXPORT std::string EncodeObject(Storable &theContents)
EXPORT void SetString(const char *szString)
EXPORT bool GetAccount(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME) const
static EXPORT bool Init(const OTString &strThreadContext)
EXPORT bool GetServer(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME) const
EXPORT bool GetBasketMemberType(const OTIdentifier &BASKET_ASSET_TYPE_ID, int32_t nIndex, OTIdentifier &theOutputMemberType) const
EXPORT int32_t SmartContract_CountNumsNeeded(const OTString &THE_CONTRACT, const OTString &AGENT_NAME) const
EXPORT bool IsValidSigner(OTPseudonym &theNym)
#define CLIENT_DEFAULT_LATENCY_SEND_MS
static EXPORT bool LoadFromString(OTASCIIArmor &ascArmor, const OTString &strInput, std::string str_bookend="-----BEGIN")
EXPORT int32_t sendUserInstrument(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &USER_ID_RECIPIENT, const OTString &RECIPIENT_PUBKEY, const OTPayment &THE_INSTRUMENT, const OTPayment *pINSTRUMENT_FOR_SENDER=nullptr) const
EXPORT int32_t depositPaymentPlan(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTString &THE_PAYMENT_PLAN) const
EXPORT bool ClearRecord(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nIndex, bool bClearAll=false) const
virtual void HarvestOpeningNumber(OTPseudonym &theNym)
EXPORT bool SetPublicKey(const OTASCIIArmor &strKey)
EXPORT OTLedger * LoadPaymentInboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool RemoveNym(const OTIdentifier &theTargetID)
const OTIdentifier & GetServerID() const
EXPORT void Format(const char *fmt,...)
EXPORT void ReleaseTransactions()
static EXPORT bool Init(const OTString &strThreadContext="", const int32_t &nLogLevel=0)
#define OT_TIME_DAY_IN_SECONDS
EXPORT bool SmartContract_ConfirmParty(const OTString &THE_CONTRACT, const OTString &PARTY_NAME, const OTIdentifier &NYM_ID, OTString &strOutput) const
EXPORT int32_t GetOutpaymentsCount() const
return the number of payments items available for this Nym.
static EXPORT const char * Version()
OTMessageOutbuffer & GetMessageOutbuffer()
static EXPORT const OTString & Credential()
EXPORT void SetReferenceString(const OTString &theStr)
EXPORT bool Init(const Defaults &defaults)
EXPORT Basket * GenerateBasketExchange(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &BASKET_ASSET_TYPE_ID, const OTIdentifier &BASKET_ASSET_ACCT_ID, int32_t TRANSFER_MULTIPLE) const
static EXPORT OTPassword * GetPassphraseFromUser(const OTString *pstrDisplay=nullptr, bool bAskTwice=false)
EXPORT const OTPseudonym * GetContractPublicNym() const
EXPORT bool Compare(const char *compare) const
int32_t GetPartyCount() const
EXPORT void PrepareToActivate(const int64_t &lOpeningTransNo, const int64_t &lClosingTransNo, const OTIdentifier &theUserID, const OTIdentifier &theAcctID)
EXPORT OTAssetContract * LoadAssetContract(const OTIdentifier &ASSET_ID) const
EXPORT const OTString & GetName()
static EXPORT Token * InstantiateAndGenerateTokenRequest(const Purse &thePurse, const OTPseudonym &theNym, Mint &theMint, int64_t lDenomination, int32_t nTokenCount=Token::GetMinimumPrototokenCount())
#define CLIENT_DEFAULT_IS_BLOCKING
EXPORT void CancelCheque()
static EXPORT void SetupSignalHandler()
EXPORT bool LoadWallet() const
EXPORT Basket * GenerateBasketCreation(const OTIdentifier &USER_ID, int64_t MINIMUM_TRANSFER) const
EXPORT Purse * Purse_Pop(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTString &THE_PURSE, const OTIdentifier *pOWNER_ID=nullptr, const OTString *pstrDisplay=nullptr) const
EXPORT bool VerifyOwner(const OTPseudonym &candidate) const
void ProcessMessageOut(const char *buf, int32_t *pnExpectReply) const
EXPORT OTMessage * Pop(const int64_t &requestNum, const OTString &serverId, const OTString &nymId)
const OTIdentifier & GetPurportedServerID() const
EXPORT int32_t usageCredits(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &USER_ID_CHECK, int64_t lAdjustment=0) const
EXPORT OTServerContract * LoadServerContract(const OTIdentifier &SERVER_ID) const
EXPORT bool GetPaymentContents(OTString &strOutput) const
EXPORT bool ConvertNymToCachedKey(OTPseudonym &theNym)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
time64_t OTTimeGetCurrentTime()
EXPORT bool SetTransportCallback(TransportCallback *pTransportCallback)
EXPORT int32_t deleteAssetAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool RecordPayment(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, bool bIsInbox, int32_t nIndex, bool bSaveCopy) const
EXPORT OTSymmetricKey * GetInternalKey()
EXPORT bool GetSenderUserID(OTIdentifier &theOutput) const
EXPORT bool GenerateNym(int32_t nBits=1024, bool bCreateFile=true, std::string str_id_source="", std::string str_alt_location="")
#define CLIENT_WALLET_FILENAME
EXPORT int32_t GetServerCount()
EXPORT bool AddTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t lTransNum, bool bSave)
EXPORT void Clear(const OTString *serverId=nullptr, const OTString *nymId=nullptr, OTPseudonym *nym=nullptr, const bool *harvestingForRetry=nullptr)
EXPORT bool TransportFunction(const OTServerContract &theServerContract, const OTEnvelope &theEnvelope) const
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
OTTransaction * LoadBoxReceipt(OTTransaction &theAbbrev, OTLedger &theLedger)
EXPORT bool Wallet_ImportCert(const OTString &DISPLAY_NAME, const OTString &FILE_CONTENTS, OTIdentifier *pNymID=nullptr) const
EXPORT OTPseudonym * GetNymByID(const OTIdentifier &NYM_ID)
EXPORT bool Confirm(OTPseudonym &PAYER_NYM, OTPseudonym *pMERCHANT_NYM=nullptr, const OTIdentifier *p_id_MERCHANT_NYM=nullptr)
EXPORT bool Wallet_CanRemoveNym(const OTIdentifier &NYM_ID) const
bool AcceptEntireNymbox(OTLedger &theNymbox, const OTIdentifier &theServerID, const OTServerContract &theServerContract, OTPseudonym &theNym, OTMessage &theMessage)
EXPORT OTPseudonym * GetNymByIDPartialMatch(const std::string PARTIAL_ID, const char *szFuncName=nullptr) const
EXPORT bool SaveExpiredBox()
EXPORT bool LoadWallet(const char *szFilename=nullptr)
EXPORT bool GetAsciiArmoredData(OTASCIIArmor &theArmoredText, bool bLineBreaks=true) const
EXPORT Purse * Purse_Push(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTString &THE_PURSE, const OTString &THE_TOKEN, const OTIdentifier *pOWNER_ID=nullptr, const OTString *pstrDisplay=nullptr) const
#define CLIENT_PID_FILENAME
EXPORT bool Msg_HarvestTransactionNumbers(const OTMessage &theMsg, const OTIdentifier &USER_ID, bool bHarvestingForRetry, bool bReplyWasSuccess, bool bReplyWasFailure, bool bTransactionWasSuccess, bool bTransactionWasFailure) const
int64_t GetAmount() const
EXPORT int32_t GetAccountCount() const
EXPORT bool GetCurrentRequestNum(const OTString &strServerID, int64_t &lReqNum) const
#define CLIENT_DEFAULT_LATENCY_RECEIVE_NO_TRIES
virtual EXPORT bool Send(const OTASCIIArmor &ascEnvelope)=0
int64_t GetDenomination() const
bool FlatSign(const OTIdentifier &theSignerNymID, const OTString &strInput, const OTString &strContractType, OTString &strOutput) const
EXPORT Purse * LoadPurse(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID, const OTIdentifier &USER_ID, const OTString *pstrDisplay=nullptr) const
EXPORT OTPaymentPlan * ProposePaymentPlan(const OTIdentifier &SERVER_ID, const time64_t &VALID_FROM, const time64_t &VALID_TO, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &SENDER_USER_ID, const OTString &PLAN_CONSIDERATION, const OTIdentifier &RECIPIENT_ACCT_ID, const OTIdentifier &RECIPIENT_USER_ID, const int64_t &INITIAL_PAYMENT_AMOUNT, const time64_t &INITIAL_PAYMENT_DELAY, const int64_t &PAYMENT_PLAN_AMOUNT, const time64_t &PAYMENT_PLAN_DELAY, const time64_t &PAYMENT_PLAN_PERIOD, time64_t PAYMENT_PLAN_LENGTH=OT_TIME_ZERO, int32_t PAYMENT_PLAN_MAX_PAYMENTS=0) const
EXPORT OTPseudonym * GetOrLoadPublicNym(const OTIdentifier &NYM_ID, const char *szFuncName=nullptr) const
EXPORT OTLedger * LoadInbox(OTPseudonym &nym) const
EXPORT OTAssetContract * GetAssetContractPartialMatch(std::string PARTIAL_ID)
EXPORT bool SetDateRange(time64_t VALID_FROM=OT_TIME_ZERO, time64_t VALID_TO=OT_TIME_ZERO)
EXPORT bool Set_str(const OTString &strSection, const OTString &strKey, const OTString &strValue, bool &out_bNewOrUpdate, const OTString &strComment="")
static EXPORT const OTString & Receipt()
bool InitClient(OTWallet &theWallet)
Need to call this before using.
EXPORT int32_t getMarketList(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
#define OT_ASSERT_MSG(x, s)
virtual EXPORT bool NewContext()=0
OTPayment * GetInstrument(const OTPseudonym &theNym, const int32_t &nIndex, OTLedger &ledger)
EXPORT int32_t getOutbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID) const
EXPORT BasketItem * At(uint32_t nIndex)
static EXPORT OTLedger * GenerateLedger(const OTIdentifier &theUserID, const OTIdentifier &theAcctID, const OTIdentifier &theServerID, ledgerType theType, bool bCreateFile=false)
void FlushMessageBuffer()
EXPORT OTLedger * LoadNymbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool NumList_VerifyAll(const OTNumList &theList, const OTNumList &theQueryNumbers) const
OTLOG_IMPORT OTLogStream otInfo
virtual EXPORT bool LoadContract()
EXPORT OTParty * GetParty(std::string str_party_name) const
EXPORT OTAccount * LoadAccount(const OTPseudonym &theNym, const OTIdentifier &ACCT_ID, const OTIdentifier &SERVER_ID, const char *szFuncName=nullptr)
EXPORT bool CompareID(const OTIdentifier &theIdentifier) const
ledgerType GetType() const
EXPORT OTTransaction * GetTransactionByIndex(int32_t nIndex) const
static EXPORT OTPseudonym * LoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const OTString *pstrName=nullptr, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr)
EXPORT int32_t Count() const
EXPORT bool IsRegisteredAtServer(const OTString &strServerID) const
const OTIdentifier & GetRemitterUserID() const
#define CLIENT_USE_SYSTEM_KEYRING
EXPORT bool SaveWallet(const char *szFilename=nullptr)
EXPORT int32_t notarizeWithdrawal(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const int64_t &AMOUNT) const
EXPORT void AddServerContract(const OTServerContract &pContract) const
EXPORT Token * Purse_Peek(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTString &THE_PURSE, const OTIdentifier *pOWNER_ID=nullptr, const OTString *pstrDisplay=nullptr) const
EXPORT bool CancelBeforeActivation(OTPseudonym &theCancelerNym)
EXPORT bool GetSenderAcctID(OTIdentifier &theOutput) const
EXPORT bool IsNym_RegisteredAtServer(const OTIdentifier &NYM_ID, const OTIdentifier &SERVER_ID) const
EXPORT OTPartyAccount * GetAccountByAgent(const std::string &str_agent_name)
EXPORT void SetNote(const OTString &theStr)
EXPORT bool CheckSet_str(const OTString &strSection, const OTString &strKey, const OTString &strDefault, OTString &out_strResult, bool &out_bIsNew, const OTString &strComment="")
static EXPORT bool ConfirmCreateFolder(const OTString &strExactPath, bool &out_Exists, bool &out_IsNew)
EXPORT bool GetNymboxHash(const std::string &server_id, OTIdentifier &theOutput) const
EXPORT int32_t notarizeDeposit(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID, const OTString &THE_PURSE) const
EXPORT bool SetInitialPayment(const int64_t &lAmount, time64_t tTimeUntilInitialPayment=OT_TIME_ZERO)
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 bool SetTempValues()
EXPORT bool SaveBoxReceipt(int64_t lLedgerType)
EXPORT OTMessage * GetSentMessage(const int64_t &lRequestNumber, const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT int32_t getAccountFiles(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID) const
EXPORT void FlushSentMessages(bool bHarvestingForRetry, const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTLedger &THE_NYMBOX) const
OTLOG_IMPORT OTLogStream otWarn
EXPORT bool WalletExists() const
EXPORT bool NumList_VerifyQuery(const OTNumList &theList, const OTNumList &theQueryNumbers) const
virtual EXPORT bool Receive(OTString &strServerReply)=0
EXPORT const char * Get() const
EXPORT bool ReassignOwnership(OTNym_or_SymmetricKey &oldOwner, OTNym_or_SymmetricKey &newOwner)
EXPORT int32_t triggerClause(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const int64_t &lTransactionNum, const OTString &strClauseName, const OTString *pStrParam=nullptr) const
EXPORT int32_t createUserAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
transactionType GetType() const
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
OTLOG_IMPORT OTLogStream otErr
void SetExchangingIn(bool bDirection)
virtual EXPORT int64_t GetOpeningNumber(const OTIdentifier &theNymID) const
EXPORT bool Decrypt(const OTIdentifier &theRecipientNymID, const OTString &strCiphertext, OTString &strOutput) const
EXPORT bool LoadExpiredBox()
EXPORT int64_t GetTransactionNum() const
EXPORT bool SetWalletFilename(const OTString &strPath)
EXPORT OTNym_or_SymmetricKey * LoadPurseAndOwnerFromString(const OTIdentifier &theServerID, const OTIdentifier &theAssetTypeID, const OTString &strPurse, Purse &thePurse, OTPassword &thePassword, bool bForEncrypting=true, const OTIdentifier *pOWNER_ID=nullptr, const OTString *pstrDisplay1=nullptr, const OTString *pstrDisplay2=nullptr) const
EXPORT OTPseudonym * LoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr) const
EXPORT bool CheckSet_long(const OTString &strSection, const OTString &strKey, const int64_t &lDefault, int64_t &out_lResult, bool &out_bIsNew, const OTString &strComment="")
std::map< std::string, std::string > the_map
EXPORT bool GetValidTo(time64_t &tOutput) const
virtual void HarvestClosingNumbers(OTPseudonym &theNym)
EXPORT bool ConfirmPaymentPlan(const OTIdentifier &SERVER_ID, const OTIdentifier &SENDER_USER_ID, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &RECIPIENT_USER_ID, OTPaymentPlan &thePlan) const
const OTString & GetAcctID() const
EXPORT OTLedger * LoadExpiredBox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT bool SmartContract_AddAccount(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &PARTY_NAME, const OTString &ACCT_NAME, const OTString &ASSET_TYPE_ID, OTString &strOutput) const
EXPORT void SetReferenceToNum(int64_t lTransactionNum)
EXPORT int32_t getNymbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
#define CLIENT_DEFAULT_LATENCY_SEND_NO_TRIES
EXPORT bool IsValid() const
EXPORT bool SavePurse(const char *szServerID=nullptr, const char *szUserID=nullptr, const char *szAssetTypeID=nullptr)
OTASCIIArmor m_ascPayload
EXPORT bool IsBasketCurrency(const OTIdentifier &BASKET_ASSET_TYPE_ID) const
EXPORT Mint * LoadMint(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_ID) const
OTPseudonym * GetNym() const
EXPORT const OTIdentifier & GetConstID() const
virtual EXPORT void HarvestClosingNumbers(OTPseudonym &theNym)
EXPORT OTLedger * LoadRecordBoxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool RemoveOutpaymentsByIndex(int32_t nIndex, bool bDeleteIt=true)
EXPORT int32_t randomizePassword(uint32_t size=DEFAULT_SIZE)
int32_t GetOutpaymentsIndexByTransNum(const OTPseudonym &nym, int64_t lTransNum)
EXPORT bool IsExpired(bool &bExpired)
EXPORT bool SmartContract_ConfirmAccount(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &PARTY_NAME, const OTString &ACCT_NAME, const OTString &AGENT_NAME, const OTString &ACCT_ID, OTString &strOutput) const
EXPORT bool SetAssetType_Name(const OTIdentifier &ASSET_ID, const OTString &STR_NEW_NAME) const
EXPORT bool Verify(const int64_t &theValue) const
EXPORT void GetString(OTString &theStr) const
OTIdentifier SUB_CONTRACT_ID
EXPORT void Cleanup() const
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
const OTIdentifier & GetRecipientUserID() const
const OTIdentifier & GetSenderAcctID() const
virtual EXPORT bool VerifyContract()
bool Wallet_ImportPurse(const OTIdentifier &SERVER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTIdentifier &SIGNER_ID, const OTString &THE_PURSE, const OTString *pstrDisplay=nullptr)
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 OTCheque * WriteCheque(const OTIdentifier &SERVER_ID, const int64_t &CHEQUE_AMOUNT, const time64_t &VALID_FROM, const time64_t &VALID_TO, const OTIdentifier &SENDER_ACCT_ID, const OTIdentifier &SENDER_USER_ID, const OTString &CHEQUE_MEMO, const OTIdentifier *pRECIPIENT_USER_ID=nullptr) const
EXPORT bool CheckSetSection(const OTString &strSection, const OTString &strComment, bool &out_bIsNewSection)
EXPORT bool IsInitialized() const
EXPORT bool SignContract(const OTIdentifier &theSignerNymID, const OTString &strContract, OTString &strOutput) const
EXPORT bool LoadPurse(const char *szServerID=nullptr, const char *szUserID=nullptr, const char *szAssetTypeID=nullptr)
EXPORT const OTString & GetBasketInfo() const
int32_t GetAccountCount() const
EXPORT bool LoadConfigFile()
EXPORT bool IsVoucher() const
EXPORT bool Contains(const char *compare) const
EXPORT OTAssetContract * GetAssetContractPartialMatch(const std::string PARTIAL_ID, const char *szFuncName=nullptr) const
static EXPORT Token * TokenFactory(OTString strInput)
EXPORT bool ResyncWithServer(const OTLedger &theNymbox, const OTPseudonym &theMessageNym)
int64_t GetOpeningTransNo() const
EXPORT Storable * DecodeObject(StoredObjectType theObjectType, std::string strInput)
#define OTDB_DEFAULT_STORAGE
const OTIdentifier & GetRecipientAcctID() const
EXPORT bool SmartContract_AddVariable(const OTString &THE_CONTRACT, const OTIdentifier &SIGNER_NYM_ID, const OTString &BYLAW_NAME, const OTString &VAR_NAME, const OTString &VAR_ACCESS, const OTString &VAR_TYPE, const OTString &VAR_VALUE, OTString &strOutput) const
void SetRequestAccountID(const OTIdentifier &theAccountID)
EXPORT bool IsEmpty() const
EXPORT OTServerContract * GetServerContractPartialMatch(std::string PARTIAL_ID)
static EXPORT OT_API * OTAPI()
EXPORT int32_t exchangeBasket(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &BASKET_ASSET_ID, const OTString &BASKET_INFO, bool bExchangeInOrOut) const
EXPORT int32_t getBoxReceipt(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nBoxType, const int64_t &lTransactionNum) const
EXPORT bool HaveAlreadySeenReply(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const int64_t &lRequestNumber) const
EXPORT OTLedger * LoadExpiredBoxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT int32_t checkUser(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &USER_ID_CHECK) const
static EXPORT std::string & trim(std::string &str)
const OTIdentifier & GetUserID() const
EXPORT bool GetString(OTString &theData, bool bLineBreaks=true) const
int64_t OTTimeGetSecondsFromTime(time64_t time)
EXPORT OTNym_or_SymmetricKey * LoadPurseAndOwnerForMerge(const OTString &strPurse, Purse &thePurse, OTPassword &thePassword, bool bCanBePublic=false, const OTIdentifier *pOWNER_ID=nullptr, const OTString *pstrDisplay=nullptr) const
EXPORT void AddClosingTransactionNo(const int64_t &lClosingTransactionNo)
void SetClosingNum(const int64_t &lClosingNum)
EXPORT int32_t getNym_MarketOffers(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT OTParty * GetPartyByIndex(int32_t nIndex) const
EXPORT bool LoadContractFromString(const OTString &theStr)
EXPORT int32_t processNymbox(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT OTPartyAccount * GetAccountByIndex(int32_t nIndex)
EXPORT bool LoadMint(const char *szAppend=nullptr)
EXPORT bool GetNym(int32_t iIndex, OTIdentifier &NYM_ID, OTString &NYM_NAME) const
EXPORT bool Savex509CertAndPrivateKey(bool bCreateFile=true, const OTString *pstrReason=nullptr)
EXPORT int32_t GetNymCount() const
EXPORT OTAccount * GetOrLoadAccount(const OTPseudonym &theNym, const OTIdentifier &ACCT_ID, const OTIdentifier &SERVER_ID, const char *szFuncName=nullptr) const
EXPORT OTAccount * GetAccountPartialMatch(const std::string PARTIAL_ID, const char *szFuncName=nullptr) const
EXPORT bool GetNymID(OTIdentifier &theOutput) const
EXPORT OTMessage * GetOutpaymentsByIndex(int32_t nIndex) const
EXPORT OTServerContract * GetServerContract(const OTIdentifier &SERVER_ID)
static EXPORT bool AppendFile(OTString &out_strPath, const OTString &strBasePath, const OTString &strFileName)
EXPORT bool SaveAccount()
EXPORT paymentType GetType() const
EXPORT bool Wallet_CanRemoveAccount(const OTIdentifier &ACCOUNT_ID) const
EXPORT OTServerContract * GetServerContractPartialMatch(const std::string PARTIAL_ID, const char *szFuncName=nullptr) const
EXPORT size_t GetMasterCredentialCount() const
EXPORT OTLedger * LoadInboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT OTTransaction * GetFinalReceipt(int64_t lReferenceNum)
EXPORT bool GetWalletFilename(OTString &strPath) const
virtual EXPORT bool ConfirmParty(OTParty &theParty)
EXPORT bool GenerateInternalKey()
static EXPORT bool SignFlatText(OTString &strFlatText, const OTString &strContractType, const OTPseudonym &theSigner, OTString &strOutput)
EXPORT bool NumList_Add(OTNumList &theList, const OTNumList &theNewNumbers) const
EXPORT OTLedger * LoadOutboxNoVerify(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID) const
EXPORT bool GetRemitterUserID(OTIdentifier &theOutput) const
EXPORT int32_t GetNymCount()
EXPORT void AddNym(const OTPseudonym &theNym)
virtual EXPORT void Release()
OTMessageBuffer & GetMessageBuffer()
static EXPORT OTString Get()
EXPORT void AddSubContract(const OTIdentifier &SUB_CONTRACT_ID, int64_t lMinimumTransferAmount)
EXPORT bool VerifyAcknowledgedNum(const OTString &strServerID, const int64_t &lRequestNum) const
EXPORT int32_t getContract(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ASSET_ID) const
EXPORT int32_t GetAssetTypeCount() const
const OTIdentifier & GetRealServerID() const
static EXPORT OTCronItem * NewCronItem(const OTString &strCronItem)
std::map< int64_t, OTTransaction * > mapOfTransactions
EXPORT bool CheckSet_bool(const OTString &strSection, const OTString &strKey, const bool &bDefault, bool &out_bResult, bool &out_bIsNew, const OTString &strComment="")
EXPORT void AddItem(OTItem &theItem)
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)
EXPORT int32_t getTransactionNumber(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID) const
EXPORT int32_t sendUserMessage(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &USER_ID_RECIPIENT, const OTString &RECIPIENT_PUBKEY, const OTString &THE_MESSAGE) const
EXPORT OTPseudonym * GetOrLoadPublicNym(const OTIdentifier &NYM_ID, const char *szFuncName=nullptr)
#define CLIENT_PASSWORD_FOLDER
EXPORT bool RemoveServerContract(const OTIdentifier &theTargetID)
EXPORT int32_t Count() const
EXPORT OTTransaction * GetTransaction(OTTransaction::transactionType theType)
EXPORT bool Wallet_RemoveServer(const OTIdentifier &SERVER_ID) const
EXPORT void IncrementRequestNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID)
EXPORT bool IsPurse() const
EXPORT int32_t issueAssetType(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTString &THE_CONTRACT) const
EXPORT bool IsEmpty() const
EXPORT bool SetServerIDIfEmpty(const OTIdentifier &theID)
int64_t lMinimumTransferAmount
EXPORT bool Wallet_ExportNym(const OTIdentifier &NYM_ID, OTString &strOutput) const
EXPORT void SetName(const OTString &strName)
EXPORT const mapOfTransactions & GetTransactionMap() const
EXPORT OTTransaction * GetChequeReceipt(int64_t lChequeNum, OTCheque **ppChequeOut=nullptr)
EXPORT bool GetAssetType(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT bool LoadPaymentInbox()
EXPORT int32_t getAccount(const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCT_ID) const
const OTIdentifier & GetServerID() const
EXPORT Token * Pop(OTNym_or_SymmetricKey theOwner)