Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OT_Command Class Reference

#include <ot_commands_ot.hpp>

Static Public Member Functions

EXPORT static OT_COMMANDS_OT
int32_t 
accept_from_paymentbox (const std::string &strMyAcctID, const std::string &strIndices, const std::string &strPaymentType)
 
EXPORT static OT_COMMANDS_OT
int32_t 
accept_inbox_items (const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_accept_invoices (const std::string &strMyAcctID, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_accept_payments (const std::string &strMyAcctID, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_account_balance (const std::string &strID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_cancel_outgoing (const std::string &strMyNym, const std::string &strMyAcct, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
std::string 
details_check_user (const std::string &strServerID, const std::string &strMyNymID, const std::string &strHisNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_clear_expired (const std::string &strServerID, const std::string &strMyNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_clear_records (const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_confirm_plan (const std::string &strPlan, int32_t nIndex)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_confirm_smart_contract (std::string &strSmartContract, int32_t nIndex)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_create_nym (int32_t nKeybits, const std::string &strName, const std::string &strSourceForNymID, const std::string &strAltLocation)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_create_offer (const std::string &strScale, const std::string &strMinIncrement, const std::string &strQuantity, const std::string &strPrice, bool bSelling, const std::string &strLifespan)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_del_mail (const std::string &strMyNymID, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_del_outmail (const std::string &strMyNymID, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_deposit (const std::string &strServerID, const std::string &strMyAcctID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_deposit_cheque (const std::string &strServerID, const std::string &strMyAcct, const std::string &strMyNymID, const std::string &strInstrument, const std::string &strType)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_deposit_purse (const std::string &strServerID, const std::string &strMyAcct, const std::string &strFromNymID, const std::string &strInstrument, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_discard_incoming (const std::string &strServer, const std::string &strMyNym, const std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_download_box_receipt (const std::string &strID, int32_t nBoxType)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_download_contract (const std::string &strServerID, const std::string &strNymID, const std::string &strContractID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_exchange_basket (const std::string &strServer, const std::string &strNym, const std::string &strAcct, const std::string &strBasketType)
 
EXPORT static OT_COMMANDS_OT
std::string 
details_export_cash (const std::string &strServerID, const std::string &strFromNymID, const std::string &strAssetTypeID, std::string &strHisNymID, const std::string &strIndices, bool bPasswordProtected, std::string &strRetainedCopy)
 
EXPORT static OT_COMMANDS_OT
std::string 
details_export_nym (const std::string &strNymID)
 
EXPORT static OT_COMMANDS_OT
std::string 
details_get_nym_market_offers (const std::string &strServerID, const std::string &strNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_import_cash (const std::string &strInstrument)
 
EXPORT static OT_COMMANDS_OT bool details_import_nym (const std::string &strNymImportFile, std::string &strOutNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_import_purse (const std::string &strInstrument, bool bHasPassword, const std::string &strPurseOwner)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_kill_offer (const std::string &strServerID, const std::string &strNymID, const std::string &strAcctID, const std::string &strTransNum)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_new_basket (const std::string &strServer, const std::string &strNym)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_nym_stat (const std::string &strID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_pay_dividend (const std::string &strAmount, const std::string &strMemo)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_propose_plan (const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID, const std::string &strHisNymID, const std::string &strHisAcctID, const std::string &strDates, const std::string &strConsideration, const std::string &strInitialPayment, const std::string &strPaymentPlan, const std::string &strExpiry)
 
EXPORT static OT_COMMANDS_OT bool details_refresh_nym (const std::string &strServerID, const std::string &strMyNymID, bool bForceDownload)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_send_cash (std::string &strResponse, const std::string &strServerID, const std::string &strAssetTypeID, const std::string &strMyNymID, const std::string &strMyAcctID, std::string &strHisNymID, const std::string &strMemo, const std::string &strAmount, std::string &strIndices, bool bPasswordProtected)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_send_transfer (const std::string &strMyAcctID, const std::string &strHisAcctID, const std::string &strAmount, const std::string &strNote)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_basket ()
 
EXPORT static OT_COMMANDS_OT bool details_show_credential (const std::string &strMyNymID, const std::string &strCredID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_credentials (const std::string &strMyNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_expired (const std::string &strServerID, const std::string &strMyNymID, int32_t nIndex, const std::string &strExpiredBox)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_expired_records (const std::string &strServerID, const std::string &strMyNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_market_offers (const std::string &strServerID, const std::string &strMarketID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_nym_offers (const std::string &strServerID, const std::string &strNymID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_record (const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID, int32_t nIndex, const std::string &strRecordBox)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_show_records (const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_stat_account (const std::string &strID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_trigger_clause (const std::string &strServerID, const std::string &strMyNymID, const std::string &strTransNum, const std::string &strClause, const std::string &strParam)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_withdraw_cash (const std::string &strMyAcctID, int64_t lAmount)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_withdraw_voucher (std::string &strOutput)
 
EXPORT static OT_COMMANDS_OT
int32_t 
details_write_cheque (std::string &strCheque, bool bIsInvoice)
 
EXPORT static OT_COMMANDS_OT
int32_t 
download_acct_files ()
 
EXPORT static OT_COMMANDS_OT
std::string 
find_masterID_for_subcred (const std::string &strMyNymID, const std::string &strInputID)
 
EXPORT static OT_COMMANDS_OT
std::string 
find_revokedID_for_subcred (const std::string &strMyNymID, const std::string &strInputID)
 
EXPORT static OT_COMMANDS_OT
int32_t 
handle_payment_index (const std::string &strMyAcctID, int32_t nIndex, const std::string &strPaymentType, const std::string &strInbox)
 
EXPORT static OT_COMMANDS_OT
int32_t 
impl_show_market_offers (std::string &strMarket)
 
EXPORT static OT_COMMANDS_OT
OTDB::MarketList
loadMarketList (const std::string &strerverID)
 
EXPORT static OT_COMMANDS_OT
OTDB::OfferListMarket
loadMarketOffers (const std::string &strerverID, const std::string &strMarketID)
 
EXPORT static OT_COMMANDS_OT bool purse_get_indices_or_amount (const std::string &strServerID, const std::string &strAssetTypeID, const std::string &strMyNymID, int64_t &lAmount, std::string &strIndices)
 
EXPORT static OT_COMMANDS_OT bool show_mail_message (const std::string &strMyNymID, int32_t nIndex, bool bShowContents)
 
EXPORT static OT_COMMANDS_OT bool show_outmail_message (const std::string &strMyNymID, int32_t nIndex, bool bShowContents)
 
EXPORT static OT_COMMANDS_OT bool show_outpayment (const std::string &strMyNym, int32_t nIndex, bool bShowInFull)
 
EXPORT static OT_COMMANDS_OT bool show_unconfirmed_parties (const std::string &strSmartContract, int32_t &nPartyCount)
 
EXPORT static OT_COMMANDS_OT
int32_t 
stat_basket_accounts (const std::string &strServer, const std::string &strNym, bool bFilter, const std::string &strBasketType)
 
EXPORT static OT_COMMANDS_OT bool stat_partyaccount (const std::string &strSmartContract, const std::string &strPartyName, const std::string &strAcctName, int32_t nCurrentAccount)
 
EXPORT static OT_COMMANDS_OT bool stat_partyaccount_index (const std::string &strSmartContract, const std::string &strPartyName, int32_t nCurrentAccount)
 
EXPORT static OT_COMMANDS_OT bool stat_partyaccounts (const std::string &strSmartContract, const std::string &strPartyName, int32_t nDepth)
 
EXPORT static OT_COMMANDS_OT bool stat_partyagent (const std::string &strSmartContract, const std::string &strPartyName, const std::string &strAgentName, int32_t nIndex)
 
EXPORT static OT_COMMANDS_OT bool stat_partyagent_index (const std::string &strSmartContract, const std::string &strPartyName, int32_t nCurrentAgent)
 
EXPORT static OT_COMMANDS_OT bool stat_partyagents (const std::string &strSmartContract, const std::string &strPartyName, int32_t nDepth)
 
EXPORT static OT_COMMANDS_OT bool withdraw_and_send_cash (const std::string &strMyAcctID, std::string &strHisNymID, const std::string &strMemo, const std::string &strAmount)
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptAll ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptInbox ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptInvoices ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptMoney ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptPayments ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptReceipts ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAcceptTransfers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAddAsset ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAddServer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAddSignature ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainAdjustUsageCredits ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainCancel ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainChangePw ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainCheckNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainClearExpired ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainClearRecords ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainConfirm ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDecode ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDecrypt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDeleteInmail ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDeleteOutmail ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDeposit ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainDiscard ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEditAccount ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEditAsset ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEditNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEditServer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEncode ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainEncrypt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainExchangeBasket ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainExportCash ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainExportNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainGetContract ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainGetMarkets ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainGetMyOffers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainGetOffers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainGetReceipt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainImportCash ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainImportNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainInbox ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainInmail ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainInpayments ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainIssueAsset ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainKillOffer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainKillPlan ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewAccount ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewAsset ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewBasket ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewCredential ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewKey ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewOffer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainNewServer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainOutbox ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainOutmail ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainOutpayment ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainPasswordDecrypt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainPasswordEncrypt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainPayDividend ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainPayInvoice ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainProposePlan ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainRefresh ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainRefreshAccount ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainRefreshNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainRegisterNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainRevokeCredential ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSendCash ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSendCheque ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSendInvoice ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSendMessage ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSendVoucher ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowAccount ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowAccounts ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowActive ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowAssets ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowBalance ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowBasket ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowCredential ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowCredentials ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowExpired ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowIncoming ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowMarkets ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowMint ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowMyOffers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowNym ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowNyms ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowOffers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowOutgoing ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowPayment ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowPurse ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowRecords ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowServers ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainShowWallet ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainSignContract ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainTransfer ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainTriggerClause ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainVerifyReceipt ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainVerifySignature ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainWithdrawCash ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainWithdrawVoucher ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainWriteCheque ()
 
EXPORT static OT_COMMANDS_OT
int32_t 
mainWriteInvoice ()
 

Detailed Description

Definition at line 149 of file ot_commands_ot.hpp.

Member Function Documentation

OT_COMMANDS_OT int32_t opentxs::OT_Command::accept_from_paymentbox ( const std::string &  strMyAcctID,
const std::string &  strIndices,
const std::string &  strPaymentType 
)
static

Definition at line 8980 of file ot_commands_ot.cpp.

8983 {
8984  if (!VerifyStringVal(strMyAcctID)) {
8985  otOut << "Failure: strMyAcctID not a valid string.\n";
8986  return -1;
8987  }
8988 
8989  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
8990  if (!VerifyStringVal(strMyNymID)) {
8991  otOut << "Failure: Unable to find NymID based on myacct. Use: --myacct "
8992  "ACCT_ID\n";
8993  otOut << "The designated asset account must be yours. OT will find the "
8994  "Nym based on the account.\n\n";
8995  return -1;
8996  }
8997 
8998  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
8999  if (!VerifyStringVal(strServerID)) {
9000  otOut << "Failure: Unable to find Server ID based on myacct. Use: "
9001  "--myacct ACCT_ID\n";
9002  otOut << "The designated asset account must be yours. OT will find the "
9003  "Server based on the account.\n\n";
9004  return -1;
9005  }
9006 
9007  string strInbox = OTAPI_Wrap::LoadPaymentInbox(strServerID, strMyNymID);
9008  if (!VerifyStringVal(strInbox)) {
9009  otOut << "\n\n accept_from_paymentbox: OT_API_LoadPaymentInbox "
9010  "Failed.\n\n";
9011  return -1;
9012  }
9013 
9014  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(strServerID, strMyNymID,
9015  strMyNymID, strInbox);
9016  if (0 > nCount) {
9017  otOut
9018  << "Unable to retrieve size of payments inbox ledger. (Failure.)\n";
9019  return -1;
9020  }
9021 
9022  int32_t nIndicesCount =
9023  VerifyStringVal(strIndices) ? OTAPI_Wrap::NumList_Count(strIndices) : 0;
9024 
9025  // Either we loop through all the instruments and accept them all, or
9026  // we loop through all the instruments and accept the specified indices.
9027  //
9028  // (But either way, we loop through all the instruments.)
9029  //
9030  for (int32_t nIndex = (nCount - 1); nIndex >= 0; --nIndex) {
9031  bool bContinue = false;
9032 
9033  // - If indices are specified, but the current index is not on
9034  // that list, then continue...
9035  //
9036  // - If NO indices are specified, accept all the ones matching MyAcct's
9037  // asset type.
9038  if ((nIndicesCount > 0) &&
9039  !OTAPI_Wrap::NumList_VerifyQuery(strIndices,
9040  std::to_string(nIndex))) {
9041  bContinue = true;
9042  }
9043  else if (!bContinue) {
9044  handle_payment_index(strMyAcctID, nIndex, strPaymentType, strInbox);
9045  }
9046  }
9047 
9048  return 1;
9049 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string to_string(const T &t)
static EXPORT std::string LoadPaymentInbox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1553
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t handle_payment_index(const std::string &strMyAcctID, int32_t nIndex, const std::string &strPaymentType, const std::string &strInbox)
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::accept_inbox_items ( const std::string &  strMyAcctID,
int32_t  nItemType,
const std::string &  strIndices 
)
static

Definition at line 5639 of file ot_commands_ot.cpp.

5642 {
5643  Utility MsgUtil;
5644 
5645  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
5646  if (!VerifyStringVal(strMyNymID)) {
5647  otOut
5648  << "Failure: Unable to find NymID based on the specified account ( "
5649  << strMyAcctID << " ).\n";
5650  return -1;
5651  }
5652  if (VerifyExists("MyNym", false) && (MyNym != strMyNymID)) {
5653  otOut << "Try again: MyNym is specified, but it's not the owner of the "
5654  "specified account ( " << strMyAcctID << " ).\n";
5655  otOut << "To override with the nym for this account, add: --mynym "
5656  << strMyNymID << " \n\n";
5657  return -1;
5658  }
5659 
5660  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
5661  if (!VerifyStringVal(strServerID)) {
5662  otOut << "Failure: Unable to find Server ID based on the specified "
5663  "account ( " << strMyAcctID << " ).\n";
5664  return -1;
5665  }
5666  if (VerifyExists("Server", false) && (Server != strServerID)) {
5667  otOut << "Try again: Server is specified, but it's not the server for "
5668  "the specified account ( " << strMyAcctID << " ).\n";
5669  otOut << "To override with the server for this account, add: --server "
5670  << strServerID << " \n\n";
5671  return -1;
5672  }
5673 
5674  // User may have already chosen indices (passed in) so we don't want to
5675  // re-download the inbox unless we HAVE to. But if the hash has changed,
5676  // that's
5677  // one clear-cut case where we _do_ have to. Otherwise our balance agreement
5678  // will fail anyway. So hopefully we can let OT "be smart about it" here
5679  // instead
5680  // of just forcing it to download every time even when unnecessary.
5681  if (!MsgUtil.getIntermediaryFiles(strServerID, strMyNymID,
5682  strMyAcctID)) // boolean
5683  {
5684  otOut << "Unable to download necessary intermediary files for this "
5685  "inbox/account. (Failure.)\n";
5686  return -1;
5687  }
5688 
5689  // Make sure we have at least one transaction number (to process the inbox
5690  // with.)
5691  //
5692  // NOTE: Normally we don't have to do this, because the high-level API is
5693  // smart
5694  // enough, when sending server transaction requests, to grab new transaction
5695  // numbers
5696  // if it is running low.
5697  // But in this case, we need the numbers available BEFORE sending the
5698  // transaction
5699  // request, because the call to OTAPI_Wrap::Ledger_CreateResponse is where
5700  // the number
5701  // is first needed, and that call is made int64_t before the server
5702  // transaction request
5703  // is actually sent.
5704  if (!MadeEasy::insure_enough_nums(10, strServerID, strMyNymID)) {
5705  return -1;
5706  }
5707 
5708  string strInbox =
5709  OTAPI_Wrap::LoadInbox(strServerID, strMyNymID, strMyAcctID);
5710 
5711  if (!VerifyStringVal(strInbox)) {
5712  otOut << "\n\n OT_API_LoadInbox: Failed.\n\n";
5713  return -1;
5714  }
5715  else {
5716  otOut << "\n\n";
5717 
5718  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(strServerID, strMyNymID,
5719  strMyAcctID, strInbox);
5720  if (nCount > 0) {
5721  // NOTE!!! DO **NOT** create the response ledger until the FIRST
5722  // iteration of the below loop that actually
5723  // creates a transaction response! If that "first iteration" never
5724  // comes (due to receipts being skipped, etc)
5725  // then OTAPI_Wrap::Transaction_CreateResponse will never get
5726  // called, and therefore Ledger_CreateResponse should
5727  // also not be called, either. (Nor should
5728  // OTAPI_Wrap::Ledger_FinalizeResponse, etc.)
5729  string strResponseLEDGER = "";
5730 
5731  int32_t nIndicesCount = VerifyStringVal(strIndices)
5732  ? OTAPI_Wrap::NumList_Count(strIndices)
5733  : 0;
5734 
5735  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
5736  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
5737  strServerID, strMyNymID, strMyAcctID, strInbox, nIndex);
5738 
5739  // nItemType == 0 for all, 1 for transfers only, 2 for receipts
5740  // only.
5741  // strIndices == "" for "all indices"
5742  if (nItemType > 0) // 0 means "all", so we don't have to skip
5743  // anything based on type, if it's 0.
5744  {
5745  string strTransType = OTAPI_Wrap::Transaction_GetType(
5746  strServerID, strMyNymID, strMyAcctID, strTrans);
5747 
5748  // incoming transfer
5749  if ("pending" == strTransType && 1 != nItemType) {
5750  // if it IS an incoming transfer, but we're doing
5751  // receipts, then skip it.
5752  continue;
5753  }
5754  // receipt
5755  if ("pending" != strTransType && 2 != nItemType) {
5756  // if it is NOT an incoming transfer, then it's a
5757  // receipt. If we're not doing receipts, then skip it.
5758  continue;
5759  }
5760  }
5761 
5762  // - If NO indices are specified, process them ALL.
5763  //
5764  // - If indices are specified, but the current index is not on
5765  // that list, then continue...
5766  if ((nIndicesCount > 0) &&
5767  !OTAPI_Wrap::NumList_VerifyQuery(strIndices,
5768  std::to_string(nIndex))) {
5769  continue;
5770  }
5771 
5772  // By this point we know we actually have to call
5773  // OTAPI_Wrap::Transaction_CreateResponse
5774  // Therefore, if OTAPI_Wrap::Ledger_CreateResponse has
5775  // not yet been called (which it won't
5776  // have been, the first time we hit this in this loop),
5777  // then we call it here this one
5778  // time, to get things started...
5779  if (!VerifyStringVal(strResponseLEDGER)) {
5780  strResponseLEDGER = OTAPI_Wrap::Ledger_CreateResponse(
5781  strServerID, strMyNymID, strMyAcctID, strInbox);
5782 
5783  if (!VerifyStringVal(strResponseLEDGER)) {
5784  otOut << "\n\nFailure: "
5785  "OT_API_Ledger_CreateResponse "
5786  "returned nullptr.\n";
5787  return -1;
5788  }
5789  }
5790 
5791  // By this point, we know the ledger response exists,
5792  // and we know we have to create
5793  // a transaction response to go inside of it, so let's
5794  // do that next...
5795  string strNEW_ResponseLEDGER =
5797  strServerID, strMyNymID, strMyAcctID, strResponseLEDGER,
5798  strTrans, true);
5799 
5800  if (!VerifyStringVal(strNEW_ResponseLEDGER)) {
5801  otOut << "\n\nFailure: "
5802  "OT_API_Transaction_CreateResponse "
5803  "returned nullptr.\n";
5804  return -1;
5805  }
5806  strResponseLEDGER = strNEW_ResponseLEDGER;
5807  }
5808 
5809  if (!VerifyStringVal(strResponseLEDGER)) {
5810  // This means there were receipts in the box, but they were
5811  // skipped.
5812  // And after the skipping was done, there were no receipts left.
5813  // So we can't just say "the box is empty" because it's not. But
5814  // nevertheless,
5815  // we aren't actually processing any of them, so we return 0 AS
5816  // IF the box
5817  // had been empty. (Because this is not an error condition. Just
5818  // a "no op".)
5819  return 0;
5820  }
5821 
5822  // Below this point, we know strResponseLEDGER needs to be sent,
5823  // so let's finalize it.
5824  string strFinalizedResponse = OTAPI_Wrap::Ledger_FinalizeResponse(
5825  strServerID, strMyNymID, strMyAcctID, strResponseLEDGER);
5826 
5827  if (!VerifyStringVal(strFinalizedResponse)) {
5828  otOut << "\n\nFailure: OT_API_Ledger_FinalizeResponse returned "
5829  "nullptr.\n";
5830  return -1;
5831  }
5832 
5833  string strResponse = MadeEasy::process_inbox(
5834  strServerID, strMyNymID, strMyAcctID, strFinalizedResponse);
5835  string strAttempt = "process_inbox";
5836 
5837  int32_t nInterpretReply = InterpretTransactionMsgReply(
5838  strServerID, strMyNymID, strMyAcctID, strAttempt, strResponse);
5839 
5840  if (1 == nInterpretReply) {
5841  bool bRetrieved = MadeEasy::retrieve_account(
5842  strServerID, strMyNymID, strMyAcctID, true);
5843 
5844  otOut << "\n\nServer response (" << strAttempt
5845  << "): SUCCESS processing/accepting inbox.\n";
5846  otOut << (bRetrieved ? "Success" : "Failed")
5847  << " retrieving intermediary files for account.\n";
5848  }
5849 
5850  //
5851  return nInterpretReply;
5852  }
5853 
5854  otOut << "The asset account inbox is empty.\n\n";
5855  }
5856 
5857  return 0;
5858 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT std::string Transaction_CreateResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &RESPONSE_LEDGER, const std::string &ORIGINAL_TRANSACTION, const bool &BOOL_DO_I_ACCEPT)
Definition: OTAPI.cpp:1677
std::string to_string(const T &t)
static EXPORT std::string Ledger_FinalizeResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Definition: OTAPI.cpp:1687
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string LoadInbox(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1525
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
static EXPORT std::string Ledger_CreateResponse(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &ORIGINAL_LEDGER)
Creates a new &#39;response&#39; ledger, set up with the right Server ID, etc,.
Definition: OTAPI.cpp:1623
std::string MyNym
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
EXPORT static OT_MADE_EASY_OT std::string process_inbox(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, const std::string &RESPONSE_LEDGER)
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
static EXPORT std::string Transaction_GetType(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Get Transaction Type (internally uses GetTransactionTypeString().)
Definition: OTAPI.cpp:1762
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_accept_invoices ( const std::string &  strMyAcctID,
const std::string &  strIndices 
)
static

Definition at line 9052 of file ot_commands_ot.cpp.

9054 {
9055  return accept_from_paymentbox(strMyAcctID, strIndices, "INVOICE");
9056 }
EXPORT static OT_COMMANDS_OT int32_t accept_from_paymentbox(const std::string &strMyAcctID, const std::string &strIndices, const std::string &strPaymentType)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_accept_payments ( const std::string &  strMyAcctID,
const std::string &  strIndices 
)
static

Definition at line 9080 of file ot_commands_ot.cpp.

9082 {
9083  int32_t nAcceptedPurses =
9084  accept_from_paymentbox(strMyAcctID, strIndices, "PURSE");
9085  int32_t nAcceptedCheques =
9086  accept_from_paymentbox(strMyAcctID, strIndices, "CHEQUE");
9087 
9088  // Note: NOT invoices.
9089 
9090  // FIX: this OR should become AND so we can detect any failure
9091  if (nAcceptedPurses >= 0 || nAcceptedCheques >= 0) {
9092  return 1;
9093  }
9094 
9095  return -1;
9096 }
EXPORT static OT_COMMANDS_OT int32_t accept_from_paymentbox(const std::string &strMyAcctID, const std::string &strIndices, const std::string &strPaymentType)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_account_balance ( const std::string &  strID)
static

Definition at line 5423 of file ot_commands_ot.cpp.

5424 {
5425  string strName = OTAPI_Wrap::GetAccountWallet_Name(strID);
5426  if (!VerifyStringVal(strName)) {
5427  otOut << "\ndetails_account_balance: Cannot find account wallet for: "
5428  << strID << "\n";
5429  return -1;
5430  }
5431 
5432  string strAssetID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(strID);
5433  if (!VerifyStringVal(strAssetID)) {
5434  otOut << "\ndetails_account_balance: Cannot cannot determine asset "
5435  "type for: " << strID << "\n";
5436  return -1;
5437  }
5438 
5439  int64_t lBalance = OTAPI_Wrap::GetAccountWallet_Balance(strID);
5440 
5441  otOut << "\n Balance: ";
5442  cout << OTAPI_Wrap::FormatAmount(strAssetID, lBalance) << "\n";
5443  otOut << strID << " (" << strName << ")\n\n";
5444 
5445  return 1;
5446 }
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:924
OTLOG_IMPORT OTLogStream otOut
static EXPORT int64_t GetAccountWallet_Balance(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1032
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_cancel_outgoing ( const std::string &  strMyNym,
const std::string &  strMyAcct,
const std::string &  strIndices 
)
static

Definition at line 945 of file ot_commands_ot.cpp.

948 {
949  // NOTE: You can't just discard a sent cheque
950  // from your outpayment box. Why not?\nJust because you remove your record
951  // of the outgoing cheque, doesn't mean you didn't already send it. (The
952  // recipient still received it, and still has it, whether you remove it from
953  // your outbox or not.) If you really want to cancel the cheque, then you
954  // need to do it in such a way that it will fail-as-cancelled when the
955  // recipient tries to deposit it. Otherwise, he would get that money whether
956  // you kept your own outgoing record or not. Therefore TODO: SOME server
957  // message must be performed here, which actually cancels the transaction
958  // number itself that appears on the cheque. This is the only way to insure
959  // that the cheque can't be used by the recipient (and even this will only
960  // work if you beat him to the punch -- otherwise if he deposits it before
961  // you cancel it, then it's already too late and he has the money.) THIS is
962  // why RecordPayment, regarding outpayments, only works on expired
963  // instruments -- because if it's not expired, you don't just want to remove
964  // your record of it. You want to cancel the transaction number itself --
965  // and that requires server communication.
966 
967  int32_t nCount = OTAPI_Wrap::GetNym_OutpaymentsCount(strMyNym);
968  if (0 > nCount) {
969  otOut << "Error: cannot retrieve outpayments for Nym: " << strMyNym
970  << "\n";
971  return -1;
972  }
973 
974  int32_t nIndicesCount = OTAPI_Wrap::NumList_Count(strIndices);
975  int32_t nSuccess = 1;
976 
977  if (nCount == 0) {
978  otOut << "\n(Outpayment box is empty)\n\n";
979  nSuccess = 0;
980  }
981  else {
982  for (int32_t nIndex = (nCount - 1); nIndex >= 0; --nIndex) {
983  // - If "all" was passed, we process the item.
984  // - If indices are specified, but the current index is not on
985  // that list, then continue...
986  if (!("all" == strIndices) && nIndicesCount > 0 &&
988  std::to_string(nIndex))) {
989  continue;
990  }
991 
992  // If it IS "all," OR, if there are indices and the current index
993  // was found in them.
994  string strServer =
996  if (!VerifyStringVal(strServer)) {
997  otOut << "ERROR: Failed retrieving server ID from "
998  "outpayment at index: " << nIndex << "\n";
999  }
1000  else {
1001  string strPaymentContents =
1003  nIndex);
1004 
1005  if (VerifyStringVal(strPaymentContents)) {
1006  // string strPaymentAssetID =
1007  // OTAPI_Wrap::Instrmnt_GetAssetID (strPaymentContents)
1008  string strPaymentType =
1009  OTAPI_Wrap::Instrmnt_GetType(strPaymentContents);
1010 
1011  // Done: Put the code here where we message the server
1012  // to cancel all relevant transaction
1013  // numbers for the instrument. If it's a cheque, there's
1014  // only one number. But if it's a smart
1015  // contract, there could be many numbers. Seems like
1016  // best thing is to just activate it, but
1017  // have a "rejected" flag which causes the activation to
1018  // fail. (That way, all the other parties
1019  // will be properly notified, which the server already
1020  // does.) We don't even need to remove it
1021  // from the outpayment box, because the failure
1022  // notification from the server will already cause
1023  // the OTClient to remove it from the outpayment box.
1024  //
1025  // Ah-ha! ANY outgoing payment plan or smart contract is
1026  // necessarily incomplete: it's outgoing
1027  // because it was sent to the next party so he could
1028  // sign it, too, and probably activate it.
1029  // Presumably he has not done so yet (if I am 'beating
1030  // him to the punch' by cancelling it before
1031  // he can activate it) and therefore the plan or smart
1032  // contract still is missing at least one
1033  // signer, so it is GUARANTEED to fail verification if I
1034  // try to activate it myself. (Good.)
1035  //
1036  // This means I can just take whatever instrument
1037  // appears outgoing, and try to activate it myself.
1038  // It will definitely fail activation, and then the
1039  // failure notice will already be sent from that,
1040  // to all the parties, and they can harvest back their
1041  // numbers automatically as necessary.
1042  //
1043  // The one problem is, though this works for payment
1044  // plans and smart contracts, it will not work
1045  // for cheques. The cheque is made out to someone else,
1046  // and he is the one normally who needs to
1047  // deposit it. Plus, I can't deposit a cheque into the
1048  // same account it's drawn on.
1049  //
1050  // UPDATE: Now when a cheque is deposited into the same
1051  // account it was drawn on, that will be
1052  // interpreted by the server as a request to CANCEL the
1053  // cheque.
1054 
1055  if ("SMARTCONTRACT" == strPaymentType) {
1056  // Just take the smart contract from the outpayment
1057  // box, and try to
1058  // activate it. It WILL fail, and then the failure
1059  // message will be
1060  // propagated to all the other parties to the
1061  // contract. (Which will
1062  // result in its automatic removal from the
1063  // outpayment box.)
1064  if (!VerifyStringVal(strMyAcct)) {
1065  otOut << "You must provide an account owned by "
1066  "this Nym, which will be used for the "
1067  "cancellation. Try adding --myacct "
1068  "ACCT_ID\nNOTE: in the future we "
1069  "should just look up one of the "
1070  "accounts from the smart contract "
1071  "itself, since the current Nym has "
1072  "already confirmed the contract. But "
1073  "for now I'm just collecting the acct "
1074  "ID at the command line, since it's "
1075  "faster.\n";
1076  }
1077  else {
1078  string strResponse =
1080  strServer, strMyNym, strMyAcct,
1081  "acct_agent_name", strPaymentContents);
1082 
1083  otOut << "Okay I just tried to activate the "
1084  "smart contract. (As a way of "
1085  "cancelling it.)\nSo while we expect "
1086  "this 'activation' to fail, it should "
1087  "have the desired effect of "
1088  "cancelling the smart contract and "
1089  "sending failure notices to all the "
1090  "parties.\n";
1091 
1092  if (VerifyStringVal(strResponse)) {
1093  otOut << "\n Here's the server reply: \n"
1094  << strResponse << "\n";
1095 
1096  int32_t nTransCancelled =
1098  strServer, strMyNym, strMyAcct,
1099  strResponse);
1100 
1101  if (1 == nTransCancelled) {
1102  otOut << "\n Success canceling!\n";
1103  }
1104  else {
1105  otOut << "\n Error canceling!\n";
1106  nSuccess = -1;
1107  }
1108  }
1109  else {
1110  otOut << "Strange, tried to cancel, but "
1111  "received a nullptr server "
1112  "reply.\n";
1113  }
1114  }
1115  }
1116  else if ("PAYMENT PLAN" == strPaymentType) {
1117  // Just take the payment plan from the outpayment
1118  // box, and try to
1119  // activate it. It WILL fail, and then the failure
1120  // message will be
1121  // propagated to the other party to the contract.
1122  // (Which will
1123  // result in its automatic removal from the
1124  // outpayment box.)
1125 
1126  string strResponse = MadeEasy::cancel_payment_plan(
1127  strServer, strMyNym, strPaymentContents);
1128 
1129  otOut << "Okay I just tried to activate the "
1130  "payment plan. (As a way of cancelling "
1131  "it.)\nSo while we expect this "
1132  "'activation' to fail, it should have the "
1133  "desired effect of cancelling the payment "
1134  "plan and sending failure notices to all "
1135  "the parties.\n";
1136 
1137  if (VerifyStringVal(strResponse)) {
1138  otOut << "\n Here's the server reply: \n"
1139  << strResponse << "\n";
1140 
1141  int32_t nTransCancelled =
1143  strServer, strMyNym, strMyAcct,
1144  strResponse);
1145 
1146  if (1 == nTransCancelled) {
1147  otOut << "\n Success canceling!\n";
1148  }
1149  else {
1150  otOut << "\n Error canceling!\n";
1151  nSuccess = -1;
1152  }
1153  }
1154  else {
1155  otOut << "Strange, tried to cancel, but "
1156  "received a nullptr server reply.\n";
1157  }
1158  }
1159  else if ("PURSE" == strPaymentType) {
1160  // This is a tricky one -- why would anyone EVER
1161  // want to discard outgoing cash?
1162  // Normally your incentive would be to do the
1163  // opposite: Keep a copy of all outgoing
1164  // cash until the copy itself expires (when the cash
1165  // expires.) This way it's always
1166  // recoverable in the event of a "worst case"
1167  // situation.
1168  //
1169  // So what do we do in this case? Nevertheless, the
1170  // user has explicitly just instructed
1171  // the client to DISCARD OUTGOING CASH.
1172  //
1173  // Perhaps we should just ask the user to CONFIRM
1174  // that he wants to erase the cash,
1175  // and make SURE that he understands the
1176  // consequences of that choice.
1177 
1178  // removes payment instrument (from payments in
1179  // or out box)
1180  bool bRecorded = OTAPI_Wrap::RecordPayment(
1181  strServer, strMyNym, false, nIndex, false);
1182  if (!bRecorded) {
1183  nSuccess = -1;
1184  }
1185  else {
1186  otOut << "Discarded cash purse:\n\n"
1187  << strPaymentContents << "\n";
1188  }
1189  otOut << (bRecorded ? "Success" : "Failure")
1190  << " discarding cash purse from "
1191  "outpayment box at index: " << nIndex
1192  << ".\n\n";
1193  }
1194  else // CHEQUE VOUCHER INVOICE
1195  {
1196  int32_t nDepositCheque = -1;
1197  bool bIsVoucher = ("VOUCHER" == strPaymentType);
1198 
1199  // Get the nym and account IDs from the cheque
1200  // itself.
1201  string strSenderAcctID =
1202  (bIsVoucher
1204  strPaymentContents)
1205  : OTAPI_Wrap::Instrmnt_GetSenderAcctID(
1206  strPaymentContents));
1207  string strSenderUserID =
1208  (bIsVoucher
1210  strPaymentContents)
1211  : OTAPI_Wrap::Instrmnt_GetSenderUserID(
1212  strPaymentContents));
1213 
1214  if (!VerifyStringVal(strSenderAcctID)) {
1215  otOut << "Failure trying to retrieve asset "
1216  "account ID from instrument.\n";
1217  }
1218  else if (!VerifyStringVal(strSenderUserID)) {
1219  otOut << "Failure trying to retrieve Sender "
1220  "Nym ID from instrument.\n";
1221  }
1222  else if (!(strSenderUserID == strMyNym)) {
1223  otOut << "Failure, very strange: Sender Nym ID "
1224  "on the instrument doesn't match the "
1225  "Nym ID.\n";
1226  }
1227  else {
1228  nDepositCheque = OT_Command::details_deposit_cheque(
1229  strServer, strSenderAcctID, strSenderUserID,
1230  strPaymentContents, strPaymentType);
1231 
1232  otOut
1233  << "\n"
1234  << (1 == nDepositCheque ? "Success" : "Failure")
1235  << " canceling cheque of type: "
1236  << strPaymentType << "\n";
1237  }
1238  }
1239  }
1240  }
1241  }
1242  }
1243  return nSuccess;
1244 }
static EXPORT std::string Instrmnt_GetRemitterUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:833
static EXPORT std::string Instrmnt_GetRemitterAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:839
std::string to_string(const T &t)
EXPORT static OT_COMMANDS_OT int32_t details_deposit_cheque(const std::string &strServerID, const std::string &strMyAcct, const std::string &strMyNymID, const std::string &strInstrument, const std::string &strType)
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool RecordPayment(const std::string &SERVER_ID, const std::string &USER_ID, const bool &bIsInbox, const int32_t &nIndex, const bool &bSaveCopy)
Definition: OTAPI.cpp:1591
static EXPORT int32_t Message_IsTransactionCanceled(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_MESSAGE)
Definition: OTAPI.cpp:2433
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:758
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetNym_OutpaymentsServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:775
EXPORT static OT_MADE_EASY_OT std::string cancel_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_PAYMENT_PLAN)
static EXPORT std::string GetNym_OutpaymentsContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:763
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
EXPORT static OT_MADE_EASY_OT std::string activate_smart_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &AGENT_NAME, const std::string &THE_SMART_CONTRACT)
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT string opentxs::OT_Command::details_check_user ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strHisNymID 
)
static

Definition at line 5984 of file ot_commands_ot.cpp.

5987 {
5988  // Just to show how easy it is now, let's try a "check_user" message.
5989  // (It sends a NymID to the server, and downloads that Nym's public key.)
5990 
5991  string strServerParam = strServerID;
5992  string strMyNymParam = strMyNymID;
5993  string strHisNymParam = strHisNymID;
5994 
5995  string strResponse;
5996 
5997  // NOTE: If this were Server, MyNym, and HisNym, then we'd have already
5998  // translated the partials to read IDs (in OT itself) but we don't have that
5999  // guarantee in this function. Maybe strServerID was passed in from user
6000  // input
6001  // directly, while inside another script. Partial IDs should still work,
6002  // right?
6003  // So here, we translate them just in case.
6004  if (VerifyStringVal(strServerID) && VerifyStringVal(strMyNymID) &&
6005  VerifyStringVal(strHisNymID)) {
6006  // IF we are able to resolve the HisNymId from a partial, then we
6007  // replace the partial with the full version.
6008  // (Otherwise we assume it's already a full ID and we don't mess with
6009  // it.)
6010  string strServerFromPartial =
6012 
6013  if (VerifyStringVal(strServerFromPartial)) {
6014  strServerParam = strServerFromPartial;
6015  }
6016 
6017  string strHisNymFromPartial =
6019 
6020  if (VerifyStringVal(strHisNymFromPartial)) {
6021  strHisNymParam = strHisNymFromPartial;
6022  }
6023 
6024  string strMyNymFromPartial =
6026 
6027  if (VerifyStringVal(strMyNymFromPartial)) {
6028  strMyNymParam = strMyNymFromPartial;
6029  }
6030 
6031  strResponse =
6032  MadeEasy::check_user(strServerParam, strMyNymParam, strHisNymParam);
6033  }
6034  else {
6035  otOut << "\n details_check_user: Bad input... strServerID, strMyNymID, "
6036  "or strHisNymID \n";
6037  }
6038 
6039  return strResponse;
6040 }
static EXPORT std::string Wallet_GetNymIDFromPartial(const std::string &PARTIAL_ID)
Attempts to find a full ID in the wallet, based on a partial of the same.
Definition: OTAPI.cpp:619
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string check_user(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Wallet_GetServerIDFromPartial(const std::string &PARTIAL_ID)
Definition: OTAPI.cpp:625
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_clear_expired ( const std::string &  strServerID,
const std::string &  strMyNymID 
)
static

Definition at line 10147 of file ot_commands_ot.cpp.

10149 {
10150  bool bTrue = true;
10151  bool bCleared = OTAPI_Wrap::ClearExpired(strServerID, strMyNymID, 0, bTrue);
10152 
10153  return bCleared ? 1 : -1;
10154 }
static EXPORT bool ClearExpired(const std::string &SERVER_ID, const std::string &USER_ID, const int32_t &nIndex, const bool &bClearAll)
Definition: OTAPI.cpp:1608
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_clear_records ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strMyAcctID 
)
static

Definition at line 10036 of file ot_commands_ot.cpp.

10039 {
10040  bool bTrue = true;
10041  bool bCleared =
10042  OTAPI_Wrap::ClearRecord(strServerID, strMyNymID, strMyAcctID, 0, bTrue);
10043 
10044  return bCleared ? 1 : -1;
10045 }
static EXPORT bool ClearRecord(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const int32_t &nIndex, const bool &bClearAll)
Definition: OTAPI.cpp:1599
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_confirm_plan ( const std::string &  strPlan,
int32_t  nIndex 
)
static

Definition at line 2037 of file ot_commands_ot.cpp.

2038 {
2039  string strLocation = "details_confirm_plan";
2040 
2041  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strPlan);
2042  string strSenderUserID = OTAPI_Wrap::Instrmnt_GetSenderUserID(strPlan);
2043  string strSenderAcctID = OTAPI_Wrap::Instrmnt_GetSenderAcctID(strPlan);
2044  string strRecipientUserID =
2046 
2047  if (VerifyStringVal(strServerID) && VerifyStringVal(strSenderUserID) &&
2048  VerifyStringVal(strSenderAcctID) &&
2049  VerifyStringVal(strRecipientUserID) && VerifyStringVal(strPlan)) {
2050 
2051  // Make sure strSenderUserID aka sender of money (aka recipient of
2052  // payment plan
2053  // instrument in his inbox, which if confirmed will have him sending
2054  // money...)
2055  // has enough transaction numbers to confirm the plan.
2056  //
2057  if (!MadeEasy::insure_enough_nums(2, strServerID, strSenderUserID)) {
2058  return -1;
2059  }
2060 
2061  string strConfirmed = OTAPI_Wrap::ConfirmPaymentPlan(
2062  strServerID, strSenderUserID, strSenderAcctID, strRecipientUserID,
2063  strPlan);
2064 
2065  if (VerifyStringVal(strConfirmed)) {
2066  // Below this point, inside this block, if we fail, then we need to
2067  // harvest the transaction
2068  // numbers back from the payment plan that we confirmed
2069  // (strConfirmed.)
2070  string strResponse = MadeEasy::deposit_payment_plan(
2071  strServerID, strSenderUserID, strConfirmed);
2072  string strAttempt = "deposit_payment_plan";
2073  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
2074 
2075  // These are cases where the transaction never even got to TRY to
2076  // run, since the message itself
2077  // failed inside the server before it even got that far.
2078  if (-1 == nMessageSuccess) {
2079  // In this case, the server never even SAW the transaction,
2080  // because its enveloping message already
2081  // failed before we even got that far. So we can harvest, as
2082  // though it was never attempted...
2083  otOut << "Message error: " << strAttempt << ".\n";
2084  int32_t nHarvested = OTAPI_Wrap::Msg_HarvestTransactionNumbers(
2085  strConfirmed, strSenderUserID, false, false, false, false,
2086  false);
2087  otOut << strLocation
2088  << ": OT_API_Msg_HarvestTransactionNumbers: "
2089  << nHarvested << "\n";
2090  return -1;
2091  }
2092  else if (0 == nMessageSuccess) {
2093  otOut << "Server reply (" << strAttempt
2094  << "): Message failure.\n";
2095  int32_t nHarvested = OTAPI_Wrap::Msg_HarvestTransactionNumbers(
2096  strConfirmed, strSenderUserID, false, false, false, false,
2097  false);
2098  otOut << strLocation
2099  << ": OT_API_Msg_HarvestTransactionNumbers: "
2100  << nHarvested << "\n";
2101  return 0;
2102  }
2103  // (else 1: message was processed successfully -- though not
2104  // necessarily the transaction inside it.)
2105 
2106  // BELOW THIS POINT, the transaction has definitely processed. It
2107  // may have succeeded or failed,
2108  // but either way, we don't need to harvest any numbers, since OT
2109  // will internally handle those
2110  // when it processes the server's reply to the transaction attempt.
2111  int32_t nInterpretReply = InterpretTransactionMsgReply(
2112  strServerID, strSenderUserID, strSenderAcctID, strAttempt,
2113  strResponse);
2114  if (1 == nInterpretReply) {
2115  bool bRetrieved = MadeEasy::retrieve_account(
2116  strServerID, strSenderUserID, strSenderAcctID, true);
2117 
2118  otOut << "\nServer response (" << strAttempt
2119  << "): SUCCESS activating payment plan!\n";
2120  otOut << (bRetrieved ? "Success" : "Failed")
2121  << " retrieving intermediary files for account.\n";
2122  }
2123  return nInterpretReply;
2124  }
2125  }
2126  return -1;
2127 }
static EXPORT std::string Instrmnt_GetSenderAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:851
static EXPORT std::string ConfirmPaymentPlan(const std::string &SERVER_ID, const std::string &SENDER_USER_ID, const std::string &SENDER_ACCT_ID, const std::string &RECIPIENT_USER_ID, const std::string &PAYMENT_PLAN)
Definition: OTAPI.cpp:1108
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Instrmnt_GetSenderUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:845
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string deposit_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_PAYMENT_PLAN)
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_confirm_smart_contract ( std::string &  strSmartContract,
int32_t  nIndex 
)
static

Definition at line 2154 of file ot_commands_ot.cpp.

2156 {
2157  string strLocation = "details_confirm_smart_contract";
2158 
2159  int32_t nPartyCount = OTAPI_Wrap::Smart_GetPartyCount(strSmartContract);
2160 
2161  if (nPartyCount <= 0) {
2162  otOut << "Failed trying to confirm a smart contract: there are "
2163  "apparently no PARTIES to this contract!\n";
2164  return -1;
2165  }
2166 
2167  // We don't need MyAcct except when actually ACTIVATING the smart contract
2168  // on the server.
2169  // This variable might get set later to MyAcct, if it matches one of the
2170  // accounts being
2171  // confirmed. (Meaning if this variable is set by the time we reach the
2172  // bottom, then we
2173  // can use it for activation, if/when needed.)
2174  string strMyAcctID = "";
2175  string strMyAcctAgentName = "";
2176 
2177  string strServerID = "";
2178  string strNymID = "";
2179 
2180  map<string, string> map_ID;
2181  map<string, string> map_agent;
2182 
2183  // By this point we know it's a smart contract, and there is at least
2184  // one party that is still unconfirmed on this contract.
2185  // Therefore let's loop through the parties and display the
2186  // unconfirmed ones.
2187  if (show_unconfirmed_parties(strSmartContract, nPartyCount)) {
2188 
2189  // By this point I know that nUnconfirmedPartyCount is larger than 0.
2190  // Therefore we displayed the unconfirmed ones...
2191  // Let's ask the user to choose one to confirm as....
2192  otOut << "\n\nWhich party are you? Enter the number, from the list "
2193  "above: ";
2194 
2195  string strPartyIndex = OT_CLI_ReadLine();
2196 
2197  if (VerifyStringVal(strPartyIndex)) {
2198  int32_t nCurrentParty = std::stol(strPartyIndex);
2199 
2200  if (nCurrentParty >= 0 && nCurrentParty < nPartyCount) {
2201  string strPartyName = OTAPI_Wrap::Smart_GetPartyByIndex(
2202  strSmartContract, nCurrentParty);
2203 
2204  if (!VerifyStringVal(strPartyName)) {
2205  otOut << "Error: Unable to retrieve smart contract party's "
2206  "name at index: " << nCurrentParty << "\n";
2207  return -1;
2208  }
2209 
2210  if (OTAPI_Wrap::Smart_IsPartyConfirmed(strSmartContract,
2211  strPartyName)) {
2212  otOut << "Failure: the party at that index is _already_ "
2213  "confirmed.\n";
2214  return -1;
2215  }
2216 
2217  // At this point we know it's a valid index for an unconfirmed
2218  // party.
2219  // And we know that strPartyName is the party's name.
2220  //
2221  // So how many accounts does strPartyName have? We must confirm
2222  // those, too.
2223  int32_t nAccountCount = OTAPI_Wrap::Party_GetAcctCount(
2224  strSmartContract, strPartyName);
2225 
2226  if (nAccountCount < 0) {
2227  otOut
2228  << "Error: Party '" << strPartyName
2229  << "' has a bad value for number of asset accounts.\n";
2230  return -1;
2231  }
2232 
2233  // Confirm the accounts.
2234  if (nAccountCount > 0) {
2235  // In the loop, if we have to devise the serverID, we store
2236  // it in this var so we don't devise twice.
2237  string strFoundServerID = "";
2238  string strFoundMyNymID = "";
2239  int32_t nCurrentAcctCount = nAccountCount;
2240 
2241  while (nCurrentAcctCount > 0) {
2242  otOut << "\n";
2243  stat_partyaccounts(strSmartContract, strPartyName, 2);
2244 
2245  otOut << "\n There are " << nCurrentAcctCount
2246  << " asset accounts remaining to be "
2247  "confirmed.\nEnter the index for an "
2248  "UNconfirmed account: ";
2249 
2250  string strAcctIndex = OT_CLI_ReadLine();
2251 
2252  if (!VerifyStringVal(strAcctIndex)) {
2253  return -1;
2254  }
2255 
2256  int32_t nAcctIndex = std::stol(strAcctIndex);
2257 
2258  if (nAcctIndex < 0) {
2259  otOut << "Error: Bad Index: " << strAcctIndex
2260  << "\n";
2261  return -1;
2262  }
2263 
2264  string strAcctName =
2266  strSmartContract, strPartyName, nAcctIndex);
2267 
2268  if (!VerifyStringVal(strAcctName)) {
2269  otOut << "Error: Unable to retrieve account name "
2270  "at index " << strAcctIndex
2271  << " for Party: " << strPartyName << "\n";
2272  return -1;
2273  }
2274 
2275  bool bAlreadyThere = false;
2276 
2277  for (auto x = map_ID.begin(); x != map_ID.end(); ++x) {
2278  if (x->first == strAcctName) {
2279  bAlreadyThere = true;
2280  }
2281  }
2282 
2283  string strAcctID = OTAPI_Wrap::Party_GetAcctID(
2284  strSmartContract, strPartyName, strAcctName);
2285 
2286  if (bAlreadyThere || VerifyStringVal(strAcctID)) {
2287  otOut << "\nSorry, but the account at index "
2288  << strAcctIndex
2289  << " is already confirmed with account ID: "
2290  << strAcctID
2291  << " \nYou are just going to have to pick a "
2292  "different account.\n";
2293  }
2294  else {
2295  // The account is NOT already confirmed (so we can
2296  // confirm it, once we select the Acct ID to use.)
2297  string strServerOnContract =
2299  strSmartContract);
2300  bool bServerOnContract =
2301  VerifyStringVal(strServerOnContract);
2302 
2303  // Now we need to ascertain the server and Nym ID...
2304 
2305  // The instrument was selected from the payments
2306  // inbox at a given index.
2307  if (-1 != nIndex) {
2308  strServerID = Server;
2309  strNymID = MyNym;
2310 
2311  // If there's a server listed on the contract
2312  // (there may not be, if this is the FIRST
2313  // confirmation) AND if that Server ID doesn't
2314  // match the one passed in on the command
2315  // line...
2316  if (bServerOnContract &&
2317  (strServerID != strServerOnContract)) {
2318  string strServerName =
2320  strServerOnContract);
2321  if (!VerifyStringVal(strServerName)) {
2322  strServerName = "";
2323  }
2324  otOut << "The server ID on the smart "
2325  "contract, " << strServerOnContract
2326  << " (" << strServerName
2327  << ") doesn't match the server "
2328  "selected at the command line "
2329  "with the --server option.\n";
2330  return -1;
2331  }
2332  }
2333  else // the instrument was pasted in.
2334  {
2335  if (bServerOnContract) {
2336  strServerID = strServerOnContract;
2337  }
2338  else if (VerifyExists("Server", false)) {
2339  strServerID = Server;
2340  }
2341  else if (VerifyStringVal(strFoundServerID)) {
2342  strServerID = strFoundServerID;
2343  }
2344  else {
2345  // There's no server on the contract, AND
2346  // there's no server chosen at the
2347  // command line.
2348  int32_t nServerCount =
2350 
2351  if (nServerCount < 1) {
2352  otOut << "Sorry, there aren't any "
2353  "server contracts in this "
2354  "wallet. Try 'opentxs "
2355  "addserver'\n";
2356  return -1;
2357  }
2358 
2360 
2361  otOut << "Paste a server ID: ";
2362 
2363  string strServerIDInput = OT_CLI_ReadLine();
2364 
2365  if (!VerifyStringVal(strServerIDInput)) {
2366  return -1;
2367  }
2368 
2369  strServerID = strServerIDInput;
2370  strFoundServerID = strServerIDInput;
2371  }
2372 
2373  if (VerifyExists("MyNym", false)) {
2374  strNymID = MyNym;
2375  }
2376  else if (VerifyStringVal(strFoundMyNymID)) {
2377  strNymID = strFoundMyNymID;
2378  }
2379  else {
2380  int32_t nNymCount =
2382 
2383  if (nNymCount < 1) {
2384  otOut << "There are apparently no Nyms "
2385  "in this wallet. Try 'opentxs "
2386  "newnym'\n";
2387  return -1;
2388  }
2389  while (true) {
2390  cout << "------------------------------"
2391  "------------------------------"
2392  "------\n";
2393  cout << " ** NYMS (filtered by "
2394  "serverID: " << strServerID
2395  << "): \n\n";
2396 
2397  bool bFoundANym = false;
2398 
2399  for (int32_t i = 0; i < nNymCount;
2400  ++i) {
2401  string strIndex = std::to_string(i);
2402  string strLoopNymID =
2404 
2405  if (OTAPI_Wrap::
2406  IsNym_RegisteredAtServer(
2407  strLoopNymID,
2408  strServerID)) {
2409  bFoundANym = true;
2410  string strName =
2412  strLoopNymID);
2413  otOut << strIndex << ": "
2414  << strLoopNymID
2415  << " --- " << strName
2416  << "\n";
2417  }
2418  }
2419 
2420  if (!bFoundANym) {
2421  otOut
2422  << "Unfortunately, didn't find "
2423  "ANY Nyms registered at "
2424  "server: " << strServerID
2425  << "\n";
2426  return -1;
2427  }
2428 
2429  otOut << "\n Select a Nym by index: ";
2430 
2431  string strNymIndex = OT_CLI_ReadLine();
2432 
2433  if (!VerifyStringVal(strNymIndex)) {
2434  return -1;
2435  }
2436 
2437  int32_t nNymIndex =
2438  std::stol(strNymIndex);
2439  if (nNymIndex < 0) {
2440  otOut
2441  << "Bad index: " << strNymIndex
2442  << "\n";
2443  return -1;
2444  }
2445 
2446  string strTempNymID =
2447  OTAPI_Wrap::GetNym_ID(nNymIndex);
2448 
2449  if (!VerifyStringVal(strTempNymID)) {
2450  otOut << "Error retrieving NymID "
2451  "from wallet at index: "
2452  << strNymIndex << "\n";
2453  return -1;
2454  }
2455 
2456  if (OTAPI_Wrap::
2457  IsNym_RegisteredAtServer(
2458  strTempNymID,
2459  strServerID)) {
2460  strNymID = strTempNymID;
2461  strFoundMyNymID = strTempNymID;
2462  break;
2463  }
2464  else {
2465  otOut << "Sorry, that Nym isn't "
2466  "registered at server: "
2467  << strServerID
2468  << "\nPlease choose another "
2469  "Nym\n";
2470  }
2471  }
2472  }
2473  }
2474 
2475  // By this point, we definitely have strServerID and
2476  // strNymID
2477 
2478  // Loop through all the accounts for that
2479  // Server/Nym, display them, allow the user to
2480  // choose one and then store it in a list somewhere
2481  // for the actual confirmation.
2482  // (Which we will do only after ALL accounts have
2483  // been selected.) We will also make sure
2484  // to prevent from selecting an account that already
2485  // appears on that list.
2486  //
2487  // Also, when we actually add an Acct ID to the
2488  // list, we need to decrement nCurrentAcctCount,
2489  // so that we are finished once all the accounts
2490  // from the smart contract template have had
2491  // actual acct IDs selected for each.
2492  string strTemplateAssetID =
2494  strSmartContract, strPartyName,
2495  strAcctName);
2496  bool bFoundTemplateAssetID =
2497  VerifyStringVal(strTemplateAssetID);
2498 
2499  bool bFoundAccounts = false;
2500  int32_t nCountAcctsWallet =
2502 
2503  otOut << "\nAccounts by index (filtered by "
2504  "serverID and nymID):\n\n";
2505 
2506  for (int32_t i = 0; i < nCountAcctsWallet; ++i) {
2507  string strWalletAcctID =
2509  if (!VerifyStringVal(strWalletAcctID)) {
2510  otOut << "Error reading account ID based "
2511  "on index: " << i << "\n";
2512  return -1;
2513  }
2514 
2515  string strAcctServerID =
2517  strWalletAcctID);
2518  string strAcctNymID =
2520  strWalletAcctID);
2521  string strAcctAssetID =
2523  strWalletAcctID);
2524 
2525  bool bAlreadyOnTheMap = false;
2526 
2527  for (auto x = map_ID.begin(); x != map_ID.end();
2528  ++x) {
2529  if (x->second == strWalletAcctID) {
2530  bAlreadyOnTheMap = true;
2531  }
2532  }
2533 
2534  if ((strServerID == strAcctServerID) &&
2535  (strNymID == strAcctNymID)) {
2536  // If the smart contract doesn't specify the
2537  // asset type ID of the account, or if
2538  // it DOES specify, AND they match, then
2539  // it's a viable choice. Display it.
2540  if (!bFoundTemplateAssetID ||
2541  (bFoundTemplateAssetID &&
2542  (strTemplateAssetID ==
2543  strAcctAssetID))) {
2544  // DO NOT display any accounts that have
2545  // already been selected! (Search the
2546  // temp map where we've been stashing
2547  // them.)
2548  if (!bAlreadyOnTheMap) {
2549  bFoundAccounts = true;
2550  string strAccountName = OTAPI_Wrap::
2552  strWalletAcctID);
2553  if (!VerifyStringVal(
2554  strAccountName)) {
2555  strAccountName = "";
2556  }
2557  otOut << i << " : "
2558  << strWalletAcctID << " ("
2559  << strAccountName << ")\n";
2560  }
2561  }
2562  }
2563  }
2564 
2565  if (!bFoundAccounts) {
2566  otOut << "Unfortunately, looks like there are "
2567  "no accounts matching the specified "
2568  "Nym (" << strNymID << ") and Server ("
2569  << strServerID
2570  << ")\nTry: opentxs newaccount --mynym "
2571  << strNymID << " --server " << strServerID
2572  << " \n";
2573  return -1;
2574  }
2575 
2576  otOut << "\nChoose an account by index (for '"
2577  << strAcctName << "'): ";
2578 
2579  string strSelectedAcctIndex = OT_CLI_ReadLine();
2580 
2581  if (!VerifyStringVal(strSelectedAcctIndex)) {
2582  return -1;
2583  }
2584 
2585  int32_t nSelectedAcctIndex =
2586  std::stol(strSelectedAcctIndex);
2587 
2588  if (nSelectedAcctIndex < 0 ||
2589  nSelectedAcctIndex >= nCountAcctsWallet) {
2590  otOut << "Bad index: " << strSelectedAcctIndex
2591  << "\n";
2592  return -1;
2593  }
2594 
2595  string strWalletAcctID =
2597  nSelectedAcctIndex);
2598  if (!VerifyStringVal(strWalletAcctID)) {
2599  otOut << "Error reading account ID based on "
2600  "index: " << nSelectedAcctIndex
2601  << "\n";
2602  return -1;
2603  }
2604 
2605  string strAcctServerID =
2607  strWalletAcctID);
2608  string strAcctNymID =
2610  strWalletAcctID);
2611  string strAcctAssetID =
2613  strWalletAcctID);
2614 
2615  if ((strServerID == strAcctServerID) &&
2616  (strNymID == strAcctNymID)) {
2617  // If the smart contract doesn't specify the
2618  // asset type ID of the account, or if
2619  // it DOES specify, AND they match, then it's a
2620  // viable choice. Allow it.
2621  if (!bFoundTemplateAssetID ||
2622  (bFoundTemplateAssetID &&
2623  (strTemplateAssetID == strAcctAssetID))) {
2624 
2625  bool bAlreadyOnIt = false;
2626 
2627  for (auto x = map_ID.begin();
2628  x != map_ID.end(); ++x) {
2629  if (x->second == strWalletAcctID) {
2630  bAlreadyOnIt = true;
2631  }
2632  }
2633 
2634  if (bAlreadyOnIt) {
2635  otOut << "Sorry, you already selected "
2636  "this account. Choose "
2637  "another.\n";
2638  }
2639  else {
2640  // strWalletAcctID has been selected for
2641  // strPartyName's account, strAcctName.
2642  // Add these to a map or whatever, to
2643  // save them until this loop is
2644  // complete.
2645 
2646  string strAgentName =
2648  strSmartContract, strPartyName,
2649  strAcctName);
2650 
2651  if (!VerifyStringVal(strAgentName)) {
2652  otOut << "\n";
2653 
2654  if (stat_partyagents(
2655  strSmartContract,
2656  strPartyName, 3)) {
2657  otOut << "\n (This choice is "
2658  "arbitrary, but you "
2659  "must pick "
2660  "one.)\nEnter the "
2661  "index for an agent, "
2662  "to have authority "
2663  "over that account: ";
2664 
2665  string strAgentIndex =
2666  OT_CLI_ReadLine();
2667 
2668  if (!VerifyStringVal(
2669  strAgentIndex)) {
2670  return -1;
2671  }
2672 
2673  int32_t nAgentIndex =
2674  std::stol(strAgentIndex);
2675 
2676  if (nAgentIndex < 0) {
2677  otOut
2678  << "Error: Bad Index: "
2679  << strAgentIndex
2680  << "\n";
2681  return -1;
2682  }
2683 
2684  strAgentName = OTAPI_Wrap::
2686  strSmartContract,
2687  strPartyName,
2688  nAgentIndex);
2689 
2690  if (!VerifyStringVal(
2691  strAgentName)) {
2692  otOut << "Error: Unable to "
2693  "retrieve agent "
2694  "name at index "
2695  << strAgentIndex
2696  << " for Party: "
2697  << strPartyName
2698  << "\n";
2699  return -1;
2700  }
2701 
2702  }
2703  else {
2704  otOut
2705  << "Failed finding the "
2706  "agent's name for "
2707  "party: " << strPartyName
2708  << " Account: "
2709  << strAcctName
2710  << " \n And then failed "
2711  "finding any agents on "
2712  "this smart contract at "
2713  "ALL.\n";
2714  return -1;
2715  }
2716  }
2717 
2718  map_ID[strAcctName] = strWalletAcctID;
2719  map_agent[strAcctName] = strAgentName;
2720 
2721  nCurrentAcctCount -= 1;
2722  }
2723  }
2724  }
2725  }
2726  }
2727 
2728  for (auto x = map_ID.begin(); x != map_ID.end(); ++x) {
2729  int32_t numCountNeeded =
2731  strSmartContract, map_agent[x->first]) +
2732  1;
2733 
2735  numCountNeeded, strServerID, strNymID)) {
2736  otOut << "\n** Sorry -- Nym (" << strNymID
2737  << ") doesn't have enough transaction "
2738  "numbers to confirm this smart contract. "
2739  "Come back when you have more.\n";
2740  return -1;
2741  }
2742  }
2743 
2744  // CONFIRM THE ACCOUNTS HERE
2745  //
2746  // By this point we KNOW we have enough transaction numbers
2747  //
2748  // Note: Any failure below this point needs to harvest back
2749  // ALL transaction numbers.
2750  // Because we haven't even TRIED to activate it, therefore
2751  // ALL numbers on the contract
2752  // are still good (even the opening number.)
2753  //
2754  // Whereas after a failed activation, we'd need to harvest
2755  // only the closing numbers, and
2756  // not the opening numbers. But in here, this is
2757  // confirmation, not activation.
2758  for (auto x = map_ID.begin(); x != map_ID.end(); ++x) {
2759  // Here we check to see if MyAcct exists -- if so we
2760  // compare it to the current acctID
2761  // and if they match, we set strMyAcctID. Later on,
2762  // if/when activating, we can just use
2763  // strMyAcctID to activate. (Otherwise we will have to
2764  // pick one from the confirmed accounts.)
2765  if (!VerifyStringVal(strMyAcctID) &&
2766  VerifyExists("MyAcct", false) &&
2767  (MyAcct == x->second)) {
2768  strMyAcctID = MyAcct;
2769  strMyAcctAgentName = map_agent[x->first];
2770  }
2771 
2772  // CONFIRM A THEORETICAL ACCT BY GIVING IT A REAL ACCT
2773  // ID.
2774  string strTempSmart =
2776  strSmartContract, strNymID, strPartyName,
2777  x->first, map_agent[x->first], x->second);
2778  if (VerifyStringVal(strTempSmart)) {
2779  strSmartContract = strTempSmart;
2780  }
2781  else {
2782  otOut << "Failure while calling "
2783  "OT_API_SmartContract_ConfirmAccount. "
2784  "Acct Name: " << x->first
2785  << " Agent Name: " << map_agent[x->first]
2786  << " Acct ID: " << x->second << " \n";
2787  int32_t nHarvested =
2789  strSmartContract, strNymID, false, false,
2790  false, false, false);
2791  otOut << strLocation
2792  << ": OT_API_Msg_HarvestTransactionNumbers: "
2793  << nHarvested << "\n";
2794  return -1;
2795  }
2796  }
2797 
2798  } // if (nCurrentAcctCount > 0)
2799 
2800  // CONFIRM THE NYM HERE.
2801  //
2802  // NOTE: confirming the Party will drop a copy into the
2803  // outpayments box.
2804  // After that, if you are not the last party, you will send it
2805  // on to
2806  // the next party. This will also drop it into the outpayments
2807  // box, but
2808  // when that happens, it will automatically first remove the
2809  // prior
2810  // one that had been dropped. This way there is only one copy in
2811  // the outbox, not two.
2812  //
2813  // If you ARE the last party, then we will activate it here, and
2814  // when the server reply is received, it will be removed from
2815  // the
2816  // outbox and moved to the record box.
2817  //
2818  // Also, whether it succeeds or fails activation, either way, a
2819  // notice
2820  // will be dropped to all the parties, informing them of this
2821  // fact.
2822  // The activating party will ignore this, since he already
2823  // processes
2824  // the server reply directly when he receives it. (And there's a
2825  // copy of
2826  // that in his nymbox to make SURE he receives it, so he
2827  // DEFINITELY
2828  // received it already.)
2829  // But each of the other parties will then move the notice from
2830  // their
2831  // outbox to their record box. (And harvest the transaction
2832  // numbers
2833  // accordingly.)
2834  // A party can "reject" a smart contract by activating it
2835  // without signing
2836  // it. That way it will fail activation, and all the other
2837  // parties will get
2838  // the failure notice, and harvest their numbers back as
2839  // appropriate. But if
2840  // he is "rude" and simply discards the contract WITHOUT
2841  // rejecting it, then
2842  // they will never get the failure notice. However, they will
2843  // also never
2844  // get the activation notice, since it was never activated in
2845  // that case, and
2846  // thus they will be safe to harvest their numbers back when it
2847  // expires.
2848  // (A well-designed wallet will do this automatically.)
2849 
2850  string strTempSmart = OTAPI_Wrap::SmartContract_ConfirmParty(
2851  strSmartContract, strPartyName, strNymID);
2852 
2853  if (VerifyStringVal(strTempSmart)) {
2854  strSmartContract = strTempSmart;
2855  }
2856  else {
2857  otOut << "Failure while calling "
2858  "OT_API_SmartContract_ConfirmParty. Party Name: "
2859  << strPartyName << " NymID: " << strNymID << "\n";
2860  int32_t nHarvested =
2862  strSmartContract, strNymID, false, false, false,
2863  false, false);
2864  otOut << strLocation
2865  << ": OT_API_Msg_HarvestTransactionNumbers: "
2866  << nHarvested << "\n";
2867  return -1;
2868  }
2869 
2870  // If you are the last party to sign, then ACTIVATE THE SMART
2871  // CONTRACT.
2872 
2873  // NOTE: No matter which party you are (perhaps you are the
2874  // middle one), when you confirm
2875  // the contract, you will send it on to the NEXT UNCONFIRMED
2876  // ONE. This means you don't know
2877  // which party it will be, since all the unconfirmed parties
2878  // have no NymID (yet.) Rather,
2879  // it's YOUR problem to provide the NymID you're sending the
2880  // contract on to. And then it's HIS
2881  // problem to decide which party he will sign on as. (Unless you
2882  // are the LAST PARTY to confirm,
2883  // in which case YOU are the activator.)
2885  strSmartContract)) {
2886  // The logic: If all the parties are confirmed, then just
2887  // activate the thing. I must be the activator.
2888  // We need the ACCT_ID that we're using to activate it with,
2889  // and we need the AGENT NAME for that account.
2890  // strMyAcctID and strMyAcctAgentName might ALREADY be set
2891  // -- otherwise we need to set those.
2892  if (!VerifyStringVal(strMyAcctID) ||
2893  !VerifyStringVal(strMyAcctAgentName)) {
2894  // We can't just use ANY account ID, but we must use one
2895  // that is listed as one of the accounts for
2896  // the party activating the contract. So we have to
2897  // display those accounts, and the user must choose
2898  // which one it's going to be. From there we can get the
2899  // account ID and the agent name and call
2900  // activate_smart_contract.
2901  stat_partyaccounts(strSmartContract, strPartyName,
2902  2); // nDepth=2
2903 
2904  otOut << "\n\n Enter the index for the account you'll "
2905  "use to ACTIVATE the smart contract: ";
2906 
2907  string strAcctIndex = OT_CLI_ReadLine();
2908 
2909  if (!VerifyStringVal(strAcctIndex)) {
2910  int32_t nHarvested =
2912  strSmartContract, strNymID, false, false,
2913  false, false, false);
2914  otOut << strLocation
2915  << ": OT_API_Msg_HarvestTransactionNumbers: "
2916  << nHarvested << "\n";
2917  return -1;
2918  }
2919 
2920  int32_t nAcctIndex = std::stol(strAcctIndex);
2921 
2922  if (nAcctIndex < 0 || nAcctIndex >= nAccountCount) {
2923  otOut << "Error: Bad Index: " << strAcctIndex
2924  << " (Acceptable values are 0 through "
2925  << (nAccountCount - 1) << ")\n";
2926  int32_t nHarvested =
2928  strSmartContract, strNymID, false, false,
2929  false, false, false);
2930  otOut << strLocation
2931  << ": OT_API_Msg_HarvestTransactionNumbers: "
2932  << nHarvested << "\n";
2933  return -1;
2934  }
2935 
2936  string strAcctName =
2938  strSmartContract, strPartyName, nAcctIndex);
2939 
2940  if (!VerifyStringVal(strAcctName)) {
2941  otOut << "Error: Unable to retrieve account name "
2942  "at index " << strAcctIndex
2943  << " for Party: " << strPartyName << "\n";
2944  int32_t nHarvested =
2946  strSmartContract, strNymID, false, false,
2947  false, false, false);
2948  otOut << strLocation
2949  << ": OT_API_Msg_HarvestTransactionNumbers: "
2950  << nHarvested << "\n";
2951  return -1;
2952  }
2953 
2954  string strAcctID = OTAPI_Wrap::Party_GetAcctID(
2955  strSmartContract, strPartyName, strAcctName);
2956 
2957  if (!VerifyStringVal(strAcctID)) {
2958  otOut << "Strange: the account at index "
2959  << strAcctIndex
2960  << " is not yet confirmed with any account "
2961  "ID. (Failure.)\n";
2962  int32_t nHarvested =
2964  strSmartContract, strNymID, false, false,
2965  false, false, false);
2966  otOut << strLocation
2967  << ": OT_API_Msg_HarvestTransactionNumbers: "
2968  << nHarvested << "\n";
2969  return -1;
2970  }
2971  strMyAcctID = strAcctID;
2972 
2973  string strAcctAgentName =
2975  strSmartContract, strPartyName, strAcctName);
2976 
2977  if (!VerifyStringVal(strAcctAgentName)) {
2978  otOut << "Strange: the account named: '"
2979  << strAcctName
2980  << "' doesn't seem to have any agent "
2981  "confirmed to it. (Failure.)\n";
2982  int32_t nHarvested =
2984  strSmartContract, strNymID, false, false,
2985  false, false, false);
2986  otOut << strLocation
2987  << ": OT_API_Msg_HarvestTransactionNumbers: "
2988  << nHarvested << "\n";
2989  return -1;
2990  }
2991  strMyAcctAgentName = strAcctAgentName;
2992  }
2993 
2994  // NOTE: Above, you see us harvesting the transaction
2995  // numbers if any error occurs, since we haven't even tried
2996  // to send the instrument yet.
2997  //
2998  // But in this next section, we only want to do that if the
2999  // transaction was definitely not processed by the server.
3000  // (Whether that processing succeeded or failed being a
3001  // separate question.)
3002  string strResponse = MadeEasy::activate_smart_contract(
3003  strServerID, strNymID, strMyAcctID, strMyAcctAgentName,
3004  strSmartContract);
3005  string strAttempt = "activate_smart_contract";
3006  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
3007 
3008  if (-1 == nMessageSuccess) {
3009  // In this case, the server never even SAW the
3010  // transaction, because its enveloping message already
3011  // failed before we even got that far. So we can
3012  // harvest, as though it was never attempted...
3013  otOut << "Message error: " << strAttempt << ".\n";
3014  int32_t nHarvested =
3016  strSmartContract, strNymID, false, false, false,
3017  false, false);
3018  otOut << strLocation
3019  << ": OT_API_Msg_HarvestTransactionNumbers: "
3020  << nHarvested << "\n";
3021  return -1;
3022  }
3023  else if (0 == nMessageSuccess) {
3024  otOut << "Server reply (" << strAttempt
3025  << "): Message failure.\n";
3026  int32_t nHarvested =
3028  strSmartContract, strNymID, false, false, false,
3029  false, false);
3030  otOut << strLocation
3031  << ": OT_API_Msg_HarvestTransactionNumbers: "
3032  << nHarvested << "\n";
3033  return 0;
3034  }
3035  // (else 1: message was processed successfully -- though not
3036  // necessarily the transaction inside it.)
3037 
3038  // BELOW THIS POINT, the transaction has definitely
3039  // processed. It may have succeeded or failed,
3040  // but either way, we don't need to harvest any numbers,
3041  // since OT will internally handle those
3042  // when it processes the server's reply to the transaction
3043  // attempt.
3044  int32_t nInterpretReply = InterpretTransactionMsgReply(
3045  strServerID, strNymID, strMyAcctID, strAttempt,
3046  strResponse);
3047 
3048  if (1 == nInterpretReply) {
3049  bool bRetrieved = MadeEasy::retrieve_account(
3050  strServerID, strNymID, strMyAcctID, true);
3051 
3052  otOut << "\nServer response (" << strAttempt
3053  << "): SUCCESS activating smart contract!\n";
3054  otOut
3055  << (bRetrieved ? "Success" : "Failed")
3056  << " retrieving intermediary files for account.\n";
3057  }
3058  return nInterpretReply;
3059  }
3060  else // SEND INSTRUMENT TO NEXT PARTY.
3061  {
3062  // But if all the parties are NOT confirmed, then we need to
3063  // send it to the next guy. In that case:
3064  // If HisNym is provided, and it's different than strNymID,
3065  // then use it. He's the next receipient.
3066  // If HisNym is NOT provided, then display the list of
3067  // NymIDs, and allow the user to paste one. We can
3068  // probably select him based on abbreviated ID or Name as
3069  // well (I think there's an API call for that...)
3070  string strHisNymID = "";
3071 
3072  if (VerifyExists("HisNym", false)) {
3073  strHisNymID = HisNym;
3074  }
3075 
3076  // If strHisNymID doesn't exist, or it's the same as
3077  // strNymID, then ask the user to select
3078  // a NymID for the recipient.
3079  if (!VerifyStringVal(strHisNymID) ||
3080  (strHisNymID == strNymID)) {
3082 
3083  otOut << "\nOnce you confirm this contract, then we "
3084  "need to send it on to the\nnext party so he "
3085  "can confirm it, too.\n\nPlease PASTE a "
3086  "recipient Nym ID (the next party): ";
3087  string strRecipientNymID = OT_CLI_ReadLine();
3088  if (!VerifyStringVal(strRecipientNymID)) {
3089  int32_t nHarvested =
3091  strSmartContract, strNymID, false, false,
3092  false, false, false);
3093  otOut << strLocation
3094  << ": OT_API_Msg_HarvestTransactionNumbers: "
3095  << nHarvested << "\n";
3096  return -1;
3097  }
3098 
3099  string strHisNymParam = strRecipientNymID;
3100 
3101  // IF we are able to resolve the HisNymId from a
3102  // partial, then we
3103  // replace the partial with the full version.
3104  // (Otherwise we assume it's already a full ID and we
3105  // don't mess with it.)
3106  string strHisNymFromPartial =
3108  strRecipientNymID);
3109 
3110  if (VerifyStringVal(strHisNymFromPartial)) {
3111  strHisNymParam = strHisNymFromPartial;
3112  }
3113 
3114  strHisNymID = strHisNymParam;
3115 
3116  if (strHisNymID == strNymID) {
3117  otOut << "\nSorry, but YOU cannot simultaneously "
3118  "be the SENDER _and_ the RECIPIENT. "
3119  "Choose another nym for one or the "
3120  "other.\n";
3121  int32_t nHarvested =
3123  strSmartContract, strNymID, false, false,
3124  false, false, false);
3125  otOut << strLocation
3126  << ": OT_API_Msg_HarvestTransactionNumbers: "
3127  << nHarvested << "\n";
3128  return -1;
3129  }
3130  }
3131 
3132  string strResponse = MadeEasy::send_user_payment(
3133  strServerID, strNymID, strHisNymID, strSmartContract);
3134 
3135  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
3136 
3137  if (1 != nMessageSuccess) {
3138  otOut << "\nFor whatever reason, our attempt to send "
3139  "the instrument on to the next user has "
3140  "failed.\n";
3141  int32_t nHarvested =
3143  strSmartContract, strNymID, false, false, false,
3144  false, false);
3145  otOut << strLocation
3146  << ": OT_API_Msg_HarvestTransactionNumbers: "
3147  << nHarvested << "\n";
3148  }
3149  else // Success. (Remove the payment instrument we just
3150  // successfully sent, from our payments inbox.)
3151  {
3152  // In the case of smart contracts, it might be sent on
3153  // to a chain of 2 or 3 users,
3154  // before finally being activated by the last one in the
3155  // chain. All of the users in
3156  // the chain (except the first one) will thus have a
3157  // copy of the smart contract in
3158  // their payments inbox AND outbox.
3159  //
3160  // But once the smart contract has successfully been
3161  // sent on to the next user, and
3162  // thus a copy of it is in my outbox already, then there
3163  // is definitely no reason for
3164  // a copy of it to stay in my inbox as well. Might as
3165  // well remove that copy.
3166  //
3167  // We can't really expect to remove the payments inbox
3168  // copy inside OT itself, when we
3169  // receive the server's atSendUserInstrument reply
3170  // message, without opening up the
3171  // (encrypted) contents. (Although that would actually
3172  // be ideal, since it would cover
3173  // all cases included dropped messages...) But we CAN
3174  // easily remove it RIGHT HERE.
3175  // Perhaps in the future I WILL move this code to the
3176  // atSendUserInstrument reply processing,
3177  // but that will require it to be encrypted to my own
3178  // key as well as the recipient's,
3179  // which we already do for sending cash, but which we up
3180  // until now have not done for
3181  // the other instruments. So perhaps we'll start doing
3182  // that sometime in the future, and
3183  // then move this code.
3184  //
3185  // In the meantime, this is good enough.
3186 
3187  otOut << "Success sending the agreement on to the next "
3188  "party.\n";
3189 
3190  if (-1 != nIndex) {
3191  OTAPI_Wrap::RecordPayment(strServerID, strNymID,
3192  true, nIndex, false);
3193  }
3194  }
3195  return nMessageSuccess;
3196  }
3197  }
3198  }
3199  }
3200  // else there aren't any unconfirmed parties, and it already displayed an
3201  // error message related to that.
3202 
3203  return -1;
3204 }
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:924
static EXPORT std::string Party_GetAcctAssetID(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1388
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT int32_t GetAccountCount()
Definition: OTAPI.cpp:526
static EXPORT std::string Wallet_GetNymIDFromPartial(const std::string &PARTIAL_ID)
Attempts to find a full ID in the wallet, based on a partial of the same.
Definition: OTAPI.cpp:619
EXPORT static OT_COMMANDS_OT int32_t mainShowNyms()
static EXPORT std::string GetNym_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:643
std::string to_string(const T &t)
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
static EXPORT std::string Party_GetAgentNameByIndex(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const int32_t &nIndex)
Definition: OTAPI.cpp:1402
static EXPORT int32_t GetServerCount()
Definition: OTAPI.cpp:516
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
std::string Server
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool RecordPayment(const std::string &SERVER_ID, const std::string &USER_ID, const bool &bIsInbox, const int32_t &nIndex, const bool &bSaveCopy)
Definition: OTAPI.cpp:1591
static EXPORT std::string Party_GetAcctNameByIndex(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const int32_t &nIndex)
Definition: OTAPI.cpp:1374
static EXPORT bool Smart_IsPartyConfirmed(const std::string &THE_CONTRACT, const std::string &PARTY_NAME)
Definition: OTAPI.cpp:1218
static EXPORT bool Smart_AreAllPartiesConfirmed(const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1213
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT bool stat_partyaccounts(const std::string &strSmartContract, const std::string &strPartyName, int32_t nDepth)
static EXPORT int32_t GetNymCount()
Definition: OTAPI.cpp:511
static EXPORT int32_t SmartContract_CountNumsNeeded(const std::string &THE_CONTRACT, const std::string &AGENT_NAME)
Definition: OTAPI.cpp:1190
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string HisNym
static EXPORT std::string GetAccountWallet_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:919
static EXPORT std::string Party_GetAcctID(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1381
EXPORT static OT_COMMANDS_OT bool stat_partyagents(const std::string &strSmartContract, const std::string &strPartyName, int32_t nDepth)
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
static EXPORT std::string Party_GetAcctAgentName(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1395
static EXPORT std::string SmartContract_ConfirmParty(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &NYM_ID)
Definition: OTAPI.cpp:1206
static EXPORT std::string Smart_GetPartyByIndex(const std::string &THE_CONTRACT, const int32_t &nIndex)
Definition: OTAPI.cpp:1234
static EXPORT std::string SmartContract_ConfirmAccount(const std::string &THE_CONTRACT, const std::string &SIGNER_NYM_ID, const std::string &PARTY_NAME, const std::string &ACCT_NAME, const std::string &AGENT_NAME, const std::string &ACCT_ID)
Definition: OTAPI.cpp:1196
std::string MyNym
EXPORT static OT_COMMANDS_OT bool show_unconfirmed_parties(const std::string &strSmartContract, int32_t &nPartyCount)
static EXPORT int32_t Party_GetAcctCount(const std::string &THE_CONTRACT, const std::string &PARTY_NAME)
Definition: OTAPI.cpp:1356
EXPORT static OT_MADE_EASY_OT std::string activate_smart_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &AGENT_NAME, const std::string &THE_SMART_CONTRACT)
EXPORT static OT_COMMANDS_OT int32_t mainShowServers()
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
static EXPORT int32_t Smart_GetPartyCount(const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1224
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_create_nym ( int32_t  nKeybits,
const std::string &  strName,
const std::string &  strSourceForNymID,
const std::string &  strAltLocation 
)
static

Definition at line 5504 of file ot_commands_ot.cpp.

5507 {
5508  string strNymID =
5509  MadeEasy::create_nym(nKeybits, strSourceForNymID, strAltLocation);
5510 
5511  if (!VerifyStringVal(strNymID)) {
5512  otOut << "details_create_nym: Failed in "
5513  "OT_ME::create_nym(keybits == " << nKeybits << ")\n";
5514  return -1;
5515  }
5516  otOut << "Success creating! " << nKeybits << " keybits, new ID: ";
5517  cout << strNymID << "\n";
5518  otOut << "\n";
5519 
5520  bool bSetName = OTAPI_Wrap::SetNym_Name(strNymID, strNymID, strName);
5521  if (!bSetName) {
5522  otOut << "Failed in OT_API_SetNym_Name(name == " << strName << ")\n";
5523  return -1;
5524  }
5525 
5526  otOut << "Success setting name to: " << strName << "\n\n";
5527  return 1;
5528 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string create_nym(int32_t nKeybits, const std::string &strNymIDSource, const std::string &strAltLocation)
static EXPORT bool SetNym_Name(const std::string &NYM_ID, const std::string &SIGNER_NYM_ID, const std::string &NYM_NEW_NAME)
Definition: OTAPI.cpp:869
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_create_offer ( const std::string &  strScale,
const std::string &  strMinIncrement,
const std::string &  strQuantity,
const std::string &  strPrice,
bool  bSelling,
const std::string &  strLifespan 
)
static

Definition at line 4666 of file ot_commands_ot.cpp.

4671 {
4672  // NOTE: The top half of this function has nothing to do with placing a new
4673  // offer.
4674  // Instead, as a convenience for knotwork, it first checks to see if there
4675  // are any
4676  // existing offers within certain parameters based on this new one, and
4677  // removes them
4678  // if so. Only then, after that is done, does it actually place the new
4679  // offer.
4680  // (Meaning: most of the code you see here at first is not actually
4681  // necessary for
4682  // placing offers, but was done at the request of a server operator.)
4683  string strLocation = "details_create_offer";
4684 
4685  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
4686  string strMyNymID2 = OTAPI_Wrap::GetAccountWallet_NymID(HisAcct);
4687 
4688  if (!VerifyStringVal(strMyNymID) || !VerifyStringVal(strMyNymID2) ||
4689  (strMyNymID != strMyNymID2)) {
4690  otOut << "You must supply myacct as your asset account, and hisacct as "
4691  "your currency account.\n";
4692  otOut << "Also, both accounts must be owned by the same Nym (you.)\n\n";
4693  return -1;
4694  }
4695 
4696  string strMyServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
4697  string strMyServerID2 = OTAPI_Wrap::GetAccountWallet_ServerID(HisAcct);
4698 
4699  if (!VerifyStringVal(strMyServerID) || !VerifyStringVal(strMyServerID2) ||
4700  (strMyServerID != strMyServerID2)) {
4701  otOut << "Both accounts must be on the same server.\n";
4702  return -1;
4703  }
4704  // Below this point we're safe to use Server.
4705 
4706  // We're about to load up the Nym's market offers so we can see if there are
4707  // any we should cancel before placing this new offer.
4708  //
4709  // Therefore, I'm going to download the Nym's market offers before loading
4710  // them
4711  // up, in case we don't even have the current list of them.
4712 
4713  OT_Command::details_get_nym_market_offers(strMyServerID, strMyNymID);
4714 
4715  /*
4716  me: How about this — when you do "opentxs newoffer" I can alter that
4717  script to automatically cancel any sell offers for a lower amount
4718  than my new buy offer, if they're on the same market at the same scale.
4719  and vice versa. Vice versa meaning, cancel any bid offers for a higher
4720  amount than my new sell offer.
4721 
4722  knotwork: yeah that would work.
4723 
4724  So when placing a buy offer, check all the other offers I already have at
4725  the same scale,
4726  same asset and currency ID. (That is, the same "market" as denoted by
4727  strMapKey in "opentxs showmyoffers")
4728  For each, see if it's a sell offer and if so, if the amount is lower than
4729  the amount on
4730  the new buy offer, then cancel that sell offer from the market. (Because I
4731  don't want to buy-high, sell low.)
4732 
4733  Similarly, if placing a sell offer, then check all the other offers I
4734  already have at the
4735  same scale, same asset and currency ID, (the same "market" as denoted by
4736  strMapKey....) For
4737  each, see if it's a buy offer and if so, if the amount is higher than the
4738  amount of my new
4739  sell offer, then cancel that buy offer from the market. (Because I don't
4740  want some old buy offer
4741  for $10 laying around for the same stock that I'm SELLING for $8! If I dump
4742  100 shares, I'll receive
4743  $800--I don't want my software to automatically turn around and BUY those
4744  same shares again for $1000!
4745  That would be a $200 loss.)
4746 
4747  This is done here:
4748  */
4749 
4750  OTDB::OfferListNym* offerListPtr = loadNymOffers(strMyServerID, strMyNymID);
4751  OTDB::OfferListNym& offerList = *offerListPtr;
4752 
4753  if (!offerListPtr) {
4754  otOut << strLocation << ": Unable to load up a (nym) offerList from "
4755  "local storage. Probably doesn't exist.\n";
4756  }
4757  else {
4758  // LOOP THROUGH THE OFFERS and sort them into a map_of_maps, key is:
4759  // scale-assetID-currencyID
4760  // the value for each key is a sub-map, with the key: transaction ID and
4761  // value: the offer data itself.
4762  int32_t nCount = offerList.GetOfferDataNymCount();
4763  if (nCount > 0) {
4764  MapOfMaps* map_of_maps = convert_offerlist_to_maps(offerList);
4765 
4766  if (nullptr == map_of_maps) {
4767  otOut << strLocation << ": Unable to convert offer list to map "
4768  "of offers. Perhaps it's empty?\n";
4769  }
4770  else {
4771  // find_strange_offers is called for each offer, for this nym,
4772  // as it iterates through the maps. When it's done,
4773  // extra_vals.the_vector
4774  // will contain a vector of all the transaction numbers for
4775  // offers that we
4776  // should cancel, before placing the new offer. (Such as an
4777  // offer to sell for
4778  // 30 clams when our new offer buys for 40...)
4779  the_lambda_struct extra_vals;
4780 
4781  extra_vals.the_asset_acct = MyAcct;
4782  extra_vals.the_currency_acct = HisAcct;
4783  extra_vals.the_scale = strScale;
4784  extra_vals.the_price = strPrice;
4785  extra_vals.bSelling = bSelling;
4786 
4787  int32_t nIterated = iterate_nymoffers_maps(
4788  *map_of_maps, find_strange_offers, extra_vals);
4789 
4790  if (-1 == nIterated) {
4791  otOut << strLocation
4792  << ": Error trying to iterate nym's offers.\n";
4793  return -1;
4794  }
4795 
4796  // Okay -- if there are any offers we need to cancel,
4797  // extra_vals.the_vector now contains
4798  // the transaction number for each one. Let's remove them from
4799  // the market before
4800  // starting up the new offer...
4801 
4802  if (extra_vals.the_vector.size() > 0) {
4803  otOut << strLocation
4804  << ": FYI, about to cancel at least one market "
4805  "offer, before placing the new one, due to price "
4806  "inconsistencies between the two...\n";
4807  }
4808 
4809  for (size_t i = 0; i < extra_vals.the_vector.size(); i++) {
4810  otOut
4811  << strLocation
4812  << ": Canceling market offer with transaction number: "
4813  << extra_vals.the_vector[i] << "\n";
4814 
4815  OT_Command::details_kill_offer(strMyServerID, strMyNymID,
4816  MyAcct,
4817  extra_vals.the_vector[i]);
4818  }
4819  extra_vals.the_vector.clear();
4820  }
4821  }
4822  else {
4823  otOut << strLocation << ": FYI, there don't seem to be any "
4824  "existing offers for this nym, so I won't "
4825  "be erasing any older ones.\n";
4826  }
4827  }
4828 
4829  // OKAY! Now that we've cleaned out any undesirable offers, let's place the
4830  // the offer itself!
4831 
4832  string strResponse = MadeEasy::create_market_offer(
4833  MyAcct, HisAcct, strScale, strMinIncrement, strQuantity, strPrice,
4834  bSelling, strLifespan, "", "0");
4835  string strAttempt = "create_market_offer";
4836  int32_t nInterpretReply = InterpretTransactionMsgReply(
4837  strMyServerID, strMyNymID, MyAcct, strAttempt, strResponse);
4838 
4839  if (1 == nInterpretReply) {
4840  otOut << "Server response (" << strAttempt
4841  << "): SUCCESS placing market offer!\n\n";
4842  }
4843 
4844  return nInterpretReply;
4845 }
EXPORT static OT_MADE_EASY_OT std::string create_market_offer(const std::string &ASSET_ACCT_ID, const std::string &CURRENCY_ACCT_ID, const std::string &scale, const std::string &minIncrement, const std::string &quantity, const std::string &price, bool bSelling, const std::string &strLifespanInSeconds, const std::string &strStopSign, const std::string &strActivationPrice)
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT OT_OTAPI_OT MapOfMaps * convert_offerlist_to_maps(opentxs::OTDB::OfferListNym &offerList)
std::string the_scale
OTLOG_IMPORT OTLogStream otOut
std::string HisAcct
EXPORT OT_OTAPI_OT opentxs::OTDB::OfferListNym * loadNymOffers(const std::string &serverID, const std::string &nymID)
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
std::string the_price
std::string the_asset_acct
EXPORT static OT_COMMANDS_OT std::string details_get_nym_market_offers(const std::string &strServerID, const std::string &strNymID)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::vector< std::string > the_vector
std::string the_currency_acct
EXPORT static OT_COMMANDS_OT int32_t details_kill_offer(const std::string &strServerID, const std::string &strNymID, const std::string &strAcctID, const std::string &strTransNum)
EXPORT OT_OTAPI_OT int32_t find_strange_offers(const opentxs::OTDB::OfferDataNym &offer_data, int32_t nIndex, const MapOfMaps &map_of_maps, const SubMap &sub_map, the_lambda_struct &extra_vals)
std::map< std::string, SubMap * > MapOfMaps
std::string MyAcct
EXPORT OT_OTAPI_OT int32_t iterate_nymoffers_maps(MapOfMaps &map_of_maps, LambdaFunc the_lambda)
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_del_mail ( const std::string &  strMyNymID,
const std::string &  strIndices 
)
static

Definition at line 10643 of file ot_commands_ot.cpp.

10645 {
10646 
10647  int32_t nCount = OTAPI_Wrap::GetNym_MailCount(strMyNymID);
10648  if (0 > nCount) {
10649  otOut << "Error: cannot retrieve mail for Nym: " << strMyNymID << "\n";
10650  return -1;
10651  }
10652 
10653  if (0 == nCount) {
10654  otOut << "\n(Mail box is empty)\n\n";
10655  return 0;
10656  }
10657 
10658  bool bIndices = VerifyStringVal(strIndices);
10659  bool bDeleteAll = false;
10660 
10661  if (bIndices && ("all" == strIndices)) {
10662  bDeleteAll = true;
10663  }
10664 
10665  int32_t nIndicesCount =
10666  (bIndices && !bDeleteAll) ? OTAPI_Wrap::NumList_Count(strIndices) : 0;
10667 
10668  // If we're not deleting ALL, then we must be deleting SPECIFC indices.
10669  // But no specific indices were supplied!
10670  // Therefore, error.
10671  if (!bDeleteAll && (nIndicesCount < 1)) {
10672  otOut << "Problem: You're apparently not deleting \"all\" indices, but "
10673  "neither have you selected SPECIFIC indices.\n Try adding: "
10674  "--args \"indices 4,6,7\" (for deleting the messages at "
10675  "indices 4, 6, and 7, for example.)\n\n";
10676  return -1;
10677  }
10678 
10679  int32_t nReturnVal = 1;
10680 
10681  for (int32_t nIndex = (nCount - 1); nIndex >= 0; --nIndex) {
10682 
10683  // If we're not deleting "all" (i.e. we're deleting specific indices)...
10684  // and the current index doesn't appear on that specified list, then
10685  // continue...
10686  if (!bDeleteAll &&
10687  !OTAPI_Wrap::NumList_VerifyQuery(strIndices,
10688  std::to_string(nIndex))) {
10689  // We skip any indices that the user isn't trying to delete.
10690  // continue // apparently not supported by the language.
10691  }
10692 
10693  // Let's try to remove it...
10694  else if (OTAPI_Wrap::Nym_RemoveMailByIndex(strMyNymID, nIndex)) {
10695  otOut << "Deleted mail at index " << nIndex
10696  << " for nym: " << strMyNymID << " \n";
10697  }
10698  else {
10699  otOut << "Error while trying to delete mail at index " << nIndex
10700  << " for nym: " << strMyNymID << " \n";
10701  nReturnVal = -1;
10702  }
10703  }
10704 
10705  return nReturnVal;
10706 }
std::string to_string(const T &t)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
static EXPORT int32_t GetNym_MailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:688
static EXPORT bool Nym_RemoveMailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:711
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_del_outmail ( const std::string &  strMyNymID,
const std::string &  strIndices 
)
static

Definition at line 10882 of file ot_commands_ot.cpp.

10884 {
10885  int32_t nCount = OTAPI_Wrap::GetNym_OutmailCount(strMyNymID);
10886  if (0 > nCount) {
10887  otOut << "Error: cannot retrieve outmail for Nym: " << strMyNymID
10888  << "\n";
10889  return -1;
10890  }
10891 
10892  if (0 == nCount) {
10893  otOut << "\n(Outmail box is empty)\n\n";
10894  return 0;
10895  }
10896 
10897  bool bIndices = VerifyStringVal(strIndices);
10898  bool bDeleteAll = false;
10899 
10900  if (bIndices && ("all" == strIndices)) {
10901  bDeleteAll = true;
10902  }
10903 
10904  int32_t nIndicesCount =
10905  (bIndices && !bDeleteAll) ? OTAPI_Wrap::NumList_Count(strIndices) : 0;
10906 
10907  // If we're not deleting ALL, then we must be deleting SPECIFC indices.
10908  // But no specific indices were supplied!
10909  // Therefore, error.
10910  if (!bDeleteAll && (nIndicesCount < 1)) {
10911  otOut << "Problem: You're apparently not deleting \"all\" indices, but "
10912  "neither have you selected SPECIFIC indices.\n Try adding: "
10913  "--args \"indices 4,6,7\" (for deleting the outgoing messages "
10914  "at indices 4, 6, and 7, for example.)\n\n";
10915  return -1;
10916  }
10917 
10918  int32_t nReturnVal = 1;
10919 
10920  for (int32_t nIndex = (nCount - 1); nIndex >= 0; --nIndex) {
10921 
10922  // If we're not deleting "all" (i.e. we're deleting specific indices)...
10923  // and the current index doesn't appear on that specified list, then
10924  // continue...
10925  if (!bDeleteAll &&
10926  !OTAPI_Wrap::NumList_VerifyQuery(strIndices,
10927  std::to_string(nIndex))) {
10928  // We skip any indices that the user isn't trying to delete.
10929  // continue // apparently not supported by the language.
10930  }
10931 
10932  // Let's try to remove it...
10933  else if (OTAPI_Wrap::Nym_RemoveOutmailByIndex(strMyNymID, nIndex)) {
10934  otOut << "Deleted outgoing mail at index " << nIndex
10935  << " for nym: " << strMyNymID << " \n";
10936  }
10937  else {
10938  otOut << "Error while trying to delete outgoing mail at index "
10939  << nIndex << " for nym: " << strMyNymID << " \n";
10940  nReturnVal = -1;
10941  }
10942  }
10943 
10944  return nReturnVal;
10945 }
std::string to_string(const T &t)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT bool Nym_RemoveOutmailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:746
static EXPORT int32_t GetNym_OutmailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:723
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_deposit ( const std::string &  strServerID,
const std::string &  strMyAcctID 
)
static

Definition at line 7752 of file ot_commands_ot.cpp.

7754 {
7755  string strInstrument = "";
7756 
7757  string strToNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
7758  if (!VerifyStringVal(strToNymID)) {
7759  otOut
7760  << "\n\nFailure: Unable to find depositor NymID based on account ( "
7761  << strMyAcctID << " ).\nUse: --myacct ACCT_ID\n";
7762  otOut << "The designated asset account must be yours. OT will find the "
7763  "Nym based on the account.\n\n";
7764  return -1;
7765  }
7766 
7767  string strIndices = "";
7768 
7769  if (VerifyExists("Args", false)) {
7770  // You have the OPTION to pass in indices for tokens in your purse, and
7771  // deposit
7772  // will automatically assume "deposit cash" and deposit those tokens.
7773  // You can also specify to deposit ALL tokens in your cash purse.
7774  // Without this extra argument, OT will ask you to paste an instrument,
7775  // and then will dynamically determine its contract type.
7776  strIndices = OT_CLI_GetValueByKey(Args, "indices");
7777  }
7778 
7779  if (VerifyStringVal(strIndices)) {
7780  // Only in the case of cash, it's possible you have some cash in Nym A's
7781  // purse, but
7782  // you want to deposit it into Nym B's account. So we have a "to" Nym
7783  // and a "from" Nym
7784  // even though they will often be the same.
7785  string strFromNymID = "";
7786 
7787  if (VerifyExists("MyNym", false)) {
7788  strFromNymID = MyNym;
7789  }
7790  else {
7791  strFromNymID = strToNymID;
7792  }
7793 
7794  // In this case, strInstrument is blank.
7795  // That's how the callee knows that we're working with the local purse.
7796  // Then strIndices tells him either to use "all" tokens in that purse,
7797  // or
7798  // the selected indices.
7799  return details_deposit_purse(strServerID, strMyAcctID, strFromNymID,
7800  strInstrument, strIndices);
7801  }
7802  else {
7803  otOut << "You can deposit a PURSE (containing cash tokens) or a CHEQUE "
7804  "/ VOUCHER. \n";
7805  otOut << "Paste your financial instrument here, followed by a ~ by "
7806  "itself on a blank line: \n";
7807 
7808  strInstrument = OT_CLI_ReadUntilEOF();
7809 
7810  if (!VerifyStringVal(strInstrument)) {
7811  return -1;
7812  }
7813 
7814  string strType = OTAPI_Wrap::Instrmnt_GetType(strInstrument);
7815 
7816  if (!VerifyStringVal(strType)) {
7817  otOut << "\n\nFailure: Unable to determine instrument type. "
7818  "Expected CHEQUE, VOUCHER, INVOICE, or (cash) PURSE.\n";
7819  return -1;
7820  }
7821 
7822  if ("CHEQUE" == strType) {
7823  return details_deposit_cheque(strServerID, strMyAcctID, strToNymID,
7824  strInstrument, strType);
7825  }
7826  else if ("VOUCHER" == strType) {
7827  return details_deposit_cheque(strServerID, strMyAcctID, strToNymID,
7828  strInstrument, strType);
7829  }
7830  else if ("INVOICE" == strType) {
7831  return details_deposit_cheque(strServerID, strMyAcctID, strToNymID,
7832  strInstrument, strType);
7833  }
7834  else if ("PURSE" == strType) {
7835  return details_deposit_purse(strServerID, strMyAcctID, strToNymID,
7836  strInstrument, "");
7837  }
7838  else {
7839  otOut << "\n\nFailure: Unable to determine instrument type. "
7840  "Expected CHEQUE, VOUCHER, INVOICE, or (cash) PURSE.\n";
7841  return -1;
7842  }
7843  }
7844 
7845  return -1;
7846 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t details_deposit_purse(const std::string &strServerID, const std::string &strMyAcct, const std::string &strFromNymID, const std::string &strInstrument, const std::string &strIndices)
EXPORT static OT_COMMANDS_OT int32_t details_deposit_cheque(const std::string &strServerID, const std::string &strMyAcct, const std::string &strMyNymID, const std::string &strInstrument, const std::string &strType)
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_deposit_cheque ( const std::string &  strServerID,
const std::string &  strMyAcct,
const std::string &  strMyNymID,
const std::string &  strInstrument,
const std::string &  strType 
)
static

Definition at line 7564 of file ot_commands_ot.cpp.

7567 {
7568  string strAssetTypeID = OTAPI_Wrap::Instrmnt_GetAssetID(strInstrument);
7569 
7570  if (!VerifyStringVal(strAssetTypeID)) {
7571  otOut << "\n\nFailure: Unable to find Asset Type ID on the "
7572  "instrument.\n\n";
7573  return -1;
7574  }
7575 
7576  string strAssetTypeAcct =
7578  if (strAssetTypeID != strAssetTypeAcct) {
7579  otOut << "\n\nFailure: Asset Type ID on the instrument ( "
7580  << strAssetTypeID << " ) doesn't match the one on the MyAcct ( "
7581  << strAssetTypeAcct << " )\n\n";
7582  return -1;
7583  }
7584 
7585  string strResponse = MadeEasy::deposit_cheque(strServerID, strMyNymID,
7586  strMyAcct, strInstrument);
7587  string strAttempt = "deposit_cheque";
7588 
7589  int32_t nInterpretReply = InterpretTransactionMsgReply(
7590  strServerID, strMyNymID, strMyAcct, strAttempt, strResponse);
7591 
7592  if (1 == nInterpretReply) {
7593  bool bRetrieved = MadeEasy::retrieve_account(strServerID, strMyNymID,
7594  strMyAcct, true);
7595 
7596  otOut << "Server response (" << strAttempt << "): SUCCESS!\n";
7597  otOut << (bRetrieved ? "Success" : "Failed")
7598  << " retrieving intermediary files for account.\n";
7599  }
7600 
7601  return nInterpretReply;
7602 }
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string deposit_cheque(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &STR_CHEQUE)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_deposit_purse ( const std::string &  strServerID,
const std::string &  strMyAcct,
const std::string &  strFromNymID,
const std::string &  strInstrument,
const std::string &  strIndices 
)
static

Definition at line 7605 of file ot_commands_ot.cpp.

7610 {
7611  string strLocation = "details_deposit_purse";
7612 
7613  string strTHE_Instrument = "";
7614 
7615  if (VerifyStringVal(strInstrument)) {
7616  strTHE_Instrument = strInstrument;
7617  }
7618 
7619  string strAssetTypeID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(strMyAcct);
7620  if (!VerifyStringVal(strAssetTypeID)) {
7621  otOut << "\n\nFailure: Unable to find Asset Type ID based on myacct. "
7622  "Use: --myacct ACCT_ID\n";
7623  otOut << "The designated asset account must be yours. OT will find the "
7624  "asset type based on the account.\n\n";
7625  return -1;
7626  }
7627 
7628  if (VerifyExists("MyPurse", false) && (MyPurse != strAssetTypeID)) {
7629  otOut << "Warning: Depositing to MyAcct, which is NOT the same asset "
7630  "type as the MyPurse asset type specified.\n";
7631  }
7632 
7633  bool bLoadedPurse = false;
7634 
7635  // If strInstrument wasn't passed, that means we're supposed to load
7636  // the purse ourselves, from local storage.
7637  if (!VerifyStringVal(strTHE_Instrument)) {
7638  strTHE_Instrument =
7639  OTAPI_Wrap::LoadPurse(strServerID, strAssetTypeID, strFromNymID);
7640 
7641  if (!VerifyStringVal(strTHE_Instrument)) {
7642  otOut << "\n " << strLocation << ": Unable to load purse from "
7643  "local storage. Does it even "
7644  "exist?\n";
7645  return -1;
7646  }
7647 
7648  bLoadedPurse = true;
7649  }
7650 
7651  // Below this point, we know that strTHE_Instrument contains either the
7652  // purse as it was passed in
7653  // to us, or it contains the purse as we loaded it from local storage.
7654  // If it WAS from local storage, then there's a chance that strIndices
7655  // contains "all" or "4, 6, 2" etc.
7656  // If that's the case, then we need to iterate through the purse, and add
7657  // the denoted token IDs to
7658  // a vector (selectedTokens) and pass it into depositCashPurse.
7659 
7660  vector<string> vecSelectedTokenIDs;
7661 
7662  // If we loaded the purse (vs the user pasting one in...)
7663  // then the user might have wanted to deposit only selected indices,
7664  // rather than ALL the tokens in that purse.
7665  // So we'll loop through the purse and add any relevant IDs to the
7666  // "selected" list, since the actual Token IDs must be passed.
7667  if (bLoadedPurse) {
7668 
7669  // Loop through purse contents...
7670  int32_t nCount = OTAPI_Wrap::Purse_Count(strServerID, strAssetTypeID,
7671  strTHE_Instrument);
7672  if (nCount < 0) {
7673  otOut << "\n " << strLocation << ": Error: Unexpected bad value "
7674  "returned from "
7675  "OT_API_Purse_Count.\n\n";
7676  return -1;
7677  }
7678 
7679  if (nCount < 1) {
7680  otOut << "\n " << strLocation
7681  << ": The purse is empty, so you can't deposit it.\n\n";
7682  return -1;
7683  }
7684  else {
7685  // Make a copy of the purse passed in, so we can iterate it and find
7686  // the
7687  // appropriate Token IDs...
7688 
7689  string strPurse = strTHE_Instrument;
7690 
7691  if (VerifyStringVal(strIndices)) {
7692  int32_t nIndex = -1;
7693 
7694  while (nCount > 0) {
7695  --nCount;
7696  ++nIndex;
7697 
7698  // NOTE: Owner can ONLY be strFromNymID in here, since
7699 
7700  // is only true in the case where we LOADED the purse from
7701  // local storage.
7702  // (Therefore this DEFINITELY is not a password-protected
7703  // purse.)
7704  string strToken = OTAPI_Wrap::Purse_Peek(
7705  strServerID, strAssetTypeID, strFromNymID, strPurse);
7706 
7707  if (!VerifyStringVal(strToken)) {
7708  otOut << strLocation << ": Error: OT_API_Purse_Peek "
7709  "unexpectedly returned nullptr "
7710  "instead of token.\n";
7711  return -1;
7712  }
7713 
7714  string strNewPurse = OTAPI_Wrap::Purse_Pop(
7715  strServerID, strAssetTypeID, strFromNymID, strPurse);
7716 
7717  if (!VerifyStringVal(strNewPurse)) {
7718  otOut << strLocation << ": Error: OT_API_Purse_Pop "
7719  "unexpectedly returned nullptr "
7720  "instead of updated purse.\n";
7721  return -1;
7722  }
7723 
7724  strPurse = strNewPurse;
7725 
7726  string strTokenID = OTAPI_Wrap::Token_GetID(
7727  strServerID, strAssetTypeID, strToken);
7728 
7729  if (!VerifyStringVal(strTokenID)) {
7730  otOut << strLocation << ": Error while depositing "
7731  "purse: bad strTokenID.\n";
7732  return -1;
7733  }
7734 
7735  if (!("all" == strIndices) &&
7737  strIndices, std::to_string(nIndex))) {
7738  vecSelectedTokenIDs.push_back(strTokenID);
7739  }
7740  }
7741  }
7742  }
7743  }
7744 
7745  int32_t nResult = MadeEasy::depositCashPurse(
7746  strServerID, strAssetTypeID, strFromNymID, strTHE_Instrument,
7747  vecSelectedTokenIDs, strMyAcct, bLoadedPurse);
7748 
7749  return nResult;
7750 }
std::string to_string(const T &t)
EXPORT static OT_MADE_EASY_OT int32_t depositCashPurse(const std::string &serverID, const std::string &assetID, const std::string &nymID, const std::string &oldPurse, const std::vector< std::string > &selectedTokens, const std::string &accountID, bool bReimportIfFailure)
static EXPORT std::string LoadPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1829
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT int32_t Purse_Count(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
returns a count of the number of cash tokens inside this purse.
Definition: OTAPI.cpp:1843
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Purse_Pop(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_OR_SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1879
static EXPORT std::string Token_GetID(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1935
static EXPORT std::string Purse_Peek(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1871
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_discard_incoming ( const std::string &  strServer,
const std::string &  strMyNym,
const std::string &  strIndices 
)
static

Definition at line 814 of file ot_commands_ot.cpp.

817 {
818  if (!VerifyStringVal(strIndices)) {
819  return -1;
820  }
821 
822  int32_t nSuccess = 1;
823 
824  string strInbox = OTAPI_Wrap::LoadPaymentInbox(strServer, strMyNym);
825 
826  if (!VerifyStringVal(strInbox)) {
827  otOut << "\n\n details_discard_incoming: OT_API_LoadPaymentInbox "
828  "Failed.\n\n";
829  return -1;
830  }
831 
832  int32_t nInboxCount =
833  OTAPI_Wrap::Ledger_GetCount(strServer, strMyNym, strMyNym, strInbox);
834 
835  if (0 > nInboxCount) {
836  otOut << "details_discard_incoming: Unable to retrieve size of "
837  "payments inbox ledger. (Failure.)\n";
838  return -1;
839  }
840 
841  if (nInboxCount > 0) {
842 
843  int32_t nIndicesCount = VerifyStringVal(strIndices)
844  ? OTAPI_Wrap::NumList_Count(strIndices)
845  : 0;
846 
847  // Either we loop through all the instruments and accept them all, or
848  // we loop through all the instruments and accept the specified indices.
849  //
850  // (But either way, we loop through all the instruments.)
851 
852  // Loop from back to front, so if any are removed,
853  // the indices remain accurate subsequently.
854  for (int32_t nInboxIndex = (nInboxCount - 1); nInboxIndex >= 0;
855  --nInboxIndex) {
856  // - If "all" was passed, we process the item.
857  // - If indices are specified, but the current index is not on
858  // that list, then continue...
859  if (!("all" == strIndices) &&
860  ((nIndicesCount > 0) &&
862  strIndices, std::to_string(nInboxIndex)))) {
863  continue;
864  }
865 
866  // If it IS "all" OR, if there are indices and the current index was
867  // found in them.
868  // removes payment instrument (from payments in or out box)
869  bool bRecorded = OTAPI_Wrap::RecordPayment(
870  strServer, strMyNym, true, nInboxIndex, false);
871  otOut << "\n" << (bRecorded ? "Success" : "Failure")
872  << " discarding instrument from payments inbox at index: "
873  << nInboxIndex
874  << ".\n\n NOTE: Now the sender has to leave it in his "
875  "outbox until it expires or he cancels it on his "
876  "end.\n";
877  if (!bRecorded) {
878  nSuccess = -1;
879  }
880  }
881 
882  }
883  else {
884  return 0;
885  }
886 
887  return nSuccess;
888 }
std::string to_string(const T &t)
static EXPORT std::string LoadPaymentInbox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1553
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool RecordPayment(const std::string &SERVER_ID, const std::string &USER_ID, const bool &bIsInbox, const int32_t &nIndex, const bool &bSaveCopy)
Definition: OTAPI.cpp:1591
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_download_box_receipt ( const std::string &  strID,
int32_t  nBoxType 
)
static

Definition at line 6298 of file ot_commands_ot.cpp.

6300 {
6301  string strMyNymID = MyNym;
6302  string strAcctID;
6303 
6304  if (0 == nBoxType) {
6305  strAcctID = MyNym;
6306  }
6307  else {
6308  if (!VerifyExists("MyAcct", false)) {
6309  otOut << "Failure: Unable to find MyAcct. Use: --myacct ACCT_ID\n";
6310  otOut << "The designated asset account must be yours. OT will find "
6311  "the Nym based on the account.\n\n";
6312  return -1;
6313  }
6314  else {
6315  strAcctID = MyAcct;
6316 
6317  // (After this point, MyNym contains the NymID, and strMyNymID
6318  // contains
6319  // the NymID that corresponds to MyAcct -- they may not necessarily
6320  // be
6321  // the same Nym...)
6322  strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strAcctID);
6323  if (!VerifyStringVal(strMyNymID)) {
6324  otOut << "Failure: Unable to find NymID based on myacct. Use: "
6325  "--myacct ACCT_ID\n";
6326  otOut << "The designated asset account must be yours. OT will "
6327  "find the Nym based on the account.\n\n";
6328  return -1;
6329  }
6330 
6331  if (strMyNymID != MyNym) {
6332  otOut << "Failure: Found a NymID based on myacct, but MyNym is "
6333  "not the same ID.\n";
6334  otOut << "To avoid any confusion, please be explicit with Nym "
6335  "ID: --mynym NYM_ID \n\n";
6336  return -1;
6337  }
6338  }
6339  }
6340 
6341  string strResponse = MadeEasy::get_box_receipt(Server, strMyNymID,
6342  strAcctID, nBoxType, strID);
6343  int32_t nInterpretReply = VerifyMessageSuccess(strResponse);
6344 
6345  if (1 != nInterpretReply) {
6346  otOut << "get_box_receipt: Failed. nInterpretReply is: "
6347  << nInterpretReply << "\n";
6348  otOut << "get_box_receipt: Perhaps that receipt is no longer in the "
6349  "box?\n";
6350  }
6351  else {
6352  otOut << "Success in get_box_receipt! Server response:\n\n";
6353  cout << strResponse << "\n";
6354  otOut << "\n\n";
6355  return 1;
6356  }
6357  return nInterpretReply;
6358 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string get_box_receipt(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, int32_t nBoxType, const std::string &STR_TRANS_NUM)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_download_contract ( const std::string &  strServerID,
const std::string &  strNymID,
const std::string &  strContractID 
)
static

Definition at line 6120 of file ot_commands_ot.cpp.

6123 {
6124  string strRetrieved =
6125  MadeEasy::retrieve_contract(strServerID, strNymID, strContractID);
6126  int32_t nRetrieved = VerifyMessageSuccess(strRetrieved);
6127 
6128  string strSuccess = "Error";
6129 
6130  if (1 == nRetrieved) {
6131  strSuccess = "Success";
6132  }
6133  else if (0 == nRetrieved) {
6134  strSuccess = "Failed";
6135  }
6136 
6137  otOut << "\n\n " << strSuccess << " retrieving contract: " << strContractID
6138  << "\n\n";
6139 
6140  return (1 == nRetrieved) ? 1 : -1;
6141 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_exchange_basket ( const std::string &  strServer,
const std::string &  strNym,
const std::string &  strAcct,
const std::string &  strBasketType 
)
static

Definition at line 391 of file ot_commands_ot.cpp.

395 {
396  // NOTE: details_exchange_basket ASSUMES that strAcct has a server of
397  // strServer and
398  // a NymID of strNym and an asset type of strBasketType. (These are already
399  // verified
400  // in OT_Command::mainExchangeBasket.)
401  int32_t nMemberCount = OTAPI_Wrap::Basket_GetMemberCount(strBasketType);
402 
403  if (nMemberCount < 2) {
404  otOut << "Strange, the chosen basket asset type apparently has no "
405  "sub-currencies. (Failure.)\n";
406  return -1;
407  }
408 
409  int64_t lMinimumTransAmount =
411 
412  if (0 > lMinimumTransAmount) {
413  otOut << "Strange, the chosen basket asset type apparently has no "
414  "minimum transfer amount. (Failure.)\n";
415  return -1;
416  }
417 
418  bool bExchangingIn = true;
419 
420  otOut << "Are you exchanging IN or OUT of the basket? [IN]: ";
421  string strInOrOut = OT_CLI_ReadLine();
422 
423  if (!VerifyStringVal(strInOrOut)) {
424  strInOrOut = "in";
425  }
426 
427  int64_t lBalance = OTAPI_Wrap::GetAccountWallet_Balance(strAcct);
428  if (0 > lBalance) {
429  otOut << "Strange: unable to retrieve balance for basket account: "
430  << strAcct << "\n";
431  return -1;
432  }
433 
434  if ((strInOrOut == "out") || (strInOrOut == "OUT")) {
435  otOut << "Exchanging OUT of the basket currency...\n\n";
436  bExchangingIn = false;
437 
438  if (lBalance < lMinimumTransAmount) {
439  otOut << "Sorry, but the minimum transfer amount for this basket "
440  "currency is " << lMinimumTransAmount
441  << "\nand the chosen account's balance is only " << lBalance
442  << ". (Failure.)\n";
443  return -1;
444  }
445  }
446  else {
447  otOut << "Exchanging IN to the basket currency...\n\n";
448  }
449 
450  int32_t nTransferMultiple = 1;
451 
452  otOut << "This basket currency has a minimum transfer amount of "
453  << lMinimumTransAmount << ".\n";
454  otOut << "Now you must choose the Transfer Multiple for the exchange. For "
455  "example:\n";
456 
457  for (int32_t i = 1; i < 5; ++i) {
458  int64_t lUnits = i * lMinimumTransAmount;
459 
460  otOut << "A transfer multiple of " << i << " will exchange " << lUnits
461  << " units of the basket currency.\n";
462  }
463  otOut << "Etc.\n";
464 
465  if (!bExchangingIn) {
466  otOut << "Keep in mind, the balance in the basket account is: "
467  << lBalance << "\n\n";
468  }
469 
470  otOut << "Please choose a transfer multiple [1]: ";
471  string strTransferMultiple = OT_CLI_ReadLine();
472 
473  if (VerifyStringVal(strTransferMultiple)) {
474  int32_t nTempMultiple = std::stol(strTransferMultiple);
475 
476  if (nTempMultiple > 1) {
477  nTransferMultiple = nTempMultiple;
478  }
479  }
480 
481  int64_t lAttemptedTransfer = (nTransferMultiple * lMinimumTransAmount);
482 
483  if (!bExchangingIn && (lAttemptedTransfer > lBalance)) {
484  otOut << "A transfer multiple of " << nTransferMultiple
485  << " will exchange " << lAttemptedTransfer
486  << " units out of the basket currency.\nUnfortunately, you only "
487  "have a " << lBalance
488  << " balance in your basket account. (Failed.)\n";
489  return -1;
490  }
491 
492  if (!MadeEasy::insure_enough_nums(20, strServer, strNym)) {
493  return -1;
494  }
495 
496  string strBasket = OTAPI_Wrap::GenerateBasketExchange(
497  strServer, strNym, strBasketType, strAcct, nTransferMultiple);
498 
499  if (!VerifyStringVal(strBasket)) {
500  otOut << "Failed generating basket exchange request.\n";
501  return -1;
502  }
503 
504  // Below this point, after any failure, call this before returning:
505  //
506  // OTAPI_Wrap::Msg_HarvestTransactionNumbers(strBasket, strNym, false,
507  // false, false, false, false)
508  //
509  // NOTE: Only do this up until the message is sent. Once it's sent, the
510  // harvesting is already
511  // handled internally. (Only need to harvest in the event that some failure
512  // occurs in the middle of
513  // constructing the basket exchange request, for any time BEFORE actually
514  // trying to send it.)
515 
516  // SUB-CURRENCIES!
517 
518  for (int32_t nMember = 0; nMember < nMemberCount; ++nMember) {
519  string strMemberType =
520  OTAPI_Wrap::Basket_GetMemberType(strBasketType, nMember);
521 
522  if (!VerifyStringVal(strMemberType)) {
523  otOut << "Error retrieving member type from index " << nMember
524  << " of basket currency: " << strBasketType << "\n";
526  strBasket, strNym, false, false, false, false, false);
527  return -1;
528  }
529 
530  string strMemberTypeName = OTAPI_Wrap::GetAssetType_Name(strMemberType);
531 
532  if (!VerifyStringVal(strMemberTypeName)) {
533  strMemberTypeName = "";
534  }
535 
536  int64_t lMemberAmount =
538  nMember);
539 
540  if (0 > lMemberAmount) {
541  otOut << "Error retrieving minimum transfer amount from index "
542  << nMember << " (" << strMemberType
543  << ") on basket currency: " << strBasketType << "\n";
545  strBasket, strNym, false, false, false, false, false);
546  return -1;
547  }
548 
549  lAttemptedTransfer = (nTransferMultiple * lMemberAmount);
550 
551  // This will only display accounts registered on strServer of asset type
552  // strMemberType.
553  OT_Command::stat_basket_accounts(strServer, strNym, true,
554  strMemberType);
555 
556  otOut << "There are " << (nMemberCount - nMember)
557  << " accounts remaining to be selected.\n\n";
558  otOut << "Currently we need to select an account with the asset type:\n"
559  << strMemberType << " (" << strMemberTypeName << ")\n";
560  otOut << "Above are all the accounts in the wallet, for the relevant "
561  "server and nym, of that asset type.\n";
562 
563  if (bExchangingIn) {
564  otOut << "\nKeep in mind, with a transfer multiple of "
565  << nTransferMultiple << " and a minimum transfer amount of "
566  << lMemberAmount
567  << "\n(for this sub-currency), you must therefore select an "
568  "account with a minimum\nbalance of: "
569  << lAttemptedTransfer << "\n";
570  }
571 
572  otOut << "\nPlease PASTE an account ID from the above list: ";
573  string strSubAccount = OT_CLI_ReadLine();
574 
575  if (!VerifyStringVal(strSubAccount)) {
577  strBasket, strNym, false, false, false, false, false);
578  return -1;
579  }
580 
581  string strSubAssetID =
583  if (!VerifyStringVal(strSubAssetID)) {
584  otOut << "Error retrieving asset type ID from pasted account: "
585  << strSubAccount << "\n";
587  strBasket, strNym, false, false, false, false, false);
588  return -1;
589  }
590 
591  if (strMemberType != strSubAssetID) {
592  otOut << "Failure: The selected account has the wrong asset type: "
593  << strSubAssetID << "\n";
595  strBasket, strNym, false, false, false, false, false);
596  return -1;
597  }
598 
599  lBalance = OTAPI_Wrap::GetAccountWallet_Balance(strSubAccount);
600  if (0 > lBalance) {
601  otOut << "Strange, error while retrieving balance for sub-account: "
602  << strSubAccount << "\n";
604  strBasket, strNym, false, false, false, false, false);
605  return -1;
606  }
607 
608  if (bExchangingIn && (lAttemptedTransfer > lBalance)) {
609  otOut << "\nWith a minimum transfer amount of " << lMemberAmount
610  << " for this sub-currency, a transfer multiple of "
611  << nTransferMultiple << " will exchange "
612  << lAttemptedTransfer
613  << " units out of the basket currency.\n\nUnfortunately, you "
614  "only have a " << lBalance
615  << " balance in your selected account. (Failure.)\n";
617  strBasket, strNym, false, false, false, false, false);
618  return -1;
619  }
620 
621  string strTempBasket = OTAPI_Wrap::AddBasketExchangeItem(
622  strServer, strNym, strBasket, strSubAssetID, strSubAccount);
623 
624  if (!VerifyStringVal(strTempBasket)) {
625  otOut << "Failed while adding this sub-account to the exchange "
626  "request!\n";
628  strBasket, strNym, false, false, false, false, false);
629  return -1;
630  }
631 
632  strBasket = strTempBasket;
633 
634  otOut << "\n\n";
635  }
636 
637  string strResponse = MadeEasy::exchange_basket_currency(
638  strServer, strNym, strBasketType, strBasket, strAcct, bExchangingIn);
639  string strAttempt = "exchange_basket";
640 
641  int32_t nInterpretReply = InterpretTransactionMsgReply(
642  strServer, strNym, strAcct, strAttempt, strResponse);
643 
644  if (1 == nInterpretReply) {
645  bool bRetrieved =
646  MadeEasy::retrieve_account(strServer, strNym, strAcct, true);
647 
648  otOut << "Server response (" << strAttempt
649  << "): SUCCESS exchanging basket!\n";
650  otOut << (bRetrieved ? "Success" : "Failed")
651  << " retrieving intermediary files for account.\n";
652  }
653 
654  return nInterpretReply;
655 }
static EXPORT int32_t Basket_GetMemberCount(const std::string &BASKET_ASSET_TYPE_ID)
Definition: OTAPI.cpp:1985
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Basket_GetMemberType(const std::string &BASKET_ASSET_TYPE_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:1990
static EXPORT std::string AddBasketExchangeItem(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &THE_BASKET, const std::string &ASSET_TYPE_ID, const std::string &ASSET_ACCT_ID)
Definition: OTAPI.cpp:2149
static EXPORT int64_t GetAccountWallet_Balance(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1032
static EXPORT std::string GenerateBasketExchange(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &BASKET_ASSET_TYPE_ID, const std::string &BASKET_ASSET_ACCT_ID, const int32_t &TRANSFER_MULTIPLE)
Definition: OTAPI.cpp:2139
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
EXPORT static OT_COMMANDS_OT int32_t stat_basket_accounts(const std::string &strServer, const std::string &strNym, bool bFilter, const std::string &strBasketType)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
EXPORT static OT_MADE_EASY_OT std::string exchange_basket_currency(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_TYPE, const std::string &THE_BASKET, const std::string &ACCT_ID, bool IN_OR_OUT)
static EXPORT int64_t Basket_GetMinimumTransferAmount(const std::string &BASKET_ASSET_TYPE_ID)
Definition: OTAPI.cpp:1996
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
static EXPORT int64_t Basket_GetMemberMinimumTransferAmount(const std::string &BASKET_ASSET_TYPE_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:2002
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT string opentxs::OT_Command::details_export_cash ( const std::string &  strServerID,
const std::string &  strFromNymID,
const std::string &  strAssetTypeID,
std::string &  strHisNymID,
const std::string &  strIndices,
bool  bPasswordProtected,
std::string &  strRetainedCopy 
)
static

Definition at line 8114 of file ot_commands_ot.cpp.

8118 {
8119 
8120  string strLocation = "\n details_export_cash";
8121 
8122  // The first three arguments are for loading up the purse we're exporting
8123  // FROM.
8124  //
8125  // Then strHisNymID is for the Nym we're exporting TO (if bPasswordProtected
8126  // is false.)
8127  //
8128  // Then strIndices contains the indices for the tokens to export.
8129  //
8130  // Then bPasswordProtected tells us whether to export to strHisNymID,
8131  // or to create a password-protected purse and export to that instead.
8132  // (In which case, the purse itself becomes the "owner" and can be passed
8133  // wherever we would normally pass a NymID as a purse owner.)
8134  //
8135  // if bPasswordProtected is false, then strHisNymID needs to contain the
8136  // recipient Nym.
8137  // This will contain MyNym by default, if --hisnym wasn't used at the
8138  // command line.
8139 
8140  string strContract = MadeEasy::load_or_retrieve_contract(
8141  strServerID, strFromNymID, strAssetTypeID);
8142 
8143  if (!VerifyStringVal(strContract)) {
8144  otOut << strLocation
8145  << ": Unable to load asset contract: " << strAssetTypeID << "\n";
8146  return "";
8147  }
8148 
8149  bool bLoadedPurse = false;
8150 
8151  string strInstrument =
8152  OTAPI_Wrap::LoadPurse(strServerID, strAssetTypeID, strFromNymID);
8153 
8154  if (!VerifyStringVal(strInstrument)) {
8155  otOut << strLocation << ": Unable to load purse from local storage. "
8156  "Does it even exist?\n";
8157  return "";
8158  }
8159 
8160  bLoadedPurse = true;
8161 
8162  // Below this point, we know that strInstrument contains the purse as we
8163  // loaded it from local storage.
8164  // If it WAS from local storage, then there's a chance that strIndices
8165  // contains "4, 6, 2" etc.
8166  // If that's the case, then we need to iterate through the purse, and add
8167  // the denoted token IDs to
8168  // a vector (selectedTokens) and pass it into exportCashPurse.
8169 
8170  vector<string> vecSelectedTokenIDs;
8171 
8172  // the user might have wanted to export only selected indices,
8173  // rather than ALL the tokens in the purse.
8174  // So we'll loop through the purse and add any relevant IDs to the
8175  // "selected" list, since the actual Token IDs must be passed.
8176  if (bLoadedPurse) {
8177 
8178  // Loop through purse contents...
8179  int32_t nCount =
8180  OTAPI_Wrap::Purse_Count(strServerID, strAssetTypeID, strInstrument);
8181  if (nCount < 0) {
8182  otOut << strLocation << ": Error: Unexpected bad value returned "
8183  "from OT_API_Purse_Count.\n\n";
8184  return "";
8185  }
8186 
8187  if (nCount < 1) {
8188  otOut << strLocation
8189  << ": The purse is empty, so you can't export it.\n\n";
8190  return "";
8191  }
8192  else {
8193  // Make a COPY of the purse for this loop, so we can iterate it and
8194  // find the
8195  // appropriate Token IDs...
8196 
8197  string strPurse = strInstrument;
8198 
8199  if (VerifyStringVal(strIndices)) {
8200  int32_t nIndex = -1;
8201 
8202  while (nCount > 0) {
8203  --nCount;
8204  ++nIndex;
8205 
8206  string strToken = OTAPI_Wrap::Purse_Peek(
8207  strServerID, strAssetTypeID, strFromNymID, strPurse);
8208 
8209  if (!VerifyStringVal(strToken)) {
8210  otOut << strLocation << ": Error: OT_API_Purse_Peek "
8211  "unexpectedly returned nullptr "
8212  "instead of token.\n";
8213  return "";
8214  }
8215 
8216  string strNewPurse = OTAPI_Wrap::Purse_Pop(
8217  strServerID, strAssetTypeID, strFromNymID, strPurse);
8218 
8219  if (!VerifyStringVal(strNewPurse)) {
8220  otOut << strLocation << ": Error: OT_API_Purse_Pop "
8221  "unexpectedly returned nullptr "
8222  "instead of updated purse.\n";
8223  return "";
8224  }
8225 
8226  strPurse = strNewPurse;
8227 
8228  string strTokenID = OTAPI_Wrap::Token_GetID(
8229  strServerID, strAssetTypeID, strToken);
8230 
8231  if (!VerifyStringVal(strTokenID)) {
8232  otOut << strLocation << ": Error while exporting "
8233  "purse: bad strTokenID.\n";
8234  return "";
8235  }
8236 
8237  // If there are no indices, then do them all. (Thus push
8238  // this one,
8239  // as we push every one.)
8240  // OR, If there are indices, and the current index is FOUND
8241  // on the
8242  // vector of indices, then we push this one (since it was
8243  // selected.)
8244  if (!("all" == strIndices) &&
8246  strIndices, std::to_string(nIndex))) {
8247  vecSelectedTokenIDs.push_back(strTokenID);
8248  }
8249  }
8250  }
8251 
8252  string strExportedCashPurse = MadeEasy::exportCashPurse(
8253  strServerID, strAssetTypeID, strFromNymID, strInstrument,
8254  vecSelectedTokenIDs, strHisNymID, bPasswordProtected,
8255  strRetainedCopy);
8256 
8257  return strExportedCashPurse;
8258  }
8259  }
8260 
8261  return "";
8262 }
std::string to_string(const T &t)
static EXPORT std::string LoadPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1829
EXPORT static OT_MADE_EASY_OT std::string exportCashPurse(const std::string &serverID, const std::string &assetID, const std::string &nymID, const std::string &oldPurse, const std::vector< std::string > &selectedTokens, std::string &recipientNymID, bool bPasswordProtected, std::string &strRetainedCopy)
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
static EXPORT int32_t Purse_Count(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
returns a count of the number of cash tokens inside this purse.
Definition: OTAPI.cpp:1843
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Purse_Pop(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_OR_SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1879
static EXPORT std::string Token_GetID(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1935
static EXPORT std::string Purse_Peek(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1871
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT string opentxs::OT_Command::details_export_nym ( const std::string &  strNymID)
static

Definition at line 3572 of file ot_commands_ot.cpp.

3573 {
3574  string strExportedNym = OTAPI_Wrap::Wallet_ExportNym(strNymID);
3575 
3576  return strExportedNym;
3577 }
static EXPORT std::string Wallet_ExportNym(const std::string &NYM_ID)
Returns the exported Nym, if success. (Else nullptr.)
Definition: OTAPI.cpp:593
OT_COMMANDS_OT string opentxs::OT_Command::details_get_nym_market_offers ( const std::string &  strServerID,
const std::string &  strNymID 
)
static

Definition at line 7283 of file ot_commands_ot.cpp.

7285 {
7286  string strResponse;
7287 
7288  if (VerifyStringVal(strServerID) && VerifyStringVal(strNymID)) {
7289  strResponse = MadeEasy::get_nym_market_offers(strServerID, strNymID);
7290  }
7291 
7292  return strResponse;
7293 }
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT std::string get_nym_market_offers(const std::string &SERVER_ID, const std::string &NYM_ID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_import_cash ( const std::string &  strInstrument)
static

Definition at line 7954 of file ot_commands_ot.cpp.

7955 {
7956  if (!VerifyStringVal(strInstrument)) {
7957  return -1;
7958  }
7959 
7960  string strType = OTAPI_Wrap::Instrmnt_GetType(strInstrument);
7961 
7962  if (!VerifyStringVal(strType)) {
7963  otOut << "\n\nFailure: Unable to determine instrument type. Expected "
7964  "(cash) PURSE.\n";
7965  return -1;
7966  }
7967 
7968  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strInstrument);
7969 
7970  if (!VerifyStringVal(strServerID)) {
7971  otOut << "\n\nFailure: Unable to determine server ID from purse.\n";
7972  return -1;
7973  }
7974 
7975  if ("PURSE" == strType) {
7976  }
7977  // Todo: case "TOKEN"
7978  //
7979  // NOTE: This is commented out because since it is guessing the NymID as
7980  // MyNym,
7981  // then it will just create a purse for MyNym and import it into that purse,
7982  // and
7983  // then later when doing a deposit, THAT's when it tries to DECRYPT that
7984  // token
7985  // and re-encrypt it to the SERVER's nym... and that's when we might find
7986  // out that
7987  // it never was encrypted to MyNym in the first place -- we had just assumed
7988  // it
7989  // was here, when we did the import. Until I can look at that in more
7990  // detail, it
7991  // will remain commented out.
7992  else {
7993  // // This version supports cash tokens (instead of purse...)
7994  // bool bImportedToken = importCashPurse(strServerID, MyNym,
7995  // strAssetID, userInput, isPurse);
7996  //
7997  // if (bImportedToken)
7998  // {
7999  // otOut << "\n\n Success importing cash token!\nServer: "
8000  // << strServerID << "\nAsset Type: " << strAssetID
8001  // << "\nNym: " << MyNym << "\n\n";
8002  // return 1;
8003  // }
8004 
8005  otOut << "\n\nFailure: Unable to determine instrument type. Expected "
8006  "(cash) PURSE.\n";
8007  return -1;
8008  }
8009 
8010  // This tells us if the purse is password-protected. (Versus being owned
8011  // by a Nym.)
8012  bool bHasPassword =
8013  OTAPI_Wrap::Purse_HasPassword(strServerID, strInstrument);
8014 
8015  // Even if the Purse is owned by a Nym, that Nym's ID may not necessarily
8016  // be present on the purse itself (it's optional to list it there.)
8017  // OTAPI_Wrap::Instrmnt_GetRecipientUserID tells us WHAT the recipient User
8018  // ID
8019  // is, IF it's on the purse. (But does NOT tell us WHETHER there is a
8020  // recipient. The above function is for that.)
8021  string strPurseOwner = "";
8022 
8023  if (!bHasPassword) {
8024  strPurseOwner = OTAPI_Wrap::Instrmnt_GetRecipientUserID(strInstrument);
8025  }
8026 
8027  // Whether the purse was password-protected (and thus had no Nym ID)
8028  // or whether it does have a Nym ID (but it wasn't listed on the purse)
8029  // Then either way, in those cases strPurseOwner will still be nullptr.
8030  //
8031  // (The third case is that the purse is Nym protected and the ID WAS
8032  // available,
8033  // in which case we'll skip this block, since we already have it.)
8034  //
8035  // But even in the case where there's no Nym at all (password protected)
8036  // we STILL need to pass a Signer Nym ID into
8037  // OTAPI_Wrap::Wallet_ImportPurse.
8038  // So if it's still nullptr here, then we use --mynym to make the call.
8039  // And also, even in the case where there IS a Nym but it's not listed,
8040  // we must assume the USER knows the appropriate NymID, even if it's not
8041  // listed on the purse itself. And in that case as well, the user can
8042  // simply specify the Nym using --mynym.
8043  //
8044  // Bottom line: by this point, if it's still not set, then we just use
8045  // MyNym, and if THAT's not set, then we return failure.
8046  if (!VerifyStringVal(strPurseOwner)) {
8047  otOut << "\n\n The NymID isn't evident from the purse itself... "
8048  "(listing it is optional.)\nThe purse may have no Nym at "
8049  "all--it may instead be password-protected.) Either way, a "
8050  "signer nym is still necessary, even for password-protected "
8051  "purses.\n\n Trying MyNym...\n";
8052 
8053  if (!VerifyExists("MyNym")) {
8054  return -1;
8055  }
8056 
8057  strPurseOwner = MyNym;
8058  }
8059 
8060  return details_import_purse(strInstrument, bHasPassword, strPurseOwner);
8061 }
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t details_import_purse(const std::string &strInstrument, bool bHasPassword, const std::string &strPurseOwner)
static EXPORT bool Purse_HasPassword(const std::string &SERVER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1850
OT_COMMANDS_OT bool opentxs::OT_Command::details_import_nym ( const std::string &  strNymImportFile,
std::string &  strOutNymID 
)
static

Definition at line 3534 of file ot_commands_ot.cpp.

3536 {
3537  strOutNymID = OTAPI_Wrap::Wallet_ImportNym(strNymImportFile);
3538 
3539  bool bVerified = VerifyStringVal(strOutNymID);
3540 
3541  return bVerified;
3542 }
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Wallet_ImportNym(const std::string &FILE_CONTENTS)
returns NymID if success, else nullptr.
Definition: OTAPI.cpp:603
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_import_purse ( const std::string &  strInstrument,
bool  bHasPassword,
const std::string &  strPurseOwner 
)
static

Definition at line 7909 of file ot_commands_ot.cpp.

7912 {
7913  if (!VerifyStringVal(strInstrument)) {
7914  return -1;
7915  }
7916 
7917  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strInstrument);
7918 
7919  if (!VerifyStringVal(strServerID)) {
7920  otOut << "\n\nFailure: Unable to determine server ID from purse.\n";
7921  return -1;
7922  }
7923 
7924  string strAssetID = OTAPI_Wrap::Instrmnt_GetAssetID(strInstrument);
7925 
7926  if (!VerifyStringVal(strAssetID)) {
7927  otOut << "\n\nFailure: Unable to determine asset type ID from purse.\n";
7928  return -1;
7929  }
7930 
7931  bool bActuallyHasPassword =
7932  OTAPI_Wrap::Purse_HasPassword(strServerID, strInstrument);
7933 
7934  if (bHasPassword != bActuallyHasPassword) {
7935  otOut << "The actual purse's opinion of whether or not it has a "
7936  "password, doesn't match the caller's opinion.\n";
7937  return -1;
7938  }
7939 
7940  bool bImported = OTAPI_Wrap::Wallet_ImportPurse(
7941  strServerID, strAssetID, strPurseOwner, strInstrument);
7942 
7943  if (bImported) {
7944  otOut << "\n\n Success importing purse!\nServer: " << strServerID
7945  << "\nAsset Type: " << strAssetID << "\nNym: " << strPurseOwner
7946  << "\n\n";
7947  return 1;
7948  }
7949 
7950  return -1;
7951 }
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool Wallet_ImportPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID, const std::string &THE_PURSE)
Should handle duplicates. Should load, merge, and save.
Definition: OTAPI.cpp:1907
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT bool Purse_HasPassword(const std::string &SERVER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1850
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_kill_offer ( const std::string &  strServerID,
const std::string &  strNymID,
const std::string &  strAcctID,
const std::string &  strTransNum 
)
static

Definition at line 5167 of file ot_commands_ot.cpp.

5171 {
5172  // Just to show how easy it is now, let's try a "kill_market_offer" message.
5173  // (It kills a market offer.)
5174 
5175  if (VerifyStringVal(strServerID) && VerifyStringVal(strNymID) &&
5176  VerifyStringVal(strAcctID) && VerifyStringVal(strTransNum)) {
5177 
5178  string strResponse = MadeEasy::kill_market_offer(
5179  strServerID, strNymID, strAcctID, strTransNum);
5180  if (1 != VerifyMessageSuccess(strResponse)) {
5181  otOut << "\n\n killoffer: Failed.\n";
5182  }
5183  else if (1 != VerifyMsgBalanceAgrmntSuccess(strServerID, strNymID,
5184  strAcctID, strResponse)) {
5185  otOut << "\n\n killoffer: Balance agreement failed.\n";
5186  }
5187  else if (1 != VerifyMsgTrnxSuccess(strServerID, strNymID, strAcctID,
5188  strResponse)) {
5189  otOut << "\n\n killoffer: Balance agreement succeeded, but "
5190  "transaction failed.\n";
5191  }
5192  else {
5193  otOut << "\n\nSuccess in killoffer! Server response:\n\n";
5194  cout << strResponse << "\n";
5195  otOut << "\n";
5196  return 1;
5197  }
5198  }
5199 
5200  return -1;
5201 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMsgBalanceAgrmntSuccess(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strMessage)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
EXPORT static OT_MADE_EASY_OT std::string kill_market_offer(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ACCT_ID, const std::string &STR_TRANS_NUM)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_UTILITY_OT int32_t VerifyMsgTrnxSuccess(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strMessage)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_new_basket ( const std::string &  strServer,
const std::string &  strNym 
)
static

Definition at line 234 of file ot_commands_ot.cpp.

236 {
237  int32_t nBasketCount = 2;
238  otOut << "How many different asset types will compose this new basket "
239  "currency? [2]: ";
240 
241  string strBasketCount = OT_CLI_ReadLine();
242 
243  if (VerifyStringVal(strBasketCount)) {
244  nBasketCount = std::stol(strBasketCount);
245 
246  if (nBasketCount < 2) {
247  otOut << "Sorry, but a basket currency must be composed of at "
248  "least 2 sub-currencies.\n";
249  return -1;
250  }
251  }
252 
253  int64_t lMinimumTransAmount = int64_t(100);
254 
255  otOut << "\nIf your basket has a minimum transfer amount of 100, you might "
256  "have 2 or 3 sub-currencies,\nwith the first being a minimum of 2 "
257  "gold, the second being a minimum of 50 dollars, and the\nthird "
258  "being a minimum of 30 silver.\nIn this example, 100 units of the "
259  "basket currency is transferrable in or out of the\nbasket "
260  "currency, in return for 2 gold, 50 dollars, and 30 silver.\n\n";
261  otOut << "What is the minimum transfer amount for the basket currency "
262  "itself? [100]: ";
263 
264  string strMinAmount = OT_CLI_ReadLine();
265 
266  if (VerifyStringVal(strMinAmount)) {
267  lMinimumTransAmount = std::stoll(strMinAmount);
268 
269  if (lMinimumTransAmount < 1) {
270  otOut << "Sorry, but this needs to be a non-zero value. Minimum is "
271  "1.\n";
272  return -1;
273  }
274  }
275 
276  string strBasket =
277  OTAPI_Wrap::GenerateBasketCreation(strNym, lMinimumTransAmount);
278 
279  if (!VerifyStringVal(strBasket)) {
280  otOut << "Error while generating initial basket object.\n";
281  return -1;
282  }
283 
284  for (int32_t ibasket = 0; ibasket < nBasketCount; ++ibasket) {
286 
287  otOut << "\nThis basket currency has " << nBasketCount
288  << " subcurrencies.\n";
289  otOut << "So far you have defined " << ibasket << " of them.\n";
290  otOut << "Please PASTE the asset type ID for a subcurrency of this "
291  "basket: ";
292 
293  string strSubcurrencyID = OT_CLI_ReadLine();
294 
295  if (!VerifyStringVal(strSubcurrencyID)) {
296  return -1;
297  }
298 
299  string strSubcurrencyContract =
300  OTAPI_Wrap::GetAssetType_Contract(strSubcurrencyID);
301 
302  if (!VerifyStringVal(strSubcurrencyContract)) {
303  otOut << "Sorry, but " << strSubcurrencyID
304  << " is apparently not a currency contract in your wallet.\n";
305  ibasket -= 1;
306  continue;
307  }
308 
309  otOut << "Enter minimum transfer amount for that asset type [100]: ";
310 
311  lMinimumTransAmount = 100;
312  strMinAmount = OT_CLI_ReadLine();
313 
314  if (VerifyStringVal(strMinAmount)) {
315  lMinimumTransAmount =
316  OTAPI_Wrap::StringToAmount(strSubcurrencyID, strMinAmount);
317 
318  if (lMinimumTransAmount < 1) {
319  otOut << "Sorry, but this needs to be a non-zero value. "
320  "Minimum is 1.\n";
321  ibasket -= 1;
322  continue;
323  }
324  }
325 
326  string strTempBasket = OTAPI_Wrap::AddBasketCreationItem(
327  strNym, strBasket, strSubcurrencyID, lMinimumTransAmount);
328 
329  if (!VerifyStringVal(strTempBasket)) {
330  otOut << "Error: OT_API_AddBasketCreationItem returned nullptr. "
331  "(Failure.)\n";
332  return -1;
333  }
334  else {
335  strBasket = strTempBasket;
336  }
337  }
338 
339  otOut << "Here's the basket we're issuing:\n\n" << strBasket << "\n";
340 
341  string strResponse =
342  MadeEasy::issue_basket_currency(strServer, strNym, strBasket);
343  int32_t nStatus = VerifyMessageSuccess(strResponse);
344  switch (nStatus) {
345  case 1: {
346  otOut << "\n\n SUCCESS in issue_basket_currency! Server response:\n\n";
347  cout << strResponse << "\n";
348 
349  string strNewID = OTAPI_Wrap::Message_GetNewAssetTypeID(strResponse);
350  bool bGotNewID = VerifyStringVal(strNewID);
351  bool bRetrieved = false;
352  string strEnding = ".";
353 
354  if (bGotNewID) {
355  string strRetrieved =
356  MadeEasy::retrieve_contract(strServer, strNym, strNewID);
357  strEnding = ": " + strNewID;
358 
359  if (1 == VerifyMessageSuccess(strRetrieved)) {
360  bRetrieved = true;
361  }
362  }
363  otOut << "Server response: SUCCESS in issue_basket_currency!\n";
364  otOut << (bRetrieved ? "Success" : "Failed")
365  << " retrieving new basket contract" << strEnding << "\n";
366  break;
367  }
368  case 0:
369  otOut << "\n\n FAILURE in issue_basket_currency! Server response:\n\n";
370  cout << strResponse << "\n";
371  otOut << " FAILURE in issue_basket_currency!\n";
372  break;
373  default:
374  otOut << "\n\nError in issue_basket_currency! nStatus is: " << nStatus
375  << "\n";
376 
377  if (VerifyStringVal(strResponse)) {
378  otOut << "Server response:\n\n";
379  cout << strResponse << "\n";
380  otOut << "\nError in issue_basket_currency! nStatus is: " << nStatus
381  << "\n";
382  }
383  break;
384  }
385  otOut << "\n";
386 
387  return (0 == nStatus) ? -1 : nStatus;
388 }
static EXPORT std::string AddBasketCreationItem(const std::string &USER_ID, const std::string &THE_BASKET, const std::string &ASSET_TYPE_ID, const int64_t &MINIMUM_TRANSFER)
Definition: OTAPI.cpp:2123
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string issue_basket_currency(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_BASKET)
EXPORT static OT_MADE_EASY_OT std::string retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
static EXPORT std::string GenerateBasketCreation(const std::string &USER_ID, const int64_t &MINIMUM_TRANSFER)
Definition: OTAPI.cpp:2117
EXPORT static OT_COMMANDS_OT int32_t mainShowAssets()
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetAssetType_Contract(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:496
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
static EXPORT std::string Message_GetNewAssetTypeID(const std::string &THE_MESSAGE)
Definition: OTAPI.cpp:2401
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_nym_stat ( const std::string &  strID)
static

Definition at line 5456 of file ot_commands_ot.cpp.

5457 {
5458  string strStats = OTAPI_Wrap::GetNym_Stats(strID);
5459  if (!VerifyStringVal(strStats)) {
5460  return -1;
5461  }
5462 
5463  cout << strStats << "\n";
5464  return 1;
5465 }
static EXPORT std::string GetNym_Stats(const std::string &NYM_ID)
Definition: OTAPI.cpp:659
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_pay_dividend ( const std::string &  strAmount,
const std::string &  strMemo 
)
static

Definition at line 7328 of file ot_commands_ot.cpp.

7330 {
7331  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
7332  if (!VerifyStringVal(strMyNymID)) {
7333  otOut << "\n\nFailure: Unable to find Payer NymID based on myacct. "
7334  "Use: --myacct DIVIDEND_SOURCE_ACCT_ID\n";
7335  otOut << "The designated asset account (that the dividends will be "
7336  "paid out of) must be yours. OT will find the Nym based on "
7337  "that account.\n\n";
7338  return -1;
7339  }
7340 
7341  string strHisPurse;
7342 
7343  if (VerifyExists("HisPurse")) {
7344  strHisPurse = HisPurse;
7345  }
7346  else {
7347  while (true) {
7348  otOut << "Enter the SHARES asset type ID (Nym must also be the "
7349  "issuer for these shares): ";
7350  string strHisPartialPurseID = OT_CLI_ReadLine();
7351 
7352  if (VerifyStringVal(strHisPartialPurseID)) {
7354  strHisPartialPurseID);
7355 
7356  if (!VerifyStringVal(strHisPurse)) {
7357  otOut << "\n\nFailure: Unable to find SHARES_ASSET_TYPE_ID "
7358  "in your wallet. Use: --hispurse "
7359  "SHARES_ASSET_TYPE_ID\n";
7360  return -1;
7361  }
7362  break;
7363  }
7364  }
7365  }
7366 
7367  string strAssetTypeID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(MyAcct);
7368 
7369  int64_t lAmount = OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount);
7370  string strResponse = MadeEasy::pay_dividend(Server, strMyNymID, MyAcct,
7371  strHisPurse, strMemo, lAmount);
7372  string strAttempt = "pay_dividend";
7373 
7374  int32_t nInterpretReply = InterpretTransactionMsgReply(
7375  Server, strMyNymID, MyAcct, strAttempt, strResponse);
7376 
7377  if (1 == nInterpretReply) {
7378  bool bRetrieved =
7379  MadeEasy::retrieve_account(Server, strMyNymID, MyAcct, true);
7380  otOut << (bRetrieved ? "Success" : "Failed")
7381  << " retrieving intermediary files for account.\n";
7382 
7383  otOut << "\n\nServer response (" << strAttempt
7384  << "): SUCCESS paying out dividends.\n";
7385  }
7386 
7387  return nInterpretReply;
7388 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT std::string Wallet_GetAssetIDFromPartial(const std::string &PARTIAL_ID)
Definition: OTAPI.cpp:631
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string HisPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string pay_dividend(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &SOURCE_ACCT_ID, const std::string &SHARES_ASSET_ID, const std::string &STR_MEMO, int64_t AMOUNT_PER_SHARE)
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_propose_plan ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strMyAcctID,
const std::string &  strHisNymID,
const std::string &  strHisAcctID,
const std::string &  strDates,
const std::string &  strConsideration,
const std::string &  strInitialPayment,
const std::string &  strPaymentPlan,
const std::string &  strExpiry 
)
static

Definition at line 1878 of file ot_commands_ot.cpp.

1884 {
1885  if (!VerifyStringVal(strConsideration)) {
1886  otOut << "Sorry, but you must describe the consideration to create a "
1887  "recurring payment plan.\n";
1888  return -1;
1889  }
1890 
1891  // Make sure strMyNymID aka recipient of money (aka sender of payment plan
1892  // instrument)
1893  // has enough transaction numbers to propose the plan in the first place.
1894  //
1895  if (!MadeEasy::insure_enough_nums(2, strServerID, strMyNymID)) {
1896  return -1;
1897  }
1898 
1899  // OTAPI_Wrap::EasyProposePlan is a version of ProposePaymentPlan that
1900  // compresses it into a
1901  // fewer number of arguments. (Then it expands them and calls
1902  // ProposePaymentPlan.)
1903  // Basically this version has ALL the same parameters, but it stuffs two or
1904  // three at a time into
1905  // a single parameter, as a comma-separated list in string form.
1906  // See details for each parameter, in the comment below.
1907  string strPlan = OTAPI_Wrap::EasyProposePlan(
1908  strServerID, strDates, strHisAcctID, strHisNymID, strConsideration,
1909  strMyAcctID, strMyNymID, strInitialPayment, strPaymentPlan, strExpiry);
1910 
1911  if (VerifyStringVal(strPlan)) {
1912  // The "propose" step (performed by the merchant) includes the
1913  // merchant's confirmation / signing.
1914  // (So there's no need for the merchant to additionally "confirm" the
1915  // plan before sending it -- he
1916  // already has done that by this point, just as part of the proposal
1917  // itself.)
1918 
1919  // Send the payment plan to the payer (the customer). If it fails,
1920  // harvest the transaction numbers
1921  // back from the payment plan. Return 1 if success.
1922 
1923  string strResponse = MadeEasy::send_user_payment(
1924  strServerID, strMyNymID, strHisNymID, strPlan);
1925  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
1926 
1927  if (1 != nMessageSuccess) {
1928  otOut << "For whatever reason, our attempt to send the payment "
1929  "plan on to the next user has failed.\n";
1930  int32_t nHarvested = OTAPI_Wrap::Msg_HarvestTransactionNumbers(
1931  strPlan, strMyNymID, false, false, false, false, false);
1932  otOut << "details_propose: OT_API_Msg_HarvestTransactionNumbers: "
1933  << nHarvested << "\n";
1934  return -1;
1935  }
1936  return nMessageSuccess;
1937  }
1938 
1939  return -1;
1940 }
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string EasyProposePlan(const std::string &SERVER_ID, const std::string &DATE_RANGE, const std::string &SENDER_ACCT_ID, const std::string &SENDER_USER_ID, const std::string &PLAN_CONSIDERATION, const std::string &RECIPIENT_ACCT_ID, const std::string &RECIPIENT_USER_ID, const std::string &INITIAL_PAYMENT, const std::string &PAYMENT_PLAN, const std::string &PLAN_EXPIRY)
Definition: OTAPI.cpp:1095
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
OT_COMMANDS_OT bool opentxs::OT_Command::details_refresh_nym ( const std::string &  strServerID,
const std::string &  strMyNymID,
bool  bForceDownload 
)
static

Definition at line 6245 of file ot_commands_ot.cpp.

6248 {
6249  bool bWasMsgSent = false;
6250  int32_t nGetAndProcessNymbox = MadeEasy::retrieve_nym(
6251  strServerID, strMyNymID, bWasMsgSent, bForceDownload);
6252  bool bReturnVal = false;
6253 
6254  switch (nGetAndProcessNymbox) {
6255  case 1:
6256  otOut << "\n\n SUCCESS in refresh nym!\n";
6257  bReturnVal = true;
6258  break;
6259  case 0:
6260  if (bWasMsgSent) {
6261  otOut << "\n\n FAILURE in refresh nym!\n";
6262  }
6263  else {
6264  otOut << "\n\n Success in refresh nym! (Skipped processing Nymbox, "
6265  "since it's empty.)\n";
6266  bReturnVal = true;
6267  }
6268  break;
6269  default:
6270  otOut << "\n\nError in refresh nym! nGetAndProcessNymbox: "
6271  << nGetAndProcessNymbox << "\n";
6272  break;
6273  }
6274 
6275  return bReturnVal;
6276 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT int32_t retrieve_nym(const std::string &strServerID, const std::string &strMyNymID, bool &bWasMsgSent, bool bForceDownload)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_send_cash ( std::string &  strResponse,
const std::string &  strServerID,
const std::string &  strAssetTypeID,
const std::string &  strMyNymID,
const std::string &  strMyAcctID,
std::string &  strHisNymID,
const std::string &  strMemo,
const std::string &  strAmount,
std::string &  strIndices,
bool  bPasswordProtected 
)
static

Definition at line 8625 of file ot_commands_ot.cpp.

8630 {
8631 
8632  string strLocation = "\n details_send_cash";
8633 
8634  int64_t lStartAmount = int64_t(0);
8635 
8636  if (VerifyStringVal(strAmount)) {
8637  lStartAmount = std::stoll(strAmount);
8638  }
8639 
8640  int64_t lAmount = lStartAmount;
8641 
8642  // What we want to do from here is, see if we can send the cash purely using
8643  // cash we already
8644  // have in the local purse.
8645  // If so, we just package it up and send it off using send_user_payment.
8646  //
8647  // But if we do NOT have the proper cash tokens in the local purse to send,
8648  // then we need to
8649  // withdraw enough tokens until we do, and then try sending again.
8650 
8651  bool bAmountFromIndices = VerifyStringVal(strIndices);
8652 
8653  bool bGotData = purse_get_indices_or_amount(
8654  strServerID, strAssetTypeID, strMyNymID, lAmount, strIndices);
8655 
8656  if (!bGotData) // NOT ENOUGH CASH FOUND IN EXISTING PURSE TO MATCH THE
8657  // AMOUNT (or indices were specified and not found.)
8658  {
8659  if (bAmountFromIndices) {
8660  // If we were starting out with indices, and those indices failed to
8661  // be found, then there's
8662  // nothing more we can do. They aren't there.
8663  otOut << strLocation
8664  << ": Sorry, those indices weren't found: " << strIndices
8665  << "\nPerhaps try: 'opentxs showpurse'\n";
8666  return -1;
8667  }
8668 
8669  // By this point, it means we started with the amount, and tried to use
8670  // it to find the
8671  // appropriate indices -- and they weren't there. This means we need to
8672  // withdraw more cash
8673  // from the server before we can send it, since we don't have enough in
8674  // our purse already.
8675  int32_t nWithdraw = details_withdraw_cash(strMyAcctID, lAmount);
8676 
8677  if (1 != nWithdraw) {
8678  otOut << strLocation << ": Tried to withdraw cash, but failed.\n";
8679  return -1;
8680  }
8681 
8682  // Okay we performed the withdrawal, so now let's see again if we can
8683  // extract the proper
8684  // cash tokens from the local purse. We'll load it up again...
8685  lAmount = lStartAmount;
8686 
8687  bGotData = purse_get_indices_or_amount(strServerID, strAssetTypeID,
8688  strMyNymID, lAmount, strIndices);
8689 
8690  if (!bGotData) {
8691  otOut << strLocation
8692  << ": Unable to get enough cash into the local purse to "
8693  "send, EVEN after performing a cash withdrawal. "
8694  "(Failure.)\n strIndices: " << strIndices << " lAmount: "
8695  << OTAPI_Wrap::FormatAmount(strAssetTypeID, lAmount) << "\n";
8696  return -1;
8697  }
8698  }
8699 
8700  // By this point, bGotData is definitely true, meaning there are already
8701  // enough cash tokens in the purse
8702  // to send, or there are now since performing a withdrawal. Either way, we
8703  // should be good to go...
8704 
8705  // Returns the exported cash purse, with strRetainedCopy containing the
8706  // sender's version of that.
8707  string strRetainedCopy = "";
8708  string strExportedCashPurse = details_export_cash(
8709  strServerID, strMyNymID, strAssetTypeID, strHisNymID, strIndices,
8710  bPasswordProtected, strRetainedCopy);
8711  int32_t nReturnVal = -1;
8712 
8713  if (VerifyStringVal(strExportedCashPurse)) {
8714  strResponse =
8715  MadeEasy::send_user_cash(strServerID, strMyNymID, strHisNymID,
8716  strExportedCashPurse, strRetainedCopy);
8717 
8718  nReturnVal = VerifyMessageSuccess(strResponse);
8719 
8720  if (1 != nReturnVal) {
8721  // It failed sending the cash to the recipient Nym.
8722  // Re-import strRetainedCopy back into the sender's cash purse.
8723  bool bImported = OTAPI_Wrap::Wallet_ImportPurse(
8724  strServerID, strAssetTypeID, strMyNymID, strRetainedCopy);
8725 
8726  if (bImported) {
8727  otOut << "\n\nFailed sending cash, but at least: success "
8728  "re-importing purse.\nServer: " << strServerID
8729  << "\nAsset Type: " << strAssetTypeID
8730  << "\nNym: " << strMyNymID << "\n\n";
8731  }
8732  else {
8733  otOut << "\n\n Failed sending cash AND failed re-importing "
8734  "purse.\nServer: " << strServerID
8735  << "\nAsset Type: " << strAssetTypeID
8736  << "\nNym: " << strMyNymID
8737  << "\n\nPurse (SAVE THIS SOMEWHERE!):\n\n"
8738  << strRetainedCopy << "\n";
8739  }
8740  }
8741  }
8742 
8743  return nReturnVal;
8744 }
EXPORT static OT_COMMANDS_OT bool purse_get_indices_or_amount(const std::string &strServerID, const std::string &strAssetTypeID, const std::string &strMyNymID, int64_t &lAmount, std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT bool Wallet_ImportPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID, const std::string &THE_PURSE)
Should handle duplicates. Should load, merge, and save.
Definition: OTAPI.cpp:1907
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT std::string send_user_cash(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT, const std::string &SENDERS_COPY)
EXPORT static OT_COMMANDS_OT std::string details_export_cash(const std::string &strServerID, const std::string &strFromNymID, const std::string &strAssetTypeID, std::string &strHisNymID, const std::string &strIndices, bool bPasswordProtected, std::string &strRetainedCopy)
EXPORT static OT_COMMANDS_OT int32_t details_withdraw_cash(const std::string &strMyAcctID, int64_t lAmount)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_send_transfer ( const std::string &  strMyAcctID,
const std::string &  strHisAcctID,
const std::string &  strAmount,
const std::string &  strNote 
)
static

Definition at line 3611 of file ot_commands_ot.cpp.

3615 {
3616  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
3617  if (!VerifyStringVal(strMyNymID)) {
3618  otOut << "Failure: Unable to find NymID (for sender) based on myacct. "
3619  "Use: --myacct ACCT_ID\n";
3620  otOut << "The designated asset account must be yours. OT will find the "
3621  "Nym based on the account.\n\n";
3622  return -1;
3623  }
3624  if (VerifyExists("MyNym", false) && !(MyNym == strMyNymID)) {
3625  otOut << "\n\nFailure: MyNym was provided (" << MyNym
3626  << "), but didn't match the Nym who owns MyAcct. To override, "
3627  "use: --mynym " << strMyNymID << "\n\n";
3628  return -1;
3629  }
3630 
3631  string strMyServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
3632  if (!VerifyStringVal(strMyServerID)) {
3633  otOut << "Failure: Unable to find ServerID based on myacct. Use: "
3634  "--myacct ACCT_ID\n";
3635  otOut << "The designated asset account must be yours. OT will find the "
3636  "Server based on the account.\n\n";
3637  return -1;
3638  }
3639  if (VerifyExists("Server", false) && !(Server == strMyServerID)) {
3640  otOut << "\n\nFailure: Server was provided (" << Server
3641  << "), but didn't match the Server where MyAcct is based. To "
3642  "override, use: --server " << strMyServerID << "\n\n";
3643  return -1;
3644  }
3645 
3646  // NEXT, we get the Server based on HIS account.
3647  //
3648  // That way, we can make sure both accounts are on the same server, before
3649  // we go riding off into the sunset sending transfer requests to the server.
3650  string strHisServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strHisAcctID);
3651  if (!VerifyStringVal(strHisServerID)) {
3652  otOut << "HisAcct is not in the wallet, so I'm assuming it's on the "
3653  "same server as MyAcct. (Proceeding.)\n";
3654 
3655  strHisServerID = strMyServerID;
3656  }
3657 
3658  if (!(strMyServerID == strHisServerID)) {
3659  otOut << "\n\nFailure: HisAcct is not on the same server as MyAcct "
3660  "(he's on " << strHisServerID << " but MyAcct is on "
3661  << strMyServerID
3662  << "). You must choose either a different sender account (using "
3663  "--myacct ACCT_ID) or a different recipient account (using "
3664  "--hisacct ACCT_ID)\n\n";
3665  return -1;
3666  }
3667 
3668  string strAssetTypeID =
3670 
3671  int64_t lAmount = OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount);
3672  string strResponse = MadeEasy::send_transfer(
3673  strMyServerID, strMyNymID, strMyAcctID, strHisAcctID, lAmount, strNote);
3674  string strAttempt = "send_transfer";
3675 
3676  int32_t nInterpretReply = InterpretTransactionMsgReply(
3677  strMyServerID, strMyNymID, strMyAcctID, strAttempt, strResponse);
3678 
3679  if (1 == nInterpretReply) {
3680  bool bRetrieved = MadeEasy::retrieve_account(strMyServerID, strMyNymID,
3681  strMyAcctID, true);
3682 
3683  otOut << "Server response (" << strAttempt
3684  << "): SUCCESS sending transfer!\n";
3685  otOut << (bRetrieved ? "Success" : "Failed")
3686  << " retrieving intermediary files for account.\n";
3687  }
3688 
3689  return nInterpretReply;
3690 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
std::string MyNym
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
EXPORT static OT_MADE_EASY_OT std::string send_transfer(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_FROM, const std::string &ACCT_TO, int64_t AMOUNT, const std::string &NOTE)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_basket ( )
static

Definition at line 75 of file ot_commands_ot.cpp.

76 {
77  int32_t nAssetCount = OTAPI_Wrap::GetAssetTypeCount();
78 
79  if (nAssetCount > 0) {
80  string strIndex = "";
81 
82  if (VerifyExists("Args", false)) {
83  string strTempIndex = OT_CLI_GetValueByKey(Args, "index");
84  if (VerifyStringVal(strTempIndex)) {
85  strIndex = strTempIndex;
86  }
87  }
88 
89  // Zoom in on a specific basket currency.
90  if (VerifyStringVal(strIndex)) {
91  int32_t nIndex = std::stol(strIndex);
92 
93  if (nIndex < 0 || nIndex >= nAssetCount) {
94  otOut << "Error: index out of bounds.\n";
95  return -1;
96  }
97  else {
98  string strAssetID = OTAPI_Wrap::GetAssetType_ID(nIndex);
99  if (!VerifyStringVal(strAssetID)) {
100  otOut << "ERROR: Failed getting asset type ID at index: "
101  << nIndex << "\n";
102  }
103  else {
104  string strAssetName =
105  OTAPI_Wrap::GetAssetType_Name(strAssetID);
106  if (!VerifyStringVal(strAssetName)) {
107  strAssetName = "";
108  }
109 
110  if (!OTAPI_Wrap::IsBasketCurrency(strAssetID)) {
111  otOut
112  << "Failure: not a basket currency: " << strAssetID
113  << " : " << strAssetName << "\n";
114  }
115  else {
116  // display all the details about this basket currency
117  cout << "Name: " << strAssetName << "\n";
118  cout << "ID: " << strAssetID << "\n";
119 
120  int32_t nMemberCount =
122 
123  if (0 > nMemberCount) {
124  otOut << "ERROR: expected int32_t return value "
125  "from "
126  "OT_API_Basket_GetMemberCount(strAssetID)"
127  "\n";
128  }
129  else if (nMemberCount <= 0) {
130  otOut << "Strange: this basket has " << nMemberCount
131  << " sub-currencies. (Expected 1 or more.)\n";
132  }
133  else {
134  int64_t nBasketMinTransAmt =
136  strAssetID);
137 
138  if (0 > nBasketMinTransAmt) {
139  otOut << "Strange: expected minimum transfer "
140  "amount for basket, but got bad value "
141  "instead.\n";
142  }
143  else {
144  cout << "Minimum transfer amount for basket: "
145  " " << nBasketMinTransAmt << "\n";
146  cout << "Number of sub-currencies in the "
147  "basket: " << nMemberCount << "\n";
148 
149  bool bFirstMember = true;
150 
151  for (int32_t nMemberIndex = 0;
152  nMemberIndex < nMemberCount;
153  ++nMemberIndex) {
154  string strMemberType =
156  strAssetID, nMemberIndex);
157  string strMemberName =
158  VerifyStringVal(strMemberType)
160  strMemberType)
161  : "";
162 
163  int64_t nMinTransAmt = OTAPI_Wrap::
165  strAssetID, nMemberIndex);
166 
167  if (bFirstMember) {
168  bFirstMember = false;
169 
170  otOut << " Index : Min Transfer "
171  "Amount : Member currency "
172  "\n---------------------------"
173  "----"
174  "--------\n";
175  }
176  cout << " " << nMemberIndex << " : "
177  << nMinTransAmt << " : "
178  << strMemberType << " : "
179  << strMemberName << "\n";
180  otOut << "---------------------------------"
181  "----"
182  "--\n";
183  }
184  }
185  }
186  }
187  }
188  }
189  return 1;
190  }
191 
192  bool bOnFirstIteration = true;
193  // List ALL the basket currencies.
194  for (int32_t nAssetIndex = 0; nAssetIndex < nAssetCount;
195  ++nAssetIndex) {
196  string strAssetID = OTAPI_Wrap::GetAssetType_ID(nAssetIndex);
197  if (VerifyStringVal(strAssetID) &&
198  OTAPI_Wrap::IsBasketCurrency(strAssetID)) {
199  if (bOnFirstIteration) {
200  bOnFirstIteration = false;
201  otOut << "Index | Basket "
202  "currencies:\n------------------------------------"
203  "\n";
204  }
205 
206  string strAssetName = OTAPI_Wrap::GetAssetType_Name(strAssetID);
207 
208  if (VerifyStringVal(strAssetName)) {
209  cout << nAssetIndex << ": " << strAssetID
210  << " : " + strAssetName << "\n";
211  }
212  else {
213  cout << nAssetIndex << ": " << strAssetID << "\n";
214  }
215  }
216  }
217  if (nAssetCount > 0) {
218  otOut << "\n";
219  }
220  }
221 
222  return -1;
223 }
static EXPORT int32_t Basket_GetMemberCount(const std::string &BASKET_ASSET_TYPE_ID)
Definition: OTAPI.cpp:1985
static EXPORT bool IsBasketCurrency(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1980
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Basket_GetMemberType(const std::string &BASKET_ASSET_TYPE_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:1990
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT int32_t GetAssetTypeCount()
Definition: OTAPI.cpp:521
static EXPORT int64_t Basket_GetMinimumTransferAmount(const std::string &BASKET_ASSET_TYPE_ID)
Definition: OTAPI.cpp:1996
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT std::string GetAssetType_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:904
static EXPORT int64_t Basket_GetMemberMinimumTransferAmount(const std::string &BASKET_ASSET_TYPE_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:2002
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT bool opentxs::OT_Command::details_show_credential ( const std::string &  strMyNymID,
const std::string &  strCredID 
)
static

Definition at line 1480 of file ot_commands_ot.cpp.

1482 {
1483  string strCredContents =
1484  OTAPI_Wrap::GetNym_CredentialContents(strMyNymID, strCredID);
1485 
1486  if (VerifyStringVal(strCredContents)) {
1487  otOut << "Master Credential contents:\n";
1488  cout << strCredContents << "\n";
1489  return true;
1490  }
1491 
1492  strCredContents =
1493  OTAPI_Wrap::GetNym_RevokedCredContents(strMyNymID, strCredID);
1494 
1495  if (VerifyStringVal(strCredContents)) {
1496  otOut << "Revoked Credential contents:\n";
1497  cout << strCredContents << "\n";
1498  return true;
1499  }
1500 
1501  // It MUST be a subcredential by this point, either for a master
1502  // or revoked master credential.
1503  bool bIsRevoked = false;
1504  string strMasterID = find_masterID_for_subcred(strMyNymID, strCredID);
1505 
1506  if (!VerifyStringVal(strMasterID)) {
1507  strMasterID = find_revokedID_for_subcred(strMyNymID, strCredID);
1508  bIsRevoked = true;
1509  }
1510 
1511  if (!VerifyStringVal(strMasterID)) {
1512  otOut << "Sorry, unable to find any credentials associated with that "
1513  "ID.\n";
1514  }
1515  else {
1516  strCredContents = OTAPI_Wrap::GetNym_SubCredentialContents(
1517  strMyNymID, strMasterID, strCredID);
1518 
1519  if (!VerifyStringVal(strCredContents)) {
1520  otOut << "Error retrieving sub-credential contents.\n";
1521  return false;
1522  }
1523 
1524  if (bIsRevoked) {
1525  otOut << "Revoked Subcredential contents:\n";
1526  }
1527  else {
1528  otOut << "Subcredential contents:\n";
1529  }
1530  cout << strCredContents << "\n";
1531  otOut << "\n";
1532  return true;
1533  }
1534  return false;
1535 }
EXPORT static OT_COMMANDS_OT std::string find_masterID_for_subcred(const std::string &strMyNymID, const std::string &strInputID)
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string GetNym_SubCredentialContents(const std::string &NYM_ID, const std::string &MASTER_CRED_ID, const std::string &SUB_CRED_ID)
Definition: OTAPI.cpp:433
static EXPORT std::string GetNym_RevokedCredContents(const std::string &NYM_ID, const std::string &CREDENTIAL_ID)
Definition: OTAPI.cpp:414
static EXPORT std::string GetNym_CredentialContents(const std::string &NYM_ID, const std::string &CREDENTIAL_ID)
Definition: OTAPI.cpp:397
EXPORT static OT_COMMANDS_OT std::string find_revokedID_for_subcred(const std::string &strMyNymID, const std::string &strInputID)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_credentials ( const std::string &  strMyNymID)
static

Definition at line 1572 of file ot_commands_ot.cpp.

1573 {
1574  int32_t nReturnVal = -1;
1575 
1576  int32_t nCredCount = OTAPI_Wrap::GetNym_CredentialCount(strMyNymID);
1577 
1578  if (0 > nCredCount) {
1579  return -1;
1580  }
1581 
1582  if (nCredCount >= 1) {
1583  nReturnVal = 1;
1584 
1585  otOut << "Idx Credential ID\n---------------------------\n";
1586 
1587  for (int32_t nCurrent = 0; nCurrent < nCredCount; ++nCurrent) {
1588  string strCredID =
1589  OTAPI_Wrap::GetNym_CredentialID(strMyNymID, nCurrent);
1590  cout << nCurrent << ": " << strCredID << "\n";
1591 
1592  int32_t nSubCredCount =
1593  OTAPI_Wrap::GetNym_SubcredentialCount(strMyNymID, strCredID);
1594 
1595  if (nSubCredCount >= 1) {
1596 
1597  otOut << " ---------------------------\n Idx "
1598  "Subcredential ID\n "
1599  "---------------------------\n";
1600 
1601  for (int32_t nCurrentSubCred = 0;
1602  nCurrentSubCred < nSubCredCount; ++nCurrentSubCred) {
1603  string strSubCredID = OTAPI_Wrap::GetNym_SubCredentialID(
1604  strMyNymID, strCredID, nCurrentSubCred);
1605  cout << " " << nCurrentSubCred << ": "
1606  << strSubCredID << "\n";
1607  }
1608  }
1609  }
1610 
1611  otOut << "\n";
1612  }
1613  else {
1614  nReturnVal = 0;
1615  }
1616 
1617  // Next: REVOKED credentials.
1618 
1619  nCredCount = OTAPI_Wrap::GetNym_RevokedCredCount(strMyNymID);
1620 
1621  if (0 > nCredCount) {
1622  return -1;
1623  }
1624 
1625  if (nCredCount >= 1) {
1626  nReturnVal = 1;
1627 
1628  otOut << "Idx Revoked Credential ID\n---------------------------\n";
1629 
1630  for (int32_t nCurrent = 0; nCurrent < nCredCount; ++nCurrent) {
1631  string strCredID =
1632  OTAPI_Wrap::GetNym_RevokedCredID(strMyNymID, nCurrent);
1633  cout << nCurrent << ": " << strCredID << "\n";
1634 
1635  int32_t nSubCredCount =
1636  OTAPI_Wrap::GetNym_SubcredentialCount(strMyNymID, strCredID);
1637 
1638  if (nSubCredCount >= 1) {
1639 
1640  otOut << " ---------------------------\n Idx "
1641  "Revoked Subcredential ID\n "
1642  "---------------------------\n";
1643 
1644  for (int32_t nCurrentSubCred = 0;
1645  nCurrentSubCred < nSubCredCount; ++nCurrentSubCred) {
1646  string strSubCredID = OTAPI_Wrap::GetNym_SubCredentialID(
1647  strMyNymID, strCredID, nCurrentSubCred);
1648  cout << " " << nCurrentSubCred << ": "
1649  << strSubCredID << "\n";
1650  }
1651  }
1652  }
1653 
1654  otOut << "\n";
1655  }
1656 
1657  return nReturnVal;
1658 }
static EXPORT std::string GetNym_SubCredentialID(const std::string &NYM_ID, const std::string &MASTER_CRED_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:426
OTLOG_IMPORT OTLogStream otOut
static EXPORT int32_t GetNym_RevokedCredCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:403
static EXPORT int32_t GetNym_CredentialCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:386
static EXPORT std::string GetNym_CredentialID(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:391
static EXPORT int32_t GetNym_SubcredentialCount(const std::string &NYM_ID, const std::string &MASTER_CRED_ID)
Definition: OTAPI.cpp:420
static EXPORT std::string GetNym_RevokedCredID(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:408
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_expired ( const std::string &  strServerID,
const std::string &  strMyNymID,
int32_t  nIndex,
const std::string &  strExpiredBox 
)
static

Definition at line 10188 of file ot_commands_ot.cpp.

10191 {
10192  if (!VerifyStringVal(strExpiredBox)) {
10193  otOut << "\n\n details_show_expired: strExpiredBox is empty.\n(Need to "
10194  "load it first before calling this function.)\n\n";
10195  return false;
10196  }
10197 
10198  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
10199  strServerID, strMyNymID, strMyNymID, strExpiredBox, nIndex);
10200  int64_t lTransID = OTAPI_Wrap::Ledger_GetTransactionIDByIndex(
10201  strServerID, strMyNymID, strMyNymID, strExpiredBox, nIndex);
10203  strServerID, strMyNymID, strMyNymID, strTrans);
10204  int64_t lAmount = OTAPI_Wrap::Transaction_GetAmount(strServerID, strMyNymID,
10205  strMyNymID, strTrans);
10206  string strType = OTAPI_Wrap::Transaction_GetType(strServerID, strMyNymID,
10207  strMyNymID, strTrans);
10208  string strSenderUserID = OTAPI_Wrap::Transaction_GetSenderUserID(
10209  strServerID, strMyNymID, strMyNymID, strTrans);
10210  string strSenderAcctID = OTAPI_Wrap::Transaction_GetSenderAcctID(
10211  strServerID, strMyNymID, strMyNymID, strTrans);
10212  string strRecipientUserID = OTAPI_Wrap::Transaction_GetRecipientUserID(
10213  strServerID, strMyNymID, strMyNymID, strTrans);
10214  string strRecipientAcctID = OTAPI_Wrap::Transaction_GetRecipientAcctID(
10215  strServerID, strMyNymID, strMyNymID, strTrans);
10216 
10217  string strUserID =
10218  VerifyStringVal(strSenderUserID) ? strSenderUserID : strRecipientUserID;
10219  string strAcctID =
10220  VerifyStringVal(strSenderAcctID) ? strSenderAcctID : strRecipientAcctID;
10221 
10222  bool bUserIDExists = VerifyStringVal(strUserID);
10223  bool bAcctIDExists = VerifyStringVal(strAcctID);
10224 
10225  string strNewlineSeparator = "";
10226 
10227  if (bUserIDExists || bAcctIDExists) {
10228  strNewlineSeparator = "\n |";
10229  }
10230 
10231  string strSeparator =
10232  (!bUserIDExists && !bAcctIDExists) ? "" : strNewlineSeparator;
10233 
10234  string strUserDenoter = (bUserIDExists ? "U:" : "");
10235  string strAcctDenoter = (bAcctIDExists ? "A:" : "");
10236 
10237  string strAssetTypeID =
10238  bAcctIDExists ? OTAPI_Wrap::GetAccountWallet_AssetTypeID(strAcctID)
10239  : "";
10240 
10241  string strAmount =
10242  OT_ERROR_AMOUNT != lAmount
10243  ? (VerifyStringVal(strAssetTypeID)
10244  ? OTAPI_Wrap::FormatAmount(strAssetTypeID, lAmount)
10245  : std::to_string(lAmount))
10246  : "UNKNOWN_AMOUNT";
10247 
10248  otOut << nIndex << " ";
10249  otOut << strAmount << (strAmount.size() < 3 ? " " : " ");
10250  otOut << strType << (strType.size() > 10 ? " " : " ");
10251  otOut << lTransID << (std::to_string(lTransID).size() < 2 ? " " : " ");
10252  otOut << lRefNum << (std::to_string(lRefNum).size() > 2 ? " " : " ")
10253  << "|";
10254  otOut << strUserDenoter << strUserID << strSeparator << strAcctDenoter
10255  << strAcctID << "\n";
10256 
10257  return true;
10258 }
std::string to_string(const T &t)
static EXPORT std::string Transaction_GetSenderAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1720
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT int64_t Transaction_GetAmount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1745
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string Transaction_GetRecipientAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1728
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
static EXPORT std::string Transaction_GetSenderUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1704
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Transaction_GetRecipientUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1712
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string Transaction_GetType(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Get Transaction Type (internally uses GetTransactionTypeString().)
Definition: OTAPI.cpp:1762
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_expired_records ( const std::string &  strServerID,
const std::string &  strMyNymID 
)
static

Definition at line 10261 of file ot_commands_ot.cpp.

10263 {
10264  string strExpiredBox = OTAPI_Wrap::LoadExpiredBox(strServerID, strMyNymID);
10265 
10266  if (!VerifyStringVal(strExpiredBox)) {
10267  otOut << "\n\n details_show_expired_records: OT_API_LoadExpiredBox: "
10268  "Failed.\n\n";
10269  return -1;
10270  }
10271 
10272  otOut << "\n\n";
10273 
10274  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(strServerID, strMyNymID,
10275  strMyNymID, strExpiredBox);
10276  if (0 > nCount) {
10277  return -1;
10278  }
10279 
10280  otOut << "SHOW EXPIRED RECORDS: \n\n";
10281  otOut << "Idx Amt Type Txn# InRef#|User / Acct\n";
10282  otOut << "---------------------------------|(from or to)\n";
10283 
10284  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
10285  if (!details_show_expired(strServerID, strMyNymID, nIndex,
10286  strExpiredBox)) {
10287  otOut << "details_show_expired_records: Error calling "
10288  "details_show_expired.\n";
10289  return -1;
10290  }
10291  }
10292 
10293  return 1;
10294 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t details_show_expired(const std::string &strServerID, const std::string &strMyNymID, int32_t nIndex, const std::string &strExpiredBox)
static EXPORT std::string LoadExpiredBox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1579
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_market_offers ( const std::string &  strServerID,
const std::string &  strMarketID 
)
static

Definition at line 6943 of file ot_commands_ot.cpp.

6945 {
6946  OTDB::OfferListMarket* offerListPtr =
6947  loadMarketOffers(strServerID, strMarketID);
6948 
6949  if (!offerListPtr) {
6950  otOut << "Unable to load up a (market) offerList from local storage.\n";
6951  return -1;
6952  }
6953  OTDB::OfferListMarket& offerList = *offerListPtr;
6954 
6955  // LOOP THROUGH THE BIDS AND PRINT THEM OUT.
6956  int32_t nBidCount = offerList.GetBidDataCount();
6957  int32_t nTemp = nBidCount;
6958 
6959  if (nBidCount > 0) {
6960  otOut << "\n** BIDS **\n\nIndex\tTrans#\tPrice\tAvailable\n";
6961 
6962  for (int32_t nIndex = 0; nIndex < nBidCount; ++nIndex) {
6963  OTDB::BidData* offerDataPtr = offerList.GetBidData(nIndex);
6964  if (!offerDataPtr) {
6965  otOut << "Unable to reference bidData on offerList, at index: "
6966  << nIndex << "\n";
6967  return -1;
6968  }
6969  OTDB::BidData& offerData = *offerDataPtr;
6970 
6971  // OUTPUT THE BID OFFER DATA...
6972  cout << nIndex << "\t" << offerData.transaction_id << "\t"
6973  << offerData.price_per_scale << "\t"
6974  << offerData.available_assets << "\n";
6975  }
6976  }
6977 
6978  // LOOP THROUGH THE ASKS AND PRINT THEM OUT.
6979  int32_t nAskCount = offerList.GetAskDataCount();
6980 
6981  if (nAskCount > 0) {
6982  otOut << "\n** ASKS **\n\nIndex\tTrans#\tPrice\tAvailable\n";
6983 
6984  for (int32_t nIndex = 0; nIndex < nAskCount; ++nIndex) {
6985  nTemp = nIndex;
6986  OTDB::AskData* offerDataPtr = offerList.GetAskData(nTemp);
6987 
6988  if (!offerDataPtr) {
6989  otOut << "Unable to reference askData on offerList, at index: "
6990  << nIndex << "\n";
6991  return -1;
6992  }
6993  OTDB::AskData& offerData = *offerDataPtr;
6994 
6995  // OUTPUT THE ASK OFFER DATA...
6996  cout << nIndex << "\t" << offerData.transaction_id << "\t"
6997  << offerData.price_per_scale << "\t"
6998  << offerData.available_assets << "\n";
6999  }
7000  }
7001 
7002  return 1;
7003 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT OTDB::OfferListMarket * loadMarketOffers(const std::string &strerverID, const std::string &strMarketID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_nym_offers ( const std::string &  strServerID,
const std::string &  strNymID 
)
static

Definition at line 7222 of file ot_commands_ot.cpp.

7224 {
7225  string strLocation = "details_show_nym_offers";
7226 
7227  OTDB::OfferListNym* offerListPtr = loadNymOffers(strServerID, strNymID);
7228 
7229  if (!offerListPtr) {
7230  otOut << strLocation << ": Unable to load up a (nym) offerList from "
7231  "local storage. Probably doesn't exist.\n";
7232  return -1;
7233  }
7234  OTDB::OfferListNym& offerList = *offerListPtr;
7235 
7236  // LOOP THROUGH THE OFFERS and sort them into a map_of_maps, key is:
7237  // scale-assetID-currencyID
7238  // the value for each key is a sub-map, with the key: transaction ID and
7239  // value: the offer data itself.
7240  int32_t nCount = offerList.GetOfferDataNymCount();
7241  if (nCount > 0) {
7242  MapOfMaps* map_of_mapsPtr = convert_offerlist_to_maps(offerList);
7243 
7244  if (!map_of_mapsPtr) {
7245  otOut << strLocation << ": Unable to convert offer list to map of "
7246  "offers. Perhaps it's empty?\n";
7247  return -1;
7248  }
7249  MapOfMaps& map_of_maps = *map_of_mapsPtr;
7250 
7251  // output_nymoffer_data is called for each offer, for this nym,
7252  // as it iterates through the maps.
7253  //
7254  // iterate_nymoffers_maps takes a final parameter extra_vals (not seen
7255  // here)
7256  // Other sections in the code which use iterate_nymoffers_maps might
7257  // pass a value
7258  // here, or expect one to be returned through the same mechansim.
7259  int32_t nIterated =
7261 
7262  if (-1 == nIterated) {
7263  otOut << strLocation << ": Error trying to iterate nym's offers.\n";
7264  return -1;
7265  }
7266  }
7267 
7268  return 1;
7269 }
EXPORT OT_OTAPI_OT MapOfMaps * convert_offerlist_to_maps(opentxs::OTDB::OfferListNym &offerList)
EXPORT OT_OTAPI_OT int32_t output_nymoffer_data(const opentxs::OTDB::OfferDataNym &offer_data, int32_t nIndex, const MapOfMaps &map_of_maps, const SubMap &sub_map, the_lambda_struct &extra_vals)
OTLOG_IMPORT OTLogStream otOut
EXPORT OT_OTAPI_OT opentxs::OTDB::OfferListNym * loadNymOffers(const std::string &serverID, const std::string &nymID)
std::map< std::string, SubMap * > MapOfMaps
EXPORT OT_OTAPI_OT int32_t iterate_nymoffers_maps(MapOfMaps &map_of_maps, LambdaFunc the_lambda)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_record ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strMyAcctID,
int32_t  nIndex,
const std::string &  strRecordBox 
)
static

Definition at line 9812 of file ot_commands_ot.cpp.

9816 {
9817  if (!VerifyStringVal(strRecordBox)) {
9818  otOut << "\n\n details_show_record: strRecordBox is empty.\n(Need to "
9819  "load it first before calling this function.)\n\n";
9820  return false;
9821  }
9822 
9823  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
9824  strServerID, strMyNymID, strMyAcctID, strRecordBox, nIndex);
9825  int64_t lTransID = OTAPI_Wrap::Ledger_GetTransactionIDByIndex(
9826  strServerID, strMyNymID, strMyAcctID, strRecordBox, nIndex);
9828  strServerID, strMyNymID, strMyAcctID, strTrans);
9829  int64_t lAmount = OTAPI_Wrap::Transaction_GetAmount(strServerID, strMyNymID,
9830  strMyAcctID, strTrans);
9831  string strType = OTAPI_Wrap::Transaction_GetType(strServerID, strMyNymID,
9832  strMyAcctID, strTrans);
9833  string strSenderUserID = OTAPI_Wrap::Transaction_GetSenderUserID(
9834  strServerID, strMyNymID, strMyAcctID, strTrans);
9835  string strSenderAcctID = OTAPI_Wrap::Transaction_GetSenderAcctID(
9836  strServerID, strMyNymID, strMyAcctID, strTrans);
9837  string strRecipientUserID = OTAPI_Wrap::Transaction_GetRecipientUserID(
9838  strServerID, strMyNymID, strMyAcctID, strTrans);
9839  string strRecipientAcctID = OTAPI_Wrap::Transaction_GetRecipientAcctID(
9840  strServerID, strMyNymID, strMyAcctID, strTrans);
9841 
9842  string strUserID =
9843  VerifyStringVal(strSenderUserID) ? strSenderUserID : strRecipientUserID;
9844  string strAcctID =
9845  VerifyStringVal(strSenderAcctID) ? strSenderAcctID : strRecipientAcctID;
9846 
9847  bool bUserIDExists = VerifyStringVal(strUserID);
9848  bool bAcctIDExists = VerifyStringVal(strAcctID);
9849 
9850  string strNewlineSeparator = "";
9851 
9852  if (bUserIDExists || bAcctIDExists) {
9853  strNewlineSeparator = "\n |";
9854  }
9855 
9856  string strSeparator =
9857  (!bUserIDExists && !bAcctIDExists) ? "" : strNewlineSeparator;
9858 
9859  string strUserDenoter = (bUserIDExists ? "U:" : "");
9860  string strAcctDenoter = (bAcctIDExists ? "A:" : "");
9861 
9862  string strAssetTypeID =
9863  bAcctIDExists ? OTAPI_Wrap::GetAccountWallet_AssetTypeID(strAcctID)
9864  : "";
9865 
9866  bool bHasAmount = OT_ERROR_AMOUNT != lAmount;
9867  bool bHasAsset = VerifyStringVal(strAssetTypeID);
9868 
9869  string strAmount =
9870  bHasAmount
9871  ? (bHasAsset ? OTAPI_Wrap::FormatAmount(strAssetTypeID, lAmount)
9872  : std::to_string(lAmount))
9873  : "UNKNOWN_AMOUNT";
9874 
9875  otOut << nIndex << " ";
9876  otOut << strAmount << (strAmount.size() < 3 ? " " : " ");
9877  otOut << strType << (strType.size() > 10 ? " " : " ");
9878  otOut << lTransID << (std::to_string(lTransID).size() < 2 ? " " : " ");
9879  otOut << lRefNum << (std::to_string(lRefNum).size() > 2 ? " " : " ")
9880  << "|";
9881  otOut << strUserDenoter << strUserID << strSeparator << strAcctDenoter
9882  << strAcctID << "\n";
9883 
9884  return true;
9885 }
std::string to_string(const T &t)
static EXPORT std::string Transaction_GetSenderAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1720
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT int64_t Transaction_GetAmount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1745
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string Transaction_GetRecipientAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1728
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
static EXPORT std::string Transaction_GetSenderUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1704
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Transaction_GetRecipientUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1712
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string Transaction_GetType(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Get Transaction Type (internally uses GetTransactionTypeString().)
Definition: OTAPI.cpp:1762
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_show_records ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strMyAcctID 
)
static

Definition at line 9888 of file ot_commands_ot.cpp.

9891 {
9892  string strRecordBox =
9893  OTAPI_Wrap::LoadRecordBox(strServerID, strMyNymID, strMyAcctID);
9894 
9895  if (!VerifyStringVal(strRecordBox)) {
9896  otOut << "\n\n details_show_records: OT_API_LoadRecordBox: Failed.\n\n";
9897  return -1;
9898  }
9899 
9900  otOut << "\n\n";
9901 
9902  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(strServerID, strMyNymID,
9903  strMyAcctID, strRecordBox);
9904  if (0 > nCount) {
9905  return -1;
9906  }
9907 
9908  otOut << "SHOW RECORDS: \n\n";
9909  otOut << "Idx Amt Type Txn# InRef#|User / Acct\n";
9910  otOut << "---------------------------------|(from or to)\n";
9911 
9912  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
9913  if (!details_show_record(strServerID, strMyNymID, strMyAcctID, nIndex,
9914  strRecordBox)) {
9915  otOut
9916  << "details_show_records: Error calling details_show_record.\n";
9917  return -1;
9918  }
9919  }
9920 
9921  return 1;
9922 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string LoadRecordBox(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID)
NOTE: Sometimes the user ID is also passed in the &quot;account ID&quot; field,.
Definition: OTAPI.cpp:1565
EXPORT static OT_COMMANDS_OT int32_t details_show_record(const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID, int32_t nIndex, const std::string &strRecordBox)
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_stat_account ( const std::string &  strID)
static

Definition at line 5392 of file ot_commands_ot.cpp.

5393 {
5394 
5395  otOut << "\n\n-------------------------------------------------------------"
5396  "-----\n";
5397 
5398  string strStatAcct = MadeEasy::stat_asset_account(strID);
5399 
5400  bool bSuccess = VerifyStringVal(strStatAcct);
5401  int32_t nSuccess = (bSuccess ? 1 : -1);
5402 
5403  if (bSuccess) {
5404  cout << strStatAcct << "\n";
5405  }
5406  else {
5407  cout << "Error trying to stat an asset account: " << strID << "\n\n";
5408  }
5409 
5410  otOut << "\n";
5411 
5412  return nSuccess;
5413 }
EXPORT static OT_MADE_EASY_OT std::string stat_asset_account(const std::string &ACCOUNT_ID)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_trigger_clause ( const std::string &  strServerID,
const std::string &  strMyNymID,
const std::string &  strTransNum,
const std::string &  strClause,
const std::string &  strParam 
)
static

Definition at line 1317 of file ot_commands_ot.cpp.

1320 {
1321  string strResponse = MadeEasy::trigger_clause(
1322  strServerID, strMyNymID, strTransNum, strClause, strParam);
1323  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
1324 
1325  if (1 != nMessageSuccess) {
1326  otOut << "For whatever reason, our attempt to trigger the clause has "
1327  "failed.\n";
1328  }
1329  else {
1330  otOut << "Success!\n";
1331  }
1332 
1333  return nMessageSuccess;
1334 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
EXPORT static OT_MADE_EASY_OT std::string trigger_clause(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &STR_TRANS_NUM, const std::string &CLAUSE_NAME, const std::string &STR_PARAM)
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_withdraw_cash ( const std::string &  strMyAcctID,
int64_t  lAmount 
)
static

Definition at line 6418 of file ot_commands_ot.cpp.

6420 {
6421  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
6422  if (!VerifyStringVal(strMyNymID)) {
6423  otOut << "Failure: Unable to find NymID based on myacct. Use: --myacct "
6424  "ACCT_ID\n";
6425  otOut << "The designated asset account must be yours. OT will find the "
6426  "Nym based on the account.\n\n";
6427  return -1;
6428  }
6429 
6430  string strAssetTypeID =
6432  if (!VerifyStringVal(strAssetTypeID)) {
6433  otOut << "Failure: Unable to find Asset Type ID based on myacct. Use: "
6434  "--myacct ACCT_ID\n";
6435  otOut << "The designated asset account must be yours. OT will find the "
6436  "asset type based on the account.\n\n";
6437  return -1;
6438  }
6439 
6440  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
6441  if (!VerifyStringVal(strServerID)) {
6442  otOut << "Unable to find the server ID based on the account. Strange! "
6443  "Perhaps specify a different account? Use: --myacct ACCT_ID "
6444  "\n";
6445  return -1;
6446  }
6447 
6448  if ((VerifyExists("Server", false) && !(strServerID == Server))) {
6449  otOut << "This account is on server ( " << strServerID
6450  << " -- the server is deduced based on the account), but the "
6451  "default server is ( " << Server
6452  << " ). To override it, use: --server " << strServerID << " \n";
6453  return -1;
6454  }
6455 
6456  string assetContract = OTAPI_Wrap::LoadAssetContract(strAssetTypeID);
6457  if (!VerifyStringVal(assetContract)) {
6458  string strResponse = MadeEasy::retrieve_contract(
6459  strServerID, strMyNymID, strAssetTypeID);
6460 
6461  if (1 != VerifyMessageSuccess(strResponse)) {
6462  otOut << "details_withdraw_cash: Unable to retrieve contract for "
6463  "IDs: \n";
6464  otOut << " Server ID: " << strServerID << "\n";
6465  otOut << " Asset ID: " << strAssetTypeID << "\n";
6466  return -1;
6467  }
6468 
6469  assetContract = OTAPI_Wrap::LoadAssetContract(strAssetTypeID);
6470  if (!VerifyStringVal(assetContract)) {
6471  otOut << "Failure: Unable to load Asset contract even after "
6472  "retrieving it.\n";
6473  return -1;
6474  }
6475  }
6476  // By this point, we KNOW the appropriate asset contract is available.
6477 
6478  string strMint = MadeEasy::load_or_retrieve_mint(strServerID, strMyNymID,
6479  strAssetTypeID);
6480 
6481  if (!VerifyStringVal(strMint)) {
6482  otOut << "Failure: Unable to load or retrieve necessary mint file for "
6483  "withdrawal.\n";
6484  return -1;
6485  }
6486  // By this point, we know we can successfully load both:
6487  // 1. the proper asset contract.
6488  // 2. the proper (unexpired) mint file.
6489 
6490  string strResponse =
6491  MadeEasy::withdraw_cash(strServerID, strMyNymID, strMyAcctID, lAmount);
6492  string strAttempt = "withdraw_cash";
6493 
6494  int32_t nInterpretReply = InterpretTransactionMsgReply(
6495  strServerID, strMyNymID, strMyAcctID, strAttempt, strResponse);
6496 
6497  if (1 == nInterpretReply) {
6498  bool bRetrieved = MadeEasy::retrieve_account(strServerID, strMyNymID,
6499  strMyAcctID, false);
6500 
6501  otOut << "\n\nServer response (" << strAttempt
6502  << "): SUCCESS withdrawing cash! (From account on server to "
6503  "local purse.) \n";
6504  otOut << (bRetrieved ? "Success" : "Failed")
6505  << " retrieving intermediary files for account.\n";
6506  }
6507 
6508  return nInterpretReply;
6509 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT std::string LoadAssetContract(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1482
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string withdraw_cash(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, int64_t AMOUNT)
EXPORT static OT_MADE_EASY_OT std::string retrieve_contract(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &CONTRACT_ID)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_mint(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ID)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_withdraw_voucher ( std::string &  strOutput)
static

Definition at line 6571 of file ot_commands_ot.cpp.

6572 {
6573  if (!VerifyExists("HisNym")) {
6574  return -1;
6575  }
6576 
6577  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
6578  if (!VerifyStringVal(strMyNymID)) {
6579  otOut << "\n\nFailure: Unable to find NymID based on myacct. Use: "
6580  "--myacct ACCT_ID\nThe designated asset account must be "
6581  "yours. OT will find the Nym based on the account.\n\n";
6582  return -1;
6583  }
6584 
6585  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
6586  if (!VerifyStringVal(strServerID)) {
6587  otOut << "\n\nFailure: Unable to find the server ID based on myacct. "
6588  "Use: --myacct ACCT_ID\nThe designated asset account must be "
6589  "yours. OT will find the server ID based on the account.\n\n";
6590  return -1;
6591  }
6592 
6593  string strRecipientPubkey =
6594  MadeEasy::load_or_retrieve_encrypt_key(strServerID, strMyNymID, HisNym);
6595  if (!VerifyStringVal(strRecipientPubkey)) {
6596  otOut << "\n\nFailure: Unable to load or download pubkey for HisNym "
6597  "based on given value (" << HisNym
6598  << "). To override, use: --hisnym HIS_NYM_ID\n\n";
6599  return -1;
6600  }
6601 
6602  string strAmount = "0";
6603  string strMemo = "";
6604 
6605  string strDefaultAmount = "1";
6606  string strDefaultMemo = "(blank memo field)";
6607 
6608  // If custom arguments have been passed on the command line,
6609  // then grab them and use them instead of asking the user to enter them
6610  // at the command line.
6611  string strAssetTypeID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(MyAcct);
6612 
6613  if (VerifyExists("Args", false)) {
6614  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
6615  string strNewMemo = OT_CLI_GetValueByKey(Args, "memo");
6616 
6617  // Set the values based on the custom arguments, for those found.
6618  if (VerifyStringVal(strNewAmount)) {
6619  strAmount = strNewAmount;
6620  }
6621  if (VerifyStringVal(strNewMemo)) {
6622  strMemo = strNewMemo;
6623  }
6624  }
6625 
6626  // If the transfer parameters aren't provided, then we
6627  // ask the user to supply them at the command line.
6628  if (!VerifyStringVal(strAmount) ||
6629  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
6630  otOut << "Enter the amount[" << strDefaultAmount << "]: ";
6631  strAmount = OT_CLI_ReadLine();
6632  }
6633  if (!VerifyStringVal(strMemo)) {
6634  otOut << "Optionally, enter a memo on a single line[" << strDefaultMemo
6635  << "]: ";
6636  strMemo = OT_CLI_ReadLine();
6637  }
6638 
6639  if (!VerifyStringVal(strAmount) ||
6640  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
6641  strAmount = strDefaultAmount;
6642  }
6643  if (!VerifyStringVal(strMemo)) {
6644  strMemo = strDefaultMemo;
6645  }
6646 
6647  int64_t lAmount = OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount);
6648  string strResponse = MadeEasy::withdraw_voucher(
6649  strServerID, strMyNymID, MyAcct, HisNym, strMemo, lAmount);
6650  string strAttempt = "withdraw_voucher";
6651 
6652  int32_t nInterpretReply = InterpretTransactionMsgReply(
6653  strServerID, strMyNymID, MyAcct, strAttempt, strResponse);
6654 
6655  if (1 == nInterpretReply) {
6656 
6657  string strLedger = OTAPI_Wrap::Message_GetLedger(strResponse);
6658 
6659  if (!VerifyStringVal(strLedger)) {
6660  otOut << "\n\n details_withdraw_voucher: Error: strLedger is null, "
6661  "returned by OT_API_Message_GetLedger.\n";
6662  return -1;
6663  }
6664 
6665  string strTransReply = OTAPI_Wrap::Ledger_GetTransactionByIndex(
6666  strServerID, strMyNymID, MyAcct, strLedger, 0);
6667 
6668  if (!VerifyStringVal(strTransReply)) {
6669  otOut << "details_withdraw_voucher: Error: strTransReply is "
6670  "unexpectedly null, returned by "
6671  "OT_API_Ledger_GetTransactionByIndex, argument passed, "
6672  "index 0 and ledger:\n\n" << strLedger << "\n\n";
6673  return -1;
6674  }
6675 
6676  strOutput = OTAPI_Wrap::Transaction_GetVoucher(strServerID, strMyNymID,
6677  MyAcct, strTransReply);
6678 
6679  if (!VerifyStringVal(strOutput)) {
6680  otOut << "details_withdraw_voucher: Error: Voucher is unexpectedly "
6681  "null, returned by OT_API_Transaction_GetVoucher with "
6682  "strTransReply set to:\n\n" << strTransReply << "\n\n";
6683  return -1;
6684  }
6685  else {
6686  // Save a copy in my own outpayments box. I don't want to lose this
6687  // voucher since it uses
6688  // one of my own transaction numbers. (If I later send the voucher
6689  // to someone, OT is smart
6690  // enough to remove the first copy from outpayments, when adding the
6691  // second copy.)
6692  //
6693  // Notice how I can send an instrument to myself. This doesn't
6694  // actually send anything --
6695  // it just puts a copy into my outpayments box for safe-keeping.
6696  MadeEasy::send_user_payment(strServerID, strMyNymID, strMyNymID,
6697  strOutput);
6698  }
6699 
6700  bool bRetrieved =
6701  MadeEasy::retrieve_account(strServerID, strMyNymID, MyAcct, true);
6702  otOut << (bRetrieved ? "Success" : "Failed")
6703  << " retrieving intermediary files for account.\n";
6704 
6705  otOut << "details_withdraw_voucher: Voucher returned by "
6706  "OT_API_Transaction_GetVoucher:\n\n";
6707  cout << strOutput << "\n";
6708  otOut << "\n\n";
6709 
6710  otOut << "\n\nServer response (" << strAttempt
6711  << "): SUCCESS withdrawing voucher (cashier's cheque)!\n";
6712 
6713  return 1;
6714  }
6715 
6716  return nInterpretReply;
6717 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string withdraw_voucher(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &RECIP_NYM_ID, const std::string &STR_MEMO, int64_t AMOUNT)
OT_UTILITY_OT int32_t InterpretTransactionMsgReply(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strAttempt, const string &strResponse)
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_encrypt_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
static EXPORT std::string Message_GetLedger(const std::string &THE_MESSAGE)
Definition: OTAPI.cpp:2396
std::string HisNym
static EXPORT std::string Transaction_GetVoucher(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1696
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::details_write_cheque ( std::string &  strCheque,
bool  bIsInvoice 
)
static

Definition at line 4038 of file ot_commands_ot.cpp.

4039 {
4040  Utility MsgUtil;
4041 
4042  if (VerifyExists("MyAcct")) {
4043 
4044  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
4045  if (!VerifyStringVal(strMyNymID)) {
4046  otOut << "Failure: Unable to find NymID (for sender) based on "
4047  "myacct. Use: --myacct ACCT_ID\n";
4048  otOut << "The designated asset account must be yours. OT will find "
4049  "the Nym based on the account.\n\n";
4050  return -1;
4051  }
4052  if (VerifyExists("MyNym", false) && !(MyNym == strMyNymID)) {
4053  otOut << "\n\nFailure: MyNym was provided (" << MyNym
4054  << "), but didn't match the Nym who owns MyAcct. To "
4055  "override, use: --mynym " << strMyNymID << "\n\n";
4056  return -1;
4057  }
4058 
4059  string strMyServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
4060  if (!VerifyStringVal(strMyServerID)) {
4061  otOut << "Failure: Unable to find ServerID based on myacct. Use: "
4062  "--myacct ACCT_ID\n";
4063  otOut << "The designated asset account must be yours. OT will find "
4064  "the Server based on the account.\n\n";
4065  return -1;
4066  }
4067  if (VerifyExists("Server", false) && !(Server == strMyServerID)) {
4068  otOut << "\n\nFailure: Server was provided (" << Server
4069  << "), but didn't match the Server where MyAcct is based. To "
4070  "override, use: --server " << strMyServerID << "\n\n";
4071  return -1;
4072  }
4073  //
4074  // When we pass in HisNym at the command line, using this option:
4075  // --hisnym HIS_NYM_ID
4076  // then OT internally TRIES to look it up on the wallet (and someday on
4077  // the address
4078  // book as well) in abbreviated or name form, in order to substitute it
4079  // with the ACTUAL
4080  // full NymID, before passing it into the script where we are now. If
4081  // nothing is found,
4082  // then it just passes through the ID so we have a chance to download
4083  // the pubkey and
4084  // verify that it actually exists.
4085  //
4086  // Therefore, if the full "HisNym" ID hasn't ALREADY been found by now,
4087  // that means we
4088  // already couldn't find it via abbreviation or name, and therefore we
4089  // will HAVE to download
4090  // it from the server since we don't have it already. (And therefore we
4091  // will NEED to know the
4092  // FULL ID, since we cannot download a pubkey from a server based on a
4093  // partial ID.)
4094  //
4095  // The point is that when we get here, there's no need to worry about
4096  // searching for a partial
4097  // or abbreviated version, and no need to ask load_or_retrieve_pubkey to
4098  // somehow translate HisNym
4099  // to a full ID. That would have already happened by now, if one were
4100  // available. So at this point
4101  // we basically have to assume the user passed the full and correct ID,
4102  // and if it's not in the
4103  // wallet already, then load_or_retrieve_pubkey can go ahead and try to
4104  // download it as if it is
4105  // the full and correct ID. If it fails, it fails.
4106  string strRecipientPubkey = "";
4107  string strHisNymID = "";
4108 
4109  if (VerifyExists("HisNym", false)) {
4110  strRecipientPubkey = MadeEasy::load_or_retrieve_encrypt_key(
4111  strMyServerID, strMyNymID, HisNym);
4112  // Note: even thogh send_user_payment already calls
4113  // load_or_retrieve_pubkey, we do it
4114  // here anyway, BEFORE trying to write the cheque. (No point writing
4115  // a cheque to HisNym until
4116  // we're sure it's real...)
4117  if (!VerifyStringVal(strRecipientPubkey)) {
4118  otOut << "\n\nFailure: Unable to load or download pubkey for "
4119  "HisNym based on given value (" << HisNym
4120  << "). To override, use: --hisnym HIS_NYM_ID\n\n";
4121  return -1;
4122  }
4123 
4124  strHisNymID = HisNym;
4125  }
4126 
4127  // Make sure we have at least one transaction number (to write the
4128  // cheque...)
4129  if (!MadeEasy::insure_enough_nums(10, strMyServerID, strMyNymID)) {
4130  return -1;
4131  }
4132 
4133  // - At this point we have MyAcct writing a cheque to HisNym.
4134  // - We have strMyServerID and strMyNymID and we know they match MyAcct.
4135  // (And we know they match --server and --mynym as well, otherwise the
4136  // user would have been be forced to override at the command line before
4137  // allowing him to continue.)
4138  // - We know that HisNym is a valid enough ID that we were able to load
4139  // his public key, or download it and THEN load it up. By this point it
4140  // was
4141  // successful either way.
4142  // - We know that the Nym has at least 1 valid transaction number, with
4143  // which to write the cheque. (If he didn't, we would have downloaded it
4144  // in
4145  // the above block.)
4146  // - Therefore let's collect all the other cheque-related data, and
4147  // write
4148  // the actual cheque, and return it to the caller.
4149 
4150  string strDefaultAmount = "1";
4151  string strDefaultMemo = "(memo field)";
4152  int64_t nDefaultLength =
4154 
4155  string strAmount = "0";
4156  string strMemo = "";
4157  int64_t nLength = OTTimeGetSecondsFromTime(OT_TIME_ZERO);
4158 
4159  string strAssetTypeID =
4161 
4162  if (VerifyExists("Args")) {
4163  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
4164  string strNewMemo = OT_CLI_GetValueByKey(Args, "memo");
4165  string strNewLength = OT_CLI_GetValueByKey(Args, "validfor");
4166 
4167  if (VerifyStringVal(strNewMemo)) {
4168  strMemo = strNewMemo;
4169  }
4170 
4171  if (VerifyStringVal(strNewAmount) &&
4172  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strNewAmount) >
4173  0)) {
4174  strAmount = strNewAmount;
4175  }
4176 
4177  if (VerifyStringVal(strNewLength) &&
4178  (std::stol(strNewLength) > 0)) {
4179  nLength = std::stol(strNewLength);
4180  }
4181  }
4182 
4183  // If the transfer parameters aren't provided, then we
4184  // ask the user to supply them at the command line.
4185  if (!VerifyStringVal(strAmount) ||
4186  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
4187  otOut << "Enter the amount[" << strDefaultAmount << "]: ";
4188  strAmount = OT_CLI_ReadLine();
4189  }
4190  if (!VerifyStringVal(strMemo)) {
4191  otOut << "Optionally, enter a note on a single line["
4192  << strDefaultMemo << "]: ";
4193  strMemo = OT_CLI_ReadLine();
4194  }
4195  if (nLength < 1) {
4196  otOut << "Enter the 'valid for' time period, in seconds (default "
4197  "is 30 days.) [" << nDefaultLength << "]: ";
4198  string strTemp = OT_CLI_ReadLine();
4199 
4200  if (VerifyStringVal(strTemp) && (std::stol(strTemp) > 0)) {
4201  nLength = std::stol(strTemp);
4202  }
4203  }
4204 
4205  if (!VerifyStringVal(strAmount) ||
4206  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
4207  strAmount = strDefaultAmount;
4208  }
4209 
4210  if (!VerifyStringVal(strMemo)) {
4211  strMemo = strDefaultMemo;
4212  }
4213 
4214  if (nLength < 1) {
4215  nLength = nDefaultLength;
4216  }
4217 
4218  // Todo: use Args feature here to allow an option to override nLength.
4219  // If it's not used, go with the default of 30 days (above.)
4220 
4221  string strLength = std::to_string(nLength);
4222 
4223  time64_t tFrom = OTAPI_Wrap::GetTime();
4224  int64_t tLength = std::stoll(strLength);
4225  time64_t tTo = OTTimeAddTimeInterval(tFrom, tLength);
4226 
4227  if (bIsInvoice) {
4228  int64_t lTempAmount =
4229  (int64_t(-1) *
4230  OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount));
4231  strAmount = OTAPI_Wrap::FormatAmount(strAssetTypeID, lTempAmount);
4232  }
4233 
4234  int64_t lAmount = OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount);
4235 
4236  strCheque =
4237  OTAPI_Wrap::WriteCheque(strMyServerID, lAmount, tFrom, tTo, MyAcct,
4238  strMyNymID, strMemo, strHisNymID);
4239 
4240  // Record it in the records?
4241  // Update: We wouldn't record that here. Instead,
4242  // OTAPI_Wrap::WriteCheque should drop a notice
4243  // into the payments outbox, the same as it does when you "sendcheque"
4244  // (after all, the same
4245  // resolution would be expected once it is cashed.)
4246 
4247  return 1;
4248  }
4249 
4250  return -1;
4251 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string to_string(const T &t)
time64_t OTTimeAddTimeInterval(time64_t lhs, int64_t rhs)
Definition: Common.hpp:238
std::string Server
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
OTLOG_IMPORT OTLogStream otOut
#define OT_TIME_MONTH_IN_SECONDS
Definition: Common.hpp:174
int64_t time64_t
Definition: Common.hpp:209
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_encrypt_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string HisNym
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
#define OT_TIME_ZERO
Definition: Common.hpp:180
EXPORT static OT_MADE_EASY_OT bool insure_enough_nums(int32_t nNumberNeeded, const std::string &strMyServerID, const std::string &strMyNymID)
std::string MyAcct
static EXPORT std::string WriteCheque(const std::string &SERVER_ID, const int64_t &CHEQUE_AMOUNT, const time64_t &VALID_FROM, const time64_t &VALID_TO, const std::string &SENDER_ACCT_ID, const std::string &SENDER_USER_ID, const std::string &CHEQUE_MEMO, const std::string &RECIPIENT_USER_ID)
Definition: OTAPI.cpp:1057
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::download_acct_files ( )
static

Definition at line 6068 of file ot_commands_ot.cpp.

6069 {
6070  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
6071  if (!VerifyStringVal(strMyNymID)) {
6072  otOut << "Failure: Unable to find NymID based on myacct. Use: --myacct "
6073  "ACCT_ID\n";
6074  otOut << "The designated asset account must be yours. OT will find the "
6075  "Nym based on the account.\n\n";
6076  return -1;
6077  }
6078 
6079  bool bRetrieved =
6080  MadeEasy::retrieve_account(Server, strMyNymID, MyAcct, true);
6081 
6082  otOut << "\n\n" << (bRetrieved ? "Success" : "Failed")
6083  << " retrieving intermediary files for account: " << MyAcct << "\n\n";
6084 
6085  return bRetrieved ? 1 : -1;
6086 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT bool retrieve_account(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCOUNT_ID, bool bForceDownload)
std::string MyAcct
OT_COMMANDS_OT string opentxs::OT_Command::find_masterID_for_subcred ( const std::string &  strMyNymID,
const std::string &  strInputID 
)
static

Definition at line 1442 of file ot_commands_ot.cpp.

1444 {
1445  int32_t nCredCount = OTAPI_Wrap::GetNym_CredentialCount(strMyNymID);
1446 
1447  if (0 > nCredCount) {
1448  return "";
1449  }
1450  else if (nCredCount >= 1) {
1451  for (int32_t nCurrent = 0; nCurrent < nCredCount; ++nCurrent) {
1452  string strCredID =
1453  OTAPI_Wrap::GetNym_CredentialID(strMyNymID, nCurrent);
1454 
1455  int32_t nSubCredCount =
1456  OTAPI_Wrap::GetNym_SubcredentialCount(strMyNymID, strCredID);
1457 
1458  if (nSubCredCount >= 1) {
1459  for (int32_t nCurrentSubCred = 0;
1460  nCurrentSubCred < nSubCredCount; ++nCurrentSubCred) {
1461  string strSubCredID = OTAPI_Wrap::GetNym_SubCredentialID(
1462  strMyNymID, strCredID, nCurrentSubCred);
1463 
1464  if (strInputID == strSubCredID) {
1465  return strCredID;
1466  }
1467  }
1468  }
1469  }
1470  }
1471  return "";
1472 }
static EXPORT std::string GetNym_SubCredentialID(const std::string &NYM_ID, const std::string &MASTER_CRED_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:426
static EXPORT int32_t GetNym_CredentialCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:386
static EXPORT std::string GetNym_CredentialID(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:391
static EXPORT int32_t GetNym_SubcredentialCount(const std::string &NYM_ID, const std::string &MASTER_CRED_ID)
Definition: OTAPI.cpp:420
OT_COMMANDS_OT string opentxs::OT_Command::find_revokedID_for_subcred ( const std::string &  strMyNymID,
const std::string &  strInputID 
)
static

Definition at line 1409 of file ot_commands_ot.cpp.

1411 {
1412  int32_t nCredCount = OTAPI_Wrap::GetNym_RevokedCredCount(strMyNymID);
1413 
1414  if (0 > nCredCount) {
1415  return "";
1416  }
1417  else if (nCredCount >= 1) {
1418  for (int32_t nCurrent = 0; nCurrent < nCredCount; ++nCurrent) {
1419  string strCredID =
1420  OTAPI_Wrap::GetNym_RevokedCredID(strMyNymID, nCurrent);
1421 
1422  int32_t nSubCredCount =
1423  OTAPI_Wrap::GetNym_SubcredentialCount(strMyNymID, strCredID);
1424 
1425  if (nSubCredCount >= 1) {
1426  for (int32_t nCurrentSubCred = 0;
1427  nCurrentSubCred < nSubCredCount; ++nCurrentSubCred) {
1428  string strSubCredID = OTAPI_Wrap::GetNym_SubCredentialID(
1429  strMyNymID, strCredID, nCurrentSubCred);
1430 
1431  if (strInputID == strSubCredID) {
1432  return strCredID;
1433  }
1434  }
1435  }
1436  }
1437  }
1438  return "";
1439 }
static EXPORT std::string GetNym_SubCredentialID(const std::string &NYM_ID, const std::string &MASTER_CRED_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:426
static EXPORT int32_t GetNym_RevokedCredCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:403
static EXPORT int32_t GetNym_SubcredentialCount(const std::string &NYM_ID, const std::string &MASTER_CRED_ID)
Definition: OTAPI.cpp:420
static EXPORT std::string GetNym_RevokedCredID(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:408
OT_COMMANDS_OT int32_t opentxs::OT_Command::handle_payment_index ( const std::string &  strMyAcctID,
int32_t  nIndex,
const std::string &  strPaymentType,
const std::string &  strInbox 
)
static

Definition at line 8776 of file ot_commands_ot.cpp.

8779 {
8780  if (!VerifyStringVal(strMyAcctID)) {
8781  otOut << "Failure: strMyAcctID not a valid string.\n";
8782  return -1;
8783  }
8784 
8785  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
8786  if (!VerifyStringVal(strMyNymID)) {
8787  otOut << "Failure: Unable to find NymID based on myacct. Use: --myacct "
8788  "ACCT_ID\n";
8789  otOut << "The designated asset account must be yours. OT will find the "
8790  "Nym based on the account.\n\n";
8791  return -1;
8792  }
8793 
8794  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
8795  if (!VerifyStringVal(strServerID)) {
8796  otOut << "Failure: Unable to find Server ID based on myacct. Use: "
8797  "--myacct ACCT_ID\n";
8798  otOut << "The designated asset account must be yours. OT will find the "
8799  "Server based on the account.\n\n";
8800  return -1;
8801  }
8802  string strInstrument = "";
8803 
8804  if (-1 == nIndex) {
8805  otOut << "Please paste the instrument, followed by an EOF or a ~ by "
8806  "itself on a blank line:\n\n";
8807  strInstrument = OT_CLI_ReadUntilEOF();
8808 
8809  if (!VerifyStringVal(strInstrument)) {
8810  otOut << "\n\n Sorry, You must paste the instrument, in order to "
8811  "process it. Or, specify an index in the\npayments inbox "
8812  "using the option: --args \"index "
8813  "INDEX_OF_INVOICE\".\n\n";
8814  return -1;
8815  }
8816  }
8817  else {
8818  strInstrument = MadeEasy::get_payment_instrument(
8819  strServerID, strMyNymID, nIndex, strInbox);
8820 
8821  if (!VerifyStringVal(strInstrument)) {
8822  otOut << "\n\n Unable to get payment instrument based on index: "
8823  << nIndex << ".\n\n";
8824  return -1;
8825  }
8826  }
8827 
8828  // By this point, strInstrument is a valid string (whether we got it from
8829  // the payments inbox,
8830  // or whether we got it from stdin.)
8831  string strType = OTAPI_Wrap::Instrmnt_GetType(strInstrument);
8832 
8833  if (!VerifyStringVal(strType)) {
8834  otOut << "\n\nFailure: Unable to determine strInstrument's type. "
8835  "Expected CHEQUE, VOUCHER, INVOICE, or (cash) PURSE.\n";
8836  return -1;
8837  }
8838 
8839  string strIndexErrorMsg = "";
8840 
8841  if (-1 != nIndex) {
8842  strIndexErrorMsg = "at index " + std::to_string(nIndex) + " ";
8843  }
8844 
8845  // If there's a payment type,
8846  // and it's not "ANY", and it's the wrong type,
8847  // then skip this one.
8848  if (VerifyStringVal(strPaymentType) && (strPaymentType != "ANY") &&
8849  (strPaymentType != strType)) {
8850  if ((("CHEQUE" == strPaymentType) && ("VOUCHER" == strType)) ||
8851  (("VOUCHER" == strPaymentType) && ("CHEQUE" == strType))) {
8852  // in this case we allow it to drop through.
8853  }
8854  else {
8855  otOut << "The instrument " << strIndexErrorMsg << "is not a "
8856  << strPaymentType << ". (It's a " << strType
8857  << ". Skipping.)\n";
8858  return -1;
8859  }
8860  }
8861 
8862  // Note: I USED to check the ASSET TYPE ID here, but then I removed it,
8863  // since
8864  // details_deposit_cheque() already verifies that (so I don't need to do it
8865  // twice.)
8866 
8867  // By this point, we know the invoice has the right asset type for the
8868  // account
8869  // we're trying to use (to pay it from.)
8870  //
8871  // But we need to make sure the invoice is made out to strMyNymID (or to no
8872  // one.)
8873  // Because if it IS endorsed to a Nym, and strMyNymID is NOT that nym, then
8874  // the
8875  // transaction will fail. So let's check, before we bother sending it...
8876  string strRecipientUserID =
8878 
8879  // Not all instruments have a specified recipient. But if they do, let's
8880  // make
8881  // sure the Nym matches.
8882  if (VerifyStringVal(strRecipientUserID) &&
8883  (strRecipientUserID != strMyNymID)) {
8884  otOut << "The instrument " << strIndexErrorMsg
8885  << "is endorsed to a specific recipient (" << strRecipientUserID
8886  << ") and that doesn't match the account's owner Nym ("
8887  << strMyNymID << "). (Skipping.)\nTry specifying a different "
8888  "account, using --myacct ACCT_ID \n";
8889  return -1;
8890  }
8891 
8892  // At this point I know the invoice isn't made out to anyone, or if it is,
8893  // it's properly
8894  // made out to the owner of the account which I'm trying to use to pay the
8895  // invoice from.
8896  // So let's pay it! P.S. strRecipientUserID might be nullptr, but
8897  // strMyNymID is guaranteed to be good.
8898 
8899  string strInstrumentAssetType =
8900  OTAPI_Wrap::Instrmnt_GetAssetID(strInstrument);
8901  string strAccountAssetID =
8903 
8904  if (VerifyStringVal(strInstrumentAssetType) &&
8905  (strAccountAssetID != strInstrumentAssetType)) {
8906  otOut << "The instrument at index " << nIndex
8907  << " has a different asset type than the selected account. "
8908  "(Skipping.)\nTry specifying a different account, using "
8909  "--myacct ACCT_ID \n";
8910  return -1;
8911  }
8912 
8913  time64_t tFrom = OTAPI_Wrap::Instrmnt_GetValidFrom(strInstrument);
8914  time64_t tTo = OTAPI_Wrap::Instrmnt_GetValidTo(strInstrument);
8915  time64_t tTime = OTAPI_Wrap::GetTime();
8916 
8917  if (tTime < tFrom) {
8918  otOut << "The instrument at index " << nIndex
8919  << " is not yet within its valid date range. (Skipping.)\n";
8920  return -1;
8921  }
8922  if (tTo > OT_TIME_ZERO && tTime > tTo) {
8923  otOut << "The instrument at index " << nIndex
8924  << " is expired. (Moving it to the record box.)\n";
8925 
8926  // Since this instrument is expired, remove it from the payments inbox,
8927  // and move to record box.
8928 
8929  // Note: this harvests
8930  if ((nIndex >= 0) && OTAPI_Wrap::RecordPayment(strServerID, strMyNymID,
8931  true, nIndex, true)) {
8932  return 0;
8933  }
8934 
8935  return -1;
8936  }
8937 
8938  // TODO, IMPORTANT: After the below deposits are completed successfully, the
8939  // wallet
8940  // will receive a "successful deposit" server reply. When that happens, OT
8941  // (internally)
8942  // needs to go and see if the deposited item was a payment in the payments
8943  // inbox. If so,
8944  // it should REMOVE it from that box and move it to the record box.
8945  //
8946  // That's why you don't see me messing with the payments inbox even when
8947  // these are successful.
8948  // They DO need to be removed from the payments inbox, but just not here in
8949  // the script. (Rather,
8950  // internally by OT itself.)
8951  if ("CHEQUE" == strType || "VOUCHER" == strType || "INVOICE" == strType) {
8952  return details_deposit_cheque(strServerID, strMyAcctID, strMyNymID,
8953  strInstrument, strType);
8954  }
8955 
8956  if ("PURSE" == strType) {
8957  int32_t nDepositPurse = details_deposit_purse(
8958  strServerID, strMyAcctID, strMyNymID, strInstrument, "");
8959 
8960  // if nIndex != -1, go ahead and call RecordPayment on the purse at
8961  // that index, to
8962  // remove it from payments inbox and move it to the recordbox.
8963  if ((nIndex != -1) && (1 == nDepositPurse)) {
8964  OTAPI_Wrap::RecordPayment(strServerID, strMyNymID, true, nIndex,
8965  true);
8966  }
8967 
8968  return nDepositPurse;
8969  }
8970 
8971  otOut << "\nSkipping this instrument: Expected CHEQUE, VOUCHER, INVOICE, "
8972  "or (cash) PURSE.\n";
8973 
8974  return -1;
8975 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT static OT_MADE_EASY_OT std::string get_payment_instrument(const std::string &SERVER_ID, const std::string &NYM_ID, int32_t nIndex, const std::string &PRELOADED_INBOX)
std::string to_string(const T &t)
EXPORT static OT_COMMANDS_OT int32_t details_deposit_purse(const std::string &strServerID, const std::string &strMyAcct, const std::string &strFromNymID, const std::string &strInstrument, const std::string &strIndices)
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
EXPORT static OT_COMMANDS_OT int32_t details_deposit_cheque(const std::string &strServerID, const std::string &strMyAcct, const std::string &strMyNymID, const std::string &strInstrument, const std::string &strType)
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool RecordPayment(const std::string &SERVER_ID, const std::string &USER_ID, const bool &bIsInbox, const int32_t &nIndex, const bool &bSaveCopy)
Definition: OTAPI.cpp:1591
static EXPORT time64_t Instrmnt_GetValidFrom(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:803
int64_t time64_t
Definition: Common.hpp:209
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
#define OT_TIME_ZERO
Definition: Common.hpp:180
static EXPORT time64_t Instrmnt_GetValidTo(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:808
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::impl_show_market_offers ( std::string &  strMarket)
static

Definition at line 7005 of file ot_commands_ot.cpp.

7006 {
7007  otOut << "Usage: showoffers --server SERVER_ID --mynym "
7008  "YOUR_NYM_ID\nAlso: --args \"market MARKET_ID\"\n";
7009 
7010  if (VerifyExists("Server")) {
7011 
7012  // If custom arguments have been passed on the command line,
7013  // then grab them and use them instead of asking the user to enter them
7014  // at the command line.
7015  if (!VerifyStringVal(strMarket) && VerifyExists("Args", false)) {
7016  string strNewMarket = OT_CLI_GetValueByKey(Args, "market");
7017 
7018  // Set the values based on the custom arguments, for those found.
7019  if (VerifyStringVal(strNewMarket)) {
7020  strMarket = strNewMarket;
7021  }
7022  }
7023 
7024  // If the transfer parameters aren't provided, then we
7025  // ask the user to supply them at the command line.
7026  if (!VerifyStringVal(strMarket)) {
7028 
7029  otOut << "\nEnter the market ID: ";
7030  strMarket = OT_CLI_ReadLine();
7031  }
7032 
7033  if (!VerifyStringVal(strMarket)) {
7034  return -1;
7035  }
7036 
7037  return details_show_market_offers(Server, strMarket);
7038  }
7039 
7040  return -1;
7041 }
EXPORT static OT_COMMANDS_OT int32_t mainShowMarkets()
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t details_show_market_offers(const std::string &strServerID, const std::string &strMarketID)
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_COMMANDS_OT OTDB::MarketList * opentxs::OT_Command::loadMarketList ( const std::string &  strerverID)
static

Definition at line 6805 of file ot_commands_ot.cpp.

6807 {
6808  if (!OTDB::Exists("markets", serverID, "market_data.bin", "")) {
6809  otOut << "The market list file doesn't exist.\n";
6810  return nullptr;
6811  }
6812 
6813  otWarn << "Markets file exists...Querying list of markets...\n";
6814 
6815  OTDB::Storable* storable =
6816  OTDB::QueryObject(OTDB::STORED_OBJ_MARKET_LIST, "markets", serverID,
6817  "market_data.bin", "");
6818  if (nullptr == storable) {
6819  otOut << "Failed to verify storable object. Probably doesn't exist.\n";
6820  return nullptr;
6821  }
6822 
6823  otWarn << "QueryObject worked. Now dynamic casting from storable to "
6824  "marketlist...\n";
6825 
6826  OTDB::MarketList* marketList = dynamic_cast<OTDB::MarketList*>(storable);
6827  if (nullptr == marketList) {
6828  otOut << "Unable to dynamic cast a storable to a marketlist.\n";
6829  return nullptr;
6830  }
6831 
6832  return marketList;
6833 
6834  // This WAS a "load or create" sort of function, but I commented out the
6835  // "create" part because
6836  // you will literally NEVER need to create this list.
6837 }
OTLOG_IMPORT OTLogStream otOut
EXPORT Storable * QueryObject(StoredObjectType theObjectType, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:788
OTLOG_IMPORT OTLogStream otWarn
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
OT_COMMANDS_OT OTDB::OfferListMarket * opentxs::OT_Command::loadMarketOffers ( const std::string &  strerverID,
const std::string &  strMarketID 
)
static

Definition at line 6911 of file ot_commands_ot.cpp.

6913 {
6914  OTDB::OfferListMarket* offerList = nullptr;
6915 
6916  if (OTDB::Exists("markets", serverID, "offers", marketID + ".bin")) {
6917  otWarn << "Offers file exists... Querying file for market offers...\n";
6918  OTDB::Storable* storable =
6920  serverID, "offers", marketID + ".bin");
6921 
6922  if (nullptr == storable) {
6923  otOut << "Unable to verify storable object. Probably doesn't "
6924  "exist.\n";
6925  return nullptr;
6926  }
6927 
6928  otWarn << "QueryObject worked. Now dynamic casting from storable to a "
6929  "(market) offerList...\n";
6930  offerList = dynamic_cast<OTDB::OfferListMarket*>(storable);
6931 
6932  if (nullptr == offerList) {
6933  otOut << "Unable to dynamic cast a storable to a (market) "
6934  "offerList.\n";
6935  return nullptr;
6936  }
6937  }
6938 
6939  return offerList;
6940 }
OTLOG_IMPORT OTLogStream otOut
EXPORT Storable * QueryObject(StoredObjectType theObjectType, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:788
OTLOG_IMPORT OTLogStream otWarn
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptAll ( )
static

Definition at line 5949 of file ot_commands_ot.cpp.

5950 {
5951  otOut << "Usage: acceptall --myacct INTO_ACCT\n";
5952 
5953  if (VerifyExists("MyAcct")) {
5954  string strIndices = "";
5955 
5956  // Incoming transfers and receipts (asset account inbox.)
5957  int32_t nAcceptedInbox = accept_inbox_items(MyAcct, 0, strIndices);
5958 
5959  // Incoming payments -- cheques, purses, vouchers (payments inbox for
5960  // nym)
5961  int32_t nAcceptedPurses =
5962  accept_from_paymentbox(MyAcct, strIndices, "PURSE");
5963 
5964  int32_t nAcceptedCheques =
5965  accept_from_paymentbox(MyAcct, strIndices, "CHEQUE");
5966 
5967  // Invoices LAST (so the MOST money is in the account before it starts
5968  // paying out.)
5969  int32_t nAcceptedInvoices =
5970  accept_from_paymentbox(MyAcct, strIndices, "INVOICE");
5971 
5972  if (nAcceptedInbox >= 0 && nAcceptedPurses >= 0 &&
5973  nAcceptedCheques >= 0 && nAcceptedInvoices >= 0) {
5974  return 1;
5975  }
5976  }
5977 
5978  return -1;
5979 }
EXPORT static OT_COMMANDS_OT int32_t accept_inbox_items(const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t accept_from_paymentbox(const std::string &strMyAcctID, const std::string &strIndices, const std::string &strPaymentType)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptInbox ( )
static

Definition at line 5880 of file ot_commands_ot.cpp.

5881 {
5882  otOut << "Usage: acceptinbox --myacct FOR_ACCT --args \"indices 3,6,8\" "
5883  "\n (Sample indices are shown.)\nIf indices are not specified for "
5884  "myacct's inbox, then OT will\naccept ALL transfers and receipts "
5885  "in that box.\n\n";
5886 
5887  if (VerifyExists("MyAcct")) {
5888  string strIndices = "";
5889 
5890  if (VerifyExists("Args", false)) {
5891  strIndices = OT_CLI_GetValueByKey(Args, "indices");
5892  }
5893 
5894  return accept_inbox_items(MyAcct, 0, strIndices);
5895  }
5896 
5897  return -1;
5898 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t accept_inbox_items(const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string Args
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptInvoices ( )
static

Definition at line 9058 of file ot_commands_ot.cpp.

9059 {
9060  otOut << "Usage: acceptinvoices --myacct FROM_ACCT --args \"indices "
9061  "3,6,8\" \n (Sample indices are shown.)\nThe invoice and myacct "
9062  "must both have same asset type. If indices\nare not specified "
9063  "for the payments inbox, then OT will pay ALL invoices in "
9064  "it\nthat have the same asset type as MyAcct.\n\n";
9065 
9066  if (VerifyExists("MyAcct")) {
9067  string strIndices = "";
9068 
9069  if (VerifyExists("Args", false)) {
9070  strIndices = OT_CLI_GetValueByKey(Args, "indices");
9071  }
9072 
9073  return details_accept_invoices(MyAcct, strIndices);
9074  }
9075 
9076  return -1;
9077 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string Args
EXPORT static OT_COMMANDS_OT int32_t details_accept_invoices(const std::string &strMyAcctID, const std::string &strIndices)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptMoney ( )
static

Definition at line 5922 of file ot_commands_ot.cpp.

5923 {
5924  otOut << "Usage: acceptmoney --myacct INTO_ACCT\n";
5925 
5926  if (VerifyExists("MyAcct")) {
5927  string strIndices = "";
5928 
5929  int32_t nAcceptedTransfers = accept_inbox_items(MyAcct, 1, strIndices);
5930 
5931  int32_t nAcceptedPurses =
5932  accept_from_paymentbox(MyAcct, strIndices, "PURSE");
5933 
5934  int32_t nAcceptedCheques =
5935  accept_from_paymentbox(MyAcct, strIndices, "CHEQUE");
5936 
5937  // FIX: these OR's should become AND's so we can detect any failure
5938  if (nAcceptedTransfers >= 0 || nAcceptedPurses >= 0 ||
5939  nAcceptedCheques >= 0) {
5940  return 1;
5941  }
5942  }
5943 
5944  return -1;
5945 }
EXPORT static OT_COMMANDS_OT int32_t accept_inbox_items(const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t accept_from_paymentbox(const std::string &strMyAcctID, const std::string &strIndices, const std::string &strPaymentType)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptPayments ( )
static

Definition at line 9098 of file ot_commands_ot.cpp.

9099 {
9100  otOut << "Usage: acceptpayments --myacct INTO_ACCT --args \"indices "
9101  "3,6,8\" \n (Sample indices are shown.)\nThe payment instrument "
9102  "and myacct must both have same asset type. If indices\nare not "
9103  "specified for the payments inbox, then OT will accept ALL "
9104  "payment\ninstruments in it that have the same asset type as "
9105  "MyAcct.\n\n";
9106 
9107  if (VerifyExists("MyAcct")) {
9108  string strIndices = "";
9109 
9110  if (VerifyExists("Args", false)) {
9111  strIndices = OT_CLI_GetValueByKey(Args, "indices");
9112  }
9113 
9114  return details_accept_payments(MyAcct, strIndices);
9115  }
9116 
9117  return -1;
9118 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t details_accept_payments(const std::string &strMyAcctID, const std::string &strIndices)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string Args
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptReceipts ( )
static

Definition at line 5860 of file ot_commands_ot.cpp.

5861 {
5862  otOut << "Usage: acceptreceipts --myacct FOR_ACCT --args \"indices "
5863  "3,6,8\" \n (Sample indices are shown.)\nIf indices are not "
5864  "specified for myacct's inbox, then OT will\naccept ALL receipts "
5865  "(but no pending transfers) in that box.\n\n";
5866 
5867  if (VerifyExists("MyAcct")) {
5868  string strIndices = "";
5869 
5870  if (VerifyExists("Args", false)) {
5871  strIndices = OT_CLI_GetValueByKey(Args, "indices");
5872  }
5873 
5874  return accept_inbox_items(MyAcct, 2, strIndices);
5875  }
5876 
5877  return -1;
5878 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t accept_inbox_items(const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string Args
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAcceptTransfers ( )
static

Definition at line 5900 of file ot_commands_ot.cpp.

5901 {
5902  otOut << "Usage: accepttransfers --myacct FOR_ACCT --args \"indices "
5903  "3,6,8\" \n (Sample indices are shown.)\nIf indices are not "
5904  "specified for myacct's inbox, then OT will\naccept ALL transfers "
5905  "(but no receipts) in that box.\n\n";
5906 
5907  if (VerifyExists("MyAcct")) {
5908  string strIndices = "";
5909 
5910  if (VerifyExists("Args", false)) {
5911  strIndices = OT_CLI_GetValueByKey(Args, "indices");
5912  }
5913 
5914  return accept_inbox_items(MyAcct, 1, strIndices);
5915  }
5916 
5917  return -1;
5918 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t accept_inbox_items(const std::string &strMyAcctID, int32_t nItemType, const std::string &strIndices)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string Args
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAddAsset ( )
static

Definition at line 11161 of file ot_commands_ot.cpp.

11162 {
11163  otOut << "Please paste a currency contract, followed by an EOF or a ~ by "
11164  "itself on a blank line:\n\n";
11165  string strContract = OT_CLI_ReadUntilEOF();
11166 
11167  if (!VerifyStringVal(strContract)) {
11168  otOut << "\n\n Sorry, You must input a currency contract, in order to "
11169  "add it to your wallet.\n\n";
11170  return -1;
11171  }
11172 
11173  int32_t nAdded = OTAPI_Wrap::AddAssetContract(strContract);
11174 
11175  if (1 != nAdded) {
11176  otOut << "\n\n Sorry, failed. Are you sure that was an asset "
11177  "contract?\n\n";
11178  return -1;
11179  }
11180 
11181  otOut << "\n\n Success adding asset contract to your wallet.\n\n";
11182  return 1;
11183 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT int32_t AddAssetContract(const std::string &strContract)
Definition: OTAPI.cpp:506
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAddServer ( )
static

Definition at line 11137 of file ot_commands_ot.cpp.

11138 {
11139  otOut << "Please paste a server contract, followed by an EOF or a ~ by "
11140  "itself on a blank line:\n\n";
11141  string strContract = OT_CLI_ReadUntilEOF();
11142 
11143  if (!VerifyStringVal(strContract)) {
11144  otOut << "\n\n Sorry, You must input a server contract, in order to "
11145  "add it to your wallet.\n\n";
11146  return -1;
11147  }
11148 
11149  int32_t nAdded = OTAPI_Wrap::AddServerContract(strContract);
11150 
11151  if (1 != nAdded) {
11152  otOut << "\n\n Sorry, failed. Are you sure that was a server "
11153  "contract?\n\n";
11154  return -1;
11155  }
11156 
11157  otOut << "\n\n Success adding server contract to your wallet.\n\n";
11158  return 1;
11159 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT int32_t AddServerContract(const std::string &strContract)
Definition: OTAPI.cpp:501
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAddSignature ( )
static

Definition at line 5071 of file ot_commands_ot.cpp.

5072 {
5073  // SignContract erases all signatures and affixes a new one alone.
5074  // But AddSignature, on the other hand, leaves all signatures in place, and
5075  // simply adds yours to the list.
5076 
5077  if (VerifyExists("MyNym")) {
5078 
5079  otOut << "Please enter an already-signed contract you wish to add your "
5080  "signature to, followed by an EOF or a ~ by itself on a blank "
5081  "line:\n\n";
5082  string strInput = OT_CLI_ReadUntilEOF();
5083 
5084  otOut << "\n\n You entered:\n" << strInput << "\n\n";
5085 
5086  string strOutput = OTAPI_Wrap::AddSignature(MyNym, strInput);
5087 
5088  otOut << "-------------------------------------------\nSigned:\n\n";
5089 
5090  cout << strOutput << "\n";
5091 
5092  otOut << "\n\n";
5093 
5094  return 1;
5095  }
5096 
5097  return -1;
5098 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string AddSignature(const std::string &SIGNER_NYM_ID, const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1000
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainAdjustUsageCredits ( )
static

Definition at line 7118 of file ot_commands_ot.cpp.

7119 {
7120  otOut << "\n\n Options: --server SERVER_ID --mynym NYM_ID\n "
7121  "--hisnym SUBJECT_NYM_ID\n\nTo adjust (change) a Nym's usage "
7122  "credits: --args \"adjust POSITIVE_OR_NEGATIVE_VALUE\" \n (Used "
7123  "for giving or taking away usage credits.)\nFor example, --args "
7124  "\"adjust 10000\" or: --args \"adjust -100\" \n\nFYI, this "
7125  "command also retrieves the current usage credits,\nand any Nym "
7126  "can use it on himself, read-only.\n\n";
7127 
7128  if (VerifyExists("Server") && VerifyExists("MyNym") &&
7129  VerifyExists("HisNym")) {
7130  string strAdjustment = "0";
7131 
7132  if (VerifyExists("Args", false)) {
7133  string strNewAdjust = OT_CLI_GetValueByKey(Args, "adjust");
7134 
7135  if (VerifyStringVal(strNewAdjust)) {
7136  strAdjustment = strNewAdjust;
7137  }
7138  }
7139 
7140  string strResponse = MadeEasy::adjust_usage_credits(
7141  Server, MyNym, HisNym, strAdjustment);
7142  int32_t nStatus = VerifyMessageSuccess(strResponse);
7143  switch (nStatus) {
7144  case 1: {
7145  otOut << "\n\n Server response:\n\n";
7146  cout << strResponse << "\n";
7147 
7148  // IF THE_MESSAGE is of command type @usageCredits, and IF it was a
7149  // SUCCESS,
7150  // then this function returns the usage credits BALANCE (it's a
7151  // int64_t int32_t, but
7152  // passed as a string). If you adjusted the balance using the
7153  // usageCredits
7154  // command (THE_MESSAGE being the server's reply to that) then you
7155  // will see
7156  // the balance AFTER the adjustment. (The current "Usage Credits"
7157  // balance.)
7158  int64_t lNewUsageBalance =
7160  string strNewUsageBalance =
7161  lNewUsageBalance > -2 ? std::to_string(lNewUsageBalance) : "";
7162 
7163  if (!VerifyStringVal(strNewUsageBalance)) {
7164  strNewUsageBalance = "(Error while calling API to retrieve "
7165  "usage credits from server reply.)";
7166  }
7167  else if (int64_t(-2) == lNewUsageBalance) {
7168  strNewUsageBalance = "Error code -2, while attempting to "
7169  "retrieve usage credits from this server "
7170  "reply.";
7171  }
7172  else if (int64_t(-1) == lNewUsageBalance) {
7173  strNewUsageBalance = "Either Nym has unlimited usage credits, "
7174  "or server has its usage credit "
7175  "enforcement turned off.\n(Either way, "
7176  "Nym is good to go, since -1 was returned "
7177  "as his 'credits balance'.)";
7178  }
7179  else if (int64_t(0) == lNewUsageBalance) {
7180  strNewUsageBalance = "Nym appears to have exhausted his supply "
7181  "of usage credits.\n(0 was returned as "
7182  "his 'credits balance'.)";
7183  }
7184  else {
7185  strNewUsageBalance = "Nym currently has " +
7186  std::to_string(lNewUsageBalance) +
7187  " usage credits.";
7188  }
7189 
7190  otOut << "\n\n adjust_usage_credits -- reply: " +
7191  strNewUsageBalance +
7192  "\n\n(FYI, this server message is the only and proper "
7193  "way to query for your own current usage credits "
7194  "balance, or also to set someone else's.)\n\n";
7195 
7196  break;
7197  }
7198  case 0:
7199  otOut << "\n\nServer response:\n\n";
7200  cout << strResponse << "\n";
7201  otOut << "\n\n FAILURE in adjust_usage_credits!\n\n";
7202  break;
7203  default:
7204  if (VerifyStringVal(strResponse)) {
7205  otOut << "Server response:\n\n";
7206  cout << strResponse << "\n";
7207  }
7208  otOut << "\n\nError in adjust_usage_credits! nStatus is: "
7209  << nStatus << "\n";
7210  break;
7211  }
7212 
7213  otOut << "\n\n";
7214 
7215  return (0 == nStatus) ? -1 : nStatus;
7216  }
7217 
7218  return -1;
7219 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string to_string(const T &t)
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string HisNym
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT int64_t Message_GetUsageCredits(const std::string &THE_MESSAGE)
Definition: OTAPI.cpp:2027
std::string MyNym
EXPORT static OT_MADE_EASY_OT std::string adjust_usage_credits(const std::string &SERVER_ID, const std::string &USER_NYM_ID, const std::string &TARGET_NYM_ID, const std::string &ADJUSTMENT)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainCancel ( )
static

Definition at line 1246 of file ot_commands_ot.cpp.

1247 {
1248  otOut << "Usage: cancel --mynym NYM_ID --args \"index "
1249  "INDEX_GOES_HERE\"\n\nThis command cancels an outgoing instrument "
1250  "from the outpayment box.\n(Usually used for cancelling a cheque, "
1251  "payment plan, or smart contract.)\nThis, of course, will fail on "
1252  "the server side, if the recipient has already deposited the "
1253  "cheque.\n\n";
1254 
1255  if (VerifyExists("MyNym")) {
1256  string strIndex = "";
1257  string strIndices = "";
1258  string strFinalIndex = "";
1259  bool bUseStdin = false;
1260 
1261  if (VerifyExists("Args", false)) {
1262  strIndex = OT_CLI_GetValueByKey(Args, "index");
1263  strIndices = OT_CLI_GetValueByKey(Args, "indices");
1264 
1265  if (VerifyStringVal(strIndex)) {
1266  strFinalIndex = strIndex;
1267  }
1268  else if (VerifyStringVal(strIndices)) {
1269  strFinalIndex = strIndices;
1270  }
1271  else {
1272  bUseStdin = true;
1273  }
1274  }
1275  else {
1276  bUseStdin = true;
1277  }
1278 
1279  if (bUseStdin) {
1280  int32_t nCount = OTAPI_Wrap::GetNym_OutpaymentsCount(MyNym);
1281 
1282  for (int32_t nPayments = 0; nPayments < nCount; ++nPayments) {
1283  show_outpayment(MyNym, nPayments, false);
1284  }
1285 
1286  otOut << "\nPlease enter the index (in your outpayment box)\nof "
1287  "the instrument you are cancelling: ";
1288  strIndex = OT_CLI_ReadLine();
1289 
1290  if (VerifyStringVal(strIndex)) {
1291  strFinalIndex = strIndex;
1292  }
1293  else {
1294  return -1;
1295  }
1296  }
1297 
1298  string strMyAcct = "";
1299  if (VerifyExists("MyAcct", false)) {
1300  strMyAcct = MyAcct;
1301  }
1302 
1303  return details_cancel_outgoing(MyNym, strMyAcct, strFinalIndex);
1304  }
1305 
1306  return -1;
1307 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:758
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_cancel_outgoing(const std::string &strMyNym, const std::string &strMyAcct, const std::string &strIndices)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
std::string MyAcct
EXPORT static OT_COMMANDS_OT bool show_outpayment(const std::string &strMyNym, int32_t nIndex, bool bShowInFull)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainChangePw ( )
static

Definition at line 3601 of file ot_commands_ot.cpp.

3602 {
3604  return 1;
3605  }
3606 
3607  return -1;
3608 }
static EXPORT bool Wallet_ChangePassphrase()
Definition: OTAPI.cpp:614
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainCheckNym ( )
static

Definition at line 6042 of file ot_commands_ot.cpp.

6043 {
6044  otOut << "Usage: checknym --mynym MY_NYM_ID --hisnym HIS_NYM_ID \n "
6045  "Downloads the public key for HisNym.\n\n";
6046 
6047  if (VerifyExists("Server") && VerifyExists("MyNym") &&
6048  VerifyExists("HisNym")) {
6049  string strResponse = details_check_user(Server, MyNym, HisNym);
6050 
6051  // -1 is error,
6052  // 0 is reply received: failure
6053  // 1 is reply received: success
6054  if (1 == VerifyMessageSuccess(strResponse)) {
6055  otOut << "\n\nSuccess in checknym! Server response:\n\n";
6056  cout << strResponse << "\n";
6057  otOut << "\n\n";
6058  return 1;
6059  }
6060  else {
6061  otOut << "\n\n checknym: Failed.\n\n";
6062  }
6063  }
6064 
6065  return -1;
6066 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string HisNym
std::string MyNym
EXPORT static OT_COMMANDS_OT std::string details_check_user(const std::string &strServerID, const std::string &strMyNymID, const std::string &strHisNymID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainClearExpired ( )
static

Definition at line 10156 of file ot_commands_ot.cpp.

10157 {
10158  otOut << " Usage: clearexpired\n\n";
10159 
10160  // CLEAR EXPIRED BOX
10161  if (VerifyExists("MyNym") && VerifyExists("Server")) {
10162  string strMyNymID = MyNym;
10163  string strServerID = Server;
10164 
10165  // expiredBox for MyNym contains the old payments (in and out.)
10166  otOut << "\n Clearing archived Nym-related expired records ("
10167  << strMyNymID << ")... \n";
10168 
10169  return details_clear_expired(strServerID, strMyNymID);
10170  }
10171 
10172  return -1;
10173 }
EXPORT static OT_COMMANDS_OT int32_t details_clear_expired(const std::string &strServerID, const std::string &strMyNymID)
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainClearRecords ( )
static

Definition at line 10047 of file ot_commands_ot.cpp.

10048 {
10049  string strLocation = "mainClearRecords";
10050 
10051  otOut << " Usage: clearrecords\n\n";
10052 
10053  // CLEAR RECORD BOX
10054  //
10055  // Load an asset account's record box from local storage and display it on
10056  // the screen.
10057  bool bNymExists = VerifyExists("MyNym", false);
10058  bool bAcctExists = VerifyExists("MyAcct", false);
10059  bool bBothExist = (bNymExists && bAcctExists);
10060  bool bShowNymOnly = (bNymExists && !bAcctExists);
10061 
10062  string strMyNymID = "";
10063 
10064  if (bShowNymOnly) {
10065  strMyNymID = MyNym;
10066  }
10067  else if (bAcctExists) {
10069  }
10070  else {
10071  otOut << strLocation << ": This should never happen. (1)\n";
10072  return -1;
10073  }
10074 
10075  if (!VerifyStringVal(strMyNymID)) {
10076  // if bShowNymOnly is true, then we KNOW MyNym is the Nym, and we
10077  // ALREADY know he's
10078  // good, since we called VerifyExists at the top of this function.
10079  // (MyNym, unlike HisNym,
10080  // is verified against the wallet, so we KNOW it's there.)
10081  // Therefore, if strMyNymID doesn't contain a proper string, then we
10082  // KNOW bShowNymOnly
10083  // must have been false, and that
10084  // OTAPI_Wrap::GetAccountWallet_NymID(MyAcct) was the call that
10085  // failed. Thus, the error message is appropriate to the latter case and
10086  // not the former.
10087  otOut << strLocation << ": Unable to find NymID based on myacct. Try a "
10088  "different account or nym, using --myacct "
10089  "ACCT_ID or --mynym NYM_ID\n";
10090  return -1;
10091  }
10092  if (bBothExist && !(strMyNymID == MyNym)) {
10093  otOut << strLocation << ": MyNym (" << MyNym
10094  << ") is not the same nym who owns MyAcct.\nTo override using "
10095  "MyAcct's owner nym, add: --mynym (" << strMyNymID << ")\n";
10096  return -1;
10097  }
10098 
10099  string strServerID = "";
10100  if (bAcctExists) {
10102  }
10103  else if (VerifyExists("Server", false)) {
10104  strServerID = Server;
10105  }
10106  else {
10107  otOut << strLocation << ": Server was not specified, and either MyAcct "
10108  "wasn't specified either, or if it was, I was "
10109  "unable to find any ServerID associated with "
10110  "MyAcct.\nTry a different account or different "
10111  "server, using --myacct ACCT_ID or --server "
10112  "SERVER_ID \n\n";
10113  return -1;
10114  }
10115 
10116  if (!VerifyStringVal(strServerID)) {
10117  otOut << strLocation << ": Unable to find Server ID.\nTry: --server "
10118  "SERVER_ID\nYou might also try: --myacct "
10119  "ACCT_ID (It will find the server ID based on "
10120  "the account.)\n";
10121  return -1;
10122  }
10123 
10124  // REMEMBER, recordbox for MyAcct contains the old inbox receipts.
10125  // Whereas recordbox for MyNym contains the old payments (in and out.)
10126  // In the case of the latter, the NYM must be passed as the ACCT...
10127  //
10128  // Meaning: there are TWO record boxes.
10129  otOut << "\n Clearing archived Nym-related records (" << strMyNymID
10130  << ")... \n";
10131  int32_t nNymRecords =
10132  details_clear_records(strServerID, strMyNymID, strMyNymID);
10133  otOut << "--------------------------------------------------------------\n";
10134  otOut << "\nClearing archived Account-related records (" << MyAcct
10135  << ")... \n";
10136  int32_t nAcctRecords =
10137  details_clear_records(strServerID, strMyNymID, MyAcct);
10138 
10139  if (2 == (nNymRecords + nAcctRecords)) {
10140  return 1;
10141  }
10142 
10143  return -1;
10144 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_clear_records(const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID)
std::string MyNym
std::string MyAcct
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainConfirm ( )
static

Definition at line 3207 of file ot_commands_ot.cpp.

3208 {
3209  int32_t nIndex = -1;
3210 
3211  if (VerifyExists("Args", false)) {
3212  string strIndex = OT_CLI_GetValueByKey(Args, "index");
3213 
3214  if (VerifyStringVal(strIndex)) {
3215  int32_t nTempIndex = std::stol(strIndex);
3216 
3217  if (nTempIndex >= 0) {
3218  nIndex = nTempIndex;
3219  }
3220  }
3221  }
3222  otOut << "\n\n";
3223  string strInstrument = "";
3224 
3225  if (-1 == nIndex) {
3226  if (VerifyExists("Server", false) && VerifyExists("MyNym", false)) {
3228 
3229  otOut << "If this is in reference to a smart contract or payment "
3230  "plan in your payments\ninbox, please enter the index to "
3231  "confirm it (or just hit enter, to paste a contract): ";
3232  string strIndex = OT_CLI_ReadLine();
3233 
3234  if (VerifyStringVal(strIndex)) {
3235  int32_t nTempIndex = std::stol(strIndex);
3236 
3237  if (nTempIndex >= 0) {
3238  nIndex = nTempIndex;
3239 
3240  strInstrument = MadeEasy::get_payment_instrument(
3241  Server, MyNym, nIndex, "");
3242 
3243  if (!VerifyStringVal(strInstrument)) {
3244  otOut << "\n Unable to get instrument from payments "
3245  "inbox, based on index: " << nIndex << ".\n";
3246  return -1;
3247  }
3248  }
3249  else {
3250  return -1;
3251  }
3252  }
3253  else {
3254  otOut << "\nPlease paste the smart contract or payment "
3255  "plan,\nfollowed by a ~ by itself on a blank "
3256  "line:\n\n";
3257 
3258  strInstrument = OT_CLI_ReadUntilEOF();
3259 
3260  if (!VerifyStringVal(strInstrument)) {
3261  return -1;
3262  }
3263  }
3264  }
3265  else {
3266  otOut << "\nPlease paste the smart contract or payment "
3267  "plan,\nfollowed by a ~ by itself on a blank line:\n\n";
3268 
3269  strInstrument = OT_CLI_ReadUntilEOF();
3270 
3271  if (!VerifyStringVal(strInstrument)) {
3272  return -1;
3273  }
3274  }
3275  }
3276  else {
3277  if (VerifyExists("Server") && VerifyExists("MyNym")) {
3278  strInstrument =
3280 
3281  if (!VerifyStringVal(strInstrument)) {
3282  otOut << "\n Unable to get instrument from payments inbox, "
3283  "based on index: " << nIndex << ".\n";
3284  return -1;
3285  }
3286  }
3287  else {
3288  otOut << "Since you specified an index, make sure to also specify "
3289  "--server and --mynym,\nso you use that index on the "
3290  "right payments inbox.\n";
3291  return -1;
3292  }
3293  }
3294 
3295  string strInstrumentType = OTAPI_Wrap::Instrmnt_GetType(strInstrument);
3296 
3297  if (!VerifyStringVal(strInstrumentType)) {
3298  otOut << "\n\nFailure: Unable to determine instrument type. Expected "
3299  "SMART CONTRACT or PAYMENT PLAN.\n";
3300  return -1;
3301  }
3302 
3303  // Is the instrument yet valid, or is it expired?
3304  // Handle both those cases here...
3305  time64_t tFrom = OTAPI_Wrap::Instrmnt_GetValidFrom(strInstrument);
3306  time64_t tTo = OTAPI_Wrap::Instrmnt_GetValidTo(strInstrument);
3307  time64_t tTime = OTAPI_Wrap::GetTime();
3308 
3309  if (tTime < tFrom) {
3310  if (-1 == nIndex) {
3311  otOut << "The instrument is not yet within its valid date range. "
3312  "(Skipping.)\n";
3313  }
3314  else {
3315  otOut << "The instrument at index " << nIndex
3316  << " is not yet within its valid date range. (Skipping.)\n";
3317  }
3318  return 0;
3319  }
3320  if ((tTo > OT_TIME_ZERO) && (tTime > tTo)) {
3321  if (-1 == nIndex) {
3322  otOut << "The instrument is expired. (Harvesting the transaction "
3323  "numbers.)\n";
3325  strInstrument, MyNym, false, false, false, false, false)) {
3326  return 0;
3327  }
3328  }
3329  else {
3330  otOut << "The instrument at index " << nIndex
3331  << " is expired. (Moving it to the record box.)\n";
3332 
3333  // Since this instrument is expired, remove it from the payments
3334  // inbox, and move to record box.
3335 
3336  // Note: this harvests.
3337  if (OTAPI_Wrap::RecordPayment(Server, MyNym, true, nIndex, true)) {
3338  return 0;
3339  }
3340  }
3341  return -1;
3342  }
3343 
3344  if ("SMARTCONTRACT" == strInstrumentType) {
3345  // Success! (It's a smart contract for sure.)
3346  //
3347  // BY this point, we know that strInstrument contains a string.
3348  // We also know that it came from the payments inbox at nIndex, or
3349  // that it was pasted in and nIndex is -1. We also know that if nIndex
3350  // is NOT -1, that means Server and MyNym are set, because that's the
3351  // box we must have gotten the smart contract out of (because someone
3352  // else sent it to us for confirmation...)
3353  return details_confirm_smart_contract(strInstrument, nIndex);
3354 
3355  }
3356  else if ("PAYMENT PLAN" == strInstrumentType) {
3357  // Success! (It's a payment plan for sure.)
3358  return details_confirm_plan(strInstrument, nIndex);
3359  }
3360  else // CHEQUE VOUCHER INVOICE PURSE
3361  {
3362  otOut << "\nFailure: Instrument is not a smart contract or payment "
3363  "plan, but rather a: " << strInstrumentType << "\n";
3364  return -1;
3365  }
3366 
3367  return -1;
3368 }
EXPORT static OT_COMMANDS_OT int32_t details_confirm_plan(const std::string &strPlan, int32_t nIndex)
EXPORT static OT_MADE_EASY_OT std::string get_payment_instrument(const std::string &SERVER_ID, const std::string &NYM_ID, int32_t nIndex, const std::string &PRELOADED_INBOX)
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
EXPORT static OT_COMMANDS_OT int32_t details_confirm_smart_contract(std::string &strSmartContract, int32_t nIndex)
std::string Server
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool RecordPayment(const std::string &SERVER_ID, const std::string &USER_ID, const bool &bIsInbox, const int32_t &nIndex, const bool &bSaveCopy)
Definition: OTAPI.cpp:1591
static EXPORT time64_t Instrmnt_GetValidFrom(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:803
int64_t time64_t
Definition: Common.hpp:209
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
#define OT_TIME_ZERO
Definition: Common.hpp:180
static EXPORT time64_t Instrmnt_GetValidTo(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:808
EXPORT static OT_COMMANDS_OT int32_t mainInpayments()
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDecode ( )
static

Definition at line 3395 of file ot_commands_ot.cpp.

3396 {
3397  otOut << "Please enter multiple lines of OT-armored text to be decoded, "
3398  "followed by an EOF or a ~ by itself on a blank line:\n\n";
3399  string strInput = OT_CLI_ReadUntilEOF();
3400 
3401  otOut << "\n\n--------------------------------------\n You entered:\n"
3402  << strInput << "\n\n";
3403 
3404  string strOutput = OTAPI_Wrap::Decode(strInput, true);
3405 
3406  otOut << "--------------------------------------\n Decoded:\n\n";
3407 
3408  if (VerifyStringVal(strOutput)) {
3409  cout << strOutput << "\n";
3410 
3411  otOut << "\n\n";
3412  return 1;
3413  }
3414 
3415  otOut << "\n\n";
3416 
3417  return -1;
3418 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Decode(const std::string &strEncoded, const bool &bLineBreaks)
Definition: OTAPI.cpp:952
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDecrypt ( )
static

Definition at line 3448 of file ot_commands_ot.cpp.

3449 {
3450  if (VerifyExists("MyNym")) {
3451 
3452  otOut << "Please enter multiple lines of input to be decrypted, "
3453  "followed by an EOF or a ~ by itself on a blank line:\n\n";
3454  string strInput = OT_CLI_ReadUntilEOF();
3455 
3456  otOut << "\n\n--------------------------------------\n You entered:\n"
3457  << strInput << "\n\n";
3458 
3459  string strOutput = OTAPI_Wrap::Decrypt(MyNym, strInput);
3460 
3461  if (VerifyStringVal(strOutput)) {
3462 
3463  otOut << "-------------------------------------- \n Decrypted:\n\n";
3464 
3465  cout << strOutput << "\n";
3466 
3467  otOut << "\n\n";
3468  return 1;
3469  }
3470  }
3471 
3472  return -1;
3473 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
static EXPORT std::string Decrypt(const std::string &RECIPIENT_NYM_ID, const std::string &strCiphertext)
Definition: OTAPI.cpp:964
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDeleteInmail ( )
static

Definition at line 10708 of file ot_commands_ot.cpp.

10709 {
10710  otOut << "Usage: deleteinmail --mynym MY_NYM_ID --args \"index 5\" (To "
10711  "delete message 5.)\n Also, try: --args \"indices all\" (for all "
10712  "messages)\n As well as: --args \"indices 3,5,6\" (for messages "
10713  "3, 5, and 6)\n\n";
10714 
10715  if (VerifyExists("MyNym")) {
10716  string strIndices = "";
10717 
10718  if (VerifyExists("Args", false)) {
10719  string strIndex = OT_CLI_GetValueByKey(Args, "index");
10720 
10721  if (VerifyStringVal(strIndex)) {
10722  strIndices = strIndex;
10723  }
10724 
10725  string strTempIndices = OT_CLI_GetValueByKey(Args, "indices");
10726 
10727  if (VerifyStringVal(strTempIndices)) {
10728  strIndices = strTempIndices;
10729  }
10730  }
10731 
10732  int32_t nDetails = details_del_mail(MyNym, strIndices);
10733  return nDetails;
10734  }
10735 
10736  return -1;
10737 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t details_del_mail(const std::string &strMyNymID, const std::string &strIndices)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDeleteOutmail ( )
static

Definition at line 10947 of file ot_commands_ot.cpp.

10948 {
10949  otOut << "Usage: deleteoutmail --mynym MY_NYM_ID --args \"index 5\" (To "
10950  "delete outmail message 5.)\n Also, try: --args \"indices all\" "
10951  "(for all outgoing messages)\n As well as: --args \"indices "
10952  "3,5,6\" (for outgoing messages 3, 5, and 6)\n\n";
10953 
10954  if (VerifyExists("MyNym")) {
10955  string strIndices = "";
10956 
10957  if (VerifyExists("Args", false)) {
10958  string strIndex = OT_CLI_GetValueByKey(Args, "index");
10959 
10960  if (VerifyStringVal(strIndex)) {
10961  strIndices = strIndex;
10962  }
10963 
10964  string strTempIndices = OT_CLI_GetValueByKey(Args, "indices");
10965 
10966  if (VerifyStringVal(strTempIndices)) {
10967  strIndices = strTempIndices;
10968  }
10969  }
10970 
10971  int32_t nDetails = details_del_outmail(MyNym, strIndices);
10972  return nDetails;
10973  }
10974 
10975  return -1;
10976 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_del_outmail(const std::string &strMyNymID, const std::string &strIndices)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDeposit ( )
static

Definition at line 7848 of file ot_commands_ot.cpp.

7849 {
7850  otOut << "Usage: deposit --myacct YOUR_ACCT_ID \n(OT will ask you to "
7851  "paste the instrument.)\nOptionally: --mynym YOUR_NYM_ID "
7852  "\nOptionally: --args \"indices 4,6,9\"\nOptionally: --args "
7853  "\"indices all\" (To deposit ALL cash tokens in your "
7854  "purse.)\nServer and NymID are usually determined based on "
7855  "MyAcct.\n If you supply optional indices, they must correspond "
7856  "to tokens in your cash purse.\n\n";
7857 
7858  // A bit complicated:
7859  //
7860  // If I specify MyPurse and MyAcct, then they MUST have the same asset type.
7861  //
7862  // If I specify MyNym and MyPurse, that is where we will look for the purse.
7863  //
7864  // If I specify MyAcct, and it's owned by a different Nym than MyNym, then
7865  // the cash
7866  // tokens will be reassigned from MyNym to MyAcct's Nym, before depositing.
7867  // Basically ALWAYS look up MyAcct's owner, and set HIM as the recipient
7868  // Nym.
7869  // (But still use MyNym, independently, to find the purse being deposited.)
7870  //
7871  // Must ALWAYS specify MyAcct because otherwise, where are you depositing
7872  // to?
7873  //
7874  // If MyNym isn't available, should use MyAcct's Nym.
7875  //
7876  // Shouldn't need to specify MyPurse, since we can ONLY deposit into MyAcct
7877  // of
7878  // the same type as MyAcct. Thus we should ignore any other asset types or
7879  // purses
7880  // since they couldn't possibly be deposited into MyAcct anyway.
7881 
7882  if (VerifyExists("MyAcct")) {
7883 
7884  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
7885  if (!VerifyStringVal(strServerID)) {
7886  otOut << "Failure: Unable to find Server ID based on myacct. Use: "
7887  "--myacct ACCT_ID\n";
7888  otOut << "The designated asset account must be yours. OT will find "
7889  "the Server based on the account.\n\n";
7890  return -1;
7891  }
7892 
7893  if (VerifyExists("Server", false) && !(Server == strServerID)) {
7894  otOut << "This account is on server ( " << strServerID
7895  << " -- the server is deduced based on the account), but the "
7896  "default server is ( " << Server
7897  << " ). To override it, use: --server " << strServerID
7898  << " \n";
7899  return -1;
7900  }
7901 
7902  return details_deposit(strServerID, MyAcct);
7903  }
7904 
7905  return -1;
7906 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_deposit(const std::string &strServerID, const std::string &strMyAcctID)
std::string MyAcct
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainDiscard ( )
static

Definition at line 890 of file ot_commands_ot.cpp.

891 {
892  otOut << "Usage: discard --mynym NYM_ID --server SERVER_ID --args "
893  "\"index|indices INDICES_GO_HERE\"\n\nThis command discards an "
894  "incoming instrument from the payments inbox.\n(Usually used for "
895  "discarding an invoice, for when you don't want to pay it.)\nYou "
896  "can also use 'all' for the index, for it to process ALL "
897  "instruments.\n\n";
898 
899  if (VerifyExists("MyNym") && VerifyExists("Server")) {
900  string strIndex = "";
901  string strIndices = "";
902  string strFinalIndex = "";
903  bool bUseStdin = false;
904 
905  if (VerifyExists("Args", false)) {
906  strIndex = OT_CLI_GetValueByKey(Args, "index");
907  strIndices = OT_CLI_GetValueByKey(Args, "indices");
908 
909  if (VerifyStringVal(strIndex)) {
910  strFinalIndex = strIndex;
911  }
912  else if (VerifyStringVal(strIndices)) {
913  strFinalIndex = strIndices;
914  }
915  else {
916  bUseStdin = true;
917  }
918  }
919  else {
920  bUseStdin = true;
921  }
922 
923  if (bUseStdin) {
925 
926  otOut << "\nPlease enter the index (in your payments inbox)\nof "
927  "the instrument you are discarding: ";
928  strIndex = OT_CLI_ReadLine();
929 
930  if (VerifyStringVal(strIndex)) {
931  strFinalIndex = strIndex;
932  }
933  else {
934  return -1;
935  }
936  }
937 
938  return details_discard_incoming(Server, MyNym, strFinalIndex);
939  }
940 
941  return -1;
942 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
EXPORT static OT_COMMANDS_OT int32_t details_discard_incoming(const std::string &strServer, const std::string &strMyNym, const std::string &strIndices)
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t mainInpayments()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEditAccount ( )
static

Definition at line 3812 of file ot_commands_ot.cpp.

3813 {
3814  otOut << "Usage: editaccount --myacct YOUR_ACCT_ID\nAlso optionally: "
3815  " --args \"label \\\"PUT LABEL HERE\\\"\"\n";
3816 
3817  if (VerifyExists("MyAcct")) {
3818 
3819  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
3820  if (!VerifyStringVal(strMyNymID)) {
3821  otOut << "\n\nFailure: Unable to find NymID based on myacct. Use: "
3822  "--myacct ACCT_ID\n";
3823  otOut << "The designated asset account must be yours. OT will find "
3824  "the Nym based on the account.\n\n";
3825  return -1;
3826  }
3827  if (VerifyExists("MyNym") && !(MyNym == strMyNymID)) {
3828  otOut << "\n\nFailure: MyNym was provided, but didn't match the "
3829  "Nym who owns MyAcct. To override, use: --mynym "
3830  << strMyNymID << "\n\n";
3831  return -1;
3832  }
3833  string strLabel = "";
3834 
3835  string strDefaultLabel = "(blank label)";
3836 
3837  // If custom arguments have been passed on the command line,
3838  // then grab them and use them instead of asking the user to enter them
3839  // at the command line.
3840  if (VerifyExists("Args", false)) {
3841  string strNewLabel = OT_CLI_GetValueByKey(Args, "label");
3842 
3843  // Set the value based on the custom argument.
3844  if (VerifyStringVal(strNewLabel)) {
3845  strLabel = strNewLabel;
3846  }
3847  }
3848 
3849  // If the label isn't provided, then we ask the
3850  // user to supply it at the command line.
3851  if (!VerifyStringVal(strLabel)) {
3852  otOut << "Enter MyAcct's new label [" << strDefaultLabel << "]: ";
3853  strLabel = OT_CLI_ReadLine();
3854  }
3855 
3856  if (!VerifyStringVal(strLabel)) {
3857  strLabel = strDefaultLabel;
3858  }
3859 
3860  bool bSet =
3861  OTAPI_Wrap::SetAccountWallet_Name(MyAcct, strMyNymID, strLabel);
3862 
3863  if (!bSet) {
3864  otOut << "\n\n FAILED trying to set MyAcct's label to: " << strLabel
3865  << "\n";
3866  otOut << "MyAcct ID: " << MyAcct << "\n";
3867  otOut << " MyNym ID: " << strMyNymID << "\n\n";
3868  return -1;
3869  }
3870  else {
3871  otOut << "\n\n SUCCESS setting MyAcct's label to: " << strLabel
3872  << "\n";
3873  otOut << "MyAcct ID: " << MyAcct << "\n";
3874  otOut << " MyNym ID: " << strMyNymID << "\n\n";
3875  return 1;
3876  }
3877  }
3878 
3879  return -1;
3880 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool SetAccountWallet_Name(const std::string &ACCT_ID, const std::string &SIGNER_NYM_ID, const std::string &ACCT_NEW_NAME)
Definition: OTAPI.cpp:1025
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEditAsset ( )
static

Definition at line 3882 of file ot_commands_ot.cpp.

3883 {
3884  otOut << "Usage: editasset --mypurse ASSET_TYPE_ID\nAlso optionally: "
3885  " --args \"label \\\"PUT LABEL HERE\\\"\"\n";
3886 
3887  if (VerifyExists("MyPurse")) {
3888  string strLabel = "";
3889 
3890  string strDefaultLabel = "(blank label)";
3891 
3892  // If custom arguments have been passed on the command line,
3893  // then grab them and use them instead of asking the user to enter them
3894  // at the command line.
3895  if (VerifyExists("Args", false)) {
3896  string strNewLabel = OT_CLI_GetValueByKey(Args, "label");
3897 
3898  // Set the value based on the custom argument.
3899  if (VerifyStringVal(strNewLabel)) {
3900  strLabel = strNewLabel;
3901  }
3902  }
3903 
3904  // If the label isn't provided, then we ask the
3905  // user to supply it at the command line.
3906  if (!VerifyStringVal(strLabel)) {
3907  otOut << "Enter MyPurse's new label [" << strDefaultLabel << "]: ";
3908  strLabel = OT_CLI_ReadLine();
3909  }
3910 
3911  if (!VerifyStringVal(strLabel)) {
3912  strLabel = strDefaultLabel;
3913  }
3914 
3915  bool bSet = OTAPI_Wrap::SetAssetType_Name(MyPurse, strLabel);
3916 
3917  if (!bSet) {
3918  otOut << "\n\n FAILED trying to set MyPurse's label to: "
3919  << strLabel << "\n";
3920  otOut << "MyPurse (AssetTypeID): " << MyPurse << "\n\n";
3921  return -1;
3922  }
3923  else {
3924  otOut << "\n\n SUCCESS setting MyPurse's label to: " << strLabel
3925  << "\n";
3926  otOut << "MyPurse (AssetTypeID): " << MyPurse << "\n\n";
3927  return 1;
3928  }
3929  }
3930 
3931  return -1;
3932 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool SetAssetType_Name(const std::string &ASSET_ID, const std::string &STR_NEW_NAME)
Definition: OTAPI.cpp:882
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEditNym ( )
static

Definition at line 3760 of file ot_commands_ot.cpp.

3761 {
3762  otOut << "Usage: editnym --mynym YOUR_NYM_ID\nAlso optionally: "
3763  "--args \"label \\\"PUT LABEL HERE\\\"\"\n";
3764 
3765  if (VerifyExists("MyNym")) {
3766  string strLabel = "";
3767 
3768  string strDefaultLabel = "(blank label)";
3769 
3770  // If custom arguments have been passed on the command line,
3771  // then grab them and use them instead of asking the user to enter them
3772  // at the command line.
3773  if (VerifyExists("Args", false)) {
3774  string strNewLabel = OT_CLI_GetValueByKey(Args, "label");
3775 
3776  // Set the value based on the custom argument.
3777  if (VerifyStringVal(strNewLabel)) {
3778  strLabel = strNewLabel;
3779  }
3780  }
3781 
3782  // If the label isn't provided, then we ask the
3783  // user to supply it at the command line.
3784  if (!VerifyStringVal(strLabel)) {
3785  otOut << "Enter MyNym's new label [" << strDefaultLabel << "]: ";
3786  strLabel = OT_CLI_ReadLine();
3787  }
3788 
3789  if (!VerifyStringVal(strLabel)) {
3790  strLabel = strDefaultLabel;
3791  }
3792 
3793  bool bSet = OTAPI_Wrap::SetNym_Name(MyNym, MyNym, strLabel);
3794 
3795  if (!bSet) {
3796  otOut << "\n\n FAILED trying to set MyNym's label to: " << strLabel
3797  << "\n";
3798  otOut << "MyNym ID: " << MyNym << "\n\n";
3799  return -1;
3800  }
3801  else {
3802  otOut << "\n\n SUCCESS setting MyNym's label to: " << strLabel
3803  << "\n";
3804  otOut << "MyNym ID: " << MyNym << "\n\n";
3805  return 1;
3806  }
3807  }
3808 
3809  return -1;
3810 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
static EXPORT bool SetNym_Name(const std::string &NYM_ID, const std::string &SIGNER_NYM_ID, const std::string &NYM_NEW_NAME)
Definition: OTAPI.cpp:869
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEditServer ( )
static

Definition at line 3934 of file ot_commands_ot.cpp.

3935 {
3936  otOut << "Usage: editserver --server SERVER_ID\nAlso optionally: "
3937  " --args \"label \\\"PUT LABEL HERE\\\"\"\n";
3938 
3939  if (VerifyExists("Server")) {
3940  string strLabel = "";
3941 
3942  string strDefaultLabel = "(blank label)";
3943 
3944  // If custom arguments have been passed on the command line,
3945  // then grab them and use them instead of asking the user to enter them
3946  // at the command line.
3947  if (VerifyExists("Args", false)) {
3948  string strNewLabel = OT_CLI_GetValueByKey(Args, "label");
3949 
3950  // Set the value based on the custom argument.
3951  if (VerifyStringVal(strNewLabel)) {
3952  strLabel = strNewLabel;
3953  }
3954  }
3955 
3956  // If the label isn't provided, then we ask the
3957  // user to supply it at the command line.
3958  if (!VerifyStringVal(strLabel)) {
3959  otOut << "Enter Server's new label [" << strDefaultLabel << "]: ";
3960  strLabel = OT_CLI_ReadLine();
3961  }
3962 
3963  if (!VerifyStringVal(strLabel)) {
3964  strLabel = strDefaultLabel;
3965  }
3966 
3967  bool bSet = OTAPI_Wrap::SetServer_Name(Server, strLabel);
3968 
3969  if (!bSet) {
3970  otOut << "\n\n FAILED trying to set Server's label to: " << strLabel
3971  << "\n";
3972  otOut << "Server ID: " << Server << "\n\n";
3973  return -1;
3974  }
3975  else {
3976  otOut << "\n\n SUCCESS setting Server's label to: " << strLabel
3977  << "\n";
3978  otOut << "Server ID: " << Server << "\n\n";
3979  return 1;
3980  }
3981  }
3982 
3983  return -1;
3984 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
static EXPORT bool SetServer_Name(const std::string &SERVER_ID, const std::string &STR_NEW_NAME)
Definition: OTAPI.cpp:876
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEncode ( )
static

Definition at line 3370 of file ot_commands_ot.cpp.

3371 {
3372  otOut << "Please enter multiple lines of input to be encoded, followed by "
3373  "an EOF or a ~ by itself on a blank line:\n\n";
3374  string strInput = OT_CLI_ReadUntilEOF();
3375 
3376  otOut << "\n\n--------------------------------------\n You entered:\n"
3377  << strInput << "\n\n";
3378 
3379  string strOutput = OTAPI_Wrap::Encode(strInput, true);
3380 
3381  otOut << "-------------------------------------- \n Encoded:\n\n";
3382 
3383  if (VerifyStringVal(strOutput)) {
3384  cout << strOutput << "\n";
3385 
3386  otOut << "\n\n";
3387  return 1;
3388  }
3389 
3390  otOut << "\n\n";
3391 
3392  return -1;
3393 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Encode(const std::string &strPlaintext, const bool &bLineBreaks)
Definition: OTAPI.cpp:946
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainEncrypt ( )
static

Definition at line 3420 of file ot_commands_ot.cpp.

3421 {
3422  if (VerifyExists("HisNym")) {
3423 
3424  otOut << "Please enter multiple lines of input to be "
3425  "encrypted,\nfollowed by an EOF or a ~ by itself on a blank "
3426  "line:\n\n";
3427  string strInput = OT_CLI_ReadUntilEOF();
3428 
3429  otOut << "\n\n--------------------------------------\n You entered:\n"
3430  << strInput << "\n\n";
3431 
3432  string strOutput = OTAPI_Wrap::Encrypt(HisNym, strInput);
3433 
3434  if (VerifyStringVal(strOutput)) {
3435 
3436  otOut << "-------------------------------------- \n Encrypted:\n\n";
3437 
3438  cout << strOutput << "\n";
3439 
3440  otOut << "\n\n";
3441  return 1;
3442  }
3443  }
3444 
3445  return -1;
3446 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Encrypt(const std::string &RECIPIENT_NYM_ID, const std::string &strPlaintext)
Definition: OTAPI.cpp:958
std::string HisNym
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainExchangeBasket ( )
static

Definition at line 657 of file ot_commands_ot.cpp.

658 {
659  otOut << "Usage: exchange --myacct BASKET_ACCT_ID\n\nThis command "
660  "exchanges in or out of a basket currency.\nYou must already have "
661  "an asset account which has a basket currency as its asset "
662  "type.\nYou must also have accounts for all the subcurrencies in "
663  "that basket.\n\n";
664 
665  if (VerifyExists("MyAcct")) {
666  string strAcctType = OTAPI_Wrap::GetAccountWallet_AssetTypeID(MyAcct);
667  string strServer = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
669 
670  if (!VerifyStringVal(strAcctType)) {
671  otOut << "Error while trying to retrieve asset type for account: "
672  << MyAcct << "\n";
673  }
674  else if (!VerifyStringVal(strServer)) {
675  otOut << "Error while trying to retrieve server ID for account: "
676  << MyAcct << "\n";
677  }
678  else if (!VerifyStringVal(strNym)) {
679  otOut << "Error while trying to retrieve Nym ID for account: "
680  << MyAcct << "\n";
681  }
682  else if (VerifyExists("MyPurse", false) && (MyPurse != strAcctType)) {
683  otOut << "MyAcct has a different asset type than the one specified "
684  "at the command line.\nPlease re-try, and add: --mypurse "
685  << strAcctType << "\n";
686  }
687  else if (VerifyExists("Server", false) && (Server != strServer)) {
688  otOut << "MyAcct has a different server ID than the one specified "
689  "at the command line.\nPlease re-try, and add: --server "
690  << strServer << "\n";
691  }
692  else if (VerifyExists("MyNym", false) && (MyNym != strNym)) {
693  otOut << "MyAcct has a different owner Nym ID than the one "
694  "specified at the command line.\nPlease re-try, and add: "
695  "--mynym " << strNym << "\n";
696  }
697  else if (!OTAPI_Wrap::IsBasketCurrency(strAcctType)) {
698  otOut << "\nMyAcct is NOT a basket currency! Its asset type is: "
699  << strAcctType << "\nHere is a list of the basket currencies "
700  "in your wallet:\n";
701 
703 
704  otOut << "\nHere is a list of the accounts whose asset type IS a "
705  "basket currency:\n";
706 
707  stat_basket_accounts("", "", false, "");
708 
709  otOut << "\nMyAcct is not a basket currency!\nPlease use --myacct "
710  "to specify an account whose asset type IS a basket "
711  "currency.\n";
712  }
713  else {
714  return details_exchange_basket(strServer, strNym, MyAcct,
715  strAcctType);
716  }
717  }
718  else {
719  otOut << "You must provide an account ID, and that account must have a "
720  "basket\ncurrency for its asset type. Use --myacct and choose "
721  "from these basket accounts:\n";
722 
723  stat_basket_accounts("", "", false, "");
724  }
725 
726  return -1;
727 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT bool IsBasketCurrency(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1980
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t stat_basket_accounts(const std::string &strServer, const std::string &strNym, bool bFilter, const std::string &strBasketType)
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_show_basket()
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t details_exchange_basket(const std::string &strServer, const std::string &strNym, const std::string &strAcct, const std::string &strBasketType)
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainExportCash ( )
static

Definition at line 8264 of file ot_commands_ot.cpp.

8265 {
8266  otOut << "Usage: exportcash --mypurse ASSET_TYPE_ID --mynym YOUR_NYM_ID "
8267  "--hisnym RECIPIENT_NYM_ID --server SERVER_ID\nOptionally: "
8268  "--args \"indices 4,6,9\"\nOptionally: --args \"passwd true\" "
8269  "(To create a password-protected purse.)\n\n(If you create a "
8270  "password-protected purse, then HisNym will be ignored and can be "
8271  "left out.)\nIf you supply optional indices, they must correspond "
8272  "to tokens in your cash purse.\n\n";
8273 
8274  if (VerifyExists("Server") && VerifyExists("MyNym") &&
8275  VerifyExists("MyPurse")) {
8276  string strIndices = "";
8277  bool bPasswordProtected = false;
8278 
8279  if (VerifyExists("Args", false)) {
8280  strIndices = OT_CLI_GetValueByKey(Args, "indices");
8281 
8282  string strPasswordProtected = OT_CLI_GetValueByKey(Args, "passwd");
8283 
8284  if (VerifyStringVal(strPasswordProtected) &&
8285  ("true" == strPasswordProtected)) {
8286  bPasswordProtected = true;
8287  }
8288  }
8289 
8290  string strHisNym = MyNym;
8291 
8292  if (!bPasswordProtected && VerifyExists("HisNym", false)) {
8293  otOut << "HisNym was provided at the command line.\nDo you wish to "
8294  "export this cash to HisNym instead of MyNym?\n\n";
8295  otOut << "HisNym is: " << HisNym << "\n MyNym is: " << MyNym
8296  << "\n\n Type yes to use HisNym, or no to use MyNym.[no]: ";
8297 
8298  string strAnswer = OT_CLI_ReadLine();
8299 
8300  if (VerifyStringVal(strAnswer) &&
8301  (("y" == strAnswer) || ("yes" == strAnswer))) {
8302  strHisNym = HisNym;
8303  }
8304  }
8305 
8306  string strServerID = Server;
8307  string strMyNymID = MyNym;
8308  string strMyPurse = MyPurse;
8309  string strRetainedCopy = "";
8310 
8311  string strExportedPurse = details_export_cash(
8312  strServerID, strMyNymID, strMyPurse, strHisNym, strIndices,
8313  bPasswordProtected, strRetainedCopy);
8314 
8315  if (VerifyStringVal(strExportedPurse)) {
8316  cout << "\n" << strExportedPurse << "\n\n";
8317  otOut << "Success exporting cash purse!\n\n";
8318  return 1;
8319  }
8320  }
8321 
8322  return -1;
8323 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string HisNym
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT static OT_COMMANDS_OT std::string details_export_cash(const std::string &strServerID, const std::string &strFromNymID, const std::string &strAssetTypeID, std::string &strHisNymID, const std::string &strIndices, bool bPasswordProtected, std::string &strRetainedCopy)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainExportNym ( )
static

Definition at line 3579 of file ot_commands_ot.cpp.

3580 {
3581  otOut << "Usage: exportnym --mynym NYM_ID\n";
3582 
3583  if (VerifyExists("MyNym")) {
3584  string strExportedNym = details_export_nym(MyNym);
3585 
3586  if (!VerifyStringVal(strExportedNym)) {
3587  otOut << "\n\n FAILED trying to export Nym: " << MyNym << "\n";
3588  return -1;
3589  }
3590  else {
3591  otOut << "\n\n SUCCESS exporting Nym: " << MyNym << "\n\n";
3592  cout << strExportedNym << "\n";
3593  otOut << "\n";
3594  return 1;
3595  }
3596  }
3597 
3598  return -1;
3599 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
EXPORT static OT_COMMANDS_OT std::string details_export_nym(const std::string &strNymID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainGetContract ( )
static

Definition at line 6143 of file ot_commands_ot.cpp.

6144 {
6145  otOut << "Usage: getcontract --server SERVER_ID --mynym YOUR_NYM_ID \n "
6146  " --args \"contract_id CONTRACT_ID_HERE\"\n\n";
6147 
6148  string strContractID = "";
6149 
6150  if (VerifyExists("Server") && VerifyExists("MyNym")) {
6151 
6152  // If custom arguments have been passed on the command line,
6153  // then grab them and use them instead of asking the user to enter them
6154  // at the command line.
6155  if (VerifyExists("Args")) {
6156  string strNewContractID = OT_CLI_GetValueByKey(Args, "contract_id");
6157 
6158  // Set the values based on the custom arguments, for those found.
6159  if (VerifyStringVal(strNewContractID)) {
6160  strContractID = strNewContractID;
6161  }
6162  else {
6163  otOut << "\n\nMissing --args \"contract_id "
6164  "CONTRACT_ID_HERE\"\n\n";
6165  return -1;
6166  }
6167 
6168  return details_download_contract(Server, MyNym, strContractID);
6169  }
6170  }
6171 
6172  return -1;
6173 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t details_download_contract(const std::string &strServerID, const std::string &strNymID, const std::string &strContractID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainGetMarkets ( )
static

Definition at line 6888 of file ot_commands_ot.cpp.

6889 {
6890  otOut
6891  << "Usage: getmarketlist --server SERVER_ID --mynym YOUR_NYM_ID\n\n";
6892 
6893  if (VerifyExists("Server") && VerifyExists("MyNym")) {
6894 
6895  string strResponse = MadeEasy::get_market_list(Server, MyNym);
6896  string strAttempt = "get_market_list";
6897  int32_t nInterpretReply = VerifyMessageSuccess(strResponse);
6898  if (1 == nInterpretReply) {
6899  otOut << "Server response (" << strAttempt
6900  << "): SUCCESS getting market list.\n\n";
6901 
6903  }
6904 
6905  return nInterpretReply;
6906  }
6907 
6908  return -1;
6909 }
EXPORT static OT_COMMANDS_OT int32_t mainShowMarkets()
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyNym
EXPORT static OT_MADE_EASY_OT std::string get_market_list(const std::string &SERVER_ID, const std::string &NYM_ID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainGetMyOffers ( )
static

Definition at line 7295 of file ot_commands_ot.cpp.

7296 {
7297 
7298  otOut << "Usage: getmyoffers --server SERVER_ID --mynym YOUR_NYM_ID\n";
7299 
7300  if (VerifyExists("Server") && VerifyExists("MyNym")) {
7301 
7302  string strResponse = details_get_nym_market_offers(Server, MyNym);
7303  string strAttempt = "get_nym_market_offers";
7304  int32_t nInterpretReply = VerifyMessageSuccess(strResponse);
7305  if (1 == nInterpretReply) {
7306  otOut << "Server response (" << strAttempt
7307  << "): SUCCESS getting nym's market offers.\n\n";
7308 
7310  }
7311 
7312  return nInterpretReply;
7313  }
7314 
7315  return -1;
7316 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t mainShowMyOffers()
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT std::string details_get_nym_market_offers(const std::string &strServerID, const std::string &strNymID)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainGetOffers ( )
static

Definition at line 7050 of file ot_commands_ot.cpp.

7051 {
7052  otOut << "Usage: getoffers --server SERVER_ID --mynym YOUR_NYM_ID\nAlso: "
7053  "--args \"market MARKET_ID depth MAX_DEPTH\"\n";
7054 
7055  if (VerifyExists("Server") && VerifyExists("MyNym")) {
7056  string strMarket = "";
7057  string strDepth = "";
7058 
7059  string strDefaultDepth = "50";
7060 
7061  // If custom arguments have been passed on the command line,
7062  // then grab them and use them instead of asking the user to enter them
7063  // at the command line.
7064  if (VerifyExists("Args", false)) {
7065  string strNewMarket = OT_CLI_GetValueByKey(Args, "market");
7066  string strNewDepth = OT_CLI_GetValueByKey(Args, "depth");
7067 
7068  // Set the values based on the custom arguments, for those found.
7069  if (VerifyStringVal(strNewMarket)) {
7070  strMarket = strNewMarket;
7071  }
7072  if (VerifyStringVal(strNewDepth)) {
7073  strDepth = strNewDepth;
7074  }
7075  }
7076 
7077  // If the transfer parameters aren't provided, then we
7078  // ask the user to supply them at the command line.
7079  if (!VerifyStringVal(strMarket)) {
7081 
7082  otOut << "\nEnter the market ID: ";
7083  strMarket = OT_CLI_ReadLine();
7084  }
7085  if (!VerifyStringVal(strDepth)) {
7086  otOut << "Optionally, enter a max depth on a single line["
7087  << strDepth << "]: ";
7088  strDepth = OT_CLI_ReadLine();
7089  }
7090 
7091  if (!VerifyStringVal(strMarket)) {
7092  return -1;
7093  }
7094  if (!VerifyStringVal(strDepth)) {
7095  strDepth = strDefaultDepth;
7096  }
7097 
7098  int64_t lDepth = std::stoll(strDepth);
7099  string strResponse =
7100  MadeEasy::get_market_offers(Server, MyNym, strMarket, lDepth);
7101  string strAttempt = "get_market_offers";
7102  int32_t nInterpretReply = VerifyMessageSuccess(strResponse);
7103 
7104  if (1 == nInterpretReply) {
7105  otOut << "Server response (" << strAttempt
7106  << "): SUCCESS getting market offers.\n\n";
7107 
7108  impl_show_market_offers(strMarket);
7109  }
7110 
7111  return nInterpretReply;
7112  }
7113 
7114  return -1;
7115 }
EXPORT static OT_COMMANDS_OT int32_t mainShowMarkets()
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t impl_show_market_offers(std::string &strMarket)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
EXPORT static OT_MADE_EASY_OT std::string get_market_offers(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &MARKET_ID, int64_t MAX_DEPTH)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainGetReceipt ( )
static

Definition at line 6360 of file ot_commands_ot.cpp.

6361 {
6362  otOut << "Usage: getreceipt --server SERVER_ID --mynym NYM_ID\n\nAlso: "
6363  " --args \"box_type BOX_TYPE_ID_HERE id "
6364  "TRANSACTION_ID_HERE\"\nBox types are 0 (Nymbox), 1 (Inbox), 2 "
6365  "(Outbox)\n\n";
6366 
6367  string strID;
6368 
6369  if (VerifyExists("Server") && VerifyExists("MyNym")) {
6370 
6371  // If custom arguments have been passed on the command line,
6372  // then grab them and use them instead of asking the user to enter them
6373  // at the command line.
6374  if (VerifyExists("Args")) {
6375  string strNewID = OT_CLI_GetValueByKey(Args, "id");
6376  string strNewType = OT_CLI_GetValueByKey(Args, "box_type");
6377 
6378  // Set the values based on the custom arguments, for those found.
6379  if (VerifyStringVal(strNewID)) {
6380  strID = strNewID;
6381  }
6382  else {
6383  otOut << "\n\nMissing --args \"id TRANSACTION_ID_HERE\"\n\n";
6384  return -1;
6385  }
6386  int32_t nBoxType = 1;
6387  if (VerifyStringVal(strNewType)) {
6388  nBoxType = std::stol(strNewType);
6389  }
6390 
6391  if (nBoxType < 0 || nBoxType > 2) {
6392  otOut << "\n\n box_type cannot be <0 or >2. Try: --args "
6393  "\"box_type 1\"\nBox types are 0 (Nymbox), 1 (Inbox), "
6394  "2 (Outbox)\n\n";
6395  return -1;
6396  }
6397 
6398  // If Inbox or Outbox, make sure we have an acct...
6399  if ((nBoxType != 0) && !VerifyExists("MyAcct", false)) {
6400  otOut << "\n\n For inbox (1) or outbox (2) box types, need an "
6401  "account ID.\nMissing: --myacct ACCT_ID_HERE \n\n";
6402  return -1;
6403  }
6404 
6405  return details_download_box_receipt(strID, nBoxType);
6406  }
6407  }
6408 
6409  return -1;
6410 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t details_download_box_receipt(const std::string &strID, int32_t nBoxType)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainImportCash ( )
static

Definition at line 8063 of file ot_commands_ot.cpp.

8064 {
8065  otOut << "Usage: importcash (OT will ask you to paste the "
8066  "instrument.)\nOptionally: importcash --mynym "
8067  "YOUR_NYM_ID\n\nAsset (Purse) ID and ServerID are both deduced "
8068  "from the cash purse that you're importing.\nNymID is also "
8069  "deduced, if necessary. (Otherwise, specify using --mynym.)\n\n";
8070 
8071  otOut << "You can import a PURSE (containing cash tokens.)\n";
8072  otOut << "Paste your financial instrument here, followed by a ~ by itself "
8073  "on a blank line: \n";
8074 
8075  string strInstrument = OT_CLI_ReadUntilEOF();
8076 
8077  if (!VerifyStringVal(strInstrument)) {
8078  return -1;
8079  }
8080 
8081  return details_import_cash(strInstrument);
8082 }
EXPORT static OT_COMMANDS_OT int32_t details_import_cash(const std::string &strInstrument)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainImportNym ( )
static

Definition at line 3544 of file ot_commands_ot.cpp.

3545 {
3546  otOut << "Usage: importnym\n";
3547 
3548  otOut << "Paste your exported Nym here (for import), followed by a ~ by "
3549  "itself on a blank line: \n";
3550 
3551  string strNymFile = OT_CLI_ReadUntilEOF();
3552 
3553  if (!VerifyStringVal(strNymFile)) {
3554  return -1;
3555  }
3556 
3557  string strOutNymID;
3558  bool bDone = details_import_nym(strNymFile, strOutNymID);
3559 
3560  if (!bDone) {
3561  otOut << "\n\n FAILED trying to import Nym.\n";
3562  return -1;
3563  }
3564  else {
3565  otOut << "\n\n SUCCESS importing Nym: " << strOutNymID << "\n\n";
3566  return 1;
3567  }
3568 
3569  return -1;
3570 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT bool details_import_nym(const std::string &strNymImportFile, std::string &strOutNymID)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainInbox ( )
static

Definition at line 10321 of file ot_commands_ot.cpp.

10322 {
10323 
10324  // SHOW INBOX
10325  //
10326  // Load an asset account's inbox from local storage and display it on the
10327  // screen.
10328 
10329  if (VerifyExists("MyAcct")) {
10330 
10331  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
10332  if (!VerifyStringVal(strMyNymID)) {
10333  otOut << "Failure: Unable to find NymID based on myacct. Use: "
10334  "--myacct ACCT_ID\n";
10335  otOut << "The designated asset account must be yours. OT will find "
10336  "the Nym based on the account.\n\n";
10337  return -1;
10338  }
10339 
10340  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
10341  if (!VerifyStringVal(strServerID)) {
10342  otOut << "Failure: Unable to find Server ID based on myacct. Use: "
10343  "--myacct ACCT_ID\n";
10344  otOut << "The designated asset account must be yours. OT will find "
10345  "the Server based on the account.\n\n";
10346  return -1;
10347  }
10348 
10349  string strInbox =
10350  OTAPI_Wrap::LoadInbox(strServerID, strMyNymID, MyAcct);
10351  if (!VerifyStringVal(strInbox)) {
10352  otOut << "\n Unable to load asset account inbox. ( " << MyAcct
10353  << " )\n Perhaps it doesn't exist yet?\n\n";
10354  return -1;
10355  }
10356  else {
10357  otOut << "\n";
10358 
10359  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(
10360  strServerID, strMyNymID, MyAcct, strInbox);
10361  if (0 > nCount) {
10362  return -1;
10363  }
10364 
10365  if (nCount > 0) {
10366  otOut << "Show inbox for an asset account (" << MyAcct
10367  << "): \n";
10368  otOut << "Idx Amt Type Txn# InRef#|User / Acct\n";
10369  otOut << "---------------------------------|(from or to)\n";
10370 
10371  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
10372  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
10373  strServerID, strMyNymID, MyAcct, strInbox, nIndex);
10374  int64_t lTransID =
10376  strServerID, strMyNymID, MyAcct, strInbox, nIndex);
10377  int64_t lRefNum =
10379  strServerID, strMyNymID, MyAcct, strTrans);
10380  int64_t lAmount = OTAPI_Wrap::Transaction_GetAmount(
10381  strServerID, strMyNymID, MyAcct, strTrans);
10382  string strType = OTAPI_Wrap::Transaction_GetType(
10383  strServerID, strMyNymID, MyAcct, strTrans);
10384  string strSenderUserID =
10386  strServerID, strMyNymID, MyAcct, strTrans);
10387  string strSenderAcctID =
10389  strServerID, strMyNymID, MyAcct, strTrans);
10390  string strRecipientUserID =
10392  strServerID, strMyNymID, MyAcct, strTrans);
10393  string strRecipientAcctID =
10395  strServerID, strMyNymID, MyAcct, strTrans);
10396 
10397  string strUserID = VerifyStringVal(strSenderUserID)
10398  ? strSenderUserID
10399  : strRecipientUserID;
10400  string strAcctID = VerifyStringVal(strSenderAcctID)
10401  ? strSenderAcctID
10402  : strRecipientAcctID;
10403 
10404  bool bUserIDExists = VerifyStringVal(strUserID);
10405  bool bAcctIDExists = VerifyStringVal(strAcctID);
10406 
10407  string strNewlineSeparator = "";
10408 
10409  if (bUserIDExists || bAcctIDExists) {
10410  strNewlineSeparator =
10411  "\n |";
10412  }
10413 
10414  string strSeparator = (!bUserIDExists && !bAcctIDExists)
10415  ? ""
10416  : strNewlineSeparator;
10417 
10418  string strUserDenoter = (bUserIDExists ? "U:" : "");
10419  string strAcctDenoter = (bAcctIDExists ? "A:" : "");
10420 
10421  string strAssetTypeID =
10422  bAcctIDExists
10424  strAcctID)
10425  : "";
10426 
10427  string strAmount = OT_ERROR_AMOUNT != lAmount
10428  ? (VerifyStringVal(strAssetTypeID)
10430  strAssetTypeID, lAmount)
10431  : std::to_string(lAmount))
10432  : "UNKNOWN_AMOUNT";
10433 
10434  otOut << nIndex << " ";
10435  otOut << strAmount
10436  << (strAmount.size() < 3 ? " " : " ");
10437  otOut << strType;
10438  otOut << (strType.size() > 10 ? " " : " ");
10439  otOut << lTransID
10440  << (std::to_string(lTransID).size() < 2 ? " "
10441  : " ");
10442  otOut << lRefNum
10443  << (std::to_string(lRefNum).size() > 2 ? " " : " ")
10444  << "|";
10445  otOut << strUserDenoter << strUserID << strSeparator
10446  << strAcctDenoter << strAcctID << "\n";
10447  }
10448 
10449  otOut << "\n For the above, try: accepttransfers, "
10450  "acceptreceipts, acceptinbox, acceptmoney, or "
10451  "acceptall.\n";
10452  }
10453  else {
10454  otOut << "\n Asset account inbox ( " << MyAcct
10455  << " ) is empty.\n";
10456  }
10457 
10458  return 1;
10459  }
10460  }
10461  return -1;
10462 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string to_string(const T &t)
static EXPORT std::string Transaction_GetSenderAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1720
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT int64_t Transaction_GetAmount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1745
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string Transaction_GetRecipientAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1728
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
static EXPORT std::string LoadInbox(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1525
static EXPORT std::string Transaction_GetSenderUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1704
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Transaction_GetRecipientUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1712
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
static EXPORT std::string Transaction_GetType(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Get Transaction Type (internally uses GetTransactionTypeString().)
Definition: OTAPI.cpp:1762
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainInmail ( )
static

Definition at line 10739 of file ot_commands_ot.cpp.

10740 {
10741  otOut << "Usage: mail --mynym MY_NYM_ID (To list all the mail messages "
10742  "for mynym.)\n Also: mail --args \"index 5\" (To examine a "
10743  "specific message.)\n\n";
10744 
10745  if (!VerifyExists("MyNym")) {
10746  return -1;
10747  }
10748 
10749  int32_t nCount = OTAPI_Wrap::GetNym_MailCount(MyNym);
10750  if (0 > nCount) {
10751  otOut << "Error: cannot retrieve mail for Nym: " << MyNym << "\n";
10752  return -1;
10753  }
10754 
10755  if (0 == nCount) {
10756  otOut << "\n(Mail box is empty)\n\n";
10757  return 0;
10758  }
10759 
10760  int32_t nIndex = -1;
10761  if (VerifyExists("Args", false)) {
10762  string strIndex = OT_CLI_GetValueByKey(Args, "index");
10763  if (VerifyStringVal(strIndex)) {
10764  nIndex = std::stol(strIndex);
10765  if (nIndex >= nCount) {
10766  otOut << "Error: invalid message index: " << strIndex << "\n";
10767  return -1;
10768  }
10769  }
10770  }
10771 
10772  if (nIndex > -1) {
10773  if (!show_mail_message(MyNym, nIndex, true)) {
10774  otOut << "Error: cannot retrieve mail message.\n";
10775  return -1;
10776  }
10777  return 1;
10778  }
10779 
10780  otOut << "\n Mail contents:\n\n";
10781 
10782  int32_t nReturnVal = 1;
10783  for (nIndex = 0; nIndex < nCount; ++nIndex) {
10784  if (!show_mail_message(MyNym, nIndex, false)) {
10785  otOut << "Error: cannot retrieve mail message.\n";
10786  nReturnVal = -1;
10787  }
10788  }
10789 
10790  return nReturnVal;
10791 }
EXPORT static OT_COMMANDS_OT bool show_mail_message(const std::string &strMyNymID, int32_t nIndex, bool bShowContents)
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
static EXPORT int32_t GetNym_MailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:688
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainInpayments ( )
static

Definition at line 9685 of file ot_commands_ot.cpp.

9686 {
9687  // SHOW PAYMENTS INBOX
9688  //
9689  // Load an asset account's payments inbox from local storage and display it
9690  // on the screen.
9691 
9692  if (VerifyExists("Server") && VerifyExists("MyNym")) {
9693 
9694  string strInbox = OTAPI_Wrap::LoadPaymentInbox(Server, MyNym);
9695 
9696  if (!VerifyStringVal(strInbox)) {
9697  otOut << "\n Unable to load the payments inbox (probably doesn't "
9698  "exist yet.)\n(Nym/Server: " << MyNym << " / " << Server
9699  << " )\n\n";
9700  return -1;
9701  }
9702  else {
9703  otOut << "\n";
9704 
9705  int32_t nCount =
9707  if (0 > nCount) {
9708  return -1;
9709  }
9710 
9711  if (nCount > 0) {
9712  otOut << "Show payments inbox (Nym/Server)\n( " << MyNym
9713  << " / " << Server << " )\n";
9714  otOut << "Idx Amt Type Txn# Asset_Type\n";
9715  otOut << "---------------------------------------\n";
9716 
9717  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
9718  string strInstrument = OTAPI_Wrap::Ledger_GetInstrument(
9719  Server, MyNym, MyNym, strInbox, nIndex);
9720 
9721  if (!VerifyStringVal(strInstrument)) {
9722  otOut << "Failed trying to get payment instrument from "
9723  "payments box.\n";
9724  return -1;
9725  }
9726 
9727  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
9728  Server, MyNym, MyNym, strInbox, nIndex);
9729  int64_t lTransNumber =
9731  Server, MyNym, MyNym, strInbox, nIndex);
9732 
9733  string strTransID = 0 <= lTransNumber
9734  ? std::to_string(lTransNumber)
9735  : "UNKNOWN_TRANS_NUM";
9736 
9738  Server, MyNym, MyNym, strTrans);
9739  int64_t lAmount =
9740  OTAPI_Wrap::Instrmnt_GetAmount(strInstrument);
9741  string strType =
9742  OTAPI_Wrap::Instrmnt_GetType(strInstrument);
9743  string strAssetType = OTAPI_Wrap::Instrmnt_GetAssetID(
9744  strInstrument); // todo: output this.
9745  string strSenderUserID =
9746  OTAPI_Wrap::Instrmnt_GetSenderUserID(strInstrument);
9747  string strSenderAcctID =
9748  OTAPI_Wrap::Instrmnt_GetSenderAcctID(strInstrument);
9749  string strRecipientUserID =
9751  string strRecipientAcctID =
9753 
9754  string strUserID = VerifyStringVal(strSenderUserID)
9755  ? strSenderUserID
9756  : strRecipientUserID;
9757  string strAcctID = VerifyStringVal(strSenderAcctID)
9758  ? strSenderAcctID
9759  : strRecipientAcctID;
9760 
9761  bool bHasAmount = OT_ERROR_AMOUNT != lAmount;
9762  bool bHasAsset = VerifyStringVal(strAssetType);
9763 
9764  string strAmount =
9765  (bHasAmount && bHasAsset)
9766  ? OTAPI_Wrap::FormatAmount(strAssetType, lAmount)
9767  : "UNKNOWN_AMOUNT";
9768 
9769  VerifyStringVal(strUserID);
9770  VerifyStringVal(strAcctID);
9771  bool bAssetIDExists = VerifyStringVal(strAssetType);
9772 
9773  string strAssetDenoter = (bAssetIDExists ? " - " : "");
9774 
9775  string strAssetName =
9776  (bAssetIDExists ? ("\"" + OTAPI_Wrap::GetAssetType_Name(
9777  strAssetType) +
9778  "\"")
9779  : "");
9780  if (!VerifyStringVal(strAssetName)) {
9781  strAssetName = "";
9782  strAssetDenoter = "";
9783  }
9784 
9785  cout << nIndex << " ";
9786  cout << strAmount
9787  << (strAmount.size() < 3 ? " " : " ");
9788  cout << strType << (strType.size() > 10 ? " " : " ");
9789  cout << strTransID
9790  << (strTransID.size() < 2 ? " " : " ");
9791  cout << strAssetType << strAssetDenoter << strAssetName
9792  << "\n";
9793  }
9794 
9795  otOut << "\n For the above, try: acceptpayments, "
9796  "acceptinvoices, acceptmoney, or acceptall.\n EXCEPT "
9797  "for smart contracts and payment plans -- for those, "
9798  "use: opentxs confirm\n\n";
9799  }
9800  else {
9801  otOut << "\n Payments inbox is empty (Nym/Server: " << MyNym
9802  << " / " << Server << " )\n";
9803  }
9804 
9805  return 1;
9806  }
9807  }
9808  return -1;
9809 }
static EXPORT int64_t Instrmnt_GetAmount(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:793
static EXPORT std::string Instrmnt_GetSenderAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:851
std::string to_string(const T &t)
static EXPORT std::string LoadPaymentInbox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1553
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
std::string Server
static EXPORT std::string Instrmnt_GetRecipientAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:863
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Instrmnt_GetSenderUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:845
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT std::string Ledger_GetInstrument(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1649
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
std::string MyNym
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainIssueAsset ( )
static

Definition at line 11185 of file ot_commands_ot.cpp.

11186 {
11187  otOut << "Usage: issueasset --server SERVER_ID --mynym NYM_ID\n\n "
11188  "(NYM_ID must already be the 'contract' key on the new "
11189  "contract.)\n See 'opentxs newasset' before running this "
11190  "script.\n\n";
11191 
11192  if (VerifyExists("Server") && VerifyExists("MyNym")) {
11193  otOut << "Please paste a currency contract, followed by an EOF or a ~ "
11194  "by itself on a blank line:\n\n";
11195  string strContract = OT_CLI_ReadUntilEOF();
11196 
11197  if (!VerifyStringVal(strContract)) {
11198  otOut << "\n\n Sorry, You must input a currency contract, in order "
11199  "to issue it on an OT server.\n\n";
11200  return -1;
11201  }
11202 
11204  // If the Nym's not registered at the server, then register him
11205  // first.
11207  }
11208 
11209  string strResponse =
11210  MadeEasy::issue_asset_type(Server, MyNym, strContract);
11211  int32_t nStatus = VerifyMessageSuccess(strResponse);
11212  switch (nStatus) {
11213  case 1:
11214  otOut << "\n\n SUCCESS in issue_asset! Server response:\n\n";
11215  cout << strResponse << "\n";
11216  break;
11217  case 0:
11218  otOut << "\n\n FAILURE in issue_asset! Server response:\n\n";
11219  cout << strResponse << "\n";
11220  break;
11221  default:
11222  otOut << "\n\nError in issue_asset! nStatus is: " << nStatus
11223  << "\n";
11224 
11225  if (VerifyStringVal(strResponse)) {
11226  otOut << "Server response:\n\n";
11227  cout << strResponse << "\n";
11228  }
11229  break;
11230  }
11231  otOut << "\n\n";
11232 
11233  return (0 == nStatus) ? -1 : nStatus;
11234  }
11235 
11236  return -1;
11237 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string issue_asset_type(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &THE_CONTRACT)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t mainRegisterNym()
std::string MyNym
static EXPORT bool IsNym_RegisteredAtServer(const std::string &NYM_ID, const std::string &SERVER_ID)
Definition: OTAPI.cpp:653
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainKillOffer ( )
static

Definition at line 5203 of file ot_commands_ot.cpp.

5204 {
5205 
5206  otOut << "\n\n FYI, used for killing an active market offer.\nUSAGE: "
5207  "killoffer --args \"transnum <transaction_number>\"\n\n";
5208 
5209  // Just to show how easy it is now, let's try a "kill_market_offer" message.
5210  // (It kills a market offer.)
5211 
5212  if (!VerifyExists("Server") || !VerifyExists("MyNym") ||
5213  !VerifyExists("MyAcct") || !VerifyExists("Args")) {
5214  }
5215  else {
5216  string strTransactionNum = OT_CLI_GetValueByKey(Args, "transnum");
5217 
5218  if (!VerifyStringVal(strTransactionNum)) {
5219  otOut << "\n\n\nYou need to provide a transaction number...\n\n";
5220  }
5221  else {
5222  return details_kill_offer(Server, MyNym, MyAcct, strTransactionNum);
5223  }
5224  }
5225 
5226  return -1;
5227 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
EXPORT static OT_COMMANDS_OT int32_t details_kill_offer(const std::string &strServerID, const std::string &strNymID, const std::string &strAcctID, const std::string &strTransNum)
std::string MyNym
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainKillPlan ( )
static

Definition at line 5229 of file ot_commands_ot.cpp.

5230 {
5231  otOut << "\n\n FYI, used for stopping an active payment plan.\nUSAGE: "
5232  "killplan --args \"transnum <transaction_number>\"\n\n";
5233 
5234  // Just to show how easy it is now, let's try a "kill_payment_plan" message.
5235  // It kills an active (already running) payment plan.
5236 
5237  if (!VerifyExists("Server") || !VerifyExists("MyNym") ||
5238  !VerifyExists("MyAcct") || !VerifyExists("Args")) {
5239  }
5240  else {
5241  string strTransactionNum = OT_CLI_GetValueByKey(Args, "transnum");
5242 
5243  if (!VerifyStringVal(strTransactionNum)) {
5244  otOut << "\n\n\nYou need to provide a transaction number...\n\n";
5245  }
5246  else {
5247  string strResponse = MadeEasy::kill_payment_plan(
5248  Server, MyNym, MyAcct, strTransactionNum);
5249  if (1 != VerifyMessageSuccess(strResponse)) {
5250  otOut << "\n\nkill_payment_plan: Failed.\n";
5251  }
5253  strResponse)) {
5254  otOut << "\n\nkill_payment_plan: Balance agreement failed.\n";
5255  }
5256  else if (1 != VerifyMsgTrnxSuccess(Server, MyNym, MyAcct,
5257  strResponse)) {
5258  otOut << "\n\nkill_payment_plan: Balance agreement succeeded, "
5259  "but transaction failed.\n";
5260  }
5261  else {
5262  otOut
5263  << "\n\nSuccess in kill_payment_plan! Server response:\n\n";
5264  cout << strResponse << "\n";
5265  otOut << "\n\n";
5266  return 1;
5267  }
5268  }
5269  }
5270 
5271  return -1;
5272 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMsgBalanceAgrmntSuccess(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strMessage)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_UTILITY_OT int32_t VerifyMsgTrnxSuccess(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strMessage)
std::string MyNym
EXPORT static OT_MADE_EASY_OT std::string kill_payment_plan(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID, const std::string &STR_TRANS_NUM)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewAccount ( )
static

Definition at line 5041 of file ot_commands_ot.cpp.

5042 {
5043  // Just to show how easy it is now, let's try a "create_asset_acct" message.
5044  // (It sends a NymID to the server, and downloads that Nym's public key.)
5045 
5046  if (VerifyExists("Server") && VerifyExists("MyNym") &&
5047  VerifyExists("MyPurse")) {
5049  // If the Nym's not registered at the server, then register him
5050  // first.
5052  }
5053 
5054  string strResponse =
5056  if (1 != VerifyMessageSuccess(strResponse)) {
5057  otOut << "\n\ncreate_asset_acct: Failed.\n\n";
5058  return -1;
5059  }
5060  else {
5061  otOut << "Success in create_asset_acct! Server response:\n\n";
5062  cout << strResponse << "\n";
5063  otOut << "\n (Success in create_asset_acct)\n\n";
5064  return 1;
5065  }
5066  }
5067 
5068  return -1;
5069 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_MADE_EASY_OT std::string create_asset_acct(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_TYPE_ID)
std::string MyPurse
EXPORT static OT_COMMANDS_OT int32_t mainRegisterNym()
std::string MyNym
static EXPORT bool IsNym_RegisteredAtServer(const std::string &NYM_ID, const std::string &SERVER_ID)
Definition: OTAPI.cpp:653
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewAsset ( )
static

Definition at line 5004 of file ot_commands_ot.cpp.

5005 {
5006  if (VerifyExists("MyNym")) {
5007  otOut << "Please enter the XML contents for the contract, followed by "
5008  "an EOF or a ~ by itself on a blank line:\n\n";
5009  string strXML = OT_CLI_ReadUntilEOF();
5010 
5011  if (VerifyStringVal(strXML)) {
5012  string strContractID =
5014 
5015  if (VerifyStringVal(strContractID)) {
5016 
5017  otOut << "-------------------------------------------\nNew "
5018  "asset ID: " << strContractID << "\n\n";
5019 
5020  string strContract =
5021  OTAPI_Wrap::GetAssetType_Contract(strContractID);
5022 
5023  if (VerifyStringVal(strContract)) {
5024 
5025  otOut << "-------------------------------------------\nNew "
5026  "asset contract:\n\n";
5027 
5028  cout << strContract << "\n";
5029 
5030  otOut << "\n\n";
5031 
5032  return 1;
5033  }
5034  }
5035  }
5036  }
5037 
5038  return -1;
5039 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string CreateAssetContract(const std::string &NYM_ID, const std::string &strXMLcontents)
Definition: OTAPI.cpp:473
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetAssetType_Contract(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:496
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewBasket ( )
static

Definition at line 225 of file ot_commands_ot.cpp.

226 {
227  if (VerifyExists("Server") && VerifyExists("MyNym")) {
229  }
230 
231  return -1;
232 }
std::string Server
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t details_new_basket(const std::string &strServer, const std::string &strNym)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewCredential ( )
static

Definition at line 46 of file ot_commands_ot.cpp.

47 {
48  otOut << "\nThis command not coded yet. A Nym is created with credentials "
49  "already,\nbut to add MORE credentials to an existing Nym, I need "
50  "to use the OT_API_AddSubcredential API call.\n\n";
51 
52  return -1;
53 }
OTLOG_IMPORT OTLogStream otOut
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewKey ( )
static

Definition at line 8746 of file ot_commands_ot.cpp.

8747 {
8748  string strKey = OTAPI_Wrap::CreateSymmetricKey();
8749 
8750  if (VerifyStringVal(strKey)) {
8751 
8752  otOut << "\n";
8753 
8754  cout << strKey << "\n";
8755 
8756  otOut << "\n";
8757 
8758  return 1;
8759  }
8760 
8761  return -1;
8762 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string CreateSymmetricKey()
Definition: OTAPI.cpp:970
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewNym ( )
static

Definition at line 5530 of file ot_commands_ot.cpp.

5531 {
5532  otOut << "Usage: newnym --args \"keybits 1024 name \\\"Bob's New "
5533  "Nym\\\"\" \nOptional: newnym --args \"source "
5534  "\\\"http://test.com/credential_IDs\\\" \" \nFYI, a source can "
5535  "be a URL, a Bitcoin address, a Namecoin address, a public "
5536  "key,\nor the unique DN info from a traditionally-issued cert. "
5537  "Hashing the source should\n produce the NymID. Also, the source "
5538  "should always (somehow) validate the\ncredential IDs, if they "
5539  "are to be trusted for their purported Nym.\nAnother optional "
5540  "parameter is 'altlocation' which, in the case of DN info as a "
5541  "source, would be the \ndownload location where a Cert should be "
5542  "found with that DN info, or a PKI where the Cert can be "
5543  "found.\n\nNOTE: If you leave the source BLANK, then OT will just "
5544  "generate a public key to serve as the source. The\npublic key "
5545  "will be hashed to form the NymID, and all credentials for that "
5546  "Nym will need to be signed by\nthe corresponding private key. "
5547  "That's the only way they can be 'verified by their source.'\n\n";
5548 
5549  int32_t nKeybits = 1024;
5550  string strName = "New Nym";
5551  string strSourceForNymID = "";
5552  string strAltLocation = "";
5553 
5554  if (VerifyExists("Args", false)) {
5555  string strKeybits = OT_CLI_GetValueByKey(Args, "keybits");
5556  string strNewName = OT_CLI_GetValueByKey(Args, "name");
5557  string strNewSource = OT_CLI_GetValueByKey(Args, "source");
5558  string strNewLocation = OT_CLI_GetValueByKey(Args, "location");
5559 
5560  if (VerifyStringVal(strKeybits) && (std::stol(strKeybits) > 0)) {
5561  nKeybits = std::stol(strKeybits);
5562  }
5563 
5564  if (VerifyStringVal(strNewName)) {
5565  strName = strNewName;
5566  }
5567 
5568  if (VerifyStringVal(strNewSource)) {
5569  strSourceForNymID = strNewSource;
5570  }
5571 
5572  if (VerifyStringVal(strNewLocation)) {
5573  strAltLocation = strNewLocation;
5574  }
5575  }
5576 
5577  return details_create_nym(nKeybits, strName, strSourceForNymID,
5578  strAltLocation);
5579 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
EXPORT static OT_COMMANDS_OT int32_t details_create_nym(int32_t nKeybits, const std::string &strName, const std::string &strSourceForNymID, const std::string &strAltLocation)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewOffer ( )
static

Definition at line 4847 of file ot_commands_ot.cpp.

4848 {
4849  otOut << "Usage: newoffer --myacct <YOUR_ASSET_ACCT> --hisacct "
4850  "<YOUR_CURRENCY_ACCT>\n\n Optional: --args \"type <bid|ask> scale "
4851  "1 quantity 100 price 101\"\n Optional: --args \"lifespan 86400\" "
4852  " (in seconds: 86400 is 1 day--the default.)\n\nWARNING: a price "
4853  "of 0 is a market order, which means 'purchase/sell at ANY "
4854  "price'\n\n";
4855 
4856  if (VerifyExists("MyAcct") && VerifyExists("HisAcct")) {
4857  string strScale = "0"; // must be 1, 10, 100, etc
4858  string strMinIncrement = "0"; // must be 1, 2, 3, etc
4859  string strQuantity = "0"; // must be >= 1
4860  string strPrice = "0"; // must be >= 0
4861  string strType = ""; // must be bid or ask
4862  string strLifespan = "0";
4863 
4864  string strDefaultScale = "1"; // must be 1, 10, 100, etc
4865  string strDefaultMinIncrement = "1"; // must be 1, 2, 3, etc
4866  string strDefaultQuantity = "100"; // must be >= 1
4867  string strDefaultPrice = "101"; // must be >= 1
4868  string strDefaultType = "bid"; // must be bid or ask
4869  string strDefaultLifespan = "86400"; // even if we put "0" here, OT
4870  // would internally default this to
4871  // 86400.
4872 
4873  // If custom arguments have been passed on the command line,
4874  // then grab them and use them instead of asking the user to enter them
4875  // at the command line.
4876  if (VerifyExists("Args")) {
4877  string strNewScale = OT_CLI_GetValueByKey(Args, "scale");
4878  string strNewMinInc = OT_CLI_GetValueByKey(Args, "min_inc");
4879  string strNewQuantity = OT_CLI_GetValueByKey(Args, "quantity");
4880  string strNewPrice = OT_CLI_GetValueByKey(Args, "price");
4881  string strNewType = OT_CLI_GetValueByKey(Args, "type");
4882  string strNewLifespan = OT_CLI_GetValueByKey(Args, "lifespan");
4883 
4884  // Set the values based on the custom arguments, for those found.
4885  if (VerifyStringVal(strNewScale)) {
4886  strScale = strNewScale;
4887  }
4888  if (VerifyStringVal(strNewMinInc)) {
4889  strMinIncrement = strNewMinInc;
4890  }
4891  if (VerifyStringVal(strNewQuantity)) {
4892  strQuantity = strNewQuantity;
4893  }
4894  if (VerifyStringVal(strNewPrice)) {
4895  strPrice = strNewPrice;
4896  }
4897  if (VerifyStringVal(strNewType)) {
4898  strType = strNewType;
4899  }
4900  if (VerifyStringVal(strNewLifespan)) {
4901  strLifespan = strNewLifespan;
4902  }
4903  }
4904 
4905  // If the offer parameters aren't satisfied yet, then
4906  // ask the user to supply them at the command line.
4907  if (!VerifyStringVal(strScale) || (std::stol(strScale) < 1)) {
4908  otOut << "Enter the market scale (1, 10, 100, etc)["
4909  << strDefaultScale << "]: ";
4910  strScale = OT_CLI_ReadLine();
4911  }
4912  if (!VerifyStringVal(strMinIncrement) ||
4913  (std::stol(strMinIncrement) < 1)) {
4914  otOut << "Enter the minimum increment[" << strDefaultMinIncrement
4915  << "]: ";
4916  strMinIncrement = OT_CLI_ReadLine();
4917  }
4918  if (!VerifyStringVal(strQuantity) || (std::stol(strQuantity) < 1)) {
4919  otOut << "Enter the quantity being purchased/sold["
4920  << strDefaultQuantity << "]: ";
4921  strQuantity = OT_CLI_ReadLine();
4922  }
4923  if (!VerifyStringVal(strPrice) || (std::stol(strPrice) < 0)) {
4924  otOut << "Enter the price per scale[" << strDefaultPrice << "]: ";
4925  strPrice = OT_CLI_ReadLine();
4926  }
4927  if (!VerifyStringVal(strType) ||
4928  ((strType != "bid") && (strType != "ask"))) {
4929  otOut << "Enter the order type (bid/ask) [" << strDefaultType
4930  << "]: ";
4931  strType = OT_CLI_ReadLine();
4932  }
4933  if (!VerifyStringVal(strLifespan) || (std::stol(strLifespan) < 1)) {
4934  otOut << "(1 hour == 3600, 1 day == 86400)\n Enter the lifespan of "
4935  "the offer, in seconds[" << strDefaultLifespan << "]: ";
4936  strLifespan = OT_CLI_ReadLine();
4937  }
4938 
4939  if (!VerifyStringVal(strScale) || (std::stol(strScale) < 1)) {
4940  strScale = strDefaultScale;
4941  }
4942  if (!VerifyStringVal(strMinIncrement) ||
4943  (std::stol(strMinIncrement) < 1)) {
4944  strMinIncrement = strDefaultMinIncrement;
4945  }
4946  if (!VerifyStringVal(strQuantity) || (std::stol(strQuantity) < 1)) {
4947  strQuantity = strDefaultQuantity;
4948  }
4949  if (!VerifyStringVal(strPrice) || (std::stol(strPrice) < 1)) {
4950  strPrice = strDefaultPrice;
4951  }
4952  if (!VerifyStringVal(strType) ||
4953  ((strType != "bid") && (strType != "ask"))) {
4954  strType = strDefaultType;
4955  }
4956  if (!VerifyStringVal(strLifespan) || (std::stol(strLifespan) < 1)) {
4957  strLifespan = strDefaultLifespan;
4958  }
4959 
4960  return details_create_offer(strScale, strMinIncrement, strQuantity,
4961  strPrice, strType != "bid", strLifespan);
4962  }
4963 
4964  return -1;
4965 }
EXPORT static OT_COMMANDS_OT int32_t details_create_offer(const std::string &strScale, const std::string &strMinIncrement, const std::string &strQuantity, const std::string &strPrice, bool bSelling, const std::string &strLifespan)
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainNewServer ( )
static

Definition at line 4967 of file ot_commands_ot.cpp.

4968 {
4969  if (VerifyExists("MyNym")) {
4970  otOut << "Please enter the XML contents for the contract, followed by "
4971  "an EOF or a ~ by itself on a blank line:\n\n";
4972  string strXML = OT_CLI_ReadUntilEOF();
4973 
4974  if (VerifyStringVal(strXML)) {
4975  string strContractID =
4977 
4978  if (VerifyStringVal(strContractID)) {
4979 
4980  otOut << "-------------------------------------------\nNew "
4981  "server ID: " << strContractID << "\n\n";
4982 
4983  string strContract =
4984  OTAPI_Wrap::GetServer_Contract(strContractID);
4985 
4986  if (VerifyStringVal(strContract)) {
4987 
4988  otOut << "-------------------------------------------\nNew "
4989  "server contract:\n\n";
4990 
4991  cout << strContract << "\n";
4992 
4993  otOut << "\n\n";
4994 
4995  return 1;
4996  }
4997  }
4998  }
4999  }
5000 
5001  return -1;
5002 }
static EXPORT std::string GetServer_Contract(const std::string &SERVER_ID)
Definition: OTAPI.cpp:479
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string CreateServerContract(const std::string &NYM_ID, const std::string &strXMLcontents)
Definition: OTAPI.cpp:467
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainOutbox ( )
static

Definition at line 10464 of file ot_commands_ot.cpp.

10465 {
10466 
10467  // SHOW OUTPUT
10468  //
10469  // Load an asset account's outbox from local storage and display it on the
10470  // screen.
10471  otOut << "-----------------------------------------------\nUSAGE: outbox "
10472  "--myacct MY_ACCT_ID\n";
10473 
10474  if (VerifyExists("MyAcct")) {
10475 
10476  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
10477  if (!VerifyStringVal(strMyNymID)) {
10478  otOut << "Failure: Unable to find NymID based on myacct. Use: "
10479  "--myacct ACCT_ID\n";
10480  otOut << "The designated asset account must be yours. OT will find "
10481  "the Nym based on the account.\n\n";
10482  return -1;
10483  }
10484 
10485  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
10486  if (!VerifyStringVal(strServerID)) {
10487  otOut << "Failure: Unable to find Server ID based on myacct. Use: "
10488  "--myacct ACCT_ID\n";
10489  otOut << "The designated asset account must be yours. OT will find "
10490  "the Server based on the account.\n\n";
10491  return -1;
10492  }
10493 
10494  string strOutbox =
10495  OTAPI_Wrap::LoadOutbox(strServerID, strMyNymID, MyAcct);
10496  if (!VerifyStringVal(strOutbox)) {
10497  otOut << "\n\n OT_API_LoadOutbox: Failed.\n\n";
10498  return -1;
10499  }
10500  else {
10501  otOut << "\n";
10502 
10503  int32_t nCount = OTAPI_Wrap::Ledger_GetCount(
10504  strServerID, strMyNymID, MyAcct, strOutbox);
10505  if (0 > nCount) {
10506  return -1;
10507  }
10508 
10509  otOut << "===> SHOW OUTBOX: \n";
10510 
10511  if (nCount <= 0) {
10512  otOut << "\nAsset account outbox is empty for account: "
10513  << MyAcct
10514  << "\n\n--------------------------------------------\n";
10515  }
10516  else {
10517  otOut << "\nIdx Amt Type Txn# InRef#|User / Acct\n";
10518  otOut << "---------------------------------|(from or to)\n";
10519 
10520  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
10521  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
10522  strServerID, strMyNymID, MyAcct, strOutbox, nIndex);
10523  int64_t lTransID =
10525  strServerID, strMyNymID, MyAcct, strOutbox, nIndex);
10526  int64_t lRefNum =
10528  strServerID, strMyNymID, MyAcct, strTrans);
10529  int64_t lAmount = OTAPI_Wrap::Transaction_GetAmount(
10530  strServerID, strMyNymID, MyAcct, strTrans);
10531  string strType = OTAPI_Wrap::Transaction_GetType(
10532  strServerID, strMyNymID, MyAcct, strTrans);
10533  string strSenderUserID =
10535  strServerID, strMyNymID, MyAcct, strTrans);
10536  string strSenderAcctID =
10538  strServerID, strMyNymID, MyAcct, strTrans);
10539  string strRecipientUserID =
10541  strServerID, strMyNymID, MyAcct, strTrans);
10542  string strRecipientAcctID =
10544  strServerID, strMyNymID, MyAcct, strTrans);
10545 
10546  string strUserID = strRecipientUserID;
10547  string strAcctID = strRecipientAcctID;
10548 
10549  bool bUserIDExists = VerifyStringVal(strUserID);
10550  bool bAcctIDExists = VerifyStringVal(strAcctID);
10551 
10552  string strNewlineSeparator = "";
10553 
10554  if (bUserIDExists || bAcctIDExists) {
10555  strNewlineSeparator =
10556  "\n |";
10557  }
10558 
10559  string strSeparator = (!bUserIDExists && !bAcctIDExists)
10560  ? ""
10561  : strNewlineSeparator;
10562 
10563  string strUserDenoter = (bUserIDExists ? "U:" : "");
10564  string strAcctDenoter = (bAcctIDExists ? "A:" : "");
10565 
10566  string strAssetTypeID =
10567  bAcctIDExists
10569  strAcctID)
10570  : "";
10571 
10572  string strAmount = OT_ERROR_AMOUNT != lAmount
10573  ? (VerifyStringVal(strAssetTypeID)
10575  strAssetTypeID, lAmount)
10576  : std::to_string(lAmount))
10577  : "UNKNOWN_AMOUNT";
10578 
10579  otOut << nIndex << " ";
10580  otOut << strAmount
10581  << (strAmount.size() < 3 ? " " : " ");
10582  otOut << strType << (strType.size() > 10 ? " " : " ");
10583  otOut << lTransID
10584  << (std::to_string(lTransID).size() < 2 ? " "
10585  : " ");
10586  otOut << lRefNum
10587  << (std::to_string(lRefNum).size() > 2 ? " " : " ")
10588  << "|";
10589  otOut << strUserDenoter << strUserID << strSeparator
10590  << strAcctDenoter << strAcctID << "\n";
10591  }
10592  }
10593 
10594  return 1;
10595  }
10596  }
10597  return -1;
10598 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string to_string(const T &t)
static EXPORT std::string Transaction_GetSenderAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1720
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT int64_t Transaction_GetAmount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1745
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string Transaction_GetRecipientAcctID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1728
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
static EXPORT std::string Transaction_GetSenderUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1704
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string LoadOutbox(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1539
static EXPORT std::string Transaction_GetRecipientUserID(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1712
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
static EXPORT std::string Transaction_GetType(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Get Transaction Type (internally uses GetTransactionTypeString().)
Definition: OTAPI.cpp:1762
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainOutmail ( )
static

Definition at line 10828 of file ot_commands_ot.cpp.

10829 {
10830  otOut << "Usage: outmail --mynym MY_NYM_ID (To list all the sent mail "
10831  "messages for mynym.)\n Also: outmail --args \"index 5\" (To "
10832  "examine a specific message.)\n\n";
10833 
10834  if (!VerifyExists("MyNym")) {
10835  return -1;
10836  }
10837 
10838  int32_t nCount = OTAPI_Wrap::GetNym_OutmailCount(MyNym);
10839  if (0 > nCount) {
10840  otOut << "Error: cannot retrieve outmail for Nym: " << MyNym << "\n";
10841  return -1;
10842  }
10843 
10844  if (0 == nCount) {
10845  otOut << "\n(Outmail box is empty)\n\n";
10846  return 0;
10847  }
10848 
10849  int32_t nIndex = -1;
10850  if (VerifyExists("Args", false)) {
10851  string strIndex = OT_CLI_GetValueByKey(Args, "index");
10852  if (VerifyStringVal(strIndex)) {
10853  nIndex = std::stol(strIndex);
10854  if (nIndex >= nCount) {
10855  otOut << "Error: invalid message index: " << strIndex << "\n";
10856  return -1;
10857  }
10858  }
10859  }
10860 
10861  if (nIndex > -1) {
10862  if (!show_outmail_message(MyNym, nIndex, true)) {
10863  otOut << "Error: cannot retrieve outmail message.\n";
10864  return -1;
10865  }
10866  return 1;
10867  }
10868 
10869  otOut << "\n Outmail contents:\n\n";
10870 
10871  int32_t nReturnVal = 1;
10872  for (nIndex = 0; nIndex < nCount; ++nIndex) {
10873  if (!show_outmail_message(MyNym, nIndex, false)) {
10874  otOut << "Error: cannot retrieve outmail message.\n";
10875  nReturnVal = -1;
10876  }
10877  }
10878 
10879  return nReturnVal;
10880 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
EXPORT static OT_COMMANDS_OT bool show_outmail_message(const std::string &strMyNymID, int32_t nIndex, bool bShowContents)
static EXPORT int32_t GetNym_OutmailCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:723
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainOutpayment ( )
static

Definition at line 11083 of file ot_commands_ot.cpp.

11084 {
11085  otOut << "Usage: outpayment --mynym MY_NYM_ID --args \"index 5\" (for "
11086  "example)\nIf no index is specified, all outgoing payments are "
11087  "listed.\n";
11088 
11089  if (!VerifyExists("MyNym")) {
11090  return -1;
11091  }
11092 
11093  int32_t nCount = OTAPI_Wrap::GetNym_OutpaymentsCount(MyNym);
11094  if (0 > nCount) {
11095  otOut << "Error: cannot retrieve outpayments for Nym: " << MyNym
11096  << "\n";
11097  return -1;
11098  }
11099 
11100  if (0 == nCount) {
11101  otOut << "\n(Outpayment box is empty)\n\n";
11102  return 0;
11103  }
11104 
11105  int32_t nIndex = -1;
11106  if (VerifyExists("Args", false)) {
11107  string strIndex = OT_CLI_GetValueByKey(Args, "index");
11108 
11109  if (VerifyStringVal(strIndex)) {
11110  nIndex = std::stol(strIndex);
11111  if (nIndex >= nCount) {
11112  otOut << "Error: invalid message index: " << strIndex << "\n";
11113  return 0;
11114  }
11115  }
11116  }
11117 
11118  if (nIndex > -1) {
11119  if (!show_outpayment(MyNym, nIndex, true)) {
11120  otOut << "Error: cannot retrieve outpayment.\n";
11121  return -1;
11122  }
11123  }
11124 
11125  otOut << "\n\n===> SHOW OUTGOING PAYMENTS:\n";
11126 
11127  int32_t nReturnVal = 1;
11128  for (nIndex = 0; nIndex < nCount; ++nIndex) {
11129  if (!show_outpayment(MyNym, nIndex, false)) {
11130  otOut << "Error: cannot retrieve outpayment.\n";
11131  nReturnVal = -1;
11132  }
11133  }
11134  return nReturnVal;
11135 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
static EXPORT int32_t GetNym_OutpaymentsCount(const std::string &NYM_ID)
Definition: OTAPI.cpp:758
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT static OT_COMMANDS_OT bool show_outpayment(const std::string &strMyNym, int32_t nIndex, bool bShowInFull)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainPasswordDecrypt ( )
static

Definition at line 3505 of file ot_commands_ot.cpp.

3506 {
3507  otOut << "Please enter a symmetric key, followed by a ~ by itself on a "
3508  "blank line:\n\n";
3509  string strKey = OT_CLI_ReadUntilEOF();
3510 
3511  otOut << "Please enter the symmetrically-encrypted ciphertext, followed by "
3512  "a ~ by itself on a blank line:\n\n";
3513 
3514  string strCiphertext = OT_CLI_ReadUntilEOF();
3515 
3516  if (VerifyStringVal(strKey) && VerifyStringVal(strCiphertext)) {
3517  string strPlaintext =
3518  OTAPI_Wrap::SymmetricDecrypt(strKey, strCiphertext);
3519 
3520  if (VerifyStringVal(strPlaintext)) {
3521 
3522  otOut << "-------------------------------------- \n Plaintext:\n\n";
3523 
3524  cout << strPlaintext << "\n";
3525 
3526  otOut << "\n\n";
3527  return 1;
3528  }
3529  }
3530 
3531  return -1;
3532 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string SymmetricDecrypt(const std::string &SYMMETRIC_KEY, const std::string &CIPHERTEXT_ENVELOPE)
Definition: OTAPI.cpp:981
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainPasswordEncrypt ( )
static

Definition at line 3475 of file ot_commands_ot.cpp.

3476 {
3477  otOut << "Please enter a symmetric key, followed by a ~ by itself on a "
3478  "blank line:\n\n";
3479  string strKey = OT_CLI_ReadUntilEOF();
3480 
3481  otOut << "Please enter the plaintext, followed by a ~ by itself on a blank "
3482  "line:\n\n";
3483 
3484  string strPlaintext = OT_CLI_ReadUntilEOF();
3485 
3486  if (VerifyStringVal(strKey) && VerifyStringVal(strPlaintext)) {
3487  string strCiphertext =
3488  OTAPI_Wrap::SymmetricEncrypt(strKey, strPlaintext);
3489 
3490  if (VerifyStringVal(strCiphertext)) {
3491 
3492  otOut << "-------------------------------------- \n "
3493  "strCiphertext:\n\n";
3494 
3495  cout << strCiphertext << "\n";
3496 
3497  otOut << "\n\n";
3498  return 1;
3499  }
3500  }
3501 
3502  return -1;
3503 }
static EXPORT std::string SymmetricEncrypt(const std::string &SYMMETRIC_KEY, const std::string &PLAINTEXT)
Definition: OTAPI.cpp:975
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainPayDividend ( )
static

Definition at line 7393 of file ot_commands_ot.cpp.

7394 {
7395  otOut << "Usage: paydividend --server SERVER_ID --mynym "
7396  "SHARES_ISSUER_NYM_ID\n --myacct "
7397  "DIVIDEND_SOURCE_ACCT_ID --hispurse SHARES_ASSET_TYPE_ID\n\nAlso "
7398  "necessary: --args \"amount PAYOUT_AMOUNT_PER_SHARE\"\nAnd "
7399  "OPTIONALLY: --args \"memo \\\"Just a memo for the dividend "
7400  "payment.\\\"\"\n\n";
7401 
7402  if (VerifyExists("Server") && VerifyExists("MyAcct")) {
7403  string strAmount = "0";
7404  string strNote = "";
7405 
7406  string strDefaultAmount = "1";
7407  string strDefaultNote = "(blank memo field)";
7408 
7409  // If custom arguments have been passed on the command line,
7410  // then grab them and use them instead of asking the user to enter them
7411  // at the command line.
7412  if (VerifyExists("Args", false)) {
7413  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
7414  string strNewNote = OT_CLI_GetValueByKey(Args, "memo");
7415 
7416  // Set the values based on the custom arguments, for those found.
7417  if (VerifyStringVal(strNewAmount)) {
7418  strAmount = strNewAmount;
7419  }
7420  if (VerifyStringVal(strNewNote)) {
7421  strNote = strNewNote;
7422  }
7423  }
7424 
7425  string strAssetTypeID =
7427 
7428  // If the transfer parameters aren't provided, then we
7429  // ask the user to supply them at the command line.
7430  if (!VerifyStringVal(strAmount) ||
7431  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
7432  otOut << "Enter the 'Payout Amount Per-Share'[" << strDefaultAmount
7433  << "]: ";
7434  strAmount = OT_CLI_ReadLine();
7435  }
7436  if (!VerifyStringVal(strNote)) {
7437  otOut << "Optionally, enter a memo on a single line["
7438  << strDefaultNote << "]: ";
7439  strNote = OT_CLI_ReadLine();
7440  }
7441 
7442  if (!VerifyStringVal(strAmount) ||
7443  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
7444  strAmount = strDefaultAmount;
7445  }
7446  if (!VerifyStringVal(strNote)) {
7447  strNote = strDefaultNote;
7448  }
7449 
7450  return details_pay_dividend(strAmount, strNote);
7451  }
7452 
7453  return -1;
7454 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
EXPORT static OT_COMMANDS_OT int32_t details_pay_dividend(const std::string &strAmount, const std::string &strMemo)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainPayInvoice ( )
static

Definition at line 9120 of file ot_commands_ot.cpp.

9121 {
9122  otOut << "Usage: payinvoice --myacct FROM_ACCT --args \"index "
9123  "INVOICE_INDEX\" \nThe invoice and myacct must both have same "
9124  "asset type. If an index is not\nspecified for the payments "
9125  "inbox, then OT will ask you to paste an invoice.\n\n";
9126 
9127  if (!VerifyExists("MyAcct")) {
9128  return -1;
9129  }
9130  int32_t nIndex = -1;
9131 
9132  if (VerifyExists("Args")) {
9133  string strIndex = OT_CLI_GetValueByKey(Args, "index");
9134 
9135  if (VerifyStringVal(strIndex)) {
9136  int32_t nTempIndex = std::stol(strIndex);
9137 
9138  if (nTempIndex >= 0) {
9139  nIndex = nTempIndex;
9140  }
9141  }
9142  }
9143  otOut << "\n\n";
9144  int32_t nPaidInvoice = handle_payment_index(MyAcct, nIndex, "INVOICE", "");
9145 
9146  if (1 == nPaidInvoice) // Success! (Therefore, remove from payments inbox,
9147  // and move to record box.)
9148  {
9149  // Should I bother moving the invoice from the payments inbox to the
9150  // record box?
9151  //
9152  // Update: Okay for now, I'm using an API call here (RecordPayment)
9153  // which moves the invoice.
9154  // HOWEVER, in the int64_t term, we don't want to do it here. Rather, we
9155  // want to do it inside OT while
9156  // it's processesing the server reply for your cheque (invoice) deposit.
9157  // For example what if there's
9158  // a network problem and we don't process that reply here now? There'll
9159  // still be a copy of the reply
9160  // in the Nymbox and it will still get processed at a future time... and
9161  // THAT's when we need to move
9162  // the record, not here. (But this is what we'll do for now.)
9163  //
9164  // OTAPI_Wrap::RecordPayment(const OTIdentifier& SERVER_ID,
9165  // const OTIdentifier& USER_ID,
9166  // bool bIsInbox, // true == payments
9167  // inbox. false == payments outbox.
9168  // int32_t nIndex) // removes payment
9169  // instrument (from payments in or out box) and moves to record box.
9170  // if (!OTAPI_Wrap::RecordPayment(strServerID, strMyNymID, ))
9171  // {; }
9172 
9173  // UPDATE:
9174  /*
9175  - In my Payments Inbox, there could be a cheque or invoice. Either way,
9176  when I deposit the cheque or
9177  pay the invoice, the chequeReceipt goes back to the signer's asset
9178  account's inbox.
9179  - When he accepts the chequeReceipt (during a processInbox) and WHEN HE
9180  GETS THE "SUCCESS" REPLY to that
9181  processInbox, is when the chequeReceipt should be moved from his inbox
9182  to his record box. It MUST be
9183  done then, inside OT, because the next time he downloads the inbox from
9184  the server, that chequeReceipt
9185  won't be in there anymore! It'll be too late to pass it on to the
9186  records.
9187  - Whereas I, being the recipient of his cheque, had it in my **payments
9188  inbox,** and thus upon receipt
9189  of a successful server-reply to my deposit transaction, need to move it
9190  from my payments inbox to my
9191  record box. (The record box will eventually be a callback so that client
9192  software can take over that
9193  functionality, which is outside the scope of OT. The actual CALL to
9194  store in the record box, however
9195  should occur inside OT.)
9196  - For now, I'm using the below API call, so it's available inside the
9197  scripts. This is "good enough"
9198  for now, just to get the payments inbox/outbox working for the scripts.
9199  But in the int64_t term, I'll need
9200  to add the hooks directly into OT as described just above. (It'll be
9201  necessary in order to get the record
9202  box working.)
9203  - Since I'm only worried about Payments Inbox for now, and since I'll be
9204  calling the below function
9205  directly from inside the scripts, how will this work? Incoming cheque or
9206  invoice will be in the payments
9207  inbox, and will need to be moved to recordBox (below call) when the
9208  script receives a success reply to
9209  the depositing/paying of that cheque/invoice.
9210  - Whereas outoing cheque/invoice is in the Outpayments box,
9211  (fundamentally more similar to the outmail
9212  box than to the payments inbox.) If the cheque/invoice is cashed/paid by
9213  the endorsee, **I** will receive
9214  the chequeReceipt, in MY asset account inbox, and when I accept it
9215  during a processInbox transaction,
9216  the SUCCESS REPLY from the server for that processInbox is where I
9217  should actually process that chequeReceipt
9218  and, if it appears in the outpayments box, move it at that time to the
9219  record box. The problem is, I can NOT
9220  do this much inside the script. To do this part, I thus HAVE to go into
9221  OT itself as I just described.
9222  - Fuck!
9223  - Therefore I might as well comment this out, since this simply isn't
9224  going to work.
9225 
9226  - Updated plan:
9227  1. DONE: Inside OT, when processing successful server reply to
9228  processInbox request, if a chequeReceipt
9229  was processed out successfully, and if that chequeReceipt is found
9230  inside the outpayments, then
9231  move it at that time to the record box.
9232  2. DONE: Inside OT, when processing successful server reply to
9233  depositCheque request, if that cheque is
9234  found inside the Payments Inbox, move it to the record box.
9235  3. As for cash:
9236  If I SENT cash, it will be in my outpayments box. But that's wrong.
9237  Because I can
9238  never see if the guy cashed it or not. Therefore it should go straight
9239  to the record box, when
9240  sent. AND it needs to be encrypted to MY key, not his -- so need to
9241  generate BOTH versions, when
9242  exporting the purse to him in the FIRST PLACE. Then my version goes
9243  straight into my record box and
9244  I can delete it at my leisure. (If he comes running the next day saying
9245  "I lost it!!" I can still
9246  recover it. But once he deposits it, then the cash will be no good and I
9247  might as well archive it
9248  or destroy it, or whatever I choose to do with my personal records.)
9249  If I RECEIVED cash, it will be in my payments inbox, and then when I
9250  deposit it, and when I process
9251  the SUCCESSFUL server REPLY to my depositCash request, it should be
9252  moved to my record Box.
9253  4. How about vouchers? If I deposit a voucher, then the "original
9254  sender" should get some sort of
9255  notice. This means attaching his ID to the voucher--which should be
9256  optional--and then dropping an
9257  "FYI" notice to him when it gets deposited. It can't be a normal
9258  chequeReceipt because that's used
9259  to verify the balance agreement against a balance change, whereas a
9260  "voucher receipt" wouldn't represent
9261  a balance change at all, since the balance was already changed when you
9262  originally bought the voucher.
9263  Instead it would probably be send to your Nymbox but it COULD NOT BE
9264  PROVEN that it was, since OT currently
9265  can't prove NOTICE!!
9266 
9267  All of the above needs to happen inside OT, since there are many plances
9268  where it's the only appropriate
9269  place to take the necessary action. (Script cannot.)
9270  */
9271 
9272  cout << "\n Success paying invoice!\n\n\n";
9273 
9274  return 1;
9275  }
9276 
9277  return -1;
9278 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t handle_payment_index(const std::string &strMyAcctID, int32_t nIndex, const std::string &strPaymentType, const std::string &strInbox)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainProposePlan ( )
static

Definition at line 1943 of file ot_commands_ot.cpp.

1944 {
1945  otOut << "Usage: propose (For a merchant to propose a payment plan to "
1946  "a customer.)\nMandatory: --server SERVER_ID --mynym PAYEE_NYM_ID "
1947  "--hisnym PAYER_NYM_ID\nMandatory: --myacct PAYEE_ACCT_ID "
1948  "--hisacct PAYER_NYM_ID\nAdditional arguments:\n Date Range: "
1949  "--args \" date_range \\\"from,to\\\" \"\nFROM should be in "
1950  "seconds from Jan 1970, and TO is added to that number.\nDefault "
1951  "FROM is the current time, and default TO is 'no expiry.'\nAlso: "
1952  "--args \" consideration \\\"like a memo\\\" \" \nAlso: --args \" "
1953  "initial_payment \\\"amount,delay\\\" \" \nDefault 'amount' (0 or "
1954  "\"\") == no initial payment. Default 'delay' (0 or \"\") is "
1955  "seconds from creation date.\nAlso: --args \" payment_plan "
1956  "\\\"amount,delay,period\\\" \" \n'amount' is a recurring "
1957  "payment. 'delay' and 'period' cause 30 days if you pass 0 or "
1958  "\"\".\n'delay' and 'period' are both measured in seconds. Period "
1959  "is time between\neach payment. Delay is time until first "
1960  "payment.\nAlso: --args \" plan_expiry \\\"length,number\\\" \" "
1961  "\n'length' is maximum lifetime in seconds. 'number' is maximum "
1962  "number of payments. 0 or \"\" is unlimited (for both.)\n\n";
1963 
1964  if (VerifyExists("Server") && VerifyExists("MyNym") &&
1965  VerifyExists("MyAcct") && VerifyExists("HisNym") &&
1966  VerifyExists("HisAcct")) {
1967  string strDates = "";
1968  string strConsideration = "";
1969  string strInitialPayment = "";
1970  string strPaymentPlan = "";
1971  string strExpiry = "";
1972 
1973  if (VerifyExists("Args", false)) {
1974  string strTempDates = OT_CLI_GetValueByKey(Args, "date_range");
1975  string strTempConsideration =
1976  OT_CLI_GetValueByKey(Args, "consideration");
1977  string strTempInitialPayment =
1978  OT_CLI_GetValueByKey(Args, "initial_payment");
1979  string strTempPaymentPlan =
1980  OT_CLI_GetValueByKey(Args, "payment_plan");
1981  string strTempExpiry = OT_CLI_GetValueByKey(Args, "plan_expiry");
1982 
1983  if (VerifyStringVal(strTempDates)) {
1984  strDates = strTempDates;
1985  }
1986  if (VerifyStringVal(strTempConsideration)) {
1987  strConsideration = strTempConsideration;
1988  }
1989  if (VerifyStringVal(strTempInitialPayment)) {
1990  strInitialPayment = strTempInitialPayment;
1991  }
1992  if (VerifyStringVal(strTempPaymentPlan)) {
1993  strPaymentPlan = strTempPaymentPlan;
1994  }
1995  if (VerifyStringVal(strTempExpiry)) {
1996  strExpiry = strTempExpiry;
1997  }
1998  }
1999  otOut << "\n";
2000 
2001  if (!VerifyStringVal(strConsideration)) {
2002  otOut << "\nDescribe the product or service being received in "
2003  "return for the\nrecurring payments, followed by a ~ by "
2004  "itself on a blank line:\n\n";
2005 
2006  strConsideration = OT_CLI_ReadUntilEOF();
2007 
2008  if (!VerifyStringVal(strConsideration)) {
2009  return -1;
2010  }
2011  }
2012 
2013  otOut << "date_range (from,to): " << strDates << "\n";
2014  otOut << "consideration: " << strConsideration << "\n";
2015  otOut << "initial_payment (amount,delay): " << strInitialPayment
2016  << "\n";
2017  otOut << "payment_plan (amount,delay,period): " << strPaymentPlan
2018  << "\n";
2019  otOut << "plan_expiry (length,number): " << strExpiry << "\n";
2020 
2021  return details_propose_plan(
2022  Server, MyNym, MyAcct, HisNym, HisAcct, strDates, strConsideration,
2023  strInitialPayment, strPaymentPlan, strExpiry);
2024  }
2025 
2026  return -1;
2027 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
std::string HisAcct
EXPORT static OT_COMMANDS_OT int32_t details_propose_plan(const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID, const std::string &strHisNymID, const std::string &strHisAcctID, const std::string &strDates, const std::string &strConsideration, const std::string &strInitialPayment, const std::string &strPaymentPlan, const std::string &strExpiry)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string HisNym
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainRefresh ( )
static

Definition at line 6100 of file ot_commands_ot.cpp.

6101 {
6102  otOut << "Usage: refresh --server SERVER_ID --mynym YOUR_NYM_ID --myacct "
6103  "YOUR_ACCT_ID\n\n";
6104 
6105  if (VerifyExists("Server") && VerifyExists("MyNym") &&
6106  VerifyExists("MyAcct")) {
6107  int32_t nSuccess = OT_Command::mainRefreshNym();
6108 
6109  if (-1 == nSuccess) {
6110  return -1;
6111  }
6112 
6114  }
6115 
6116  return -1;
6117 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t mainRefreshAccount()
EXPORT static OT_COMMANDS_OT int32_t mainRefreshNym()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainRefreshAccount ( )
static

Definition at line 6088 of file ot_commands_ot.cpp.

6089 {
6090  otOut << "Usage: refreshaccount --server SERVER_ID --myacct "
6091  "YOUR_ACCT_ID\n\n";
6092 
6093  if (VerifyExists("Server") && VerifyExists("MyAcct")) {
6094  return download_acct_files();
6095  }
6096 
6097  return -1;
6098 }
EXPORT static OT_COMMANDS_OT int32_t download_acct_files()
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainRefreshNym ( )
static

Definition at line 6278 of file ot_commands_ot.cpp.

6279 {
6280  otOut << "Usage: refreshnym --server SERVER_ID --mynym NYM_ID\n\n(If you "
6281  "don't have a NymID, then use the newnym command first.)\n\n";
6282 
6283  if (VerifyExists("Server") && VerifyExists("MyNym")) {
6284  bool bReturnVal = details_refresh_nym(Server, MyNym, true);
6285 
6286  otOut << "\n";
6287 
6288  if (bReturnVal) {
6289  return 1;
6290  }
6291  }
6292 
6293  return -1;
6294 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT bool details_refresh_nym(const std::string &strServerID, const std::string &strMyNymID, bool bForceDownload)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainRegisterNym ( )
static

Definition at line 6209 of file ot_commands_ot.cpp.

6210 {
6211  otOut << "Usage: registernym --server SERVER_ID --mynym NYM_ID\n\n(If "
6212  "you don't have a NymID, then use create_nym.ot first.)\n\n";
6213 
6214  if (VerifyExists("Server") && VerifyExists("MyNym")) {
6215  string strResponse = MadeEasy::register_nym(Server, MyNym);
6216  int32_t nSuccess = VerifyMessageSuccess(strResponse);
6217  switch (nSuccess) {
6218  case 1:
6219  otOut << "\n\n Server response:\n\n";
6220  cout << strResponse << "\n";
6221  otOut << "\n\n SUCCESS in register_nym!\n(Also, success "
6222  "syncronizing the request number.)\n\n";
6223  break;
6224  case 0:
6225  otOut << "\n\n FAILURE in register_nym! Server response:\n\n";
6226  cout << strResponse << "\n";
6227  break;
6228  default:
6229  otOut << "\n\nError in register_nym!\n";
6230 
6231  if (VerifyStringVal(strResponse)) {
6232  otOut << "Server response:\n\n";
6233  cout << strResponse << "\n";
6234  }
6235  break;
6236  }
6237  otOut << "\n\n";
6238 
6239  return nSuccess;
6240  }
6241 
6242  return -1;
6243 }
EXPORT static OT_MADE_EASY_OT std::string register_nym(const std::string &SERVER_ID, const std::string &NYM_ID)
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainRevokeCredential ( )
static

Definition at line 38 of file ot_commands_ot.cpp.

39 {
40  otOut << "\nThis command not coded yet. We need to use the "
41  "OT_API_RevokeSubcredential API call here.\n\n";
42 
43  return -1;
44 }
OTLOG_IMPORT OTLogStream otOut
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSendCash ( )
static

Definition at line 4301 of file ot_commands_ot.cpp.

4302 {
4303 
4304  otOut << "Usage: sendcash --[myacct|mypurse] <ID> --hisnym "
4305  "<RECIPIENT_NYM_ID>\nFor mypurse, the server and nym are also "
4306  "required: --server <SERVER_ID> --mynym <NYM_ID> \nOptionally: "
4307  "--args \"passwd true\" (To send a password-protected "
4308  "purse.)\nOptionally: --args \"memo \\\"one-line memo allowed "
4309  "here.\\\" amount AMOUNT\"\nThis command sends cash to the "
4310  "recipient, from your purse if specified, and withdrawing first "
4311  "from your account, if necessary.\n\n";
4312 
4313  string strServerID = "";
4314  string strMyAcctID = "";
4315  string strMyNymID = "";
4316  string strAssetTypeID = "";
4317 
4318  bool bServerExists = VerifyExists("Server", false);
4319  bool bMyPurseExists = VerifyExists("MyPurse", false);
4320  bool bMyAcctExists = VerifyExists("MyAcct", false);
4321  bool bMyNymExists = VerifyExists("MyNym", false);
4322 
4323  if (!bMyPurseExists && !bMyAcctExists) {
4324  otOut << "\n You must provide EITHER --myacct <ACCT_ID> OR --mypurse "
4325  "<ASSET_TYPE_ID>\nFor mypurse, the server and nym are also "
4326  "required: --server <SERVER_ID> --mynym <NYM_ID> \n";
4327  return -1;
4328  }
4329 
4330  if (bMyPurseExists) {
4331  strAssetTypeID = MyPurse;
4332 
4333  if (bServerExists && bMyNymExists) {
4334  strServerID = Server;
4335  strMyNymID = MyNym;
4336  }
4337  else {
4338  otOut << "\n MyPurse was specified, but you must also specify a "
4339  "server and nym: --server <SERVER_ID> --mynym "
4340  "<NYM_ID>\nMaybe we can find them using MyAcct...\n";
4341  }
4342  }
4343  // NOTE: If MyNym and Server are not provided here, but MyAcct IS, the nym
4344  // and server can still be derived from MyAcct.
4345  // The purse will still be used, but only if it has the same asset type ID
4346  // as MyAcct does. (Meaning there was no point,
4347  // then, in specifying the purse at all, since all the info was derived from
4348  // the account in that case.)
4349 
4350  if (bMyAcctExists) {
4351  string strAcctAssetID =
4353  if (!VerifyStringVal(strAcctAssetID)) {
4354  otOut
4355  << "\n Failed trying to retrieve AssetTypeID based on MyAcct: "
4356  << MyAcct << "\n";
4357  return -1;
4358  }
4359 
4360  string strAcctServerID = OTAPI_Wrap::GetAccountWallet_ServerID(MyAcct);
4361  if (!VerifyStringVal(strAcctServerID)) {
4362  otOut << "\n Failed trying to retrieve ServerID based on MyAcct: "
4363  << MyAcct << "\n";
4364  return -1;
4365  }
4366 
4367  string strAcctNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
4368  if (!VerifyStringVal(strAcctNymID)) {
4369  otOut << "\n Failed trying to retrieve NymID based on MyAcct: "
4370  << MyAcct << "\n";
4371  return -1;
4372  }
4373 
4374  if (VerifyStringVal(strServerID) && strAcctServerID != strServerID) {
4375  otOut << "\n Server ID provided on the command line doesn't match "
4376  "the Server ID for MyAcct. Expected: " << strAcctServerID
4377  << "\n Try adding: --server " << strAcctServerID << "\n";
4378  return -1;
4379  }
4380 
4381  if (VerifyStringVal(strAssetTypeID) &&
4382  strAcctAssetID != strAssetTypeID) {
4383  otOut << "\n Asset Type ID provided on the command line doesn't "
4384  "match the Asset Type ID of MyAcct. Expected: "
4385  << strAcctAssetID << "\n Try adding: --mypurse "
4386  << strAcctAssetID << "\n";
4387  return -1;
4388  }
4389 
4390  if (VerifyStringVal(strMyNymID) && strAcctNymID != strMyNymID) {
4391  otOut << "\n Nym ID provided on the command line doesn't match the "
4392  "Nym ID for MyAcct. Expected: " << strAcctNymID
4393  << "\n Try adding: --mynym " << strAcctNymID << "\n";
4394  return -1;
4395  }
4396 
4397  strServerID = strAcctServerID;
4398  strAssetTypeID = strAcctAssetID;
4399  strMyNymID = strAcctNymID;
4400  strMyAcctID = MyAcct;
4401  }
4402 
4403  // Since MyPurse might have been specified with NO server or Nym, and with
4404  // MyAcct NOT specified,
4405  // we could potentially end up down here without a server or Nym still. This
4406  // is only possible because
4407  // we allow the purse to fall through, in case those values are picked up
4408  // from the account instead.
4409  // But by this point, we have to MAKE SURE we have a server and Nym. So
4410  // let's do that now:
4411 
4412  if (!VerifyStringVal(strServerID)) {
4413  otOut << "\n Failed: Missing Server ID. Try adding: --server "
4414  "<SERVER_ID>\n";
4415  return -1;
4416  }
4417 
4418  if (!VerifyStringVal(strMyNymID)) {
4419  otOut << "\n Failed: Missing MyNym ID. Try adding: --mynym <NYM_ID>\n";
4420  return -1;
4421  }
4422 
4423  // Below this point, we KNOW there's EITHER a purse OR account (or both.)
4424  // We know if there is only a purse specified, that it properly also has
4425  // a serverID and nymID. (MyPurse itself being the asset type ID.)
4426  //
4427  // We know that if a purse AND account are both specified, that they have
4428  // matching asset types, AND matching server and nym IDs. You might think
4429  // there'd be no point in doing that, since you could just not specify the
4430  // purse at all, and only specify the account. And you'd be right! Either
4431  // way,
4432  // we'll try to pay it first out of the cash purse, and only withdraw from
4433  // the account if we're unable to pay it solely through the purse first.
4434  //
4435  // We know that strServerID is correct, strAssetTypeID is correct, and
4436  // strMyNymID
4437  // is correct, whether we're using an account or a purse. And we know that
4438  // if
4439  // we're using an account, we know that strMyAcctID is correct as well.
4440  //
4441  // Below this point we can just try to pay it from the purse, and if unable
4442  // to,
4443  // try to get the remaining funds from the account, IF that's available.
4444  if (!VerifyExists("HisNym")) {
4445  otOut
4446  << "\n Failed: Missing HisNym ID. Try adding: --hisnym <NYM_ID>\n";
4447  return -1;
4448  }
4449 
4450  // Make sure the recipient exists first.
4451  // That will avoid starting the cash withdrawal process unnecessarily
4452  string hisPubKey =
4453  MadeEasy::load_or_retrieve_encrypt_key(strServerID, strMyNymID, HisNym);
4454  if (!VerifyStringVal(hisPubKey)) {
4455  otOut << "\n Failed: Unknown HisNym ID: " << HisNym << "\n";
4456  return -1;
4457  }
4458 
4459  string strAmount = "0";
4460  string strMemo = "";
4461 
4462  string strDefaultAmount = "1";
4463  string strDefaultMemo = "(blank memo field)";
4464 
4465  string strIndices = "";
4466  bool bPasswordProtected = false;
4467 
4468  // If custom arguments have been passed on the command line,
4469  // then grab them and use them instead of asking the user to enter them
4470  // at the command line.
4471  if (VerifyExists("Args", false)) {
4472  strIndices = OT_CLI_GetValueByKey(Args, "indices");
4473 
4474  string strPasswordProtected = OT_CLI_GetValueByKey(Args, "passwd");
4475 
4476  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
4477  string strNewMemo = OT_CLI_GetValueByKey(Args, "memo");
4478 
4479  if (VerifyStringVal(strNewAmount)) {
4480  strAmount = strNewAmount;
4481  }
4482  if (VerifyStringVal(strNewMemo)) {
4483  strMemo = strNewMemo;
4484  }
4485  if (VerifyStringVal(strPasswordProtected) &&
4486  ("true" == strPasswordProtected)) {
4487  bPasswordProtected = true;
4488  }
4489  }
4490 
4491  // If the withdrawal parameters aren't provided, then we
4492  // ask the user to supply them at the command line.
4493  if ((!VerifyStringVal(strAmount) ||
4494  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) &&
4495  !VerifyStringVal(strIndices)) {
4496  otOut << "Enter the amount[" << strDefaultAmount << "]: ";
4497  strAmount = OT_CLI_ReadLine();
4498  }
4499 
4500  if (!VerifyStringVal(strAmount) ||
4501  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
4502  strAmount = strDefaultAmount;
4503  }
4504 
4505  if (!VerifyStringVal(strMemo)) {
4506  otOut << "Optionally, enter a memo on a single line[" << strDefaultMemo
4507  << "]: ";
4508  strMemo = OT_CLI_ReadLine();
4509  }
4510 
4511  string strResponse = "";
4512 
4513  int32_t nReturnVal = details_send_cash(
4514  strResponse, strServerID, strAssetTypeID, strMyNymID, strMyAcctID,
4515  HisNym, strMemo, strAmount, strIndices, bPasswordProtected);
4516 
4517  if (1 != nReturnVal) {
4518  otOut << "mainSendCash: Failed in details_send_cash.\n";
4519  return -1;
4520  }
4521 
4522  otOut << "Success in sendcash! Server response:\n\n";
4523  cout << strResponse << "\n";
4524  otOut << "(Success in sendcash)\n";
4525 
4526  return 1;
4527 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_encrypt_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
std::string HisNym
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
EXPORT static OT_COMMANDS_OT int32_t details_send_cash(std::string &strResponse, const std::string &strServerID, const std::string &strAssetTypeID, const std::string &strMyNymID, const std::string &strMyAcctID, std::string &strHisNymID, const std::string &strMemo, const std::string &strAmount, std::string &strIndices, bool bPasswordProtected)
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSendCheque ( )
static

Definition at line 4529 of file ot_commands_ot.cpp.

4530 {
4531  otOut << "Usage: sendcheque --myacct <MY_ACCT_ID> --hisnym "
4532  "<RECIPIENT_NYM_ID>\nOptionally: --args \"memo \\\"one-line memo "
4533  "allowed here.\\\" amount AMOUNT\"\nAdditionally: --args "
4534  "\"validfor IN_SECONDS\" \nThis command WRITES AND SENDS the "
4535  "cheque.\n(Use 'writecheque', not 'sendcheque', if you don't want "
4536  "it to be immediately SENT.)\n";
4537 
4538  string strCheque = "";
4539  int32_t nReturnVal = details_write_cheque(strCheque, false);
4540 
4541  if ((1 == nReturnVal) && VerifyStringVal(strCheque)) {
4542 
4543  otOut << "\n-------------------------------------------\n the "
4544  "cheque:\n\n";
4545 
4546  cout << strCheque << "\n";
4547 
4548  otOut << "\n";
4549 
4550  // TODO: Store a copy in outpayments box (OR VERIFY THAT IT'S ALREADY
4551  // BEING DONE, WHICH I BELIEVE THAT IT IS.)
4552 
4553  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strCheque);
4554  string strSenderNymID = OTAPI_Wrap::Instrmnt_GetSenderUserID(strCheque);
4555  string strRecipientNymID =
4557 
4558  if (!VerifyStringVal(strServerID)) {
4559  otOut << "Unable to retrieve a Server ID from this cheque! Very "
4560  "strange. (Failure.)\n";
4561  return -1;
4562  }
4563  if (!VerifyStringVal(strSenderNymID)) {
4564  otOut << "Unable to retrieve a Sender Nym ID from this cheque! "
4565  "Very strange. (Failure.)\n";
4566  return -1;
4567  }
4568  if (!VerifyStringVal(strRecipientNymID)) {
4569  otOut << "Unable to retrieve a Recipient Nym ID from this cheque! "
4570  "Very strange. (Failure.)\n(Although it's fine to WRITE a "
4571  "cheque with no recipient, still need the ID to SEND "
4572  "one.)\n";
4573  return -1;
4574  }
4575 
4576  string strResponse = MadeEasy::send_user_payment(
4577  strServerID, strSenderNymID, strRecipientNymID, strCheque);
4578  nReturnVal = VerifyMessageSuccess(strResponse);
4579 
4580  if (1 != nReturnVal) {
4581  otOut << "sendcheque: Failed.\n";
4582 
4583  if (VerifyStringVal(strResponse)) {
4585  strResponse, strSenderNymID, false, false, false, false,
4586  false);
4587  }
4588  }
4589  else {
4590  otOut << "Success in sendcheque! Server response:\n\n";
4591  cout << strResponse << "\n";
4592  otOut << "(Success in sendcheque)\n";
4593  return 1;
4594  }
4595  }
4596 
4597  return nReturnVal;
4598 }
static EXPORT bool Msg_HarvestTransactionNumbers(const std::string &THE_MESSAGE, const std::string &USER_ID, const bool &bHarvestingForRetry, const bool &bReplyWasSuccess, const bool &bReplyWasFailure, const bool &bTransactionWasSuccess, const bool &bTransactionWasFailure)
Definition: OTAPI.cpp:1434
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Instrmnt_GetSenderUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:845
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_write_cheque(std::string &strCheque, bool bIsInvoice)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSendInvoice ( )
static

Definition at line 4600 of file ot_commands_ot.cpp.

4601 {
4602  otOut << "Usage: sendinvoice --myacct <MY_ACCT_ID> --hisnym "
4603  "<RECIPIENT_NYM_ID>\nOptionally: --args \"memo \\\"one-line memo "
4604  "allowed here.\\\" amount AMOUNT\"\nAdditionally: --args "
4605  "\"validfor IN_SECONDS\" \nThis command WRITES AND SENDS the "
4606  "invoice. (Use 'writeinvoice', not 'sendinvoice',\nif you don't "
4607  "want it to be immediately SENT.)\n";
4608 
4609  string strCheque = "";
4610  int32_t nReturnVal = details_write_cheque(strCheque, true);
4611 
4612  if ((1 == nReturnVal) && VerifyStringVal(strCheque)) {
4613 
4614  otOut << "\n-------------------------------------------\n the "
4615  "invoice:\n\n";
4616 
4617  cout << strCheque << "\n";
4618 
4619  otOut << "\n";
4620 
4621  // TODO: Store a copy in outpayments box (OR VERIFY THAT IT'S ALREADY
4622  // BEING DONE, WHICH I BELIEVE THAT IT IS.)
4623 
4624  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strCheque);
4625  string strSenderNymID = OTAPI_Wrap::Instrmnt_GetSenderUserID(strCheque);
4626  string strRecipientNymID =
4628 
4629  if (!VerifyStringVal(strServerID)) {
4630  otOut << "Unable to retrieve a Server ID from this invoice! Very "
4631  "strange. (Failure.)\n";
4632  return -1;
4633  }
4634  if (!VerifyStringVal(strSenderNymID)) {
4635  otOut << "Unable to retrieve a Sender Nym ID from this invoice! "
4636  "Very strange. (Failure.)\n";
4637  return -1;
4638  }
4639  if (!VerifyStringVal(strRecipientNymID)) {
4640  otOut << "Unable to retrieve a Recipient Nym ID (Endorsee) from "
4641  "this invoice! Very strange. (Failure.)\n(Although it's "
4642  "fine to WRITE a invoice with no endorsee, still need the "
4643  "ID to SEND it.)\n";
4644  return -1;
4645  }
4646 
4647  string strResponse = MadeEasy::send_user_payment(
4648  strServerID, strSenderNymID, strRecipientNymID, strCheque);
4649  nReturnVal = VerifyMessageSuccess(strResponse);
4650 
4651  if (1 != nReturnVal) {
4652  otOut << "sendinvoice: Failed.\n";
4653  }
4654  else {
4655  otOut << "Success in sendinvoice! Server response:\n\n";
4656  cout << strResponse << "\n";
4657  otOut << "(Success in sendinvoice)\n";
4658  return 1;
4659  }
4660  }
4661 
4662  return nReturnVal;
4663 }
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Instrmnt_GetSenderUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:845
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_write_cheque(std::string &strCheque, bool bIsInvoice)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSendMessage ( )
static

Definition at line 3986 of file ot_commands_ot.cpp.

3987 {
3988  otOut << "Usage: sendmessage --server <SERVER_ID> --mynym <YOUR_NYM_ID> "
3989  "--hisnym <RECIPIENT_NYM_ID>\n\n";
3990 
3991  if (VerifyExists("Server") && VerifyExists("MyNym") &&
3992  VerifyExists("HisNym")) {
3993 
3994  string strName = OTAPI_Wrap::GetServer_Name(Server);
3995  if (!VerifyStringVal(strName)) {
3996  otOut << "Error: unkknown server ID: " << Server << "\n";
3997  return -1;
3998  }
3999 
4000  string myPubKey =
4002  if (!VerifyStringVal(myPubKey)) {
4003  otOut << "\n Failed: Unknown MyNym ID: " << MyNym << "\n";
4004  return -1;
4005  }
4006 
4007  string hisPubKey =
4009  if (!VerifyStringVal(hisPubKey)) {
4010  otOut << "\n Failed: Unknown HisNym ID: " << HisNym << "\n";
4011  return -1;
4012  }
4013 
4014  otOut << "Please enter your message on multiple lines, optionally "
4015  "beginning with a \"Subject: \" line.\n";
4016  otOut << "Use Ctrl-C to cancel, otherwise finish your message with an "
4017  "EOF or a ~ by itself on a blank line:\n\n";
4018 
4019  string strMessage = OT_CLI_ReadUntilEOF();
4020 
4021  string strResponse =
4022  MadeEasy::send_user_msg(Server, MyNym, HisNym, strMessage);
4023  if (1 != VerifyMessageSuccess(strResponse)) {
4024  otOut << "send_user_msg: Failed.\n";
4025  }
4026  else {
4027  otOut << "Success in send_user_msg! Server response:\n\n";
4028  cout << strResponse << "\n";
4029  otOut << "\nSuccess in send_user_msg.\n\n";
4030  return 1;
4031  }
4032  }
4033 
4034  return -1;
4035 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_MADE_EASY_OT std::string send_user_msg(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_MESSAGE)
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_encrypt_key(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &TARGET_NYM_ID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string HisNym
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSendVoucher ( )
static

Definition at line 6737 of file ot_commands_ot.cpp.

6738 {
6739  otOut << "Usage: sendvoucher --myacct MY_ASSET_ACCT --hisnym "
6740  "RECIPIENT_NYM_ID\nOptionally: --args \"memo \\\"one-line memo "
6741  "allowed here.\\\" amount AMOUNT\"\nServer is deduced from "
6742  "MyAcct. This command withdraws AND SENDS the\nvoucher. (Use "
6743  "'withdrawvoucher', not 'sendvoucher', if you don't want it to be "
6744  "immediately SENT.)\n";
6745 
6746  if (VerifyExists("MyAcct")) {
6747  string strCheque = "";
6748  int32_t nReturnVal = details_withdraw_voucher(strCheque);
6749 
6750  if ((1 == nReturnVal) && VerifyStringVal(strCheque)) {
6751 
6752  otOut << "\n-------------------------------------------\n the "
6753  "voucher:\n\n";
6754 
6755  cout << strCheque << "\n";
6756 
6757  otOut << "\n";
6758 
6759  // TODO: Store a copy in outpayments box (OR VERIFY THAT IT'S
6760  // ALREADY BEING DONE, WHICH I BELIEVE THAT IT IS.)
6761 
6762  string strServerID = OTAPI_Wrap::Instrmnt_GetServerID(strCheque);
6763  if (!VerifyStringVal(strServerID)) {
6764  otOut << "Unable to retrieve a Server ID from this voucher! "
6765  "Very strange. (Failure.)\n";
6766  return -1;
6767  }
6768 
6769  string strSenderNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
6770  if (!VerifyStringVal(strSenderNymID)) {
6771  otOut << "Unable to retrieve a Sender Nym ID from this "
6772  "voucher! Very strange. (Failure.)\n";
6773  return -1;
6774  }
6775 
6776  string strRecipientNymID =
6778  if (!VerifyStringVal(strRecipientNymID)) {
6779  otOut << "Unable to retrieve a Recipient Nym ID from this "
6780  "voucher! Very strange. (Failure.)\n(Although it's "
6781  "fine to WITHDRAW a voucher with no recipient, still "
6782  "need the recipient ID to SEND one.)\n";
6783  return -1;
6784  }
6785 
6786  string strResponse = MadeEasy::send_user_payment(
6787  strServerID, strSenderNymID, strRecipientNymID, strCheque);
6788  nReturnVal = VerifyMessageSuccess(strResponse);
6789  if (1 == nReturnVal) {
6790  otOut << "Success in sendvoucher! Server response:\n\n";
6791  cout << strResponse << "\n";
6792  otOut << "(Success in sendvoucher)\n";
6793  return 1;
6794  }
6795 
6796  otOut << "sendvoucher: Failed.\n";
6797  }
6798 
6799  return nReturnVal;
6800  }
6801 
6802  return -1;
6803 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT std::string Instrmnt_GetServerID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:823
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT int32_t VerifyMessageSuccess(const string &strMessage)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
EXPORT static OT_MADE_EASY_OT std::string send_user_payment(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &RECIPIENT_NYM_ID, const std::string &THE_PAYMENT)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyAcct
EXPORT static OT_COMMANDS_OT int32_t details_withdraw_voucher(std::string &strOutput)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowAccount ( )
static

Definition at line 5415 of file ot_commands_ot.cpp.

5416 {
5417  if (VerifyExists("MyAcct")) {
5418  return details_stat_account(MyAcct);
5419  }
5420  return -1;
5421 }
EXPORT static OT_COMMANDS_OT int32_t details_stat_account(const std::string &strID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowAccounts ( )
static

Definition at line 5350 of file ot_commands_ot.cpp.

5351 {
5352  cout << "------------------------------------------------------------------"
5353  "\n";
5354  cout << " ** ACCOUNTS: \n\n";
5355 
5356  int32_t nAccountCount = OTAPI_Wrap::GetAccountCount();
5357 
5358  for (int32_t i = 0; i < nAccountCount; ++i) {
5359  if ((i > 0) && (i != (nAccountCount))) {
5360  cout << "-------------------------------------\n";
5361  }
5362  string strID = OTAPI_Wrap::GetAccountWallet_ID(i);
5363  string strStatAcct = MadeEasy::stat_asset_account(strID);
5364  bool bSuccess = VerifyStringVal(strStatAcct);
5365  if (bSuccess) {
5366  cout << strStatAcct << "\n";
5367  }
5368  else {
5369  cout << "Error trying to stat an asset account: " << strID << "\n";
5370  }
5371 
5372  cout << "\n";
5373  }
5374  cout << "------------------------------------------------------------------"
5375  "\n";
5376 
5377  return 1;
5378 }
static EXPORT int32_t GetAccountCount()
Definition: OTAPI.cpp:526
EXPORT static OT_MADE_EASY_OT std::string stat_asset_account(const std::string &ACCOUNT_ID)
static EXPORT std::string GetAccountWallet_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:919
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowActive ( )
static

Definition at line 9310 of file ot_commands_ot.cpp.

9311 {
9312  otOut << "Usage: showactive --server SERVER_ID --mynym NYM_ID (To "
9313  "display a list of IDs.)\nOR: showactive --server SERVER_ID "
9314  "--args \"id TRANSACTION_ID\"\n\nLists the transaction numbers of "
9315  "currently active payment plans\nand smart contracts. Also useful "
9316  "for displaying contents by ID.\n\n";
9317 
9318  string strError = "\nPlease provide either: --mynym NYM_ID (to view a "
9319  "list of active transactions)\nor, to view details for a "
9320  "specific transaction, use --args \"id TRANSACTION_ID\" "
9321  "\n\n";
9322 
9323  if (VerifyExists("Server")) {
9324  int64_t lTransNum = 0;
9325  bool bDetailMode = false;
9326 
9327  if (VerifyExists("Args", false)) {
9328  string strTransNum = OT_CLI_GetValueByKey(Args, "id");
9329  if (VerifyStringVal(strTransNum)) {
9330  lTransNum = std::stoll(strTransNum);
9331 
9332  if (lTransNum > 0) {
9333  bDetailMode = true;
9334  }
9335  else {
9336  otOut << "Missing argument (1): " << strError;
9337  return -1;
9338  }
9339  }
9340  }
9341  if (!bDetailMode && !VerifyExists("MyNym")) {
9342  otOut << "Missing argument (2): " << strError;
9343  return -1;
9344  }
9345  // By this point, we know for a fact that either MyNym was supplied, and
9346  // thus we need to display a list
9347  // of active transactions for the given nym/server, or otherwise,
9348  // bDetailMode will be true, and lTransNum
9349  // contains a greater-than-zero value in int64_t form, in which case, we
9350  // need to display the details
9351  // of that cron item.
9352 
9353  if (bDetailMode) {
9354  string strCronItem =
9356 
9357  if (VerifyStringVal(strCronItem)) {
9358  string strType = OTAPI_Wrap::Instrmnt_GetType(strCronItem);
9359 
9360  if (!VerifyStringVal(strType)) {
9361  strType = "UNKNOWN";
9362  }
9363 
9364  otOut << "Found an active transaction!\n";
9365  otOut << "ID: " << lTransNum << " Type: " << strType
9366  << "\n\nContents:\n\n";
9367 
9368  cout << strCronItem << "\n";
9369 
9370  otOut << "\n";
9371  }
9372  }
9373  else {
9375 
9376  if (VerifyStringVal(strIDs) &&
9377  OTAPI_Wrap::NumList_Count(strIDs) > 0) {
9378  vector<string> vecIDs = tokenize(strIDs, ",", true);
9379 
9380  for (size_t nIndex = 0; nIndex < vecIDs.size(); ++nIndex) {
9381  string strTransNum = vecIDs[nIndex];
9382  if (VerifyStringVal(strTransNum)) {
9383  lTransNum = std::stoll(strTransNum);
9384 
9385  if (lTransNum > 0) {
9386  string strCronItem = OTAPI_Wrap::GetActiveCronItem(
9387  Server, lTransNum);
9388 
9389  if (VerifyStringVal(strCronItem)) {
9390  string strType =
9391  OTAPI_Wrap::Instrmnt_GetType(strCronItem);
9392  ;
9393 
9394  if (!VerifyStringVal(strType)) {
9395  strType = "UNKNOWN";
9396  }
9397  if (0 == nIndex) {
9398  otOut << "\n Found " << vecIDs.size()
9399  << " active transactions:\n\n";
9400  }
9401  cout << "ID: " << strTransNum
9402  << " Type: " << strType << "\n\n";
9403  }
9404  }
9405  }
9406  }
9407  otOut << "\n";
9408  }
9409  else {
9410  otOut << "\nFound no active transactions. Perhaps try 'opentxs "
9411  "refresh' first?\n";
9412  }
9413  }
9414  return 1;
9415  }
9416  return -1;
9417 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
static EXPORT std::string GetNym_ActiveCronItemIDs(const std::string &NYM_ID, const std::string &SERVER_ID)
Definition: OTAPI.cpp:365
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
vector< string > tokenize(const string &str, const string &delimiters, bool trimEmpty)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
static EXPORT std::string GetActiveCronItem(const std::string &SERVER_ID, int64_t lTransNum)
Definition: OTAPI.cpp:370
static EXPORT int32_t NumList_Count(const std::string &strNumList)
Definition: OTAPI.cpp:353
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowAssets ( )
static

Definition at line 5333 of file ot_commands_ot.cpp.

5334 {
5335  cout << "------------------------------------------------------------------"
5336  "\n";
5337  cout << " ** ASSET TYPES: \n\n";
5338  int32_t nAssetTypeCount = OTAPI_Wrap::GetAssetTypeCount();
5339 
5340  for (int32_t i = 0; i < nAssetTypeCount; ++i) {
5341  string strID = OTAPI_Wrap::GetAssetType_ID(i);
5342  string strName = OTAPI_Wrap::GetAssetType_Name(strID);
5343 
5344  cout << strID << " --- " << strName << "\n";
5345  }
5346 
5347  return 1;
5348 }
static EXPORT int32_t GetAssetTypeCount()
Definition: OTAPI.cpp:521
static EXPORT std::string GetAssetType_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:904
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowBalance ( )
static

Definition at line 5448 of file ot_commands_ot.cpp.

5449 {
5450  if (VerifyExists("MyAcct")) {
5452  }
5453  return -1;
5454 }
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_account_balance(const std::string &strID)
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowBasket ( )
static

Definition at line 64 of file ot_commands_ot.cpp.

65 {
66  otOut << "Usage: showbasket\nOPTIONAL: --args \"index "
67  "BASKET_INDEX\"\n\nNOTE: If you leave off the index, then it "
68  "lists all the basket currencies.\nBut if an index is provided, "
69  "this command will zoom in and show the details\nfor that "
70  "specific basket currency.\n\n";
71 
73 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT int32_t details_show_basket()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowCredential ( )
static

Definition at line 1537 of file ot_commands_ot.cpp.

1538 {
1539  otOut << "Usage: showcredential --mynym NYM_ID --args \"id "
1540  "CREDENTIAL_ID\"\n\nThis command displays the contents of a given "
1541  "credential (for a given Nym.)\n\n";
1542 
1543  if (VerifyExists("MyNym")) {
1544  string strCredID = "";
1545 
1546  if (VerifyExists("Args", false)) {
1547  string strTempCredID = OT_CLI_GetValueByKey(Args, "id");
1548 
1549  if (!VerifyStringVal(strTempCredID)) {
1550  otOut << "Please enter the ID for the credential: ";
1551  string strInput = OT_CLI_ReadLine();
1552 
1553  if (VerifyStringVal(strInput)) {
1554  strCredID = strInput;
1555  }
1556  }
1557  else {
1558  strCredID = strTempCredID;
1559  }
1560  }
1561 
1562  if (VerifyStringVal(strCredID) &&
1563  details_show_credential(MyNym, strCredID)) {
1564  return 1;
1565  }
1566  }
1567 
1568  return -1;
1569 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT bool details_show_credential(const std::string &strMyNymID, const std::string &strCredID)
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowCredentials ( )
static

Definition at line 1660 of file ot_commands_ot.cpp.

1661 {
1662  otOut << "Usage: credentials --mynym NYM_ID\n\nThis command displays the "
1663  "list of credentials for a given Nym.\n\n";
1664 
1665  if (VerifyExists("MyNym")) {
1667  }
1668 
1669  return -1;
1670 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_show_credentials(const std::string &strMyNymID)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowExpired ( )
static

Definition at line 10296 of file ot_commands_ot.cpp.

10297 {
10298  string strLocation = "mainShowExpired";
10299 
10300  // SHOW EXPIRED RECORD BOX
10301  if (VerifyExists("MyNym") && VerifyExists("Server")) {
10302  string strMyNymID = MyNym;
10303  string strServerID = Server;
10304 
10305  // expiredbox for MyNym contains the old payments (in and out.)
10306 
10307  otOut << "\n\nNote: OT is completely done with these expired records. "
10308  "A proper GUI will sweep them out\nperiodically and archive "
10309  "them somewhere, or just erase them. All you can do at "
10310  "the\ncommand line (using this tool) is view them, or erase "
10311  "them using: opentxs clearexpired \n\n";
10312  otOut << "\nArchived Nym-related expired records (" << strMyNymID
10313  << "): \n";
10314 
10315  return details_show_expired_records(strServerID, strMyNymID);
10316  }
10317 
10318  return -1;
10319 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_show_expired_records(const std::string &strServerID, const std::string &strMyNymID)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowIncoming ( )
static

Definition at line 9629 of file ot_commands_ot.cpp.

9630 {
9631  int32_t nShowPayments = -1;
9632  int32_t nShowInbox = -1;
9633 
9634  if (VerifyExists("MyAcct", false)) {
9635  nShowInbox = OT_Command::mainInbox();
9636  }
9637  else {
9638  otOut << "Try adding --myacct ASSET_ACCT_ID (to see the asset "
9639  "account's inbox.)\n";
9640  }
9641 
9642  if (VerifyExists("Server", false) && VerifyExists("MyNym", false)) {
9643  nShowPayments = OT_Command::mainInpayments();
9644  }
9645  else {
9646  otOut << "Try adding --mynym NYM_ID and --server SERVER_ID\n(to see "
9647  "the payments inbox for that Server and Nym.)\n";
9648  }
9649 
9650  if ((nShowInbox > -1) || (nShowPayments > -1)) {
9651  return 1;
9652  }
9653 
9654  return -1;
9655 }
EXPORT static OT_COMMANDS_OT int32_t mainInbox()
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t mainInpayments()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowMarkets ( )
static

Definition at line 6839 of file ot_commands_ot.cpp.

6840 {
6841  if (VerifyExists("Server")) {
6842  OTDB::MarketList* marketListPtr = loadMarketList(Server);
6843  if (!marketListPtr) {
6844  otOut << "Unable to load up marketlist from local storage.\n";
6845  return -1;
6846  }
6847  OTDB::MarketList& marketList = *marketListPtr;
6848 
6849  // LOOP THROUGH THE MARKETS AND PRINT THEM OUT.
6850 
6851  int32_t nCount = marketList.GetMarketDataCount();
6852  if (0 > nCount) {
6853  otOut << "Loaded the market list, but GetMarketDataCount returns "
6854  "an invalid result. (Failure.)\n";
6855  }
6856  else if (nCount <= 0) {
6857  otOut << "Loaded the market list, but GetMarketDataCount says "
6858  "there aren't any markets in the list. (Returning.)\n";
6859  }
6860  else {
6861  otOut << "\nIndex\tScale\tMarket\t\t\t\t\t\tAsset\t\t\t\t\t\tCurren"
6862  "cy\n";
6863 
6864  for (int32_t nIndex = 0; nIndex < nCount; ++nIndex) {
6865  OTDB::MarketData* marketDataPtr =
6866  marketList.GetMarketData(nIndex);
6867  if (!marketDataPtr) {
6868  otOut << "Unable to reference marketData on marketList, at "
6869  "index: " << nIndex << "\n";
6870  return -1;
6871  }
6872  OTDB::MarketData& marketData = *marketDataPtr;
6873 
6874  // OUTPUT THE MARKET DATA...
6875  cout << nIndex << "\t" << marketData.scale << "\tM "
6876  << marketData.market_id << "\tA "
6877  << marketData.asset_type_id << "\tC "
6878  << marketData.currency_type_id << "\n";
6879  }
6880  }
6881 
6882  return 1;
6883  }
6884 
6885  return -1;
6886 }
std::string Server
EXPORT static OT_COMMANDS_OT OTDB::MarketList * loadMarketList(const std::string &strerverID)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowMint ( )
static

Definition at line 5475 of file ot_commands_ot.cpp.

5476 {
5477  if (VerifyExists("Server") && VerifyExists("MyNym") &&
5478  VerifyExists("MyPurse")) {
5479 
5480  string strMint =
5482  if (!VerifyStringVal(strMint)) {
5483  otOut << "\n\n load_or_retrieve_mint: Failed.\n\n";
5484  return -1;
5485  }
5486  else {
5487  otOut << "\n\n";
5488  cout << strMint << "\n";
5489  otOut << "\n\n";
5490  return 1;
5491  }
5492  }
5493 
5494  return -1;
5495 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_MADE_EASY_OT std::string load_or_retrieve_mint(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ASSET_ID)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowMyOffers ( )
static

Definition at line 7271 of file ot_commands_ot.cpp.

7272 {
7273  otOut << "Usage: showmyoffers --server SERVER_ID --mynym YOUR_NYM_ID\n\n";
7274 
7275  if (VerifyExists("Server") && VerifyExists("MyNym")) {
7277  }
7278 
7279  return -1;
7280 }
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_show_nym_offers(const std::string &strServerID, const std::string &strNymID)
std::string MyNym
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowNym ( )
static

Definition at line 5467 of file ot_commands_ot.cpp.

5468 {
5469  if (VerifyExists("MyNym")) {
5470  return details_nym_stat(MyNym);
5471  }
5472  return -1;
5473 }
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
std::string MyNym
EXPORT static OT_COMMANDS_OT int32_t details_nym_stat(const std::string &strID)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowNyms ( )
static

Definition at line 5296 of file ot_commands_ot.cpp.

5297 {
5298  cout << "------------------------------------------------------------------"
5299  "\n";
5300  cout << " ** NYMS: \n\n";
5301 
5302  int32_t nNymCount = OTAPI_Wrap::GetNymCount();
5303 
5304  for (int32_t i = 0; i < nNymCount; ++i) {
5305  string strIndex = std::to_string(i);
5306  string strID = OTAPI_Wrap::GetNym_ID(i);
5307  string strName = OTAPI_Wrap::GetNym_Name(strID);
5308 
5309  cout << strIndex << ": " << strID << " --- " << strName << "\n";
5310  }
5311 
5312  return 1;
5313 }
static EXPORT std::string GetNym_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:643
std::string to_string(const T &t)
static EXPORT int32_t GetNymCount()
Definition: OTAPI.cpp:511
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowOffers ( )
static

Definition at line 7043 of file ot_commands_ot.cpp.

7044 {
7045  string strMarket;
7046 
7047  return impl_show_market_offers(strMarket);
7048 }
EXPORT static OT_COMMANDS_OT int32_t impl_show_market_offers(std::string &strMarket)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowOutgoing ( )
static

Definition at line 9657 of file ot_commands_ot.cpp.

9658 {
9659  int32_t nShowPayments = -1;
9660  int32_t nShowOutbox = -1;
9661 
9662  if (VerifyExists("MyAcct", false)) {
9663  nShowOutbox = OT_Command::mainOutbox();
9664  }
9665  else {
9666  otOut << "Try adding --myacct ASSET_ACCT_ID (to see the asset "
9667  "account's outbox.)\n";
9668  }
9669 
9670  if (VerifyExists("MyNym", false)) {
9671  nShowPayments = OT_Command::mainOutpayment();
9672  }
9673  else {
9674  otOut << "Try adding --mynym NYM_ID (to see the outpayment box for "
9675  "that Nym.)\n";
9676  }
9677 
9678  if ((nShowOutbox > -1) || (nShowPayments > -1)) {
9679  return 1;
9680  }
9681 
9682  return -1;
9683 }
EXPORT static OT_COMMANDS_OT int32_t mainOutbox()
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t mainOutpayment()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowPayment ( )
static

Definition at line 9421 of file ot_commands_ot.cpp.

9422 {
9423  otOut << "Usage: showpayment --args \"index PAYMENT_INDEX showmemo "
9424  "true|false\"\n Default index is 0. Default showmemo is false.\n";
9425 
9426  // SHOW a payment from the PAYMENTS INBOX
9427  //
9428  // Load an asset account's payments inbox from local storage and display it
9429  // on the screen.
9430 
9431  if (VerifyExists("Server") && VerifyExists("MyNym") &&
9432  VerifyExists("Args")) {
9433  string strIndex = OT_CLI_GetValueByKey(Args, "index");
9434  string strShowLargeMemo = OT_CLI_GetValueByKey(Args, "showmemo");
9435  int32_t nIndex = 0;
9436  bool bShowLargeMemo = false;
9437 
9438  // Set the values based on the custom arguments, for those found.
9439  if (VerifyStringVal(strShowLargeMemo) && ("true" == strShowLargeMemo)) {
9440  bShowLargeMemo = true;
9441  }
9442 
9443  if (VerifyStringVal(strIndex)) {
9444  int32_t nTempIndex = std::stol(strIndex);
9445 
9446  if (nTempIndex >= 0) {
9447  nIndex = nTempIndex;
9448  }
9449  }
9450 
9451  string strInbox = OTAPI_Wrap::LoadPaymentInbox(Server, MyNym);
9452 
9453  if (!VerifyStringVal(strInbox)) {
9454  otOut << "\n\n OT_API_LoadPaymentInbox: Failed.\n\n";
9455  return -1;
9456  }
9457  else {
9458  otOut << "\n\n";
9459 
9460  int32_t nCount =
9462  if (0 <= nCount) {
9463  if (nIndex > (nCount - 1)) {
9464  otOut << "Index out of bounds. (There are " << nCount
9465  << " indices, starting at 0.\n";
9466  return -1;
9467  }
9468 
9469  otOut << "Ind Amt Type Txn# Memo\n";
9470  otOut << "---------------------------------\n";
9471 
9472  string strInstrument = OTAPI_Wrap::Ledger_GetInstrument(
9473  Server, MyNym, MyNym, strInbox, nIndex);
9474 
9475  if (!VerifyStringVal(strInstrument)) {
9476  otOut << "Failed trying to get payment instrument from "
9477  "payments box.\n";
9478  return -1;
9479  }
9480 
9481  string strTrans = OTAPI_Wrap::Ledger_GetTransactionByIndex(
9482  Server, MyNym, MyNym, strInbox, nIndex);
9483  int64_t lTransNumber =
9485  Server, MyNym, MyNym, strInbox, nIndex);
9486 
9488  Server, MyNym, MyNym, strTrans);
9489 
9490  int64_t lAmount = OTAPI_Wrap::Instrmnt_GetAmount(strInstrument);
9491  string strType = OTAPI_Wrap::Instrmnt_GetType(strInstrument);
9492  string strAssetType = OTAPI_Wrap::Instrmnt_GetAssetID(
9493  strInstrument); // todo: output this.
9494  string strMemo = OTAPI_Wrap::Instrmnt_GetMemo(strInstrument);
9495  string strSenderUserID =
9496  OTAPI_Wrap::Instrmnt_GetSenderUserID(strInstrument);
9497  string strSenderAcctID =
9498  OTAPI_Wrap::Instrmnt_GetSenderAcctID(strInstrument);
9499  string strRemitterUserID =
9501  string strRemitterAcctID =
9503  string strRecipientUserID =
9505  string strRecipientAcctID =
9507 
9508  string strUserID = VerifyStringVal(strRemitterUserID)
9509  ? strRemitterUserID
9510  : strSenderUserID;
9511  string strAcctID = VerifyStringVal(strRemitterAcctID)
9512  ? strRemitterAcctID
9513  : strSenderAcctID;
9514 
9515  bool bUserIDExists = VerifyStringVal(strUserID);
9516  bool bAcctIDExists = VerifyStringVal(strAcctID);
9517  bool bAssetIDExists = VerifyStringVal(strAssetType);
9518  bool bMemoExists = VerifyStringVal(strMemo);
9519 
9520  bool bHasAmount = OT_ERROR_AMOUNT != lAmount;
9521 
9522  if (bMemoExists && (strMemo.find("\n") != string::npos) &&
9523  !bShowLargeMemo) {
9524  strMemo = "<too large to display here>";
9525  }
9526  else if (bMemoExists) {
9527  string strTempMemo = "\"" + strMemo + "\"";
9528  strMemo = strTempMemo;
9529  }
9530 
9531  string strNewlineSeparator = "";
9532 
9533  if (bUserIDExists || bAcctIDExists) {
9534  strNewlineSeparator = "\n";
9535  }
9536 
9537  string strSeparator =
9538  (!bUserIDExists && !bAcctIDExists && !bAssetIDExists)
9539  ? ""
9540  : strNewlineSeparator;
9541 
9542  // Set up some symbols to appear or not,
9543  // based on whether there is something to show.
9544  string strUserDenoter = (bUserIDExists ? "U:" : "");
9545  string strUserDenoter2 = (bUserIDExists ? " - " : "");
9546  string strAcctDenoter = (bAcctIDExists ? "A:" : "");
9547  string strAcctDenoter2 = (bAcctIDExists ? " - " : "");
9548  string strAssetDenoter = (bAssetIDExists ? "T:" : "");
9549  string strAssetDenoter2 = (bAssetIDExists ? " - " : "");
9550 
9551  // If we have the user/acct/asset ID, then get the associated
9552  // name (if that exists.)
9553  string strUserName =
9554  (bUserIDExists
9555  ? ("\"" + OTAPI_Wrap::GetNym_Name(strUserID) + "\"")
9556  : "");
9557  string strAcctName =
9558  (bAcctIDExists
9559  ? ("\"" +
9560  OTAPI_Wrap::GetAccountWallet_Name(strAcctID) + "\"")
9561  : "");
9562  string strAssetName =
9563  (bAssetIDExists
9564  ? ("\"" + OTAPI_Wrap::GetAssetType_Name(strAssetType) +
9565  "\"")
9566  : "");
9567 
9568  // Just making sure here that if the string wasn't there, that
9569  // it's set to
9570  // a proper empty string, instead of a null or a "not a value"
9571  // value.
9572  if (!VerifyStringVal(strUserName)) {
9573  strUserName = "";
9574  strUserDenoter2 = "";
9575  }
9576  if (!VerifyStringVal(strAcctName)) {
9577  strAcctName = "";
9578  strAcctDenoter2 = "";
9579  }
9580  if (!VerifyStringVal(strAssetName)) {
9581  strAssetName = "";
9582  strAssetDenoter2 = "";
9583  }
9584 
9585  if ("\"\"" == strUserName) {
9586  strUserName = "";
9587  strUserDenoter2 = "";
9588  }
9589  if ("\"\"" == strAcctName) {
9590  strAcctName = "";
9591  strAcctDenoter2 = "";
9592  }
9593  if ("\"\"" == strAssetName) {
9594  strAssetName = "";
9595  strAssetDenoter2 = "";
9596  }
9597 
9598  cout << nIndex << " ";
9599 
9600  if (bAssetIDExists && bHasAmount) {
9601  string strAmount =
9602  OTAPI_Wrap::FormatAmount(strAssetType, lAmount);
9603  cout << strAmount
9604  << (strAmount.size() < 3 ? " " : " ");
9605  }
9606  else {
9607  cout << " ";
9608  }
9609 
9610  cout << strType << (strType.size() > 10 ? " " : " ");
9611  cout << lTransNumber
9612  << (std::to_string(lTransNumber).size() < 2 ? " "
9613  : " ");
9614  cout << (bMemoExists ? strMemo : "") << "\n";
9615  cout << strUserDenoter << strUserID << strUserDenoter2
9616  << strUserName << strSeparator;
9617  cout << strAcctDenoter << strAcctID << strAcctDenoter2
9618  << strAcctName << strSeparator;
9619  cout << strAssetDenoter << strAssetType << strAssetDenoter2
9620  << strAssetName << "\n";
9621  cout << "Instrument:\n" << strInstrument << "\n";
9622  }
9623  return 1;
9624  }
9625  }
9626  return -1;
9627 }
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:924
static EXPORT int64_t Instrmnt_GetAmount(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:793
static EXPORT std::string Instrmnt_GetSenderAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:851
static EXPORT std::string Instrmnt_GetRemitterUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:833
static EXPORT std::string Instrmnt_GetRemitterAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:839
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string to_string(const T &t)
static EXPORT std::string LoadPaymentInbox(const std::string &SERVER_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1553
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
std::string Server
static EXPORT std::string Instrmnt_GetRecipientAcctID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:863
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
static EXPORT std::string Instrmnt_GetMemo(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:818
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Instrmnt_GetSenderUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:845
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT std::string Ledger_GetInstrument(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1649
static EXPORT int32_t Ledger_GetCount(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER)
Find out how many pending transactions (and receipts) are in this inbox.
Definition: OTAPI.cpp:1615
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string Ledger_GetTransactionByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1631
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
static EXPORT std::string Instrmnt_GetRecipientUserID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:857
static EXPORT int64_t Ledger_GetTransactionIDByIndex(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_LEDGER, const int32_t &nIndex)
Definition: OTAPI.cpp:1659
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT int64_t Transaction_GetDisplayReferenceToNum(const std::string &SERVER_ID, const std::string &USER_ID, const std::string &ACCOUNT_ID, const std::string &THE_TRANSACTION)
Definition: OTAPI.cpp:1754
std::string MyNym
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowPurse ( )
static

Definition at line 7456 of file ot_commands_ot.cpp.

7457 {
7458  otOut << "Usage: showpurse --mypurse ASSET_TYPE_ID --mynym YOUR_NYM_ID "
7459  "--server SERVER_ID \n\n";
7460 
7461  if (VerifyExists("Server") && VerifyExists("MyNym") &&
7462  VerifyExists("MyPurse")) {
7463 
7464  string strPurse = OTAPI_Wrap::LoadPurse(Server, MyPurse, MyNym);
7465 
7466  if (!VerifyStringVal(strPurse)) {
7467  otOut << "\n OT_Command::mainShowPurse: Unable to load purse. Does "
7468  "it even exist?\n";
7469  }
7470  else {
7471  int64_t lAmount =
7473 
7474  cout << "\n\nTOTAL VALUE: "
7475  << OTAPI_Wrap::FormatAmount(MyPurse, lAmount) << "\n";
7476 
7477  // Loop through purse contents and display tokens.
7478  int32_t nCount = OTAPI_Wrap::Purse_Count(Server, MyPurse, strPurse);
7479  if (nCount < 0) {
7480  otOut << "\n OT_Command::mainShowPurse: Error: Unexpected bad "
7481  "value returned from OT_API_Purse_Count.\n\n";
7482  return -1;
7483  }
7484 
7485  if (nCount > 0) {
7486  cout << "Token count: " << nCount << "\n\n";
7487  cout << "Index\tValue\tSeries\tValidFrom\tValidTo\t\tStatus\n";
7488 
7489  int32_t nIndex = -1;
7490 
7491  while (nCount > 0) {
7492  --nCount;
7493  ++nIndex;
7494 
7495  string strToken = OTAPI_Wrap::Purse_Peek(Server, MyPurse,
7496  MyNym, strPurse);
7497 
7498  if (!VerifyStringVal(strToken)) {
7499  otOut << "mainShowPurse: Error: OT_API_Purse_Peek "
7500  "unexpectedly returned nullptr instead of "
7501  "token.\n";
7502  return -1;
7503  }
7504 
7505  string strNewPurse =
7507 
7508  if (!VerifyStringVal(strNewPurse)) {
7509  otOut << "mainShowPurse: Error: OT_API_Purse_Pop "
7510  "unexpectedly returned nullptr instead of "
7511  "updated purse.\n";
7512  return -1;
7513  }
7514 
7515  strPurse = strNewPurse;
7516 
7517  int64_t lDenomination = OTAPI_Wrap::Token_GetDenomination(
7518  Server, MyPurse, strToken);
7519  int32_t nSeries =
7522  Server, MyPurse, strToken);
7523  time64_t tValidTo =
7525  time64_t lTime = OTAPI_Wrap::GetTime();
7526 
7527  if (0 > lDenomination) {
7528  otOut << "Error while showing purse: bad "
7529  "lDenomination.\n";
7530  return -1;
7531  }
7532  if (OT_TIME_ZERO > lTime) {
7533  otOut << "Error while showing purse: bad strTime.\n";
7534  return -1;
7535  }
7536 
7537  string strStatus = (lTime > tValidTo) ? "expired" : "valid";
7538 
7539  cout << nIndex << "\t" << lDenomination << "\t" << nSeries
7540  << "\t" << tValidFrom << "\t" << tValidTo << "\t"
7541  << strStatus << "\n";
7542  }
7543  }
7544 
7545  return 1;
7546  }
7547  }
7548 
7549  return -1;
7550 }
static EXPORT int32_t Token_GetSeries(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1949
static EXPORT std::string LoadPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1829
std::string Server
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
OTLOG_IMPORT OTLogStream otOut
int64_t time64_t
Definition: Common.hpp:209
static EXPORT time64_t Token_GetValidFrom(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
the date is seconds since Jan 1970.
Definition: OTAPI.cpp:1956
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT int32_t Purse_Count(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
returns a count of the number of cash tokens inside this purse.
Definition: OTAPI.cpp:1843
static EXPORT int64_t Purse_GetTotalValue(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
Get Purse Total Value (internally uses GetTotalValue().)
Definition: OTAPI.cpp:1836
static EXPORT time64_t Token_GetValidTo(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1963
std::string MyPurse
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Purse_Pop(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_OR_SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1879
static EXPORT int64_t Token_GetDenomination(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
The actual cash value of the token. Returns a int64_t.
Definition: OTAPI.cpp:1942
std::string MyNym
static EXPORT std::string Purse_Peek(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1871
#define OT_TIME_ZERO
Definition: Common.hpp:180
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowRecords ( )
static

Definition at line 9924 of file ot_commands_ot.cpp.

9925 {
9926  string strLocation = "mainShowRecords";
9927 
9928  // SHOW RECORD BOX
9929  //
9930  // Load an asset account's record box from local storage and display it on
9931  // the screen.
9932  bool bNymExists = VerifyExists("MyNym", false);
9933  bool bAcctExists = VerifyExists("MyAcct", false);
9934  bool bBothExist = (bNymExists && bAcctExists);
9935  bool bShowNymOnly = (bNymExists && !bAcctExists);
9936 
9937  string strMyNymID = "";
9938 
9939  if (bShowNymOnly) {
9940  strMyNymID = MyNym;
9941  }
9942  else if (bAcctExists) {
9944  }
9945  else {
9946  otOut << strLocation << ": This should never happen. (1)\n";
9947  return -1;
9948  }
9949 
9950  if (!VerifyStringVal(strMyNymID)) {
9951  // if bShowNymOnly is true, then we KNOW MyNym is the Nym, and we
9952  // ALREADY know he's
9953  // good, since we called VerifyExists at the top of this function.
9954  // (MyNym, unlike HisNym,
9955  // is verified against the wallet, so we KNOW it's there.)
9956  // Therefore, if strMyNymID doesn't contain a proper string, then we
9957  // KNOW bShowNymOnly
9958  // must have been false, and that
9959  // OTAPI_Wrap::GetAccountWallet_NymID(MyAcct) was the call that
9960  // failed. Thus, the error message is appropriate to the latter case and
9961  // not the former.
9962  otOut << strLocation << ": Unable to find NymID based on myacct. Try a "
9963  "different account or nym, using --myacct "
9964  "ACCT_ID or --mynym NYM_ID\n";
9965  return -1;
9966  }
9967  if (bBothExist && !(strMyNymID == MyNym)) {
9968  otOut << strLocation << ": MyNym (" << MyNym
9969  << ") is not the same nym who owns MyAcct.\nTo override using "
9970  "MyAcct's owner nym, add: --mynym (" << strMyNymID << ")\n";
9971  return -1;
9972  }
9973 
9974  string strServerID = "";
9975  if (bAcctExists) {
9977  }
9978  else if (VerifyExists("Server", false)) {
9979  strServerID = Server;
9980  }
9981  else {
9982  otOut << strLocation << ": Server was not specified, and either MyAcct "
9983  "wasn't specified either, or if it was, I was "
9984  "unable to find any ServerID associated with "
9985  "MyAcct.\nTry a different account or different "
9986  "server, using --myacct ACCT_ID or --server "
9987  "SERVER_ID \n\n";
9988  return -1;
9989  }
9990 
9991  if (!VerifyStringVal(strServerID)) {
9992  otOut << strLocation << ": Unable to find Server ID.\nTry: --server "
9993  "SERVER_ID\nYou might also try: --myacct "
9994  "ACCT_ID (It will find the server ID based on "
9995  "the account.)\n";
9996  return -1;
9997  }
9998  //
9999  // REMEMBER, recordbox for MyAcct contains the old inbox receipts.
10000  // Whereas recordbox for MyNym contains the old payments (in and out.)
10001  // In the case of the latter, the NYM must be passed as the ACCT...
10002  //
10003  // Meaning: there are TWO record boxes. So must there thus be two commands
10004  // for viewing them? Or do we combine them somehow?
10006  // ===> I say combine them, since they are for viewing only (nothing is
10007  // actually done
10008  // with the records -- they're just there for the actual client to take and
10009  // store
10010  // however it wishes.)
10011  otOut << "\n\nNote: OT is completely done with these records. A proper GUI "
10012  "will sweep them out\nperiodically and archive them somewhere, or "
10013  "just erase them. All you can do at the\ncommand line (using this "
10014  "tool) is view them, or erase them using: opentxs clearrecords "
10015  "\n\n";
10016  otOut << "\nArchived Nym-related records (" << strMyNymID << "): \n";
10017  int32_t nNymRecords =
10018  details_show_records(strServerID, strMyNymID, strMyNymID);
10019  otOut << "--------------------------------------------------------------\n";
10020 
10021  int32_t nAcctRecords = 1;
10022 
10023  if (bAcctExists) {
10024  otOut << "\nArchived Account-related records (" << MyAcct << "): \n";
10025  nAcctRecords = details_show_records(strServerID, strMyNymID, MyAcct);
10026  }
10027 
10028  if (2 == (nNymRecords + nAcctRecords)) {
10029  return 1;
10030  }
10031 
10032  return -1;
10033 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_show_records(const std::string &strServerID, const std::string &strMyNymID, const std::string &strMyAcctID)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string MyNym
std::string MyAcct
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowServers ( )
static

Definition at line 5315 of file ot_commands_ot.cpp.

5316 {
5317  cout << "------------------------------------------------------------------"
5318  "\n";
5319  cout << " ** SERVERS: \n\n";
5320  int32_t nServerCount = OTAPI_Wrap::GetServerCount();
5321 
5322  for (int32_t i = 0; i < nServerCount; ++i) {
5323  string strIndex = std::to_string(i);
5324  string strID = OTAPI_Wrap::GetServer_ID(i);
5325  string strName = OTAPI_Wrap::GetServer_Name(strID);
5326 
5327  cout << strIndex << ": " << strID << " --- " << strName << "\n";
5328  }
5329 
5330  return 1;
5331 }
std::string to_string(const T &t)
static EXPORT int32_t GetServerCount()
Definition: OTAPI.cpp:516
static EXPORT std::string GetServer_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:894
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainShowWallet ( )
static

Definition at line 5380 of file ot_commands_ot.cpp.

5381 {
5382  cout << "\n";
5383 
5388 
5389  return 1;
5390 }
EXPORT static OT_COMMANDS_OT int32_t mainShowAccounts()
EXPORT static OT_COMMANDS_OT int32_t mainShowNyms()
EXPORT static OT_COMMANDS_OT int32_t mainShowAssets()
EXPORT static OT_COMMANDS_OT int32_t mainShowServers()
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainSignContract ( )
static

Definition at line 5100 of file ot_commands_ot.cpp.

5101 {
5102  // SignContract erases all signatures and affixes a new one alone.
5103  // But AddSignature, on the other hand, leaves all signatures in place, and
5104  // simply adds yours to the list.
5105 
5106  otOut << "Usage: signcontract \n Optionally, you may specify a contract "
5107  "type: signcontract --args \"type LEDGER\"\nIn that example, the "
5108  "output would start with the bookend: -----BEGIN OT SIGNED "
5109  "LEDGER-----\n(You don't need to specify the type if the bookend "
5110  "is already present on the input string.)\n\n";
5111 
5112  if (VerifyExists("MyNym")) {
5113  otOut << "Please enter a contract to be signed, followed by an EOF or "
5114  "a ~ by itself on a blank line:\n\n";
5115  string strInput = OT_CLI_ReadUntilEOF();
5116 
5117  otOut << "\n\n You entered:\n" << strInput << "\n\n";
5118 
5119  string strOutput = OTAPI_Wrap::SignContract(MyNym, strInput);
5120 
5121  if (!VerifyStringVal(strOutput)) {
5122  // Maybe we need to flat sign (maybe it wasn't already a signed
5123  // contract...)
5124  string strContractType;
5125 
5126  if (VerifyExists("Args")) {
5127  strContractType = OT_CLI_GetValueByKey(Args, "type");
5128  }
5129 
5130  if (VerifyStringVal(strContractType)) {
5131  otOut << "A properly-formed-and-signed contract was not "
5132  "provided, but a 'type' was... so we'll try "
5133  "flatsigning the input text...\n\n";
5134  strOutput =
5135  OTAPI_Wrap::FlatSign(MyNym, strInput, strContractType);
5136  }
5137  else {
5138  otOut << "A properly-formed-and-signed contract was not "
5139  "provided, and neither was a 'type' in order to form "
5140  "one. (Failure.)\n";
5141  return -1;
5142  }
5143  }
5144 
5145  int32_t nReturnVal = -1;
5146 
5147  if (VerifyStringVal(strOutput)) {
5148 
5149  otOut << "-------------------------------------------\nSigned:\n\n";
5150 
5151  cout << strOutput << "\n";
5152 
5153  nReturnVal = 1;
5154  }
5155  else {
5156  otOut << "\nSorry, but OT was unable to sign. Oh well.";
5157  }
5158 
5159  otOut << "\n\n";
5160 
5161  return nReturnVal;
5162  }
5163 
5164  return -1;
5165 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT std::string SignContract(const std::string &SIGNER_NYM_ID, const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:987
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT std::string FlatSign(const std::string &SIGNER_NYM_ID, const std::string &THE_INPUT, const std::string &CONTRACT_TYPE)
Definition: OTAPI.cpp:993
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainTransfer ( )
static

Definition at line 3695 of file ot_commands_ot.cpp.

3696 {
3697  otOut << "Usage: transfer --myacct YOUR_ASSET_ACCT --hisacct "
3698  "RECIPIENT_ASSET_ACCT\n\nAlso NECESSARY: --args \"amount "
3699  "PUT_AMOUNT_HERE\"\nAnd OPTIONALLY: --args \"memo \\\"Just a memo "
3700  "for the transfer.\\\"\"\n\n";
3701 
3702  if (VerifyExists("MyAcct") && VerifyExists("HisAcct")) {
3703  string strAssetTypeID =
3705  if (!VerifyStringVal(strAssetTypeID)) {
3706  otOut << "\n\nFailure: Unable to find asset ID based on myacct. "
3707  "Use: --myacct ACCT_ID\n";
3708  return -1;
3709  }
3710 
3711  string strAmount = "0";
3712  string strNote = "";
3713 
3714  string strDefaultAmount = "10";
3715  string strDefaultNote = "(blank memo field)";
3716 
3717  // If custom arguments have been passed on the command line,
3718  // then grab them and use them instead of asking the user to enter them
3719  // at the command line.
3720  if (VerifyExists("Args", false)) {
3721  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
3722  string strNewNote = OT_CLI_GetValueByKey(Args, "memo");
3723 
3724  // Set the values based on the custom arguments, for those found.
3725  if (VerifyStringVal(strNewAmount)) {
3726  strAmount = strNewAmount;
3727  }
3728  if (VerifyStringVal(strNewNote)) {
3729  strNote = strNewNote;
3730  }
3731  }
3732 
3733  // If the transfer parameters aren't provided, then we
3734  // ask the user to supply them at the command line.
3735  if (!VerifyStringVal(strAmount) ||
3736  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
3737  otOut << "Enter the amount[" << strDefaultAmount << "]: ";
3738  strAmount = OT_CLI_ReadLine();
3739  }
3740  if (!VerifyStringVal(strNote)) {
3741  otOut << "Optionally, enter a memo on a single line["
3742  << strDefaultNote << "]: ";
3743  strNote = OT_CLI_ReadLine();
3744  }
3745 
3746  if (!VerifyStringVal(strAmount) ||
3747  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
3748  strAmount = strDefaultAmount;
3749  }
3750  if (!VerifyStringVal(strNote)) {
3751  strNote = strDefaultNote;
3752  }
3753 
3754  return details_send_transfer(MyAcct, HisAcct, strAmount, strNote);
3755  }
3756 
3757  return -1;
3758 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
std::string HisAcct
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_send_transfer(const std::string &strMyAcctID, const std::string &strHisAcctID, const std::string &strAmount, const std::string &strNote)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainTriggerClause ( )
static

Definition at line 1336 of file ot_commands_ot.cpp.

1337 {
1338  otOut << "Usage: STRING GOES HERE";
1339 
1340  if (VerifyExists("Server") && VerifyExists("MyNym")) {
1341  // At this point we need to collect some other data:
1342  // First, we need the transaction number for the smart contract.
1343  // Second, we need the name of the clause we will be triggering.
1344  // Third we need (optionally) any string parameter that the user
1345  // may wish to pass into the clause when it gets triggered.
1346 
1347  string strTransNum = "";
1348  string strClause = "";
1349  string strParam = "";
1350 
1351  if (VerifyExists("Args", false)) {
1352  string strTempTransNum = OT_CLI_GetValueByKey(Args, "id");
1353  string strTempClause = OT_CLI_GetValueByKey(Args, "clause");
1354  string strTempParam = OT_CLI_GetValueByKey(Args, "param");
1355 
1356  // TRANSACTION ID
1357  if (!VerifyStringVal(strTempTransNum)) {
1358  otOut << "Please enter the transaction ID for the running "
1359  "smart contract: ";
1360  string strInputTransNum = OT_CLI_ReadLine();
1361 
1362  if (VerifyStringVal(strInputTransNum)) {
1363  strTransNum = strInputTransNum;
1364  }
1365  }
1366  else {
1367  strTransNum = strTempTransNum;
1368  }
1369 
1370  // CLAUSE NAME
1371  if (!VerifyStringVal(strTempClause)) {
1372  otOut << "Please enter the name of the clause you wish to "
1373  "trigger: ";
1374  string strInputClause = OT_CLI_ReadLine();
1375 
1376  if (VerifyStringVal(strInputClause)) {
1377  strClause = strInputClause;
1378  }
1379  }
1380  else {
1381  strClause = strTempClause;
1382  }
1383 
1384  // OPTIONAL PARAMETER
1385  if (!VerifyStringVal(strTempParam)) {
1386  otOut << "You can pass an optional parameter string (to pass "
1387  "to the clause itself)\nfollowed by a ~ by itself on "
1388  "a blank line. (Just use ~ to leave it blank.)\n\n";
1389  string strInputParam = OT_CLI_ReadUntilEOF();
1390 
1391  if (VerifyStringVal(strInputParam)) {
1392  strParam = strInputParam;
1393  }
1394  }
1395  else {
1396  strParam = strTempParam;
1397  }
1398  }
1399 
1400  if (VerifyStringVal(strTransNum) && VerifyStringVal(strClause)) {
1401  return details_trigger_clause(Server, MyNym, strTransNum, strClause,
1402  strParam);
1403  }
1404  }
1405  return -1;
1406 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
std::string Server
EXPORT static OT_COMMANDS_OT int32_t details_trigger_clause(const std::string &strServerID, const std::string &strMyNymID, const std::string &strTransNum, const std::string &strClause, const std::string &strParam)
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
std::string MyNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainVerifyReceipt ( )
static

Definition at line 6175 of file ot_commands_ot.cpp.

6176 {
6177  // SHOW INBOX
6178  //
6179  // Load an asset account's inbox from local storage and display it on the
6180  // screen.
6181 
6182  if (VerifyExists("Server") && VerifyExists("MyAcct")) {
6183 
6184  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(MyAcct);
6185  if (!VerifyStringVal(strMyNymID)) {
6186  otOut << "Failure: Unable to find NymID based on myacct. Use: "
6187  "--myacct ACCT_ID\n";
6188  otOut << "The designated asset account must be yours. OT will find "
6189  "the Nym based on the account.\n\n";
6190  return -1;
6191  }
6192 
6193  bool bSuccess =
6195  if (!bSuccess) {
6196  otOut << "\n\n OT_API_VerifyAccountReceipt: Failed. Try using "
6197  "refreshaccount and then try verifying again.\n\n";
6198  return -1;
6199  }
6200  else {
6201  otOut << "\n\nVerify receipt: success!\n\n";
6202  return 1;
6203  }
6204  }
6205 
6206  return -1;
6207 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
std::string Server
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT bool VerifyAccountReceipt(const std::string &SERVER_ID, const std::string &NYM_ID, const std::string &ACCT_ID)
Definition: OTAPI.cpp:1018
std::string MyAcct
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainVerifySignature ( )
static

Definition at line 5274 of file ot_commands_ot.cpp.

5275 {
5276  if (VerifyExists("HisNym")) {
5277  otOut << "Please enter a contract you wish to verify with HisNym, "
5278  "followed by an EOF or a ~ by itself on a blank line:\n\n";
5279  string strInput = OT_CLI_ReadUntilEOF();
5280 
5281  otOut << "\n\n--------------------------------------\n You entered:\n"
5282  << strInput << "\n\n";
5283 
5284  if (OTAPI_Wrap::VerifySignature(HisNym, strInput)) {
5285  cout << "\n\n *** Verified! ***\n\n\n";
5286  return 1;
5287  }
5288  else {
5289  cout << "Failed!\n\n\n";
5290  }
5291  }
5292 
5293  return -1;
5294 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
static EXPORT bool VerifySignature(const std::string &SIGNER_NYM_ID, const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1006
std::string HisNym
EXPORT std::string OT_CLI_ReadUntilEOF()
Definition: Helpers.hpp:156
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainWithdrawCash ( )
static

Definition at line 6514 of file ot_commands_ot.cpp.

6515 {
6516  otOut << "Usage: withdraw --myacct YOUR_ASSET_ACCT \nYou can provide an "
6517  "amount: --args \"amount PUT_AMOUNT_HERE\"\n\n";
6518 
6519  if (VerifyExists("MyAcct")) {
6520 
6521  string strAssetTypeID =
6523  if (!VerifyStringVal(strAssetTypeID)) {
6524  return -1;
6525  }
6526 
6527  string strAmount = "0";
6528 
6529  string strDefaultAmount = "1";
6530 
6531  // If custom arguments have been passed on the command line,
6532  // then grab them and use them instead of asking the user to enter them
6533  // at the command line.
6534  if (VerifyExists("Args", false)) {
6535  string strNewAmount = OT_CLI_GetValueByKey(Args, "amount");
6536 
6537  // Set the values based on the custom arguments, for those found.
6538  if (VerifyStringVal(strNewAmount)) {
6539  strAmount = strNewAmount;
6540  }
6541  }
6542 
6543  // If the withdrawal parameters aren't provided, then we
6544  // ask the user to supply them at the command line.
6545  if (!VerifyStringVal(strAmount) ||
6546  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
6547  otOut << "Enter the amount[" << strDefaultAmount << "]: ";
6548  strAmount = OT_CLI_ReadLine();
6549  }
6550 
6551  if (!VerifyStringVal(strAmount) ||
6552  (OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount) < 1)) {
6553  strAmount = strDefaultAmount;
6554  }
6555 
6556  int64_t lAmount = OTAPI_Wrap::StringToAmount(strAssetTypeID, strAmount);
6557 
6558  return details_withdraw_cash(MyAcct, lAmount);
6559  }
6560 
6561  return -1;
6562 }
EXPORT std::string OT_CLI_GetValueByKey(const std::string &str_Args, const std::string &str_key)
Definition: OT_ME.cpp:201
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT std::string OT_CLI_ReadLine()
Definition: Helpers.hpp:144
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
std::string Args
static EXPORT int64_t StringToAmount(const std::string &ASSET_TYPE_ID, const std::string &str_input)
Definition: OTAPI.cpp:484
std::string MyAcct
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
EXPORT static OT_COMMANDS_OT int32_t details_withdraw_cash(const std::string &strMyAcctID, int64_t lAmount)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainWithdrawVoucher ( )
static

Definition at line 6722 of file ot_commands_ot.cpp.

6723 {
6724  otOut << "Usage: withdrawvoucher --myacct YOUR_ASSET_ACCT --hisnym "
6725  "RECIPIENT_NYM_ID\n\nAlso NECESSARY: --args \"amount "
6726  "PUT_AMOUNT_HERE\"\nAnd OPTIONALLY: --args \"memo \\\"Just a memo "
6727  "for the voucher cheque.\\\"\"\n\n";
6728 
6729  if (VerifyExists("MyAcct")) {
6730  string strVoucher = "";
6731  return details_withdraw_voucher(strVoucher);
6732  }
6733 
6734  return -1;
6735 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT static OT_COMMANDS_OT int32_t details_withdraw_voucher(std::string &strOutput)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainWriteCheque ( )
static

Definition at line 4253 of file ot_commands_ot.cpp.

4254 {
4255  otOut << "Usage: writecheque --myacct <MY_ACCT_ID> --hisnym "
4256  "<HIS_NYM_ID>\nOptionally: --args \"memo \\\"one-line memo "
4257  "allowed here.\\\" amount AMOUNT\"\nAdditionally: --args "
4258  "\"validfor IN_SECONDS\" \nThis command WRITES but DOES NOT SEND "
4259  "the cheque. (Use sendcheque for that.)\n\n";
4260 
4261  string strCheque = "";
4262  int32_t nReturnVal = details_write_cheque(strCheque, false);
4263 
4264  if ((1 == nReturnVal) && VerifyStringVal(strCheque)) {
4265 
4266  otOut << "\n-------------------------------------------\n the "
4267  "cheque:\n\n";
4268 
4269  cout << strCheque << "\n";
4270 
4271  otOut << "\n";
4272  }
4273 
4274  return nReturnVal;
4275 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_write_cheque(std::string &strCheque, bool bIsInvoice)
OT_COMMANDS_OT int32_t opentxs::OT_Command::mainWriteInvoice ( )
static

Definition at line 4277 of file ot_commands_ot.cpp.

4278 {
4279  otOut << "Usage: writeinvoice --myacct <MY_ACCT_ID> --hisnym "
4280  "<HIS_NYM_ID>\nOptionally: --args \"memo \\\"one-line memo "
4281  "allowed here.\\\" amount AMOUNT\"\nAdditionally: --args "
4282  "\"validfor IN_SECONDS\" \nThis command WRITES but DOES NOT SEND "
4283  "the invoice. (Use sendinvoice for that.)\n";
4284 
4285  string strCheque = "";
4286  int32_t nReturnVal = details_write_cheque(strCheque, true);
4287 
4288  if ((1 == nReturnVal) && VerifyStringVal(strCheque)) {
4289 
4290  otOut << "\n-------------------------------------------\n the "
4291  "invoice:\n\n";
4292 
4293  cout << strCheque << "\n";
4294 
4295  otOut << "\n";
4296  }
4297 
4298  return nReturnVal;
4299 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT int32_t details_write_cheque(std::string &strCheque, bool bIsInvoice)
OT_COMMANDS_OT bool opentxs::OT_Command::purse_get_indices_or_amount ( const std::string &  strServerID,
const std::string &  strAssetTypeID,
const std::string &  strMyNymID,
int64_t &  lAmount,
std::string &  strIndices 
)
static

Definition at line 8335 of file ot_commands_ot.cpp.

8338 {
8339 
8340  string strLocation = "\n purse_get_indices_or_amount";
8341 
8342  string strLoopIndices = "";
8343  int64_t lAmountRemaining = lAmount;
8344  int64_t lLoopAmount = 0;
8345 
8346  // lLoopAmount is where we will start at 0, and keep the running total of
8347  // the value for the selected indices, as we loop.
8348  // lAmountRemaining is where we will start at lAmount, and then SUBTRACT the
8349  // value of each selected index, as we loop.
8350  // If we are trying to determine the indices based on lAmount, we'll SEE if
8351  // the current index is less-than-or-equal-to
8352  // lAmountRemaining, and if so, we'll concat that index to our output and
8353  // subtract the denomination of the token at the
8354  // current index from lAmountRemaining.
8355  // If bFindAmountFromIndices is true then lAmount is already 0 and then
8356  // lAmountRemaining is already 0 as well.
8357 
8358  bool bFindIndicesFromAmount = false;
8359  bool bFindAmountFromIndices = false;
8360 
8361  if (VerifyStringVal(strIndices) && (0 == lAmount)) {
8362  bFindAmountFromIndices = true;
8363  }
8364  else if (!VerifyStringVal(strIndices) && (0 != lAmount)) {
8365  bFindIndicesFromAmount = true;
8366  }
8367  else {
8368  otOut << strLocation << ": Can only pass indices, OR amount to this "
8369  "function, but not both (the other becomes "
8370  "output.)\n";
8371  return false;
8372  }
8373 
8374  otOut << "strServerID: " << strServerID << "\n";
8375  otOut << "strAssetTypeID: " << strAssetTypeID << "\n";
8376  otOut << "strMyNymID: " << strMyNymID << "\n";
8377 
8378  string strLocalPurse =
8379  OTAPI_Wrap::LoadPurse(strServerID, strAssetTypeID, strMyNymID);
8380 
8381  bool bLoadedPurse = VerifyStringVal(strLocalPurse);
8382  if (!bLoadedPurse) {
8383  otOut << strLocation
8384  << ": Unable to load local purse. Does it even exist?\n";
8385  return false;
8386  }
8387  else {
8388 
8389  // Loop through purse contents...
8390  int32_t nCount =
8391  OTAPI_Wrap::Purse_Count(strServerID, strAssetTypeID, strLocalPurse);
8392  if (nCount < 0) {
8393  otOut << strLocation << ": Error: Unexpected bad value returned "
8394  "from OT_API_Purse_Count.\n\n";
8395  return false;
8396  }
8397 
8398  if (nCount < 1) {
8399  otOut << strLocation << ": The purse is empty.\n\n";
8400  return false;
8401  }
8402  else {
8403  // Make a copy of the purse passed in, so we can iterate it and find
8404  // the
8405  // appropriate Token IDs...
8406 
8407  string strPurse = strLocalPurse;
8408 
8409  int32_t nIndex = -1;
8410 
8411  while (nCount > 0) {
8412  --nCount;
8413  ++nIndex;
8414 
8415  // NOTE: Owner can ONLY be strMyNymID in here, since
8416 
8417  // is only true in the case where we LOADED the purse from local
8418  // storage.
8419  // (Therefore this DEFINITELY is not a password-protected
8420  // purse.)
8421  string strToken = OTAPI_Wrap::Purse_Peek(
8422  strServerID, strAssetTypeID, strMyNymID, strPurse);
8423 
8424  if (!VerifyStringVal(strToken)) {
8425  otOut << strLocation << ": Error: OT_API_Purse_Peek "
8426  "unexpectedly returned nullptr "
8427  "instead of token.\n";
8428  return false;
8429  }
8430 
8431  string strNewPurse = OTAPI_Wrap::Purse_Pop(
8432  strServerID, strAssetTypeID, strMyNymID, strPurse);
8433 
8434  if (!VerifyStringVal(strNewPurse)) {
8435  otOut << strLocation << ": Error: OT_API_Purse_Pop "
8436  "unexpectedly returned nullptr "
8437  "instead of updated purse.\n";
8438  return false;
8439  }
8440 
8441  strPurse = strNewPurse;
8442 
8443  string strTokenID = OTAPI_Wrap::Token_GetID(
8444  strServerID, strAssetTypeID, strToken);
8445  if (!VerifyStringVal(strTokenID)) {
8446  otOut << strLocation << ": Error: bad strTokenID.\n";
8447  return false;
8448  }
8449  int64_t lDenomination = OTAPI_Wrap::Token_GetDenomination(
8450  strServerID, strAssetTypeID, strToken);
8451  if (0 > lDenomination) {
8452  otOut << "Error while showing purse: bad lDenomination.\n";
8453  return false;
8454  }
8455  int32_t nSeries = OTAPI_Wrap::Token_GetSeries(
8456  strServerID, strAssetTypeID, strToken);
8457  if (0 > nSeries) {
8458  otOut << "Error while showing purse: bad nSeries.\n";
8459  return false;
8460  }
8462  strServerID, strAssetTypeID, strToken);
8463  if (OT_TIME_ZERO > tValidFrom) {
8464  otOut << "Error while showing purse: bad tValidFrom.\n";
8465  return false;
8466  }
8468  strServerID, strAssetTypeID, strToken);
8469  if (OT_TIME_ZERO > tValidTo) {
8470  otOut << "Error while showing purse: bad tValidTo.\n";
8471  return false;
8472  }
8473  time64_t lTime = OTAPI_Wrap::GetTime();
8474  if (OT_TIME_ZERO > lTime) {
8475  otOut << "Error while showing purse: bad lTime.\n";
8476  return false;
8477  }
8478  string strStatus = (lTime > tValidTo) ? "expired" : "valid";
8479 
8480  // lLoopAmount is where we will start at 0, and keep the running
8481  // total of the value for the selected indices, as we loop.
8482  // lAmountRemaining is where we will start at lAmount, and then
8483  // SUBTRACT the value of each selected index, as we loop.
8484  // If we are trying to determine the indices based on lAmount,
8485  // we'll SEE if value at the current index is
8486  // less-than-or-equal-to
8487  // lAmountRemaining, and if so, we'll concat that index to our
8488  // output and subtract the denomination of the token at the
8489  // current index from lAmountRemaining.
8490  // If bFindAmountFromIndices is true then lAmount is already 0
8491  // and then lAmountRemaining is already 0 as well.
8492 
8493  // TODO: This would work better if the tokens were sorted. In
8494  // the future, pull the tokens onto a map or something,
8495  // and then SORT IT based on denomination of token. THEN go
8496  // through the tokens from largest to smallest and do what we're
8497  // doing here in this loop. And then it will work perfectly
8498  // everytime. Todo. This version will work okay, but there will
8499  // be
8500  // times it fails and ends up withdrawing cash when it didn't
8501  // really need to. TOdo.
8502 
8503  if (lTime > tValidTo) {
8504  otOut << strLocation << ": Skipping: Token is " << strStatus
8505  << ".\n";
8506  }
8507  else if (bFindAmountFromIndices) {
8508  if (VerifyStringVal(strIndices) &&
8509  (("all" == strIndices) ||
8511  strIndices, std::to_string(nIndex)))) {
8512  string strTempIndices = OTAPI_Wrap::NumList_Add(
8513  strLoopIndices, std::to_string(nIndex));
8514  strLoopIndices = strTempIndices;
8515  lLoopAmount += lDenomination;
8516  }
8517  }
8518  else if (bFindIndicesFromAmount) {
8519  if (lAmountRemaining > 0 &&
8520  lDenomination <= lAmountRemaining) {
8521  string strTempIndices = OTAPI_Wrap::NumList_Add(
8522  strLoopIndices, std::to_string(nIndex));
8523  strLoopIndices = strTempIndices;
8524  lLoopAmount += lDenomination;
8525  lAmountRemaining -= lDenomination;
8526 
8527  if (0 == lAmountRemaining) {
8528  break;
8529  }
8530  }
8531  }
8532  }
8533  }
8534  }
8535 
8536  if (bFindAmountFromIndices) {
8537  lAmount = lLoopAmount;
8538  return true;
8539  }
8540  else if (bFindIndicesFromAmount) {
8541  strIndices = strLoopIndices;
8542  lAmount = lAmountRemaining;
8543 
8544  if (0 == lAmountRemaining) {
8545  return true;
8546  }
8547 
8548  strIndices = "";
8549  }
8550 
8551  return false;
8552 }
static EXPORT int32_t Token_GetSeries(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1949
std::string to_string(const T &t)
static EXPORT std::string LoadPurse(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &USER_ID)
Definition: OTAPI.cpp:1829
static EXPORT time64_t GetTime()
Definition: OTAPI.cpp:941
OTLOG_IMPORT OTLogStream otOut
int64_t time64_t
Definition: Common.hpp:209
static EXPORT time64_t Token_GetValidFrom(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
the date is seconds since Jan 1970.
Definition: OTAPI.cpp:1956
static EXPORT int32_t Purse_Count(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_PURSE)
returns a count of the number of cash tokens inside this purse.
Definition: OTAPI.cpp:1843
static EXPORT time64_t Token_GetValidTo(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1963
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Purse_Pop(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_OR_SIGNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1879
static EXPORT std::string NumList_Add(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:329
static EXPORT int64_t Token_GetDenomination(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
The actual cash value of the token. Returns a int64_t.
Definition: OTAPI.cpp:1942
static EXPORT std::string Token_GetID(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &THE_TOKEN)
Definition: OTAPI.cpp:1935
static EXPORT std::string Purse_Peek(const std::string &SERVER_ID, const std::string &ASSET_TYPE_ID, const std::string &OWNER_ID, const std::string &THE_PURSE)
Definition: OTAPI.cpp:1871
#define OT_TIME_ZERO
Definition: Common.hpp:180
static EXPORT bool NumList_VerifyQuery(const std::string &strNumList, const std::string &strNumbers)
Definition: OTAPI.cpp:341
OT_COMMANDS_OT bool opentxs::OT_Command::show_mail_message ( const std::string &  strMyNymID,
int32_t  nIndex,
bool  bShowContents 
)
static

Definition at line 10600 of file ot_commands_ot.cpp.

10603 {
10604  bool bMailVerified = OTAPI_Wrap::Nym_VerifyMailByIndex(strMyNymID, nIndex);
10605 
10606  if (!bMailVerified) {
10607  cout << "UNVERIFIED mail! At index: " << nIndex << "\n\n";
10608  // return false;
10609  }
10610  else {
10611  cout << "------------------------------\nVerified mail at index: "
10612  << nIndex << "\n";
10613  }
10614 
10615  string strMailServerID =
10616  OTAPI_Wrap::GetNym_MailServerIDByIndex(strMyNymID, nIndex);
10617  string strMailSenderID =
10618  OTAPI_Wrap::GetNym_MailSenderIDByIndex(strMyNymID, nIndex);
10619  string strMailContents =
10620  OTAPI_Wrap::GetNym_MailContentsByIndex(strMyNymID, nIndex);
10621 
10622  if (VerifyStringVal(strMailSenderID)) {
10623  string strName = OTAPI_Wrap::GetNym_Name(strMailSenderID);
10624  if (!VerifyStringVal(strName)) {
10625  strName = "";
10626  }
10627  cout << "Mail from: " << strMailSenderID << " \"" << strName << "\" \n";
10628  }
10629  if (VerifyStringVal(strMailServerID)) {
10630  string strName = OTAPI_Wrap::GetServer_Name(strMailServerID);
10631  if (!VerifyStringVal(strName)) {
10632  strName = "";
10633  }
10634  cout << "Server ID: " << strMailServerID << " \"" << strName << "\" \n";
10635  }
10636  if (bShowContents && VerifyStringVal(strMailContents)) {
10637  cout << "Contents:\n" << strMailContents << "\n\n";
10638  }
10639 
10640  return true;
10641 }
static EXPORT bool Nym_VerifyMailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:717
static EXPORT std::string GetNym_MailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:693
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
static EXPORT std::string GetNym_MailServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:705
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
static EXPORT std::string GetNym_MailSenderIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:699
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT bool opentxs::OT_Command::show_outmail_message ( const std::string &  strMyNymID,
int32_t  nIndex,
bool  bShowContents 
)
static

Definition at line 10793 of file ot_commands_ot.cpp.

10796 {
10797  bool bMailVerified =
10798  OTAPI_Wrap::Nym_VerifyOutmailByIndex(strMyNymID, nIndex);
10799 
10800  if (!bMailVerified) {
10801  cout << "UNVERIFIED outmail! At index: " << nIndex << "\n\n";
10802  // return false;
10803  }
10804  else {
10805  cout << "--------------------------------------------------------"
10806  "\nVerified outmail at index: " << nIndex << "\n";
10807  }
10808 
10809  string strMailServerID =
10810  OTAPI_Wrap::GetNym_OutmailServerIDByIndex(strMyNymID, nIndex);
10811  string strMailRecipientID =
10813  string strMailContents =
10814  OTAPI_Wrap::GetNym_OutmailContentsByIndex(strMyNymID, nIndex);
10815 
10816  if (VerifyStringVal(strMailRecipientID)) {
10817  cout << "Mail was sent to: " << strMailRecipientID << "\n";
10818  }
10819  if (VerifyStringVal(strMailServerID)) {
10820  cout << "At server ID: " << strMailServerID << "\n";
10821  }
10822  if (bShowContents && VerifyStringVal(strMailContents)) {
10823  cout << "Contents:\n" << strMailContents << "\n\n";
10824  }
10825  return true;
10826 }
static EXPORT std::string GetNym_OutmailContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:728
static EXPORT std::string GetNym_OutmailRecipientIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:734
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT bool Nym_VerifyOutmailByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:752
static EXPORT std::string GetNym_OutmailServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:740
OT_COMMANDS_OT bool opentxs::OT_Command::show_outpayment ( const std::string &  strMyNym,
int32_t  nIndex,
bool  bShowInFull 
)
static

Definition at line 10978 of file ot_commands_ot.cpp.

10981 {
10982  bool bMailVerified =
10983  OTAPI_Wrap::Nym_VerifyOutpaymentsByIndex(strMyNym, nIndex);
10984 
10985  if (!bMailVerified) {
10986  cout << "UNVERIFIED sent (outgoing) payment! At index: " << nIndex
10987  << "\n";
10988  // return false;
10989  }
10990  else {
10991  cout << "\n----------------------------------------------\n(index "
10992  << nIndex << ")\n";
10993  }
10994 
10995  string strMailServerID =
10997  string strMailRecipientID =
10999  string strMailContents =
11001 
11002  if (VerifyStringVal(strMailContents)) {
11003  int64_t lPaymentAmount =
11004  OTAPI_Wrap::Instrmnt_GetAmount(strMailContents);
11005  string strPaymentAmount = OT_ERROR_AMOUNT != lPaymentAmount
11006  ? std::to_string(lPaymentAmount)
11007  : "UNKNOWN_PAYMENT_AMOUNT";
11008 
11009  string strPaymentAssetID =
11010  OTAPI_Wrap::Instrmnt_GetAssetID(strMailContents);
11011  string strPaymentType = OTAPI_Wrap::Instrmnt_GetType(strMailContents);
11012 
11013  string strFormatted = "";
11014  string strAssetTypeName = "";
11015 
11016  string strRecipientString = "";
11017  string strServerString = "";
11018 
11019  if (VerifyStringVal(strMailRecipientID)) {
11020  string strName = OTAPI_Wrap::GetNym_Name(strMailRecipientID);
11021  if (!VerifyStringVal(strName)) {
11022  strName = "";
11023  }
11024  strRecipientString = "Payment sent to: " + strMailRecipientID +
11025  " \"" + strName + "\" ";
11026  }
11027  if (VerifyStringVal(strMailServerID)) {
11028  string strName = OTAPI_Wrap::GetServer_Name(strMailServerID);
11029  if (!VerifyStringVal(strName)) {
11030  strName = "";
11031  }
11032  strServerString =
11033  " At server ID: " + strMailServerID + " \"" + strName + "\" ";
11034  }
11035 
11036  if (VerifyStringVal(strPaymentAssetID)) {
11037  strAssetTypeName = OTAPI_Wrap::GetAssetType_Name(strPaymentAssetID);
11038  if (!VerifyStringVal(strAssetTypeName)) {
11039  strAssetTypeName = "";
11040  }
11041  }
11042  else {
11043  strPaymentAssetID = "UNKNOWN_ASSET_ID";
11044  }
11045 
11046  if (OT_ERROR_AMOUNT != lPaymentAmount) {
11047  if (!VerifyStringVal(strPaymentType)) {
11048  strPaymentType = "UNKNOWN_PAYMENT_TYPE";
11049  }
11050  string strTempFormat;
11051  if (lPaymentAmount >= 0) {
11052  strTempFormat =
11053  OTAPI_Wrap::FormatAmount(strPaymentAssetID, lPaymentAmount);
11054  }
11055  if (!VerifyStringVal(strTempFormat)) {
11056  strTempFormat = strPaymentAmount;
11057  }
11058 
11059  strFormatted = "( " + strPaymentType + ": " + strTempFormat + " )";
11060  }
11061 
11062  cout << " Amount: " << strPaymentAmount << " " << strFormatted
11063  << "\n";
11064  cout << strRecipientString << "\n";
11065  cout << " Of asset type: " << strPaymentAssetID << " \""
11066  << strAssetTypeName << "\"\n";
11067  cout << strServerString << "\n";
11068 
11069  if (bShowInFull) {
11070  cout << " Instrument: \n" << strMailContents << "\n\n";
11071  }
11072  }
11073  else {
11074  otOut << "Error: bad result from "
11075  "OT_API_GetNym_OutpaymentsContentsByIndex at Index: " << nIndex
11076  << "\n";
11077  return false;
11078  }
11079 
11080  return true;
11081 }
static EXPORT int64_t Instrmnt_GetAmount(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:793
std::string to_string(const T &t)
#define OT_ERROR_AMOUNT
Definition: Common.hpp:166
static EXPORT std::string Instrmnt_GetAssetID(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:828
static EXPORT std::string Instrmnt_GetType(const std::string &THE_INSTRUMENT)
Definition: OTAPI.cpp:813
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string FormatAmount(const std::string &ASSET_TYPE_ID, const int64_t &THE_AMOUNT)
Definition: OTAPI.cpp:490
static EXPORT bool Nym_VerifyOutpaymentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:787
static EXPORT std::string GetServer_Name(const std::string &SERVER_ID)
Definition: OTAPI.cpp:899
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
static EXPORT std::string GetNym_OutpaymentsRecipientIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:769
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetNym_OutpaymentsServerIDByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:775
static EXPORT std::string GetNym_OutpaymentsContentsByIndex(const std::string &NYM_ID, const int32_t &nIndex)
Definition: OTAPI.cpp:763
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT bool opentxs::OT_Command::show_unconfirmed_parties ( const std::string &  strSmartContract,
int32_t &  nPartyCount 
)
static

Definition at line 1819 of file ot_commands_ot.cpp.

1821 {
1822  if (0 == nPartyCount) {
1823  nPartyCount = OTAPI_Wrap::Smart_GetPartyCount(strSmartContract);
1824  if (nPartyCount < 0) {
1825  otOut << "Failure: There are apparently no PARTIES to this smart "
1826  "contract.\n";
1827  return false;
1828  }
1829  }
1830 
1831  // See if the smart contract is already confirmed by all parties.
1832  if (OTAPI_Wrap::Smart_AreAllPartiesConfirmed(strSmartContract)) {
1833  otOut << "Looks like all the parties on this contract are already "
1834  "confirmed.\n(Perhaps you want to 'activate' it instead.)\n";
1835  return false;
1836  }
1837 
1838  int32_t nUnconfirmedPartyCount = 0;
1839 
1840  for (int32_t nCurrentParty = 0; nCurrentParty < nPartyCount;
1841  ++nCurrentParty) {
1842  string strPartyName =
1843  OTAPI_Wrap::Smart_GetPartyByIndex(strSmartContract, nCurrentParty);
1844 
1845  if (!VerifyStringVal(strPartyName)) {
1846  otOut << "Error: Unable to retrieve smart contract party's name at "
1847  "index: " << nCurrentParty << "\n";
1848  return false;
1849  }
1850 
1851  bool bIsPartyConfirmed =
1852  OTAPI_Wrap::Smart_IsPartyConfirmed(strSmartContract, strPartyName);
1853  if (!bIsPartyConfirmed) {
1854  string strIndex = std::to_string(nCurrentParty);
1855  otOut << strIndex << " : Unconfirmed party: " << strPartyName
1856  << "\n";
1857  ++nUnconfirmedPartyCount;
1858  }
1859  }
1860 
1861  if (nUnconfirmedPartyCount <= 0) {
1862  otOut << "SHOULD NEVER HAPPEN: OT_API_Smart_AreAllPartiesConfirmed was "
1863  "already verified as false, above.\nSo then why am I at the "
1864  "bottom of this loop and I haven't found any unconfirmed "
1865  "parties?\n";
1866  return false;
1867  }
1868 
1869  return true;
1870 }
std::string to_string(const T &t)
OTLOG_IMPORT OTLogStream otOut
static EXPORT bool Smart_IsPartyConfirmed(const std::string &THE_CONTRACT, const std::string &PARTY_NAME)
Definition: OTAPI.cpp:1218
static EXPORT bool Smart_AreAllPartiesConfirmed(const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1213
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Smart_GetPartyByIndex(const std::string &THE_CONTRACT, const int32_t &nIndex)
Definition: OTAPI.cpp:1234
static EXPORT int32_t Smart_GetPartyCount(const std::string &THE_CONTRACT)
Definition: OTAPI.cpp:1224
OT_COMMANDS_OT int32_t opentxs::OT_Command::stat_basket_accounts ( const std::string &  strServer,
const std::string &  strNym,
bool  bFilter,
const std::string &  strBasketType 
)
static

Definition at line 742 of file ot_commands_ot.cpp.

745 {
746  cout << "------------------------------------------------------------------"
747  "\n";
748  cout << " ** ACCOUNTS :\n\n";
749 
750  int32_t nAccountCount = OTAPI_Wrap::GetAccountCount();
751 
752  for (int32_t i = 0; i < nAccountCount; ++i) {
753  string strID = OTAPI_Wrap::GetAccountWallet_ID(i);
754  string strAssetID = OTAPI_Wrap::GetAccountWallet_AssetTypeID(strID);
755  string strAcctServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strID);
756  string strAcctNymID = OTAPI_Wrap::GetAccountWallet_NymID(strID);
757 
758  if (!VerifyStringVal(strServer) ||
759  (VerifyStringVal(strServer) && (strServer == strAcctServerID))) {
760  if (!VerifyStringVal(strNym) ||
761  (VerifyStringVal(strNym) && (strNym == strAcctNymID))) {
762  if ((!VerifyStringVal(strBasketType) &&
763  OTAPI_Wrap::IsBasketCurrency(strAssetID)) ||
764  (VerifyStringVal(strBasketType) && bFilter &&
765  (strBasketType == strAssetID)) ||
766  (VerifyStringVal(strBasketType) && !bFilter &&
767  (strBasketType != strAssetID))) {
768  if ((i > 0) && (i != (nAccountCount))) {
769  cout << "-------------------------------------\n";
770  }
771 
772  string strStatAcct = MadeEasy::stat_asset_account(strID);
773  bool bSuccess = VerifyStringVal(strStatAcct);
774  if (bSuccess) {
775  cout << strStatAcct << "\n";
776  }
777  else {
778  cout << "Error trying to stat an account: " << strID
779  << "\n";
780  }
781 
782  cout << "\n";
783  }
784  }
785  }
786  }
787  cout << "------------------------------------------------------------------"
788  "\n";
789 
790  return 1;
791 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
static EXPORT int32_t GetAccountCount()
Definition: OTAPI.cpp:526
static EXPORT bool IsBasketCurrency(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:1980
EXPORT static OT_MADE_EASY_OT std::string stat_asset_account(const std::string &ACCOUNT_ID)
static EXPORT std::string GetAccountWallet_ID(const int32_t &nIndex)
Definition: OTAPI.cpp:919
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyaccount ( const std::string &  strSmartContract,
const std::string &  strPartyName,
const std::string &  strAcctName,
int32_t  nCurrentAccount 
)
static

Definition at line 1740 of file ot_commands_ot.cpp.

1743 {
1744  string strAcctAssetID = OTAPI_Wrap::Party_GetAcctAssetID(
1745  strSmartContract, strPartyName, strAcctName);
1746  string strAcctID = OTAPI_Wrap::Party_GetAcctID(strSmartContract,
1747  strPartyName, strAcctName);
1748  string strAcctAgentName = OTAPI_Wrap::Party_GetAcctAgentName(
1749  strSmartContract, strPartyName, strAcctName);
1750 
1751  if (VerifyStringVal(strAcctAssetID)) {
1752  cout << "-------------------\nAccount '" << strAcctName << "' (index "
1753  << nCurrentAccount << " on Party '" << strPartyName
1754  << "') has asset type: " << strAcctAssetID << " ("
1755  << OTAPI_Wrap::GetAssetType_Name(strAcctAssetID) << ")\n";
1756  }
1757 
1758  if (VerifyStringVal(strAcctID)) {
1759  cout << "Account '" << strAcctName << "' (party '" << strPartyName
1760  << "') is confirmed as Account ID: " << strAcctID << " ("
1761  << OTAPI_Wrap::GetAccountWallet_Name(strAcctID) << ")\n";
1762  }
1763 
1764  if (VerifyStringVal(strAcctAgentName)) {
1765  cout << "Account '" << strAcctName << "' (party '" << strPartyName
1766  << "') is managed by agent: " << strAcctAgentName << "\n";
1767  }
1768 
1769  return true;
1770 }
static EXPORT std::string GetAccountWallet_Name(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:924
static EXPORT std::string Party_GetAcctAssetID(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1388
static EXPORT std::string Party_GetAcctID(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1381
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string Party_GetAcctAgentName(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &ACCT_NAME)
Definition: OTAPI.cpp:1395
static EXPORT std::string GetAssetType_Name(const std::string &ASSET_TYPE_ID)
Definition: OTAPI.cpp:909
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyaccount_index ( const std::string &  strSmartContract,
const std::string &  strPartyName,
int32_t  nCurrentAccount 
)
static

Definition at line 1772 of file ot_commands_ot.cpp.

1775 {
1776  string strAcctName = OTAPI_Wrap::Party_GetAcctNameByIndex(
1777  strSmartContract, strPartyName, nCurrentAccount);
1778 
1779  if (!VerifyStringVal(strAcctName)) {
1780  otOut << "Error: Failed retrieving Asset Account Name from party '"
1781  << strPartyName << "' at account index: " << nCurrentAccount
1782  << "\n";
1783  return false;
1784  }
1785  return stat_partyaccount(strSmartContract, strPartyName, strAcctName,
1786  nCurrentAccount);
1787 }
OTLOG_IMPORT OTLogStream otOut
static EXPORT std::string Party_GetAcctNameByIndex(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const int32_t &nIndex)
Definition: OTAPI.cpp:1374
EXPORT static OT_COMMANDS_OT bool stat_partyaccount(const std::string &strSmartContract, const std::string &strPartyName, const std::string &strAcctName, int32_t nCurrentAccount)
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyaccounts ( const std::string &  strSmartContract,
const std::string &  strPartyName,
int32_t  nDepth 
)
static

Definition at line 1789 of file ot_commands_ot.cpp.

1791 {
1792  int32_t nAccountCount =
1793  OTAPI_Wrap::Party_GetAcctCount(strSmartContract, strPartyName);
1794 
1795  if (nAccountCount < 0) {
1796  otOut << "Error: Party '" << strPartyName
1797  << "' has bad value for number of asset accounts.\n";
1798  return false;
1799  }
1800 
1801  if (nDepth > 0) {
1802  for (int32_t nCurrentAccount = 0; nCurrentAccount < nAccountCount;
1803  ++nCurrentAccount) {
1804  if (!stat_partyaccount_index(strSmartContract, strPartyName,
1805  nCurrentAccount)) {
1806  return false;
1807  }
1808  }
1809  }
1810  else {
1811  cout << "Party '" << strPartyName << "' has " << nAccountCount
1812  << (1 == nAccountCount ? " asset account." : " asset accounts.")
1813  << "\n";
1814  }
1815 
1816  return true;
1817 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT bool stat_partyaccount_index(const std::string &strSmartContract, const std::string &strPartyName, int32_t nCurrentAccount)
static EXPORT int32_t Party_GetAcctCount(const std::string &THE_CONTRACT, const std::string &PARTY_NAME)
Definition: OTAPI.cpp:1356
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyagent ( const std::string &  strSmartContract,
const std::string &  strPartyName,
const std::string &  strAgentName,
int32_t  nIndex 
)
static

Definition at line 1672 of file ot_commands_ot.cpp.

1676 {
1677  string strAgentID = OTAPI_Wrap::Party_GetAgentID(
1678  strSmartContract, strPartyName, strAgentName);
1679 
1680  if (VerifyStringVal(strAgentID)) {
1681  cout << "--------------------\n " << nIndex << " : Agent '"
1682  << strAgentName << "' (party '" << strPartyName
1683  << "') has NymID: " << strAgentID << " ('"
1684  << OTAPI_Wrap::GetNym_Name(strAgentID) << "')\n";
1685  }
1686  else {
1687  cout << " " << nIndex << " : Agent '" << strAgentName << "' (party '"
1688  << strPartyName << "') has no NymID assigned (yet.)\n";
1689  }
1690 
1691  return true;
1692 }
static EXPORT std::string Party_GetAgentID(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const std::string &AGENT_NAME)
Definition: OTAPI.cpp:1409
static EXPORT std::string GetNym_Name(const std::string &NYM_ID)
Definition: OTAPI.cpp:648
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyagent_index ( const std::string &  strSmartContract,
const std::string &  strPartyName,
int32_t  nCurrentAgent 
)
static

Definition at line 1694 of file ot_commands_ot.cpp.

1697 {
1698  string strAgentName = OTAPI_Wrap::Party_GetAgentNameByIndex(
1699  strSmartContract, strPartyName, nCurrentAgent);
1700 
1701  if (!VerifyStringVal(strAgentName)) {
1702  otOut << "Error: Failed retrieving Agent Name from party '"
1703  << strPartyName << "' at agent index: " << nCurrentAgent << "\n";
1704  return false;
1705  }
1706  return stat_partyagent(strSmartContract, strPartyName, strAgentName,
1707  nCurrentAgent);
1708 }
static EXPORT std::string Party_GetAgentNameByIndex(const std::string &THE_CONTRACT, const std::string &PARTY_NAME, const int32_t &nIndex)
Definition: OTAPI.cpp:1402
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
EXPORT static OT_COMMANDS_OT bool stat_partyagent(const std::string &strSmartContract, const std::string &strPartyName, const std::string &strAgentName, int32_t nIndex)
OT_COMMANDS_OT bool opentxs::OT_Command::stat_partyagents ( const std::string &  strSmartContract,
const std::string &  strPartyName,
int32_t  nDepth 
)
static

Definition at line 1710 of file ot_commands_ot.cpp.

1713 {
1714  int32_t nAgentCount =
1715  OTAPI_Wrap::Party_GetAgentCount(strSmartContract, strPartyName);
1716 
1717  if (nAgentCount < 0) {
1718  otOut << "Error: Party '" << strPartyName
1719  << "' has bad value for number of authorized agents.\n";
1720  return false;
1721  }
1722 
1723  if (nDepth > 0) {
1724  for (int32_t nCurrentAgent = 0; nCurrentAgent < nAgentCount;
1725  ++nCurrentAgent) {
1726  if (!stat_partyagent_index(strSmartContract, strPartyName,
1727  nCurrentAgent)) {
1728  return false;
1729  }
1730  }
1731  }
1732  else {
1733  cout << "Party '" << strPartyName << "' has " << nAgentCount
1734  << (1 == nAgentCount ? " agent." : " agents.") << "\n";
1735  }
1736 
1737  return true;
1738 }
OTLOG_IMPORT OTLogStream otOut
EXPORT static OT_COMMANDS_OT bool stat_partyagent_index(const std::string &strSmartContract, const std::string &strPartyName, int32_t nCurrentAgent)
static EXPORT int32_t Party_GetAgentCount(const std::string &THE_CONTRACT, const std::string &PARTY_NAME)
Definition: OTAPI.cpp:1362
OT_COMMANDS_OT bool opentxs::OT_Command::withdraw_and_send_cash ( const std::string &  strMyAcctID,
std::string &  strHisNymID,
const std::string &  strMemo,
const std::string &  strAmount 
)
static

Definition at line 8554 of file ot_commands_ot.cpp.

8557 {
8558  string strLocation = "withdraw_and_send_cash";
8559 
8560  if (!VerifyStringVal(strMyAcctID) || !VerifyStringVal(strHisNymID) ||
8561  !VerifyStringVal(strAmount)) {
8562  otOut << strLocation << ": Failure: Missing one of: strMyAcctID ("
8563  << strMyAcctID << "), strHisNymID (" << strHisNymID
8564  << "), or strAmount (" << strAmount << ")\n";
8565  return false;
8566  }
8567 
8568  string strMyNymID = OTAPI_Wrap::GetAccountWallet_NymID(strMyAcctID);
8569  if (!VerifyStringVal(strMyNymID)) {
8570  otOut << strLocation
8571  << ": Failure: Unable to find NymID based on strMyAcctID ("
8572  << strMyAcctID << ").\n";
8573  return false;
8574  }
8575 
8576  string strServerID = OTAPI_Wrap::GetAccountWallet_ServerID(strMyAcctID);
8577  if (!VerifyStringVal(strServerID)) {
8578  otOut << strLocation
8579  << ": Failure: Unable to find Server ID based on strMyAcctID ("
8580  << strMyAcctID << ").\n";
8581  return false;
8582  }
8583 
8584  string strAssetTypeID =
8586  if (!VerifyStringVal(strAssetTypeID)) {
8587  otOut
8588  << strLocation
8589  << ": Failure: Unable to find Asset Type ID based on strMyAcctID ("
8590  << strMyAcctID << ").\n";
8591  return false;
8592  }
8593 
8594  int64_t lAmount = int64_t(0);
8595 
8596  if (VerifyStringVal(strAmount)) {
8597  lAmount = std::stoll(strAmount);
8598  }
8599 
8600  if (lAmount <= 0) {
8601  otOut << strLocation << ": Invalid value: strAmount (" << strAmount
8602  << ")\n";
8603  return false;
8604  }
8605 
8606  string strTempMemo = "";
8607  string strResponse = "";
8608  string strIndices = "";
8609  bool bPasswordProtected = false;
8610 
8611  if (VerifyStringVal(strMemo)) {
8612  strTempMemo = strMemo;
8613  }
8614 
8616  strResponse, strServerID, strAssetTypeID, strMyNymID,
8617  strMyAcctID, strHisNymID, strTempMemo, strAmount, strIndices,
8618  bPasswordProtected)) {
8619  return true;
8620  }
8621 
8622  return false;
8623 }
static EXPORT std::string GetAccountWallet_NymID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1052
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool VerifyStringVal(const std::string &nValue)
static EXPORT std::string GetAccountWallet_AssetTypeID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1042
EXPORT static OT_COMMANDS_OT int32_t details_send_cash(std::string &strResponse, const std::string &strServerID, const std::string &strAssetTypeID, const std::string &strMyNymID, const std::string &strMyAcctID, std::string &strHisNymID, const std::string &strMemo, const std::string &strAmount, std::string &strIndices, bool bPasswordProtected)
static EXPORT std::string GetAccountWallet_ServerID(const std::string &ACCOUNT_ID)
Definition: OTAPI.cpp:1047

The documentation for this class was generated from the following files: