Modernize Windows Qt6 wallet build
This commit is contained in:
@@ -406,9 +406,12 @@ AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
|
||||
if test -d "$qt_plugin_path/generic"; then
|
||||
QT_LIBS="$QT_LIBS -L$qt_plugin_path/generic"
|
||||
fi
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledHarfbuzz -lQt6BundledLibpng -lQt6BundledLibjpeg -lQt6BundledPcre2"
|
||||
if test "x$TARGET_OS" = xwindows; then
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledFreetype -ld3d11 -ldxgi -ldwrite -ldwmapi -luxtheme -lversion -lauthz -luserenv -lnetapi32 -lsynchronization -lsecur32 -lwinhttp -lsetupapi -lshcore -lwtsapi32 -ld3d9 -lruntimeobject"
|
||||
fi
|
||||
if test "x$TARGET_OS" = xlinux; then
|
||||
QT_LIBS="-lQt6XcbQpa -lQt6InputSupport -lQt6FbSupport -lQt6DeviceDiscoverySupport $QT_LIBS"
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledHarfbuzz -lQt6BundledLibpng -lQt6BundledLibjpeg -lQt6BundledPcre2"
|
||||
if test "x$PKG_CONFIG" != x; then
|
||||
QT6_XCB_LIBS=`PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig $PKG_CONFIG --libs --static x11 x11-xcb xcb xcb-cursor xcb-icccm xcb-image xcb-keysyms xcb-randr xcb-renderutil xcb-shape xcb-shm xcb-sync xcb-xfixes xcb-xkb xkbcommon xkbcommon-x11 fontconfig freetype2 harfbuzz 2>/dev/null`
|
||||
QT_LIBS="$QT_LIBS $QT6_XCB_LIBS"
|
||||
|
||||
@@ -29333,9 +29333,12 @@ printf "%s\n" "#define QT_STATICPLUGIN 1" >>confdefs.h
|
||||
if test -d "$qt_plugin_path/generic"; then
|
||||
QT_LIBS="$QT_LIBS -L$qt_plugin_path/generic"
|
||||
fi
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledHarfbuzz -lQt6BundledLibpng -lQt6BundledLibjpeg -lQt6BundledPcre2"
|
||||
if test "x$TARGET_OS" = xwindows; then
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledFreetype -ld3d11 -ldxgi -ldwrite -ldwmapi -luxtheme -lversion -lauthz -luserenv -lnetapi32 -lsynchronization -lsecur32 -lwinhttp -lsetupapi -lshcore -lwtsapi32 -ld3d9 -lruntimeobject"
|
||||
fi
|
||||
if test "x$TARGET_OS" = xlinux; then
|
||||
QT_LIBS="-lQt6XcbQpa -lQt6InputSupport -lQt6FbSupport -lQt6DeviceDiscoverySupport $QT_LIBS"
|
||||
QT_LIBS="$QT_LIBS -lQt6BundledHarfbuzz -lQt6BundledLibpng -lQt6BundledLibjpeg -lQt6BundledPcre2"
|
||||
if test "x$PKG_CONFIG" != x; then
|
||||
QT6_XCB_LIBS=`PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig $PKG_CONFIG --libs --static x11 x11-xcb xcb xcb-cursor xcb-icccm xcb-image xcb-keysyms xcb-randr xcb-renderutil xcb-shape xcb-shm xcb-sync xcb-xfixes xcb-xkb xkbcommon xkbcommon-x11 fontconfig freetype2 harfbuzz 2>/dev/null`
|
||||
QT_LIBS="$QT_LIBS $QT6_XCB_LIBS"
|
||||
|
||||
@@ -4,8 +4,9 @@ set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
JOBS="${JOBS:-1}"
|
||||
HOST="${HOST:-x86_64-w64-mingw32}"
|
||||
BUILD_HOST="${BUILD_HOST:-$("$ROOT/depends/config.guess")}"
|
||||
PREFIX="$ROOT/depends/$HOST"
|
||||
NATIVE_BIN="$PREFIX/native/bin"
|
||||
NATIVE_BIN="$ROOT/depends/build/$BUILD_HOST/bin"
|
||||
PROTOBUF_VERSION="${PROTOBUF_VERSION:-2.6.1}"
|
||||
PROTOBUF_SOURCE="$ROOT/depends/sources/protobuf-$PROTOBUF_VERSION.tar.bz2"
|
||||
PROTOBUF_BUILD="${PROTOBUF_BUILD:-/tmp/agrarian-protobuf-$PROTOBUF_VERSION-native}"
|
||||
@@ -27,7 +28,7 @@ require_path() {
|
||||
copy_first_match() {
|
||||
local name="$1"
|
||||
local match
|
||||
match="$(find "$ROOT/depends/work/build/$HOST" -path "*/qtbase/bin/$name" -type f | sort | tail -n 1 || true)"
|
||||
match="$(find "$ROOT/depends/$BUILD_HOST" \( -path "*/bin/$name" -o -path "*/libexec/$name" \) -type f | sort | tail -n 1 || true)"
|
||||
if [[ -z "$match" ]]; then
|
||||
echo "Could not find Qt host tool after depends build: $name" >&2
|
||||
exit 1
|
||||
@@ -97,6 +98,15 @@ require_cmd cp
|
||||
ensure_posix_mingw
|
||||
|
||||
echo "Building Win64 depends for $HOST..."
|
||||
echo "Building native Qt6 host tools and metadata for $BUILD_HOST..."
|
||||
make -C depends HOST="$BUILD_HOST" NO_QT=0 qt -j"$JOBS"
|
||||
qt_host_cache=( "$ROOT/depends/built/$BUILD_HOST/qt"/qt-*.tar.gz )
|
||||
if [[ ${#qt_host_cache[@]} -ne 1 || ! -f "${qt_host_cache[0]}" ]]; then
|
||||
echo "Could not locate a single native Qt6 cache archive for $BUILD_HOST" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$ROOT/depends/$BUILD_HOST"
|
||||
tar --no-same-owner -xf "${qt_host_cache[0]}" -C "$ROOT/depends/$BUILD_HOST"
|
||||
make -C depends HOST="$HOST" NO_QT=0 -j"$JOBS"
|
||||
require_path "$PREFIX/share/config.site"
|
||||
ensure_native_tools
|
||||
@@ -105,17 +115,20 @@ if [[ ! -f configure ]]; then
|
||||
./autogen.sh
|
||||
fi
|
||||
|
||||
echo "Configuring Win64 Qt wallet build..."
|
||||
echo "Configuring Win64 Qt6 wallet build..."
|
||||
CONFIG_SITE="$PREFIX/share/config.site" ./configure \
|
||||
--prefix=/ \
|
||||
--disable-maintainer-mode \
|
||||
--disable-tests \
|
||||
--disable-bench \
|
||||
--with-gui=qt5 \
|
||||
--with-gui=qt6 \
|
||||
--with-qt-incdir="$PREFIX/include" \
|
||||
--with-qt-libdir="$PREFIX/lib"
|
||||
--with-qt-libdir="$PREFIX/lib" \
|
||||
--with-qt-plugindir="$PREFIX/plugins" \
|
||||
--with-qt-translationdir="$PREFIX/translations" \
|
||||
--with-qt-bindir="$NATIVE_BIN"
|
||||
|
||||
echo "Building Win64 Qt wallet with JOBS=$JOBS..."
|
||||
echo "Building Win64 Qt6 wallet with JOBS=$JOBS..."
|
||||
make -j"$JOBS"
|
||||
|
||||
echo "Windows wallet build complete:"
|
||||
|
||||
@@ -36,6 +36,8 @@ $(package)_config_opts_m68k_linux=linux-generic32
|
||||
$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc
|
||||
$(package)_config_opts_x86_64_mingw32=mingw64
|
||||
$(package)_config_opts_i686_mingw32=mingw
|
||||
$(package)_config_env_x86_64_mingw32=WINDRES=x86_64-w64-mingw32-windres
|
||||
$(package)_config_env_i686_mingw32=WINDRES=i686-w64-mingw32-windres
|
||||
endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
|
||||
+17
-3
@@ -29,6 +29,7 @@ $(package)_config_opts += -no-icu
|
||||
$(package)_config_opts += -no-opengl
|
||||
$(package)_config_opts += -no-pch
|
||||
$(package)_config_opts += -no-feature-sql
|
||||
$(package)_config_opts += -no-feature-vulkan
|
||||
$(package)_config_opts += -nomake examples
|
||||
$(package)_config_opts += -nomake tests
|
||||
$(package)_config_opts += -opensource
|
||||
@@ -49,6 +50,19 @@ $(package)_config_opts_linux += -system-freetype
|
||||
$(package)_config_opts_linux += -no-feature-sessionmanager
|
||||
$(package)_config_opts_mingw32 = -qpa windows
|
||||
$(package)_config_opts_darwin = -qpa cocoa
|
||||
$(package)_cmake_opts_mingw32 = -DCMAKE_SYSTEM_NAME=Windows
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_C_COMPILER=$($(package)_cc)
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_CXX_COMPILER=$($(package)_cxx)
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_RC_COMPILER=$(host_toolchain)windres
|
||||
$(package)_cmake_opts_mingw32 += -DOPENSSL_ROOT_DIR=$(host_prefix)
|
||||
$(package)_cmake_opts_mingw32 += -DOPENSSL_USE_STATIC_LIBS=TRUE
|
||||
$(package)_cmake_opts_mingw32 += -DZLIB_ROOT=$(host_prefix)
|
||||
$(package)_cmake_opts_mingw32 += -DQT_HOST_PATH=$(BASEDIR)/$(BUILD)
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_FIND_ROOT_PATH=$(host_prefix)
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
|
||||
$(package)_cmake_opts_mingw32 += -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
|
||||
endef
|
||||
|
||||
define $(package)_fetch_cmds
|
||||
@@ -71,9 +85,9 @@ endef
|
||||
|
||||
define $(package)_config_cmds
|
||||
export PKG_CONFIG_SYSROOT_DIR=/ && \
|
||||
export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig && \
|
||||
export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig$(if $(filter linux,$(host_os)),:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig) && \
|
||||
export PKG_CONFIG_PATH=$(host_prefix)/share/pkgconfig && \
|
||||
../qtbase/configure $($(package)_config_opts) -- -G Ninja
|
||||
../qtbase/configure $($(package)_config_opts) -- -G Ninja $($(package)_cmake_opts) $($(package)_cmake_opts_$(host_os)) $($(package)_cmake_opts_$(host_arch)_$(host_os))
|
||||
endef
|
||||
|
||||
define $(package)_build_cmds
|
||||
@@ -85,6 +99,6 @@ define $(package)_stage_cmds
|
||||
endef
|
||||
|
||||
define $(package)_postprocess_cmds
|
||||
rm -rf lib/cmake share/doc share/examples share/qt6/sbom && \
|
||||
rm -rf share/doc share/examples share/qt6/sbom && \
|
||||
rm -f lib/lib*.la lib/*.prl plugins/*/*.prl
|
||||
endef
|
||||
|
||||
@@ -53,7 +53,7 @@ The wallet build is sensitive to tool version mismatches:
|
||||
|
||||
* Native Ubuntu uses the deterministic depends Qt6, OpenSSL, Boost, protobuf,
|
||||
and supporting libraries.
|
||||
* Windows cross-target wallets currently use the existing Qt5 cross path and
|
||||
* Windows cross-target wallets use the deterministic depends Qt6 path and
|
||||
matching Qt host tools staged by depends.
|
||||
|
||||
The helper scripts keep those rules in one place so the build is repeatable on a
|
||||
|
||||
@@ -227,9 +227,9 @@ builds and stages a matching native `protoc` when needed.
|
||||
QT NOTE
|
||||
============================================================
|
||||
|
||||
The current Windows cross-build helper still targets the existing Qt5 cross
|
||||
path. The native Ubuntu wallet path has moved to Qt6. Keep those paths separate
|
||||
until the Windows Qt6 cross-build is explicitly modernized and smoke-tested.
|
||||
The Windows cross-build helper targets the Qt6 depends path. Keep the helper's
|
||||
Qt host tools (`moc`, `uic`, `rcc`) staged from the matching depends build to
|
||||
avoid mixing host Qt tools with target Qt libraries.
|
||||
|
||||
============================================================
|
||||
END OF DOCUMENT
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@ The installer requires these `.pc` files in `depends/<host>/(lib|share)/pkgconfi
|
||||
|
||||
- Native Ubuntu Qt6 path: `Qt6Core.pc`, `Qt6Gui.pc`, `Qt6Network.pc`,
|
||||
`Qt6Widgets.pc`
|
||||
- Windows cross-build Qt5 path: `Qt5Core.pc`, `Qt5Gui.pc`, `Qt5Network.pc`,
|
||||
`Qt5Widgets.pc`
|
||||
- Windows cross-build Qt6 path: `Qt6Core.pc`, `Qt6Gui.pc`, `Qt6Network.pc`,
|
||||
`Qt6Widgets.pc`
|
||||
|
||||
Fix by rebuilding depends with Qt enabled:
|
||||
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ If wallet is enabled (default), installer preflight checks require:
|
||||
|
||||
For the current native Ubuntu Qt wallet path, depends should also provide Qt6
|
||||
pkg-config files such as `Qt6Core.pc`, `Qt6Gui.pc`, `Qt6Network.pc`, and
|
||||
`Qt6Widgets.pc`. The Windows cross-build path still uses the existing Qt5
|
||||
depends target.
|
||||
`Qt6Widgets.pc`. The Windows cross-build path also uses the Qt6 depends target.
|
||||
|
||||
When missing, the installer exits early and prints the exact missing path(s) plus the `make -C depends ...` command to fix them.
|
||||
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ static void convertSeed6(std::vector<CAddress>& vSeedsOut, const SeedSpec6* data
|
||||
static Checkpoints::MapCheckpoints mapCheckpoints =
|
||||
boost::assign::map_list_of
|
||||
(0, uint256("000003452250d81f8b07d42e127c92729802e3c48f3c7b9834256fd0fb9a0c2e"));
|
||||
static const Checkpoints::CCheckpointData data = {
|
||||
static const Checkpoints::CCheckpointData mainCheckpointData = {
|
||||
&mapCheckpoints,
|
||||
1643790201, // * UNIX timestamp of last checkpoint block
|
||||
0, // * total number of transactions between genesis and last checkpoint
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
|
||||
const Checkpoints::CCheckpointData& Checkpoints() const
|
||||
{
|
||||
return data;
|
||||
return mainCheckpointData;
|
||||
}
|
||||
};
|
||||
static CMainParams mainParams;
|
||||
@@ -462,7 +462,7 @@ public:
|
||||
const Checkpoints::CCheckpointData& Checkpoints() const
|
||||
{
|
||||
// UnitTest share the same checkpoints as MAIN
|
||||
return data;
|
||||
return mainCheckpointData;
|
||||
}
|
||||
|
||||
//! Published setters to allow changing values in unit test cases
|
||||
|
||||
+24
-24
@@ -684,12 +684,12 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
}
|
||||
|
||||
// hardcoded $DATADIR/bootstrap.dat
|
||||
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
if (filesystem::exists(pathBootstrap)) {
|
||||
boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
if (boost::filesystem::exists(pathBootstrap)) {
|
||||
FILE* file = fopen(pathBootstrap.string().c_str(), "rb");
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
LogPrintf("Importing bootstrap.dat...\n");
|
||||
LoadExternalBlockFile(file);
|
||||
RenameOver(pathBootstrap, pathBootstrapOld);
|
||||
@@ -1105,15 +1105,15 @@ bool AppInit2()
|
||||
// ********************************************************* Step 5: Backup wallet and verify wallet database integrity
|
||||
#ifdef ENABLE_WALLET
|
||||
if (!fDisableWallet) {
|
||||
filesystem::path backupDir = GetDataDir() / "backups";
|
||||
if (!filesystem::exists(backupDir)) {
|
||||
boost::filesystem::path backupDir = GetDataDir() / "backups";
|
||||
if (!boost::filesystem::exists(backupDir)) {
|
||||
// Always create backup folder to not confuse the operating system's file browser
|
||||
filesystem::create_directories(backupDir);
|
||||
boost::filesystem::create_directories(backupDir);
|
||||
}
|
||||
nWalletBackups = GetArg("-createwalletbackups", 10);
|
||||
nWalletBackups = std::max(0, std::min(10, nWalletBackups));
|
||||
if (nWalletBackups > 0) {
|
||||
if (filesystem::exists(backupDir)) {
|
||||
if (boost::filesystem::exists(backupDir)) {
|
||||
// Create backup of the wallet
|
||||
std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d-%H-%M", GetTime());
|
||||
std::string backupPathStr = backupDir.string();
|
||||
@@ -1176,30 +1176,30 @@ bool AppInit2()
|
||||
if (GetBoolArg("-resync", false)) {
|
||||
uiInterface.InitMessage(_("Preparing for resync..."));
|
||||
// Delete the local blockchain folders to force a resync from scratch to get a consitent blockchain-state
|
||||
filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
filesystem::path chainstateDir = GetDataDir() / "chainstate";
|
||||
filesystem::path sporksDir = GetDataDir() / "sporks";
|
||||
filesystem::path zerocoinDir = GetDataDir() / "zerocoin";
|
||||
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
boost::filesystem::path chainstateDir = GetDataDir() / "chainstate";
|
||||
boost::filesystem::path sporksDir = GetDataDir() / "sporks";
|
||||
boost::filesystem::path zerocoinDir = GetDataDir() / "zerocoin";
|
||||
|
||||
LogPrintf("Deleting blockchain folders blocks, chainstate, sporks and zerocoin\n");
|
||||
// We delete in 4 individual steps in case one of the folder is missing already
|
||||
try {
|
||||
if (filesystem::exists(blocksDir)){
|
||||
if (boost::filesystem::exists(blocksDir)){
|
||||
boost::filesystem::remove_all(blocksDir);
|
||||
LogPrintf("-resync: folder deleted: %s\n", blocksDir.string().c_str());
|
||||
}
|
||||
|
||||
if (filesystem::exists(chainstateDir)){
|
||||
if (boost::filesystem::exists(chainstateDir)){
|
||||
boost::filesystem::remove_all(chainstateDir);
|
||||
LogPrintf("-resync: folder deleted: %s\n", chainstateDir.string().c_str());
|
||||
}
|
||||
|
||||
if (filesystem::exists(sporksDir)){
|
||||
if (boost::filesystem::exists(sporksDir)){
|
||||
boost::filesystem::remove_all(sporksDir);
|
||||
LogPrintf("-resync: folder deleted: %s\n", sporksDir.string().c_str());
|
||||
}
|
||||
|
||||
if (filesystem::exists(zerocoinDir)){
|
||||
if (boost::filesystem::exists(zerocoinDir)){
|
||||
boost::filesystem::remove_all(zerocoinDir);
|
||||
LogPrintf("-resync: folder deleted: %s\n", zerocoinDir.string().c_str());
|
||||
}
|
||||
@@ -1236,7 +1236,7 @@ bool AppInit2()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filesystem::exists(GetDataDir() / strWalletFile)) {
|
||||
if (boost::filesystem::exists(GetDataDir() / strWalletFile)) {
|
||||
CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover);
|
||||
if (r == CDBEnv::RECOVER_OK) {
|
||||
string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
|
||||
@@ -1400,19 +1400,19 @@ bool AppInit2()
|
||||
fReindex = GetBoolArg("-reindex", false);
|
||||
|
||||
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
|
||||
filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
if (!filesystem::exists(blocksDir)) {
|
||||
filesystem::create_directories(blocksDir);
|
||||
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
if (!boost::filesystem::exists(blocksDir)) {
|
||||
boost::filesystem::create_directories(blocksDir);
|
||||
bool linked = false;
|
||||
for (unsigned int i = 1; i < 10000; i++) {
|
||||
filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
|
||||
if (!filesystem::exists(source)) break;
|
||||
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i - 1);
|
||||
boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
|
||||
if (!boost::filesystem::exists(source)) break;
|
||||
boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i - 1);
|
||||
try {
|
||||
filesystem::create_hard_link(source, dest);
|
||||
boost::filesystem::create_hard_link(source, dest);
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
|
||||
linked = true;
|
||||
} catch (filesystem::filesystem_error& e) {
|
||||
} catch (boost::filesystem::filesystem_error& e) {
|
||||
// Note: hardlink creation failing is not a disaster, it just means
|
||||
// blocks will get re-downloaded from peers.
|
||||
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
|
||||
|
||||
+1
-1
@@ -4966,7 +4966,7 @@ bool AbortNode(const std::string& strMessage, const std::string& userMessage)
|
||||
|
||||
bool CheckDiskSpace(uint64_t nAdditionalBytes)
|
||||
{
|
||||
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
|
||||
uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available;
|
||||
|
||||
// Check for nMinDiskSpace bytes (currently 50MB)
|
||||
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)
|
||||
|
||||
+19
-18
@@ -4,6 +4,25 @@
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32_WINNT
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#ifdef _WIN32_IE
|
||||
#undef _WIN32_IE
|
||||
#endif
|
||||
#define _WIN32_IE 0x0501
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
#include "guiutil.h"
|
||||
|
||||
#include "bitcoinaddressvalidator.h"
|
||||
@@ -19,24 +38,6 @@
|
||||
#include "script/standard.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32_WINNT
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#ifdef _WIN32_IE
|
||||
#undef _WIN32_IE
|
||||
#endif
|
||||
#define _WIN32_IE 0x0501
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include "shellapi.h"
|
||||
#include "shlobj.h"
|
||||
#include "shlwapi.h"
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#if BOOST_FILESYSTEM_VERSION >= 3
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// If we don't want a message to be processed by Qt, return true and set result to
|
||||
// the value that the window procedure should return. Otherwise return false.
|
||||
bool WinShutdownMonitor::nativeEventFilter(const QByteArray& eventType, void* pMessage, long* pnResult)
|
||||
bool WinShutdownMonitor::nativeEventFilter(const QByteArray& eventType, void* pMessage, WinShutdownMonitorResult* pnResult)
|
||||
{
|
||||
Q_UNUSED(eventType);
|
||||
|
||||
|
||||
@@ -12,12 +12,19 @@
|
||||
#include <windef.h> // for HWND
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
typedef qintptr WinShutdownMonitorResult;
|
||||
#else
|
||||
typedef long WinShutdownMonitorResult;
|
||||
#endif
|
||||
|
||||
class WinShutdownMonitor : public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
/** Implements QAbstractNativeEventFilter interface for processing Windows messages */
|
||||
bool nativeEventFilter(const QByteArray& eventType, void* pMessage, long* pnResult);
|
||||
bool nativeEventFilter(const QByteArray& eventType, void* pMessage, WinShutdownMonitorResult* pnResult);
|
||||
|
||||
/** Register the reason for blocking shutdown on Windows to allow clean client exit */
|
||||
static void registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId);
|
||||
|
||||
@@ -4505,22 +4505,22 @@ string CWallet::GetUniqueWalletBackupName(bool fzagrAuto) const
|
||||
|
||||
void CWallet::ZPivBackupWallet()
|
||||
{
|
||||
filesystem::path backupDir = GetDataDir() / "backups";
|
||||
filesystem::path backupPath;
|
||||
boost::filesystem::path backupDir = GetDataDir() / "backups";
|
||||
boost::filesystem::path backupPath;
|
||||
string strNewBackupName;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
strNewBackupName = strprintf("wallet-autozagrbackup-%d.dat", i);
|
||||
backupPath = backupDir / strNewBackupName;
|
||||
|
||||
if (filesystem::exists(backupPath)) {
|
||||
if (boost::filesystem::exists(backupPath)) {
|
||||
//Keep up to 10 backups
|
||||
if (i <= 8) {
|
||||
//If the next file backup exists and is newer, then iterate
|
||||
filesystem::path nextBackupPath = backupDir / strprintf("wallet-autozagrbackup-%d.dat", i + 1);
|
||||
if (filesystem::exists(nextBackupPath)) {
|
||||
time_t timeThis = filesystem::last_write_time(backupPath);
|
||||
time_t timeNext = filesystem::last_write_time(nextBackupPath);
|
||||
boost::filesystem::path nextBackupPath = backupDir / strprintf("wallet-autozagrbackup-%d.dat", i + 1);
|
||||
if (boost::filesystem::exists(nextBackupPath)) {
|
||||
time_t timeThis = boost::filesystem::last_write_time(backupPath);
|
||||
time_t timeNext = boost::filesystem::last_write_time(nextBackupPath);
|
||||
if (timeThis > timeNext) {
|
||||
//The next backup is created before this backup was
|
||||
//The next backup is the correct path to use
|
||||
@@ -4543,8 +4543,8 @@ void CWallet::ZPivBackupWallet()
|
||||
BackupWallet(*this, backupPath.string());
|
||||
|
||||
if(!GetArg("-zagrbackuppath", "").empty()) {
|
||||
filesystem::path customPath(GetArg("-zagrbackuppath", ""));
|
||||
filesystem::create_directories(customPath);
|
||||
boost::filesystem::path customPath(GetArg("-zagrbackuppath", ""));
|
||||
boost::filesystem::create_directories(customPath);
|
||||
|
||||
if(!customPath.has_extension()) {
|
||||
customPath /= GetUniqueWalletBackupName(true);
|
||||
|
||||
+19
-19
@@ -962,10 +962,10 @@ void NotifyBacked(const CWallet& wallet, bool fSuccess, string strMessage)
|
||||
wallet.NotifyWalletBacked(fSuccess, strMessage);
|
||||
}
|
||||
|
||||
bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool fEnableCustom)
|
||||
bool BackupWallet(const CWallet& wallet, const boost::filesystem::path& strDest, bool fEnableCustom)
|
||||
{
|
||||
filesystem::path pathCustom;
|
||||
filesystem::path pathWithFile;
|
||||
boost::filesystem::path pathCustom;
|
||||
boost::filesystem::path pathWithFile;
|
||||
if (!wallet.fFileBacked) {
|
||||
return false;
|
||||
} else if(fEnableCustom) {
|
||||
@@ -978,8 +978,8 @@ bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool f
|
||||
pathCustom = pathWithFile.parent_path();
|
||||
}
|
||||
try {
|
||||
filesystem::create_directories(pathCustom);
|
||||
} catch(const filesystem::filesystem_error& e) {
|
||||
boost::filesystem::create_directories(pathCustom);
|
||||
} catch(const boost::filesystem::filesystem_error& e) {
|
||||
NotifyBacked(wallet, false, strprintf("%s\n", e.what()));
|
||||
pathCustom = "";
|
||||
}
|
||||
@@ -996,8 +996,8 @@ bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool f
|
||||
bitdb.mapFileUseCount.erase(wallet.strWalletFile);
|
||||
|
||||
// Copy wallet.dat
|
||||
filesystem::path pathDest(strDest);
|
||||
filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
|
||||
boost::filesystem::path pathDest(strDest);
|
||||
boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
|
||||
if (is_directory(pathDest)) {
|
||||
if(!exists(pathDest)) create_directory(pathDest);
|
||||
pathDest /= wallet.strWalletFile;
|
||||
@@ -1008,21 +1008,21 @@ bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool f
|
||||
int nThreshold = GetArg("-custombackupthreshold", DEFAULT_CUSTOMBACKUPTHRESHOLD);
|
||||
if (nThreshold > 0) {
|
||||
|
||||
typedef std::multimap<std::time_t, filesystem::path> folder_set_t;
|
||||
typedef std::multimap<std::time_t, boost::filesystem::path> folder_set_t;
|
||||
folder_set_t folderSet;
|
||||
filesystem::directory_iterator end_iter;
|
||||
boost::filesystem::directory_iterator end_iter;
|
||||
|
||||
pathCustom.make_preferred();
|
||||
// Build map of backup files for current(!) wallet sorted by last write time
|
||||
|
||||
filesystem::path currentFile;
|
||||
for (filesystem::directory_iterator dir_iter(pathCustom); dir_iter != end_iter; ++dir_iter) {
|
||||
boost::filesystem::path currentFile;
|
||||
for (boost::filesystem::directory_iterator dir_iter(pathCustom); dir_iter != end_iter; ++dir_iter) {
|
||||
// Only check regular files
|
||||
if (filesystem::is_regular_file(dir_iter->status())) {
|
||||
if (boost::filesystem::is_regular_file(dir_iter->status())) {
|
||||
currentFile = dir_iter->path().filename();
|
||||
// Only add the backups for the current wallet, e.g. wallet.dat.*
|
||||
if (dir_iter->path().stem().string() == wallet.strWalletFile) {
|
||||
folderSet.insert(folder_set_t::value_type(filesystem::last_write_time(dir_iter->path()), *dir_iter));
|
||||
folderSet.insert(folder_set_t::value_type(boost::filesystem::last_write_time(dir_iter->path()), *dir_iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1046,10 +1046,10 @@ bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool f
|
||||
try {
|
||||
auto entry = folderSet.find(oldestBackup);
|
||||
if (entry != folderSet.end()) {
|
||||
filesystem::remove(entry->second);
|
||||
boost::filesystem::remove(entry->second);
|
||||
LogPrintf("Old backup deleted: %s\n", (*entry).second);
|
||||
}
|
||||
} catch (filesystem::filesystem_error& error) {
|
||||
} catch (boost::filesystem::filesystem_error& error) {
|
||||
string strMessage = strprintf("Failed to delete backup %s\n", error.what());
|
||||
LogPrint(nullptr, strMessage.data());
|
||||
NotifyBacked(wallet, false, strMessage);
|
||||
@@ -1067,7 +1067,7 @@ bool BackupWallet(const CWallet& wallet, const filesystem::path& strDest, bool f
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AttemptBackupWallet(const CWallet& wallet, const filesystem::path& pathSrc, const filesystem::path& pathDest)
|
||||
bool AttemptBackupWallet(const CWallet& wallet, const boost::filesystem::path& pathSrc, const boost::filesystem::path& pathDest)
|
||||
{
|
||||
bool retStatus;
|
||||
string strMessage;
|
||||
@@ -1077,9 +1077,9 @@ bool AttemptBackupWallet(const CWallet& wallet, const filesystem::path& pathSrc,
|
||||
return false;
|
||||
}
|
||||
#if BOOST_VERSION >= 107400 /* BOOST_LIB_VERSION 1_74 */
|
||||
filesystem::copy_file(pathSrc.c_str(), pathDest, filesystem::copy_options::overwrite_existing);
|
||||
boost::filesystem::copy_file(pathSrc.c_str(), pathDest, boost::filesystem::copy_options::overwrite_existing);
|
||||
#elif BOOST_VERSION >= 105800 /* BOOST_LIB_VERSION 1_58 */
|
||||
filesystem::copy_file(pathSrc.c_str(), pathDest, filesystem::copy_option::overwrite_if_exists);
|
||||
boost::filesystem::copy_file(pathSrc.c_str(), pathDest, boost::filesystem::copy_option::overwrite_if_exists);
|
||||
#else
|
||||
std::ifstream src(pathSrc.c_str(), std::ios::binary | std::ios::in);
|
||||
std::ofstream dst(pathDest.c_str(), std::ios::binary | std::ios::out | std::ios::trunc);
|
||||
@@ -1091,7 +1091,7 @@ bool AttemptBackupWallet(const CWallet& wallet, const filesystem::path& pathSrc,
|
||||
strMessage = strprintf("copied wallet.dat to %s\n", pathDest.string());
|
||||
LogPrint(nullptr, strMessage.data());
|
||||
retStatus = true;
|
||||
} catch (const filesystem::filesystem_error& e) {
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
retStatus = false;
|
||||
strMessage = strprintf("%s\n", e.what());
|
||||
LogPrint(nullptr, strMessage.data());
|
||||
|
||||
Reference in New Issue
Block a user