1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2011 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
9 #include <boost/filesystem.hpp>
10 #include <boost/filesystem/fstream.hpp>
13 using namespace boost;
16 unsigned int nWalletDBUpdated;
17 uint64 nAccountingEntryNumber = 0;
25 static CCriticalSection cs_db;
26 static bool fDbEnvInit = false;
28 static map<string, int> mapFileUseCount;
29 static map<string, Db*> mapDb;
49 CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
55 fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
56 bool fCreate = strchr(pszMode, 'c');
57 unsigned int nFlags = DB_THREAD;
67 string strDataDir = GetDataDir();
68 string strLogDir = strDataDir + "/database";
69 filesystem::create_directory(strLogDir.c_str());
70 string strErrorFile = strDataDir + "/db.log";
71 printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str());
73 dbenv.set_lg_dir(strLogDir.c_str());
74 dbenv.set_lg_max(10000000);
75 dbenv.set_lk_max_locks(10000);
76 dbenv.set_lk_max_objects(10000);
77 dbenv.set_errfile(fopen(strErrorFile.c_str(), "a")); /// debug
78 dbenv.set_flags(DB_AUTO_COMMIT, 1);
79 ret = dbenv.open(strDataDir.c_str(),
89 throw runtime_error(strprintf("CDB() : error %d opening database environment", ret));
94 ++mapFileUseCount[strFile];
98 pdb = new Db(&dbenv, 0);
100 ret = pdb->open(NULL, // Txn pointer
102 "main", // Logical db name
103 DB_BTREE, // Database type
111 CRITICAL_BLOCK(cs_db)
112 --mapFileUseCount[strFile];
114 throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret));
117 if (fCreate && !Exists(string("version")))
119 bool fTmp = fReadOnly;
121 WriteVersion(VERSION);
125 mapDb[strFile] = pdb;
135 vTxn.front()->abort();
139 // Flush database activity from memory pool to disk log
140 unsigned int nMinutes = 0;
143 if (strFile == "addr.dat")
145 if (strFile == "blkindex.dat" && IsInitialBlockDownload() && nBestHeight % 500 != 0)
147 dbenv.txn_checkpoint(0, nMinutes, 0);
149 CRITICAL_BLOCK(cs_db)
150 --mapFileUseCount[strFile];
153 void static CloseDb(const string& strFile)
155 CRITICAL_BLOCK(cs_db)
157 if (mapDb[strFile] != NULL)
159 // Close the database handle
160 Db* pdb = mapDb[strFile];
163 mapDb[strFile] = NULL;
168 bool Resilver(const string& strFile)
172 CRITICAL_BLOCK(cs_db)
174 if (!mapFileUseCount.count(strFile) || mapFileUseCount[strFile] == 0)
176 // Flush log data to the dat file
178 dbenv.txn_checkpoint(0, 0, 0);
179 dbenv.lsn_reset(strFile.c_str(), 0);
180 mapFileUseCount.erase(strFile);
182 bool fSuccess = true;
183 printf("Resilvering %s...\n", strFile.c_str());
184 string strFileRes = strFile + ".resilver";
185 CDB db(strFile.c_str(), "r");
186 Db* pdbCopy = new Db(&dbenv, 0);
188 int ret = pdbCopy->open(NULL, // Txn pointer
189 strFileRes.c_str(), // Filename
190 "main", // Logical db name
191 DB_BTREE, // Database type
196 printf("Cannot create database file %s\n", strFileRes.c_str());
200 Dbc* pcursor = db.GetCursor();
206 int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
207 if (ret == DB_NOTFOUND)
215 Dbt datKey(&ssKey[0], ssKey.size());
216 Dbt datValue(&ssValue[0], ssValue.size());
217 int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE);
223 Db* pdb = mapDb[strFile];
226 if (pdbCopy->close(0))
230 mapDb[strFile] = NULL;
235 if (dbA.remove(strFile.c_str(), NULL, 0))
238 if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0))
242 printf("Resilvering of %s FAILED!\n", strFileRes.c_str());
252 void DBFlush(bool fShutdown)
254 // Flush log data to the actual data file
255 // on all files that are not in use
256 printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
259 CRITICAL_BLOCK(cs_db)
261 map<string, int>::iterator mi = mapFileUseCount.begin();
262 while (mi != mapFileUseCount.end())
264 string strFile = (*mi).first;
265 int nRefCount = (*mi).second;
266 printf("%s refcount=%d\n", strFile.c_str(), nRefCount);
269 // Move log data to the dat file
271 dbenv.txn_checkpoint(0, 0, 0);
272 printf("%s flush\n", strFile.c_str());
273 dbenv.lsn_reset(strFile.c_str(), 0);
274 mapFileUseCount.erase(mi++);
282 if (mapFileUseCount.empty())
283 dbenv.log_archive(&listp, DB_ARCH_REMOVE);
299 bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex)
303 return Read(make_pair(string("tx"), hash), txindex);
306 bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex)
309 return Write(make_pair(string("tx"), hash), txindex);
312 bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight)
317 uint256 hash = tx.GetHash();
318 CTxIndex txindex(pos, tx.vout.size());
319 return Write(make_pair(string("tx"), hash), txindex);
322 bool CTxDB::EraseTxIndex(const CTransaction& tx)
325 uint256 hash = tx.GetHash();
327 return Erase(make_pair(string("tx"), hash));
330 bool CTxDB::ContainsTx(uint256 hash)
333 return Exists(make_pair(string("tx"), hash));
336 bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>& vtx)
342 Dbc* pcursor = GetCursor();
346 unsigned int fFlags = DB_SET_RANGE;
351 if (fFlags == DB_SET_RANGE)
352 ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
354 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
356 if (ret == DB_NOTFOUND)
368 ssKey >> strType >> hashItem >> pos;
370 ssValue >> nItemHeight;
373 if (strType != "owner" || hashItem != hash160)
375 if (nItemHeight >= nMinHeight)
377 vtx.resize(vtx.size()+1);
378 if (!vtx.back().ReadFromDisk(pos))
390 bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
394 if (!ReadTxIndex(hash, txindex))
396 return (tx.ReadFromDisk(txindex.pos));
399 bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx)
402 return ReadDiskTx(hash, tx, txindex);
405 bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex)
407 return ReadDiskTx(outpoint.hash, tx, txindex);
410 bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx)
413 return ReadDiskTx(outpoint.hash, tx, txindex);
416 bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
418 return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex);
421 bool CTxDB::EraseBlockIndex(uint256 hash)
423 return Erase(make_pair(string("blockindex"), hash));
426 bool CTxDB::ReadHashBestChain(uint256& hashBestChain)
428 return Read(string("hashBestChain"), hashBestChain);
431 bool CTxDB::WriteHashBestChain(uint256 hashBestChain)
433 return Write(string("hashBestChain"), hashBestChain);
436 bool CTxDB::ReadBestInvalidWork(CBigNum& bnBestInvalidWork)
438 return Read(string("bnBestInvalidWork"), bnBestInvalidWork);
441 bool CTxDB::WriteBestInvalidWork(CBigNum bnBestInvalidWork)
443 return Write(string("bnBestInvalidWork"), bnBestInvalidWork);
446 CBlockIndex static * InsertBlockIndex(uint256 hash)
452 map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
453 if (mi != mapBlockIndex.end())
457 CBlockIndex* pindexNew = new CBlockIndex();
459 throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
460 mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
461 pindexNew->phashBlock = &((*mi).first);
466 bool CTxDB::LoadBlockIndex()
468 // Get database cursor
469 Dbc* pcursor = GetCursor();
473 // Load mapBlockIndex
474 unsigned int fFlags = DB_SET_RANGE;
479 if (fFlags == DB_SET_RANGE)
480 ssKey << make_pair(string("blockindex"), uint256(0));
482 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
484 if (ret == DB_NOTFOUND)
492 if (strType == "blockindex")
494 CDiskBlockIndex diskindex;
495 ssValue >> diskindex;
497 // Construct block index object
498 CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
499 pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
500 pindexNew->pnext = InsertBlockIndex(diskindex.hashNext);
501 pindexNew->nFile = diskindex.nFile;
502 pindexNew->nBlockPos = diskindex.nBlockPos;
503 pindexNew->nHeight = diskindex.nHeight;
504 pindexNew->nVersion = diskindex.nVersion;
505 pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
506 pindexNew->nTime = diskindex.nTime;
507 pindexNew->nBits = diskindex.nBits;
508 pindexNew->nNonce = diskindex.nNonce;
510 // Watch for genesis block
511 if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == hashGenesisBlock)
512 pindexGenesisBlock = pindexNew;
514 if (!pindexNew->CheckIndex())
515 return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);
524 // Calculate bnChainWork
525 vector<pair<int, CBlockIndex*> > vSortedByHeight;
526 vSortedByHeight.reserve(mapBlockIndex.size());
527 BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
529 CBlockIndex* pindex = item.second;
530 vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
532 sort(vSortedByHeight.begin(), vSortedByHeight.end());
533 BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
535 CBlockIndex* pindex = item.second;
536 pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork();
539 // Load hashBestChain pointer to end of best chain
540 if (!ReadHashBestChain(hashBestChain))
542 if (pindexGenesisBlock == NULL)
544 return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded");
546 if (!mapBlockIndex.count(hashBestChain))
547 return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index");
548 pindexBest = mapBlockIndex[hashBestChain];
549 nBestHeight = pindexBest->nHeight;
550 bnBestChainWork = pindexBest->bnChainWork;
551 printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight);
553 // Load bnBestInvalidWork, OK if it doesn't exist
554 ReadBestInvalidWork(bnBestInvalidWork);
556 // Verify blocks in the best chain
557 CBlockIndex* pindexFork = NULL;
558 for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
560 if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks"))
563 if (!block.ReadFromDisk(pindex))
564 return error("LoadBlockIndex() : block.ReadFromDisk failed");
565 if (!block.CheckBlock())
567 printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
568 pindexFork = pindex->pprev;
573 // Reorg back to the fork
574 printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight);
576 if (!block.ReadFromDisk(pindexFork))
577 return error("LoadBlockIndex() : block.ReadFromDisk failed");
579 block.SetBestChain(txdb, pindexFork);
593 bool CAddrDB::WriteAddress(const CAddress& addr)
595 return Write(make_pair(string("addr"), addr.GetKey()), addr);
598 bool CAddrDB::EraseAddress(const CAddress& addr)
600 return Erase(make_pair(string("addr"), addr.GetKey()));
603 bool CAddrDB::LoadAddresses()
605 CRITICAL_BLOCK(cs_mapAddresses)
608 Dbc* pcursor = GetCursor();
617 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
618 if (ret == DB_NOTFOUND)
626 if (strType == "addr")
630 mapAddresses.insert(make_pair(addr.GetKey(), addr));
635 printf("Loaded %d addresses\n", mapAddresses.size());
643 return CAddrDB("cr+").LoadAddresses();
653 bool CWalletDB::WriteName(const string& strAddress, const string& strName)
656 return Write(make_pair(string("name"), strAddress), strName);
659 bool CWalletDB::EraseName(const string& strAddress)
661 // This should only be used for sending addresses, never for receiving addresses,
662 // receiving addresses must always have an address book entry if they're not change return.
664 return Erase(make_pair(string("name"), strAddress));
667 bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account)
670 return Read(make_pair(string("acc"), strAccount), account);
673 bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account)
675 return Write(make_pair(string("acc"), strAccount), account);
678 bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
680 return Write(boost::make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry);
683 int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
685 list<CAccountingEntry> entries;
686 ListAccountCreditDebit(strAccount, entries);
688 int64 nCreditDebit = 0;
689 BOOST_FOREACH (const CAccountingEntry& entry, entries)
690 nCreditDebit += entry.nCreditDebit;
695 void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& entries)
697 bool fAllAccounts = (strAccount == "*");
699 Dbc* pcursor = GetCursor();
701 throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
702 unsigned int fFlags = DB_SET_RANGE;
707 if (fFlags == DB_SET_RANGE)
708 ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
710 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
712 if (ret == DB_NOTFOUND)
717 throw runtime_error("CWalletDB::ListAccountCreditDebit() : error scanning DB");
723 if (strType != "acentry")
725 CAccountingEntry acentry;
726 ssKey >> acentry.strAccount;
727 if (!fAllAccounts && acentry.strAccount != strAccount)
731 entries.push_back(acentry);
738 int CWalletDB::LoadWallet(CWallet* pwallet)
740 pwallet->vchDefaultKey.clear();
741 int nFileVersion = 0;
742 vector<uint256> vWalletUpgrade;
743 bool fIsResilvered = false;
744 bool fIsEncrypted = false;
748 // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
749 fMinimizeToTray = false;
750 fMinimizeOnClose = false;
753 //// todo: shouldn't we catch exceptions and try to recover and continue?
754 CRITICAL_BLOCK(pwallet->cs_wallet)
757 Dbc* pcursor = GetCursor();
766 int ret = ReadAtCursor(pcursor, ssKey, ssValue);
767 if (ret == DB_NOTFOUND)
773 // Taking advantage of the fact that pair serialization
774 // is just the two items serialized one after the other
777 if (strType == "name")
781 ssValue >> pwallet->mapAddressBook[strAddress];
783 else if (strType == "tx")
787 CWalletTx& wtx = pwallet->mapWallet[hash];
789 wtx.pwallet = pwallet;
791 if (wtx.GetHash() != hash)
792 printf("Error in wallet.dat, hash mismatch\n");
794 // Undo serialize changes in 31600
795 if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
797 if (!ssValue.empty())
801 ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
802 printf("LoadWallet() upgrading tx ver=%d %d '%s' %s\n", wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount.c_str(), hash.ToString().c_str());
803 wtx.fTimeReceivedIsTxTime = fTmp;
807 printf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString().c_str());
808 wtx.fTimeReceivedIsTxTime = 0;
810 vWalletUpgrade.push_back(hash);
814 //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
815 //printf(" %12I64d %s %s %s\n",
816 // wtx.vout[0].nValue,
817 // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(),
818 // wtx.hashBlock.ToString().substr(0,20).c_str(),
819 // wtx.mapValue["message"].c_str());
821 else if (strType == "acentry")
827 if (nNumber > nAccountingEntryNumber)
828 nAccountingEntryNumber = nNumber;
830 else if (strType == "key" || strType == "wkey")
832 vector<unsigned char> vchPubKey;
835 if (strType == "key")
839 key.SetPrivKey(pkey);
845 key.SetPrivKey(wkey.vchPrivKey);
847 if (!pwallet->LoadKey(key))
850 else if (strType == "mkey")
854 CMasterKey kMasterKey;
855 ssValue >> kMasterKey;
856 if(pwallet->mapMasterKeys.count(nID) != 0)
858 pwallet->mapMasterKeys[nID] = kMasterKey;
859 if (pwallet->nMasterKeyMaxID < nID)
860 pwallet->nMasterKeyMaxID = nID;
862 else if (strType == "ckey")
864 vector<unsigned char> vchPubKey;
866 vector<unsigned char> vchPrivKey;
867 ssValue >> vchPrivKey;
868 if (!pwallet->LoadCryptedKey(vchPubKey, vchPrivKey))
872 else if (strType == "defaultkey")
874 ssValue >> pwallet->vchDefaultKey;
876 else if (strType == "pool")
880 pwallet->setKeyPool.insert(nIndex);
882 else if (strType == "version")
884 ssValue >> nFileVersion;
885 if (nFileVersion == 10300)
888 else if (strType == "setting")
895 if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
897 if (strKey == "nTransactionFee") ssValue >> nTransactionFee;
898 if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;
899 if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors;
900 if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray;
901 if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose;
902 if (strKey == "fUseProxy") ssValue >> fUseProxy;
903 if (strKey == "addrProxy") ssValue >> addrProxy;
904 if (strKey == "fIsResilvered") ssValue >> fIsResilvered;
905 if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
907 else if (strType == "minversion")
910 ssValue >> nMinVersion;
911 if (nMinVersion > VERSION)
918 BOOST_FOREACH(uint256 hash, vWalletUpgrade)
919 WriteTx(hash, pwallet->mapWallet[hash]);
921 printf("nFileVersion = %d\n", nFileVersion);
922 printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
923 printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
924 printf("fMinimizeToTray = %d\n", fMinimizeToTray);
925 printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
926 printf("fUseProxy = %d\n", fUseProxy);
927 printf("addrProxy = %s\n", addrProxy.ToString().c_str());
929 printf("fUseUPnP = %d\n", fUseUPnP);
933 if (nFileVersion < VERSION)
935 // Get rid of old debug.log file in current directory
936 if (nFileVersion <= 105 && !pszSetDataDir[0])
939 WriteVersion(VERSION);
942 if (fIsEncrypted && !fIsResilvered)
943 return DB_NEED_RESILVER;
948 void ThreadFlushWalletDB(void* parg)
950 const string& strFile = ((const string*)parg)[0];
951 static bool fOneThread;
955 if (mapArgs.count("-noflushwallet"))
958 unsigned int nLastSeen = nWalletDBUpdated;
959 unsigned int nLastFlushed = nWalletDBUpdated;
960 int64 nLastWalletUpdate = GetTime();
965 if (nLastSeen != nWalletDBUpdated)
967 nLastSeen = nWalletDBUpdated;
968 nLastWalletUpdate = GetTime();
971 if (nLastFlushed != nWalletDBUpdated && GetTime() - nLastWalletUpdate >= 2)
973 TRY_CRITICAL_BLOCK(cs_db)
975 // Don't do this if any databases are in use
977 map<string, int>::iterator mi = mapFileUseCount.begin();
978 while (mi != mapFileUseCount.end())
980 nRefCount += (*mi).second;
984 if (nRefCount == 0 && !fShutdown)
986 map<string, int>::iterator mi = mapFileUseCount.find(strFile);
987 if (mi != mapFileUseCount.end())
989 printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
990 printf("Flushing wallet.dat\n");
991 nLastFlushed = nWalletDBUpdated;
992 int64 nStart = GetTimeMillis();
994 // Flush wallet.dat so it's self contained
996 dbenv.txn_checkpoint(0, 0, 0);
997 dbenv.lsn_reset(strFile.c_str(), 0);
999 mapFileUseCount.erase(mi++);
1000 printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
1008 bool BackupWallet(const CWallet& wallet, const string& strDest)
1010 if (!wallet.fFileBacked)
1014 CRITICAL_BLOCK(cs_db)
1016 if (!mapFileUseCount.count(wallet.strWalletFile) || mapFileUseCount[wallet.strWalletFile] == 0)
1018 // Flush log data to the dat file
1019 CloseDb(wallet.strWalletFile);
1020 dbenv.txn_checkpoint(0, 0, 0);
1021 dbenv.lsn_reset(wallet.strWalletFile.c_str(), 0);
1022 mapFileUseCount.erase(wallet.strWalletFile);
1025 filesystem::path pathSrc(GetDataDir() + "/" + wallet.strWalletFile);
1026 filesystem::path pathDest(strDest);
1027 if (filesystem::is_directory(pathDest))
1028 pathDest = pathDest / wallet.strWalletFile;
1029 #if BOOST_VERSION >= 104000
1030 filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists);
1032 filesystem::copy_file(pathSrc, pathDest);
1034 printf("copied wallet.dat to %s\n", pathDest.string().c_str());