133 #include "../core/stdafx.hpp"
137 #include "../cash/Purse.hpp"
139 #include "../core/OTAccount.hpp"
140 #include "../core/OTAssetContract.hpp"
141 #include "../core/crypto/OTCachedKey.hpp"
142 #include "../core/util/OTDataFolder.hpp"
143 #include "../core/util/OTFolders.hpp"
144 #include "../core/OTLog.hpp"
145 #include "../core/crypto/OTPassword.hpp"
146 #include "../core/crypto/OTPasswordData.hpp"
147 #include "../core/OTPseudonym.hpp"
148 #include "../core/OTServerContract.hpp"
149 #include "../core/OTStorage.hpp"
150 #include "../core/crypto/OTSymmetricKey.hpp"
152 #include <irrxml/irrXML.hpp>
160 m_pWithdrawalPurse =
nullptr;
168 void OTWallet::Release()
172 while (!m_mapNyms.empty()) {
180 m_mapNyms.erase(m_mapNyms.begin());
185 while (!m_mapContracts.empty()) {
186 OTAssetContract* pContract = m_mapContracts.begin()->second;
193 m_mapContracts.erase(m_mapContracts.begin());
198 while (!m_mapServers.empty()) {
199 OTServerContract* pContract = m_mapServers.begin()->second;
206 m_mapServers.erase(m_mapServers.begin());
211 while (!m_mapAccounts.empty()) {
212 OTAccount* pAccount = m_mapAccounts.begin()->second;
219 m_mapAccounts.erase(m_mapAccounts.begin());
224 m_mapExtraKeys.clear();
240 m_pWithdrawalPurse = (
Purse*)&thePurse;
247 if (m_pWithdrawalPurse)
delete m_pWithdrawalPurse;
249 m_pWithdrawalPurse =
nullptr;
262 if (
nullptr != pNym) {
277 for (
auto& it : m_mapNyms) {
280 "nullptr pseudonym pointer in OTWallet::GetNymByID.");
285 if (id_CurrentNym == NYM_ID)
return pNym;
296 for (
auto& it : m_mapNyms) {
300 "nullptr pseudonym pointer in OTWallet::GetNymByIDPartialMatch.");
305 std::string strIdentifier = strTemp.
Get();
307 if (strIdentifier.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
313 for (
auto& it : m_mapNyms) {
317 "nullptr pseudonym pointer in OTWallet::GetNymByIDPartialMatch.");
321 std::string str_NymName = strNymName.
Get();
323 if (str_NymName.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
333 return static_cast<int32_t
>(m_mapNyms.size());
338 return static_cast<int32_t
>(m_mapServers.size());
343 return static_cast<int32_t
>(m_mapContracts.size());
348 return static_cast<int32_t
>(m_mapAccounts.size());
356 int32_t iCurrentIndex = (-1);
358 for (
auto& it : m_mapNyms) {
365 if (iIndex == iCurrentIndex) {
382 int32_t iCurrentIndex = (-1);
384 for (
auto& it : m_mapServers) {
391 if (iIndex == iCurrentIndex)
409 int32_t iCurrentIndex = (-1);
411 for (
auto& it : m_mapContracts) {
418 if (iIndex == iCurrentIndex)
436 int32_t iCurrentIndex = (-1);
438 for (
auto& it : m_mapAccounts) {
445 if (iIndex == iCurrentIndex)
460 "\n-------------------------------------------------\n");
465 for (
auto& it : m_mapNyms) {
467 OT_ASSERT_MSG((
nullptr != pNym),
"nullptr pseudonym pointer in "
468 "OTWallet::m_mapNyms, "
469 "OTWallet::DisplayStatistics.");
475 "\n-------------------------------------------------\n");
478 for (
auto& it : m_mapContracts) {
480 OT_ASSERT_MSG(
nullptr != pContract,
"nullptr contract pointer in "
481 "OTWallet::m_mapContracts, "
482 "OTWallet::DisplayStatistics");
488 "-------------------------------------------------\n");
491 for (
auto& it : m_mapServers) {
493 OT_ASSERT_MSG(
nullptr != pServer,
"nullptr server pointer in "
494 "OTWallet::m_mapServers, "
495 "OTWallet::DisplayStatistics");
501 "-------------------------------------------------\n");
504 for (
auto& it : m_mapAccounts) {
506 OT_ASSERT_MSG(
nullptr != pAccount,
"nullptr account pointer in "
507 "OTWallet::m_mapAccounts, "
508 "OTWallet::DisplayStatistics");
513 "-------------------------------------------------\n\n");
530 for (
auto it(m_mapNyms.begin()); it != m_mapNyms.end(); ++it) {
536 if (aNymID == NYM_ID) {
546 if (&theNym != pNym)
delete pNym;
554 m_mapNyms[strNymID.
Get()] =
558 (const_cast<OTPseudonym&>(theNym)).SetNymName(strName);
570 for (
auto it(m_mapAccounts.begin()); it != m_mapAccounts.end(); ++it) {
576 if (anAccountID == ACCOUNT_ID) {
582 m_mapAccounts.erase(it);
590 const OTString strAcctID(ACCOUNT_ID);
600 for (
auto& it : m_mapAccounts) {
607 if (anAccountID == theAccountID)
return pAccount;
619 for (
auto& it : m_mapAccounts) {
626 std::string strIdentifier = strTemp.
Get();
628 if (strIdentifier.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
634 for (
auto& it : m_mapAccounts) {
640 std::string str_Name = strName.
Get();
642 if (str_Name.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
654 for (
auto& it : m_mapAccounts) {
660 return pIssuerAccount;
669 for (
auto& it : m_mapServers) {
671 OT_ASSERT_MSG((
nullptr != pServer),
"nullptr server pointer in "
672 "OTWallet::m_mapServers, "
673 "OTWallet::GetServerContract");
678 if (id_CurrentContract == SERVER_ID)
686 std::string PARTIAL_ID)
688 for (
auto& it : m_mapServers) {
690 OT_ASSERT_MSG((
nullptr != pServer),
"nullptr server pointer in "
691 "OTWallet::m_mapServers, "
692 "OTWallet::GetServerContract");
697 OTString strTemp(id_CurrentContract);
698 std::string strIdentifier = strTemp.
Get();
700 if (strIdentifier.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
706 for (
auto& it : m_mapServers) {
708 OT_ASSERT_MSG((
nullptr != pServer),
"nullptr server pointer in "
709 "OTWallet::m_mapServers, "
710 "OTWallet::GetServerContract");
714 std::string str_Name = strName.
Get();
716 if (str_Name.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
728 OTString STR_CONTRACT_ID(CONTRACT_ID);
733 otErr <<
"Error: Attempt to add Server Contract but it is already in "
740 m_mapServers[STR_CONTRACT_ID.
Get()] =
743 otInfo <<
"Saving server contract to disk...\n";
755 OTString STR_CONTRACT_ID(CONTRACT_ID);
760 otErr <<
"Error: Attempt to add Asset Contract but it is already in "
767 m_mapContracts[STR_CONTRACT_ID.
Get()] =
770 otInfo <<
"Saving asset contract to disk...\n";
780 const char* szFuncName)
783 (
nullptr != szFuncName) ? szFuncName :
"OTWallet::VerifyAssetAccount";
787 otOut <<
"OTWallet::VerifyAssetAccount " << szFunc
788 <<
": Server ID passed in (" << s1 <<
") didn't match the one "
789 "on the account (" << s2
790 <<
"). Acct ID: " << strAcctID <<
"\n";
799 otOut <<
"OTWallet::VerifyAssetAccount " << szFunc
800 <<
": Nym (ID: " << strNymID
801 <<
") is not the owner of the account: " << strAcctID <<
"\n";
808 otOut <<
"OTWallet::VerifyAssetAccount " << szFunc
809 <<
": Account signature or AccountID fails to verify. "
810 "NymID: " << strNymID <<
" AcctID: " << strAcctID <<
"\n";
825 const char* szFuncName)
828 (
nullptr != szFuncName) ? szFuncName :
"OTWallet::GetOrLoadAccount";
837 otOut <<
"OTWallet::GetOrLoadAccount " << szFunc
838 <<
": There's no asset account in the wallet with that ID ("
839 << strAcctID <<
"). "
840 "Attempting to load it from storage...\n";
841 pAccount =
LoadAccount(theNym, ACCT_ID, SERVER_ID, szFuncName);
846 if (
nullptr == pAccount)
848 otErr <<
"OTWallet::GetOrLoadAccount " << szFunc
849 <<
": Error loading Asset Account: " << strAcctID <<
"\n";
866 const char* szFuncName)
869 (
nullptr != szFuncName) ? szFuncName :
"OTWallet::LoadAccount";
876 if (
nullptr != pAccount)
899 otErr <<
"OTWallet::LoadAccount " << szFunc
900 <<
": Failed loading Asset Account: " << strAcctID <<
"\n";
911 const char* szFuncName)
914 const char* szFunc =
"OTWallet::GetOrLoadPublicNym";
916 szFuncName = (szFuncName ==
nullptr) ?
"" : szFuncName;
922 otWarn << szFunc <<
" " << szFuncName
923 <<
": There's no Nym already loaded with that ID. "
924 "Attempting to load public key...\n";
935 otOut << szFunc <<
" " << szFuncName
936 <<
": Unable to load public Nym for: " << strNymID <<
" \n";
942 if ((
nullptr != pNym) && (
false == pNym->
HasPublicKey()))
943 otErr << szFunc <<
" " << szFuncName <<
": Found nym (" << strNymID
944 <<
"), but he has no public key. "
945 "(Still returning the Nym, since it exists.)\n";
958 const char* szFuncName,
963 otErr << __FUNCTION__ <<
":" << szFuncName
964 <<
": Error: NYM_ID passed in empty, returning null";
970 if (
nullptr == pPWData) pPWData = &thePWData;
972 szFuncName = (szFuncName ==
nullptr) ?
"" : szFuncName;
982 otWarn << __FUNCTION__ <<
" " << szFuncName
983 <<
": There's no Nym already loaded with that ID. "
984 "Attempting to load private key...\n";
987 pPWData, pImportPassword);
994 otLog << __FUNCTION__ <<
": " << szFuncName <<
": ("
996 <<
": is " << (bChecking ?
"true" :
"false")
997 <<
"). Unable to load Private Nym for: " << strNymID <<
"\n";
1005 if (
nullptr != pNym)
1010 otErr << __FUNCTION__ <<
" " << szFuncName
1011 <<
": Found nym, but he has no public key: " << strNymID
1021 << __FUNCTION__ <<
" " << szFuncName
1022 <<
": Found nym in wallet (" << strNymID
1024 "but he currently has no private key loaded. Reloading...\n";
1044 pPWData, pImportPassword);
1050 otOut << __FUNCTION__ <<
" " << szFuncName
1051 <<
": Unable to load private Nym for: " << strNymID
1055 otErr << __FUNCTION__ <<
" " << szFuncName <<
": Found nym ("
1056 << strNymID <<
"), but he had no private key. Then tried "
1057 "to remove him from wallet (in order "
1058 "to reload him with private key) and then "
1059 "the removal failed. Sorry.\n";
1074 const char* szFuncName,
1086 if (
nullptr == pNym)
1088 nullptr == pPWData ? &thePWData : pPWData);
1103 for (
auto it(m_mapNyms.begin()); it != m_mapNyms.end(); ++it) {
1106 "nullptr pseudonym pointer in OTWallet::RemoveNym.");
1115 for (
const auto& it_master : m_setNymsOnCachedKey) {
1117 if (theTargetID == theNymID) {
1118 m_setNymsOnCachedKey.erase(it_master);
1123 m_mapNyms.erase(it);
1137 for (
auto it(m_mapContracts.begin()); it != m_mapContracts.end(); ++it) {
1143 if (aContractID == theTargetID) {
1144 m_mapContracts.erase(it);
1157 for (
auto it(m_mapServers.begin()); it != m_mapServers.end(); ++it) {
1159 OT_ASSERT_MSG((
nullptr != pServer),
"nullptr server pointer in "
1160 "OTWallet::m_mapServers, "
1161 "OTWallet::RemoveServerContract");
1166 if (id_CurrentContract == theTargetID) {
1167 m_mapServers.erase(it);
1171 delete pServerContract;
1187 for (
auto it(m_mapAccounts.begin()); it != m_mapAccounts.end(); ++it) {
1193 if (anAccountID == theTargetID) {
1194 m_mapAccounts.erase(it);
1205 for (
auto& it : m_mapContracts) {
1212 if (aContractID == theContractID)
return pContract;
1219 std::string PARTIAL_ID)
1221 for (
auto& it : m_mapContracts) {
1229 std::string strIdentifier = strTemp.
Get();
1231 if (strIdentifier.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
1237 for (
auto& it : m_mapContracts) {
1243 std::string str_Name = strName.
Get();
1245 if (str_Name.compare(0, PARTIAL_ID.length(), PARTIAL_ID) == 0)
1263 "<?xml version=\"1.0\"?>\n<wallet name=\"%s\" version=\"%s\">\n\n",
1272 strContract.
Concatenate(
"<cachedKey>\n%s</cachedKey>\n\n",
1273 ascMasterContents.
Get());
1276 otErr <<
"OTWallet::SaveContract: Failed trying to write master "
1284 for (
auto& it : m_mapExtraKeys) {
1285 const std::string str_id = it.first;
1286 std::shared_ptr<OTSymmetricKey> pKey = it.second;
1296 if (pKey && pKey->SerializeTo(ascKeyContents)) {
1298 "<symmetricKey id=\"%s\">\n%s</symmetricKey>\n\n",
1299 ascKeyID.Get(), ascKeyContents.
Get());
1302 otErr <<
"OTWallet::SaveContract: Failed trying to serialize "
1303 "symmetric keys to wallet.\n";
1311 for (
const auto& it : m_setNymsOnCachedKey) {
1315 strContract.
Concatenate(
"<nymUsingCachedKey id=\"%s\" />\n\n",
1319 for (
auto& it : m_mapNyms) {
1321 OT_ASSERT_MSG(
nullptr != pNym,
"nullptr pseudonym pointer in "
1322 "OTWallet::m_mapNyms, "
1323 "OTWallet::SaveContract");
1328 for (
auto& it : m_mapContracts) {
1330 OT_ASSERT_MSG(
nullptr != pContract,
"nullptr contract pointer in "
1331 "OTWallet::m_mapContracts, "
1332 "OTWallet::SaveContract");
1337 for (
auto& it : m_mapServers) {
1339 OT_ASSERT_MSG(
nullptr != pServer,
"nullptr server pointer in "
1340 "OTWallet::m_mapServers, "
1341 "OTWallet::SaveContract");
1346 for (
auto& it : m_mapAccounts) {
1348 OT_ASSERT_MSG(
nullptr != pAccount,
"nullptr account pointer in "
1349 "OTWallet::m_mapAccounts, "
1350 "OTWallet::SaveContract");
1369 const std::string& str_KeyID,
const std::string* pReason)
1378 std::shared_ptr<OTSymmetricKey> pExtraKey =
getExtraKey(str_KeyID);
1392 const bool bGotMasterPW = pMasterKey->GetMasterPassword(
1393 pMasterKey, master_password,
1394 (
nullptr == pReason) ?
"" : pReason->c_str());
1399 &master_password)) {
1400 std::shared_ptr<OTSymmetricKey> pNewExtraKey(
1404 pNewExtraKey->SerializeFrom(strNewKeyOutput) &&
1407 pExtraKey = pNewExtraKey;
1417 if (pExtraKey)
return pExtraKey;
1419 return std::shared_ptr<OTSymmetricKey>();
1436 for (
auto& it : m_mapExtraKeys) {
1437 const std::string str_id = it.first;
1438 std::shared_ptr<OTSymmetricKey> pOldKey = it.second;
1442 if (pOldKey && pOldKey->SerializeTo(thePayload)) {
1445 if (pNewKey && pNewKey->SerializeFrom(thePayload))
1447 std::pair<std::string, std::shared_ptr<OTSymmetricKey>>(
1461 for (
auto& it : mapChanged) {
1462 std::shared_ptr<OTSymmetricKey> pNewKey = it.second;
1465 if (!pNewKey->ChangePassphrase(oldPassphrase, newPassphrase))
1476 m_mapExtraKeys.clear();
1477 m_mapExtraKeys = mapChanged;
1487 if (key_id.empty() || !strPlaintext.
Exists())
return false;
1489 std::string str_Reason((
nullptr != pstrDisplay) ? pstrDisplay->
Get() :
"");
1491 std::shared_ptr<OTSymmetricKey> pKey =
1500 if (pMasterKey->GetMasterPassword(pMasterKey, master_password))
1502 pstrDisplay, bBookends,
1512 if (key_id.empty() || !strCiphertext.
Exists())
return false;
1522 if (pMasterKey->GetMasterPassword(pMasterKey, master_password))
1524 pstrDisplay, &master_password);
1532 if (str_id.empty())
return std::shared_ptr<OTSymmetricKey>();
1534 auto it = m_mapExtraKeys.find(str_id);
1536 if (it != m_mapExtraKeys.end())
1538 std::shared_ptr<OTSymmetricKey> pKey = it->second;
1543 return std::shared_ptr<OTSymmetricKey>();
1547 std::shared_ptr<OTSymmetricKey> pKey)
1549 if (str_id.empty() || !pKey)
return false;
1551 auto it = m_mapExtraKeys.find(str_id);
1553 if (it != m_mapExtraKeys.end())
1556 m_mapExtraKeys.insert(
1557 std::pair<std::string, std::shared_ptr<OTSymmetricKey>>(str_id, pKey));
1571 otErr << __FUNCTION__ <<
": Filename Dosn't Exist!\n";
1575 bool bSuccess =
false;
1588 otErr <<
"OTWallet::SaveWallet: Error saving wallet (failed "
1597 strFinal.
Get(),
".",
1620 "OTWallet::LoadWallet: nullptr filename.\n");
1643 otErr << __FUNCTION__ <<
": Wallet file does not exist: " << szFilename
1644 <<
". Creating...\n";
1646 const char* szContents =
"<?xml version=\"1.0\"?>\n"
1647 "<wallet name=\"\" version=\"1.0\">\n"
1652 otErr << __FUNCTION__
1653 <<
": Error: Unable to create blank wallet file.\n";
1661 if (!strFileContents.
Exists()) {
1662 otErr << __FUNCTION__ <<
": Error reading wallet file: " << szFilename
1667 bool bNeedToSaveAgain =
false;
1673 otErr << __FUNCTION__
1674 <<
": Input string apparently was encoded and then failed "
1675 "decoding. Filename: " << szFilename <<
" \n"
1677 << strFileContents <<
"\n";
1682 irr::io::createIrrXMLReader(xmlFileContents);
1685 while (xml && xml->read()) {
1702 const OTString strNodeName(xml->getNodeName());
1704 switch (xml->getNodeType()) {
1705 case irr::io::EXN_NONE:
1706 case irr::io::EXN_TEXT:
1707 case irr::io::EXN_COMMENT:
1708 case irr::io::EXN_ELEMENT_END:
1709 case irr::io::EXN_CDATA:
1714 case irr::io::EXN_ELEMENT: {
1715 if (strNodeName.Compare(
"wallet")) {
1716 OTASCIIArmor ascWalletName = xml->getAttributeValue(
"name");
1718 if (ascWalletName.
Exists())
1726 m_strVersion = xml->getAttributeValue(
"version");
1728 otWarn <<
"\nLoading wallet: " << m_strName
1729 <<
", version: " << m_strVersion <<
"\n";
1735 else if (strNodeName.Compare(
"masterKey") ||
1736 strNodeName.Compare(
"cachedKey")) {
1750 std::shared_ptr<OTCachedKey> sharedPtr(
1753 bNeedToSaveAgain = sharedPtr->GetMasterPassword(
1754 sharedPtr, tempPassword,
1755 "We do not have a check hash yet for this "
1756 "password, please enter your password",
1761 otWarn <<
"Loading cachedKey:\n" << ascCachedKey <<
"\n";
1767 else if (strNodeName.Compare(
"nymUsingMasterKey") ||
1768 strNodeName.Compare(
"nymUsingCachedKey")) {
1769 NymID = xml->getAttributeValue(
"id");
1773 otWarn <<
"NymID using Cached Key: " << NymID <<
"\n";
1774 if (!NymID.Exists()) {
1775 otErr << __FUNCTION__ <<
": NymID using Cached Key was "
1776 "empty when loading wallet!\n";
1782 m_setNymsOnCachedKey.insert(theNymID);
1784 else if (strNodeName.Compare(
"symmetricKey")) {
1789 if (!ascKeyID.
Exists() ||
1793 otErr << __FUNCTION__ <<
": Failed loading "
1794 "symmetricKey ID (it was "
1798 xml, ascSymmetricKey)) {
1799 std::shared_ptr<OTSymmetricKey> pKey(
1802 if (!pKey || !pKey->SerializeFrom(ascSymmetricKey))
1803 otErr << __FUNCTION__
1804 <<
": Failed serializing symmetricKey from "
1805 "string (id: " << strKeyID <<
")\n";
1807 const std::string str_id(strKeyID.
Get());
1810 otErr << __FUNCTION__
1811 <<
": Failed adding serialized "
1812 "symmetricKey to wallet (id: "
1813 << strKeyID <<
")\n";
1817 else if (strNodeName.Compare(
"pseudonym")) {
1818 OTASCIIArmor ascNymName = xml->getAttributeValue(
"name");
1823 NymID = xml->getAttributeValue(
"nymID");
1828 otInfo <<
"\n\n** Pseudonym ** (wallet listing): "
1829 << NymName <<
"\nID: " << NymID <<
"\n";
1830 if (!NymID.Exists()) {
1831 otErr << __FUNCTION__ <<
": NymID dosn't Exist!\n";
1847 const bool bIsOldStyleNym =
1862 if (
nullptr == pNym)
1865 if (
nullptr == pNym)
1866 otOut << __FUNCTION__ <<
": Failed loading Nym ("
1867 << NymName <<
") with ID: " << NymID <<
"\n";
1883 else if (strNodeName.Compare(
"assetType")) {
1885 OTASCIIArmor ascAssetName = xml->getAttributeValue(
"name");
1887 if (ascAssetName.
Exists())
1893 AssetID = xml->getAttributeValue(
1896 otInfo <<
"\n\n****Asset Contract**** (wallet listing)\n "
1897 "Asset Name: " << AssetName
1898 <<
"\n Contract ID: " << AssetID <<
"\n";
1903 AssetName, strContractPath, AssetID, AssetID);
1906 "Error allocating memory "
1907 "for Asset Contract in "
1908 "OTWallet::LoadWallet\n");
1912 otWarn <<
"** Asset Contract Verified "
1913 "**\n------------------------------------"
1914 "----------------------------------------"
1917 pContract->
SetName(AssetName);
1919 m_mapContracts[AssetID.Get()] = pContract;
1923 pContract =
nullptr;
1924 otOut <<
"Contract FAILED to verify.\n";
1929 pContract =
nullptr;
1930 otErr << __FUNCTION__
1931 <<
": Error reading file for Asset Contract.\n";
1935 else if (strNodeName.Compare(
"notaryProvider")) {
1936 OTASCIIArmor ascServerName = xml->getAttributeValue(
"name");
1938 if (ascServerName.
Exists())
1945 xml->getAttributeValue(
"serverID");
1947 otInfo <<
"\n\n\n****Server Contract**** (wallet "
1948 "listing):\n Server Name: " << ServerName
1949 <<
"\n Server ID: " << ServerID <<
"\n";
1954 ServerName, strContractPath, ServerID, ServerID);
1957 "Error allocating memory "
1958 "for Server Contract in "
1959 "OTWallet::LoadWallet\n");
1963 pContract->
SetName(ServerName);
1967 otWarn <<
"** Server Contract Verified "
1968 "**\n------------------------------------"
1969 "----------------------------------------"
1975 m_mapServers[ServerID.Get()] = pContract;
1979 pContract =
nullptr;
1980 otOut << __FUNCTION__
1981 <<
": Server contract failed to verify.\n";
1986 pContract =
nullptr;
1989 <<
": Error reading file for Transaction Server.\n";
1992 else if (strNodeName.Compare(
"assetAccount")) {
1993 OTASCIIArmor ascAcctName = xml->getAttributeValue(
"name");
1995 if (ascAcctName.
Exists())
1999 AcctID = xml->getAttributeValue(
"accountID");
2000 ServerID = xml->getAttributeValue(
"serverID");
2002 otInfo <<
"\n----------------------------------------------"
2003 "----------------------------\n"
2004 "****Account**** (wallet listing)\n"
2005 " Account Name: " << AcctName
2006 <<
"\n Account ID: " << AcctID
2007 <<
"\n Server ID: " << ServerID <<
"\n";
2009 const OTIdentifier ACCOUNT_ID(AcctID), SERVER_ID(ServerID);
2019 otErr << __FUNCTION__
2020 <<
": Error loading existing Asset Account.\n";
2025 otErr << __FUNCTION__
2026 <<
": unknown element type: " << xml->getNodeName()
2032 <<
": Unknown XML type: " << xml->getNodeName() <<
"\n";
2042 for (
auto& it : m_mapNyms) {
2046 "ASSERT: OTWallet::LoadWallet: nullptr pseudonym pointer.");
2052 bNeedToSaveAgain =
true;
2057 if (xml)
delete xml;
2061 if (bNeedToSaveAgain)
SaveWallet(szFilename);
2071 bool bConverted =
false;
2075 OTString strNymID, strCredList, strOutput;
2082 strFilename.
Format(
"%s.cred", strNymID.
Get());
2088 "CREDENTIAL LIST") &&
2092 strFilename.
Get())) {
2093 otErr << __FUNCTION__ <<
": Failure trying to store "
2095 <<
" credential list for Nym: " << strNymID <<
"\n";
2101 for (
auto& it : mapCredFiles) {
2102 std::string str_cred_id = it.first;
2107 if (ascLoopArmor.
Exists() &&
2115 strNymID.
Get(), str_cred_id)) {
2116 otErr << __FUNCTION__ <<
": Failure trying to store "
2118 <<
" credential for Nym: " << strNymID <<
"\n";
2127 OTString strReason(
"Converting Nym to cached master key.");
2132 m_setNymsOnCachedKey.insert(theNym.
GetConstID());
2150 for (
const auto& it : m_setNymsOnCachedKey) {
2151 if (needle == it)
return true;
EXPORT bool GetNym(int32_t iIndex, OTIdentifier &NYM_ID, OTString &NYM_NAME)
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT OTPseudonym * GetOrLoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr)
std::map< std::string, std::string > Map
static EXPORT OTPseudonym * LoadPublicNym(const OTIdentifier &NYM_ID, const OTString *pstrName=nullptr, const char *szFuncName=nullptr)
EXPORT OTAccount * GetOrLoadAccount(const OTPseudonym &theNym, const OTIdentifier &ACCT_ID, const OTIdentifier &SERVER_ID, const char *szFuncName=nullptr)
EXPORT int32_t GetAccountCount()
EXPORT bool IsNymOnCachedKey(const OTIdentifier &needle) const
EXPORT bool Encrypt_ByKeyID(const std::string &key_id, const OTString &strPlaintext, OTString &strOutput, const OTString *pstrDisplay=nullptr, bool bBookends=true)
EXPORT bool ChangePassphrasesOnExtraKeys(const OTPassword &oldPassphrase, const OTPassword &newPassphrase)
EXPORT std::shared_ptr< OTSymmetricKey > getOrCreateExtraKey(const std::string &str_KeyID, const std::string *pReason=nullptr)
virtual EXPORT bool DisplayStatistics(OTString &contents) const
EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
EXPORT OTAccount * GetAccountPartialMatch(std::string PARTIAL_ID)
std::map< std::string, std::shared_ptr< OTSymmetricKey > > mapOfSymmetricKeys
EXPORT const OTIdentifier & GetAssetTypeID() const
EXPORT OTAssetContract * GetAssetContract(const OTIdentifier &theContractID)
virtual EXPORT bool DisplayStatistics(OTString &strContents) const
static EXPORT const char * PathSeparator()
EXPORT void AddServerContract(const OTServerContract &theContract)
EXPORT void GetName(OTString &strName) const
EXPORT void AddPendingWithdrawal(const Purse &thePurse)
EXPORT bool SavePseudonymWallet(OTString &strOutput) const
bool VerifyAssetAccount(const OTPseudonym &theNym, OTAccount &theAcct, const OTIdentifier &SERVER_ID, const OTString &strAcctID, const char *szFuncName=nullptr)
EXPORT void GetPrivateCredentials(OTString &strCredList, OTString::Map *pmapCredFiles=nullptr)
EXPORT OTPseudonym * GetNymByIDPartialMatch(std::string PARTIAL_ID)
OTLOG_IMPORT OTLogStream otOut
EXPORT void AddAssetContract(const OTAssetContract &theContract)
EXPORT OTPseudonym * GetOrLoadNym(const OTIdentifier &NYM_ID, bool bChecking=false, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr)
EXPORT void DisplayStatistics(OTString &strOutput)
EXPORT bool GetAccount(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT OTAccount * GetIssuerAccount(const OTIdentifier &theAssetTypeID)
EXPORT int32_t GetAssetTypeCount()
EXPORT void Concatenate(const char *arg,...)
EXPORT bool IsIssuer() const
EXPORT bool WriteArmoredString(OTString &strOutput, const std::string str_type, bool bEscaped=false) const
static EXPORT const OTString & Contract()
EXPORT bool SignContractWithFirstNymOnList(OTContract &theContract)
EXPORT bool DecodeIfArmored(bool escapedIsAllowed=true)
EXPORT bool Exists() const
EXPORT bool SetString(const OTString &theData, bool bLineBreaks=true)
static EXPORT std::shared_ptr< OTCachedKey > It(OTIdentifier *pIdentifier=nullptr)
EXPORT bool RemoveAssetContract(const OTIdentifier &theTargetID)
EXPORT bool RemoveNym(const OTIdentifier &theTargetID)
EXPORT std::shared_ptr< OTSymmetricKey > getExtraKey(const std::string &str_id)
EXPORT void Format(const char *fmt,...)
void RemovePendingWithdrawal()
EXPORT bool addExtraKey(const std::string &str_id, std::shared_ptr< OTSymmetricKey > pKey)
static EXPORT bool Decrypt(const OTString &strKey, OTString &strCiphertext, OTString &strOutput, const OTString *pstrDisplay=nullptr, const OTPassword *pAlreadyHavePW=nullptr)
static EXPORT const OTString & Credential()
EXPORT bool VerifyOwner(const OTPseudonym &candidate) const
EXPORT bool ConvertNymToCachedKey(OTPseudonym &theNym)
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
EXPORT int32_t GetServerCount()
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT OTPseudonym * GetNymByID(const OTIdentifier &NYM_ID)
static EXPORT bool Encrypt(const OTString &strKey, const OTString &strPlaintext, OTString &strOutput, const OTString *pstrDisplay=nullptr, bool bBookends=true, const OTPassword *pAlreadyHavePW=nullptr)
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
EXPORT bool LoadWallet(const char *szFilename=nullptr)
EXPORT bool RemoveAccount(const OTIdentifier &theTargetID)
EXPORT bool Decrypt_ByKeyID(const std::string &key_id, const OTString &strCiphertext, OTString &strOutput, const OTString *pstrDisplay=nullptr)
EXPORT OTAssetContract * GetAssetContractPartialMatch(std::string PARTIAL_ID)
EXPORT bool HasPublicKey()
#define OT_ASSERT_MSG(x, s)
OTLOG_IMPORT OTLogStream otInfo
virtual EXPORT bool LoadContract()
EXPORT OTAccount * LoadAccount(const OTPseudonym &theNym, const OTIdentifier &ACCT_ID, const OTIdentifier &SERVER_ID, const char *szFuncName=nullptr)
EXPORT bool CompareID(const OTIdentifier &theIdentifier) const
static EXPORT OTPseudonym * LoadPrivateNym(const OTIdentifier &NYM_ID, bool bChecking=false, const OTString *pstrName=nullptr, const char *szFuncName=nullptr, const OTPasswordData *pPWData=nullptr, const OTPassword *pImportPassword=nullptr)
EXPORT bool SaveWallet(const char *szFilename=nullptr)
virtual EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
EXPORT bool HasPrivateKey()
OTLOG_IMPORT OTLogStream otWarn
EXPORT const char * Get() const
virtual EXPORT bool SignContract(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
OTLOG_IMPORT OTLogStream otErr
virtual bool VerifyAccount(const OTPseudonym &theNym)
EXPORT void DisplayStatistics(OTString &strOutput)
EXPORT const OTIdentifier & GetConstID() const
virtual EXPORT bool VerifyContract()
EXPORT bool GetServer(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool IsEmpty() const
EXPORT OTServerContract * GetServerContractPartialMatch(std::string PARTIAL_ID)
EXPORT bool GetString(OTString &theData, bool bLineBreaks=true) const
EXPORT bool Savex509CertAndPrivateKey(bool bCreateFile=true, const OTString *pstrReason=nullptr)
EXPORT OTServerContract * GetServerContract(const OTIdentifier &SERVER_ID)
EXPORT size_t GetMasterCredentialCount() const
EXPORT int32_t GetNymCount()
static EXPORT OTAccount * LoadExistingAccount(const OTIdentifier &accountId, const OTIdentifier &serverId)
static EXPORT bool CreateNewKey(OTString &strOutput, const OTString *pstrDisplay=nullptr, const OTPassword *pAlreadyHavePW=nullptr)
EXPORT void AddNym(const OTPseudonym &theNym)
virtual EXPORT void Release()
bool SaveContract(OTString &strContract)
const OTIdentifier & GetRealServerID() const
EXPORT void AddAccount(const OTAccount &theAcct)
EXPORT OTPseudonym * GetOrLoadPublicNym(const OTIdentifier &NYM_ID, const char *szFuncName=nullptr)
EXPORT bool RemoveServerContract(const OTIdentifier &theTargetID)
virtual bool SaveContractWallet(std::ofstream &ofs) const =0
OTLOG_IMPORT OTLogStream otLog5
EXPORT void SetName(const OTString &strName)
EXPORT bool GetAssetType(int32_t iIndex, OTIdentifier &THE_ID, OTString &THE_NAME)