149 : transactionNumber_(0)
156 while (!contractsMap_.empty()) {
157 auto it = contractsMap_.begin();
160 contractsMap_.erase(it);
165 while (!mintsMap_.empty()) {
166 auto it = mintsMap_.begin();
167 Mint* pMint = it->second;
212 int64_t& lTransactionNumber,
213 bool bStoreTheNumber)
215 OTIdentifier NYM_ID(theNym), SERVER_NYM_ID(server_->m_nymServer);
223 if (NYM_ID == SERVER_NYM_ID)
224 pNym = &server_->m_nymServer;
231 transactionNumber_++;
236 transactionNumber_--;
248 else if (bStoreTheNumber && (
false ==
250 server_->m_strServerID,
254 OTLog::Error(
"Error adding transaction number to Nym file.\n");
255 transactionNumber_--;
268 lTransactionNumber = transactionNumber_;
279 OTPseudonym& theNym,
const int64_t& lTransactionNumber)
284 OTIdentifier NYM_ID(theNym), SERVER_NYM_ID(server_->m_nymServer);
292 if (NYM_ID == SERVER_NYM_ID)
293 pNym = &server_->m_nymServer;
302 ?
"(However, that number IS issued to that Nym... He must have "
303 "already used it.)\n"
304 :
"(In fact, that number isn't even issued to that Nym, though "
305 "perhaps it was at some time in the past?)\n");
307 OTLog::vError(
"%s: %ld not available for Nym %s to use. \n%s",
311 lTransactionNumber, strNymID.
Get(), strIssued.Get());
321 const int64_t& lTransactionNumber,
324 OTIdentifier NYM_ID(theNym), SERVER_NYM_ID(server_->m_nymServer);
332 if (NYM_ID == SERVER_NYM_ID)
333 pNym = &server_->m_nymServer;
337 bool bRemoved =
false;
341 server_->m_nymServer, server_->m_strServerID,
346 server_->m_strServerID,
355 const int64_t& lTransactionNumber,
358 OTIdentifier NYM_ID(theNym), SERVER_NYM_ID(server_->m_nymServer);
366 if (NYM_ID == SERVER_NYM_ID)
367 pNym = &server_->m_nymServer;
373 lTransactionNumber, bSave);
396 for (
auto& it : contractsMap_) {
403 if (theContractID == ASSET_TYPE_ID)
return pContract;
423 if (
nullptr != pContract)
426 contractsMap_[STR_CONTRACT_ID.
Get()] = &theContract;
439 OTLog::Output(0,
"User attempted to add Basket that already exists.\n");
443 OTString strBasketID(BASKET_ID), strBasketAcctID(BASKET_ACCOUNT_ID),
444 strBasketContractID(BASKET_CONTRACT_ID);
446 idToBasketMap_[strBasketID.Get()] = strBasketAcctID.Get();
447 contractIdToBasketAccountId_[strBasketContractID.
Get()] =
448 strBasketAcctID.Get();
462 for (
auto& it : contractIdToBasketAccountId_) {
463 OTString strBasketContractID = it.first.c_str();
464 OTString strBasketAcctID = it.second.c_str();
467 id_BASKET_ACCT(strBasketAcctID);
469 if (BASKET_CONTRACT_ID == id_BASKET_CONTRACT)
473 BASKET_ACCOUNT_ID = id_BASKET_ACCT;
489 for (
auto& it : contractIdToBasketAccountId_) {
490 OTString strBasketContractID = it.first.c_str();
491 OTString strBasketAcctID = it.second.c_str();
494 id_BASKET_ACCT(strBasketAcctID);
496 if (BASKET_ACCOUNT_ID == id_BASKET_ACCT)
500 BASKET_CONTRACT_ID = id_BASKET_CONTRACT;
516 for (
auto& it : idToBasketMap_) {
517 OTString strBasketID = it.first.c_str();
518 OTString strBasketAcctID = it.second.c_str();
520 OTIdentifier id_BASKET(strBasketID), id_BASKET_ACCT(strBasketAcctID);
525 BASKET_ACCOUNT_ID = id_BASKET_ACCT;
539 std::shared_ptr<OTAccount> pAccount;
540 const OTIdentifier SERVER_USER_ID(server_->m_nymServer),
541 SERVER_ID(server_->m_strServerID);
542 bool bWasAcctCreated =
false;
544 server_->m_nymServer, SERVER_USER_ID, ASSET_TYPE_ID, SERVER_ID,
546 if (bWasAcctCreated) {
548 pAccount->GetIdentifier(strAcctID);
549 const OTString strAssetTypeID(ASSET_TYPE_ID);
551 OTLog::vOutput(0,
"OTServer::GetVoucherAccount: Successfully created "
552 "voucher account ID: %s Asset Type ID: %s\n",
553 strAcctID.
Get(), strAssetTypeID.
Get());
556 OTLog::Error(
"OTServer::GetVoucherAccount: Error saving main "
557 "server file containing new account ID!!\n");
569 Mint* pMint =
nullptr;
571 for (
auto& it : mintsMap_) {
574 "nullptr mint pointer in Transactor::getMint\n");
579 if ((ASSET_TYPE_ID ==
585 const OTString ASSET_ID_STR(ASSET_TYPE_ID);
588 strMintFilename.
Format(
"%s%s%s%s%d", server_->m_strServerID.
Get(),
593 const char* szFilename = strMintFilename.
Get();
595 server_->m_strServerUserID, ASSET_ID_STR);
604 "Error allocating memory for Mint in Transactor::getMint");
606 strSeries.
Format(
"%s%d",
".", nSeries);
621 std::pair<std::string, Mint*>(ASSET_ID_STR.
Get(), pMint));
627 "Error verifying Mint in Transactor::getMint:\n%s%s%s\n",
632 OTLog::vError(
"Error loading Mint in Transactor::getMint:\n%s%s%s\n",
636 if (
nullptr != pMint)
delete pMint;
static EXPORT const OTString & Mint()
static EXPORT void vError(const char *szError,...)
bool lookupBasketContractIDByAccountID(const OTIdentifier &basketAccountId, OTIdentifier &basketContractId)
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
static EXPORT Mint * MintFactory()
bool lookupBasketAccountIDByContractID(const OTIdentifier &basketContractId, OTIdentifier &basketAccountId)
bool issueNextTransactionNumber(OTPseudonym &nym, int64_t &txNumber, bool storeNumber=true)
EXPORT bool VerifyIssuedNum(const OTString &strServerID, const int64_t &lTransNum) const
static EXPORT const char * PathSeparator()
bool verifyTransactionNumber(OTPseudonym &nym, const int64_t &transactionNumber)
EXPORT bool VerifyMint(const OTPseudonym &theOperator)
EXPORT std::shared_ptr< OTAccount > GetOrCreateAccount(OTPseudonym &serverNym, const OTIdentifier &ACCOUNT_OWNER_ID, const OTIdentifier &ASSET_TYPE_ID, const OTIdentifier &SERVER_ID, bool &wasAcctCreated, int64_t stashTransNum=0)
Transactor(OTServer *server)
bool lookupBasketAccountID(const OTIdentifier &basketId, OTIdentifier &basketAccountId)
std::shared_ptr< OTAccount > getVoucherAccount(const OTIdentifier &assetTypeId)
int32_t GetSeries() const
bool removeTransactionNumber(OTPseudonym &nym, const int64_t &transactionNumber, bool save=false)
static EXPORT void Error(const char *szError)
EXPORT void Format(const char *fmt,...)
Mint * getMint(const OTIdentifier &assetTypeId, int32_t seriesCount)
Lookup the current mint for any given asset type ID and series.
EXPORT bool RemoveTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum)
EXPORT bool AddTransactionNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, int64_t lTransNum, bool bSave)
bool removeIssuedNumber(OTPseudonym &nym, const int64_t &transactionNumber, bool save=false)
EXPORT bool RemoveIssuedNum(OTPseudonym &SIGNER_NYM, const OTString &strServerID, const int64_t &lTransNum, bool bSave)
#define OT_ASSERT_MSG(x, s)
virtual EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
bool addAssetContract(OTAssetContract &contract)
OTAssetContract * getAssetContract(const OTIdentifier &id)
EXPORT const char * Get() const
EXPORT bool LoadMint(const char *szAppend=nullptr)
static EXPORT void vOutput(int32_t nVerbosity, const char *szOutput,...)
bool addBasketAccountID(const OTIdentifier &basketId, const OTIdentifier &basketAccountId, const OTIdentifier &basketContractId)
EXPORT bool VerifyTransactionNum(const OTString &strServerID, const int64_t &lTransNum) const