1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
10 #include "serialize.h"
14 #include <boost/filesystem.hpp>
15 #include <boost/foreach.hpp>
18 using namespace boost;
21 static uint64_t nAccountingEntryNumber = 0;
27 bool CWalletDB::WriteName(const string& strAddress, const string& strName)
30 return Write(make_pair(string("name"), strAddress), strName);
33 bool CWalletDB::EraseName(const string& strAddress)
35 // This should only be used for sending addresses, never for receiving addresses,
36 // receiving addresses must always have an address book entry if they're not change return.
38 return Erase(make_pair(string("name"), strAddress));
41 bool CWalletDB::WritePurpose(const string& strAddress, const string& strPurpose)
44 return Write(make_pair(string("purpose"), strAddress), strPurpose);
47 bool CWalletDB::ErasePurpose(const string& strPurpose)
50 return Erase(make_pair(string("purpose"), strPurpose));
53 bool CWalletDB::WriteTx(uint256 hash, const CWalletTx& wtx)
56 return Write(std::make_pair(std::string("tx"), hash), wtx);
59 bool CWalletDB::EraseTx(uint256 hash)
62 return Erase(std::make_pair(std::string("tx"), hash));
65 bool CWalletDB::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata& keyMeta)
69 if (!Write(std::make_pair(std::string("keymeta"), vchPubKey),
73 // hash pubkey/privkey to accelerate wallet load
74 std::vector<unsigned char> vchKey;
75 vchKey.reserve(vchPubKey.size() + vchPrivKey.size());
76 vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end());
77 vchKey.insert(vchKey.end(), vchPrivKey.begin(), vchPrivKey.end());
79 return Write(std::make_pair(std::string("key"), vchPubKey), std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false);
82 bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey,
83 const std::vector<unsigned char>& vchCryptedSecret,
84 const CKeyMetadata &keyMeta)
86 const bool fEraseUnencryptedKey = true;
89 if (!Write(std::make_pair(std::string("keymeta"), vchPubKey),
93 if (!Write(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false))
95 if (fEraseUnencryptedKey)
97 Erase(std::make_pair(std::string("key"), vchPubKey));
98 Erase(std::make_pair(std::string("wkey"), vchPubKey));
103 bool CWalletDB::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey)
106 return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true);
109 bool CWalletDB::WriteCScript(const uint160& hash, const CScript& redeemScript)
112 return Write(std::make_pair(std::string("cscript"), hash), redeemScript, false);
115 bool CWalletDB::WriteBestBlock(const CBlockLocator& locator)
118 return Write(std::string("bestblock"), locator);
121 bool CWalletDB::ReadBestBlock(CBlockLocator& locator)
123 return Read(std::string("bestblock"), locator);
126 bool CWalletDB::WriteOrderPosNext(int64_t nOrderPosNext)
129 return Write(std::string("orderposnext"), nOrderPosNext);
132 bool CWalletDB::WriteDefaultKey(const CPubKey& vchPubKey)
135 return Write(std::string("defaultkey"), vchPubKey);
138 bool CWalletDB::ReadPool(int64_t nPool, CKeyPool& keypool)
140 return Read(std::make_pair(std::string("pool"), nPool), keypool);
143 bool CWalletDB::WritePool(int64_t nPool, const CKeyPool& keypool)
146 return Write(std::make_pair(std::string("pool"), nPool), keypool);
149 bool CWalletDB::ErasePool(int64_t nPool)
152 return Erase(std::make_pair(std::string("pool"), nPool));
155 bool CWalletDB::WriteMinVersion(int nVersion)
157 return Write(std::string("minversion"), nVersion);
160 bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account)
163 return Read(make_pair(string("acc"), strAccount), account);
166 bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account)
168 return Write(make_pair(string("acc"), strAccount), account);
171 bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry)
173 return Write(boost::make_tuple(string("acentry"), acentry.strAccount, nAccEntryNum), acentry);
176 bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
178 return WriteAccountingEntry(++nAccountingEntryNumber, acentry);
181 int64_t CWalletDB::GetAccountCreditDebit(const string& strAccount)
183 list<CAccountingEntry> entries;
184 ListAccountCreditDebit(strAccount, entries);
186 int64_t nCreditDebit = 0;
187 BOOST_FOREACH (const CAccountingEntry& entry, entries)
188 nCreditDebit += entry.nCreditDebit;
193 void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)
195 bool fAllAccounts = (strAccount == "*");
197 Dbc* pcursor = GetCursor();
199 throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
200 unsigned int fFlags = DB_SET_RANGE;
204 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
205 if (fFlags == DB_SET_RANGE)
206 ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64_t(0));
207 CDataStream ssValue(SER_DISK, CLIENT_VERSION);
208 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
210 if (ret == DB_NOTFOUND)
215 throw runtime_error("CWalletDB::ListAccountCreditDebit() : error scanning DB");
221 if (strType != "acentry")
223 CAccountingEntry acentry;
224 ssKey >> acentry.strAccount;
225 if (!fAllAccounts && acentry.strAccount != strAccount)
229 ssKey >> acentry.nEntryNo;
230 entries.push_back(acentry);
238 CWalletDB::ReorderTransactions(CWallet* pwallet)
240 LOCK(pwallet->cs_wallet);
241 // Old wallets didn't have any defined order for transactions
242 // Probably a bad idea to change the output of this
244 // First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap.
245 typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
246 typedef multimap<int64_t, TxPair > TxItems;
249 for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it)
251 CWalletTx* wtx = &((*it).second);
252 txByTime.insert(make_pair(wtx->nTimeReceived, TxPair(wtx, (CAccountingEntry*)0)));
254 list<CAccountingEntry> acentries;
255 ListAccountCreditDebit("", acentries);
256 BOOST_FOREACH(CAccountingEntry& entry, acentries)
258 txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
261 int64_t& nOrderPosNext = pwallet->nOrderPosNext;
263 std::vector<int64_t> nOrderPosOffsets;
264 for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it)
266 CWalletTx *const pwtx = (*it).second.first;
267 CAccountingEntry *const pacentry = (*it).second.second;
268 int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos;
272 nOrderPos = nOrderPosNext++;
273 nOrderPosOffsets.push_back(nOrderPos);
276 // Have to write accounting regardless, since we don't keep it in memory
277 if (!WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
282 int64_t nOrderPosOff = 0;
283 BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets)
285 if (nOrderPos >= nOffsetStart)
288 nOrderPos += nOrderPosOff;
289 nOrderPosNext = std::max(nOrderPosNext, nOrderPos + 1);
294 // Since we're changing the order, write it back
297 if (!WriteTx(pwtx->GetHash(), *pwtx))
301 if (!WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
309 class CWalletScanState {
313 unsigned int nKeyMeta;
317 vector<uint256> vWalletUpgrade;
320 nKeys = nCKeys = nKeyMeta = 0;
321 fIsEncrypted = false;
322 fAnyUnordered = false;
328 ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
329 CWalletScanState &wss, string& strType, string& strErr)
333 // Taking advantage of the fact that pair serialization
334 // is just the two items serialized one after the other
336 if (strType == "name")
340 ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()].name;
342 else if (strType == "purpose")
346 ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()].purpose;
348 else if (strType == "tx")
354 CValidationState state;
355 if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid()))
358 // Undo serialize changes in 31600
359 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
361 if (!ssValue.empty())
365 ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
366 strErr = strprintf("LoadWallet() upgrading tx ver=%d %d '%s' %s",
367 wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount, hash.ToString());
368 wtx.fTimeReceivedIsTxTime = fTmp;
372 strErr = strprintf("LoadWallet() repairing tx ver=%d %s", wtx.fTimeReceivedIsTxTime, hash.ToString());
373 wtx.fTimeReceivedIsTxTime = 0;
375 wss.vWalletUpgrade.push_back(hash);
378 if (wtx.nOrderPos == -1)
379 wss.fAnyUnordered = true;
381 pwallet->AddToWallet(wtx, true);
383 //LogPrintf("LoadWallet %s\n", wtx.GetHash().ToString());
384 //LogPrintf(" %12d %s %s %s\n",
385 // wtx.vout[0].nValue,
386 // DateTimeStrFormat("%Y-%m-%d %H:%M:%S", wtx.GetBlockTime()),
387 // wtx.hashBlock.ToString(),
388 // wtx.mapValue["message"]);
390 else if (strType == "acentry")
396 if (nNumber > nAccountingEntryNumber)
397 nAccountingEntryNumber = nNumber;
399 if (!wss.fAnyUnordered)
401 CAccountingEntry acentry;
403 if (acentry.nOrderPos == -1)
404 wss.fAnyUnordered = true;
407 else if (strType == "key" || strType == "wkey")
411 if (!vchPubKey.IsValid())
413 strErr = "Error reading wallet database: CPubKey corrupt";
420 if (strType == "key")
427 pkey = wkey.vchPrivKey;
430 // Old wallets store keys as "key" [pubkey] => [privkey]
431 // ... which was slow for wallets with lots of keys, because the public key is re-derived from the private key
432 // using EC operations as a checksum.
433 // Newer wallets store keys as "key"[pubkey] => [privkey][hash(pubkey,privkey)], which is much faster while
434 // remaining backwards-compatible.
441 bool fSkipCheck = false;
445 // hash pubkey/privkey to accelerate wallet load
446 std::vector<unsigned char> vchKey;
447 vchKey.reserve(vchPubKey.size() + pkey.size());
448 vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end());
449 vchKey.insert(vchKey.end(), pkey.begin(), pkey.end());
451 if (Hash(vchKey.begin(), vchKey.end()) != hash)
453 strErr = "Error reading wallet database: CPubKey/CPrivKey corrupt";
460 if (!key.Load(pkey, vchPubKey, fSkipCheck))
462 strErr = "Error reading wallet database: CPrivKey corrupt";
465 if (!pwallet->LoadKey(key, vchPubKey))
467 strErr = "Error reading wallet database: LoadKey failed";
471 else if (strType == "mkey")
475 CMasterKey kMasterKey;
476 ssValue >> kMasterKey;
477 if(pwallet->mapMasterKeys.count(nID) != 0)
479 strErr = strprintf("Error reading wallet database: duplicate CMasterKey id %u", nID);
482 pwallet->mapMasterKeys[nID] = kMasterKey;
483 if (pwallet->nMasterKeyMaxID < nID)
484 pwallet->nMasterKeyMaxID = nID;
486 else if (strType == "ckey")
488 vector<unsigned char> vchPubKey;
490 vector<unsigned char> vchPrivKey;
491 ssValue >> vchPrivKey;
494 if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey))
496 strErr = "Error reading wallet database: LoadCryptedKey failed";
499 wss.fIsEncrypted = true;
501 else if (strType == "keymeta")
505 CKeyMetadata keyMeta;
509 pwallet->LoadKeyMetadata(vchPubKey, keyMeta);
511 // find earliest key creation time, as wallet birthday
512 if (!pwallet->nTimeFirstKey ||
513 (keyMeta.nCreateTime < pwallet->nTimeFirstKey))
514 pwallet->nTimeFirstKey = keyMeta.nCreateTime;
516 else if (strType == "defaultkey")
518 ssValue >> pwallet->vchDefaultKey;
520 else if (strType == "pool")
526 pwallet->setKeyPool.insert(nIndex);
528 // If no metadata exists yet, create a default with the pool key's
529 // creation time. Note that this may be overwritten by actually
530 // stored metadata for that key later, which is fine.
531 CKeyID keyid = keypool.vchPubKey.GetID();
532 if (pwallet->mapKeyMetadata.count(keyid) == 0)
533 pwallet->mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime);
535 else if (strType == "version")
537 ssValue >> wss.nFileVersion;
538 if (wss.nFileVersion == 10300)
539 wss.nFileVersion = 300;
541 else if (strType == "cscript")
547 if (!pwallet->LoadCScript(script))
549 strErr = "Error reading wallet database: LoadCScript failed";
553 else if (strType == "orderposnext")
555 ssValue >> pwallet->nOrderPosNext;
557 else if (strType == "destdata")
559 std::string strAddress, strKey, strValue;
563 if (!pwallet->LoadDestData(CBitcoinAddress(strAddress).Get(), strKey, strValue))
565 strErr = "Error reading wallet database: LoadDestData failed";
576 static bool IsKeyType(string strType)
578 return (strType== "key" || strType == "wkey" ||
579 strType == "mkey" || strType == "ckey");
582 DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
584 pwallet->vchDefaultKey = CPubKey();
585 CWalletScanState wss;
586 bool fNoncriticalErrors = false;
587 DBErrors result = DB_LOAD_OK;
590 LOCK(pwallet->cs_wallet);
592 if (Read((string)"minversion", nMinVersion))
594 if (nMinVersion > CLIENT_VERSION)
596 pwallet->LoadMinVersion(nMinVersion);
600 Dbc* pcursor = GetCursor();
603 LogPrintf("Error getting wallet database cursor\n");
610 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
611 CDataStream ssValue(SER_DISK, CLIENT_VERSION);
612 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
613 if (ret == DB_NOTFOUND)
617 LogPrintf("Error reading next record from wallet database\n");
621 // Try to be tolerant of single corrupt records:
622 string strType, strErr;
623 if (!ReadKeyValue(pwallet, ssKey, ssValue, wss, strType, strErr))
625 // losing keys is considered a catastrophic error, anything else
626 // we assume the user can live with:
627 if (IsKeyType(strType))
631 // Leave other errors alone, if we try to fix them we might make things worse.
632 fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
634 // Rescan if there is a bad transaction record:
635 SoftSetBoolArg("-rescan", true);
639 LogPrintf("%s\n", strErr);
643 catch (boost::thread_interrupted) {
650 if (fNoncriticalErrors && result == DB_LOAD_OK)
651 result = DB_NONCRITICAL_ERROR;
653 // Any wallet corruption at all: skip any rewriting or
654 // upgrading, we don't want to make it worse.
655 if (result != DB_LOAD_OK)
658 LogPrintf("nFileVersion = %d\n", wss.nFileVersion);
660 LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total\n",
661 wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys);
663 // nTimeFirstKey is only reliable if all keys have metadata
664 if ((wss.nKeys + wss.nCKeys) != wss.nKeyMeta)
665 pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
667 BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade)
668 WriteTx(hash, pwallet->mapWallet[hash]);
670 // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
671 if (wss.fIsEncrypted && (wss.nFileVersion == 40000 || wss.nFileVersion == 50000))
672 return DB_NEED_REWRITE;
674 if (wss.nFileVersion < CLIENT_VERSION) // Update
675 WriteVersion(CLIENT_VERSION);
677 if (wss.fAnyUnordered)
678 result = ReorderTransactions(pwallet);
683 DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash)
685 pwallet->vchDefaultKey = CPubKey();
686 CWalletScanState wss;
687 bool fNoncriticalErrors = false;
688 DBErrors result = DB_LOAD_OK;
691 LOCK(pwallet->cs_wallet);
693 if (Read((string)"minversion", nMinVersion))
695 if (nMinVersion > CLIENT_VERSION)
697 pwallet->LoadMinVersion(nMinVersion);
701 Dbc* pcursor = GetCursor();
704 LogPrintf("Error getting wallet database cursor\n");
711 CDataStream ssKey(SER_DISK, CLIENT_VERSION);
712 CDataStream ssValue(SER_DISK, CLIENT_VERSION);
713 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
714 if (ret == DB_NOTFOUND)
718 LogPrintf("Error reading next record from wallet database\n");
724 if (strType == "tx") {
728 vTxHash.push_back(hash);
733 catch (boost::thread_interrupted) {
740 if (fNoncriticalErrors && result == DB_LOAD_OK)
741 result = DB_NONCRITICAL_ERROR;
746 DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet)
748 // build list of wallet TXs
749 vector<uint256> vTxHash;
750 DBErrors err = FindWalletTx(pwallet, vTxHash);
751 if (err != DB_LOAD_OK)
754 // erase each wallet TX
755 BOOST_FOREACH (uint256& hash, vTxHash) {
763 void ThreadFlushWalletDB(const string& strFile)
765 // Make this thread recognisable as the wallet flushing thread
766 RenameThread("bitcoin-wallet");
768 static bool fOneThread;
772 if (!GetBoolArg("-flushwallet", true))
775 unsigned int nLastSeen = nWalletDBUpdated;
776 unsigned int nLastFlushed = nWalletDBUpdated;
777 int64_t nLastWalletUpdate = GetTime();
782 if (nLastSeen != nWalletDBUpdated)
784 nLastSeen = nWalletDBUpdated;
785 nLastWalletUpdate = GetTime();
788 if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)
790 TRY_LOCK(bitdb.cs_db,lockDb);
793 // Don't do this if any databases are in use
795 map<string, int>::iterator mi = bitdb.mapFileUseCount.begin();
796 while (mi != bitdb.mapFileUseCount.end())
798 nRefCount += (*mi).second;
804 boost::this_thread::interruption_point();
805 map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
806 if (mi != bitdb.mapFileUseCount.end())
808 LogPrint("db", "Flushing wallet.dat\n");
809 nLastFlushed = nWalletDBUpdated;
810 int64_t nStart = GetTimeMillis();
812 // Flush wallet.dat so it's self contained
813 bitdb.CloseDb(strFile);
814 bitdb.CheckpointLSN(strFile);
816 bitdb.mapFileUseCount.erase(mi++);
817 LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart);
825 bool BackupWallet(const CWallet& wallet, const string& strDest)
827 if (!wallet.fFileBacked)
833 if (!bitdb.mapFileUseCount.count(wallet.strWalletFile) || bitdb.mapFileUseCount[wallet.strWalletFile] == 0)
835 // Flush log data to the dat file
836 bitdb.CloseDb(wallet.strWalletFile);
837 bitdb.CheckpointLSN(wallet.strWalletFile);
838 bitdb.mapFileUseCount.erase(wallet.strWalletFile);
841 filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
842 filesystem::path pathDest(strDest);
843 if (filesystem::is_directory(pathDest))
844 pathDest /= wallet.strWalletFile;
847 #if BOOST_VERSION >= 104000
848 filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists);
850 filesystem::copy_file(pathSrc, pathDest);
852 LogPrintf("copied wallet.dat to %s\n", pathDest.string());
854 } catch(const filesystem::filesystem_error &e) {
855 LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what());
866 // Try to (very carefully!) recover wallet.dat if there is a problem.
868 bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
870 // Recovery procedure:
871 // move wallet.dat to wallet.timestamp.bak
872 // Call Salvage with fAggressive=true to
873 // get as much data as possible.
874 // Rewrite salvaged data to wallet.dat
875 // Set -rescan so any missing transactions will be
877 int64_t now = GetTime();
878 std::string newFilename = strprintf("wallet.%d.bak", now);
880 int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL,
881 newFilename.c_str(), DB_AUTO_COMMIT);
883 LogPrintf("Renamed %s to %s\n", filename, newFilename);
886 LogPrintf("Failed to rename %s to %s\n", filename, newFilename);
890 std::vector<CDBEnv::KeyValPair> salvagedData;
891 bool allOK = dbenv.Salvage(newFilename, true, salvagedData);
892 if (salvagedData.empty())
894 LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename);
897 LogPrintf("Salvage(aggressive) found %u records\n", salvagedData.size());
899 bool fSuccess = allOK;
900 Db* pdbCopy = new Db(&dbenv.dbenv, 0);
901 int ret = pdbCopy->open(NULL, // Txn pointer
902 filename.c_str(), // Filename
903 "main", // Logical db name
904 DB_BTREE, // Database type
909 LogPrintf("Cannot create database file %s\n", filename);
913 CWalletScanState wss;
915 DbTxn* ptxn = dbenv.TxnBegin();
916 BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData)
920 CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION);
921 CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION);
922 string strType, strErr;
923 bool fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue,
924 wss, strType, strErr);
925 if (!IsKeyType(strType))
929 LogPrintf("WARNING: CWalletDB::Recover skipping %s: %s\n", strType, strErr);
933 Dbt datKey(&row.first[0], row.first.size());
934 Dbt datValue(&row.second[0], row.second.size());
935 int ret2 = pdbCopy->put(ptxn, &datKey, &datValue, DB_NOOVERWRITE);
946 bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename)
948 return CWalletDB::Recover(dbenv, filename, false);
951 bool CWalletDB::WriteDestData(const std::string &address, const std::string &key, const std::string &value)
954 return Write(boost::make_tuple(std::string("destdata"), address, key), value);
957 bool CWalletDB::EraseDestData(const std::string &address, const std::string &key)
960 return Erase(boost::make_tuple(string("destdata"), address, key));