diff --git a/CMakeLists.txt b/CMakeLists.txt index 6774e0e..90c7188 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1089,6 +1089,12 @@ if(BDB_INCLUDE_DIR AND BDB_LIBRARY) add_executable(dragonx-wallet-rebuild tools/wallet_rebuild/main.cpp) target_include_directories(dragonx-wallet-rebuild PRIVATE ${CMAKE_SOURCE_DIR}/src ${BDB_INCLUDE_DIR}) target_link_libraries(dragonx-wallet-rebuild PRIVATE ${BDB_LIBRARY}) + if(WIN32) + target_link_libraries(dragonx-wallet-rebuild PRIVATE ws2_32) # static libdb-6.2 pulls in winsock + else() + find_package(Threads REQUIRED) + target_link_libraries(dragonx-wallet-rebuild PRIVATE Threads::Threads ${CMAKE_DL_LIBS}) # static libdb needs pthread/dl + endif() set_target_properties(dragonx-wallet-rebuild PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) message(STATUS "wallet-rebuild helper: ON (Berkeley DB ${BDB_LIBRARY})") else() diff --git a/build.sh b/build.sh index d8681a4..66d9f3b 100755 --- a/build.sh +++ b/build.sh @@ -286,6 +286,14 @@ bundle_linux_daemon() { # asmap.dat find_asmap && cp "$ASMAP_DAT" "$dest/asmap.dat" && info " Bundled asmap.dat" + # dragonx-wallet-rebuild helper (offline recovery for a BDB-inconsistent wallet.dat) + for p in "$SCRIPT_DIR/build/linux/bin/dragonx-wallet-rebuild" "$SCRIPT_DIR/../dragonx-wallet-rebuild"; do + if [[ -f "$p" ]]; then + cp "$p" "$dest/dragonx-wallet-rebuild"; chmod +x "$dest/dragonx-wallet-rebuild" + info " Bundled dragonx-wallet-rebuild"; break + fi + done + return $found } @@ -336,11 +344,20 @@ build_release_linux() { mkdir -p "$bd" && cd "$bd" # ── Compile ────────────────────────────────────────────────────────────── + # Point the wallet-rebuild helper at the vendored static Berkeley DB (same libdb the daemon links) + # so its output is a v6.2 btree the bundled dragonxd reads. Pass the paths EXPLICITLY (bypasses + # find_library + its cache); the helper target is simply not built if the depends tree is absent. + local lin_bdb="$SCRIPT_DIR/external/dragonx/depends/x86_64-unknown-linux-gnu" + local BDB_ARGS=() + if [[ -f "$lin_bdb/lib/libdb-6.2.a" && -f "$lin_bdb/include/db.h" ]]; then + BDB_ARGS=( -DBDB_INCLUDE_DIR="$lin_bdb/include" -DBDB_LIBRARY="$lin_bdb/lib/libdb-6.2.a" ) + fi info "Configuring ..." cmake "$SCRIPT_DIR" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \ -DDRAGONX_USE_SYSTEM_SDL3=ON \ + "${BDB_ARGS[@]}" \ "${CMAKE_LITE_ARGS[@]}" info "Building with $JOBS jobs ..." @@ -350,6 +367,7 @@ build_release_linux() { info "Stripping ..." strip "bin/${APP_BASENAME}" + [[ -f "bin/dragonx-wallet-rebuild" ]] && strip "bin/dragonx-wallet-rebuild" info "Binary: $(du -h "bin/${APP_BASENAME}" | cut -f1)" if should_bundle_full_node_assets; then @@ -750,11 +768,20 @@ HDR fi # ── CMake + build ──────────────────────────────────────────────────────── + # The wallet-rebuild helper links the vendored mingw static Berkeley DB (the mingw toolchain's + # find_library is sysroot-only, so pass the depends paths EXPLICITLY to bypass the search). Only + # enabled if the depends tree is present; guarded with -DBDB_* left empty otherwise. + local win_bdb="$SCRIPT_DIR/external/dragonx/depends/x86_64-w64-mingw32" + local BDB_ARGS=() + if [[ -f "$win_bdb/lib/libdb-6.2.a" && -f "$win_bdb/include/db.h" ]]; then + BDB_ARGS=( -DBDB_INCLUDE_DIR="$win_bdb/include" -DBDB_LIBRARY="$win_bdb/lib/libdb-6.2.a" ) + fi info "Configuring (cross-compile) ..." cmake "$SCRIPT_DIR" \ -DCMAKE_TOOLCHAIN_FILE="$bd/mingw-toolchain.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DDRAGONX_USE_SYSTEM_SDL3=OFF \ + "${BDB_ARGS[@]}" \ "${FT_CMAKE_ARG[@]}" \ "${CMAKE_LITE_ARGS[@]}" @@ -779,6 +806,8 @@ HDR for f in dragonxd.exe dragonx-cli.exe dragonx-tx.exe; do [[ -f "$DD/$f" ]] && cp "$DD/$f" "$dist_dir/" done + # dragonx-wallet-rebuild helper (offline recovery for a BDB-inconsistent wallet.dat) + [[ -f "bin/dragonx-wallet-rebuild.exe" ]] && { cp "bin/dragonx-wallet-rebuild.exe" "$dist_dir/"; info " Bundled dragonx-wallet-rebuild.exe"; } # Bundle Sapling params + asmap for the zip distribution # (The single-file exe has these embedded via INCBIN, but the zip