From 680be25d2a35d35fe0904288e3c584192fe6289c Mon Sep 17 00:00:00 2001 From: crowning- Date: Thu, 9 Apr 2015 00:31:01 +0200 Subject: [PATCH 01/18] Added missing scrollbar-arrows --- src/qt/res/css/drkblue.css | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index cce44820a..755040cdd 100755 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -274,47 +274,25 @@ color:#333; QScrollBar { /* Scroll Bar */ background-color:#ffffff; +background:#e0e0e0; } QScrollBar:vertical { /* Vertical Scroll Bar Attributes */ border:1px solid #818181; border-left:0px; -background:#333; width:17px; -margin: 0px 0px 0px 0px; } QScrollBar:horizontal { /* Horizontal Scroll Bar Attributes */ border:1px solid #818181; border-top:0px; -background:#333; height:17px; -margin: 0px 0px 0px 0px; } - -QScrollBar::handle:vertical { /* Scroll Bar Slider - vertical */ -background:#e0e0e0; -min-height:10px; -} - -QScrollBar::handle:horizontal { /* Scroll Bar Slider - horizontal */ -background:#e0e0e0; -min-width:10px; -} - - QScrollBar::add-page, QScrollBar::sub-page { /* Scroll Bar Background */ background:#F8F6F6; } -QScrollBar:up-arrow, QScrollBar:down-arrow { /* Up and Down Arrows */ -border:2px solid #333; -width:3px; -height:3px; -background:#fff; -} - /*******************************************************/ /* DIALOG BOXES */ From 756f77151770cd2062f74020589abebe60c8ae05 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 05:32:11 +0200 Subject: [PATCH 02/18] CSS reverted to master --- src/qt/res/css/drkblue.css | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index 755040cdd..3aaa4e216 100755 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -274,25 +274,47 @@ color:#333; QScrollBar { /* Scroll Bar */ background-color:#ffffff; -background:#e0e0e0; } QScrollBar:vertical { /* Vertical Scroll Bar Attributes */ border:1px solid #818181; border-left:0px; +background:#333; width:17px; +margin: 0px 0px 0px 0px; } QScrollBar:horizontal { /* Horizontal Scroll Bar Attributes */ border:1px solid #818181; border-top:0px; +background:#333; height:17px; +margin: 0px 0px 0px 0px; } + +QScrollBar::handle:vertical { /* Scroll Bar Slider - vertical */ +background:#e0e0e0; +min-height:10px; +} + +QScrollBar::handle:horizontal { /* Scroll Bar Slider - horizontal */ +background:#e0e0e0; +min-width:10px; +} + + QScrollBar::add-page, QScrollBar::sub-page { /* Scroll Bar Background */ background:#F8F6F6; } +QScrollBar:up-arrow, QScrollBar:down-arrow { /* Up and Down Arrows */ +border:2px solid #333; +width:3px; +height:3px; +background:#fff; +} + /*******************************************************/ /* DIALOG BOXES */ @@ -1392,3 +1414,4 @@ border:1px solid #d7d7d7; } + From 2bb8209877ef651b6ffc490ec30c1dc1d5223f94 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 05:34:08 +0200 Subject: [PATCH 03/18] CSS reverted to master --- src/qt/res/css/drkblue.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index 3aaa4e216..cce44820a 100755 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -1414,4 +1414,3 @@ border:1px solid #d7d7d7; } - From 51304dfaa2efe9025fe92d7205505bf2597dda52 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 06:14:18 +0200 Subject: [PATCH 04/18] Create backups of wallet.dat automatically --- src/init.cpp | 30 +++++++++++++++++++++++++++++- src/init.h | 0 src/qt/Makefile.am | 3 ++- src/qt/bitcoingui.cpp | 5 +++++ src/qt/bitcoingui.h | 1 + src/qt/dash.qrc | 1 + src/qt/guiutil.cpp | 9 +++++++++ src/qt/guiutil.h | 3 +++ src/qt/res/icons/browse.png | Bin 0 -> 1741 bytes src/qt/rpcconsole.cpp | 5 +++++ src/qt/rpcconsole.h | 2 ++ 11 files changed, 57 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/init.h mode change 100644 => 100755 src/qt/bitcoingui.h create mode 100755 src/qt/res/icons/browse.png mode change 100644 => 100755 src/qt/rpcconsole.h diff --git a/src/init.cpp b/src/init.cpp index b73084799..fc3ad20bb 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -711,9 +711,37 @@ bool AppInit2(boost::thread_group& threadGroup) int64_t nStart; - // ********************************************************* Step 5: verify wallet database integrity + // ********************************************************* Step 5: Backup wallet and verify wallet database integrity #ifdef ENABLE_WALLET if (!fDisableWallet) { + filesystem::path backupDir = GetDataDir() / "backups"; + if (!filesystem::exists(backupDir)) + { + // Always created backup folder, even when it's not used. + filesystem::create_directories(backupDir); + } + + if(GetBoolArg("-createwalletbackups", true)) + { + if (!filesystem::exists(backupDir)) + filesystem::create_directories(backupDir); + // Create backup of the wallet + if (filesystem::exists(backupDir)) + { + std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d %H:%M:%S", GetTime()); + std::string backupDirStr = backupDir.string(); + backupDirStr += "/" + strWalletFile; + boost::filesystem::path sourceFile = strWalletFile; + boost::filesystem::path backupFile = backupDirStr + dateTimeStr; + try { + boost::filesystem::copy_file(sourceFile, backupFile); + LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); + } catch(boost::filesystem::filesystem_error &error) { + LogPrintf("Failed to create backup %s -> %s\n", sourceFile, backupFile); + } + } + } + LogPrintf("Using wallet %s\n", strWalletFile); uiInterface.InitMessage(_("Verifying wallet...")); diff --git a/src/init.h b/src/init.h old mode 100644 new mode 100755 diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am index d90081dec..8dfc7a73a 100755 --- a/src/qt/Makefile.am +++ b/src/qt/Makefile.am @@ -222,7 +222,8 @@ RES_ICONS = \ res/icons/drkblue_editpaste.png \ res/icons/drkblue_address-book.png \ res/icons/drkblue_editcopy.png \ - res/icons/drkblue_remove.png + res/icons/drkblue_remove.png \ + res/icons/browse.png BITCOIN_QT_CPP = \ diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 59fdb50e2..259cafb77 100755 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -193,6 +193,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) : connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole())); connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork())); connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor())); + connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups())); // prevents an oben debug window from becoming stuck/unusable on client shutdown @@ -330,6 +331,8 @@ void BitcoinGUI::createActions(bool fIsTestnet) openNetworkAction->setStatusTip(tr("Show network monitor")); openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this); openConfEditorAction->setStatusTip(tr("Open configuration file")); + showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Auto&Backups"), this); + showBackupsAction->setStatusTip(tr("S")); usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this); usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels")); @@ -408,6 +411,7 @@ void BitcoinGUI::createMenuBar() tools->addAction(openRPCConsoleAction); tools->addAction(openNetworkAction); tools->addAction(openConfEditorAction); + tools->addAction(showBackupsAction); } QMenu *help = appMenuBar->addMenu(tr("&Help")); @@ -570,6 +574,7 @@ void BitcoinGUI::createTrayIconMenu() trayIconMenu->addAction(openRPCConsoleAction); trayIconMenu->addAction(openNetworkAction); trayIconMenu->addAction(openConfEditorAction); + trayIconMenu->addAction(showBackupsAction); #ifndef Q_OS_MAC // This is built-in on Mac trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h old mode 100644 new mode 100755 index 7bdb16abd..ee19ff691 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -97,6 +97,7 @@ private: QAction *openRPCConsoleAction; QAction *openNetworkAction; QAction *openConfEditorAction; + QAction *showBackupsAction; QAction *openAction; QAction *showHelpMessageAction; diff --git a/src/qt/dash.qrc b/src/qt/dash.qrc index 6ab324693..4ed6a718d 100755 --- a/src/qt/dash.qrc +++ b/src/qt/dash.qrc @@ -45,6 +45,7 @@ res/icons/drkblue_address-book.png res/icons/drkblue_editcopy.png res/icons/drkblue_remove.png + res/icons/browse.png res/css/drkblue.css diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 7895b53ee..3832c770b 100755 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -384,6 +384,15 @@ void openConfigfile() QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig))); } +void showBackups() +{ + boost::filesystem::path pathBackups = GetDataDir() / "backups"; + + /* Open folder with default browser */ + if (boost::filesystem::exists(pathBackups)) + QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathBackups))); +} + ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent) : QObject(parent), size_threshold(size_threshold) { diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index ad3168f81..229e00aa2 100755 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -106,6 +106,9 @@ namespace GUIUtil // Open dash.conf void openConfigfile(); + + // Browse backup folder + void showBackups(); /** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text representation if needed. This assures that Qt can word-wrap long tooltip messages. diff --git a/src/qt/res/icons/browse.png b/src/qt/res/icons/browse.png new file mode 100755 index 0000000000000000000000000000000000000000..ae13a151d5ad11239194edd1fd91199f8dd72f4e GIT binary patch literal 1741 zcmV;;1~U1HP)|f|?2FH71}*ARmH#2?}N;pMop}hB72t{zDuGi6Vp; z*sOoQ8Ke~T8Duq#8UFwMgOTL`0&qnJNdSN#2-Ga6|36rhED|7bcOl0=`Q_o}VI6Wd+pB9(8B07A<3e@GgD6;jMt%3Xi}!bpU$-~=T?Mn*J8FhW8CB>ESUY2b$ZgQf3(&}<4$ zsEpt!fTa-@EDit&AdED?0L=v~u)K!_fKoFo3o=0yBsdX5qXsPYAL2@o17HOtHsb&S z2qO)^asd-C!oGg_!SL(fFJSQf162$RpnBmytXKwSe300`e-I3k`wR3cSS={k1NqFr zqL`JHg#lD(#W#n3o}6;g1={6~ZsObx_Q;0g(xRsQ^E zX7~wAI7}?qLjWLvFdP61LQtGN`~=htOlhCL154E3h};3A|3cFWm=7%lL4^`1de~VJ zYW_j%4PH)22%`gl0K%FGK?No=Q0B$`-wfRE-ZRLE0v+)eQQ09^zlbWBfdLrW4EJ9! zF&w|j&cH9k%phsN$-oFqOMm|0PJ{pfgpmedK?-s`-*<+iXMo23f)+r~90996(E&gJv7qHLuutGY4CMU;`ux{F7KXPUe=__6 zN^r6=GjMRQVa*+^z@P(#o}eHD13w=VymEp?9k!wvAb^f;_k9AEaK9M7f5*h%zWoB{1U_CS25xR9c>4jCNU?#W^@rU8Z4=mvcDhGh_{J;=k=VoMh4NcI0 zp^23dixz+YV!;&!;2IAY1;2qI@bf3o$3G!e;O{>W{?DIGSRDXzARiAC11m5J{(WPF zG*qB1Dr_MD5J1@51OFhY1C(&S{rJW3<^wZ>x7jxaJ%vvUYLb5$-o9rB=XrGS8`xj~ zrvW}-9l#091>Zm=A|t$>z?KF80tnRsOpGj`77ftTz}7H?{_^<;!`pWZ4B83|3|^aL$)Sv_DA>hJ$QzZp2bKLZx6pmLv)U@r$4 z*bG1Zu`~SRkpLzaU=I2VZNjlKFh9Qj;^E~JkIVo6FWrf(2OxkL2fA+v5I_UoHv|Zv j0e1jE01dbU00ImEejxC)$7P#?00000NkvXXu0mjfTPNqK literal 0 HcmV?d00001 diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 284ee0af6..7c94811af 100755 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -524,3 +524,8 @@ void RPCConsole::showConfEditor() { GUIUtil::openConfigfile(); } + +void RPCConsole::showBackups() +{ + GUIUtil::showBackups(); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h old mode 100644 new mode 100755 index 97b4806e9..3fa435ab7 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -67,6 +67,8 @@ public slots: void showNetwork(); /** Open external (default) editor with dash.conf */ void showConfEditor(); + /** Show folder with wallet backups in default browser */ + void showBackups(); signals: // For RPC command executor From cfdc68633b9f8a2fe93a4bf57e27777b475b2b31 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 13:02:28 +0200 Subject: [PATCH 05/18] Make backup timestamp Windows-FS compatible --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index fc3ad20bb..882c96cb5 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -728,7 +728,7 @@ bool AppInit2(boost::thread_group& threadGroup) // Create backup of the wallet if (filesystem::exists(backupDir)) { - std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d %H:%M:%S", GetTime()); + std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); std::string backupDirStr = backupDir.string(); backupDirStr += "/" + strWalletFile; boost::filesystem::path sourceFile = strWalletFile; From 91bcad1d1f0f564774bc0bf54ef1e9e3f80d25d1 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 13:43:41 +0200 Subject: [PATCH 06/18] Added OS-independent path separator --- src/init.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 882c96cb5..dbc582840 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -729,8 +729,7 @@ bool AppInit2(boost::thread_group& threadGroup) if (filesystem::exists(backupDir)) { std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); - std::string backupDirStr = backupDir.string(); - backupDirStr += "/" + strWalletFile; + std::string backupDirStr = backupDir.string() + boost::filesystem::path::preferred_separator + strWalletFile; boost::filesystem::path sourceFile = strWalletFile; boost::filesystem::path backupFile = backupDirStr + dateTimeStr; try { From 2b040d1e485747ffbc53ce47519cd352084a6947 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 14:25:47 +0200 Subject: [PATCH 07/18] Wallet backup OS-dependent path fix --- src/init.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index dbc582840..b22cc354a 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -729,9 +729,12 @@ bool AppInit2(boost::thread_group& threadGroup) if (filesystem::exists(backupDir)) { std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); - std::string backupDirStr = backupDir.string() + boost::filesystem::path::preferred_separator + strWalletFile; + std::string backupDirStr = backupDir.string(); + backupDirStr += "/" + strWalletFile; boost::filesystem::path sourceFile = strWalletFile; boost::filesystem::path backupFile = backupDirStr + dateTimeStr; + backupFile.make_preferred(); + try { boost::filesystem::copy_file(sourceFile, backupFile); LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); From 7b8e729cb002527e89c66732984b7024e1be0af0 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 15:23:33 +0200 Subject: [PATCH 08/18] Changed error handling for debugging --- src/init.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index b22cc354a..a917a7df5 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -723,11 +723,10 @@ bool AppInit2(boost::thread_group& threadGroup) if(GetBoolArg("-createwalletbackups", true)) { - if (!filesystem::exists(backupDir)) - filesystem::create_directories(backupDir); // Create backup of the wallet if (filesystem::exists(backupDir)) { +// boost::system::error_code error; std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); std::string backupDirStr = backupDir.string(); backupDirStr += "/" + strWalletFile; @@ -739,7 +738,7 @@ bool AppInit2(boost::thread_group& threadGroup) boost::filesystem::copy_file(sourceFile, backupFile); LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); } catch(boost::filesystem::filesystem_error &error) { - LogPrintf("Failed to create backup %s -> %s\n", sourceFile, backupFile); + LogPrintf("Failed to create backup %s\n", &error); } } } From 2b99647461dddf6fba2dc1d19702148718b1b7fd Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 15:56:20 +0200 Subject: [PATCH 09/18] Changed error handling for debugging --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index a917a7df5..f9c421c4e 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -738,7 +738,7 @@ bool AppInit2(boost::thread_group& threadGroup) boost::filesystem::copy_file(sourceFile, backupFile); LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); } catch(boost::filesystem::filesystem_error &error) { - LogPrintf("Failed to create backup %s\n", &error); + LogPrintf("Failed to create backup %s\n", error.what()); } } } From 3846db711a9929cce8626adc2e4000d215f8a47c Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 16:49:02 +0200 Subject: [PATCH 10/18] Wallet autobackup completed --- src/init.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f9c421c4e..e503cb2d2 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -726,12 +726,15 @@ bool AppInit2(boost::thread_group& threadGroup) // Create backup of the wallet if (filesystem::exists(backupDir)) { -// boost::system::error_code error; std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); - std::string backupDirStr = backupDir.string(); - backupDirStr += "/" + strWalletFile; - boost::filesystem::path sourceFile = strWalletFile; - boost::filesystem::path backupFile = backupDirStr + dateTimeStr; + std::string backupPathStr = backupDir.string(); + backupPathStr += "/" + strWalletFile; + + std::string sourcePathStr = GetDataDir().string(); + sourcePathStr += "/" + strWalletFile; + + boost::filesystem::path sourceFile = sourcePathStr; + boost::filesystem::path backupFile = backupPathStr + dateTimeStr; backupFile.make_preferred(); try { From d2c0981786d518d993cf160a718343d2127102c4 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sat, 11 Apr 2015 17:21:18 +0200 Subject: [PATCH 11/18] Sanity check for backup source added --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index e503cb2d2..da3ebfc0c 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -735,6 +735,7 @@ bool AppInit2(boost::thread_group& threadGroup) boost::filesystem::path sourceFile = sourcePathStr; boost::filesystem::path backupFile = backupPathStr + dateTimeStr; + sourceFile.make_preferred(); backupFile.make_preferred(); try { From ea3c318fda6c1b7e0cd9b498b9bf5d6d27b95448 Mon Sep 17 00:00:00 2001 From: crowning- Date: Sun, 12 Apr 2015 01:02:33 +0200 Subject: [PATCH 12/18] Limit maximum number of wallet-backups to 10 --- src/init.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index da3ebfc0c..da88a41af 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -273,6 +273,7 @@ std::string HelpMessage(HelpMessageMode hmm) #ifdef ENABLE_WALLET strUsage += "\n" + _("Wallet options:") + "\n"; + strUsage += " -createwalletbackups " + _("Create a new backup of the wallet on start (default: 1)") + "\n"; strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n"; strUsage += " -keepass " + _("Use KeePass 2 integration using KeePassHttp plugin (default: 0)") + "\n"; strUsage += " -keepassport= " + _("Connect to KeePassHttp on port (default: 19455)") + "\n"; @@ -714,36 +715,62 @@ bool AppInit2(boost::thread_group& threadGroup) // ********************************************************* Step 5: Backup wallet and verify wallet database integrity #ifdef ENABLE_WALLET if (!fDisableWallet) { + filesystem::path backupDir = GetDataDir() / "backups"; if (!filesystem::exists(backupDir)) { - // Always created backup folder, even when it's not used. + // Always create backup folder to not confuse the operating system's file browser filesystem::create_directories(backupDir); } if(GetBoolArg("-createwalletbackups", true)) { - // Create backup of the wallet if (filesystem::exists(backupDir)) { + // Create backup of the wallet std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H.%M", GetTime()); std::string backupPathStr = backupDir.string(); backupPathStr += "/" + strWalletFile; - std::string sourcePathStr = GetDataDir().string(); sourcePathStr += "/" + strWalletFile; - boost::filesystem::path sourceFile = sourcePathStr; boost::filesystem::path backupFile = backupPathStr + dateTimeStr; sourceFile.make_preferred(); backupFile.make_preferred(); - try { boost::filesystem::copy_file(sourceFile, backupFile); LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); } catch(boost::filesystem::filesystem_error &error) { LogPrintf("Failed to create backup %s\n", error.what()); } + // Keep only the last 10 backups, including the new one of course + typedef std::multimap folder_set_t; + folder_set_t folder_set; + boost::filesystem::directory_iterator end_iter; + boost::filesystem::path backupFolder = backupDir.string(); + backupFolder.make_preferred(); + // Build map of backup files sorted by last write time + for (boost::filesystem::directory_iterator dir_iter(backupFolder); dir_iter != end_iter; ++dir_iter) + { + if ( boost::filesystem::is_regular_file(dir_iter->status()) ) + folder_set.insert(folder_set_t::value_type(boost::filesystem::last_write_time(dir_iter->path()), *dir_iter)); + } + // Loop backward through backup files and keep the 10 newest ones + int counter = 0; + BOOST_REVERSE_FOREACH(PAIRTYPE(const std::time_t, boost::filesystem::path) file, folder_set) + { + counter++; + if (counter > 10) + { + // More than 10 backups: delete oldest one(s) + try { + boost::filesystem::remove(file.second); + LogPrintf("Old backup deleted: %s\n", file.second); + } catch(boost::filesystem::filesystem_error &error) { + LogPrintf("Failed to delete backup %s\n", error.what()); + } + } + } } } From b56b9275c7517a958fdfaa83d39563188ecaeeb5 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 12 Apr 2015 07:30:57 +0300 Subject: [PATCH 13/18] fix DS and IX for CoinControl in litemode --- src/qt/sendcoinsdialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index a68d4a008..b0a8f4a64 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -52,6 +52,8 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) : ui->checkUseDarksend->setChecked(false); ui->checkUseDarksend->setVisible(false); ui->checkInstantX->setVisible(false); + CoinControlDialog::coinControl->useDarkSend = false; + CoinControlDialog::coinControl->useInstantX = false; } connect(ui->checkUseDarksend, SIGNAL(stateChanged ( int )), this, SLOT(updateDisplayUnit())); connect(ui->checkInstantX, SIGNAL(stateChanged ( int )), this, SLOT(updateInstantX())); From 5a1857795e7827ec20f9526653c9206f56f25ddc Mon Sep 17 00:00:00 2001 From: crowning- Date: Sun, 12 Apr 2015 14:43:53 +0200 Subject: [PATCH 14/18] Number of automatic backups configurable (0-10) --- src/init.cpp | 52 ++++++++++++++++++++++--------------------- src/qt/bitcoingui.cpp | 4 ++-- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index da88a41af..ffc8700b1 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -48,6 +48,7 @@ using namespace boost; #ifdef ENABLE_WALLET std::string strWalletFile; CWallet* pwalletMain; +int nWalletBackups = 10; #endif #ifdef WIN32 @@ -273,22 +274,22 @@ std::string HelpMessage(HelpMessageMode hmm) #ifdef ENABLE_WALLET strUsage += "\n" + _("Wallet options:") + "\n"; - strUsage += " -createwalletbackups " + _("Create a new backup of the wallet on start (default: 1)") + "\n"; - strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n"; - strUsage += " -keepass " + _("Use KeePass 2 integration using KeePassHttp plugin (default: 0)") + "\n"; - strUsage += " -keepassport= " + _("Connect to KeePassHttp on port (default: 19455)") + "\n"; - strUsage += " -keepasskey= " + _("KeePassHttp key for AES encrypted communication with KeePass") + "\n"; - strUsage += " -keepassid= " + _("KeePassHttp id for the established association") + "\n"; - strUsage += " -keepassname= " + _("Name to construct url for KeePass entry that stores the wallet passphrase") + "\n"; - strUsage += " -keypool= " + _("Set key pool size to (default: 1000)") + "\n"; - strUsage += " -paytxfee= " + _("Fee per kB to add to transactions you send") + "\n"; - strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + " " + _("on startup") + "\n"; - strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + " " + _("on startup") + "\n"; - strUsage += " -spendzeroconfchange " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n"; - strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + " " + _("on startup") + "\n"; - strUsage += " -wallet= " + _("Specify wallet file (within data directory)") + " " + _("(default: wallet.dat)") + "\n"; - strUsage += " -walletnotify= " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n"; - strUsage += " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n"; + strUsage += " -createwalletbackups= " + _("Number of automatic wallet backups (default: 10)") + "\n"; + strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n"; + strUsage += " -keepass " + _("Use KeePass 2 integration using KeePassHttp plugin (default: 0)") + "\n"; + strUsage += " -keepassport= " + _("Connect to KeePassHttp on port (default: 19455)") + "\n"; + strUsage += " -keepasskey= " + _("KeePassHttp key for AES encrypted communication with KeePass") + "\n"; + strUsage += " -keepassid= " + _("KeePassHttp id for the established association") + "\n"; + strUsage += " -keepassname= " + _("Name to construct url for KeePass entry that stores the wallet passphrase") + "\n"; + strUsage += " -keypool= " + _("Set key pool size to (default: 1000)") + "\n"; + strUsage += " -paytxfee= " + _("Fee per kB to add to transactions you send") + "\n"; + strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + " " + _("on startup") + "\n"; + strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + " " + _("on startup") + "\n"; + strUsage += " -spendzeroconfchange " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n"; + strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + " " + _("on startup") + "\n"; + strUsage += " -wallet= " + _("Specify wallet file (within data directory)") + " " + _("(default: wallet.dat)") + "\n"; + strUsage += " -walletnotify= " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n"; + strUsage += " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n"; #endif strUsage += "\n" + _("Debugging/Testing options:") + "\n"; @@ -722,8 +723,9 @@ bool AppInit2(boost::thread_group& threadGroup) // Always create backup folder to not confuse the operating system's file browser filesystem::create_directories(backupDir); } - - if(GetBoolArg("-createwalletbackups", true)) + nWalletBackups = GetArg("-createwalletbackups", 10); + nWalletBackups = std::max(0, std::min(10, nWalletBackups)); + if(nWalletBackups > 0) { if (filesystem::exists(backupDir)) { @@ -737,7 +739,7 @@ bool AppInit2(boost::thread_group& threadGroup) boost::filesystem::path backupFile = backupPathStr + dateTimeStr; sourceFile.make_preferred(); backupFile.make_preferred(); - try { + try { boost::filesystem::copy_file(sourceFile, backupFile); LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile); } catch(boost::filesystem::filesystem_error &error) { @@ -752,7 +754,7 @@ bool AppInit2(boost::thread_group& threadGroup) // Build map of backup files sorted by last write time for (boost::filesystem::directory_iterator dir_iter(backupFolder); dir_iter != end_iter; ++dir_iter) { - if ( boost::filesystem::is_regular_file(dir_iter->status()) ) + if ( boost::filesystem::is_regular_file(dir_iter->status())) folder_set.insert(folder_set_t::value_type(boost::filesystem::last_write_time(dir_iter->path()), *dir_iter)); } // Loop backward through backup files and keep the 10 newest ones @@ -760,20 +762,20 @@ bool AppInit2(boost::thread_group& threadGroup) BOOST_REVERSE_FOREACH(PAIRTYPE(const std::time_t, boost::filesystem::path) file, folder_set) { counter++; - if (counter > 10) + if (counter > nWalletBackups) { - // More than 10 backups: delete oldest one(s) - try { + // More than nWalletBackups backups: delete oldest one(s) + try { boost::filesystem::remove(file.second); LogPrintf("Old backup deleted: %s\n", file.second); } catch(boost::filesystem::filesystem_error &error) { LogPrintf("Failed to delete backup %s\n", error.what()); - } + } } } } } - + LogPrintf("Using wallet %s\n", strWalletFile); uiInterface.InitMessage(_("Verifying wallet...")); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 259cafb77..f8f0e9bbb 100755 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -331,8 +331,8 @@ void BitcoinGUI::createActions(bool fIsTestnet) openNetworkAction->setStatusTip(tr("Show network monitor")); openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this); openConfEditorAction->setStatusTip(tr("Open configuration file")); - showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Auto&Backups"), this); - showBackupsAction->setStatusTip(tr("S")); + showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Automatic &Backups"), this); + showBackupsAction->setStatusTip(tr("Show automatically created wallet backups")); usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this); usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels")); From 9c9085716e13b02208e930ea8833f259168fb880 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Mon, 13 Apr 2015 06:53:55 -0700 Subject: [PATCH 15/18] update seeder order --- src/chainparams.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 597053818..064e91cd9 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -62,9 +62,9 @@ public: assert(hashGenesisBlock == uint256("0x00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6")); assert(genesis.hashMerkleRoot == uint256("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7")); - vSeeds.push_back(CDNSSeedData("masternode.io", "dnsseed.masternode.io")); - vSeeds.push_back(CDNSSeedData("darkcoin.qa", "dnsseed.darkcoin.qa")); vSeeds.push_back(CDNSSeedData("darkcoin.io", "dnsseed.darkcoin.io")); + vSeeds.push_back(CDNSSeedData("darkcoin.qa", "dnsseed.darkcoin.qa")); + vSeeds.push_back(CDNSSeedData("masternode.io", "dnsseed.masternode.io")); base58Prefixes[PUBKEY_ADDRESS] = list_of( 76); // Dash addresses start with 'X' base58Prefixes[SCRIPT_ADDRESS] = list_of( 16); // Dash script addresses start with '7' @@ -133,9 +133,9 @@ public: /*vSeeds.push_back(CDNSSeedData("dashpay.io", "testnet-seed.dashpay.io")); vSeeds.push_back(CDNSSeedData("dash.qa", "testnet-seed.dash.qa")); *///legacy seeders + vSeeds.push_back(CDNSSeedData("darkcoin.io", "testnet-seed.darkcoin.io")); vSeeds.push_back(CDNSSeedData("darkcoin.qa", "testnet-seed.darkcoin.qa")); vSeeds.push_back(CDNSSeedData("masternode.io", "test.dnsseed.masternode.io")); - vSeeds.push_back(CDNSSeedData("darkcoin.io", "testnet-seed.darkcoin.io")); base58Prefixes[PUBKEY_ADDRESS] = list_of(139); // Testnet dash addresses start with 'x' or 'y' base58Prefixes[SCRIPT_ADDRESS] = list_of( 19); // Testnet dash script addresses start with '8' or '9' From 51b6287695f181286b83919660008cfcba1313a9 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Mon, 13 Apr 2015 06:55:09 -0700 Subject: [PATCH 16/18] add dashpay seed --- src/chainparams.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 064e91cd9..a77acbc34 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -65,6 +65,7 @@ public: vSeeds.push_back(CDNSSeedData("darkcoin.io", "dnsseed.darkcoin.io")); vSeeds.push_back(CDNSSeedData("darkcoin.qa", "dnsseed.darkcoin.qa")); vSeeds.push_back(CDNSSeedData("masternode.io", "dnsseed.masternode.io")); + vSeeds.push_back(CDNSSeedData("dashpay.io", "dnsseed.dashpay.io")); base58Prefixes[PUBKEY_ADDRESS] = list_of( 76); // Dash addresses start with 'X' base58Prefixes[SCRIPT_ADDRESS] = list_of( 16); // Dash script addresses start with '7' From d8ebb6826d0cec091aa103e75554ee665f7d9254 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Mon, 13 Apr 2015 07:01:52 -0700 Subject: [PATCH 17/18] update hard-coded nodes --- src/chainparams.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a77acbc34..407520d97 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -21,9 +21,9 @@ using namespace boost::assign; unsigned int pnSeed[] = { - 0x3210ce66, 0x3213747b, 0x1717ba83, 0x3210ce66, 0x3213747b, - 0x1715cc22, 0xbc8e2769, 0x36f8e397, 0x2a793a5b, 0x3251c027, - 0x05fe6003, 0xaf73c92c, 0xd035bf02, 0xc06f4182, 0xa2f32110, + 0xb32b80ef, 0x807f6aeb, 0x259dfa0a, 0xa2d16323, 0x6c3dd236, + 0xacf50584, 0x2ea2420a, 0x4e6db2c3, 0x8a80a95e, 0x340b8de5, + 0x253b153a, 0x2e69760f, 0xb2217edd, 0x68ec1783, 0x6c3dd125, }; class CMainParams : public CChainParams { From c38eff15e0ba9757d402d9698c3cb5d34e2906c8 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Mon, 13 Apr 2015 10:49:02 -0700 Subject: [PATCH 18/18] Ignore dsee entries with signatures --- src/masternodeman.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 67d3c04dd..697481da0 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -364,7 +364,7 @@ CMasternode* CMasternodeMan::FindOldestNotInVec(const std::vector &vVins, bool found = false; BOOST_FOREACH(const CTxIn& vin, vVins) - if(mn.vin == vin) + if(mn.vin.prevout == vin.prevout) { found = true; break; @@ -610,6 +610,11 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData return; } + if(!vin.scriptSig.empty()) { + LogPrintf("dsee - Ignore Not Empty ScriptSig %s\n",vin.ToString().c_str()); + return; + } + std::string errorMessage = ""; if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ LogPrintf("dsee - Got bad Masternode address signature\n");