281 std::shared_ptr<OTAccount> account;
282 wasAcctCreated =
false;
285 if (stashTransNum <= 0) {
287 <<
"AccountList::GetOrCreateAccount: Failed attempt to create "
288 "stash account without cron item #.\n";
295 std::string assetTypeIdString = OTString(assetTypeId).Get();
297 OTString acctTypeString;
300 auto acctIDsIt = mapAcctIDs_.find(assetTypeIdString);
302 if (mapAcctIDs_.end() != acctIDsIt) {
304 std::string accountIdString = acctIDsIt->second;
305 auto weakIt = mapWeakAccts_.find(accountIdString);
308 if (mapWeakAccts_.end() != weakIt) {
310 std::shared_ptr<OTAccount> weakAccount(weakIt->second);
326 <<
"AccountList::GetOrCreateAccount: Warning: account ("
328 <<
") was already in memory so I gave you a "
329 "pointer to the existing one. (But who else has a "
340 mapWeakAccts_.erase(weakIt);
347 OTString acctIDString(accountIdString.c_str());
348 OTIdentifier accountID(acctIDString);
352 OTAccount* loadedAccount =
355 if (!loadedAccount) {
356 otErr <<
"Failed trying to load " << acctTypeString
357 <<
" account with account ID: " << acctIDString <<
'\n';
359 else if (!loadedAccount->VerifySignature(serverNym)) {
360 otErr <<
"Failed verifying server's signature on " << acctTypeString
361 <<
" account with account ID: " << acctIDString <<
'\n';
363 else if (!loadedAccount->VerifyOwnerByID(accountOwnerId)) {
364 OTString strOwnerID(accountOwnerId);
365 otErr <<
"Failed verifying owner ID (" << strOwnerID <<
") on "
366 << acctTypeString <<
" account ID: " << acctIDString <<
'\n';
369 otLog3 <<
"Successfully loaded " << acctTypeString
370 <<
" account ID: " << acctIDString
371 <<
" Asset Type ID: " << assetTypeIdString <<
"\n";
373 account = std::shared_ptr<OTAccount>(loadedAccount);
376 mapWeakAccts_[acctIDString.Get()] =
377 std::weak_ptr<OTAccount>(account);
385 accountOwnerId.GetString(message.m_strNymID);
386 assetTypeId.GetString(message.m_strAssetID);
387 serverId.GetString(message.m_strServerID);
390 accountOwnerId, serverId, serverNym, message, acctType_, stashTransNum);
392 if (!createdAccount) {
393 otErr <<
" AccountList::GetOrCreateAccount: Failed trying to generate"
395 <<
" account with asset type ID: " << assetTypeIdString <<
"\n";
398 OTString acctIDString;
399 createdAccount->GetIdentifier(acctIDString);
401 otOut <<
"Successfully created " << acctTypeString
402 <<
" account ID: " << acctIDString
403 <<
" Asset Type ID: " << assetTypeIdString <<
"\n";
405 account = std::shared_ptr<OTAccount>(createdAccount);
409 mapWeakAccts_[acctIDString.Get()] = std::weak_ptr<OTAccount>(account);
411 mapAcctIDs_[message.m_strAssetID.Get()] = acctIDString.Get();
413 wasAcctCreated =
true;
static EXPORT OTAccount * GenerateNewAccount(const OTIdentifier &userId, const OTIdentifier &serverId, const OTPseudonym &serverNym, const OTMessage &message, AccountType acctType=simple, int64_t stashTransNum=0)
OTLOG_IMPORT OTLogStream otOut
OTLOG_IMPORT OTLogStream otLog3
void TranslateAccountTypeToString(OTAccount::AccountType type, OTString &acctType)
OTLOG_IMPORT OTLogStream otErr
static EXPORT OTAccount * LoadExistingAccount(const OTIdentifier &accountId, const OTIdentifier &serverId)