diff --git a/.gitignore b/.gitignore index 9a098af..b5dd9e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.vscode .sass-cache *.*~ *.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 5acea4b..a1809e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(PROJECT_NAME project(${PROJECT_NAME}) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -O3") @@ -14,7 +14,7 @@ endif() if (NOT MONERO_DIR) - set(MONERO_DIR ~/wownero) + set(MONERO_DIR ~/src/wownero) endif() message(STATUS MONERO_DIR ": ${MONERO_DIR}") @@ -49,7 +49,6 @@ list(APPEND CMAKE_MODULE_PATH "${MY_CMAKE_DIR}") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${MONERO_BUILD_DIR}" CACHE PATH "Add Monero directory for library searching") - include(MyUtils) find_package(Monero) @@ -139,12 +138,13 @@ set(LIBRARIES myext mstch wallet + cryptonote_core + cryptonote_basic + cryptonote_protocol + cryptonote_format_utils_basic blockchain_db device - ${WALLET_CRYPTO} - cryptonote_core - cryptonote_protocol - cryptonote_basic + ${WALLET_CRYPTO} multisig daemonizer blocks @@ -165,7 +165,6 @@ set(LIBRARIES ${Boost_LIBRARIES} pthread unbound - curl crypto ssl) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..23fb0c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,97 @@ +# Use ubuntu:latest as base for builder stage image +FROM ubuntu:latest as builder + +# Set Monero branch/tag to be used for monerod compilation +ARG MONERO_BRANCH=v0.18.4.0 + +# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation +ENV DEBIAN_FRONTEND="noninteractive" + +# Install dependencies for monerod and xmrblocks compilation +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + git \ + build-essential \ + cmake \ + miniupnpc \ + graphviz \ + doxygen \ + pkg-config \ + ca-certificates \ + zip \ + libboost-all-dev \ + libunbound-dev \ + libunwind8-dev \ + libssl-dev \ + libcurl4-openssl-dev \ + libgtest-dev \ + libreadline-dev \ + libzmq3-dev \ + libsodium-dev \ + libhidapi-dev \ + libhidapi-libusb0 \ + && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Set compilation environment variables +ENV CFLAGS='-fPIC' +ENV CXXFLAGS='-fPIC' +ENV USE_SINGLE_BUILDDIR=1 +ENV BOOST_DEBUG=1 + +WORKDIR /root + +# Clone and compile monerod with all available threads +ARG NPROC +RUN git clone --recursive --branch ${MONERO_BRANCH} \ + --depth 1 --shallow-submodules https://github.com/monero-project/monero.git \ + && cd monero \ + && test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && make -j"$(cat /nproc)" + +# Copy and cmake/make xmrblocks with all available threads +COPY . /root/onion-monero-blockchain-explorer/ +WORKDIR /root/onion-monero-blockchain-explorer/build +RUN cmake .. && make -j"$(cat /nproc)" + +# Use ldd and awk to bundle up dynamic libraries for the final image +RUN zip /lib.zip $(ldd xmrblocks | grep -E '/[^\ ]*' -o) + +# Use ubuntu:latest as base for final image +FROM ubuntu:latest AS final + +# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation +ENV DEBIAN_FRONTEND="noninteractive" + +# Update Ubuntu packages and install unzip to handle bundled libs from builder stage +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends unzip \ + && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +COPY --from=builder /lib.zip . +RUN unzip -o lib.zip \ + && rm -rf lib.zip \ + && apt purge -y unzip + +# Add user and setup directories for monerod and xmrblocks +RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu \ + && useradd -ms /bin/bash monero \ + && mkdir -p /home/monero/.bitmonero \ + && chown -R monero:monero /home/monero/.bitmonero +USER monero + +# Switch to home directory and install newly built xmrblocks binary +WORKDIR /home/monero +COPY --chown=monero:monero --from=builder /root/onion-monero-blockchain-explorer/build/xmrblocks . +COPY --chown=monero:monero --from=builder /root/onion-monero-blockchain-explorer/build/templates ./templates/ + +# Expose volume used for lmdb access by xmrblocks +VOLUME /home/monero/.bitmonero + +# Expose default explorer http port +EXPOSE 8081 + +ENTRYPOINT ["/bin/sh", "-c"] + +# Set sane defaults that are overridden if the user passes any commands +CMD ["./xmrblocks --enable-json-api --enable-autorefresh-option --enable-pusher"] diff --git a/cmake/FindMonero.cmake b/cmake/FindMonero.cmake index 9b91ecf..b80a55e 100644 --- a/cmake/FindMonero.cmake +++ b/cmake/FindMonero.cmake @@ -45,7 +45,7 @@ foreach (l ${LIBS}) find_library(Xmr_${L}_LIBRARY NAMES ${l} PATHS ${CMAKE_LIBRARY_PATH} - PATH_SUFFIXES "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/src/crypto/wallet" "/contrib/epee/src" "/external/easylogging++/" "/external/${l}" "external/miniupnp/miniupnpc" "/external/RandomWOW" + PATH_SUFFIXES "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/src/crypto/wallet" "/contrib/epee/src" "/external/easylogging++/" "/external/${l}" "external/miniupnp/miniupnpc" "/external/randomwow" NO_DEFAULT_PATH ) @@ -67,6 +67,13 @@ if (EXISTS ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a) PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/src/ringct/libringct_basic.a) endif() +if (EXISTS ${MONERO_BUILD_DIR}/src/cryptonote_basic/libcryptonote_format_utils_basic.a) + message(STATUS FindMonero " found libcryptonote_format_utils_basic.a") + add_library(cryptonote_format_utils_basic STATIC IMPORTED) + set_property(TARGET cryptonote_format_utils_basic + PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/src/cryptonote_basic/libcryptonote_format_utils_basic.a) +endif() + message(STATUS ${MONERO_SOURCE_DIR}/build) @@ -76,7 +83,7 @@ include_directories( ${MONERO_SOURCE_DIR}/src/crypto ${MONERO_SOURCE_DIR}/src/crypto/wallet ${MONERO_SOURCE_DIR}/external - ${MONERO_SOURCE_DIR}/external/RandomWOW/src + ${MONERO_SOURCE_DIR}/external/randomwow/src ${MONERO_SOURCE_DIR}/build ${MONERO_SOURCE_DIR}/external/easylogging++ ${MONERO_SOURCE_DIR}/contrib/epee/include diff --git a/d7853cc48c.patch b/d7853cc48c.patch new file mode 100644 index 0000000..a14bad1 --- /dev/null +++ b/d7853cc48c.patch @@ -0,0 +1,450 @@ +From d7853cc48ca87e3a4a8e08bf96139b40e87a4cfc Mon Sep 17 00:00:00 2001 +From: wowario +Date: Tue, 11 Dec 2018 18:43:06 +0300 +Subject: [PATCH] wowified + +--- + CMakeLists.txt | 2 +- + cmake/FindMonero.cmake | 4 ++-- + main.cpp | 10 ++++----- + src/CmdLineOptions.cpp | 6 +++--- + src/CurrentBlockchainStatus.cpp | 4 ++-- + src/MempoolStatus.cpp | 4 ++-- + src/page.h | 10 ++++----- + src/rpccalls.h | 2 +- + src/templates/checkrawoutputkeys.html | 2 +- + src/templates/footer.html | 2 +- + src/templates/header.html | 4 ++-- + src/templates/index2.html | 2 +- + src/templates/js/config.js | 30 ++++++++++++++++++++++++++ + src/templates/my_outputs.html | 6 +++--- + src/templates/partials/tx_details.html | 16 +++++++------- + src/templates/rawtx.html | 6 +++--- + src/tools.h | 4 ++-- + 17 files changed, 72 insertions(+), 42 deletions(-) + create mode 100755 src/templates/js/config.js + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 34ff718..6c7e633 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -14,7 +14,7 @@ endif() + + + if (NOT MONERO_DIR) +- set(MONERO_DIR ~/monero) ++ set(MONERO_DIR ~/wownero) + endif() + + message(STATUS MONERO_DIR ": ${MONERO_DIR}") +diff --git a/cmake/FindMonero.cmake b/cmake/FindMonero.cmake +index f9b73ae..9b91ecf 100644 +--- a/cmake/FindMonero.cmake ++++ b/cmake/FindMonero.cmake +@@ -45,7 +45,7 @@ foreach (l ${LIBS}) + find_library(Xmr_${L}_LIBRARY + NAMES ${l} + PATHS ${CMAKE_LIBRARY_PATH} +- PATH_SUFFIXES "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/src/crypto/wallet" "/contrib/epee/src" "/external/easylogging++/" "/external/${l}" "external/miniupnp/miniupnpc" ++ PATH_SUFFIXES "/src/${l}" "/src/" "/external/db_drivers/lib${l}" "/lib" "/src/crypto" "/src/crypto/wallet" "/contrib/epee/src" "/external/easylogging++/" "/external/${l}" "external/miniupnp/miniupnpc" "/external/RandomWOW" + NO_DEFAULT_PATH + ) + +@@ -76,7 +76,7 @@ include_directories( + ${MONERO_SOURCE_DIR}/src/crypto + ${MONERO_SOURCE_DIR}/src/crypto/wallet + ${MONERO_SOURCE_DIR}/external +- ${MONERO_SOURCE_DIR}/external/randomx/src ++ ${MONERO_SOURCE_DIR}/external/randomwow/src + ${MONERO_SOURCE_DIR}/build + ${MONERO_SOURCE_DIR}/external/easylogging++ + ${MONERO_SOURCE_DIR}/contrib/epee/include +diff --git a/main.cpp b/main.cpp +index 016363f..d317e4f 100644 +--- a/main.cpp ++++ b/main.cpp +@@ -207,9 +207,9 @@ main(int ac, const char* av[]) + + string deamon_url {*deamon_url_opt}; + +- if (testnet && deamon_url == "http:://127.0.0.1:18081") +- deamon_url = "http:://127.0.0.1:28081"; +- if (stagenet && deamon_url == "http:://127.0.0.1:18081") ++ if (testnet && deamon_url == "http:://127.0.0.1:34568") ++ deamon_url = "http:://127.0.0.1:11181"; ++ if (stagenet && deamon_url == "http:://127.0.0.1:34568") + deamon_url = "http:://127.0.0.1:38081"; + + uint64_t mempool_info_timeout {5000}; +@@ -435,7 +435,7 @@ main(int ac, const char* av[]) + || post_body.count("viewkey") == 0 + || post_body.count("tx_hash") == 0) + { +- return string("xmr address, viewkey or tx hash not provided"); ++ return string("wow address, viewkey or tx hash not provided"); + } + + string tx_hash = remove_bad_chars(post_body["tx_hash"]); +@@ -482,7 +482,7 @@ main(int ac, const char* av[]) + || post_body.count("txprvkey") == 0 + || post_body.count("txhash") == 0) + { +- return string("xmr address, tx private key or " ++ return string("wow address, tx private key or " + "tx hash not provided"); + } + +diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp +index 4304fc1..46e1cde 100644 +--- a/src/CmdLineOptions.cpp ++++ b/src/CmdLineOptions.cpp +@@ -18,7 +18,7 @@ namespace xmreg + p.add("txhash", -1); + + options_description desc( +- "xmrblocks, Onion Monero Blockchain Explorer"); ++ "xmrblocks, Wownero Blockchain Explorer"); + + desc.add_options() + ("help,h", value()->default_value(false)->implicit_value(true), +@@ -44,7 +44,7 @@ namespace xmreg + ("enable-autorefresh-option", value()->default_value(false)->implicit_value(true), + "enable users to have the index page on autorefresh") + ("enable-emission-monitor", value()->default_value(false)->implicit_value(true), +- "enable Monero total emission monitoring thread") ++ "enable Wownero total emission monitoring thread") + ("port,p", value()->default_value("8081"), + "default explorer port") + ("bindaddr,x", value()->default_value("0.0.0.0"), +@@ -64,7 +64,7 @@ namespace xmreg + ("concurrency,c", value()->default_value(0), + "number of threads handling http queries. Default is 0 which means it is based you on the cpu") + ("bc-path,b", value(), +- "path to lmdb folder of the blockchain, e.g., ~/.bitmonero/lmdb") ++ "path to lmdb folder of the blockchain, e.g., ~/.wownero/lmdb") + ("ssl-crt-file", value(), + "path to crt file for ssl (https) functionality") + ("ssl-key-file", value(), +diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp +index 040f01d..05c411a 100644 +--- a/src/CurrentBlockchainStatus.cpp ++++ b/src/CurrentBlockchainStatus.cpp +@@ -297,13 +297,13 @@ CurrentBlockchainStatus::is_thread_running() + return is_running; + } + +-bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"}; ++bf::path CurrentBlockchainStatus::blockchain_path {"/home/mwo/.wownero/lmdb"}; + + cryptonote::network_type CurrentBlockchainStatus::nettype {cryptonote::network_type::MAINNET}; + + string CurrentBlockchainStatus::output_file {"emission_amount.txt"}; + +-string CurrentBlockchainStatus::deamon_url {"http:://127.0.0.1:18081"}; ++string CurrentBlockchainStatus::deamon_url {"http:://127.0.0.1:34568"}; + + uint64_t CurrentBlockchainStatus::blockchain_chunk_size {10000}; + +diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp +index b55b312..05c228f 100644 +--- a/src/MempoolStatus.cpp ++++ b/src/MempoolStatus.cpp +@@ -325,8 +325,8 @@ MempoolStatus::is_thread_running() + return is_running; + } + +-bf::path MempoolStatus::blockchain_path {"/home/mwo/.bitmonero/lmdb"}; +-string MempoolStatus::deamon_url {"http:://127.0.0.1:18081"}; ++bf::path MempoolStatus::blockchain_path {"/home/mwo/.wownero/lmdb"}; ++string MempoolStatus::deamon_url {"http:://127.0.0.1:34568"}; + cryptonote::network_type MempoolStatus::nettype {cryptonote::network_type::MAINNET}; + atomic MempoolStatus::is_running {false}; + boost::thread MempoolStatus::m_thread; +diff --git a/src/page.h b/src/page.h +index 77a047c..6113a3a 100644 +--- a/src/page.h ++++ b/src/page.h +@@ -2103,7 +2103,7 @@ show_my_outputs(string tx_hash_str, + {"blk_height" , tx_blk_height_str}, + {"tx_size" , fmt::format("{:0.4f}", + static_cast(txd.size) / 1024.0)}, +- {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", true)}, ++ {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.11f}", true)}, + {"blk_timestamp" , blk_timestamp}, + {"delta_time" , age.first}, + {"outputs_no" , static_cast(txd.output_pub_keys.size())}, +@@ -2663,7 +2663,7 @@ show_my_outputs(string tx_hash_str, + context["show_inputs"] = show_key_images; + context["inputs_no"] = static_cast(inputs.size()); + context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str( +- sum_mixin_xmr, "{:0.12f}", false); ++ sum_mixin_xmr, "{:0.11f}", false); + + + uint64_t possible_spending {0}; +@@ -2696,7 +2696,7 @@ show_my_outputs(string tx_hash_str, + } + + context["possible_spending"] = xmreg::xmr_amount_to_str( +- possible_spending, "{:0.12f}", false); ++ possible_spending, "{:0.11f}", false); + + add_css_style(context); + +@@ -6060,9 +6060,9 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) + {"blk_height" , tx_blk_height_str}, + {"tx_blk_height" , tx_blk_height}, + {"tx_size" , fmt::format("{:0.4f}", tx_size)}, +- {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.12f}", false)}, ++ {"tx_fee" , xmreg::xmr_amount_to_str(txd.fee, "{:0.11f}", false)}, + {"tx_fee_micro" , xmreg::xmr_amount_to_str(txd.fee*1e6, "{:0.4f}", false)}, +- {"payed_for_kB" , fmt::format("{:0.12f}", payed_for_kB)}, ++ {"payed_for_kB" , fmt::format("{:0.11f}", payed_for_kB)}, + {"tx_version" , static_cast(txd.version)}, + {"blk_timestamp" , blk_timestamp}, + {"blk_timestamp_uint" , blk.timestamp}, +diff --git a/src/rpccalls.h b/src/rpccalls.h +index 17a2d2c..a693e75 100644 +--- a/src/rpccalls.h ++++ b/src/rpccalls.h +@@ -85,7 +85,7 @@ public: + + using login_opt = boost::optional; + +- rpccalls(string _deamon_url = "http:://127.0.0.1:18081", ++ rpccalls(string _deamon_url = "http:://127.0.0.1:34568", + login_opt _login = login_opt {}, + uint64_t _timeout = 200000); + +diff --git a/src/templates/checkrawoutputkeys.html b/src/templates/checkrawoutputkeys.html +index 572bbdc..c12d66d 100644 +--- a/src/templates/checkrawoutputkeys.html ++++ b/src/templates/checkrawoutputkeys.html +@@ -15,7 +15,7 @@ +

Output keys for address: {{address}}

+

Viewkey: {{viewkey}}

+ {{#has_total_xmr}} +-

Total xmr: {{total_xmr}}

++

Total wow: {{total_xmr}}

+ {{/has_total_xmr}} + +
+diff --git a/src/templates/footer.html b/src/templates/footer.html +index 4e0cbe6..682d09a 100644 +--- a/src/templates/footer.html ++++ b/src/templates/footer.html +@@ -2,7 +2,7 @@ +
+ source code + | explorer version (api): {{git_branch_name}}-{{last_git_commit_date}}-{{last_git_commit_hash}} ({{api}}) +- | monero version: {{monero_version_full}} ++ | wownero version: {{monero_version_full}} +
+
+ +diff --git a/src/templates/header.html b/src/templates/header.html +index 55fe829..9eb518f 100644 +--- a/src/templates/header.html ++++ b/src/templates/header.html +@@ -7,7 +7,7 @@ + {{#refresh}} + + {{/refresh}} +- Onion Monero Blockchain Explorer ++ Wownero Blockchain Explorer + +