384 server_->m_strWalletFilename.
Get());
389 server_->m_strWalletFilename.
Get()));
391 if (!strFileContents.Exists()) {
392 OTLog::vError(
"%s: Unable to read main file: %s\n", __FUNCTION__,
393 server_->m_strWalletFilename.
Get());
402 bool bNeedToConvertUser =
false;
403 bool bNeedToSaveAgain =
false;
405 bool bFailure =
false;
408 OTStringXML xmlFileContents(strFileContents);
411 xmlFileContents.DecodeIfArmored())
414 OTLog::vError(
"%s: Notary server file apparently was encoded and "
415 "then failed decoding. Filename: %s \n"
417 __FUNCTION__, server_->m_strWalletFilename.
Get(),
418 strFileContents.Get());
422 irr::io::createIrrXMLReader(xmlFileContents);
424 std::unique_ptr<irr::io::IrrXMLReader> theXMLGuardian(xml);
425 while (xml && xml->read()) {
429 OTString AssetContract;
432 const OTString strNodeName(xml->getNodeName());
434 switch (xml->getNodeType()) {
435 case irr::io::EXN_TEXT:
440 case irr::io::EXN_ELEMENT: {
441 if (strNodeName.Compare(
"notaryServer")) {
442 m_strVersion = xml->getAttributeValue(
"version");
443 server_->m_strServerID = xml->getAttributeValue(
"serverID");
444 server_->m_strServerUserID =
445 xml->getAttributeValue(
"serverUserID");
447 OTString strTransactionNumber;
451 strTransactionNumber =
452 xml->getAttributeValue(
"transactionNum");
454 atol(strTransactionNumber.Get()));
458 "\nLoading Open Transactions server. File version: %s\n"
459 " Last Issued Transaction Number: %ld\n Server ID: "
460 " %s\n Server User ID: %s\n",
463 server_->m_strServerID.
Get(),
464 server_->m_strServerUserID.
Get());
466 if (m_strVersion.
Compare(
"1.0"))
471 bNeedToConvertUser =
true;
478 "LoadServerUserAndContract.\n",
492 else if (strNodeName.Compare(
"masterKey") ||
493 strNodeName.Compare(
"cachedKey")) {
494 OTASCIIArmor ascCachedKey;
504 OTPassword tempPassword;
505 tempPassword.zeroMemory();
506 std::shared_ptr<OTCachedKey> sharedPtr(
508 bNeedToSaveAgain = sharedPtr->GetMasterPassword(
509 sharedPtr, tempPassword,
510 "We do not have a check hash yet for this "
512 "please enter your password",
527 if (!m_strVersion.
Compare(
"1.0"))
532 "LoadServerUserAndContract.\n",
538 else if (strNodeName.Compare(
"accountList"))
542 const OTString strAcctType = xml->getAttributeValue(
"type");
543 const OTString strAcctCount =
544 xml->getAttributeValue(
"count");
548 xml, strAcctType, strAcctCount))
550 "%s: Error loading voucher accountList.\n",
553 else if (strNodeName.Compare(
"basketInfo")) {
554 OTString strBasketID = xml->getAttributeValue(
"basketID");
555 OTString strBasketAcctID =
556 xml->getAttributeValue(
"basketAcctID");
557 OTString strBasketContractID =
558 xml->getAttributeValue(
"basketContractID");
560 const OTIdentifier BASKET_ID(strBasketID),
561 BASKET_ACCT_ID(strBasketAcctID),
562 BASKET_CONTRACT_ID(strBasketContractID);
565 BASKET_ID, BASKET_ACCT_ID, BASKET_CONTRACT_ID))
567 "Basket ID: %s\n Basket Acct ID: "
568 "%s\n Basket Contract ID: %s\n",
569 strBasketID.Get(), strBasketAcctID.Get(),
570 strBasketContractID.Get());
573 "Basket ID: %s\n Basket Acct ID: %s\n",
574 strBasketID.Get(), strBasketAcctID.Get());
580 else if (strNodeName.Compare(
"assetType")) {
581 OTASCIIArmor ascAssetName = xml->getAttributeValue(
"name");
583 if (ascAssetName.Exists())
584 ascAssetName.GetString(AssetName,
587 AssetID = xml->getAttributeValue(
591 "listing)\n Name: %s\n Contract ID: %s\n",
592 AssetName.Get(), AssetID.Get());
594 OTString strContractPath;
597 OTAssetContract* pContract =
new OTAssetContract(
598 AssetName, strContractPath, AssetID, AssetID);
601 "ASSERT: allocating memory for Asset "
602 "Contract in MainFile::LoadMainFile\n");
604 if (pContract->LoadContract()) {
605 if (pContract->VerifyContract()) {
608 pContract->SetName(AssetName);
610 server_->transactor_.contractsMap_[AssetID.Get()] =
617 "Asset Contract FAILED to verify.\n");
624 0,
"%s: Failed reading file for Asset Contract.\n",
631 __FUNCTION__, xml->getNodeName());
641 OTString strReason(
"Converting Server Nym to master key.");
642 if (bNeedToConvertUser &&
648 OTString strReason(
"Creating a Hash Check for the master key.");
649 if (bNeedToSaveAgain &&
static EXPORT void vError(const char *szError,...)
bool LoadServerUserAndContract()
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
int64_t transactionNumber() const
EXPORT int32_t ReadFromXMLNode(irr::io::IrrXMLReader *&xml, const OTString &acctType, const OTString &acctCount)
static EXPORT const OTString & Contract()
static EXPORT std::shared_ptr< OTCachedKey > It(OTIdentifier *pIdentifier=nullptr)
EXPORT bool Compare(const char *compare) const
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
#define OT_ASSERT_MSG(x, s)
EXPORT const char * Get() const
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool Savex509CertAndPrivateKey(bool bCreateFile=true, const OTString *pstrReason=nullptr)
static EXPORT void vOutput(int32_t nVerbosity, const char *szOutput,...)
bool addBasketAccountID(const OTIdentifier &basketId, const OTIdentifier &basketAccountId, const OTIdentifier &basketContractId)