610 #include <irrxml/irrXML.hpp>
612 #ifdef OT_USE_SCRIPT_CHAI
614 #include <chaiscript/chaiscript.hpp>
615 #ifdef OT_USE_CHAI_STDLIB
616 #include <chaiscript/chaiscript_stdlib.hpp>
622 #ifndef SMART_CONTRACT_PROCESS_INTERVAL
623 #define SMART_CONTRACT_PROCESS_INTERVAL \
624 30 // 30 seconds, for testing. Should be: based on fees. Otherwise once per
633 #ifndef SMARTCONTRACT_CALLBACK_PARTY_MAY_CANCEL
634 #define SMARTCONTRACT_CALLBACK_PARTY_MAY_CANCEL \
635 "callback_party_may_cancel_contract"
656 #ifndef SMARTCONTRACT_HOOK_ON_PROCESS
657 #define SMARTCONTRACT_HOOK_ON_PROCESS "cron_process"
663 #ifndef SMARTCONTRACT_HOOK_ON_ACTIVATE
664 #define SMARTCONTRACT_HOOK_ON_ACTIVATE "cron_activate"
681 #ifndef SMARTCONTRACT_HOOK_ON_REMOVE
682 #define SMARTCONTRACT_HOOK_ON_REMOVE "cron_remove"
690 #ifndef SMARTCONTRACT_HOOK_ON_EXPIRE
691 #define SMARTCONTRACT_HOOK_ON_EXPIRE "cron_expire"
701 #ifndef SMARTCONTRACT_HOOK_ON_DEACTIVATE
702 #define SMARTCONTRACT_HOOK_ON_DEACTIVATE "cron_deactivate"
842 std::string from_acct_name, std::string to_acct_name,
843 std::string str_Amount);
864 #ifdef OT_USE_SCRIPT_CHAI
865 using namespace chaiscript;
867 OTScriptChai* pScript =
dynamic_cast<OTScriptChai*
>(&theScript);
869 if (
nullptr != pScript) {
892 "get_acct_asset_type_id");
894 "get_stash_balance");
898 "send_notice_to_parties");
900 "set_seconds_until_timer");
902 "get_remaining_timer");
905 "deactivate_contract");
922 "party_may_cancel_contract");
962 #endif // OT_USE_SCRIPT_CHAI
964 otErr <<
"OTSmartContract::RegisterOTNativeCallsWithScript: Failed "
965 "dynamic casting OTScript to OTScriptChai \n";
981 otOut <<
"OTSmartContract::DeactivateSmartContract: deactivate_contract() "
982 "was called from within the script. "
983 "Flagging smartcontract for removal from Cron ("
1043 const OTParty* pParty = it.second;
1055 const OTParty* pParty = it.second;
1067 if (
nullptr != pParty) {
1069 "OT_ASSERT: nullptr != pAgent in "
1070 "OTSmartContract::GetOpeningNumber.\n");
1082 if (
nullptr != pPartyAcct) {
1103 std::string str_seconds_from_now)
1106 if (str_seconds_from_now.size() <= 0)
1108 otOut <<
"OTSmartContract::" << __FUNCTION__
1109 <<
": blank input (str_seconds_from_now).\n";
1135 strReturnVal.
Format(
"%" PRId64
"", tSecondsLeft);
1138 return strReturnVal.
Get();
1145 otErr <<
"FYI: OTSmartContract::onRemovalFromCron was just called. \n";
1160 if (
GetCron()->GetTransactionCount() < 1) {
1161 otOut << __FUNCTION__ <<
": Failed to process smart contract "
1163 "receipts! Flagging for removal.\n";
1173 if (
GetHooks(str_HookName, theMatchingClauses)) {
1174 otOut <<
"Cron: Processing smart contract clauses for hook: "
1178 theMatchingClauses);
1195 if (from_acct_name.size() <= 0) {
1196 otErr <<
"OTSmartContract::GetAcctBalance: error: from_acct_name is "
1208 if (
nullptr == pFromAcct) {
1209 otOut <<
"OTSmartContract::GetAcctBalances: error: from_acct ("
1210 << from_acct_name <<
") not found on any party.\n";
1224 if (
nullptr == pFromAgent) {
1225 otOut <<
"OTSmartContract::GetAcctBalance: error: authorized agent ("
1226 << pFromAcct->
GetAgentName() <<
") not found for from_acct ("
1227 << from_acct_name <<
") on acct's party.\n";
1232 otOut <<
"OTSmartContract::GetAcctBalance: error: authorized agent ("
1234 << from_acct_name <<
") is not an active agent.\n";
1245 if (
nullptr == pFromParty) {
1247 <<
"OTSmartContract::GetAcctBalance: error: Party pointer nullptr "
1249 <<
") for from_acct (" << from_acct_name <<
").\n";
1335 const bool bFromAgentID = pFromAgent->
GetSignerID(theFromAgentID);
1337 if (!bFromAgentID) {
1338 otErr <<
"OTSmartContract::GetAcctBalance: Failed to find FromAgent's "
1339 "Signer ID: " << pFromAgent->
GetName() <<
" \n";
1344 otErr <<
"OTSmartContract::GetAcctBalance: Error: FromAcct has empty "
1345 "AcctID: " << from_acct_name <<
" \n";
1356 const std::string str_party_id = pFromParty->
GetPartyID();
1357 const OTString strPartyID(str_party_id);
1367 if (
nullptr == pPartyAssetAcct) {
1368 otOut <<
"OTSmartContract::GetAcctBalance: ERROR verifying existence "
1369 "of source account.\n";
1373 else if (!pPartyAssetAcct->VerifySignature(*pServerNym)) {
1374 otOut <<
"OTSmartContract::GetAcctBalance: ERROR failed to verify the "
1375 "server's signature on the party's account.\n";
1379 else if (!pPartyAssetAcct->VerifyOwnerByID(PARTY_USER_ID)) {
1380 otOut <<
"OTSmartContract::GetAcctBalance: ERROR failed to verify "
1381 "party user ownership of party account.\n";
1386 std::unique_ptr<OTAccount> theSourceAcctSmrtPtr(pPartyAssetAcct);
1389 strBalance.
Format(
"%lld", pPartyAssetAcct->GetBalance());
1391 return strBalance.
Get();
1407 std::string str_return_value;
1409 if (from_acct_name.size() <= 0) {
1410 otErr <<
"OTSmartContract::GetAssetTypeIDofAcct: error: from_acct_name "
1411 "is non-existent.\n";
1412 return str_return_value;
1422 if (
nullptr == pFromAcct) {
1423 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: error: from_acct ("
1424 << from_acct_name <<
") not found on any party.\n";
1425 return str_return_value;
1438 if (
nullptr == pFromAgent) {
1439 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: error: authorized "
1441 <<
") not found for from_acct (" << from_acct_name
1442 <<
") on acct's party.\n";
1443 return str_return_value;
1447 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: error: authorized "
1448 "agent (" << pFromAcct->
GetAgentName() <<
") for from_acct ("
1449 << from_acct_name <<
") is not an active agent.\n";
1450 return str_return_value;
1460 if (
nullptr == pFromParty) {
1461 otErr <<
"OTSmartContract::GetAssetTypeIDofAcct: error: Party pointer "
1462 "nullptr on authorized agent (" << pFromAcct->
GetAgentName()
1463 <<
") for from_acct (" << from_acct_name <<
").\n";
1464 return str_return_value;
1552 const bool bFromAgentID = pFromAgent->
GetSignerID(theFromAgentID);
1554 if (!bFromAgentID) {
1555 otErr <<
"OTSmartContract::GetAssetTypeIDofAcct: Failed to find "
1556 "FromAgent's Signer ID: " << pFromAgent->
GetName() <<
" \n";
1557 return str_return_value;
1561 otErr <<
"OTSmartContract::GetAssetTypeIDofAcct: Error: FromAcct has "
1562 "empty AcctID: " << from_acct_name <<
" \n";
1563 return str_return_value;
1573 const std::string str_party_id = pFromParty->
GetPartyID();
1574 const OTString strPartyID(str_party_id);
1584 if (
nullptr == pPartyAssetAcct) {
1585 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: ERROR verifying "
1586 "existence of source account.\n";
1588 return str_return_value;
1590 else if (!pPartyAssetAcct->VerifySignature(*pServerNym)) {
1591 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: ERROR failed to "
1592 "verify the server's signature on the party's account.\n";
1594 return str_return_value;
1596 else if (!pPartyAssetAcct->VerifyOwnerByID(PARTY_USER_ID)) {
1597 otOut <<
"OTSmartContract::GetAssetTypeIDofAcct: ERROR failed to "
1598 "verify party user ownership of party account.\n";
1600 return str_return_value;
1603 std::unique_ptr<OTAccount> theSourceAcctSmrtPtr(pPartyAssetAcct);
1605 const OTString strAssetTypeID(pPartyAssetAcct->GetAssetTypeID());
1606 str_return_value = strAssetTypeID.
Get();
1608 return str_return_value;
1612 std::string asset_type_id)
1625 if (from_stash_name.size() <= 0) {
1626 otErr <<
"OTSmartContract::GetStashBalance: error: from_stash_name is "
1630 if (asset_type_id.size() <= 0) {
1631 otErr <<
"OTSmartContract::GetStashBalance: error: asset_type_id is "
1656 return strBalance.
Get();
1673 bool bDroppedNotice =
false;
1676 if (0 == lNewTransactionNumber) {
1677 otErr << __FUNCTION__ <<
": ** ERROR: Notice not sent to parties, "
1678 "since no transaction numbers were "
1686 const OTString strReference(*
this);
1689 *pServerNym,
GetServerID(), lNewTransactionNumber,
1694 otOut << __FUNCTION__
1695 <<
": Dropping notifications into all parties' nymboxes: "
1696 << (bDroppedNotice ?
"Success" :
"Failure") <<
"\n";
1699 return bDroppedNotice;
1716 if (
nullptr == pParty) {
1717 otOut << __FUNCTION__ <<
": Unable to find this party: " << party_name
1770 bool bDroppedNotice =
false;
1774 if (0 == lNewTransactionNumber) {
1775 otErr << __FUNCTION__ <<
": ** ERROR: Notice not sent to party, since "
1776 "no transaction numbers were available!\n";
1783 const OTString strReference(*
this);
1788 *pServerNym,
GetServerID(), lNewTransactionNumber,
1793 otOut << __FUNCTION__ <<
": "
1794 << (bDroppedNotice ?
"Success" :
"Failure")
1795 <<
" dropping notification into party's nymbox: "
1799 return bDroppedNotice;
1820 std::string to_stash_name,
1821 std::string str_Amount)
1833 if (str_Amount.size() < 1) {
1834 otOut <<
"OTSmartContract::StashAcctFunds: Error: empty amount.\n";
1838 const int64_t lAmount = atol(str_Amount.c_str());
1841 otOut <<
"OTSmartContract::StashAcctFunds: Error: lAmount cannot be 0 "
1842 "or <0. (Value passed in was " << lAmount <<
".)\n";
1846 if (from_acct_name.size() <= 0) {
1847 otErr <<
"OTSmartContract::StashAcctFunds: error: from_acct_name is "
1851 if (to_stash_name.size() <= 0) {
1852 otErr <<
"OTSmartContract::StashAcctFunds: error: to_stash_name is "
1869 if (
nullptr == pFromAcct) {
1870 otOut <<
"OTSmartContract::StashAcctFunds: error: from_acct ("
1871 << from_acct_name <<
") not found on any party.\n";
1887 if (
nullptr == pFromAgent) {
1888 otOut <<
"OTSmartContract::StashAcctFunds: error: authorized agent ("
1889 << pFromAcct->
GetAgentName() <<
") not found for from_acct ("
1890 << from_acct_name <<
") on acct's party.\n";
1895 otOut <<
"OTSmartContract::StashAcctFunds: error: authorized agent ("
1897 << from_acct_name <<
") is not an active agent.\n";
1909 if (
nullptr == pFromParty) {
1911 <<
"OTSmartContract::StashAcctFunds: error: Party pointer nullptr "
1913 <<
") for from_acct (" << from_acct_name <<
").\n";
2005 const bool bFromAgentID = pFromAgent->
GetSignerID(theFromAgentID);
2007 if (!bFromAgentID) {
2008 otErr <<
"OTSmartContract::StashAcctFunds: Failed to find FromAgent's "
2009 "Signer ID: " << pFromAgent->
GetName() <<
" \n";
2014 otErr <<
"OTSmartContract::StashAcctFunds: Error: FromAcct has empty "
2015 "AcctID: " << from_acct_name <<
" \n";
2028 theFromAgentID.
GetString(m_strLastSenderUser);
2030 theFromAcctID.GetString(m_strLastSenderAcct);
2042 bool bMoved =
StashFunds(map_Nyms_Already_Loaded, lAmount, theFromAcctID,
2043 theFromAgentID, *pStash);
2045 otOut <<
"OTSmartContract::StashAcctFunds: Failed in final call. "
2046 "Values: from_acct: " << from_acct_name
2047 <<
", to_stash: " << to_stash_name <<
", lAmount: " << lAmount
2073 std::string from_stash_name,
2074 std::string str_Amount)
2087 if (str_Amount.size() < 1) {
2088 otOut <<
"OTSmartContract::UnstashAcctFunds: Error: empty amount.\n";
2092 const int64_t lAmount = atol(str_Amount.c_str());
2095 otOut <<
"OTSmartContract::UnstashAcctFunds: Error: lAmount cannot be "
2096 "0 or <0. (Value passed in was " << lAmount <<
".)\n";
2100 if (to_acct_name.size() <= 0) {
2101 otErr <<
"OTSmartContract::UnstashAcctFunds: error: to_acct_name is "
2105 if (from_stash_name.size() <= 0) {
2106 otErr <<
"OTSmartContract::UnstashAcctFunds: error: from_stash_name is "
2122 if (
nullptr == pToAcct) {
2123 otOut <<
"OTSmartContract::UnstashAcctFunds: error: to_acct ("
2124 << to_acct_name <<
") not found on any party.\n";
2139 if (
nullptr == pToAgent) {
2140 otOut <<
"OTSmartContract::UnstashAcctFunds: error: authorized agent ("
2142 << to_acct_name <<
") on acct's party.\n";
2147 otOut <<
"OTSmartContract::UnstashAcctFunds: error: authorized agent ("
2149 << to_acct_name <<
") is not an active agent.\n";
2161 if (
nullptr == pToParty) {
2162 otErr <<
"OTSmartContract::UnstashAcctFunds: error: Party pointer "
2165 <<
") for to_acct (" << to_acct_name <<
").\n";
2235 const bool bToAgentID = pToAgent->
GetSignerID(theToAgentID);
2238 otErr <<
"OTSmartContract::UnstashAcctFunds: Failed to find 'To' "
2239 "Agent's Signer ID: " << pToAgent->
GetName() <<
" \n";
2244 otErr <<
"OTSmartContract::UnstashAcctFunds: Error: ToAcct has empty "
2245 "AcctID: " << to_acct_name <<
" \n";
2258 theToAgentID.
GetString(m_strLastRecipientUser);
2261 theToAcctID.GetString(m_strLastRecipientAcct);
2267 const int64_t lNegativeAmount = (lAmount * (-1));
2272 bool bMoved =
StashFunds(map_Nyms_Already_Loaded, lNegativeAmount,
2273 theToAcctID, theToAgentID, *pStash);
2275 otOut <<
"OTSmartContract::UnstashAcctFunds: Failed in final call. "
2276 "Values: to_acct: " << to_acct_name
2277 <<
", from_stash: " << from_stash_name <<
", lAmount: " << lAmount
2292 const int64_t& lAmount,
2307 otOut <<
"OTSmartContract::StashFunds: a zero amount is not allowed.\n";
2320 if (
nullptr == pPartyAssetAcct) {
2321 otOut <<
"OTSmartContract::StashFunds: ERROR verifying existence of "
2322 "source account.\n";
2327 otOut <<
"OTSmartContract::StashFunds: ERROR failed to verify the "
2328 "server's signature on the party's account.\n";
2333 otOut <<
"OTSmartContract::StashFunds: ERROR failed to verify party "
2334 "user ownership of party account.\n";
2339 std::unique_ptr<OTAccount> theSourceAcctSmrtPtr(pPartyAssetAcct);
2348 const std::string str_asset_type_id = strAssetTypeID.
Get();
2357 const bool bUnstashing =
2359 const int64_t lAbsoluteAmount =
2385 const int64_t lPartyAssetBalance = pPartyAssetAcct->
GetBalance();
2386 const int64_t lStashItemAmount = pStashItem->
GetAmount();
2388 const int64_t lSourceAmount =
2389 bUnstashing ? lStashItemAmount : lPartyAssetBalance;
2394 if ((lSourceAmount - lAbsoluteAmount) < 0) {
2395 otOut <<
"OTSmartContract::StashFunds: Not enough funds available in "
2396 "the source to accommodate this action.\n";
2400 bool bWasAcctCreated =
false;
2407 if (!pStashAccount) {
2408 OT_FAIL_MSG(
"ASSERT in OTSmartContract::StashFunds: returned nullptr "
2409 "pointer (should never happen.)\n");
2412 if (bWasAcctCreated) {
2414 pStashAccount->GetIdentifier(strAcctID);
2416 otOut <<
"OTSmartContract::StashFunds: Successfully created stash "
2417 "account ID: " << strAcctID
2418 <<
"\n (Stash acct has Asset Type ID: " << strAssetTypeID
2429 if (!pStashAccount) {
2430 OT_FAIL_MSG(
"ASSERT in OTSmartContract::StashFunds: returned nullptr "
2431 "pointer (should never happen.)\n");
2442 const int64_t lSourceAmount2 = bUnstashing ? pStashAccount->GetBalance()
2448 if ((lSourceAmount2 - lAbsoluteAmount) < 0) {
2449 otOut <<
"OTSmartContract::StashFunds: Not enough funds available in "
2450 "the stash acct to accommodate this action.\n";
2462 const OTIdentifier STASH_ACCT_ID(pStashAccount->GetRealAccountID());
2464 if (PARTY_ACCT_ID == STASH_ACCT_ID) {
2465 otErr <<
"OTSmartContract::StashFunds: ERROR: both account IDs were "
2474 if (pPartyAssetAcct->
GetAssetTypeID() != pStashAccount->GetAssetTypeID()) {
2475 otErr <<
"OTSmartContract::StashFunds: Aborted stash: Asset type ID "
2476 "doesn't match. THIS SHOULD NEVER HAPPEN.\n";
2481 if (!pStashAccount->VerifyOwnerByID(SERVER_USER_ID)) {
2482 otErr <<
"OTSmartContract::StashFunds: Error: Somehow the stash "
2483 "account isn't server-nym owned.\n";
2487 const OTIdentifier STASH_USER_ID(pStashAccount->GetUserID());
2489 bool bSuccess =
false;
2491 OTString strPartyUserID(PARTY_USER_ID), strStashUserID(STASH_USER_ID),
2492 strPartyAcctID(PARTY_ACCT_ID), strStashAcctID(STASH_ACCT_ID),
2493 strServerNymID(SERVER_USER_ID);
2502 std::unique_ptr<OTCronItem> pOrigCronItem(
2513 OTString strOrigPlan(*pOrigCronItem);
2529 const bool bPartyNymIsServerNym =
2530 ((PARTY_USER_ID == SERVER_USER_ID) ?
true :
false);
2535 const std::string str_party_id = strPartyUserID.Get();
2536 auto it_party = map_NymsAlreadyLoaded.find(str_party_id);
2538 if (map_NymsAlreadyLoaded.end() !=
2541 pPartyNym = it_party->second;
2547 if (bPartyNymIsServerNym) {
2549 pPartyNym = pServerNym;
2551 else if (
nullptr == pPartyNym)
2557 otErr <<
"OTSmartContract::StashFunds: Failure loading party Nym "
2558 "public key: " << strPartyUserID <<
"\n";
2570 otWarn <<
"OTSmartContract::StashFunds: Loading party Nym, since "
2571 "he apparently wasn't already loaded.\n"
2572 "(On a cron item processing, this is normal. But if you "
2573 "triggered a clause directly, then your Nym SHOULD be "
2574 "already loaded...)\n";
2575 pPartyNym = &thePartyNym;
2578 otErr <<
"OTSmartContract::StashFunds: Failure loading or "
2579 "verifying party Nym public key: " << strPartyUserID
2590 map_ALREADY_LOADED.insert(std::pair<std::string, OTPseudonym*>(
2591 strServerNymID.
Get(),
2594 auto it_temp = map_ALREADY_LOADED.find(strPartyUserID.Get());
2595 if (map_ALREADY_LOADED.end() == it_temp)
2596 map_ALREADY_LOADED.insert(std::pair<std::string, OTPseudonym*>(
2597 strPartyUserID.Get(),
2602 if (!pOrigCronItem->VerifyNymAsAgent(
2603 *pPartyNym, *pServerNym,
2606 &map_ALREADY_LOADED)) {
2607 otErr <<
"OTSmartContract::StashFunds: Failed authorization for party "
2608 "Nym: " << strPartyUserID <<
"\n";
2622 otOut <<
"OTSmartContract::StashFunds: ERROR verifying ownership on "
2623 "source account.\n";
2633 OTLedger thePartyInbox(PARTY_USER_ID, PARTY_ACCT_ID, SERVER_ID);
2637 bool bSuccessLoadingPartyInbox = thePartyInbox.
LoadInbox();
2641 if (
true == bSuccessLoadingPartyInbox)
2642 bSuccessLoadingPartyInbox =
2645 otErr <<
"OTSmartContract::StashFunds: Failed trying to load "
2653 if (!bSuccessLoadingPartyInbox) {
2654 otErr <<
"OTSmartContract::StashFunds: ERROR loading or generating "
2663 if (0 == lNewTransactionNumber) {
2664 otOut <<
"OTSmartContract::StashFunds: Aborted move: There are "
2665 "no more transaction numbers available in Cron.\n";
2672 lNewTransactionNumber);
2749 bool bMoveParty =
false;
2750 bool bMoveStash =
false;
2754 if (pStashAccount->GetBalance() >= lAbsoluteAmount) {
2756 bMoveStash = pStashAccount->Debit(
2761 bMoveParty = pPartyAssetAcct->
Credit(
2771 bool bErr = pStashAccount->Credit(
2774 otErr <<
"OTSmartContract::StashFunds: While "
2775 "succeeded debiting the stash account, "
2777 "pPartyAssetAcct->Credit(lAbsoluteAmount);"
2779 "Also, tried to credit stash account back "
2781 << (bErr ?
"success" :
"failure") <<
".\n";
2794 otErr <<
"OTSmartContract::StashFunds: ERROR: "
2795 "Debited stash account and credited "
2796 "party account, but "
2797 "then unable to debit the stash "
2798 "record inside the smart contract "
2803 otErr <<
"OTSmartContract::StashFunds: FAILED in: "
2804 "pStashAccount->Debit(lAbsoluteAmount);\n";
2810 if (pPartyAssetAcct->
GetBalance() >= lAbsoluteAmount) {
2812 bMoveParty = pPartyAssetAcct->
Debit(
2817 bMoveStash = pStashAccount->Credit(
2827 bool bErr = pPartyAssetAcct->
Credit(
2830 otErr <<
"OTSmartContract::StashFunds: While "
2831 "succeeded debiting the asset account, "
2833 "pStashAccount->Credit(lAbsoluteAmount); "
2835 "Also, tried to credit asset account back "
2837 << (bErr ?
"success" :
"failure") <<
".\n";
2850 otErr <<
"OTSmartContract::StashFunds: ERROR: "
2851 "Debited party account and credited "
2852 "stash account, but "
2853 "then unable to credit the stash "
2854 "record inside the smart contract "
2859 otErr <<
"OTSmartContract::StashFunds: FAILED in: "
2860 "pPartyAssetAcct->Debit(lAbsoluteAmount);\n";
2869 if (!bMoveParty || !bMoveStash) {
2874 otErr <<
"OTSmartContract::StashFunds: Very strange! Funds "
2875 "were available but "
2876 "debit " << ((bUnstashing) ?
"stash" :
"party")
2877 <<
" or credit " << ((bUnstashing) ?
"party" :
"stash")
2878 <<
" failed while performing move.\n";
2888 if (
true == bSuccess)
2895 const int64_t lReceiptAmount = (lAmount * (-1));
2912 otOut <<
"OTSmartContract::StashFunds: Move performed.\n";
2926 otOut <<
"OTSmartContract::StashFunds: Move failed.\n";
3012 OTString strUpdatedCronItem(*
this);
3035 pTransParty->
AddItem(*pItemParty);
3052 pPartyAssetAcct->
SaveInbox(thePartyInbox);
3064 if (
true == bSuccess) {
3071 pStashAccount->ReleaseSignatures();
3075 pStashAccount->SignContract(*pServerNym);
3079 pStashAccount->SaveContract();
3085 pStashAccount->SaveAccount();
3120 std::string to_acct_name,
3121 std::string str_Amount)
3133 if (str_Amount.size() < 1) {
3134 otOut <<
"OTSmartContract::MoveAcctFunds: Error: empty amount.\n";
3138 const int64_t lAmount = atol(str_Amount.c_str());
3141 otOut <<
"OTSmartContract::MoveAcctFunds: Error: lAmount cannot be 0 "
3142 "or <0. (Value passed in was " << lAmount <<
".)\n";
3146 if (from_acct_name.size() <= 0) {
3147 otErr <<
"OTSmartContract::MoveAcctFunds: error: from_acct_name is "
3151 if (to_acct_name.size() <= 0) {
3152 otErr <<
"OTSmartContract::MoveAcctFunds: error: to_acct_name is "
3166 if (
nullptr == pFromAcct) {
3167 otOut <<
"OTSmartContract::MoveAcctFunds: error: from_acct ("
3168 << from_acct_name <<
") not found on any party.\n";
3172 if (
nullptr == pToAcct) {
3173 otOut <<
"OTSmartContract::MoveAcctFunds: error: to_acct ("
3174 << to_acct_name <<
") not found on any party.\n";
3193 if (
nullptr == pFromAgent) {
3194 otOut <<
"OTSmartContract::MoveAcctFunds: error: authorized agent ("
3195 << pFromAcct->
GetAgentName() <<
") not found for from_acct ("
3196 << from_acct_name <<
") on acct's party.\n";
3199 if (
nullptr == pToAgent) {
3200 otOut <<
"OTSmartContract::MoveAcctFunds: error: authorized agent ("
3201 << pToAcct->
GetAgentName() <<
") not found for to_acct ("
3202 << to_acct_name <<
") on acct's party.\n";
3207 otOut <<
"OTSmartContract::MoveAcctFunds: error: authorized agent ("
3209 << from_acct_name <<
") is not an active agent.\n";
3213 otOut <<
"OTSmartContract::MoveAcctFunds: error: authorized agent ("
3214 << pToAcct->
GetAgentName() <<
") for to_acct (" << to_acct_name
3215 <<
") is not an active agent.\n";
3228 if (
nullptr == pFromParty) {
3229 otErr <<
"OTSmartContract::MoveAcctFunds: error: Party pointer nullptr "
3232 <<
") for from_acct (" << from_acct_name <<
").\n";
3235 if (
nullptr == pToParty) {
3236 otErr <<
"OTSmartContract::MoveAcctFunds: error: Party pointer nullptr "
3239 <<
") for to_acct (" << to_acct_name <<
").\n";
3310 const bool bFromAgentID = pFromAgent->
GetSignerID(theFromAgentID);
3311 const bool bToAgentID = pToAgent->
GetSignerID(theToAgentID);
3313 if (!bFromAgentID) {
3314 otErr <<
"OTSmartContract::MoveAcctFunds: Failed to find FromAgent's "
3315 "Signer ID: " << pFromAgent->
GetName() <<
" \n";
3319 otErr <<
"OTSmartContract::MoveAcctFunds: Failed to find ToAgent's "
3320 "Signer ID: " << pToAgent->
GetName() <<
" \n";
3325 otErr <<
"OTSmartContract::MoveAcctFunds: Error: FromAcct has empty "
3326 "AcctID: " << from_acct_name <<
" \n";
3330 otErr <<
"OTSmartContract::MoveAcctFunds: Error: ToAcct has empty "
3331 "AcctID: " << to_acct_name <<
" \n";
3346 theFromAgentID.
GetString(m_strLastSenderUser);
3348 theFromAcctID.GetString(m_strLastSenderAcct);
3350 theToAgentID.
GetString(m_strLastRecipientUser);
3353 theToAcctID.GetString(m_strLastRecipientAcct);
3360 bool bMoved = MoveFunds(map_Nyms_Already_Loaded, lAmount, theFromAcctID,
3361 theFromAgentID, theToAcctID, theToAgentID);
3363 otOut <<
"OTSmartContract::MoveAcctFunds: Failed in call to MoveFunds. "
3364 "from_acct: " << from_acct_name
3365 <<
" to_acct: " << to_acct_name <<
"\n";
3378 const int64_t& lNewTransactionNumber,
3396 OTString strUpdatedCronItem(*
this);
3397 OTString* pstrAttachment = &strUpdatedCronItem;
3399 const OTString strOrigCronItem(theOrigCronItem);
3455 "Unexpected nullptr pointer in party map.");
3466 std::unique_ptr<OTPseudonym> thePartyNymAngel;
3475 pPartyNym = pServerNym;
3482 else if ((
nullptr != pActingNym) &&
3487 pPartyNym = pActingNym;
3492 if (
nullptr == pPartyNym) {
3508 thePartyNymAngel.reset(pPartyNym);
3551 <<
"OTSmartContract::" << __FUNCTION__
3552 <<
": Failed verifying "
3553 "pPartyNym != nullptr && pParty->GetOpeningTransNo() > 0 && "
3555 "pPartyNym->VerifyIssuedNum(pParty->GetOpeningTransNo())\n";
3566 lNewTransactionNumber,
3568 strOrigCronItem,
nullptr, pstrAttachment, pPartyNym))) {
3569 otErr <<
"OTSmartContract::" << __FUNCTION__
3570 <<
": Failure dropping final receipt into nymbox for even a "
3587 const OTString strServerNymID(theServerNymID);
3589 if (nym_map.end() == nym_map.find(strServerNymID.
Get()))
3590 nym_map.insert(std::pair<std::string, OTPseudonym*>(
3591 strServerNymID.
Get(), pServerNym));
3597 const OTString strOriginatorNymID(theOriginatorNymID);
3599 if (nym_map.end() == nym_map.find(strOriginatorNymID.
Get()))
3600 nym_map.insert(std::pair<std::string, OTPseudonym*>(
3601 strOriginatorNymID.
Get(), &theOriginator));
3604 if (
nullptr != pActingNym) {
3606 const OTString strActingNymID(theActingNymID);
3608 if (nym_map.end() == nym_map.find(strActingNymID.
Get()))
3609 nym_map.insert(std::pair<std::string, OTPseudonym*>(
3610 strActingNymID.
Get(), pActingNym));
3613 if (
nullptr != pPartyNym) {
3615 const OTString strPartyNymID(thePartyNymID);
3617 if (nym_map.end() == nym_map.find(strPartyNymID.
Get()))
3618 nym_map.insert(std::pair<std::string, OTPseudonym*>(
3619 strPartyNymID.
Get(), pPartyNym));
3636 strServerID, *pServerNym, lNewTransactionNumber,
3637 strOrigCronItem,
nullptr, pstrAttachment)) {
3638 otErr <<
"OTSmartContract::onFinalReceipt: Failure dropping final "
3639 "receipt into all inboxes. (Missed at least one.)\n";
3683 otLog3 <<
"Cron job has expired.\n";
3698 if (
GetCron()->GetTransactionCount() < 1) {
3699 otOut <<
"Failed to process smart contract: Cron is out of transaction "
3736 if (
GetHooks(str_HookName, theMatchingClauses)) {
3737 otOut <<
"Cron: Processing smart contract clauses for hook: "
3741 theMatchingClauses);
3745 otLog3 <<
"OTSmartContract::ProcessCron: Removing smart contract from "
3746 "cron processing...\n";
3758 (
nullptr != pstrLabel) ? pstrLabel->c_str() :
"");
3771 for (
auto& it_clauses : theClauses) {
3772 const std::string str_clause_name = it_clauses.first;
3773 OTClause* pClause = it_clauses.second;
3774 OT_ASSERT((
nullptr != pClause) && (str_clause_name.size() > 0));
3781 const std::string str_code =
3783 const std::string str_language =
3786 std::shared_ptr<OTScript> pScript =
3789 std::unique_ptr<OTVariable> theVarAngel;
3804 const std::string str_party_name = it.first;
3806 OT_ASSERT((
nullptr != pParty) && (str_party_name.size() > 0));
3808 pScript->AddParty(str_party_name, *pParty);
3827 const std::string str_Name(
"param_string");
3828 std::string str_Value(
"");
3835 otErr <<
"OTSmartContract::ExecuteClauses: While preparing to "
3837 <<
", clause: " << str_clause_name
3838 <<
". Error: Parameter variable named " << str_Name
3839 <<
" already exists. (Skipping the parameter actually "
3845 if (
nullptr != pParam)
3846 str_Value = pParam->
Get();
3852 theVarAngel.reset(pVar);
3870 if (!pScript->ExecuteScript())
3878 otErr <<
"OTSmartContract::ExecuteClauses: Error while running "
3880 <<
", clause: " << str_clause_name <<
" \n\n";
3883 otOut <<
"OTSmartContract::ExecuteClauses: Success executing "
3885 <<
", clause: " << str_clause_name <<
" \n\n";
3898 otErr <<
"OTSmartContract::ExecuteClauses: Error instantiating "
3928 if (0 == lNewTransactionNumber) {
3929 otErr <<
"OTSmartContract::ExecuteClauses: ** ERROR: Notice not "
3930 "sent to parties, since no "
3931 "transaction numbers were available!\n";
3938 const OTString strReference(*
this);
3941 *pServerNym,
GetServerID(), lNewTransactionNumber,
3945 otOut << __FUNCTION__
3946 <<
": FYI, 'Important' variables were changed during the "
3947 "execution of this script.\n"
3948 << (bDroppedNotice ?
"Success" :
"Failure")
3949 <<
" dropping notifications into all parties' nymboxes.\n";
3979 if (
nullptr == pParty) {
3981 <<
"OTSmartContract::CanCancelContract: Unable to find this party: "
3982 << str_party_name <<
"\n";
4050 if (
nullptr != pCallbackClause)
4053 otOut <<
"OTSmartContract::CanCancelContract: Found script for: "
4063 OTVariable theReturnVal(
"return_val",
false);
4066 "param_party_name", str_party_name,
4070 theParameters.insert(
4071 std::pair<std::string, OTVariable*>(
"param_party_name", ¶m1));
4075 *pCallbackClause, theParameters,
4078 otErr <<
"OTSmartContract::CanCancelContract: Error while running "
4080 << SMARTCONTRACT_CALLBACK_PARTY_MAY_CANCEL <<
", clause "
4081 << pCallbackClause->
GetName() <<
" \n";
4085 otOut <<
"OTSmartContract::CanCancelContract: Success executing "
4087 << SMARTCONTRACT_CALLBACK_PARTY_MAY_CANCEL
4088 <<
", clause: " << pCallbackClause->
GetName() <<
".\n\n";
4096 <<
"OTSmartContract::CanCancelContract: Unable to find script for: "
4098 <<
". Therefore, default return value is: TRUE.\n";
4149 if (
nullptr == pParty) {
4150 otOut <<
"OTSmartContract::CanRemoveItemFromCron: Warning: theNym is "
4152 "for any party to this contract, yet tried to remove it.\n";
4199 bool bReturnValue =
false;
4200 bool bPartyHasName =
false;
4201 const std::string str_party_name = pParty->
GetPartyName(&bPartyHasName);
4203 if (bPartyHasName &&
4207 otOut <<
"OTSmartContract::CanRemoveItemFromCron: Looks like theNym "
4208 "represents a party (" << str_party_name
4210 "IS allowed by this contract to cancel it whenever he "
4212 bReturnValue =
true;
4219 return bReturnValue;
4396 OTAgent* pAuthAgent =
nullptr;
4399 if (
nullptr == pAuthParty) {
4402 otOut << __FUNCTION__
4403 <<
": Unable to find a party in this smart contract, based "
4404 "on theNym (" << strNymID <<
") as authorizing agent.\n";
4427 mapOfNyms map_Nyms_Loaded_In_This_Function;
4436 map_Accts_Already_Loaded.insert(std::pair<std::string, OTAccount*>(
4437 strAcctID.Get(), &theAcct));
4444 bool bAreAnyInvalidParties =
false;
4445 std::set<OTParty*> theFailedParties;
4450 const std::string str_party_name = it_party.first;
4451 OTParty* pParty = it_party.second;
4453 "OTSmartContract::VerifySmartContract: "
4454 "Unexpected nullptr pointer in party "
4488 bool bToBurnOrNotToBurn = bBurnTransNo;
4517 bToBurnOrNotToBurn =
false;
4520 mapOfNyms map_Nyms_NewlyLoaded, map_Nyms_Already_Loaded_AS_OF_NOW;
4522 map_Nyms_Already_Loaded_AS_OF_NOW.insert(
4523 map_Nyms_Already_Loaded.begin(), map_Nyms_Already_Loaded.end());
4524 map_Nyms_Already_Loaded_AS_OF_NOW.insert(
4525 map_Nyms_Loaded_In_This_Function.begin(),
4526 map_Nyms_Loaded_In_This_Function.end());
4535 &map_Nyms_Already_Loaded_AS_OF_NOW, &map_Nyms_NewlyLoaded,
4536 bToBurnOrNotToBurn);
4538 map_Nyms_Loaded_In_This_Function.insert(map_Nyms_NewlyLoaded.begin(),
4539 map_Nyms_NewlyLoaded.end());
4563 if (!bIsPartyAuthorized) {
4564 otOut << __FUNCTION__ <<
": Party " << str_party_name
4565 <<
" does NOT verify as authorized! \n";
4566 bAreAnyInvalidParties =
true;
4570 theFailedParties.insert(pParty);
4607 bool bAreAnyInvalidAccounts =
false;
4755 for (
auto& it_party : m_mapParties) {
4756 const std::string str_party_name = it_party.first;
4757 OTParty* pParty = it_party.second;
4759 "Unexpected nullptr pointer in party map.");
4763 auto it_failed = theFailedParties.find(pParty);
4765 if (theFailedParties.end() != it_failed)
4769 otOut << __FUNCTION__ <<
": FYI, at least one party ("
4771 <<
") has failed, and right now I'm skipping verification of "
4772 "his asset accounts.\n";
4776 mapOfNyms map_Nyms_NewlyLoaded, map_Nyms_Already_Loaded_AS_OF_NOW;
4778 map_Nyms_Already_Loaded_AS_OF_NOW.insert(
4779 map_Nyms_Already_Loaded.begin(), map_Nyms_Already_Loaded.end());
4780 map_Nyms_Already_Loaded_AS_OF_NOW.insert(
4781 map_Nyms_Loaded_In_This_Function.begin(),
4782 map_Nyms_Loaded_In_This_Function.end());
4790 theServerNym, map_Nyms_Already_Loaded_AS_OF_NOW,
4794 map_Nyms_NewlyLoaded);
4796 map_Nyms_Loaded_In_This_Function.insert(map_Nyms_NewlyLoaded.begin(),
4797 map_Nyms_NewlyLoaded.end());
4798 if (!bAgentsLoaded) {
4799 otOut << __FUNCTION__
4800 <<
": Failed trying to Load and Verify Agent Nyms for party: "
4801 << str_party_name <<
"\n";
4802 bAreAnyInvalidAccounts =
true;
4808 mapOfAccounts map_Accts_NewlyLoaded, map_Accts_Already_Loaded_AS_OF_NOW;
4810 map_Accts_Already_Loaded_AS_OF_NOW.insert(
4811 map_Accts_Already_Loaded.begin(), map_Accts_Already_Loaded.end());
4812 map_Accts_Already_Loaded_AS_OF_NOW.insert(
4813 map_Accts_Loaded_In_This_Function.begin(),
4814 map_Accts_Loaded_In_This_Function.end());
4822 theServerNym, strServerID,
4823 map_Accts_Already_Loaded_AS_OF_NOW,
4826 map_Accts_NewlyLoaded);
4829 map_Accts_Loaded_In_This_Function.insert(map_Accts_NewlyLoaded.begin(),
4830 map_Accts_NewlyLoaded.end());
4831 if (!bAcctsLoaded) {
4834 <<
": Failed trying to Load and Verify Asset Accts for party: "
4835 << str_party_name <<
"\n";
4836 bAreAnyInvalidAccounts =
true;
4851 theServerNym, strServerID,
4853 if (!bAreAcctsVerified) {
4854 otOut << __FUNCTION__
4855 <<
": Failed trying to Verify Asset Accts with their Agents, "
4856 "for party: " << str_party_name <<
"\n";
4857 bAreAnyInvalidAccounts =
true;
4881 const bool bSuccess = (!bAreAnyInvalidParties &&
4882 !bAreAnyInvalidAccounts);
4884 if (bAreAnyInvalidParties)
4885 otOut << __FUNCTION__ <<
": Failure: There are invalid party(s) on "
4886 "this smart contract.\n";
4888 if (bAreAnyInvalidAccounts)
4889 otOut << __FUNCTION__ <<
": Failure: there are invalid account(s) or "
4890 "authorized agent(s) on this smart "
4942 map_Nyms_Loaded_In_This_Function);
4945 map_Accts_Loaded_In_This_Function);
4983 "OTSmartContract::CloseoutOpeningNumbers:"
4984 " Unexpected nullptr pointer in party map.");
5009 std::set<OTParty*>* pFailedParties)
5014 const std::string str_party_name = it.first;
5017 "OTSmartContract::HarvestClosingNumbers: "
5018 "Unexpected nullptr pointer in party map.");
5030 if (
nullptr != pFailedParties)
5035 auto it_failed = pFailedParties->find(pParty);
5037 if (pFailedParties->end() != it_failed)
5041 otOut << __FUNCTION__ <<
": FYI, at least one party ("
5043 <<
") has failed verification, so right now I'm skipping "
5044 "harvesting of his "
5045 "closing transaction numbers. (Since he failed, we "
5046 "never verified his accounts, so we never grabbed "
5048 "numbers in the first place, so there's no need to "
5049 "grab them back now.)\n";
5094 "Unexpected nullptr pointer in party map.");
5138 "Unexpected nullptr pointer in party map.");
5152 while (!theMap.empty()) {
5159 theMap.erase(theMap.begin());
5167 while (!theMap.empty()) {
5168 OTAccount* pAcct = theMap.begin()->second;
5174 theMap.erase(theMap.begin());
5196 otOut <<
"OTSmartContract::AddParty: Party doesn't have an active "
5197 "agent -- who will sign for this smart contract?\n";
5205 otOut <<
"OTSmartContract::AddParty: Failed adding party.\n";
5233 otOut <<
"OTSmartContract::ConfirmParty: Party doesn't have an active "
5234 "agent -- who will sign for this smart contract?\n";
5252 otOut <<
"OTSmartContract::ConfirmParty: Failure trying to reserve "
5253 "transaction numbers for "
5254 "the smart contract. (Nym needs more numbers than he has.)\n";
5278 otOut <<
"OTSmartContract::ConfirmParty: Failed confirming party.\n";
5317 auto it = m_mapStashes.find(str_stash_name);
5319 if (m_mapStashes.end() == it)
5324 m_mapStashes.insert(
5325 std::pair<std::string, OTStash*>(str_stash_name, pStash));
5372 while (!m_mapStashes.empty()) {
5373 OTStash* pStash = m_mapStashes.begin()->second;
5379 m_mapStashes.erase(m_mapStashes.begin());
5404 return static_cast<int32_t
>(m_mapStashes.size());
5422 otErr <<
"OTSmartContract::Compare: Error: How is this function EVER "
5423 "being called when there are stashes present? Only the server "
5424 "can create stashes.\n";
5429 otErr <<
"OTSmartContract::Compare: Error: How is this function EVER "
5430 "being called when there are "
5431 "stash accounts present? Only the server can create stash "
5440 if (
nullptr != pSmartContract) {
5442 otErr <<
"OTSmartContract::Compare: Error: How is this function "
5443 "EVER being called when there are stashes present on rhs? "
5444 "Only the server can create stashes.\n";
5449 otErr <<
"OTSmartContract::Compare: Error: How is this function "
5450 "EVER being called when there are stash accounts present "
5451 "on rhs? Only the server can create stash accounts.\n";
5490 "<smartContract\n version=\"%s\"\n"
5491 " serverID=\"%s\"\n"
5492 " activatorUserID=\"%s\"\n"
5493 " activatorAcctID=\"%s\"\n"
5494 " lastSenderUserID=\"%s\"\n"
5495 " lastSenderAcctID=\"%s\"\n"
5496 " lastRecipientUserID=\"%s\"\n"
5497 " lastRecipientAcctID=\"%s\"\n"
5498 " canceled=\"%s\"\n"
5499 " cancelerUserID=\"%s\"\n"
5500 " transactionNum=\"%lld\"\n"
5501 " creationDate=\"%" PRId64
"\"\n"
5502 " validFrom=\"%" PRId64
"\"\n"
5503 " validTo=\"%" PRId64
"\"\n"
5504 " nextProcessDate=\"%" PRId64
"\""
5515 tValidTo, tNextProcess);
5524 "<closingTransactionNumber value=\"%lld\"/>\n\n",
5533 otErr <<
"OTSmartContract::" << __FUNCTION__
5534 <<
": ERROR: There's only ever "
5535 "supposed to be a single closing number here (for "
5536 "smart contracts.)\n";
5559 for (
auto& it : m_mapStashes) {
5573 m_strLastSenderUser.
Release();
5575 m_strLastSenderAcct.
Release();
5577 m_strLastRecipientUser.
Release();
5579 m_strLastRecipientAcct.
Release();
5590 const int64_t& lClosingTransNo,
5619 const OTString strNodeName(xml->getNodeName());
5621 int32_t nReturnVal = 0;
5635 if (0 != (nReturnVal)) {
5639 if (strNodeName.Compare(
"smartContract")) {
5642 const OTString strServerID(xml->getAttributeValue(
"serverID"));
5644 xml->getAttributeValue(
"activatorUserID"));
5646 xml->getAttributeValue(
"activatorAcctID"));
5647 const OTString strCanceled(xml->getAttributeValue(
"canceled"));
5649 xml->getAttributeValue(
"cancelerUserID"));
5651 if (strServerID.Exists()) {
5655 if (strActivatorUserID.Exists()) {
5656 const OTIdentifier ACTIVATOR_USER_ID(strActivatorUserID);
5659 if (strActivatorAcctID.Exists()) {
5660 const OTIdentifier ACTIVATOR_ACCT_ID(strActivatorAcctID);
5664 if (strCanceled.Exists() && strCanceled.Compare(
"true")) {
5667 if (strCancelerUserID.Exists())
5676 const OTString strTransNum = xml->getAttributeValue(
"transactionNum");
5680 const OTString str_valid_from = xml->getAttributeValue(
"validFrom");
5681 const OTString str_valid_to = xml->getAttributeValue(
"validTo");
5682 const OTString str_creation = xml->getAttributeValue(
"creationDate");
5684 xml->getAttributeValue(
"nextProcessDate");
5686 int64_t tValidFrom = str_valid_from.
ToLong();
5687 int64_t tValidTo = str_valid_to.
ToLong();
5688 int64_t tCreation = str_creation.
ToLong();
5689 int64_t tNextProcess = str_next_process.
ToLong();
5702 m_strLastSenderUser = xml->getAttributeValue(
5703 "lastSenderUserID");
5704 m_strLastSenderAcct = xml->getAttributeValue(
5705 "lastSenderAcctID");
5706 m_strLastRecipientUser =
5707 xml->getAttributeValue(
"lastRecipientUserID");
5710 m_strLastRecipientAcct =
5711 xml->getAttributeValue(
"lastRecipientAcctID");
5715 otWarn <<
"\n\n Smartcontract. Transaction Number: "
5718 otInfo <<
" Creation Date: " << tCreation
5719 <<
" Valid From: " << tValidFrom <<
"\n Valid To: " << tValidTo
5721 " ServerID: " << strServerID
5723 " activatorUserID: " << strActivatorUserID <<
"\n ";
5727 else if (strNodeName.Compare(
"accountList"))
5730 const OTString strAcctType = xml->getAttributeValue(
"type");
5731 const OTString strAcctCount = xml->getAttributeValue(
"count");
5735 otErr <<
"OTSmartContract::ProcessXMLNode: Error loading stash "
5742 else if (strNodeName.Compare(
"stash"))
5744 const OTString strStashName = xml->getAttributeValue(
"name");
5745 const OTString strItemCount = xml->getAttributeValue(
"count");
5747 const std::string str_stash_name = strStashName.
Get();
5751 if ((-1) == pStash->
ReadFromXMLNode(xml, strStashName, strItemCount)) {
5752 otErr <<
"OTSmartContract::ProcessXMLNode: Error loading stash: "
5753 << strStashName <<
"\n";
5760 m_mapStashes.insert(
5761 std::pair<std::string, OTStash*>(strStashName.
Get(), pStash));
5783 bool OTSmartContract::MoveFunds(
5784 const mapOfNyms& map_NymsAlreadyLoaded,
const int64_t& lAmount,
5797 otOut <<
" OTCronItem::MoveFunds: Error: lAmount cannot be 0 or <0. "
5798 "(Value passed in was " << lAmount <<
".)\n";
5802 bool bSuccess =
false;
5804 const OTIdentifier SERVER_ID(pCron->
GetServerID());
5805 const OTIdentifier SERVER_USER_ID(*pServerNym);
5807 OTString strSenderUserID(SENDER_USER_ID),
5808 strRecipientUserID(RECIPIENT_USER_ID), strSourceAcctID(SOURCE_ACCT_ID),
5809 strRecipientAcctID(RECIPIENT_ACCT_ID), strServerNymID(SERVER_USER_ID);
5818 if (SOURCE_ACCT_ID == RECIPIENT_ACCT_ID) {
5819 otOut <<
"OTCronItem::MoveFunds: Aborted move: both account IDs were "
5848 std::unique_ptr<OTCronItem> theOrigPlanGuardian(pOrigCronItem);
5852 OTString strOrigPlan(*pOrigCronItem);
5872 OTPseudonym theSenderNym, theRecipientNym;
5877 bool bSenderNymIsServerNym =
5878 ((SENDER_USER_ID == SERVER_USER_ID) ?
true :
false);
5879 bool bRecipientNymIsServerNym =
5880 ((RECIPIENT_USER_ID == SERVER_USER_ID) ?
true :
false);
5885 bool bUsersAreSameNym =
5886 ((SENDER_USER_ID == RECIPIENT_USER_ID) ?
true :
false);
5888 OTPseudonym* pSenderNym =
nullptr;
5889 OTPseudonym* pRecipientNym =
nullptr;
5891 auto it_sender = map_NymsAlreadyLoaded.find(strSenderUserID.Get());
5892 auto it_recipient = map_NymsAlreadyLoaded.find(strRecipientUserID.Get());
5894 if (map_NymsAlreadyLoaded.end() !=
5897 pSenderNym = it_sender->second;
5899 (pSenderNym->CompareID(SENDER_USER_ID)));
5901 if (map_NymsAlreadyLoaded.end() != it_recipient)
5905 pRecipientNym = it_recipient->second;
5907 (pRecipientNym->CompareID(RECIPIENT_USER_ID)));
5911 if (bSenderNymIsServerNym) {
5913 pSenderNym = pServerNym;
5922 if (!theSenderNym.LoadPublicKey()) {
5923 OTString strNymID(SENDER_USER_ID);
5924 otErr <<
"OTCronItem::MoveFunds: Failure loading Sender Nym public "
5925 "key: " << strNymID <<
"\n";
5930 if (theSenderNym.VerifyPseudonym() &&
5931 theSenderNym.LoadSignedNymfile(*pServerNym))
5937 otOut <<
"OTCronItem::MoveFunds: Loading sender Nym, since he **** "
5938 "APPARENTLY **** wasn't already loaded.\n"
5939 "(On a cron item processing, this is normal. But if you "
5940 "triggered a clause directly, then your Nym SHOULD be "
5941 "already loaded...)\n";
5942 pSenderNym = &theSenderNym;
5945 OTString strNymID(SENDER_USER_ID);
5946 otErr <<
"OTCronItem::MoveFunds: Failure loading or verifying "
5947 "Sender Nym public key: " << strNymID <<
"\n";
5954 if (bRecipientNymIsServerNym) {
5956 pRecipientNym = pServerNym;
5958 else if (bUsersAreSameNym)
5961 pRecipientNym = pSenderNym;
5969 if (!theRecipientNym.LoadPublicKey()) {
5970 OTString strNymID(RECIPIENT_USER_ID);
5971 otErr <<
"OTCronItem::MoveFunds: Failure loading Recipient Nym "
5972 "public key: " << strNymID <<
"\n";
5977 if (theRecipientNym.VerifyPseudonym() &&
5978 theRecipientNym.LoadSignedNymfile(*pServerNym)) {
5979 otOut <<
"OTCronItem::MoveFunds: Loading recipient Nym, since he "
5980 "**** APPARENTLY **** wasn't already loaded.\n"
5981 "(On a cron item processing, this is normal. But if you "
5982 "triggered a clause directly, then your Nym SHOULD be "
5983 "already loaded...)\n";
5985 pRecipientNym = &theRecipientNym;
5988 OTString strNymID(RECIPIENT_USER_ID);
5989 otErr <<
"OTCronItem::MoveFunds: Failure loading or verifying "
5990 "Recipient Nym public key: " << strNymID <<
"\n";
6001 auto it_temp = map_ALREADY_LOADED.find(strServerNymID.Get());
6002 if (map_ALREADY_LOADED.end() == it_temp)
6003 map_ALREADY_LOADED.insert(std::pair<std::string, OTPseudonym*>(
6004 strServerNymID.Get(),
6006 it_temp = map_ALREADY_LOADED.find(strSenderUserID.Get());
6007 if (map_ALREADY_LOADED.end() == it_temp)
6008 map_ALREADY_LOADED.insert(std::pair<std::string, OTPseudonym*>(
6009 strSenderUserID.Get(),
6011 it_temp = map_ALREADY_LOADED.find(strRecipientUserID.Get());
6012 if (map_ALREADY_LOADED.end() == it_temp)
6013 map_ALREADY_LOADED.insert(std::pair<std::string, OTPseudonym*>(
6014 strRecipientUserID.Get(), pRecipientNym));
6102 if (!pOrigCronItem->VerifyNymAsAgent(
6103 *pSenderNym, *pServerNym,
6106 &map_ALREADY_LOADED)) {
6107 otErr <<
"OTCronItem::MoveFunds: Failed authorization for sender Nym: "
6108 << strSenderUserID <<
"\n";
6113 if (!pOrigCronItem->VerifyNymAsAgent(
6114 *pRecipientNym, *pServerNym,
6117 &map_ALREADY_LOADED)) {
6119 <<
"OTCronItem::MoveFunds: Failed authorization for recipient Nym: "
6120 << strRecipientUserID <<
"\n";
6179 OTAccount* pSourceAcct =
6182 if (
nullptr == pSourceAcct) {
6183 otOut <<
"OTCronItem::MoveFunds: ERROR verifying existence of source "
6189 std::unique_ptr<OTAccount> theSourceAcctSmrtPtr(pSourceAcct);
6191 OTAccount* pRecipientAcct =
6194 if (
nullptr == pRecipientAcct) {
6195 otOut <<
"OTCronItem::MoveFunds: ERROR verifying existence of "
6196 "recipient account.\n";
6201 std::unique_ptr<OTAccount> theRecipAcctSmrtPtr(pRecipientAcct);
6211 if (pSourceAcct->GetAssetTypeID() !=
6212 pRecipientAcct->GetAssetTypeID()) {
6217 otOut <<
"OTCronItem::MoveFunds: ERROR - attempted payment between "
6218 "accounts of different "
6227 else if (!pSourceAcct->VerifySignature(*pServerNym) ||
6229 otOut <<
"OTCronItem::MoveFunds: ERROR verifying signature or "
6230 "ownership on source account.\n";
6234 else if (!pRecipientAcct->VerifySignature(*pServerNym) ||
6236 otOut <<
"OTCronItem::MoveFunds: ERROR verifying signature or "
6237 "ownership on recipient account.\n";
6255 OTLedger theSenderInbox(SENDER_USER_ID, SOURCE_ACCT_ID, SERVER_ID),
6256 theRecipientInbox(RECIPIENT_USER_ID, RECIPIENT_ACCT_ID, SERVER_ID);
6260 bool bSuccessLoadingSenderInbox = theSenderInbox.LoadInbox();
6261 bool bSuccessLoadingRecipientInbox = theRecipientInbox.LoadInbox();
6265 if (
true == bSuccessLoadingSenderInbox)
6266 bSuccessLoadingSenderInbox =
6267 theSenderInbox.VerifyAccount(*pServerNym);
6269 otErr <<
"OTCronItem::MoveFunds: ERROR loading sender inbox "
6276 if (
true == bSuccessLoadingRecipientInbox)
6277 bSuccessLoadingRecipientInbox =
6278 theRecipientInbox.VerifyAccount(*pServerNym);
6280 otErr <<
"OTCronItem::MoveFunds: ERROR loading recipient inbox "
6287 if ((
false == bSuccessLoadingSenderInbox) ||
6288 (
false == bSuccessLoadingRecipientInbox)) {
6289 otErr <<
"OTCronItem::MoveFunds: ERROR loading or generating one "
6290 "(or both) of the inbox ledgers.\n";
6294 int64_t lNewTransactionNumber =
6299 if (0 == lNewTransactionNumber) {
6300 otOut <<
"OTCronItem::MoveFunds: Aborted move: There are no "
6301 "more transaction numbers available.\n";
6308 lNewTransactionNumber);
6312 lNewTransactionNumber);
6339 const int64_t lTransRecipRefNo =
6363 pTransSend->SetReferenceToNum(lTransSendRefNo);
6364 pTransRecip->SetReferenceToNum(lTransRecipRefNo);
6377 pTransSend->SetReferenceString(strOrigPlan);
6378 pTransRecip->SetReferenceString(strOrigPlan);
6387 if (pSourceAcct->GetBalance() >= lAmount) {
6389 bool bMoveSender = pSourceAcct->Debit(lAmount);
6390 bool bMoveRecipient =
false;
6395 pRecipientAcct->Credit(lAmount);
6403 if (!bMoveRecipient)
6404 pSourceAcct->Credit(lAmount);
6410 if (!bMoveSender || !bMoveRecipient) {
6411 otErr <<
"OTCronItem::MoveFunds: Very strange! Funds were "
6413 "debit or credit failed while performing move.\n";
6424 if (
true == bSuccess)
6429 pItemRecip->SetStatus(
6432 pItemSend->SetAmount(lAmount * (-1));
6436 pItemRecip->SetAmount(lAmount);
6443 otLog3 <<
"OTCronItem::MoveFunds: Move performed.\n";
6458 pItemSend->SetAmount(
6460 pItemRecip->SetAmount(
6463 otLog3 <<
"OTCronItem::MoveFunds: Move failed.\n";
6548 OTString strUpdatedCronItem(*
this);
6556 pItemSend->SetAttachment(strUpdatedCronItem);
6557 pItemRecip->SetAttachment(strUpdatedCronItem);
6566 pItemSend->SignContract(*pServerNym);
6567 pItemRecip->SignContract(*pServerNym);
6569 pItemSend->SaveContract();
6570 pItemRecip->SaveContract();
6574 pTransSend->AddItem(*pItemSend);
6575 pTransRecip->AddItem(*pItemRecip);
6577 pTransSend->SignContract(*pServerNym);
6578 pTransRecip->SignContract(*pServerNym);
6580 pTransSend->SaveContract();
6581 pTransRecip->SaveContract();
6587 theSenderInbox.AddTransaction(*pTransSend);
6588 theRecipientInbox.AddTransaction(*pTransRecip);
6592 theSenderInbox.ReleaseSignatures();
6593 theRecipientInbox.ReleaseSignatures();
6596 theSenderInbox.SignContract(*pServerNym);
6597 theRecipientInbox.SignContract(*pServerNym);
6600 theSenderInbox.SaveContract();
6601 theRecipientInbox.SaveContract();
6604 pSourceAcct->SaveInbox(theSenderInbox);
6605 pRecipientAcct->SaveInbox(theRecipientInbox);
6609 pTransSend->SaveBoxReceipt(theSenderInbox);
6610 pTransRecip->SaveBoxReceipt(theRecipientInbox);
6616 if (
true == bSuccess) {
6620 pSourceAcct->ReleaseSignatures();
6621 pRecipientAcct->ReleaseSignatures();
6624 pSourceAcct->SignContract(*pServerNym);
6625 pRecipientAcct->SignContract(*pServerNym);
6628 pSourceAcct->SaveContract();
6629 pRecipientAcct->SaveContract();
6634 pSourceAcct->SaveAccount();
6635 pRecipientAcct->SaveAccount();
bool SendANoticeToAllParties()
OTParty * FindPartyBasedOnNymIDAsAgent(const OTIdentifier &theNymID, OTAgent **ppAgent=nullptr) const
virtual void GetAllTransactionNumbers(OTNumList &numlistOutput) const
int64_t GetNextTransactionNumber()
bool DropFinalReceiptToNymboxes(const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
void SetAmount(int64_t lAmount)
virtual void onActivate()
#define SMARTCONTRACT_HOOK_ON_ACTIVATE
bool LoadAndVerifyAgentNyms(OTPseudonym &theServerNym, mapOfNyms &map_Nyms_Already_Loaded, mapOfNyms &map_NewlyLoaded)
static EXPORT int64_t StringToLong(const std::string &number)
bool HasTransactionNum(const int64_t &lInput) const
int32_t GetCountStashAccts() const
OTStashItem * GetStash(const std::string &str_asset_type_id)
static EXPORT OTTransaction * GenerateTransaction(const OTIdentifier &theUserID, const OTIdentifier &theAccountID, const OTIdentifier &theServerID, transactionType theType, int64_t lTransactionNum=0)
bool VerifyAccountsWithTheirAgents(OTPseudonym &theSignerNym, const OTString &strServerID, bool bBurnTransNo=false)
virtual EXPORT bool AddParty(OTParty &theParty)
std::string GetRemainingTimer() const
EXPORT std::string GetPartyName(bool *pBoolSuccess=nullptr) const
bool LoadAndVerifyAssetAccounts(OTPseudonym &theServerNym, const OTString &strServerID, mapOfAccounts &map_Accts_Already_Loaded, mapOfAccounts &map_NewlyLoaded)
EXPORT bool StashFunds(const mapOfNyms &map_NymsAlreadyLoaded, const int64_t &lAmount, const OTIdentifier &PARTY_ACCT_ID, const OTIdentifier &PARTY_USER_ID, OTStash &theStash)
EXPORT void RegisterForExecution(OTScript &theScript)
EXPORT bool SendNoticeToAllParties(bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &theServerID, const int64_t &lNewTransactionNumber, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr) const
const OTIdentifier & GetSenderUserID() const
OTStash * GetStash(std::string str_stash_name)
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
std::string GetAssetTypeIDofAcct(std::string from_acct_name)
bool(OTSmartContract::* OT_SM_RetBool_ThrStr)(std::string from_acct_name, std::string to_acct_name, std::string str_Amount)
time64_t GetValidTo() const
EXPORT bool VerifySmartContract(OTPseudonym &theNym, OTAccount &theAcct, OTPseudonym &theServerNym, bool bBurnTransNo=false)
EXPORT OTParty * FindPartyBasedOnNymAsAuthAgent(OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
void SetValidFrom(time64_t TIME_FROM)
virtual void onFinalReceipt(OTCronItem &theOrigCronItem, const int64_t &lNewTransactionNumber, OTPseudonym &theOriginator, OTPseudonym *pRemover)
virtual void RegisterOTNativeCallsWithScript(OTScript &theScript)
virtual EXPORT bool VerifyAccount(const OTPseudonym &theNym)
EXPORT const OTIdentifier & GetAssetTypeID() const
int64_t GetTransactionNum() const
EXPORT void RegisterVariablesForExecution(OTScript &theScript)
EXPORT int64_t GetBalance() const
EXPORT bool VerifyOwnerByID(const OTIdentifier &nymId) const
void ClearTemporaryPointers()
bool ReserveTransNumsForConfirm(const OTString &strServerID)
int64_t OTTimeGetTimeInterval(time64_t lhs, time64_t rhs)
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
EXPORT bool SaveContract()
int64_t m_lTransactionNum
EXPORT bool VerifyIssuedNum(const OTString &strServerID, const int64_t &lTransNum) const
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
EXPORT int64_t ToLong() const
void ClearTemporaryPointers()
virtual void HarvestOpeningNumber(OTPseudonym &theNym)
bool SendNoticeToParty(bool bSuccessMsg, OTPseudonym &theServerNym, const OTIdentifier &theServerID, const int64_t &lNewTransactionNumber, const OTString &strReference, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr, OTPseudonym *pActualNym=nullptr)
static EXPORT OTCronItem * LoadCronReceipt(const int64_t &lTransactionNum)
std::map< std::string, OTVariable * > mapOfVariables
virtual EXPORT void RegisterOTNativeCallsWithScript(OTScript &theScript)
bool IsFlaggedForRemoval() const
void CloseoutOpeningNumber(const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
bool GetSignerID(OTIdentifier &theOutput) const
bool CanCancelContract(std::string str_party_name)
EXPORT bool AddTransaction(OTTransaction &theTransaction)
#define SMARTCONTRACT_HOOK_ON_PROCESS
OTLOG_IMPORT OTLogStream otOut
virtual void onRemovalFromCron()
std::map< std::string, OTPseudonym * > mapOfNyms
virtual EXPORT bool Compare(OTScriptable &rhs) const
std::string GetStashBalance(std::string stash_name, std::string asset_type_id)
const OTIdentifier & GetServerID() const
OTLOG_IMPORT OTLogStream otLog3
EXPORT void SetAttachment(const OTString &theStr)
bool CopyValueBool() const
EXPORT std::shared_ptr< OTAccount > GetOrCreateAccount(OTPseudonym &serverNym, const OTIdentifier &ACCOUNT_OWNER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTIdentifier &SERVER_ID, bool &wasAcctCreated, int64_t stashTransNum=0)
std::map< std::string, OTClause * > mapOfClauses
virtual void SetDisplayLabel(const std::string *pstrLabel=nullptr)
#define SMART_CONTRACT_PROCESS_INTERVAL
void SetValidTo(time64_t TIME_TO)
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
EXPORT bool LoadSignedNymfile(OTPseudonym &SIGNER_NYM)
EXPORT int32_t ReadFromXMLNode(irr::io::IrrXMLReader *&xml, const OTString &acctType, const OTString &acctCount)
void CloseoutOpeningNumbers(OTPseudonym *pSignerNym=nullptr)
EXPORT const OTString & GetName() const
void HarvestOpeningNumber(const OTString &strServerID)
EXPORT void Concatenate(const char *arg,...)
EXPORT OTAgent * GetAuthorizedAgent()
EXPORT bool VerifyCurrentDate()
EXPORT int32_t GetCountAccountIDs() const
EXPORT int32_t GetTransactionNumCount(const OTIdentifier &theServerID) const
void SetCreationDate(const time64_t &CREATION_DATE)
void ClearClosingNumbers()
mapOfParties m_mapParties
EXPORT int64_t GetClosingTransactionNoAt(uint32_t nIndex) const
EXPORT bool VerifyPseudonym() const
int64_t GetAmount() const
static EXPORT OTItem * CreateItemFromTransaction(const OTTransaction &theOwner, OTItem::itemType theType, const OTIdentifier *pDestinationAcctID=nullptr)
const time64_t & GetNextProcessDate() const
EXPORT void ReleaseSignatures()
EXPORT bool Exists() const
EXPORT void SetString(const char *szString)
EXPORT void SetIdentifier(const OTIdentifier &theIdentifier)
virtual bool CanRemoveItemFromCron(OTPseudonym &theNym)
const OTIdentifier & GetServerID() const
EXPORT void Format(const char *fmt,...)
void SetStatus(const OTItem::itemStatus &theVal)
void HarvestClosingNumbers(const OTString &strServerID, bool bSave=false, OTPseudonym *pSignerNym=nullptr)
time64_t GetValidFrom() const
EXPORT bool LoadPublicKey()
const OTIdentifier & GetRealAccountID() const
virtual bool ProcessCron()
void SetNextProcessDate(const time64_t &tNEXT_DATE)
EXPORT void SetReferenceString(const OTString &theStr)
bool ExecuteCallback(OTClause &theCallbackClause, mapOfVariables &theParameters, OTVariable &varReturnVal)
EXPORT void PrepareToActivate(const int64_t &lOpeningTransNo, const int64_t &lClosingTransNo, const OTIdentifier &theUserID, const OTIdentifier &theAcctID)
EXPORT int32_t GetCountClosingNumbers() const
EXPORT const OTString & GetName()
bool VerifyPartyAuthorization(OTParty &theParty, OTPseudonym &theSignerNym, const OTString &strServerID, mapOfNyms *pmap_ALREADY_LOADED=nullptr, mapOfNyms *pmap_NEWLY_LOADED=nullptr, bool bBurnTransNo=false)
virtual bool IsValidOpeningNumber(const int64_t &lOpeningNum) const
time64_t OTTimeGetCurrentTime()
void UpdateContentsToString(OTString &strAppend, bool bCalculatingID) const
virtual bool ProcessCron()
OTPseudonym * LoadAuthorizingAgentNym(OTPseudonym &theSignerNym, OTAgent **ppAgent=nullptr)
EXPORT const char * GetCode() const
int32_t ReadFromXMLNode(irr::io::IrrXMLReader *&xml, const OTString &strStashName, const OTString &strItemCount)
EXPORT bool RemoveIssuedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
void SetTransactionNum(int64_t lTransactionNum)
void RetrieveNymPointers(mapOfNyms &map_Nyms_Already_Loaded)
static void CleanupAccts(mapOfAccounts &theMap)
static void CleanupNyms(mapOfNyms &theMap)
OTString m_strContractType
#define OT_ASSERT_MSG(x, s)
std::map< std::string, OTAccount * > mapOfAccounts
OTClause * GetCallback(std::string str_CallbackName)
OTLOG_IMPORT OTLogStream otInfo
EXPORT OTParty * GetParty(std::string str_party_name) const
EXPORT bool CompareID(const OTIdentifier &theIdentifier) const
const OTString & GetAgentName() const
bool DebitStash(const int64_t &lAmount)
EXPORT std::string GetPartyID(bool *pBoolSuccess=nullptr) const
int32_t GetCountStashes() const
const int64_t & GetProcessInterval() const
void SetSenderAcctID(const OTIdentifier &ACCT_ID)
bool DropFinalReceiptToInboxes(mapOfNyms *pNymMap, const OTString &strServerID, OTPseudonym &theServerNym, const int64_t &lNewTransactionNumber, const OTString &strOrigCronItem, OTString *pstrNote=nullptr, OTString *pstrAttachment=nullptr)
EXPORT OTVariable * GetVariable(std::string str_Name)
OTStringXML m_xmlUnsigned
virtual bool HasTransactionNum(const int64_t &lInput) const
EXPORT bool SaveBoxReceipt(int64_t lLedgerType)
OTLOG_IMPORT OTLogStream otWarn
virtual bool AddParty(OTParty &theParty)
EXPORT const char * Get() const
void Serialize(OTString &strAppend) const
virtual bool ConfirmParty(OTParty &theParty)
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
EXPORT bool SaveInbox(OTLedger &box, OTIdentifier *hash=nullptr)
void SetServerID(const OTIdentifier &SERVER_ID)
EXPORT bool IsAnIndividual() const
OTLOG_IMPORT OTLogStream otErr
EXPORT void Serialize(OTString &append) const
OTBylaw * GetBylaw() const
virtual void HarvestClosingNumbers(OTPseudonym &theNym)
const OTString & GetAcctID() const
EXPORT void SetReferenceToNum(int64_t lTransactionNum)
void ReleaseLastSenderRecipientIDs()
OTIdentifier * m_pCancelerNymID
EXPORT const char * GetLanguage() const
void Release_SmartContract()
virtual bool Compare(OTScriptable &rhs) const
OTPseudonym * GetServerNym() const
EXPORT void ExecuteClauses(mapOfClauses &theClauses, OTString *pParam=nullptr)
EXPORT void GetString(OTString &theStr) const
virtual bool SaveContractWallet(std::ofstream &ofs) const
void DeactivateSmartContract()
virtual int64_t GetOpeningNumber(const OTIdentifier &theNymID) const
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
const OTIdentifier & GetSenderAcctID() const
const time64_t & GetLastProcessDate() const
virtual EXPORT bool VerifyNymAsAgentForAccount(OTPseudonym &theNym, OTAccount &theAccount) const
virtual void UpdateContents()
bool IsDirtyImportant() const
std::set< int64_t > & GetSetOpenCronItems()
int64_t GetOpeningTransNo() const
int64_t GetClosingTransNo() const
EXPORT OTParty * FindPartyBasedOnNymAsAgent(OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
void HarvestAllTransactionNumbers(const OTString &strServerID)
void SetSenderUserID(const OTIdentifier &USER_ID)
void SetRemainingTimer(std::string str_seconds_from_now)
bool HasActiveAgent() const
int64_t OTTimeGetSecondsFromTime(time64_t time)
EXPORT void AddClosingTransactionNo(const int64_t &lClosingTransactionNo)
bool SendNoticeToParty(std::string party_name)
bool GetHooks(std::string str_HookName, mapOfClauses &theResults)
bool CreditStash(const int64_t &lAmount)
std::string GetAcctBalance(std::string from_acct_name)
int64_t GetAmount(std::string str_asset_type_id)
virtual EXPORT void Release()
OTPartyAccount * GetPartyAccountByID(const OTIdentifier &theAcctID) const
bool UnstashAcctFunds(std::string to_acct_name, std::string from_stash_name, std::string str_Amount)
EXPORT bool SaveAccount()
OTPartyAccount * GetPartyAccount(std::string str_acct_name) const
virtual EXPORT bool ConfirmParty(OTParty &theParty)
OTParty * GetParty() const
virtual EXPORT ~OTSmartContract()
EXPORT bool Credit(const int64_t &amount)
static EXPORT OTAccount * LoadExistingAccount(const OTIdentifier &accountId, const OTIdentifier &serverId)
EXPORT bool Debit(const int64_t &amount)
virtual EXPORT void Release()
EXPORT std::shared_ptr< OTScript > OTScriptFactory(const std::string &script_type="")
void GetAllTransactionNumbers(OTNumList &numlistOutput) const
virtual int64_t GetClosingNumber(const OTIdentifier &theAcctID) const
void SetProcessInterval(const int64_t &THE_DATE)
bool StashAcctFunds(std::string from_acct_name, std::string to_stash_name, std::string str_Amount)
EXPORT void AddItem(OTItem &theItem)
#define SMARTCONTRACT_CALLBACK_PARTY_MAY_CANCEL
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)
const time64_t & GetCreationDate() const
bool HasAuthorizingAgent(OTPseudonym &theNym, OTAgent **ppAgent=nullptr) const
bool MoveAcctFundsStr(std::string from_acct_name, std::string to_acct_name, std::string str_Amount)
EXPORT bool SetServerIDIfEmpty(const OTIdentifier &theID)
void SetLastProcessDate(const time64_t &THE_DATE)