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

Namespaces

 OTDB
 

Classes

class  Basket
 
class  BasketContract
 
class  BasketItem
 
class  LucreDumper
 
class  Mint
 
class  MintLucre
 
class  Purse
 
class  Token
 
class  Token_Lucre
 
class  OT_API
 
class  OT_Command
 
class  OT_ME
 
class  OTAPI_Wrap
 
class  OTAPI_Exec
 
class  OTClient
 
class  OTMessageBuffer
 
class  OTMessageOutbuffer
 
class  OTRecord
 
class  OTNameLookup
 
class  OTLookupCaller
 
class  OTRecordList
 
class  OTServerConnection
 
class  OTWallet
 
class  TransportCallback
 
class  AccountList
 
class  AccountVisitor
 
class  OTCron
 
class  OTCronItem
 
class  OpenSSL_BIO
 
class  OTASCIIArmor
 
class  OTAsymmetricKey
 
class  OTAsymmetricKey_OpenSSL
 
class  OTCachedKey
 
class  OTCallback
 
class  OTCaller
 
class  OTCredential
 
class  OTCryptoConfig
 
class  OTCrypto_Decrypt_Output
 
class  OTCrypto
 
class  OTCrypto_OpenSSL
 
class  OTEnvelope
 
class  OTKeyCredential
 
class  OTKeypair
 
class  OTKeyring
 
class  OTLowLevelKeyData
 
class  OTMasterkey
 
class  OTNym_or_SymmetricKey
 
class  OTPassword
 
class  OTPasswordData
 
class  OTSignature
 
class  OTSignatureMetadata
 
class  OTSignedFile
 
class  OTSubcredential
 
class  OTSubkey
 
class  OTSymmetricKey
 
class  OTAccount
 
class  OTAssetContract
 
class  OTCheque
 
class  OTContract
 
class  OTData
 
class  OTIdentifier
 
class  OTInstrument
 
class  OTItem
 
class  OTLedger
 
class  OTLogStream
 
class  OTLog
 
class  OTMessage
 
class  OTNumList
 
class  OTPayload
 
class  OTPseudonym
 
class  OTServerContract
 
class  OTSettings
 
class  OTString
 
class  OTStringXML
 
class  OTTrackable
 
class  OTTransaction
 
class  OTTransactionType
 
class  OTAgreement
 
class  OTPaymentPlan
 
class  OTAgent
 
class  OTBylaw
 
class  OTClause
 
class  OTParty
 
class  OTPartyAccount
 
class  OTScript
 
class  OTScriptable
 
class  OTSmartContract
 
class  OTStash
 
class  OTStashItem
 
class  OTVariable
 
class  OTMarket
 
class  OTOffer
 
class  OTTrade
 
class  OTDataFolder
 
class  OTFolders
 
class  OTPaths
 
struct  split
 
class  OTPayment
 
class  OTSocket
 
class  OTSocket_ZMQ_4
 
class  ClientConnection
 
struct  ConfigLoader
 
class  MainFile
 
class  MessageProcessor
 
class  Notary
 
class  OTServer
 
class  PayDividendVisitor
 
class  ServerLoader
 
struct  ServerSettings
 
class  Transactor
 
class  UserCommandProcessor
 
class  MadeEasy
 
class  Utility
 
class  OTMeCpp
 
struct  ELGAMAL
 
struct  PgpKeys
 
struct  sig_ucontext_t
 
class  Opentxs
 

Typedefs

typedef std::deque< BasketItem * > dequeOfBasketItems
 
typedef std::map< int64_t,
OTASCIIArmor * > 
mapOfArmor
 
typedef std::deque
< OTASCIIArmor * > 
dequeOfTokens
 
typedef std::map< int32_t,
OTASCIIArmor * > 
mapOfPrototokens
 
typedef std::multimap< int64_t,
OTMessage * > 
mapOfMessages
 
typedef std::weak_ptr< OTRecordweak_ptr_OTRecord
 
typedef std::shared_ptr< OTRecordshared_ptr_OTRecord
 
typedef std::vector
< shared_ptr_OTRecord
vec_OTRecordList
 
typedef std::list< std::string > list_of_strings
 
typedef std::map< std::string,
std::string > 
map_of_strings
 
typedef std::map< std::string,
OTAccount * > 
mapOfAccounts
 
typedef std::map< std::string,
OTAssetContract * > 
mapOfContracts
 
typedef std::map< std::string,
OTPseudonym * > 
mapOfNyms
 
typedef std::map< std::string,
OTServerContract * > 
mapOfServers
 
typedef std::map< std::string,
std::shared_ptr
< OTSymmetricKey > > 
mapOfSymmetricKeys
 
typedef std::set< OTIdentifiersetOfIdentifiers
 
typedef std::map< int64_t,
OTCronItem * > 
mapOfCronItems
 
typedef std::multimap
< time64_t, OTCronItem * > 
multimapOfCronItems
 
typedef std::map< std::string,
OTMarket * > 
mapOfMarkets
 
typedef std::list< int64_t > listOfLongNumbers
 
typedef std::list
< OTAsymmetricKey * > 
listOfAsymmetricKeys
 
typedef int32_t OT_OPENSSL_CALLBACK (char *buf, int32_t size, int32_t rwflag, void *userdata)
 
typedef std::map< std::string,
std::shared_ptr< OTCachedKey > > 
mapOfCachedKeys
 
typedef std::map< std::string,
OTSubcredential * > 
mapOfSubcredentials
 
typedef std::multimap
< std::string, OTAsymmetricKey * > 
mapOfAsymmetricKeys
 
typedef std::set< OTPseudonym * > setOfNyms
 
typedef std::list< OTSignature * > listOfSignatures
 
typedef std::list< OTItem * > listOfItems
 
typedef std::map< int64_t,
OTTransaction * > 
mapOfTransactions
 
typedef std::deque< OTString * > dequeOfStrings
 
typedef std::deque< OTMessage * > dequeOfMail
 
typedef std::map< std::string,
int64_t > 
mapOfRequestNums
 
typedef std::map< std::string,
int64_t > 
mapOfHighestNums
 
typedef std::deque< int64_t > dequeOfTransNums
 
typedef std::map< std::string,
dequeOfTransNums * > 
mapOfTransNums
 
typedef std::map< std::string,
OTIdentifier
mapOfIdentifiers
 
typedef std::map< std::string,
OTCredential * > 
mapOfCredentials
 
typedef std::map< std::string,
std::string > 
mapOfCallbacks
 
typedef std::map< std::string,
OTClause * > 
mapOfClauses
 
typedef std::map< std::string,
OTVariable * > 
mapOfVariables
 
typedef std::multimap
< std::string, std::string > 
mapOfHooks
 
typedef std::map< std::string,
OTAgent * > 
mapOfAgents
 
typedef std::map< std::string,
OTPartyAccount * > 
mapOfPartyAccounts
 
typedef std::map< std::string,
OTParty * > 
mapOfParties
 
typedef std::map< std::string,
OTBylaw * > 
mapOfBylaws
 
typedef std::map< std::string,
OTStash * > 
mapOfStashes
 
typedef std::map< std::string,
OTStashItem * > 
mapOfStashItems
 
typedef std::multimap< int64_t,
OTOffer * > 
mapOfOffers
 
typedef std::map< int64_t,
OTOffer * > 
mapOfOffersTrnsNum
 
typedef uint8_t OT_BYTE
 
typedef bool OT_BOOL
 
typedef std::map< std::string,
Token * > 
mapOfTokenPointers
 
typedef std::map< std::string,
std::string > 
mapOfArguments
 
typedef std::array< bool, 4 > OTfourbool
 
typedef std::map< int32_t,
OTPayment * > 
mapOfPayments
 
typedef bool(OTSmartContract::* OT_SM_RetBool_ThrStr )(std::string from_acct_name, std::string to_acct_name, std::string str_Amount)
 
typedef std::list< OTAccount * > listOfAccounts
 
typedef std::deque< Token * > dequeOfTokenPtrs
 

Enumerations

enum  { TradeProcessIntervalSeconds = 10 }
 

Functions

EXPORT int32_t OT_CLI_GetArgsCount (const std::string &str_Args)
 
EXPORT std::string OT_CLI_GetValueByKey (const std::string &str_Args, const std::string &str_key)
 
EXPORT std::string OT_CLI_GetValueByIndex (const std::string &str_Args, int32_t nIndex)
 
EXPORT std::string OT_CLI_GetKeyByIndex (const std::string &str_Args, int32_t nIndex)
 
EXPORT std::string OT_CLI_ReadLine ()
 
EXPORT std::string OT_CLI_ReadUntilEOF ()
 
EXPORT bool OT_API_Set_AddrBookCallback (OTLookupCaller &theCaller)
 
EXPORT bool OT_API_Set_PasswordCallback (OTCaller &theCaller)
 
EXPORT std::shared_ptr< OTScriptOTScriptFactory (const std::string &script_type="")
 
EXPORT std::shared_ptr< OTScriptOTScriptFactory (const std::string &script_type, const std::string &script_contents)
 
EXPORT const char * GetTransactionTypeString (int transactionNumber)
 
int32_t LoadAbbreviatedRecord (irr::io::IrrXMLReader *&xml, int64_t &lNumberOfOrigin, int64_t &lTransactionNum, int64_t &lInRefTo, int64_t &lInRefDisplay, time64_t &the_DATE_SIGNED, int &theType, OTString &strHash, int64_t &lAdjustment, int64_t &lDisplayValue, int64_t &lClosingNum, int64_t &lRequestNum, bool &bReplyTransSuccess, OTNumList *pNumList=nullptr)
 
EXPORT bool VerifyBoxReceiptExists (const OTIdentifier &SERVER_ID, const OTIdentifier &USER_ID, const OTIdentifier &ACCOUNT_ID, int32_t nBoxType, const int64_t &lTransactionNum)
 
OTTransactionLoadBoxReceipt (OTTransaction &theAbbrev, OTLedger &theLedger)
 
EXPORT OTTransactionLoadBoxReceipt (OTTransaction &theAbbrev, int64_t lLedgerType)
 
bool SetupBoxReceiptFilename (int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
 
bool SetupBoxReceiptFilename (OTLedger &theLedger, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
 
bool SetupBoxReceiptFilename (int64_t lLedgerType, const OTString &strUserOrAcctID, const OTString &strServerID, const int64_t &lTransactionNum, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
 
void AppendChecksum (OT_BYTE *buffer, uint32_t &size)
 
EXPORT OT_BYTE CalcChecksum (OT_BYTE *buffer, uint32_t size)
 
OT_BYTE CalcChecksum (const OT_BYTE *const buffer, uint32_t size)
 
EXPORT OT_BOOL IsChecksumValid (OT_BYTE *buffer, uint32_t size)
 
char * str_dup2 (const char *str, uint32_t length)
 
template<typename T >
std::string to_string (const T &t)
 
size_t strlcpy (char *dst, const char *src, size_t siz)
 
size_t strlcat (char *dst, const char *src, size_t siz)
 
void SetMonitor (const char *filepathexact)
 
OTPaymentGetInstrument (const OTPseudonym &theNym, const int32_t &nIndex, OTLedger &ledger)
 
int32_t GetOutpaymentsIndexByTransNum (const OTPseudonym &nym, int64_t lTransNum)
 
vector< string > tokenize (const string &str, const string &delimiters, bool trimEmpty)
 
bool NewScriptExists (const OTString &strScriptFilename, bool bIsHeader, OTString &out_ScriptFilepath)
 
OT_UTILITY_OT bool VerifyExists (const string &theObjectNameAsStr)
 
OT_UTILITY_OT bool VerifyExists (const string &theObjectNameAsStr, bool bDisplayError)
 
OT_UTILITY_OT bool VerifyMessage (const string &strMessage)
 
OT_UTILITY_OT int32_t VerifyMessageSuccess (const string &strMessage)
 
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 VerifyMsgTrnxSuccess (const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, 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 VerifyStringVal (const std::string &nValue)
 
void load_str_trans_add_to_ledger (const OTIdentifier &the_nym_id, const OTString &str_trans, OTString str_box_type, const int64_t &lTransNum, OTPseudonym &the_nym, OTLedger &ledger)
 
bool compare_records (shared_ptr_OTRecord i, shared_ptr_OTRecord j)
 
void SetupHeader (u_header &theCMD, int32_t nTypeID, int32_t nCmdID, OTPayload &thePayload)
 
void TranslateAccountTypeToString (OTAccount::AccountType type, OTString &acctType)
 
OTAccount::AccountType TranslateAccountTypeStringToEnum (const OTString &acctType)
 
std::string compress_string (const std::string &str, int32_t compressionlevel=Z_BEST_COMPRESSION)
 
std::string decompress_string (const std::string &str)
 
int32_t default_pass_cb (char *buf, int32_t size, int32_t, void *userdata)
 
int32_t souped_up_pass_cb (char *buf, int32_t size, int32_t rwflag, void *userdata)
 
PgpKeys ExportRsaKey (uint8_t *pbData, int32_t dataLength)
 
unsigned int64_t ot_openssl_thread_id (void)
 
void ot_openssl_locking_callback (int32_t mode, int32_t type, char *file, int32_t line)
 
void ot_openssl_locking_callback (int32_t mode, int32_t type, const char *, int32_t)
 
char * ot_openssl_base64_encode (const uint8_t *input, int32_t in_len, int32_t bLineBreaks)
 
uint8_t * ot_openssl_base64_decode (const char *input, size_t *out_len, int32_t bLineBreaks)
 
void * ot_secure_memset (void *v, uint8_t c, uint32_t n)
 
bool ot_lockPage (void *addr, size_t len)
 
bool ot_unlockPage (void *addr, size_t len)
 
void separateThousands (std::stringstream &sss, int64_t value, const char *szSeparator)
 
std::ostream & operator<< (std::ostream &os, const OTIdentifier &obj)
 
OTItem::itemType GetItemTypeFromString (const OTString &strType)
 
OTLOG_IMPORT OTLogStream otErr (-1)
 
OTLOG_IMPORT OTLogStream otInfo (2)
 
OTLOG_IMPORT OTLogStream otOut (0)
 
OTLOG_IMPORT OTLogStream otWarn (1)
 
OTLOG_IMPORT OTLogStream otLog3 (3)
 
OTLOG_IMPORT OTLogStream otLog4 (4)
 
OTLOG_IMPORT OTLogStream otLog5 (5)
 
void ot_terminate (void)
 
void crit_err_hdlr (int32_t sig_num, siginfo_t *info, void *ucontext)
 
std::ostream & operator<< (std::ostream &os, const OTString &obj)
 
void fwrite_string (std::ostream &ofs, const char *str)
 
bool is_ot_namechar_invalid (char c)
 
void cleanup_four_accounts (OTAccount *p1, OTAccount *p2, OTAccount *p3, OTAccount *p4)
 
void rollback_four_accounts (OTAccount &p1, bool b1, const int64_t &a1, OTAccount &p2, bool b2, const int64_t &a2, OTAccount &p3, bool b3, const int64_t &a3, OTAccount &p4, bool b4, const int64_t &a4)
 
bool isPowerOfTen (const int64_t &x)
 
bool GetExecutable (OTString &strExecutablePath)
 
bool GetCurrentWorking (OTString &strCurrentWorkingPath)
 

Variables

const char * OT_BEGIN_ARMORED = "-----BEGIN OT ARMORED"
 
const char * OT_END_ARMORED = "-----END OT ARMORED"
 
const char * OT_BEGIN_ARMORED_escaped = "- -----BEGIN OT ARMORED"
 
const char * OT_END_ARMORED_escaped = "- -----END OT ARMORED"
 
const char * OT_BEGIN_SIGNED = "-----BEGIN SIGNED"
 
const char * OT_BEGIN_SIGNED_escaped = "- -----BEGIN SIGNED"
 
EXPORT OT_OPENSSL_CALLBACK default_pass_cb
 
EXPORT OT_OPENSSL_CALLBACK souped_up_pass_cb
 
OTLOG_IMPORT OTLogStream otErr
 
OTLOG_IMPORT OTLogStream otInfo
 
OTLOG_IMPORT OTLogStream otOut
 
OTLOG_IMPORT OTLogStream otWarn
 
OTLOG_IMPORT OTLogStream otLog3
 
OTLOG_IMPORT OTLogStream otLog4
 
OTLOG_IMPORT OTLogStream otLog5
 
const int32_t Token__nMinimumPrototokenCount = 1
 
const int32_t OT_FALSE = 0
 
const int32_t OT_TRUE = 1
 
const int32_t OT_ERROR = (-1)
 
int32_t allow_debug = 1
 
char const *const __TypeStrings []
 

Typedef Documentation

Definition at line 143 of file BasketItem.hpp.

typedef std::deque<OTMessage*> opentxs::dequeOfMail

Definition at line 156 of file OTPseudonym.hpp.

typedef std::deque<OTString*> opentxs::dequeOfStrings

Definition at line 156 of file OTLog.hpp.

typedef std::deque<Token*> opentxs::dequeOfTokenPtrs

Definition at line 167 of file Notary.cpp.

typedef std::deque<OTASCIIArmor*> opentxs::dequeOfTokens

Definition at line 147 of file Purse.hpp.

typedef std::deque<int64_t> opentxs::dequeOfTransNums

Definition at line 161 of file OTPseudonym.hpp.

typedef std::list<std::string> opentxs::list_of_strings

Definition at line 233 of file OTRecordList.hpp.

typedef std::list<OTAccount*> opentxs::listOfAccounts

Definition at line 166 of file Notary.cpp.

Definition at line 148 of file OTAsymmetricKey.hpp.

typedef std::list<OTItem*> opentxs::listOfItems

Definition at line 145 of file OTItem.hpp.

typedef std::list<int64_t> opentxs::listOfLongNumbers

Definition at line 162 of file OTCron.hpp.

Definition at line 158 of file OTContract.hpp.

typedef std::map<std::string, std::string> opentxs::map_of_strings

Definition at line 234 of file OTRecordList.hpp.

typedef std::map< std::string, OTAccount * > opentxs::mapOfAccounts

Definition at line 157 of file OTWallet.hpp.

typedef std::map<std::string, OTAgent*> opentxs::mapOfAgents

Definition at line 151 of file OTParty.hpp.

typedef std::map<std::string, std::string> opentxs::mapOfArguments

Definition at line 171 of file OT_ME.cpp.

typedef std::map< int64_t, OTASCIIArmor * > opentxs::mapOfArmor

Definition at line 146 of file Mint.hpp.

typedef std::multimap< std::string, OTAsymmetricKey * > opentxs::mapOfAsymmetricKeys

Definition at line 155 of file OTCrypto.hpp.

typedef std::map<std::string, OTBylaw*> opentxs::mapOfBylaws

Definition at line 148 of file OTScriptable.hpp.

typedef std::map<std::string, std::shared_ptr<OTCachedKey> > opentxs::mapOfCachedKeys

Definition at line 309 of file OTCachedKey.hpp.

typedef std::map<std::string, std::string> opentxs::mapOfCallbacks

Definition at line 142 of file OTBylaw.hpp.

typedef std::map< std::string, OTClause * > opentxs::mapOfClauses

Definition at line 145 of file OTBylaw.hpp.

typedef std::map<std::string, OTAssetContract*> opentxs::mapOfContracts

Definition at line 160 of file OTWallet.hpp.

typedef std::map<std::string, OTCredential*> opentxs::mapOfCredentials

Definition at line 164 of file OTPseudonym.hpp.

typedef std::map<int64_t, OTCronItem*> opentxs::mapOfCronItems

Definition at line 148 of file OTCron.hpp.

typedef std::map<std::string, int64_t> opentxs::mapOfHighestNums

Definition at line 160 of file OTPseudonym.hpp.

typedef std::multimap<std::string, std::string> opentxs::mapOfHooks

Definition at line 153 of file OTBylaw.hpp.

typedef std::map<std::string, OTIdentifier> opentxs::mapOfIdentifiers

Definition at line 163 of file OTPseudonym.hpp.

typedef std::map<std::string, OTMarket*> opentxs::mapOfMarkets

Definition at line 158 of file OTCron.hpp.

typedef std::multimap<int64_t, OTMessage*> opentxs::mapOfMessages

Definition at line 144 of file OTMessageOutbuffer.hpp.

typedef std::map< std::string, OTPseudonym * > opentxs::mapOfNyms

Definition at line 161 of file OTWallet.hpp.

typedef std::multimap<int64_t, OTOffer*> opentxs::mapOfOffers

Definition at line 156 of file OTMarket.hpp.

typedef std::map<int64_t, OTOffer*> opentxs::mapOfOffersTrnsNum

Definition at line 159 of file OTMarket.hpp.

typedef std::map< std::string, OTParty * > opentxs::mapOfParties

Definition at line 155 of file OTScript.hpp.

typedef std::map< std::string, OTPartyAccount * > opentxs::mapOfPartyAccounts

Definition at line 153 of file OTParty.hpp.

typedef std::map<int32_t, OTPayment*> opentxs::mapOfPayments

Definition at line 557 of file OTRecordList.cpp.

typedef std::map<int32_t, OTASCIIArmor*> opentxs::mapOfPrototokens

Definition at line 147 of file Token.hpp.

typedef std::map<std::string, int64_t> opentxs::mapOfRequestNums

Definition at line 159 of file OTPseudonym.hpp.

typedef std::map<std::string, OTServerContract*> opentxs::mapOfServers

Definition at line 162 of file OTWallet.hpp.

typedef std::map<std::string, OTStash*> opentxs::mapOfStashes

Definition at line 148 of file OTSmartContract.hpp.

typedef std::map<std::string, OTStashItem*> opentxs::mapOfStashItems

Definition at line 156 of file OTStash.hpp.

typedef std::map<std::string, OTSubcredential*> opentxs::mapOfSubcredentials

Definition at line 182 of file OTCredential.hpp.

typedef std::map<std::string, std::shared_ptr<OTSymmetricKey> > opentxs::mapOfSymmetricKeys

Definition at line 164 of file OTWallet.hpp.

typedef std::map<std::string, Token*> opentxs::mapOfTokenPointers

Definition at line 152 of file Purse.cpp.

typedef std::map<int64_t, OTTransaction*> opentxs::mapOfTransactions

Definition at line 146 of file OTLedger.hpp.

typedef std::map<std::string, dequeOfTransNums*> opentxs::mapOfTransNums

Definition at line 162 of file OTPseudonym.hpp.

typedef std::map< std::string, OTVariable * > opentxs::mapOfVariables

Definition at line 146 of file OTBylaw.hpp.

Definition at line 155 of file OTCron.hpp.

typedef bool opentxs::OT_BOOL

Definition at line 142 of file OTDataCheck.hpp.

typedef uint8_t opentxs::OT_BYTE

Definition at line 141 of file OTDataCheck.hpp.

typedef int32_t opentxs::OT_OPENSSL_CALLBACK(char *buf, int32_t size, int32_t rwflag, void *userdata)

Definition at line 195 of file OTAsymmetricKey.hpp.

typedef bool(OTSmartContract::* opentxs::OT_SM_RetBool_ThrStr)(std::string from_acct_name, std::string to_acct_name, std::string str_Amount)

Definition at line 841 of file OTSmartContract.cpp.

typedef std::array<bool, 4> opentxs::OTfourbool

Definition at line 170 of file ot_utility_ot.hpp.

Definition at line 165 of file OTWallet.hpp.

typedef std::set<OTPseudonym*> opentxs::setOfNyms

Definition at line 154 of file OTEnvelope.hpp.

typedef std::shared_ptr<OTRecord> opentxs::shared_ptr_OTRecord

Definition at line 230 of file OTRecordList.hpp.

Definition at line 232 of file OTRecordList.hpp.

typedef std::weak_ptr<OTRecord> opentxs::weak_ptr_OTRecord

Definition at line 229 of file OTRecordList.hpp.

Enumeration Type Documentation

anonymous enum
Enumerator
TradeProcessIntervalSeconds 

Definition at line 149 of file OTTrade.cpp.

Function Documentation

void opentxs::AppendChecksum ( OT_BYTE *  buffer,
uint32_t &  size 
)

Definition at line 141 of file OTDataCheck.cpp.

142 {
143  uint32_t i;
144  OT_BYTE total = 0;
145 
146  OT_ASSERT(nullptr != buffer);
147  // otErr << "Appending checksum. Size: %d ", size);
148 
149  for (i = 0; i < size; i++) {
150  total += buffer[i];
151  // otErr << "%d ", buffer[i]);
152  }
153 
154  // otErr << " VALUE: %d\n", (255 - total));
155 
156  buffer[size++] = 255 - total;
157 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
uint8_t OT_BYTE
OT_BYTE opentxs::CalcChecksum ( OT_BYTE *  buffer,
uint32_t  size 
)

Definition at line 159 of file OTDataCheck.cpp.

160 {
161  uint32_t i;
162  OT_BYTE total = 0;
163 
164  OT_ASSERT(nullptr != buffer);
165 
166  // otErr << "Calculating checksum. Size: %d ", size);
167 
168  for (i = 0; i < size; i++) {
169  total += buffer[i];
170  // otErr << "%d ", buffer[i]);
171  }
172  // otErr << " VALUE: %d\n", (255 - total));
173 
174  return (255 - total);
175 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
uint8_t OT_BYTE
OT_BYTE opentxs::CalcChecksum ( const OT_BYTE *const  buffer,
uint32_t  size 
)

Definition at line 177 of file OTDataCheck.cpp.

178 {
179  uint32_t i;
180  OT_BYTE total = 0;
181 
182  OT_ASSERT(nullptr != buffer);
183 
184  // otErr << "Calculating checksum. Size: %d\n", size);
185 
186  for (i = 0; i < size; i++) {
187  total += buffer[i];
188  // otErr << "%d ", buffer[i]);
189  }
190  // otErr << " TOTAL: %d\n", (255 - total));
191 
192  return (255 - total);
193 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
uint8_t OT_BYTE
void opentxs::cleanup_four_accounts ( OTAccount *  p1,
OTAccount *  p2,
OTAccount *  p3,
OTAccount *  p4 
)

Definition at line 964 of file OTMarket.cpp.

966 {
967  if (p1) delete p1;
968  if (p2) delete p2;
969  if (p3) delete p3;
970  if (p4) delete p4;
971 }
bool opentxs::compare_records ( shared_ptr_OTRecord  i,
shared_ptr_OTRecord  j 
)

Definition at line 1059 of file OTRecordList.cpp.

1060 {
1061  return j->operator<(*i);
1062 }
std::string opentxs::compress_string ( const std::string &  str,
int32_t  compressionlevel = Z_BEST_COMPRESSION 
)

Compress a STL string using zlib with given compression level and return the binary data.

Definition at line 303 of file OTASCIIArmor.cpp.

305 {
306  z_stream zs; // z_stream is zlib's control structure
307  memset(&zs, 0, sizeof(zs));
308 
309  if (deflateInit(&zs, compressionlevel) != Z_OK)
310  throw(std::runtime_error("deflateInit failed while compressing."));
311 
312  zs.next_in = (Bytef*)str.data();
313  zs.avail_in = static_cast<uInt>(str.size()); // set the z_stream's input
314 
315  int32_t ret;
316  char outbuffer[32768];
317  std::string outstring;
318 
319  // retrieve the compressed bytes blockwise
320  do {
321  zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
322  zs.avail_out = sizeof(outbuffer);
323 
324  ret = deflate(&zs, Z_FINISH);
325 
326  if (outstring.size() < zs.total_out) {
327  // append the block to the output string
328  outstring.append(outbuffer, zs.total_out - outstring.size());
329  }
330  } while (ret == Z_OK);
331 
332  deflateEnd(&zs);
333 
334  if (ret != Z_STREAM_END) { // an error occurred that was not EOF
335  std::ostringstream oss;
336  oss << "Exception during zlib compression: (" << ret << ") " << zs.msg;
337  throw(std::runtime_error(oss.str()));
338  }
339 
340  return outstring;
341 }
void opentxs::crit_err_hdlr ( int32_t  sig_num,
siginfo_t *  info,
void *  ucontext 
)

Definition at line 1141 of file OTLog.cpp.

1142 {
1143 #ifndef ANDROID
1144  static std::mutex the_Mutex;
1145 
1146  std::lock_guard<std::mutex> lock(the_Mutex);
1147 
1148  OT_ASSERT(nullptr != v);
1149 
1150 #ifdef _LP64
1151  typedef uint64_t ot_ulong;
1152 #else
1153  typedef uint32_t ot_ulong;
1154 #endif // lp64
1155 
1156  ot_ulong eip = 0;
1157  ucontext_t* uc = (ucontext_t*)v;
1158 
1159 #if defined(__APPLE__)
1160 #ifdef __arm__
1161  _STRUCT_MCONTEXT* mc; // mcontext_t seems to be missing from arm/_structs.h
1162  // cppcheck-suppress unreadVariable
1163  mc = uc->uc_mcontext;
1164 // eip = mc->__ss.__eip; // arm doesn't have eip
1165 #else
1166  mcontext_t mc;
1167  mc = uc->uc_mcontext;
1168 #ifdef _LP64
1169  eip = mc->__ss.__rip;
1170 #else
1171  eip = mc->__ss.__eip;
1172 #endif
1173 #endif // __arm__
1174 #elif defined(__linux__)
1175  mcontext_t* mc;
1176  struct sigcontext* ctx;
1177  mc = &uc->uc_mcontext;
1178  ctx = (struct sigcontext*)mc;
1179 #ifdef __i386__
1180  eip = ctx->eip;
1181 #else
1182  eip = ctx->rip;
1183 #endif
1184 #elif defined(__FreeBSD__)
1185  mcontext_t* mc;
1186  mc = &uc->uc_mcontext;
1187 #ifdef __i386__
1188  eip = mc->mc_eip;
1189 #elif defined(__amd64__)
1190  eip = mc->mc_rip;
1191 #endif
1192  ot_ulong addr = (ot_ulong)info->si_addr;
1193  if (__FreeBSD__ < 7) {
1194  /*
1195  * FreeBSD /usr/src/sys/i386/i386/trap.c kludgily reuses
1196  * frame->tf_err as somewhere to put the faulting address
1197  * (cr2) when calling into the generic signal dispatcher.
1198  * Unfortunately, that means that the bit in tf_err that says
1199  * whether this is a read or write fault is irretrievably gone.
1200  * So we have to figure it out. Let's assume that if the page
1201  * is already mapped in core, it is a write fault. If not, it is a
1202  * read fault.
1203  *
1204  * This is apparently fixed in FreeBSD 7, but I don't have any
1205  * FreeBSD 7 machines on which to verify this.
1206  */
1207  char vec;
1208  int32_t r;
1209 
1210  vec = 0;
1211  r = mincore((void*)addr, 1, &vec);
1212  // iprint("FreeBSD fault [%d]: addr=%p[%p] mincore=%d vec=%#x
1213  // errno=%d\n", signo, addr, (uchar*)addr-uzero, r, vec, errno);
1214  if (r < 0 || vec == 0)
1215  mc->mc_err = 0; /* read fault */
1216  else
1217  mc->mc_err = 2; /* write fault */
1218  }
1219 #else
1220 #error "Unknown OS in sigsegv"
1221 #endif
1222 
1223  void* caller_address = (void*)eip;
1224 
1225  std::cerr << "signal " << sig_num << " (" << strsignal(sig_num)
1226  << "), address is " << info->si_addr << " from " << caller_address
1227  << std::endl << std::endl;
1228 
1229  void* array[50];
1230  int32_t size = backtrace(array, 50);
1231 
1232  array[1] = caller_address;
1233 
1234  char** messages = backtrace_symbols(array, size);
1235 
1236  // skip first stack frame (points here)
1237  for (int32_t i = 1; i < size && messages != nullptr; ++i) {
1238  char* mangled_name = 0, *offset_begin = 0, *offset_end = 0;
1239 
1240  // find parantheses and +address offset surrounding mangled name
1241  for (char* p = messages[i]; *p; ++p) {
1242  if (*p == '(') {
1243  mangled_name = p;
1244  }
1245  else if (*p == '+') {
1246  offset_begin = p;
1247  }
1248  else if (*p == ')') {
1249  offset_end = p;
1250  break;
1251  }
1252  }
1253 
1254  // if the line could be processed, attempt to demangle the symbol
1255  if (mangled_name && offset_begin && offset_end &&
1256  mangled_name < offset_begin) {
1257  *mangled_name++ = '\0';
1258  *offset_begin++ = '\0';
1259  *offset_end++ = '\0';
1260 
1261  int32_t status;
1262  char* real_name = abi::__cxa_demangle(mangled_name, 0, 0, &status);
1263 
1264  // if demangling is successful, output the demangled function name
1265  if (status == 0) {
1266  std::cerr << "[bt]: (" << i << ") " << messages[i] << " : "
1267  << real_name << "+" << offset_begin << offset_end
1268  << std::endl;
1269 
1270  }
1271  // otherwise, output the mangled function name
1272  else {
1273  std::cerr << "[bt]: (" << i << ") " << messages[i] << " : "
1274  << mangled_name << "+" << offset_begin << offset_end
1275  << std::endl;
1276  }
1277  free(real_name);
1278  }
1279  // otherwise, print the whole line
1280  else {
1281  std::cerr << "[bt]: (" << i << ") " << messages[i] << std::endl;
1282  }
1283  }
1284  std::cerr << std::endl;
1285 
1286  free(messages);
1287 #endif // #ifndef ANDROID
1288  _exit(0);
1289 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
std::string opentxs::decompress_string ( const std::string &  str)

Decompress an STL string using zlib and return the original data.

Definition at line 344 of file OTASCIIArmor.cpp.

345 {
346  z_stream zs; // z_stream is zlib's control structure
347  memset(&zs, 0, sizeof(zs));
348 
349  if (inflateInit(&zs) != Z_OK)
350  throw(std::runtime_error("inflateInit failed while decompressing."));
351 
352  zs.next_in = (Bytef*)str.data();
353  zs.avail_in = static_cast<uInt>(str.size());
354 
355  int32_t ret;
356  char outbuffer[32768];
357  std::string outstring;
358 
359  // get the decompressed bytes blockwise using repeated calls to inflate
360  do {
361  zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
362  zs.avail_out = sizeof(outbuffer);
363 
364  ret = inflate(&zs, 0);
365 
366  if (outstring.size() < zs.total_out) {
367  outstring.append(outbuffer, zs.total_out - outstring.size());
368  }
369 
370  } while (ret == Z_OK);
371 
372  inflateEnd(&zs);
373 
374  if (ret != Z_STREAM_END) { // an error occurred that was not EOF
375  std::ostringstream oss;
376  oss << "Exception during zlib decompression: (" << ret << ")";
377  if (zs.msg != nullptr) {
378  oss << " " << zs.msg;
379  }
380  throw(std::runtime_error(oss.str()));
381  }
382 
383  return outstring;
384 }
int32_t opentxs::default_pass_cb ( char *  buf,
int32_t  size,
int32_t  ,
void *  userdata 
)

Definition at line 382 of file OTAsymmetricKey.cpp.

384 {
385  int32_t len = 0;
386  const uint32_t theSize = uint32_t(size);
387 
388  // We'd probably do something else if 'rwflag' is 1
389 
390  const OTPasswordData* pPWData = nullptr;
391  std::string str_userdata;
392 
393  if (nullptr != userdata) {
394  pPWData = static_cast<OTPasswordData*>(userdata);
395 
396  if (nullptr != pPWData) {
397  str_userdata = pPWData->GetDisplayString();
398  }
399  }
400  else
401  str_userdata = "";
402 
403  // otWarn << "OPENSSL_CALLBACK: (Password callback hasn't been set
404  // yet...) Using 'test' pass phrase for \"%s\"\n", (char *)u);
405 
406  otWarn << __FUNCTION__ << ": Using DEFAULT TEST PASSWORD: "
407  "'test' (for \"" << str_userdata << "\")\n";
408 
409  // get pass phrase, length 'len' into 'tmp'
410  //
411  // std::string str_Password;
412  // std::getline (std::cin, str_Password);
413 
414  // const char *tmp_passwd = ""; // For now removing any possibility that
415  // "test" password can slip through.
416  const char* tmp_passwd = "test";
417  // const char *tmp_passwd = str_Password.c_str();
418 
419  len = static_cast<int32_t>(strlen(tmp_passwd));
420  // len = str_Password.size();
421 
422  if (len <= 0) {
423  otOut << __FUNCTION__ << ": Problem? Returning 0...\n";
424  return 0;
425  }
426 
427  // if too int64_t, truncate
428  if (len > size) len = size;
429 
430  const uint32_t theLength = static_cast<const uint32_t>(len);
431 
432  // void * pv =
433  OTPassword::safe_memcpy(buf, // destination
434  theSize, // size of destination buffer.
435  tmp_passwd, // source
436  theLength); // length of source.
437  // bool bZeroSource=false); // if true, sets the source buffer to zero after
438  // copying is done.
439  return len;
440 }
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otWarn
PgpKeys opentxs::ExportRsaKey ( uint8_t *  pbData,
int32_t  dataLength 
)

Definition at line 813 of file OTAsymmetricKeyOpenSSL.cpp.

814 {
815  PgpKeys pgpKeys;
816  int32_t i;
817 
818  OT_ASSERT(nullptr != pbData);
819 
820  memset(&pgpKeys, 0, sizeof(pgpKeys));
821  for (i = 0; i < dataLength;) {
822  int32_t packetLength;
823  uint8_t packetTag = pbData[i++];
824  if ((packetTag & 0x80) == 0) break;
825  if ((packetTag & 0x40)) {
826  packetTag &= 0x3F;
827  packetLength = pbData[i++];
828  if ((packetLength > 191) && (packetLength < 224))
829  packetLength = ((packetLength - 192) << 8) + pbData[i++];
830  else if ((packetLength > 223) && (packetLength < 255))
831  packetLength = (1 << (packetLength & 0x1f));
832  else if (packetLength == 255) {
833  packetLength = (pbData[i] << 24) + (pbData[i + 1] << 16) +
834  (pbData[i + 2] << 8) + pbData[i + 3];
835  i += 4;
836  }
837  }
838  else {
839  packetLength = packetTag & 3;
840  packetTag = (packetTag >> 2) & 15;
841  if (packetLength == 0)
842  packetLength = pbData[i++];
843  else if (packetLength == 1) {
844  packetLength = (pbData[i] << 8) + pbData[i + 1];
845  i += 2;
846  }
847  else if (packetLength == 2) {
848  packetLength = (pbData[i] << 24) + (pbData[i + 1] << 16) +
849  (pbData[i + 2] << 8) + pbData[i + 3];
850  i += 4;
851  }
852  else
853  packetLength = dataLength - 1;
854  }
855 
856  if ((packetTag == 6) || (packetTag == 14)) // a public key
857  {
858  int32_t algorithm;
859  int32_t version = pbData[i++];
860 
861  // skip time over 4 bytes
862  i += 4;
863 
864  if ((version == 2) || (version == 3)) {
865  // skip validity over 2 bytes
866  i += 2;
867  }
868 
869  algorithm = pbData[i++];
870 
871  if ((algorithm == 1) || (algorithm == 2) ||
872  (algorithm == 3)) // an RSA key
873  {
874  int32_t modulusLength, exponentLength;
875  RSA* pKey = RSA_new();
876 
877  // Get the modulus
878  modulusLength = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
879  pKey->n = BN_bin2bn(pbData + i + 2, modulusLength, nullptr);
880  i += modulusLength + 2;
881 
882  // Get the exponent
883  exponentLength = (pbData[i] * 256 + pbData[i + 1] + 7) / 8;
884  pKey->e = BN_bin2bn(pbData + i + 2, exponentLength, nullptr);
885  i += exponentLength + 2;
886 
887  pgpKeys.pRsa = pKey;
888 
889  continue;
890  }
891  else if (algorithm == 17) // a DSA key
892  {
893  int32_t pLen, qLen, gLen, yLen;
894  DSA* pKey = DSA_new();
895 
896  // Get Prime P
897  pLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
898  pKey->p = BN_bin2bn(pbData + i + 2, pLen, nullptr);
899  i += pLen + 2;
900 
901  // Get Prime Q
902  qLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
903  pKey->q = BN_bin2bn(pbData + i + 2, qLen, nullptr);
904  i += qLen + 2;
905 
906  // Get Prime G
907  gLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
908  pKey->g = BN_bin2bn(pbData + i + 2, gLen, nullptr);
909  i += gLen + 2;
910 
911  // Get Prime Y
912  yLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
913  pKey->pub_key = BN_bin2bn(pbData + i + 2, yLen, nullptr);
914  i += yLen + 2;
915 
916  pgpKeys.pDsa = pKey;
917 
918  continue;
919  }
920  else if ((algorithm == 16) || (algorithm == 20)) // Elgamal key
921  // (not supported
922  // by OpenSSL
923  {
924  int32_t pLen, gLen, yLen;
925  ELGAMAL* pKey = (ELGAMAL*)malloc(sizeof(ELGAMAL));
926  if (nullptr == pKey) {
927  otErr << __FUNCTION__ << ": Error: pKey is nullptr!";
928  OT_FAIL;
929  }
930 
931  // Get Prime P
932  pLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
933 
934  pKey->p = BN_bin2bn(pbData + i + 2, pLen, nullptr);
935 
936  i += pLen + 2;
937 
938  // Get Prime G
939  gLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
940  pKey->g = BN_bin2bn(pbData + i + 2, gLen, nullptr);
941  i += gLen + 2;
942 
943  // Get Prime Y
944  yLen = ((pbData[i] * 256 + pbData[i + 1] + 7) / 8);
945  pKey->pub_key = BN_bin2bn(pbData + i + 2, yLen, nullptr);
946  i += yLen + 2;
947 
948  pgpKeys.pElgamal = pKey;
949 
950  continue;
951  }
952  else {
953  i -= 6;
954  if (version == 2 || version == 3) i -= 2;
955  }
956  }
957 
958  i += packetLength;
959  }
960 
961  return pgpKeys;
962 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
#define OT_FAIL
Definition: Assert.hpp:139
OTLOG_IMPORT OTLogStream otErr
void opentxs::fwrite_string ( std::ostream &  ofs,
const char *  str 
)

Definition at line 519 of file OTString.cpp.

520 {
521  char* pchar;
522 
523  pchar = (char*)str;
524 
525  if (str)
526  while (*pchar) {
527  if (*pchar != '\r') ofs << *pchar;
528  pchar++;
529  }
530 }
bool opentxs::GetCurrentWorking ( OTString &  strCurrentWorkingPath)

Definition at line 1116 of file OTPaths.cpp.

1117 {
1118 
1119 #ifdef _WIN32
1120  // Windows Common
1121  TCHAR* szPath = nullptr;
1122 #ifdef _UNICODE
1123 // Windows Unicode
1124 #define GetCurrentDir _wgetcwd
1125 #else
1126 // Windows No-Unicode
1127 #define GetCurrentDir _getcwd
1128 #endif
1129 #else
1130 // Unix
1131 #define GetCurrentDir getcwd
1132  char* szPath = nullptr;
1133 #endif
1134 
1135  // All
1136  szPath = GetCurrentDir(nullptr, 0);
1137  OT_ASSERT(szPath != nullptr);
1138 
1139  OTString result;
1140 
1141 #ifdef _WIN32
1142 #ifdef _UNICODE
1143  // Windows Unicode
1144  strCurrentWorkingPath.Set(utf8util::UTF8FromUTF16(szPath));
1145 #endif
1146 #else
1147  // Unix
1148  strCurrentWorkingPath.Set(szPath);
1149 #endif
1150  // All
1151  return true;
1152 }
#define GetCurrentDir
#define OT_ASSERT(x)
Definition: Assert.hpp:150
EXPORT std::string UTF8FromUTF16(const std::wstring &utf16)
bool opentxs::GetExecutable ( OTString &  strExecutablePath)

Definition at line 1073 of file OTPaths.cpp.

1074 {
1075 #ifdef TARGET_OS_MAC
1076  char bufPath[PATH_MAX + 1] = "";
1077  uint32_t size = sizeof(bufPath);
1078  if (_NSGetExecutablePath(bufPath, &size) == 0)
1079  strExecutablePath.Set(bufPath);
1080  else
1081  return false;
1082 #elif defined __linux__
1083 
1084  char buff[4096] = "";
1085  ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff) - 1);
1086  if (len != -1) { // good
1087  buff[len] = '\0';
1088  strExecutablePath.Set(buff);
1089  }
1090  else { // bad
1091  strExecutablePath.Set("");
1092  return false;
1093  }
1094 
1095 #elif defined _WIN32
1096 
1097 #ifdef _UNICODE
1098  TCHAR bufPath[_MAX_PATH + 1] = L"";
1099 #else
1100  TCHAR bufPath[_MAX_PATH + 1] = "";
1101 #endif
1102 
1103  GetModuleFileName(nullptr, bufPath, sizeof(bufPath) / sizeof(TCHAR));
1104 
1105 #ifdef UNICODE
1106  strExecutablePath.Set(utf8util::UTF8FromUTF16(bufPath));
1107 #else
1108  strExecutablePath.Set(bufPath);
1109 #endif
1110 #else
1111  return false;
1112 #endif
1113  return true;
1114 }
EXPORT std::string UTF8FromUTF16(const std::wstring &utf16)
EXPORT OTPayment * opentxs::GetInstrument ( const OTPseudonym &  theNym,
const int32_t &  nIndex,
OTLedger &  ledger 
)

Definition at line 149 of file Helpers.cpp.

152 {
153  if ((0 > nIndex) || (nIndex >= ledger.GetTransactionCount())) {
154  otErr << __FUNCTION__
155  << ": nIndex is out of bounds (it's in the negative.)\n";
156  OT_FAIL;
157  }
158 
159  // if (nIndex >= GetTransactionCount())
160  // {
161  // otErr << "%s: out of bounds: %d\n", __FUNCTION__, nIndex);
162  // return nullptr; // out of bounds. I'm saving from an
163  // OT_ASSERT_MSG()
164  // happening here. (Maybe I shouldn't.)
165  // // ^^^ That's right you shouldn't! That's the client
166  // developer's problem, not yours.
167  // }
168 
169  OTTransaction* pTransaction = ledger.GetTransactionByIndex(nIndex);
170 
171  if (nullptr == pTransaction) {
172  otErr << __FUNCTION__
173  << ": good index but uncovered nullptr pointer: " << nIndex
174  << "\n";
175  return nullptr; // Weird.
176  }
177 
178  const int64_t lTransactionNum = pTransaction->GetTransactionNum();
179 
180  // Update: for transactions in ABBREVIATED form, the string is empty, since
181  // it has never actually
182  // been signed (in fact the whole point32_t with abbreviated transactions in
183  // a ledger is that they
184  // take up very little room, and have no signature of their own, but exist
185  // merely as XML tags on
186  // their parent ledger.)
187  //
188  // THEREFORE I must check to see if this transaction is abbreviated and if
189  // so, sign it in order to
190  // force the UpdateContents() call, so the programmatic user of this API
191  // will be able to load it up.
192  //
193  if (pTransaction->IsAbbreviated()) {
194  ledger.LoadBoxReceipt(static_cast<int64_t>(
195  lTransactionNum)); // I don't check return val here because I still
196  // want it to send the abbreviated form, if this
197  // fails.
198  pTransaction =
199  ledger.GetTransaction(static_cast<int64_t>(lTransactionNum));
200 
201  if (nullptr == pTransaction) {
202  otErr << __FUNCTION__
203  << ": good index but uncovered nullptr "
204  "pointer after trying to load full version of receipt "
205  "(from abbreviated) at index: " << nIndex << "\n";
206  return nullptr; // Weird. Clearly I need the full box receipt, if
207  // I'm
208  // to get the instrument out of it.
209  }
210  }
211 
212  /*
213  TO EXTRACT INSTRUMENT FROM PAYMENTS INBOX:
214  -- Iterate through the transactions in the payments inbox.
215  -- (They should all be "instrumentNotice" transactions.)
216  -- Each transaction contains (1) OTMessage in "in ref to" field, which in
217  turn contains an encrypted
218  OTPayment in the payload field, which contains the actual financial
219  instrument.
220  -- *** Therefore, this function, based purely on ledger index (as we
221  iterate):
222  1. extracts the OTMessage from the Transaction "in ref to" field (for the
223  transaction at that index),
224  2. then decrypts the payload on that message, producing an OTPayment object,
225  3. ...which contains the actual instrument.
226  */
227 
228  if ((OTTransaction::instrumentNotice != pTransaction->GetType()) &&
229  (OTTransaction::payDividend != pTransaction->GetType()) &&
230  (OTTransaction::notice != pTransaction->GetType())) {
231  otOut << __FUNCTION__
232  << ": Failure: Expected OTTransaction::instrumentNotice, "
233  "::payDividend or ::notice, "
234  "but found: OTTransaction::" << pTransaction->GetTypeString()
235  << "\n";
236  return nullptr;
237  }
238 
239  if ((OTTransaction::instrumentNotice ==
240  pTransaction->GetType()) || // It's encrypted.
241  (OTTransaction::payDividend == pTransaction->GetType())) {
242  OTString strMsg;
243  pTransaction->GetReferenceString(strMsg);
244 
245  if (!strMsg.Exists()) {
246  otOut << __FUNCTION__
247  << ": Failure: Expected OTTransaction::instrumentNotice to "
248  "contain an 'in reference to' string, but it was empty. "
249  "(Returning \"\".)\n";
250  return nullptr;
251  }
252 
253  std::unique_ptr<OTMessage> pMsg(new OTMessage);
254  if (nullptr == pMsg) {
255  otErr << __FUNCTION__ << ": Null: Assert while allocating memory "
256  "for an OTMessage!\n";
257  OT_FAIL;
258  }
259 
260  if (!pMsg->LoadContractFromString(strMsg)) {
261  otOut << __FUNCTION__
262  << ": Failed trying to load OTMessage from string:\n\n"
263  << strMsg << "\n\n";
264  return nullptr;
265  }
266 
267  // By this point, the original OTMessage has been loaded from string
268  // successfully.
269  // Now we need to decrypt the payment on that message (which contains
270  // the instrument
271  // itself that we need to return.) We decrypt it the same way as we do
272  // in
273  // OTAPI_Wrap::GetNym_MailContentsByIndex():
274  //
275 
276  // SENDER: pMsg->m_strNymID
277  // RECIPIENT: pMsg->m_strNymID2
278  // INSTRUMENT: pMsg->m_ascPayload (in an OTEnvelope)
279  //
280  OTEnvelope theEnvelope;
281  OTString strEnvelopeContents;
282 
283  // Decrypt the Envelope.
284  if (!theEnvelope.SetAsciiArmoredData(pMsg->m_ascPayload))
285  otOut << __FUNCTION__
286  << ": Failed trying to set ASCII-armored data for envelope:\n"
287  << strMsg << "\n\n";
288  else if (!theEnvelope.Open(theNym, strEnvelopeContents))
289  otOut << __FUNCTION__
290  << ": Failed trying to decrypt the financial instrument "
291  "that was supposedly attached as a payload to this "
292  "payment message:\n" << strMsg << "\n\n";
293  else if (!strEnvelopeContents.Exists())
294  otOut << __FUNCTION__
295  << ": Failed: after decryption, cleartext is empty. From:\n"
296  << strMsg << "\n\n";
297  else {
298  std::unique_ptr<OTPayment> pPayment(
299  new OTPayment(strEnvelopeContents)); // strEnvelopeContents
300  // contains a PURSE or
301  // CHEQUE (etc) and not
302  // specifically a PAYMENT.
303  OT_ASSERT(nullptr != pPayment);
304 
305  if (!pPayment->IsValid())
306  otOut << __FUNCTION__
307  << ": Failed: after decryption, payment is invalid. "
308  "Contents:\n\n" << strEnvelopeContents << "\n\n";
309  else // success.
310  {
311  return pPayment.release(); // Caller responsible to delete.
312  }
313  }
314  }
315  else
316  otErr << __FUNCTION__ << ": This must be a notice (vs an "
317  "instrumentNotice or payDividend). "
318  "!!! Not yet supported !!!\n";
319 
320  return nullptr;
321 }
OTLOG_IMPORT OTLogStream otOut
#define OT_ASSERT(x)
Definition: Assert.hpp:150
#define OT_FAIL
Definition: Assert.hpp:139
OTLOG_IMPORT OTLogStream otErr
OTItem::itemType opentxs::GetItemTypeFromString ( const OTString &  strType)

Definition at line 1639 of file OTItem.cpp.

1640 {
1641  OTItem::itemType theType = OTItem::error_state;
1642 
1643  if (strType.Compare("transfer"))
1644  theType = OTItem::transfer;
1645  else if (strType.Compare("atTransfer"))
1646  theType = OTItem::atTransfer;
1647 
1648  else if (strType.Compare("acceptTransaction"))
1649  theType = OTItem::acceptTransaction;
1650  else if (strType.Compare("atAcceptTransaction"))
1651  theType = OTItem::atAcceptTransaction;
1652 
1653  else if (strType.Compare("acceptMessage"))
1654  theType = OTItem::acceptMessage;
1655  else if (strType.Compare("atAcceptMessage"))
1656  theType = OTItem::atAcceptMessage;
1657 
1658  else if (strType.Compare("acceptNotice"))
1659  theType = OTItem::acceptNotice;
1660  else if (strType.Compare("atAcceptNotice"))
1661  theType = OTItem::atAcceptNotice;
1662 
1663  else if (strType.Compare("acceptPending"))
1664  theType = OTItem::acceptPending;
1665  else if (strType.Compare("atAcceptPending"))
1666  theType = OTItem::atAcceptPending;
1667  else if (strType.Compare("rejectPending"))
1668  theType = OTItem::rejectPending;
1669  else if (strType.Compare("atRejectPending"))
1670  theType = OTItem::atRejectPending;
1671 
1672  else if (strType.Compare("acceptCronReceipt"))
1673  theType = OTItem::acceptCronReceipt;
1674  else if (strType.Compare("atAcceptCronReceipt"))
1675  theType = OTItem::atAcceptCronReceipt;
1676  else if (strType.Compare("disputeCronReceipt"))
1677  theType = OTItem::disputeCronReceipt;
1678  else if (strType.Compare("atDisputeCronReceipt"))
1679  theType = OTItem::atDisputeCronReceipt;
1680  else if (strType.Compare("acceptItemReceipt"))
1681  theType = OTItem::acceptItemReceipt;
1682  else if (strType.Compare("atAcceptItemReceipt"))
1683  theType = OTItem::atAcceptItemReceipt;
1684  else if (strType.Compare("disputeItemReceipt"))
1685  theType = OTItem::disputeItemReceipt;
1686  else if (strType.Compare("atDisputeItemReceipt"))
1687  theType = OTItem::atDisputeItemReceipt;
1688 
1689  else if (strType.Compare("acceptFinalReceipt"))
1690  theType = OTItem::acceptFinalReceipt;
1691  else if (strType.Compare("atAcceptFinalReceipt"))
1692  theType = OTItem::atAcceptFinalReceipt;
1693  else if (strType.Compare("disputeFinalReceipt"))
1694  theType = OTItem::disputeFinalReceipt;
1695  else if (strType.Compare("atDisputeFinalReceipt"))
1696  theType = OTItem::atDisputeFinalReceipt;
1697 
1698  else if (strType.Compare("acceptBasketReceipt"))
1699  theType = OTItem::acceptBasketReceipt;
1700  else if (strType.Compare("atAcceptBasketReceipt"))
1701  theType = OTItem::atAcceptBasketReceipt;
1702  else if (strType.Compare("disputeBasketReceipt"))
1703  theType = OTItem::disputeBasketReceipt;
1704  else if (strType.Compare("atDisputeBasketReceipt"))
1705  theType = OTItem::atDisputeBasketReceipt;
1706 
1707  else if (strType.Compare("serverfee"))
1708  theType = OTItem::serverfee;
1709  else if (strType.Compare("atServerfee"))
1710  theType = OTItem::atServerfee;
1711  else if (strType.Compare("issuerfee"))
1712  theType = OTItem::issuerfee;
1713  else if (strType.Compare("atIssuerfee"))
1714  theType = OTItem::atIssuerfee;
1715 
1716  else if (strType.Compare("balanceStatement"))
1717  theType = OTItem::balanceStatement;
1718  else if (strType.Compare("atBalanceStatement"))
1719  theType = OTItem::atBalanceStatement;
1720  else if (strType.Compare("transactionStatement"))
1721  theType = OTItem::transactionStatement;
1722  else if (strType.Compare("atTransactionStatement"))
1723  theType = OTItem::atTransactionStatement;
1724 
1725  else if (strType.Compare("withdrawal"))
1726  theType = OTItem::withdrawal;
1727  else if (strType.Compare("atWithdrawal"))
1728  theType = OTItem::atWithdrawal;
1729  else if (strType.Compare("deposit"))
1730  theType = OTItem::deposit;
1731  else if (strType.Compare("atDeposit"))
1732  theType = OTItem::atDeposit;
1733 
1734  else if (strType.Compare("withdrawVoucher"))
1735  theType = OTItem::withdrawVoucher;
1736  else if (strType.Compare("atWithdrawVoucher"))
1737  theType = OTItem::atWithdrawVoucher;
1738  else if (strType.Compare("depositCheque"))
1739  theType = OTItem::depositCheque;
1740  else if (strType.Compare("atDepositCheque"))
1741  theType = OTItem::atDepositCheque;
1742 
1743  else if (strType.Compare("payDividend"))
1744  theType = OTItem::payDividend;
1745  else if (strType.Compare("atPayDividend"))
1746  theType = OTItem::atPayDividend;
1747 
1748  else if (strType.Compare("marketOffer"))
1749  theType = OTItem::marketOffer;
1750  else if (strType.Compare("atMarketOffer"))
1751  theType = OTItem::atMarketOffer;
1752 
1753  else if (strType.Compare("paymentPlan"))
1754  theType = OTItem::paymentPlan;
1755  else if (strType.Compare("atPaymentPlan"))
1756  theType = OTItem::atPaymentPlan;
1757 
1758  else if (strType.Compare("smartContract"))
1759  theType = OTItem::smartContract;
1760  else if (strType.Compare("atSmartContract"))
1761  theType = OTItem::atSmartContract;
1762 
1763  else if (strType.Compare("cancelCronItem"))
1764  theType = OTItem::cancelCronItem;
1765  else if (strType.Compare("atCancelCronItem"))
1766  theType = OTItem::atCancelCronItem;
1767 
1768  else if (strType.Compare("exchangeBasket"))
1769  theType = OTItem::exchangeBasket;
1770  else if (strType.Compare("atExchangeBasket"))
1771  theType = OTItem::atExchangeBasket;
1772 
1773  else if (strType.Compare("chequeReceipt"))
1774  theType = OTItem::chequeReceipt;
1775  else if (strType.Compare("voucherReceipt"))
1776  theType = OTItem::voucherReceipt;
1777  else if (strType.Compare("marketReceipt"))
1778  theType = OTItem::marketReceipt;
1779  else if (strType.Compare("paymentReceipt"))
1780  theType = OTItem::paymentReceipt;
1781  else if (strType.Compare("transferReceipt"))
1782  theType = OTItem::transferReceipt;
1783 
1784  else if (strType.Compare("finalReceipt"))
1785  theType = OTItem::finalReceipt;
1786  else if (strType.Compare("basketReceipt"))
1787  theType = OTItem::basketReceipt;
1788 
1789  else if (strType.Compare("replyNotice"))
1790  theType = OTItem::replyNotice;
1791  else if (strType.Compare("successNotice"))
1792  theType = OTItem::successNotice;
1793  else if (strType.Compare("notice"))
1794  theType = OTItem::notice;
1795 
1796  else
1797  theType = OTItem::error_state;
1798 
1799  return theType;
1800 }
EXPORT int32_t opentxs::GetOutpaymentsIndexByTransNum ( const OTPseudonym &  nym,
int64_t  lTransNum 
)

Definition at line 323 of file Helpers.cpp.

324 {
325  int32_t lOutpaymentsCount = nym.GetOutpaymentsCount();
326 
327  for (int32_t lOutpaymentsIndex = 0; lOutpaymentsIndex < lOutpaymentsCount;
328  ++lOutpaymentsIndex) {
329  OTMessage* pOutpaymentMsg =
330  nym.GetOutpaymentsByIndex(lOutpaymentsIndex);
331  if (nullptr != pOutpaymentMsg) {
332  OTString strPayment;
333 
334  // There isn't any encrypted envelope this time, since it's my
335  // outPayments box.
336  //
337  if (pOutpaymentMsg->m_ascPayload.Exists() &&
338  pOutpaymentMsg->m_ascPayload.GetString(strPayment) &&
339  strPayment.Exists()) {
340  OTPayment thePayment(strPayment);
341 
342  // Let's see if it's the cheque we're looking for...
343  //
344  if (thePayment.IsValid()) {
345  if (thePayment.SetTempValues()) {
346  if (thePayment.HasTransactionNum(lTransNum)) {
347  return static_cast<int32_t>(lOutpaymentsIndex);
348  }
349  }
350  }
351  }
352  }
353  }
354 
355  return -1;
356 }
const char * opentxs::GetTransactionTypeString ( int  transactionNumber)

Definition at line 212 of file Helpers.cpp.

213 {
214  return TypeStrings[transactionNumber];
215 }
EXPORT OT_UTILITY_OT int32_t opentxs::InterpretTransactionMsgReply ( const string &  SERVER_ID,
const string &  USER_ID,
const string &  ACCOUNT_ID,
const string &  strAttempt,
const string &  strResponse 
)

Definition at line 300 of file ot_utility_ot.cpp.

305 {
306  int32_t nMessageSuccess = VerifyMessageSuccess(strResponse);
307  if (-1 == nMessageSuccess) {
308  otOut << "Message error: " << strAttempt << ".\n";
309  return -1;
310  }
311  if (0 == nMessageSuccess) {
312  otOut << "Server reply (" << strAttempt << "): Message failure.\n";
313 
314  return 0;
315  }
316 
317  int32_t nBalanceSuccess = VerifyMsgBalanceAgrmntSuccess(
318  SERVER_ID, USER_ID, ACCOUNT_ID, strResponse);
319  if (-1 == nBalanceSuccess) {
320  otOut << "Balance agreement error: " << strAttempt << ".\n";
321  return -1;
322  }
323  if (0 == nBalanceSuccess) {
324  otOut << "Server reply (" << strAttempt
325  << "): Balance agreement failure.\n";
326  return 0;
327  }
328 
329  int32_t nTransSuccess =
330  VerifyMsgTrnxSuccess(SERVER_ID, USER_ID, ACCOUNT_ID, strResponse);
331  if (-1 == nTransSuccess) {
332  otOut << "Transaction error: " << strAttempt << ".\n";
333  return -1;
334  }
335  if (0 == nTransSuccess) {
336  otOut << "Server reply (" << strAttempt << "): Transaction failure.\n";
337  return 0;
338  }
339 
340  return 1;
341 }
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 int32_t VerifyMsgTrnxSuccess(const string &SERVER_ID, const string &USER_ID, const string &ACCOUNT_ID, const string &strMessage)
bool opentxs::is_ot_namechar_invalid ( char  c)

Definition at line 249 of file OTScriptable.cpp.

250 {
251  return !(isalnum(c) || (c == '_'));
252 }
OT_BOOL opentxs::IsChecksumValid ( OT_BYTE *  buffer,
uint32_t  size 
)

Definition at line 195 of file OTDataCheck.cpp.

196 {
197  uint32_t i;
198  OT_BYTE total = 0;
199 
200  OT_ASSERT(nullptr != buffer);
201 
202  // otErr << Validating checksum. Size: %d\n", size);
203 
204  for (i = 0; i < size; i++) {
205  total += buffer[i];
206 
207  // otErr << "%d ", buffer[i]);
208  }
209  if (total == 255) {
210  // otErr << "VALID\n";
211  return true;
212  }
213  else {
214  // otErr << "INVALID: %d\n", total);
215  return false;
216  }
217 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
uint8_t OT_BYTE
bool opentxs::isPowerOfTen ( const int64_t &  x)

Definition at line 149 of file OTOffer.cpp.

150 {
151  if (1 == x) return true;
152 
153  const int64_t lBase = 10;
154  int64_t lIt = lBase;
155 
156  for (int32_t i = 1; i < 23; i++) {
157  if (x == lIt) return true;
158  lIt *= lBase;
159  }
160 
161  return false;
162 }
void opentxs::load_str_trans_add_to_ledger ( const OTIdentifier &  the_nym_id,
const OTString &  str_trans,
OTString  str_box_type,
const int64_t &  lTransNum,
OTPseudonym &  the_nym,
OTLedger &  ledger 
)

Definition at line 1946 of file OTClient.cpp.

1951 {
1952  if (nullptr == ledger.GetTransaction(lTransNum)) // (Only add it if it's not
1953  // already there.)
1954  {
1955  OTTransactionType* pTransType =
1956  OTTransactionType::TransactionFactory(str_trans);
1957 
1958  if (nullptr == pTransType)
1959  otErr << __FUNCTION__ << ": Error instantiating transaction type "
1960  "based on str_trans:\n" << str_trans
1961  << "\n";
1962  else {
1963  OTTransaction* pCopy = dynamic_cast<OTTransaction*>(pTransType);
1964 
1965  if (nullptr ==
1966  pCopy) // it's a transaction type but not a transaction.
1967  {
1968  const OTString strUserID(the_nym_id), strAcctID(the_nym_id);
1969  otOut
1970  << __FUNCTION__
1971  << ": it's a transaction type but not a transaction: (for "
1972  << str_box_type << "):\n\n" << str_trans << "\n\n";
1973  delete pTransType;
1974  pTransType = nullptr;
1975  }
1976  else // The copy transaction is now loaded from the string. Add it
1977  // to the ledger...
1978  {
1979  if (!ledger.AddTransaction(*pCopy)) // if unable to add that
1980  // transaction, once loaded,
1981  // signed, and saved, to the
1982  // paymentInbox or recordBox
1983  // ledger...
1984  {
1985  OTString strUserID(the_nym_id), strAcctID(the_nym_id);
1986  otOut << __FUNCTION__
1987  << ": Unable to add the transaction to the "
1988  << str_box_type
1989  << " with user/acct IDs: " << strUserID << " / "
1990  << strAcctID << ", and loading from string:\n\n"
1991  << str_trans << "\n\n";
1992  delete pCopy;
1993  pCopy = nullptr;
1994  }
1995  else // We were able to add it, so now let's save the
1996  // paymentInbox (or recordBox.)
1997  {
1998  ledger.ReleaseSignatures();
1999  ledger.SignContract(the_nym);
2000  ledger.SaveContract();
2001 
2002  if (OTLedger::paymentInbox == ledger.GetType())
2003  ledger.SavePaymentInbox();
2004  else if (OTLedger::recordBox == ledger.GetType())
2005  ledger.SaveRecordBox();
2006  else if (OTLedger::expiredBox == ledger.GetType())
2007  ledger.SaveExpiredBox();
2008 
2009  if (!pCopy->SaveBoxReceipt(ledger)) // <===================
2010  otErr
2011  << __FUNCTION__ << ": " << str_box_type
2012  << " Failed trying to SaveBoxReceipt. Contents:\n\n"
2013  << str_trans << "\n\n";
2014  }
2015  }
2016  } // else (pCopy not null.)
2017  } // if this transaction wasn't already in the paymentInbox / recordBox
2018  // (whichever was passed in)...
2019  // else it WAS already there, so do nothing. (No need to add it twice.)
2020 } // void load_str_trans_add_to_ledger
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otErr
int32_t opentxs::LoadAbbreviatedRecord ( irr::io::IrrXMLReader *&  xml,
int64_t &  lNumberOfOrigin,
int64_t &  lTransactionNum,
int64_t &  lInRefTo,
int64_t &  lInRefDisplay,
time64_t the_DATE_SIGNED,
int &  theType,
OTString &  strHash,
int64_t &  lAdjustment,
int64_t &  lDisplayValue,
int64_t &  lClosingNum,
int64_t &  lRequestNum,
bool &  bReplyTransSuccess,
OTNumList *  pNumList = nullptr 
)

Definition at line 218 of file Helpers.cpp.

226 {
227 
228  const OTString strOrigin = xml->getAttributeValue("numberOfOrigin");
229  const OTString strTransNum = xml->getAttributeValue("transactionNum");
230  const OTString strInRefTo = xml->getAttributeValue("inReferenceTo");
231  const OTString strInRefDisplay = xml->getAttributeValue("inRefDisplay");
232  const OTString strDateSigned = xml->getAttributeValue("dateSigned");
233 
234  if (!strTransNum.Exists() || !strInRefTo.Exists() ||
235  !strInRefDisplay.Exists() || !strDateSigned.Exists()) {
236  otOut << "OTTransaction::LoadAbbreviatedRecord: Failure: missing "
237  "strTransNum (" << strTransNum << ") or strInRefTo ("
238  << strInRefTo << ") or strInRefDisplay (" << strInRefDisplay
239  << ") or strDateSigned(" << strDateSigned
240  << ") while loading abbreviated receipt. \n";
241  return (-1);
242  }
243  lTransactionNum = atol(strTransNum.Get());
244  lInRefTo = atol(strInRefTo.Get());
245  lInRefDisplay = atol(strInRefDisplay.Get());
246 
247  if (strOrigin.Exists()) lNumberOfOrigin = atol(strOrigin.Get());
248 
249  // DATE SIGNED
250  the_DATE_SIGNED = OTTimeGetTimeFromSeconds(
251  strDateSigned.Get()); // (We already verified it Exists() just above.)
252 
253  // Transaction TYPE for the abbreviated record...
254  theType = OTTransaction::error_state; // default
255  const OTString strAbbrevType =
256  xml->getAttributeValue("type"); // the type of inbox receipt, or outbox
257  // receipt, or nymbox receipt.
258  // (Transaction type.)
259  if (strAbbrevType.Exists()) {
260  theType = OTTransaction::GetTypeFromString(strAbbrevType);
261 
262  if (OTTransaction::error_state == theType) {
263  otErr << "OTTransaction::LoadAbbreviatedRecord: Failure: "
264  "OTTransaction::error_state was the found type (based on "
265  "string " << strAbbrevType
266  << "), when loading abbreviated receipt for trans num: "
267  << lTransactionNum << " (In Reference To: " << lInRefTo
268  << ") \n";
269  return (-1);
270  }
271  }
272  else {
273  otOut << "OTTransaction::LoadAbbreviatedRecord: Failure: unknown "
274  "transaction type (" << strAbbrevType
275  << ") when "
276  "loading abbreviated receipt for trans num: "
277  << lTransactionNum << " (In Reference To: " << lInRefTo << ") \n";
278  return (-1);
279  }
280 
281  // RECEIPT HASH
282  //
283  strHash = xml->getAttributeValue("receiptHash");
284  if (!strHash.Exists()) {
285  otOut << "OTTransaction::LoadAbbreviatedRecord: Failure: Expected "
286  "receiptHash while loading "
287  "abbreviated receipt for trans num: " << lTransactionNum
288  << " (In Reference To: " << lInRefTo << ")\n";
289  return (-1);
290  }
291 
292  lAdjustment = 0;
293  lDisplayValue = 0;
294  lClosingNum = 0;
295 
296  const OTString strAbbrevAdjustment = xml->getAttributeValue("adjustment");
297  if (strAbbrevAdjustment.Exists())
298  lAdjustment = atol(strAbbrevAdjustment.Get());
299  // -------------------------------------
300  const OTString strAbbrevDisplayValue =
301  xml->getAttributeValue("displayValue");
302  if (strAbbrevDisplayValue.Exists())
303  lDisplayValue = atol(strAbbrevDisplayValue.Get());
304 
305  if (OTTransaction::replyNotice == theType) {
306  const OTString strRequestNum = xml->getAttributeValue("requestNumber");
307 
308  if (!strRequestNum.Exists()) {
309  otOut << "OTTransaction::LoadAbbreviatedRecord: Failed loading "
310  "abbreviated receipt: "
311  "expected requestNumber on replyNotice trans num: "
312  << lTransactionNum << " (In Reference To: " << lInRefTo
313  << ")\n";
314  return (-1);
315  }
316  lRequestNum = atol(strRequestNum.Get());
317 
318  const OTString strTransSuccess = xml->getAttributeValue("transSuccess");
319 
320  bReplyTransSuccess = strTransSuccess.Compare("true");
321  } // if replyNotice (expecting request Number)
322 
323  // If the transaction is a certain type, then it will also have a CLOSING
324  // number.
325  // (Grab that too.)
326  //
327  if ((OTTransaction::finalReceipt == theType) ||
328  (OTTransaction::basketReceipt == theType)) {
329  const OTString strAbbrevClosingNum =
330  xml->getAttributeValue("closingNum");
331 
332  if (!strAbbrevClosingNum.Exists()) {
333  otOut << "OTTransaction::LoadAbbreviatedRecord: Failed loading "
334  "abbreviated receipt: "
335  "expected closingNum on trans num: " << lTransactionNum
336  << " (In Reference To: " << lInRefTo << ")\n";
337  return (-1);
338  }
339  lClosingNum = atol(strAbbrevClosingNum.Get());
340  } // if finalReceipt or basketReceipt (expecting closing num)
341 
342  // These types carry their own internal list of numbers.
343  //
344  if ((nullptr != pNumList) && ((OTTransaction::blank == theType) ||
345  (OTTransaction::successNotice == theType))) {
346  const OTString strNumbers =
347  xml->getAttributeValue("totalListOfNumbers");
348  pNumList->Release();
349 
350  if (strNumbers.Exists()) pNumList->Add(strNumbers);
351  } // if blank or successNotice (expecting totalListOfNumbers.. no more
352  // multiple blanks in the same ledger! They all go in a single
353  // transaction.)
354 
355  return 1;
356 }
OTLOG_IMPORT OTLogStream otOut
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
Definition: Common.hpp:215
OTLOG_IMPORT OTLogStream otErr
OTTransaction * opentxs::LoadBoxReceipt ( OTTransaction &  theAbbrev,
OTLedger &  theLedger 
)

Definition at line 399 of file Helpers.cpp.

400 {
401  const int64_t lLedgerType = static_cast<int64_t>(theLedger.GetType());
402  return LoadBoxReceipt(theAbbrev, lLedgerType);
403 }
OTTransaction * LoadBoxReceipt(OTTransaction &theAbbrev, OTLedger &theLedger)
Definition: Helpers.cpp:399
OTTransaction * opentxs::LoadBoxReceipt ( OTTransaction &  theAbbrev,
int64_t  lLedgerType 
)

Definition at line 405 of file Helpers.cpp.

406 {
407  // See if the appropriate file exists, and load it up from
408  // local storage, into a string.
409  // Then, try to load the transaction from that string and see if successful.
410  // If it verifies, then return it. Otherwise return nullptr.
411 
412  // Can only load abbreviated transactions (so they'll become their full
413  // form.)
414  //
415  if (!theAbbrev.IsAbbreviated()) {
416  otOut << __FUNCTION__ << ": Unable to load box receipt "
417  << theAbbrev.GetTransactionNum()
418  << ": "
419  "(Because argument 'theAbbrev' wasn't abbreviated.)\n";
420  return nullptr;
421  }
422 
423  // Next, see if the appropriate file exists, and load it up from
424  // local storage, into a string.
425 
426  OTString strFolder1name, strFolder2name, strFolder3name, strFilename;
427 
429  lLedgerType, theAbbrev,
430  __FUNCTION__, // "OTTransaction::LoadBoxReceipt",
431  strFolder1name, strFolder2name, strFolder3name, strFilename))
432  return nullptr; // This already logs -- no need to log twice, here.
433 
434  // See if the box receipt exists before trying to load it...
435  //
436  if (!OTDB::Exists(strFolder1name.Get(), strFolder2name.Get(),
437  strFolder3name.Get(), strFilename.Get())) {
438  otWarn << __FUNCTION__
439  << ": Box receipt does not exist: " << strFolder1name
440  << OTLog::PathSeparator() << strFolder2name
441  << OTLog::PathSeparator() << strFolder3name
442  << OTLog::PathSeparator() << strFilename << "\n";
443  return nullptr;
444  }
445 
446  // Try to load the box receipt from local storage.
447  //
448  std::string strFileContents(OTDB::QueryPlainString(
449  strFolder1name.Get(), // <=== LOADING FROM DATA STORE.
450  strFolder2name.Get(), strFolder3name.Get(), strFilename.Get()));
451  if (strFileContents.length() < 2) {
452  otErr << __FUNCTION__ << ": Error reading file: " << strFolder1name
453  << OTLog::PathSeparator() << strFolder2name
454  << OTLog::PathSeparator() << strFolder3name
455  << OTLog::PathSeparator() << strFilename << "\n";
456  return nullptr;
457  }
458 
459  OTString strRawFile(strFileContents.c_str());
460 
461  if (!strRawFile.Exists()) {
462  otErr << __FUNCTION__ << ": Error reading file (resulting output "
463  "string is empty): " << strFolder1name
464  << OTLog::PathSeparator() << strFolder2name
465  << OTLog::PathSeparator() << strFolder3name
466  << OTLog::PathSeparator() << strFilename << "\n";
467  return nullptr;
468  }
469 
470  // Finally, try to load the transaction from that string and see if
471  // successful.
472  //
473  OTTransactionType* pTransType =
474  OTTransactionType::TransactionFactory(strRawFile);
475 
476  if (nullptr == pTransType) {
477  otErr << __FUNCTION__ << ": Error instantiating transaction "
478  "type based on strRawFile: " << strFolder1name
479  << OTLog::PathSeparator() << strFolder2name
480  << OTLog::PathSeparator() << strFolder3name
481  << OTLog::PathSeparator() << strFilename << "\n";
482  return nullptr;
483  }
484 
485  OTTransaction* pBoxReceipt = dynamic_cast<OTTransaction*>(pTransType);
486 
487  if (nullptr == pBoxReceipt) {
488  otErr << __FUNCTION__
489  << ": Error dynamic_cast from transaction "
490  "type to transaction, based on strRawFile: " << strFolder1name
491  << OTLog::PathSeparator() << strFolder2name
492  << OTLog::PathSeparator() << strFolder3name
493  << OTLog::PathSeparator() << strFilename << "\n";
494  delete pTransType;
495  pTransType = nullptr; // cleanup!
496  return nullptr;
497  }
498 
499  // BELOW THIS POINT, pBoxReceipt exists, and is an OTTransaction pointer,
500  // and is loaded,
501  // and basically is ready to be compared to theAbbrev, which is its
502  // abbreviated version.
503  // It MUST either be returned or deleted.
504 
505  bool bSuccess = theAbbrev.VerifyBoxReceipt(*pBoxReceipt);
506 
507  if (!bSuccess) {
508  otErr << __FUNCTION__ << ": Failed verifying Box Receipt:\n"
509  << strFolder1name << OTLog::PathSeparator() << strFolder2name
510  << OTLog::PathSeparator() << strFolder3name
511  << OTLog::PathSeparator() << strFilename << "\n";
512 
513  delete pBoxReceipt;
514  pBoxReceipt = nullptr;
515  return nullptr;
516  }
517  else
518  otInfo << __FUNCTION__ << ": Successfully loaded Box Receipt in:\n"
519  << strFolder1name << OTLog::PathSeparator() << strFolder2name
520  << OTLog::PathSeparator() << strFolder3name
521  << OTLog::PathSeparator() << strFilename << "\n";
522 
523  // Todo: security analysis. By this point we've verified the hash of the
524  // transaction against the stored
525  // hash inside the abbreviated version. (VerifyBoxReceipt) We've also
526  // verified a few other values like transaction
527  // number, and the "in ref to" display number. We're then assuming based on
528  // those, that the adjustment and display
529  // amount are correct. (The hash is actually a zero knowledge proof of this
530  // already.) This is good for speedier
531  // optimization but may be worth revisiting in case any security holes.
532  // UPDATE: We'll save this for optimization needs in the future.
533  // pBoxReceipt->SetAbbrevAdjustment( theAbbrev.GetAbbrevAdjustment()
534  // );
535  // pBoxReceipt->SetAbbrevDisplayAmount(
536  // theAbbrev.GetAbbrevDisplayAmount() );
537 
538  return pBoxReceipt;
539 }
OTLOG_IMPORT OTLogStream otOut
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:728
OTLOG_IMPORT OTLogStream otInfo
bool SetupBoxReceiptFilename(int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
Definition: Helpers.cpp:591
OTLOG_IMPORT OTLogStream otWarn
OTLOG_IMPORT OTLogStream otErr
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
bool opentxs::NewScriptExists ( const OTString &  strScriptFilename,
bool  bIsHeader,
OTString &  out_ScriptFilepath 
)

Definition at line 2481 of file OT_ME.cpp.

2483 {
2484  //
2485  // "so $(prefix)/lib/opentxs for the headers,
2486  // and others:
2487  // 1st priorty: $(data_dir)/scripts
2488  // 2nd priorty: $(prefix)/lib/opentxs/scripts
2489  //
2490  int64_t lFileLength(0);
2491 
2492  OT_ASSERT_MSG(strScriptFilename.Exists(),
2493  "NewScriptHeaderExists: Error! Filename not Supplied!");
2494  if (3 > strScriptFilename.GetLength()) {
2495  otErr << "NewScriptHeaderExists: Filename: " << strScriptFilename
2496  << " is too short!\n";
2497  OT_FAIL;
2498  }
2499 
2500  OTString strScriptsFolder(OTPaths::ScriptsFolder()); // /usr/local / lib
2501  // / opentxs OR
2502  // (android) res/raw
2503  {
2504  bool bGetFolderSuccess =
2505  strScriptsFolder.Exists() && 3 < strScriptsFolder.GetLength();
2506  OT_ASSERT_MSG(bGetFolderSuccess,
2507  "NewScriptHeaderExists: Unalbe to Get Scripts Path");
2508  }
2509 
2510  if (bIsHeader) {
2511 
2512  {
2513  bool bBuildFullPathSuccess = OTPaths::AppendFile(
2514  out_ScriptFilepath, strScriptsFolder, strScriptFilename);
2515  OT_ASSERT_MSG(
2516  bBuildFullPathSuccess,
2517  "NewScriptHeaderExists: Unalbe to Build Full Script Path");
2518  }
2519 
2520  return OTPaths::FileExists(out_ScriptFilepath, lFileLength);
2521  }
2522  else {
2523  OTString strDataFolder(OTDataFolder::Get()), strDataScriptsFolder;
2524 
2525  {
2526  bool bGetFolderSuccess =
2527  strDataFolder.Exists() && 3 < strDataFolder.GetLength();
2528  OT_ASSERT_MSG(bGetFolderSuccess,
2529  "NewScriptHeaderExists: Unalbe to Get Scripts Path");
2530  }
2531 
2532  {
2533  bool bBuildScriptPath = OTPaths::RelativeToCanonical(
2534  strDataScriptsFolder, strDataFolder, "scripts");
2535  OT_ASSERT_MSG(
2536  bBuildScriptPath,
2537  "NewScriptHeaderExists: Unalbe to Build Full Script Path");
2538  }
2539 
2540  {
2541  bool bBuildFullPathSuccess = OTPaths::RelativeToCanonical(
2542  out_ScriptFilepath, strDataScriptsFolder, strScriptFilename);
2543  OT_ASSERT_MSG(
2544  bBuildFullPathSuccess,
2545  "NewScriptHeaderExists: Unalbe to Build Full Script Path");
2546  }
2547 
2548  if (OTPaths::FileExists(out_ScriptFilepath, lFileLength))
2549  return true;
2550  else {
2551  OTString strGlobalScriptsFolder;
2552 
2553  {
2554  bool bBuildScriptPath = OTPaths::RelativeToCanonical(
2555  strGlobalScriptsFolder, strScriptsFolder, "scripts");
2556  OT_ASSERT_MSG(
2557  bBuildScriptPath,
2558  "NewScriptHeaderExists: Unalbe to Build Full Script Path");
2559  }
2560  {
2561  bool bBuildFullPathSuccess = OTPaths::RelativeToCanonical(
2562  out_ScriptFilepath, strGlobalScriptsFolder,
2563  strScriptFilename);
2564  OT_ASSERT_MSG(
2565  bBuildFullPathSuccess,
2566  "NewScriptHeaderExists: Unalbe to Build Full Script Path");
2567  }
2568 
2569  return OTPaths::FileExists(out_ScriptFilepath, lFileLength);
2570  }
2571  }
2572 }
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
#define OT_FAIL
Definition: Assert.hpp:139
OTLOG_IMPORT OTLogStream otErr
std::ostream& opentxs::operator<< ( std::ostream &  os,
const OTIdentifier &  obj 
)

Definition at line 145 of file OTIdentifier.cpp.

146 {
147  OTString str;
148  obj.GetString(str);
149  os << str;
150  return os;
151 }
std::ostream& opentxs::operator<< ( std::ostream &  os,
const OTString &  obj 
)

Definition at line 150 of file OTString.cpp.

151 {
152  os << obj.Get();
153  return os;
154 }
bool opentxs::OT_API_Set_AddrBookCallback ( OTLookupCaller &  theCaller)

Definition at line 190 of file OTRecordList.cpp.

194 {
195  if (!theCaller.isCallbackSet()) {
196  otErr << __FUNCTION__
197  << ": ERROR:\nOTLookupCaller::setCallback() "
198  "MUST be called first, with an OTNameLookup-extended "
199  "class passed to it,\n"
200  "before then invoking this function (and passing that "
201  "OTLookupCaller as a parameter "
202  "into this function.)\n";
203  return false;
204  }
205 
206  otWarn << __FUNCTION__
207  << ": FYI, calling "
208  "OTRecordList::setAddrBookCaller(theCaller) now... "
209  "(which is where "
210  "OT internally sets its pointer to the Java caller "
211  "object, which must have been passed in as a "
212  "parameter to this function.\n";
213 
214  const bool bSuccess = OTRecordList::setAddrBookCaller(theCaller);
215 
216  otWarn << __FUNCTION__
217  << ": RESULT of call to OTRecordList::setAddrBookCaller: "
218  << (bSuccess ? "SUCCESS" : "FAILURE") << "";
219 
220  return bSuccess;
221 }
OTLOG_IMPORT OTLogStream otWarn
OTLOG_IMPORT OTLogStream otErr
bool opentxs::OT_API_Set_PasswordCallback ( OTCaller &  theCaller)

Definition at line 335 of file OTAsymmetricKey.cpp.

338 {
339  if (!theCaller.isCallbackSet()) {
340  otErr << __FUNCTION__ << ": ERROR:\nOTCaller::setCallback() "
341  "MUST be called first, with an "
342  "OTCallback-extended class passed to it,\n"
343  "before then invoking this function (and "
344  "passing that OTCaller as a parameter "
345  "into this function.)\n";
346  return false;
347  }
348 
349  otWarn << __FUNCTION__
350  << ": FYI, calling OTAsymmetricKey::SetPasswordCaller(theCaller) "
351  "now... (which is where "
352  "OT internally sets its pointer to the Java caller object, which "
353  "must have been passed in as a "
354  "parameter to this function. "
355  "This is also where OT either sets its internal 'C'-based "
356  "password callback to the souped_up "
357  "version which uses that Java caller object, "
358  "OR where OT sets its internal callback to nullptr--which causes "
359  "OpenSSL to ask for the passphrase "
360  "on the CONSOLE instead.)\n";
361 
362  const bool bSuccess = OTAsymmetricKey::SetPasswordCaller(theCaller);
363 
364  otWarn << __FUNCTION__
365  << ": RESULT of call to OTAsymmetricKey::SetPasswordCaller: "
366  << (bSuccess ? "SUCCESS" : "FAILURE") << "\n";
367 
368  return bSuccess;
369 }
OTLOG_IMPORT OTLogStream otWarn
OTLOG_IMPORT OTLogStream otErr
int32_t opentxs::OT_CLI_GetArgsCount ( const std::string &  str_Args)

Definition at line 187 of file OT_ME.cpp.

188 {
189  const OTString strArgs(str_Args);
190  int32_t nRetVal = 0;
191  mapOfArguments map_values;
192  const bool bTokenized = strArgs.TokenizeIntoKeyValuePairs(map_values);
193  if (bTokenized) nRetVal = static_cast<int32_t>(map_values.size());
194  return nRetVal;
195 }
std::map< std::string, std::string > mapOfArguments
Definition: OT_ME.cpp:171
std::string opentxs::OT_CLI_GetKeyByIndex ( const std::string &  str_Args,
int32_t  nIndex 
)

Definition at line 253 of file OT_ME.cpp.

254 {
255  const OTString strArgs(str_Args);
256  std::string str_retval = "";
257  mapOfArguments map_values;
258  const bool bTokenized = strArgs.TokenizeIntoKeyValuePairs(map_values);
259  if (bTokenized && (nIndex < static_cast<int32_t>(map_values.size()))) {
260  int32_t nMapIndex = (-1);
261  for (auto& it : map_values) {
262  ++nMapIndex;
263  // const std::string str_key = it->first;
264  // const std::string str_val = it->second;
265  // BY this point, nMapIndex contains the index we're at on
266  // map_values
267  // (compare to nIndex.) And str_key and str_val contain the
268  // key/value
269  // pair for THAT index.
270  //
271  if (nIndex == nMapIndex) {
272  str_retval = it.first; // Found it!
273  break;
274  }
275  }
276  }
277  return str_retval;
278 }
std::map< std::string, std::string > mapOfArguments
Definition: OT_ME.cpp:171
std::string opentxs::OT_CLI_GetValueByIndex ( const std::string &  str_Args,
int32_t  nIndex 
)

Definition at line 222 of file OT_ME.cpp.

223 {
224  const OTString strArgs(str_Args);
225  std::string str_retval = "";
226  mapOfArguments map_values;
227  const bool bTokenized = strArgs.TokenizeIntoKeyValuePairs(map_values);
228  if (bTokenized && (nIndex < static_cast<int32_t>(map_values.size()))) {
229  int32_t nMapIndex = (-1);
230  for (auto& it : map_values) {
231  ++nMapIndex;
232  // const std::string str_key = it->first;
233  // const std::string str_val = it->second;
234  // BY this point, nMapIndex contains the index we're at on
235  // map_values
236  // (compare to nIndex.) And str_key and str_val contain the
237  // key/value
238  // pair for THAT index.
239  //
240  if (nIndex == nMapIndex) {
241  str_retval = it.second; // Found it!
242  break;
243  }
244  }
245  }
246  return str_retval;
247 }
std::map< std::string, std::string > mapOfArguments
Definition: OT_ME.cpp:171
std::string opentxs::OT_CLI_GetValueByKey ( const std::string &  str_Args,
const std::string &  str_key 
)

Definition at line 201 of file OT_ME.cpp.

203 {
204  const OTString strArgs(str_Args);
205  std::string str_retval = "";
206  mapOfArguments map_values;
207  const bool bTokenized = strArgs.TokenizeIntoKeyValuePairs(map_values);
208  if (bTokenized && (!map_values.empty())) {
209  // Okay we now have key/value pairs -- let's look it up!
210  auto it = map_values.find(str_key);
211 
212  if (map_values.end() != it) // found it
213  str_retval = it->second;
214  }
215  return str_retval;
216 }
std::map< std::string, std::string > mapOfArguments
Definition: OT_ME.cpp:171
std::string opentxs::OT_CLI_ReadLine ( )
inline

Definition at line 144 of file Helpers.hpp.

145 {
146  std::string line;
147  if (std::getline(std::cin, line)) {
148  return line;
149  }
150 
151  return "";
152 }
std::string opentxs::OT_CLI_ReadUntilEOF ( )
inline

Definition at line 156 of file Helpers.hpp.

157 {
158  // don't skip the whitespace while reading
159  // std::cin >> std::noskipws;
160 
161  // std::ostringstream oss;
162  //
163  // oss << std::cin; // Convert value into a string.
164  // s = outs.str();
165 
166  // use stream iterators to copy the stream to a string
167  // std::istream_iterator<std::string> it(std::cin);
168  // std::istream_iterator<std::string> end;
169  // std::istream_iterator<char> it(std::cin);
170  // std::istream_iterator<char> end;
171  // std::string results(it, end);
172 
173  // int32_t onechar;
174 
175  std::string result("");
176 
177  for (;;) {
178  std::string input_line("");
179 
180  // int32_t n;
182  // std::stringstream ssn;
183  //
184  // std::getline(std::cin, input_line);
185  // ssn << input_line;
186  // ssn >> n;
187 
188  // std::getline(std::cin, input_line, '\n');
189  if (std::getline(std::cin, input_line, '\n')) {
190  input_line += "\n";
191 
192  if (input_line[0] == '~') // This is our special "break" character
193  // for multi-line input.
194  break;
195 
196  result += input_line;
197  }
198  else {
199  OTLog::Error("OT_CLI_ReadUntilEOF: getline() was unable to read a "
200  "string from std::cin\n");
201  break;
202  }
203  if (std::cin.eof()) {
204  // cout << "IT WAS EOF\n";
205  std::cin.clear();
206  break;
207  }
208  if (std::cin.fail()) {
209  // cout << "IT WAS FAIL\n";
210  std::cin.clear();
211  break;
212  }
213  if (std::cin.bad()) {
214  // cout << "IT WAS BAD\n";
215  std::cin.clear();
216  break;
217  }
218  // std::cin.clear();
219  // std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
220  // '\n');
221 
222  } // while
223 
224  return result;
225 }
bool opentxs::ot_lockPage ( void *  addr,
size_t  len 
)

Definition at line 234 of file OTPassword.cpp.

235 {
236 #ifdef _WIN32
237 // return VirtualLock(addr, len);
238 #elif defined(PREDEF_PLATFORM_UNIX)
239  static bool bWarned = false;
240  if (mlock(addr, len) && !bWarned) {
241  bWarned = true;
242  otErr << "ot_lockPage: WARNING: unable to lock memory. \n"
243  " (Passwords / secret keys may be swapped to disk!)\n";
244  }
245  return true;
246 #else
247  OT_FAIL_MSG("ASSERT: ot_lockPage unable to lock memory.");
248 #endif
249  return false;
250 }
#define mlock(a, b)
Definition: OTPassword.cpp:156
#define OT_FAIL_MSG(s)
Definition: Assert.hpp:144
OTLOG_IMPORT OTLogStream otErr
uint8_t* opentxs::ot_openssl_base64_decode ( const char *  input,
size_t *  out_len,
int32_t  bLineBreaks 
)

Definition at line 1291 of file OTCrypto.cpp.

1293 {
1294 
1295  OT_ASSERT(nullptr != input);
1296 
1297  int32_t in_len =
1298  static_cast<int32_t>(strlen(input)); // todo security (strlen)
1299  int32_t out_max_len = (in_len * 6 + 7) / 8;
1300  uint8_t* buf = new uint8_t[out_max_len];
1301  OT_ASSERT(nullptr != buf);
1302  memset(buf, 0, out_max_len); // todo security
1303 
1304  OpenSSL_BIO b64 = BIO_new(BIO_f_base64());
1305 
1306  if (b64) {
1307  if (!bLineBreaks) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
1308 
1309  OpenSSL_BIO bmem =
1310  BIO_new_mem_buf((char*)input, in_len); // todo casting.
1311  OT_ASSERT(nullptr != bmem);
1312 
1313  OpenSSL_BIO b64join = BIO_push(b64, bmem);
1314  b64.release();
1315  bmem.release();
1316  OT_ASSERT(nullptr != b64join);
1317 
1318  *out_len = BIO_read(b64join, buf, out_max_len);
1319 
1320  }
1321  else {
1322  OT_FAIL_MSG("Failed creating new Bio in base64_decode.\n");
1323  }
1324 
1325  return buf;
1326 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
#define OT_FAIL_MSG(s)
Definition: Assert.hpp:144
char* opentxs::ot_openssl_base64_encode ( const uint8_t *  input,
int32_t  in_len,
int32_t  bLineBreaks 
)

Definition at line 1251 of file OTCrypto.cpp.

1253 {
1254  char* buf = nullptr;
1255  BUF_MEM* bptr = nullptr;
1256 
1257  OT_ASSERT_MSG(in_len >= 0,
1258  "OT_base64_encode: Abort: in_len is a negative number!");
1259 
1260  OpenSSL_BIO b64 = BIO_new(BIO_f_base64());
1261 
1262  if (!b64) return buf;
1263 
1264  if (!bLineBreaks) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
1265 
1266  OpenSSL_BIO bmem = BIO_new(BIO_s_mem());
1267 
1268  if (bmem) {
1269  OpenSSL_BIO b64join = BIO_push(b64, bmem);
1270  b64.release();
1271  bmem.release();
1272 
1273  if (BIO_write(b64join, input, in_len) == in_len) {
1274  (void)BIO_flush(b64join);
1275  BIO_get_mem_ptr(b64join, &bptr);
1276  // otLog5 << "DEBUG base64_encode size: %lld, in_len:
1277  // %lld\n", bptr->length+1, in_len);
1278  buf = new char[bptr->length + 1];
1279  OT_ASSERT(nullptr != buf);
1280  memcpy(buf, bptr->data, bptr->length); // Safe.
1281  buf[bptr->length] = '\0'; // Forcing null terminator.
1282  }
1283  }
1284  else {
1285  OT_FAIL_MSG("Failed creating new Bio in base64_encode.\n");
1286  }
1287 
1288  return buf;
1289 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
#define OT_FAIL_MSG(s)
Definition: Assert.hpp:144
void opentxs::ot_openssl_locking_callback ( int32_t  mode,
int32_t  type,
char *  file,
int32_t  line 
)
void opentxs::ot_openssl_locking_callback ( int32_t  mode,
int32_t  type,
const char *  ,
int32_t   
)

Definition at line 1147 of file OTCrypto.cpp.

1149 {
1150  if (mode & CRYPTO_LOCK) {
1151  OTCrypto_OpenSSL::s_arrayMutex[type].lock();
1152  }
1153  else {
1154  OTCrypto_OpenSSL::s_arrayMutex[type].unlock();
1155  }
1156 }
uint64_t opentxs::ot_openssl_thread_id ( void  )

Definition at line 1103 of file OTCrypto.cpp.

1104 {
1105  uint64_t ret = this_thread::get_raw_id();
1106 
1107  return (ret);
1108 }
void * opentxs::ot_secure_memset ( void *  v,
uint8_t  c,
uint32_t  n 
)

Definition at line 177 of file OTPassword.cpp.

178 {
179  OT_ASSERT((nullptr != v) && (n > 0));
180 
181  volatile uint8_t* p = static_cast<volatile uint8_t*>(v);
182  while (n--) *p++ = c;
183 
184  return v;
185 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
void opentxs::ot_terminate ( void  )

Definition at line 944 of file OTLog.cpp.

945 {
946  if (auto e = std::current_exception()) {
947  try {
948  std::rethrow_exception(e);
949  }
950  catch (const std::exception& e) {
951  std::cerr << "ot_terminate: " << __FUNCTION__
952  << " caught unhandled exception."
953  << " type: " << typeid(e).name()
954  << " what(): " << e.what() << std::endl;
955  }
956  catch (...) {
957  std::cerr << "ot_terminate: " << __FUNCTION__
958  << " caught unknown/unhandled exception." << std::endl;
959  }
960  }
961 
962  print_stacktrace();
963 
964  // Call the default std::terminate() handler.
965  std::abort();
966 }
bool opentxs::ot_unlockPage ( void *  addr,
size_t  len 
)

Definition at line 257 of file OTPassword.cpp.

258 {
259 #ifdef _WIN32
260 // return VirtualUnlock(addr, len);
261 #elif defined(PREDEF_PLATFORM_UNIX)
262  static bool bWarned = false;
263  if (munlock(addr, len) && !bWarned) {
264  bWarned = true;
265  otErr << "ot_unlockPage: WARNING: unable to unlock memory used for "
266  "storing secrets.\n";
267  }
268  return true;
269 #else
270  OT_FAIL_MSG("ASSERT: ot_unlockPage unable to unlock secret memory.");
271 #endif
272  return false;
273 }
#define OT_FAIL_MSG(s)
Definition: Assert.hpp:144
#define munlock(a, b)
Definition: OTPassword.cpp:160
OTLOG_IMPORT OTLogStream otErr
OTLOG_IMPORT OTLogStream opentxs::otErr ( 1)
OTLOG_IMPORT OTLogStream opentxs::otInfo ( )
OTLOG_IMPORT OTLogStream opentxs::otLog3 ( )
OTLOG_IMPORT OTLogStream opentxs::otLog4 ( )
OTLOG_IMPORT OTLogStream opentxs::otLog5 ( )
OTLOG_IMPORT OTLogStream opentxs::otOut ( )
std::shared_ptr< OTScript > opentxs::OTScriptFactory ( const std::string &  script_type = "")

Definition at line 203 of file OTScript.cpp.

204 {
205 
206 #ifdef OT_USE_SCRIPT_CHAI
207  // default or explicit chai script interpreter
208  if (script_type == "" || script_type == "chai") // todo no hardcoding.
209  {
210  std::shared_ptr<OTScript> pChaiScript(new OTScriptChai);
211  return pChaiScript;
212  }
213 
214 //#elif OT_USE_SCRIPT_LUA
215 // if (script_type =="lua") // todo no hardcoding.
216 // {
217 // std::shared_ptr<OTScript> pLuaScript(new OTScriptLua);
218 // return pLuaScript;
219 // }
220 
221 #else
222  // default no script interpreter
223  if (script_type == "") {
224  otErr << "\n\n WARNING 1: script_type == noscript. \n\n";
225 
226  std::shared_ptr<OTScript> pNoScript(new OTScript);
227  return pNoScript;
228  }
229 #endif
230 
231  otErr << __FUNCTION__ << ": Script language (" << script_type
232  << ") not found.\n";
233 
234  std::shared_ptr<OTScript> retVal;
235  return retVal;
236 }
OTLOG_IMPORT OTLogStream otErr
std::shared_ptr< OTScript > opentxs::OTScriptFactory ( const std::string &  script_type,
const std::string &  script_contents 
)

Definition at line 238 of file OTScript.cpp.

240 {
241 
242 #ifdef OT_USE_SCRIPT_CHAI
243  // default or explicit chai script interpreter
244  if (script_type == "" || script_type == "chai") // todo no hardcoding.
245  {
246  std::shared_ptr<OTScript> pChaiScript(
247  new OTScriptChai(script_contents));
248  return pChaiScript;
249  }
250 
251 //#elif OT_USE_SCRIPT_LUA
252 // if (script_type =="lua") // todo no hardcoding.
253 // {
254 // std::shared_ptr<OTScript> pLuaScript(new OTScriptLua(script_contents));
255 // return pLuaScript;
256 // }
257 
258 #else
259  // default no script interpreter
260  if (script_type == "") {
261  otErr << "\n\n WARNING 2: script_type == noscript. \n\n";
262 
263  std::shared_ptr<OTScript> pNoScript(new OTScript);
264  return pNoScript;
265  }
266 #endif
267 
268  otErr << __FUNCTION__ << ": Script language (" << script_type
269  << ") not found.\n";
270 
271  std::shared_ptr<OTScript> retVal;
272  return retVal;
273 }
OTLOG_IMPORT OTLogStream otErr
OTLOG_IMPORT OTLogStream opentxs::otWarn ( )
void opentxs::rollback_four_accounts ( OTAccount &  p1,
bool  b1,
const int64_t &  a1,
OTAccount &  p2,
bool  b2,
const int64_t &  a2,
OTAccount &  p3,
bool  b3,
const int64_t &  a3,
OTAccount &  p4,
bool  b4,
const int64_t &  a4 
)

Definition at line 986 of file OTMarket.cpp.

990 {
991  if (b1) p1.Credit(a1);
992  if (b2) p2.Credit(a2);
993  if (b3) p3.Debit(a3);
994  if (b4) p4.Debit(a4);
995 }
void opentxs::separateThousands ( std::stringstream &  sss,
int64_t  value,
const char *  szSeparator 
)
inline

Definition at line 300 of file OTAssetContract.cpp.

302 {
303  if (value < 1000) {
304  sss << value;
305  return;
306  }
307 
308  separateThousands(sss, value / 1000, szSeparator);
309  sss << szSeparator << std::setfill('0') << std::setw(3) << value % 1000;
310 }
void separateThousands(std::stringstream &sss, int64_t value, const char *szSeparator)
void opentxs::SetMonitor ( const char *  filepathexact)

Definition at line 183 of file MintLucre.cpp.

184 {
185  BIO* out = BIO_new_file(filepathexact, "w");
186  assert(out);
187  SetDumper(out);
188 }
void SetDumper(BIO *out)
bool opentxs::SetupBoxReceiptFilename ( int64_t  lLedgerType,
OTTransaction &  theTransaction,
const char *  szCaller,
OTString &  strFolder1name,
OTString &  strFolder2name,
OTString &  strFolder3name,
OTString &  strFilename 
)

Definition at line 591 of file Helpers.cpp.

595 {
596  OTString strUserOrAcctID;
597  theTransaction.GetIdentifier(strUserOrAcctID);
598 
599  const OTString strServerID(theTransaction.GetRealServerID());
600 
601  return SetupBoxReceiptFilename(lLedgerType, strUserOrAcctID, strServerID,
602  theTransaction.GetTransactionNum(), szCaller,
603  strFolder1name, strFolder2name,
604  strFolder3name, strFilename);
605 }
bool SetupBoxReceiptFilename(int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
Definition: Helpers.cpp:591
bool opentxs::SetupBoxReceiptFilename ( OTLedger &  theLedger,
OTTransaction &  theTransaction,
const char *  szCaller,
OTString &  strFolder1name,
OTString &  strFolder2name,
OTString &  strFolder3name,
OTString &  strFilename 
)

Definition at line 607 of file Helpers.cpp.

611 {
612  int64_t lLedgerType = 0;
613 
614  switch (theLedger.GetType()) {
615  case OTLedger::nymbox:
616  lLedgerType = 0;
617  break;
618  case OTLedger::inbox:
619  lLedgerType = 1;
620  break;
621  case OTLedger::outbox:
622  lLedgerType = 2;
623  break;
624  // case OTLedger::message: lLedgerType = 3; break;
625  case OTLedger::paymentInbox:
626  lLedgerType = 4;
627  break;
628  case OTLedger::recordBox:
629  lLedgerType = 5;
630  break;
631  case OTLedger::expiredBox:
632  lLedgerType = 6;
633  break;
634  default:
635  otErr << "OTTransaction::" << __FUNCTION__ << " " << szCaller
636  << ": Error: unknown box type. "
637  "(This should never happen.)\n";
638  return false;
639  }
640 
641  return SetupBoxReceiptFilename(lLedgerType, theTransaction, szCaller,
642  strFolder1name, strFolder2name,
643  strFolder3name, strFilename);
644 }
bool SetupBoxReceiptFilename(int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
Definition: Helpers.cpp:591
OTLOG_IMPORT OTLogStream otErr
bool opentxs::SetupBoxReceiptFilename ( int64_t  lLedgerType,
const OTString &  strUserOrAcctID,
const OTString &  strServerID,
const int64_t &  lTransactionNum,
const char *  szCaller,
OTString &  strFolder1name,
OTString &  strFolder2name,
OTString &  strFolder3name,
OTString &  strFilename 
)

Definition at line 541 of file Helpers.cpp.

548 {
549  OT_ASSERT(nullptr != szCaller);
550 
551  const char* pszFolder = nullptr; // "nymbox" (or "inbox" or "outbox")
552  switch (lLedgerType) {
553  case 0:
554  pszFolder = OTFolders::Nymbox().Get();
555  break;
556  case 1:
557  pszFolder = OTFolders::Inbox().Get();
558  break;
559  case 2:
560  pszFolder = OTFolders::Outbox().Get();
561  break;
562  // case 3: (message ledger.)
563  case 4:
564  pszFolder = OTFolders::PaymentInbox().Get();
565  break;
566  case 5:
567  pszFolder = OTFolders::RecordBox().Get();
568  break;
569  case 6:
570  pszFolder = OTFolders::ExpiredBox().Get();
571  break;
572  default:
573  otErr << "OTTransaction::" << __FUNCTION__ << " " << szCaller
574  << ": Error: unknown box type: " << lLedgerType
575  << ". (This should never happen.)\n";
576  return false;
577  }
578 
579  strFolder1name.Set(pszFolder); // "nymbox" (or "inbox" or "outbox")
580  strFolder2name.Set(strServerID); // "SERVER_ID"
581  strFolder3name.Format("%s.r", strUserOrAcctID.Get()); // "USER_ID.r"
582 
583  strFilename.Format("%lld.rct", lTransactionNum); // "TRANSACTION_ID.rct"
584  // todo hardcoding of file extension. Need to standardize extensions.
585 
586  // Finished product: "nymbox/SERVER_ID/USER_ID.r/TRANSACTION_ID.rct"
587 
588  return true;
589 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
OTLOG_IMPORT OTLogStream otErr
void opentxs::SetupHeader ( u_header theCMD,
int32_t  nTypeID,
int32_t  nCmdID,
OTPayload &  thePayload 
)

Definition at line 164 of file OTServerConnection.cpp.

166 {
167  uint32_t lSize = thePayload.GetSize(); // outputting in normal byte order,
168  // but sent to network in network
169  // byte order.
170 
171  theCMD.fields.type_id = (nTypeID > 0) ? static_cast<BYTE>(nTypeID) : '\0';
172  theCMD.fields.command_id = (nCmdID > 0) ? static_cast<BYTE>(nCmdID) : '\0';
173  ;
174  theCMD.fields.size =
175  htonl(lSize); // think this is causing problems.. maybe not...
176  theCMD.fields.checksum = CalcChecksum(theCMD.buf, OT_CMD_HEADER_SIZE - 1);
177 
178  BYTE byChecksum = (BYTE)theCMD.fields.checksum;
179  int32_t nChecksum = byChecksum;
180 
181  otLog4 << "OT_CMD_HEADER_SIZE: " << OT_CMD_HEADER_SIZE
182  << " -- CMD TYPE: " << nTypeID << " -- CMD NUM: " << nCmdID
183  << " -- (followed by 2 bytes of filler)\n"
184  "PAYLOAD SIZE: " << lSize << " -- CHECKSUM: " << nChecksum
185  << "\n";
186 
187  otLog5 << "First 9 bytes are:";
188  for (int i = 0; i < 9; i++) {
189  otLog5 << " " << int(theCMD.buf[i]);
190  }
191  otLog5 << "\n";
192 }
OTLOG_IMPORT OTLogStream otLog4
BYTE buf[OT_CMD_HEADER_SIZE]
Definition: stdafx.hpp:26
uint32_t size
Definition: stdafx.hpp:32
EXPORT OT_BYTE CalcChecksum(OT_BYTE *buffer, uint32_t size)
struct u_header::@0 fields
#define OT_CMD_HEADER_SIZE
Definition: stdafx.hpp:19
uint8_t BYTE
Definition: stdafx.hpp:21
BYTE command_id
Definition: stdafx.hpp:30
BYTE type_id
Definition: stdafx.hpp:29
OTLOG_IMPORT OTLogStream otLog5
BYTE checksum
Definition: stdafx.hpp:33
int32_t opentxs::souped_up_pass_cb ( char *  buf,
int32_t  size,
int32_t  rwflag,
void *  userdata 
)

Definition at line 460 of file OTAsymmetricKey.cpp.

462 {
463  // OT_ASSERT(nullptr != buf); // apparently it CAN be nullptr sometimes.
464  OT_ASSERT(nullptr != userdata);
465  const OTPasswordData* pPWData = static_cast<OTPasswordData*>(userdata);
466  const std::string str_userdata = pPWData->GetDisplayString();
467 
468  OTPassword thePassword;
469  bool bGotPassword = false;
470 
471  // Sometimes it's passed in, otherwise we use the global one.
472  std::shared_ptr<OTCachedKey> pCachedKey(pPWData->GetCachedKey());
473 
474  if (!pCachedKey) {
475  // Global one.
476  pCachedKey =
477  OTCachedKey::It(); // Used to only use this one (global one) but now
478  // I allow pPWData to contain a pointer to the
479  // exact instance. (To enable multiple
480  // instances...) If that's not found then here we
481  // set it to the global one.
482  }
483  if (!pCachedKey) OT_FAIL;
484 
485  const bool b1 = pPWData->isForNormalNym();
486  const bool b3 = !(pCachedKey->isPaused());
487 
488  // For example, perhaps we need to collect a password for a symmetric key.
489  // In that case, it has nothing to do with any master key, or any
490  // public/private
491  // keys. It ONLY wants to do a simple password collect.
492  //
493  const bool bOldSystem = pPWData->isUsingOldSystem();
494 
495  // otLog5 <<
496  // "--------------------------------------------------------------------------------\n"
497  // "TOP OF SOUPED-UP PASS CB:\n pPWData->isForNormalNym():
498  // %s \n "
500  // "!(pCachedKey->isPaused()): %s \n",
501  // b1 ? "NORMAL" : "NOT normal",
503  // b3 ? "NOT paused" : "PAUSED"
504  // );
505 
506  //
507  // It's for one of the normal Nyms.
508  // (NOT the master key.)
509  // If it was for the master key, we'd just pop up the dialog and get the
510  // master passphrase.
511  // But since it's for a NORMAL Nym, we have to call
512  // OTCachedKey::GetMasterPassword. IT will pop
513  // up the dialog if it needs to, by recursively calling this in master mode,
514  // and then it'll use
515  // the user passphrase from that dialog to derive a key, and use THAT key to
516  // unlock the actual
517  // "passphrase" (a random value) which is then passed back to OpenSSL to use
518  // for the Nyms.
519  //
520  if (b1 && // Normal Nyms, unlike Master passwords, have to look up the
521  // master password first.
522  !bOldSystem && b3) // ...Unless they are still using the old system, in
523  // which case they do NOT look up the master
524  // password...
525  {
526 
527  // Therefore we need to provide the password from an OTSymmetricKey
528  // stored here.
529  // (the "actual key" in the OTSymmetricKey IS the password that we are
530  // passing back!)
531 
532  // So either the "actual key" is cached on a timer, from some previous
533  // request like
534  // this, OR we have to pop up the passphrase dialog, ask for the
535  // passphrase for the
536  // OTSymmetricKey, and then use it to GET the actual key from that
537  // OTSymmetricKey.
538  // The OTSymmetricKey should be stored in the OTWallet or OTServer,
539  // which sets a pointer
540  // to itself inside the OTPasswordData class statically, on
541  // initialization.
542  // That way, OTPasswordData can use that pointer to get a pointer to the
543  // relevant
544  // OTSymmetricKey being used as the MASTER key.
545  //
546  otLog3 << __FUNCTION__ << ": Using GetMasterPassword() call. \n";
547 
548  bGotPassword = pCachedKey->GetMasterPassword(
549  pCachedKey, thePassword,
550  str_userdata.c_str()); // bool bVerifyTwice=false
551 
552  // NOTE: shouldn't the above call to GetMasterPassword be passing the
553  // rwflag as the final parameter?
554  // Just as we see below with the call to GetPasswordFromConsole. Right?
555  // Of course, it DOES generate internally,
556  // if necessary, and thus it forces an "ask twice" in that situation
557  // anyway. (It's that smart.)
558  // Actually that's it. The master already asks twice when it's
559  // generating.
560 
561  // bool GetMasterPassword(OTPassword& theOutput,
562  // const char * szDisplay=nullptr,
563  // bool bVerifyTwice=false);
564 
565  // otOut << "OPENSSL_CALLBACK (souped_up_pass_cb): Finished calling
566  // GetMasterPassword(). Result: %s\n",
567  // bGotPassword ? "SUCCESS" : "FAILURE");
568  }
569  else {
570  otLog3 << __FUNCTION__ << ": Using OT Password Callback. \n";
571 
572  OTCaller* pCaller =
573  OTAsymmetricKey::GetPasswordCaller(); // See if the developer
574  // registered one via the OT
575  // API.
576 
577  // if (nullptr == pCaller)
578  // {
579  // otErr << "OPENSSL_CALLBACK (souped_up_pass_cb): OTCaller is
580  // nullptr. Try calling OT_API_Set_PasswordCallback() first.\n";
581  // OT_ASSERT(0); // This will never actually happen, since
582  // SetPasswordCaller() and souped_up_pass_cb are activated in same
583  // place.
584  // }
585 
586  if (nullptr == pCaller) // We'll just grab it from the console then.
587  {
588  otOut << "Passphrase request for: \"" << str_userdata << "\"\n";
589 
590  bGotPassword = OTCrypto::It()->GetPasswordFromConsole(
591  thePassword, (1 == rwflag) ? true : false);
592  }
593  else // Okay, we have a callback, so let's pop up the dialog!
594  {
595 
596  // The dialog should display this string (so the user knows what he
597  // is authorizing.)
598  //
599  pCaller->SetDisplay(str_userdata.c_str(),
600  static_cast<int32_t>(str_userdata.size()));
601 
602  if (1 == rwflag) {
603  otLog4 << __FUNCTION__
604  << ": Using OT Password Callback (asks twice) for \""
605  << str_userdata << "\"...\n";
606  pCaller->callTwo(); // This is where Java pops up a modal dialog
607  // and asks for password twice...
608  }
609  else {
610  otLog4 << __FUNCTION__
611  << ": Using OT Password Callback (asks once) for \""
612  << str_userdata << "\"...\n";
613  pCaller->callOne(); // This is where Java pops up a modal dialog
614  // and asks for password once...
615  }
616 
617  /*
618  NOTICE: (For security...)
619 
620  We are using an OTPassword object to collect the password from the
621  caller.
622  (We're not passing strings back and forth.) The OTPassword object
623  is where we
624  can centralize our efforts to scrub the memory clean as soon as
625  we're done with
626  the password. It's also designed to be light (no baggage) and to be
627  passed around
628  easily, with a set-size array for the data.
629 
630  Notice I am copying the password directly from the OTPassword
631  object into the buffer
632  provided to me by OpenSSL. When the OTPassword object goes out of
633  scope, then it cleans
634  up automatically.
635  */
636 
637  bGotPassword = pCaller->GetPassword(thePassword);
638  }
639  }
640 
641  if (!bGotPassword) {
642  otOut << __FUNCTION__
643  << ": Failure: (false == bGotPassword.) (Returning 0.)\n";
644  return 0;
645  }
646  // --------------------------------------
647  otInfo << __FUNCTION__ << ": Success!\n";
648  /*
649  http://openssl.org/docs/crypto/pem.html#
650  "The callback must return the number of characters in the passphrase or 0
651  if an error occurred."
652  */
653  int32_t len = thePassword.isPassword() ? thePassword.getPasswordSize()
654  : thePassword.getMemorySize();
655 
656  if (len < 0) {
657  otOut << __FUNCTION__ << ": <0 length password was "
658  "returned from the API password callback. "
659  "Returning 0.\n";
660  return 0;
661  }
662  // --------------------------------------
663  else if (len == 0) {
664  const char* szDefault = "test";
665 
666  otOut << __FUNCTION__
667  << ": 0 length password was "
668  "returned from the API password callback. "
669  "Substituting default password 'test'.\n"; // todo: security:
670  // is this safe?
671  // Here's what's
672  // driving this: We
673  // can't return 0
674  // length string,
675  // but users wanted
676  // to be able to
677  // "just hit enter"
678  // and use an empty
679  // passphrase. So
680  // for cases where
681  // the user has
682  // explicitly "hit
683  // enter" we will
684  // substitute "test"
685  // as their
686  // passphrase
687  // instead. They
688  // still have to do
689  // this
690  // explicitly--it
691  // only happens when
692  // they use an empty
693  // one.
694 
695  if (thePassword.isPassword())
696  thePassword.setPassword(szDefault,
697  static_cast<int32_t>(OTString::safe_strlen(
698  szDefault, _PASSWORD_LEN)));
699  else
700  thePassword.setMemory(static_cast<const void*>(szDefault),
701  static_cast<uint32_t>(OTString::safe_strlen(
702  szDefault, _PASSWORD_LEN)) +
703  1); // setMemory doesn't assume the null
704  // terminator like setPassword does.
705 
706  len = thePassword.isPassword() ? thePassword.getPasswordSize()
707  : thePassword.getMemorySize();
708  }
709 
710  OTPassword* pMasterPW = pPWData->GetMasterPW();
711 
712  if (pPWData->isForCachedKey() && (nullptr != pMasterPW)) {
713  *pMasterPW = thePassword;
714  }
715  // --------------------------------------
716  else if (nullptr != buf) {
717  // if too int64_t, truncate
718  if (len > size) len = size;
719 
720  const uint32_t theSize = static_cast<uint32_t>(size);
721  const uint32_t theLength = static_cast<uint32_t>(len);
722 
723  if (thePassword.isPassword()) {
724  // otErr << "%s: BEFORE TEXT PASSWORD: %s LENGTH: %d\n",
725  // __FUNCTION__, thePassword.getPassword(), theLength);
726 
727  OTPassword::safe_memcpy(buf, // destination
728  theSize, // size of destination buffer.
729  thePassword.getPassword_uint8(), // source
730  theLength); // length of source.
731  // bool bZeroSource=false); // No need to set this true, since
732  // OTPassword (source) already zeros its memory automatically.
733  buf[theLength] = '\0'; // null terminator.
734 
735  // int32_t nSize =
736  // static_cast<int32_t>(thePassword.getPasswordSize());
737  // otErr << "%s: AFTER TEXT PASSWORD: %s LENGTH: %d\n",
738  // __FUNCTION__, buf, nSize);
739  }
740  else {
741  OTPassword::safe_memcpy(buf, // destination
742  theSize, // size of destination buffer.
743  thePassword.getMemory_uint8(), // source
744  theLength); // length of source.
745  // bool bZeroSource=false); // No need to set this true, since
746  // OTPassword (source) already zeros its memory automatically.
747 
748  // int32_t nSize =
749  // static_cast<int32_t>(thePassword.getMemorySize());
750  // otErr << "%s: (BINARY PASSWORD) LENGTH: %d\n",
751  // __FUNCTION__, nSize);
752  }
753 
754  }
755  // --------------------------------------
756  else // should never happen
757  {
758  // OT_FAIL_MSG("This should never happen. (souped_up_pass_cb");
759  }
760  return len;
761 }
OTLOG_IMPORT OTLogStream otLog4
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otLog3
#define OT_ASSERT(x)
Definition: Assert.hpp:150
OTLOG_IMPORT OTLogStream otInfo
#define OT_FAIL
Definition: Assert.hpp:139
#define _PASSWORD_LEN
char * opentxs::str_dup2 ( const char *  str,
uint32_t  length 
)

Definition at line 143 of file StringUtils.cpp.

146 {
147  char* str_new = new char[length + 1]; // CREATE EXTRA BYTE OF SPACE FOR \0
148  // (NOT PART OF LENGTH)
149  OT_ASSERT(nullptr != str_new);
150 
151 #ifdef _WIN32
152  strncpy_s(str_new, length + 1, str, length);
153 #else
154  strncpy(str_new, str, length);
155 #endif
156 
157  // INITIALIZE EXTRA BYTE OF SPACE
158  //
159  // If length is 10, then buffer is created with 11 elements,
160  // indexed from 0 (first element) through 10 (11th element).
161  //
162  // Therefore str_new[length==10] is the 11th element, which was
163  // the extra one created on our buffer, to store the \0 null terminator.
164  //
165  // This way I know I'm never cutting off data that was in the string itself.
166  // Rather, I am only setting to 0 an EXTRA byte that I created myself, AFTER
167  // the string's length itself.
168  //
169  str_new[length] = '\0';
170 
171  return str_new;
172 }
#define OT_ASSERT(x)
Definition: Assert.hpp:150
size_t opentxs::strlcat ( char *  dst,
const char *  src,
size_t  siz 
)
inline

Definition at line 242 of file StringUtils.hpp.

243 {
244  char* d = dst;
245  const char* s = src;
246  size_t n = siz;
247  size_t dlen;
248 
249  /* Find the end of dst and adjust bytes left but don't go past end */
250  while (n-- != 0 && *d != '\0') d++;
251  dlen = d - dst;
252  n = siz - dlen;
253 
254  if (n == 0) return (dlen + strlen(s));
255  while (*s != '\0') {
256  if (n != 1) {
257  *d++ = *s;
258  n--;
259  }
260  s++;
261  }
262  *d = '\0';
263 
264  return (dlen + (s - src)); /* count does not include NUL */
265 }
size_t opentxs::strlcpy ( char *  dst,
const char *  src,
size_t  siz 
)
inline

Definition at line 213 of file StringUtils.hpp.

214 {
215  char* d = dst;
216  const char* s = src;
217  size_t n = siz;
218 
219  /* Copy as many bytes as will fit */
220  if (n != 0) {
221  while (--n != 0) {
222  if ((*d++ = *s++) == '\0') break;
223  }
224  }
225 
226  /* Not enough room in dst, add NUL and traverse rest of src */
227  if (n == 0) {
228  if (siz != 0) *d = '\0'; /* NUL-terminate dst */
229  while (*s++)
230  ;
231  }
232 
233  return (s - src - 1); /* count does not include NUL */
234 }
template<typename T >
std::string opentxs::to_string ( const T &  t)
inline

Definition at line 183 of file StringUtils.hpp.

184 {
185  std::stringstream ss;
186  ss << t;
187  return ss.str();
188 }
vector<string> opentxs::tokenize ( const string &  str,
const string &  delimiters,
bool  trimEmpty 
)

Definition at line 9280 of file ot_commands_ot.cpp.

9282 {
9283  int32_t lastPos = 0;
9284  vector<string> tokens;
9285 
9286  while (true) {
9287  int32_t pos = str.find_first_of(delimiters, lastPos);
9288 
9289  if (-1 == pos) {
9290  pos = str.size();
9291 
9292  if (pos != lastPos || !trimEmpty) {
9293  tokens.push_back(str.substr(lastPos, pos - lastPos));
9294  }
9295  break;
9296  }
9297  else {
9298  if (pos != lastPos || !trimEmpty) {
9299  tokens.push_back(str.substr(lastPos, pos - lastPos));
9300  }
9301  }
9302 
9303  lastPos = pos + 1;
9304  }
9305  return tokens;
9306 }
OTAccount::AccountType opentxs::TranslateAccountTypeStringToEnum ( const OTString &  acctType)

Definition at line 672 of file OTAccount.cpp.

674 {
675  OTAccount::AccountType acctType = OTAccount::err_acct;
676 
677  if (acctTypeString.Compare("simple"))
678  acctType = OTAccount::simple;
679  else if (acctTypeString.Compare("issuer"))
680  acctType = OTAccount::issuer;
681  else if (acctTypeString.Compare("basket"))
682  acctType = OTAccount::basket;
683  else if (acctTypeString.Compare("basketsub"))
684  acctType = OTAccount::basketsub;
685  else if (acctTypeString.Compare("mint"))
686  acctType = OTAccount::mint;
687  else if (acctTypeString.Compare("voucher"))
688  acctType = OTAccount::voucher;
689  else if (acctTypeString.Compare("stash"))
690  acctType = OTAccount::stash;
691  else
692  otErr << "Error: Unknown account type: " << acctTypeString << "\n";
693 
694  return acctType;
695 }
OTLOG_IMPORT OTLogStream otErr
void opentxs::TranslateAccountTypeToString ( OTAccount::AccountType  type,
OTString &  acctType 
)

Definition at line 697 of file OTAccount.cpp.

699 {
700  switch (type) {
701  case OTAccount::simple:
702  acctType.Set("simple");
703  break;
704  case OTAccount::issuer:
705  acctType.Set("issuer");
706  break;
707  case OTAccount::basket:
708  acctType.Set("basket");
709  break;
710  case OTAccount::basketsub:
711  acctType.Set("basketsub");
712  break;
713  case OTAccount::mint:
714  acctType.Set("mint");
715  break;
716  case OTAccount::voucher:
717  acctType.Set("voucher");
718  break;
719  case OTAccount::stash:
720  acctType.Set("stash");
721  break;
722  default:
723  acctType.Set("err_acct");
724  break;
725  }
726 }
bool opentxs::VerifyBoxReceiptExists ( const OTIdentifier &  SERVER_ID,
const OTIdentifier &  USER_ID,
const OTIdentifier &  ACCOUNT_ID,
int32_t  nBoxType,
const int64_t &  lTransactionNum 
)

Definition at line 358 of file Helpers.cpp.

365 {
366  const int64_t lLedgerType = static_cast<int64_t>(nBoxType);
367 
368  const OTString strServerID(SERVER_ID),
369  strUserOrAcctID(0 == lLedgerType ? USER_ID : ACCOUNT_ID); // (For Nymbox
370  // aka type 0,
371  // the UserID
372  // will be
373  // here.)
374  // --------------------------------------------------------------------
375  OTString strFolder1name, strFolder2name, strFolder3name, strFilename;
376 
377  if (!SetupBoxReceiptFilename(lLedgerType, // nBoxType is lLedgerType
378  strUserOrAcctID, strServerID, lTransactionNum,
379  "OTTransaction::VerifyBoxReceiptExists",
380  strFolder1name, strFolder2name, strFolder3name,
381  strFilename))
382  return false; // This already logs -- no need to log twice, here.
383  // --------------------------------------------------------------------
384  // See if the box receipt exists before trying to save over it...
385  //
386  const bool bExists =
387  OTDB::Exists(strFolder1name.Get(), strFolder2name.Get(),
388  strFolder3name.Get(), strFilename.Get());
389 
390  otWarn << "OTTransaction::" << (bExists ? "(Already have this one)"
391  : "(Need to download this one)")
392  << ": " << __FUNCTION__ << ": " << strFolder1name
393  << OTLog::PathSeparator() << strFolder2name << OTLog::PathSeparator()
394  << strFolder3name << OTLog::PathSeparator() << strFilename << "\n";
395 
396  return bExists;
397 }
bool SetupBoxReceiptFilename(int64_t lLedgerType, OTTransaction &theTransaction, const char *szCaller, OTString &strFolder1name, OTString &strFolder2name, OTString &strFolder3name, OTString &strFilename)
Definition: Helpers.cpp:591
OTLOG_IMPORT OTLogStream otWarn
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
OT_UTILITY_OT bool opentxs::VerifyExists ( const string &  theObjectNameAsStr)

Definition at line 144 of file ot_utility_ot.cpp.

145 {
146  return VerifyExists(theObjectNameAsStr, true);
147 }
OT_UTILITY_OT bool VerifyExists(const string &theObjectNameAsStr)
EXPORT OT_UTILITY_OT bool opentxs::VerifyExists ( const string &  theObjectNameAsStr,
bool  bDisplayError 
)

Definition at line 149 of file ot_utility_ot.cpp.

151 {
152  if (OT_ME::FindVariable2(theObjectNameAsStr) == nullptr) {
153  if (bDisplayError) {
154  otOut << "Missing parameter: --";
155  locale loc;
156  for (auto elem : theObjectNameAsStr) {
157  otOut << tolower(elem, loc);
158  }
159  otOut << "\n";
160  }
161  return false;
162  }
163 
164  return true;
165 }
OTLOG_IMPORT OTLogStream otOut
OT_UTILITY_OT bool opentxs::VerifyMessage ( const string &  strMessage)

Definition at line 190 of file ot_utility_ot.cpp.

191 {
192  if (10 > strMessage.length()) {
193  otWarn << "VerifyMessage: Error strMessage is: Too Short:" << strMessage
194  << "\n";
195  return false;
196  }
197  return true;
198 }
OTLOG_IMPORT OTLogStream otWarn
EXPORT OT_UTILITY_OT int32_t opentxs::VerifyMessageSuccess ( const string &  strMessage)

Definition at line 200 of file ot_utility_ot.cpp.

201 {
202  if (!VerifyMessage(strMessage)) {
203  return -1;
204  }
205 
206  int32_t nStatus = OTAPI_Wrap::Message_GetSuccess(strMessage);
207  switch (nStatus) {
208  case -1:
209  otOut << "VerifyMessageSuccess: Error calling "
210  "OT_API_Message_GetSuccess, for message:\n\n" << strMessage
211  << "\n";
212  break;
213  case 0:
214  otWarn << "VerifyMessageSuccess: Reply received: success == FALSE. "
215  "Reply message:\n\n" << strMessage << "\n";
216  break;
217  case 1:
218  otWarn << "VerifyMessageSuccess: Reply received: success == TRUE.\n";
219  break;
220  default:
221  otOut << "VerifyMessageSuccess: Error. (This should never happen!) "
222  "nStatus: " << nStatus << ", Input: " << strMessage << "\n";
223  nStatus = -1;
224  break;
225  }
226 
227  return nStatus;
228 }
OT_UTILITY_OT bool VerifyMessage(const string &strMessage)
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otWarn
EXPORT OT_UTILITY_OT int32_t opentxs::VerifyMsgBalanceAgrmntSuccess ( const string &  SERVER_ID,
const string &  USER_ID,
const string &  ACCOUNT_ID,
const string &  strMessage 
)

Definition at line 230 of file ot_utility_ot.cpp.

233 {
234  if (!VerifyMessage(strMessage)) {
235  return -1;
236  }
237 
238  int32_t nSuccess = OTAPI_Wrap::Message_GetBalanceAgreementSuccess(
239  SERVER_ID, USER_ID, ACCOUNT_ID, strMessage);
240  switch (nSuccess) {
241  case -1:
242  otOut << "VerifyMsgBalanceAgrmntSuccess: Error calling "
243  "OT_API_Msg_GetBlnceAgrmntSuccess, for message:\n\n"
244  << strMessage << "\n";
245  break;
246  case 0:
247  otWarn << "VerifyMsgBalanceAgrmntSuccess: Reply received: success == "
248  "FALSE. Reply message:\n\n" << strMessage << "\n";
249  break;
250  case 1:
251  otWarn << "VerifyMsgBalanceAgrmntSuccess: Reply received: success == "
252  "TRUE.\n";
253  break;
254  default:
255  otOut << "VerifyMsgBalanceAgrmntSuccess: Error. (This should never "
256  "happen!) Input: " << strMessage << "\n";
257  nSuccess = -1;
258  break;
259  }
260 
261  return nSuccess;
262 }
OT_UTILITY_OT bool VerifyMessage(const string &strMessage)
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otWarn
EXPORT OT_UTILITY_OT int32_t opentxs::VerifyMsgTrnxSuccess ( const string &  SERVER_ID,
const string &  USER_ID,
const string &  ACCOUNT_ID,
const string &  strMessage 
)

Definition at line 265 of file ot_utility_ot.cpp.

267 {
268  if (!VerifyMessage(strMessage)) {
269  return -1;
270  }
271 
272  int32_t nSuccess = OTAPI_Wrap::Message_GetTransactionSuccess(
273  SERVER_ID, USER_ID, ACCOUNT_ID, strMessage);
274  switch (nSuccess) {
275  case -1:
276  otOut << "VerifyMsgTrnxSuccess: Error calling "
277  "OT_API_Message_GetSuccess, for message:\n\n" << strMessage
278  << "\n";
279  break;
280  case 0:
281  otWarn << "VerifyMsgTrnxSuccess: Reply received: success == FALSE. "
282  "Reply message:\n\n" << strMessage << "\n";
283  break;
284  case 1:
285  otWarn << "VerifyMsgTrnxSuccess: Reply received: success == TRUE.\n";
286  break;
287  default:
288  otOut << "VerifyMsgTrnxSuccess: Error. (This should never happen!) "
289  "Input: " << strMessage << "\n";
290  nSuccess = -1;
291  break;
292  }
293 
294  return nSuccess;
295 }
OT_UTILITY_OT bool VerifyMessage(const string &strMessage)
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otWarn
OT_UTILITY_OT bool opentxs::VerifyStringVal ( const std::string &  nValue)
inline

Definition at line 145 of file ot_utility_ot.hpp.

146 {
147  return 0 < nValue.length();
148 }

Variable Documentation

char const *const opentxs::__TypeStrings
Initial value:
= {
"simple",
"issuer",
"basket",
"basketsub",
"mint",
"voucher",
"stash",
"err_acct"}

Definition at line 161 of file OTAccount.cpp.

int32_t opentxs::allow_debug = 1

Definition at line 162 of file OTServerConnection.cpp.

EXPORT OT_OPENSSL_CALLBACK opentxs::default_pass_cb

Definition at line 199 of file OTAsymmetricKey.hpp.

const char * opentxs::OT_BEGIN_ARMORED = "-----BEGIN OT ARMORED"

Definition at line 148 of file OTASCIIArmor.cpp.

const char * opentxs::OT_BEGIN_ARMORED_escaped = "- -----BEGIN OT ARMORED"

Definition at line 151 of file OTASCIIArmor.cpp.

const char * opentxs::OT_BEGIN_SIGNED = "-----BEGIN SIGNED"

Definition at line 154 of file OTASCIIArmor.cpp.

const char * opentxs::OT_BEGIN_SIGNED_escaped = "- -----BEGIN SIGNED"

Definition at line 155 of file OTASCIIArmor.cpp.

const char * opentxs::OT_END_ARMORED = "-----END OT ARMORED"

Definition at line 149 of file OTASCIIArmor.cpp.

const char * opentxs::OT_END_ARMORED_escaped = "- -----END OT ARMORED"

Definition at line 152 of file OTASCIIArmor.cpp.

const int32_t opentxs::OT_ERROR = (-1)

Definition at line 188 of file OTAPI_Exec.cpp.

const int32_t opentxs::OT_FALSE = 0

Definition at line 180 of file OTAPI_Exec.cpp.

const int32_t opentxs::OT_TRUE = 1

Definition at line 184 of file OTAPI_Exec.cpp.

OTLOG_IMPORT OTLogStream opentxs::otErr
OTLOG_IMPORT OTLogStream opentxs::otInfo
OTLOG_IMPORT OTLogStream opentxs::otLog3
OTLOG_IMPORT OTLogStream opentxs::otLog4
OTLOG_IMPORT OTLogStream opentxs::otLog5
OTLOG_IMPORT OTLogStream opentxs::otOut
OTLOG_IMPORT OTLogStream opentxs::otWarn
EXPORT OT_OPENSSL_CALLBACK opentxs::souped_up_pass_cb

Definition at line 200 of file OTAsymmetricKey.hpp.

const int32_t opentxs::Token__nMinimumPrototokenCount = 1

Definition at line 178 of file Token.cpp.