diff options
55 files changed, 417 insertions, 1556 deletions
diff --git a/.travis.yml b/.travis.yml index 36c48f8d6..3eb75bea7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,11 @@ matrix: - pip install --user cpp-coveralls install: - sudo apt-get -y install libboost-{chrono,program-options,date-time,thread,system,filesystem,regex,serialization}1.58{-dev,.0} + env: + # exclude long-running and failing tests (#895) + - ARGS=" -E 'coretests|libwallet_api_tests' " script: - - make -j2 debug-test + - make -j2 coverage after_success: - travis_wait coveralls -e external -e tests -e cmake -e contrib -e translations -e utils --gcov-options '\-lp' &> /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index e280826c0..0b0ce5a4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ cmake_minimum_required(VERSION 2.8.7) -project(bitmonero) +project(monero) function (die msg) if (NOT WIN32) @@ -76,6 +76,11 @@ if (ARM_TEST STREQUAL "arm") endif() endif() +if (ARCH_ID STREQUAL "aarch64") + set(ARM 1) + set(ARM8 1) +endif() + if(WIN32 OR ARM) set(OPT_FLAGS_RELEASE "-O2") else() @@ -353,8 +358,15 @@ else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + option(COVERAGE "Enable profiling for test coverage report" 0) + + if(COVERAGE) + message(STATUS "Building with profiling for test coverage report") + set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage --coverage") + endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}") # With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that # is fixed in the code (Issue #847), force compiler to be conservative. @@ -367,31 +379,99 @@ else() message(STATUS "AES support enabled") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") - elseif(ARM) + elseif(ARM) #NB ARMv8 DOES support AES, but not yet coded message(STATUS "AES support disabled (not available on ARM)") else() message(STATUS "AES support disabled") endif() - if(ARM6) - message(STATUS "Setting ARM6 C and C++ flags") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp -mfloat-abi=hard") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp -mfloat-abi=hard") - endif() + if(ARM) + message(STATUS "Setting FPU Flags for ARM Processors") + include(TestCXXAcceptsFlag) + + #NB NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic + #Need custom assembly code to take full advantage of NEON SIMD + + #Cortex-A5/9 -mfpu=neon-fp16 + #Cortex-A7/15 -mfpu=neon-vfpv4 + #Cortex-A8 -mfpu=neon + #ARMv8 -FP and SIMD on by default for all ARM8v-a series, NO -mfpu setting needed + + #For custom -mtune, processor IDs for ARMv8-A series: + #0xd04 - Cortex-A35 + #0xd07 - Cortex-A57 + #0xd08 - Cortex-A72 + #0xd03 - Cortex-A73 + + if(NOT ARM8) + CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp3-d16 CXX_ACCEPTS_VFP3_D16) + CHECK_CXX_ACCEPTS_FLAG(-mfpu=vfp4 CXX_ACCEPTS_VFP4) + CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=hard CXX_ACCEPTS_MFLOAT_HARD) + CHECK_CXX_ACCEPTS_FLAG(-mfloat-abi=softfp CXX_ACCEPTS_MFLOAT_SOFTFP) + endif() - if(ARM7) - message(STATUS "Setting ARM7 C and C++ flags") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") - endif() + if(ARM8) + CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-835769 CXX_ACCEPTS_MFIX_CORTEX_A53_835769) + CHECK_CXX_ACCEPTS_FLAG(-mfix-cortex-a53-843419 CXX_ACCEPTS_MFIX_CORTEX_A53_843419) + endif() + + if(ARM6) + message(STATUS "Selecting VFP for ARMv6") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp") + endif(ARM6) + + if(ARM7) + if(CXX_ACCEPTS_VFP3_D16 AND NOT CXX_ACCEPTS_VFP4) + message(STATUS "Selecting VFP3 for ARMv7") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp3-d16") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp3-d16") + endif() + + if(CXX_ACCEPTS_VFP4) + message(STATUS "Selecting VFP4 for ARMv7") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp4") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp4") + endif() + + if(CXX_ACCEPTS_MFLOAT_HARD) + message(STATUS "Setting Hardware ABI for Floating Point") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") + endif() + + if(CXX_ACCEPTS_MFLOAT_SOFTFP AND NOT CXX_ACCEPTS_MFLOAT_HARD) + message(STATUS "Setting Software ABI for Floating Point") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=softfp") + endif() + endif(ARM7) + + if(ARM8) + if(CXX_ACCEPTS_MFIX_CORTEX_A53_835769) + message(STATUS "Enabling Cortex-A53 workaround 835769") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-835769") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-835769") + endif() + + if(CXX_ACCEPTS_MFIX_CORTEX_A53_843419) + message(STATUS "Enabling Cortex-A53 workaround 843419") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfix-cortex-a53-843419") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfix-cortex-a53-843419") + endif() + endif(ARM8) + + endif(ARM) if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") endif() + + set(DEBUG_FLAGS "-g3") if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)) - set(DEBUG_FLAGS "-g3 -Og -fprofile-arcs -ftest-coverage --coverage") + set(DEBUG_FLAGS "${DEBUG_FLAGS} -Og ") else() - set(DEBUG_FLAGS "-g3 -O0 -fprofile-arcs -ftest-coverage --coverage") + set(DEBUG_FLAGS "${DEBUG_FLAGS} -O0 ") endif() if(NOT DEFINED USE_LTO_DEFAULT) @@ -533,3 +613,11 @@ if(BUILD_DOCUMENTATION) endif() endif() +# when ON - will install libwallet_merged into "lib" +option(BUILD_GUI_DEPS "Build GUI dependencies." OFF) + +# This is not nice, distribution packagers should not enable this, but depend +# on libunbound shipped with their distribution instead +option(INSTALL_VENDORED_LIBUNBOUND "Install libunbound binary built from source vendored with this repo." OFF) + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..158832f4a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +FROM debian:testing +MAINTAINER eiabea <developer@eiabea.com> + +# Install clone dependencies +RUN set -e && \ + apt-get update -q && \ + apt-get install -q -y --no-install-recommends ca-certificates git && \ + git clone https://github.com/monero-project/monero.git src && \ + apt-get purge -y git && \ + apt-get clean -q -y && \ + apt-get autoclean -q -y && \ + apt-get autoremove -q -y + +WORKDIR /src + +# Install make dependencies +RUN set -e && \ + apt-get update -q && \ + apt-get install -q -y --no-install-recommends build-essential ca-certificates g++ gcc cmake \ + pkg-config libunbound2 libevent-2.0-5 libgtest-dev libboost-all-dev libdb5.3++-dev libdb5.3-dev libssl-dev && \ + make -j 4 && \ + apt-get purge -y g++ gcc cmake pkg-config && \ + apt-get clean -q -y && \ + apt-get autoclean -q -y && \ + apt-get autoremove -q -y && \ + mkdir /monero && \ + mv /src/build/release/bin/* /monero && \ + rm -rf /src + +WORKDIR /monero + +# Contains the blockchain +VOLUME /root/.bitmonero + +# Generate your wallet via accessing the container and run: +# cd /wallet +# /./bitmonero/monero-wallet-cli +VOLUME /wallet + +ENV LOG_LEVEL 0 +ENV P2P_BIND_IP 0.0.0.0 +ENV P2P_BIND_PORT 18080 +ENV RPC_BIND_IP 127.0.0.1 +ENV RPC_BIND_PORT 18081 + +EXPOSE 18080 +EXPOSE 18081 + +CMD ./monerod --log-level=$LOG_LEVEL --p2p-bind-ip=$P2P_BIND_IP --p2p-bind-port=$P2P_BIND_PORT --rpc-bind-ip=$RPC_BIND_IP --rpc-bind-port=$RPC_BIND_PORT
\ No newline at end of file @@ -1,21 +1,21 @@ # Copyright (c) 2014-2016, The Monero Project -# +# # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without modification, are # permitted provided that the following conditions are met: -# +# # 1. Redistributions of source code must retain the above copyright notice, this list of # conditions and the following disclaimer. -# +# # 2. Redistributions in binary form must reproduce the above copyright notice, this list # of conditions and the following disclaimer in the documentation and/or other # materials provided with the distribution. -# +# # 3. Neither the name of the copyright holder nor the names of its contributors may be # used to endorse or promote products derived from this software without specific # prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -58,6 +58,10 @@ release-all: mkdir -p build/release cd build/release && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) +coverage: + mkdir -p build/debug + cd build/debug && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug -D COVERAGE=ON ../.. && $(MAKE) && $(MAKE) test + release-static-arm6: mkdir -p build/release cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) @@ -65,7 +69,11 @@ release-static-arm6: release-static-arm7: mkdir -p build/release cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) - + +release-static-armv8: + mkdir -p build/release + cd build/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=release ../.. && $(MAKE) + release-static: release-static-64 release-static-64: diff --git a/README.i18n b/README.i18n index 0c7a010ef..c4eabaf15 100644 --- a/README.i18n +++ b/README.i18n @@ -25,7 +25,7 @@ To build translations after modiying them: To test a translation: - LANG=es ./build/release/bin/simplewallet + LANG=es ./build/release/bin/monero-wallet-cli To add new translatable sources in the source: @@ -2,15 +2,15 @@ Copyright (c) 2014-2016, The Monero Project -[![Build Status](https://travis-ci.org/monero-project/bitmonero.svg?branch=master)](https://travis-ci.org/monero-project/bitmonero) -[![Coverage Status](https://coveralls.io/repos/github/monero-project/bitmonero/badge.svg?branch=master)](https://coveralls.io/github/monero-project/bitmonero?branch=master) +[![Build Status](https://travis-ci.org/monero-project/monero.svg?branch=master)](https://travis-ci.org/monero-project/monero) +[![Coverage Status](https://coveralls.io/repos/github/monero-project/monero/badge.svg?branch=master)](https://coveralls.io/github/monero-project/monero?branch=master) ## Development Resources - Web: [getmonero.org](https://getmonero.org) - Forum: [forum.getmonero.org](https://forum.getmonero.org) - Mail: [dev@getmonero.org](mailto:dev@getmonero.org) -- GitHub: [https://github.com/monero-project/bitmonero](https://github.com/monero-project/bitmonero) +- GitHub: [https://github.com/monero-project/monero](https://github.com/monero-project/monero) - IRC: [#monero-dev on Freenode](irc://chat.freenode.net/#monero-dev) ## Introduction @@ -65,8 +65,18 @@ Packages are available for * OS X via [Homebrew](http://brew.sh) - brew tap sammy007/cryptonight - brew install bitmonero --build-from-source + brew tap sammy007/cryptonight + brew install bitmonero --build-from-source + +* Docker + + docker build -t monero . + + # either run in foreground + docker run -it -v /monero/chain:/root/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero + + # or in background + docker run -it -d -v /monero/chain:/root/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero Packaging for your favorite distribution would be a welcome contribution! @@ -74,21 +84,34 @@ Packaging for your favorite distribution would be a welcome contribution! ### Dependencies -* GCC `>=4.7.3` -* CMake `>=3.0.0` -* pkg-config -* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is) -* libevent `>=2.0` -* libgtest `>=1.5` -* Boost `>=1.58` -* BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev) -* libunwind (optional, for stack trace on exception) -* miniupnpc (optional, for NAT punching) -* ldns `>=1.6.17` (optional, for statically-linked binaries) -* expat `>=1.1` (optional, for statically-linked binaries) -* bison or yacc (optional, for statically-linked binaries) -* Doxygen (optional, for generating documentation) -* graphviz (optional, for generating documentation) +The following table summarizes the tools and libraries required to build. A +few of the libraries are also included in this repository (marked as +"Vendored"). By default, the build uses the library installed on the system, +and ignores the vendored sources. However, if no library is found installed on +the system, then the vendored source will be built and used. The vendored +sources are also used for statically-linked builds because distribution +packages often include only shared library binaries (`.so`) but not static +library archives (`.a`). + +| Dep | Min. Version | Vendored | Debian/Ubuntu Pkg | Arch Pkg | Optional | Purpose | +| -------------- | ------------- | ---------| ------------------ | -------------- | -------- | -------------- | +| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | NO | | +| CMake | 3.0.0 | NO | `cmake` | `cmake` | NO | | +| pkg-config | any | NO | `pkg-config` | `base-devel` | NO | | +| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | NO | | +| BerkeleyDB | 4.8 | NO | `libdb{,++}-dev` | `db` | NO | | +| libevent | 2.0 | NO | `libevent-dev` | `libevent` | NO | | +| libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | NO | | +| libminiupnpc | 2.0 | YES | `libminiupnpc-dev` | `miniupnpc` | YES | NAT punching | +| libunwind | any | NO | `libunwind-dev` | `libunwind` | YES | stack traces | +| ldns | 1.6.17 | NO | `libldns-dev` | `ldns` | YES | ? | +| expat | 1.1 | NO | `libexpat1-dev` | `expat` | YES | ? | +| GTest | 1.5 | YES | `libgtest-dev`^ | `gtest` | YES | test suite | +| Doxygen | any | NO | `doxygen` | `doxygen` | YES | documentation | +| Graphviz | any | NO | `graphviz` | `graphviz` | YES | documentation | + +[^] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must +build the library binary manually. ### Build instructions @@ -100,7 +123,7 @@ invokes cmake commands as needed. * Install the dependencies * Change to the root of the source code directory and build: - cd bitmonero + cd monero make *Optional*: If your machine has several cores and enough memory, enable @@ -197,7 +220,8 @@ By default, in either dynamically or statically linked builds, binaries target t * ```make release-static-64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors * ```make release-static-32``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors -* ```make release-static-arm7``` builds binaries on Linux on armv7 portable across POSIX systesm on armv7 processors +* ```make release-static-arm8``` builds binaries on Linux on armv8 portable across POSIX systems on armv8 processors +* ```make release-static-arm7``` builds binaries on Linux on armv7 portable across POSIX systems on armv7 processors * ```make release-static-arm6``` builds binaries on Linux on armv7 or armv6 portable across POSIX systems on armv6 processors, such as the Raspberry Pi * ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems * ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems @@ -219,15 +243,15 @@ Dependencies: Doxygen `>=1.8.0`, Graphviz `>=2.28` (optional). * The output will be built in doc/html/ -## Running bitmonerod +## Running monerod The build places the binary in `bin/` sub-directory within the build directory from which cmake was invoked (repository root by default). To run in foreground: - ./bin/bitmonerod + ./bin/monerod -To list all available options, run `./bin/bitmonerod --help`. Options can be +To list all available options, run `./bin/monerod --help`. Options can be specified either on the command line or in a configuration file passed by the `--config-file` argument. To specify an option in the configuration file, add a line with the syntax `argumentname=value`, where `argumentname` is the name @@ -235,14 +259,14 @@ of the argument without the leading dashes, for example `log-level=1`. To run in background: - ./bin/bitmonerod --log-file bitmonerod.log --detach + ./bin/monerod --log-file monerod.log --detach To run as a systemd service, copy -[bitmonerod.service](utils/systemd/bitmonerod.service) to `/etc/systemd/system/` and -[bitmonerod.conf](utils/conf/bitmonerod.conf) to `/etc/`. The [example -service](utils/systemd/bitmonerod.service) assumes that the user `bitmonero` exists +[monerod.service](utils/systemd/monerod.service) to `/etc/systemd/system/` and +[monerod.conf](utils/conf/monerod.conf) to `/etc/`. The [example +service](utils/systemd/monerod.service) assumes that the user `monero` exists and its home is the data directory specified in the [example -config](utils/conf/bitmonerod.conf). +config](utils/conf/monerod.conf). ## Internationalization @@ -250,20 +274,20 @@ See README.i18n ## Using Tor -While Monero isn't made to integrate with Tor, it can be used wrapped with torsocks, if you add --p2p-bind-ip 127.0.0.1 to the bitmonerod command line. You also want to set DNS requests to go over TCP, so they'll be routed through Tor, by setting DNS_PUBLIC=tcp. You may also disable IGD (UPnP port forwarding negotiation), which is pointless with Tor. To allow local connections from the wallet, add TORSOCKS_ALLOW_INBOUND=1. Example: +While Monero isn't made to integrate with Tor, it can be used wrapped with torsocks, if you add --p2p-bind-ip 127.0.0.1 to the monerod command line. You also want to set DNS requests to go over TCP, so they'll be routed through Tor, by setting DNS_PUBLIC=tcp. You may also disable IGD (UPnP port forwarding negotiation), which is pointless with Tor. To allow local connections from the wallet, add TORSOCKS_ALLOW_INBOUND=1. Example: -`DNS_PUBLIC=tcp TORSOCKS_ALLOW_INBOUND=1 torsocks bitmonerod --p2p-bind-ip 127.0.0.1 --no-igd` +`DNS_PUBLIC=tcp TORSOCKS_ALLOW_INBOUND=1 torsocks monerod --p2p-bind-ip 127.0.0.1 --no-igd` TAILS ships with a very restrictive set of firewall rules. Therefore, you need to add a rule to allow this connection too, in addition to telling torsocks to allow inbound connections. Full example: `sudo iptables -I OUTPUT 2 -p tcp -d 127.0.0.1 -m tcp --dport 18081 -j ACCEPT` -`DNS_PUBLIC=tcp TORSOCKS_ALLOW_INBOUND=1 torsocks ./bitmonerod --p2p-bind-ip 127.0.0.1 --no-igd --rpc-bind-ip 127.0.0.1 --data-dir /home/amnesia/Persistent/your/directory/to/the/blockchain` +`DNS_PUBLIC=tcp TORSOCKS_ALLOW_INBOUND=1 torsocks ./monerod --p2p-bind-ip 127.0.0.1 --no-igd --rpc-bind-ip 127.0.0.1 --data-dir /home/amnesia/Persistent/your/directory/to/the/blockchain` -`./simplewallet` +`./monero-wallet-cli` ## Using readline -While bitmonerod and simplewallet do not use readline directly, most of the functionality can be obtained by running them via rlwrap. This allows command recall, edit capabilities, etc. It does not give autocompletion without an extra completion file, however. To use rlwrap, simply prepend `rlwrap` to the command line, eg: +While monerod and monero-wallet-cli do not use readline directly, most of the functionality can be obtained by running them via rlwrap. This allows command recall, edit capabilities, etc. It does not give autocompletion without an extra completion file, however. To use rlwrap, simply prepend `rlwrap` to the command line, eg: -`rlwrap bin/simplewallet --wallet-file /path/to/wallet` +`rlwrap bin/monero-wallet-cli --wallet-file /path/to/wallet` diff --git a/cmake/MergeStaticLibs.cmake b/cmake/MergeStaticLibs.cmake deleted file mode 100644 index 858a026a3..000000000 --- a/cmake/MergeStaticLibs.cmake +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (C) 2012 Modelon AB - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the BSD style license. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# FMILIB_License.txt file for more details. - -# You should have received a copy of the FMILIB_License.txt file -# along with this program. If not, contact Modelon AB <http://www.modelon.com>. - -# Merge_static_libs(outlib lib1 lib2 ... libn) merges a number of static -# libs into a single static library -function(merge_static_libs outlib ) - set(libs ${ARGV}) - list(REMOVE_AT libs 0) -# Create a dummy file that the target will depend on - set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c) - file(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") - - add_library(${outlib} STATIC ${dummyfile}) - - if("${CMAKE_CFG_INTDIR}" STREQUAL ".") - set(multiconfig FALSE) - else() - set(multiconfig TRUE) - endif() - -# First get the file names of the libraries to be merged - foreach(lib ${libs}) - get_target_property(libtype ${lib} TYPE) - if(NOT libtype STREQUAL "STATIC_LIBRARY") - message(FATAL_ERROR "Merge_static_libs can only process static libraries") - endif() - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}") - list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}}) - endforeach() - else() - get_target_property(libfile ${lib} LOCATION) - list(APPEND libfiles "${libfile}") - endif(multiconfig) - endforeach() - message(STATUS "will be merging ${libfiles}") -# Just to be sure: cleanup from duplicates - if(multiconfig) - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE}) - set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}}) - endforeach() - endif() - list(REMOVE_DUPLICATES libfiles) - -# Now the easy part for MSVC and for MAC - if(MSVC) - # lib.exe does the merging of libraries just need to conver the list into string - foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - set(flags "") - foreach(lib ${libfiles_${CONFIG_TYPE}}) - set(flags "${flags} ${lib}") - endforeach() - string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME) - set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}") - endforeach() - - elseif(APPLE) - # Use OSX's libtool to merge archives - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND rm ${outfile} - COMMAND /usr/bin/libtool -static -o ${outfile} - ${libfiles} - ) - else() - # general UNIX - need to "ar -x" and then "ar -ru" - if(multiconfig) - message(FATAL_ERROR "Multiple configurations are not supported") - endif() - get_target_property(outfile ${outlib} LOCATION) - message(STATUS "outfile location is ${outfile}") - foreach(lib ${libfiles}) -# objlistfile will contain the list of object files for the library - set(objlistfile ${lib}.objlist) - set(objdir ${lib}.objdir) - set(objlistcmake ${objlistfile}.cmake) -# we only need to extract files once - if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake}) -#--------------------------------- - FILE(WRITE ${objlistcmake} -"# Extract object files from the library -message(STATUS \"Extracting object files from ${lib}\") -EXECUTE_PROCESS(COMMAND ${CMAKE_AR} -x ${lib} - WORKING_DIRECTORY ${objdir}) -# save the list of object files -EXECUTE_PROCESS(COMMAND ls . - OUTPUT_FILE ${objlistfile} - WORKING_DIRECTORY ${objdir})") -#--------------------------------- - file(MAKE_DIRECTORY ${objdir}) - add_custom_command( - OUTPUT ${objlistfile} - COMMAND ${CMAKE_COMMAND} -P ${objlistcmake} - DEPENDS ${lib}) - endif() - list(APPEND extrafiles "${objlistfile}") - # relative path is needed by ar under MSYS - file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile}) - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}" - COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}" - WORKING_DIRECTORY ${objdir}) - endforeach() - add_custom_command(TARGET ${outlib} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}" - COMMAND ${CMAKE_RANLIB} ${outfile}) - endif() - file(WRITE ${dummyfile}.base "const char* ${outlib}_sublibs=\"${libs}\";") - add_custom_command( - OUTPUT ${dummyfile} - COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile} - DEPENDS ${libs} ${extrafiles}) - - endfunction()
\ No newline at end of file diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index 4f7ebfa04..a0ade10a3 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -137,7 +137,7 @@ namespace net_utils ////////////////////////////////////////////////////////////////////////// boost::asio::ip::tcp::resolver resolver(m_io_service); - boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port); + boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port, boost::asio::ip::tcp::resolver::query::canonical_name); boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); boost::asio::ip::tcp::resolver::iterator end; if(iterator == end) diff --git a/external/unbound/CMakeLists.txt b/external/unbound/CMakeLists.txt index 0dd5d6bc4..4b82fab82 100644 --- a/external/unbound/CMakeLists.txt +++ b/external/unbound/CMakeLists.txt @@ -228,3 +228,9 @@ if (MINGW) COPYONLY) endforeach () endif () + + +if (INSTALL_VENDORED_LIBUNBOUND) + install(TARGETS unbound + ARCHIVE DESTINATION lib) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70bb215d0..55a276f06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,11 +82,18 @@ function (bitmonero_add_library name) FILES ${ARGN}) - add_library("${name}" - ${ARGN}) + # Define a ("virtual") object library and an actual library that links those + # objects together. The virtual libraries can be arbitrarily combined to link + # any subset of objects into one library archive. This is used for releasing + # libwallet, which combines multiple components. + set(objlib obj_${name}) + add_library(${objlib} OBJECT ${ARGN}) + add_library("${name}" STATIC $<TARGET_OBJECTS:${objlib}>) set_property(TARGET "${name}" PROPERTY FOLDER "libs") + target_compile_definitions(${objlib} + PRIVATE $<TARGET_PROPERTY:${name},INTERFACE_COMPILE_DEFINITIONS>) endfunction () add_subdirectory(common) @@ -100,7 +107,6 @@ add_subdirectory(wallet) add_subdirectory(p2p) add_subdirectory(cryptonote_protocol) -add_subdirectory(miner) add_subdirectory(simplewallet) add_subdirectory(daemonizer) add_subdirectory(daemon) diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index 4ec284e38..137ed9dc6 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -1235,7 +1235,7 @@ void BlockchainBDB::unlock() check_open(); } -bool BlockchainBDB::block_exists(const crypto::hash& h) const +bool BlockchainBDB::block_exists(const crypto::hash& h, uint64_t *height) const { LOG_PRINT_L3("BlockchainBDB::" << __func__); check_open(); @@ -1251,6 +1251,9 @@ bool BlockchainBDB::block_exists(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR("DB error attempting to fetch block index from hash")); + if (height) + *height = get_result - 1; + return true; } diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index f8e9440bd..f320ab0e3 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -250,7 +250,7 @@ public: virtual void unlock(); - virtual bool block_exists(const crypto::hash& h) const; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const; virtual block get_block(const crypto::hash& h) const; diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index d26080a3b..5b6a793d8 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -736,10 +736,11 @@ public: * @brief checks if a block exists * * @param h the hash of the requested block + * @param height if non NULL, returns the block's height if found * * @return true of the block exists, otherwise false */ - virtual bool block_exists(const crypto::hash& h) const = 0; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const = 0; /** * @brief fetches the block with the given hash diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index c0cf28dda..8ad875fc8 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -1387,7 +1387,7 @@ void BlockchainLMDB::unlock() auto_txn.commit(); \ } while(0) -bool BlockchainLMDB::block_exists(const crypto::hash& h) const +bool BlockchainLMDB::block_exists(const crypto::hash& h, uint64_t *height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1405,7 +1405,14 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) const else if (get_result) throw0(DB_ERROR(lmdb_error("DB error attempting to fetch block index from hash", get_result).c_str())); else + { + if (height) + { + const blk_height *bhp = (const blk_height *)key.mv_data; + *height = bhp->bh_height; + } ret = true; + } TXN_POSTFIX_RDONLY(); return ret; diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 050e9e0ae..9df4b86d1 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -168,7 +168,7 @@ public: virtual void unlock(); - virtual bool block_exists(const crypto::hash& h) const; + virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const; virtual block get_block(const crypto::hash& h) const; diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index d98c2ce83..6f62128cc 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -58,26 +58,6 @@ bitmonero_private_headers(blockchain_export ${blockchain_export_private_headers}) -set(blockchain_dump_sources - blockchain_dump.cpp - ) - -set(blockchain_dump_private_headers) - -bitmonero_private_headers(blockchain_dump - ${blockchain_dump_private_headers}) - - -set(cn_deserialize_sources - cn_deserialize.cpp - ) - -set(cn_deserialize_private_headers) - -bitmonero_private_headers(cn_deserialize - ${cn_deserialize_private_headers}) - - bitmonero_add_executable(blockchain_import ${blockchain_import_sources} ${blockchain_import_private_headers}) @@ -98,7 +78,7 @@ add_dependencies(blockchain_import version) set_property(TARGET blockchain_import PROPERTY - OUTPUT_NAME "blockchain_import") + OUTPUT_NAME "monero-blockchain-import") bitmonero_add_executable(blockchain_export ${blockchain_export_sources} @@ -115,38 +95,4 @@ add_dependencies(blockchain_export version) set_property(TARGET blockchain_export PROPERTY - OUTPUT_NAME "blockchain_export") - -bitmonero_add_executable(blockchain_dump - ${blockchain_dump_sources} - ${blockchain_dump_private_headers}) - -target_link_libraries(blockchain_dump - LINK_PRIVATE - cryptonote_core - blockchain_db - p2p - ${CMAKE_THREAD_LIBS_INIT}) - -add_dependencies(blockchain_dump - version) -set_property(TARGET blockchain_dump - PROPERTY - OUTPUT_NAME "blockchain_dump") - -bitmonero_add_executable(cn_deserialize - ${cn_deserialize_sources} - ${cn_deserialize_private_headers}) - -target_link_libraries(cn_deserialize - LINK_PRIVATE - cryptonote_core - p2p - ${CMAKE_THREAD_LIBS_INIT}) - -add_dependencies(cn_deserialize - version) -set_property(TARGET cn_deserialize - PROPERTY - OUTPUT_NAME "cn_deserialize") - + OUTPUT_NAME "monero-blockchain-export") diff --git a/src/blockchain_utilities/README.md b/src/blockchain_utilities/README.md index 7df6937ad..809df3bfa 100644 --- a/src/blockchain_utilities/README.md +++ b/src/blockchain_utilities/README.md @@ -4,41 +4,24 @@ Copyright (c) 2014-2016, The Monero Project ## Introduction -The blockchain utilities allow one to convert an old style blockchain.bin file -to a new style database. There are two ways to upgrade an old style blockchain: -The recommended way is to run a `blockchain_export`, then `blockchain_import`. -The other way is to run `blockchain_converter`. In both cases, you will be left -with a new style blockchain. - -For importing into the LMDB database, compile with `DATABASE=lmdb` - -e.g. - -`DATABASE=lmdb make release` - -This is also the default compile setting on the master branch. - -The exporter will use the LMDB database as its source. -If you are still using an old style in-memory database (blockchain.bin), you will -have to either resync from scratch, or use an older version of the tools to export -it and import it. +The blockchain utilities allow one to import and export the blockchain. ## Usage: See also each utility's "--help" option. -### Export an existing in-memory database +### Export an existing blockchain database -`$ blockchain_export` +`$ monero-blockchain-export` -This loads the existing blockchain, for whichever database type it was compiled for, and exports it to `$MONERO_DATA_DIR/export/blockchain.raw` +This loads the existing blockchain and exports it to `$MONERO_DATA_DIR/export/blockchain.raw` ### Import the exported file -`$ blockchain_import` +`$ monero-blockchain-import` -This imports blocks from `$MONERO_DATA_DIR/export/blockchain.raw` (exported using the `blockchain_export` tool as described above) -into the current database. +This imports blocks from `$MONERO_DATA_DIR/export/blockchain.raw` (exported using the +`monero-blockchain-export` tool as described above) into the current database. Defaults: `--batch on`, `--batch size 20000`, `--verify on` @@ -47,14 +30,14 @@ Batch size refers to number of blocks and can be adjusted for performance based Verification should only be turned off if importing from a trusted blockchain. If you encounter an error like "resizing not supported in batch mode", you can just re-run -the `blockchain_import` command again, and it will restart from where it left off. +the `monero-blockchain-import` command again, and it will restart from where it left off. ```bash ## use default settings to import blockchain.raw into database -$ blockchain_import +$ monero-blockchain-import ## fast import with large batch size, database mode "fastest", verification off -$ blockchain_import --batch-size 20000 --database lmdb#fastest --verify off +$ monero-blockchain-import --batch-size 20000 --database lmdb#fastest --verify off ``` @@ -77,7 +60,7 @@ stop at block number `--database <database type>#<flag(s)>` -database type: `lmdb, berkeley, memory` +database type: `lmdb, memory` flags: @@ -94,27 +77,12 @@ LMDB flags (more than one may be specified): `nosync, nometasync, writemap, mapasync, nordahead` -BerkeleyDB flags (takes one): - -`txn_write_nosync, txn_nosync, txn_sync` - -``` ## Examples: -$ blockchain_import --database lmdb#fastest -$ blockchain_import --database berkeley#fastest - -$ blockchain_import --database lmdb#nosync -$ blockchain_import --database lmdb#nosync,nometasync -$ blockchain_import --database berkeley#txn_nosync ``` +$ monero-blockchain-import --database lmdb#fastest +$ monero-blockchain-import --database lmdb#nosync -### Blockchain converter with batching -`blockchain_converter` has also been updated and includes batching for faster writes. However, on lower RAM systems, this will be slower than using the exporter and importer utilities. The converter needs to keep the blockchain in memory for the duration of the conversion, like the original bitmonerod, thus leaving less memory available to the destination database to operate. - -Due to higher resource use, it is recommended to use the importer with an exported file instead of the converter. - -```bash -$ blockchain_converter --batch on --batch-size 20000 +$ monero-blockchain-import --database lmdb#nosync,nometasync ``` diff --git a/src/blockchain_utilities/blockchain_dump.cpp b/src/blockchain_utilities/blockchain_dump.cpp deleted file mode 100644 index 626900d42..000000000 --- a/src/blockchain_utilities/blockchain_dump.cpp +++ /dev/null @@ -1,417 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/blockchain.h" -#include "cryptonote_core/tx_pool.h" -#include "blockchain_db/blockchain_db.h" -#include "blockchain_db/lmdb/db_lmdb.h" -#ifdef BERKELEY_DB -#include "blockchain_db/berkeleydb/db_bdb.h" -#endif -#include "blockchain_utilities.h" -#include "common/command_line.h" -#include "version.h" - -namespace po = boost::program_options; -using namespace epee; // log_space - -using namespace cryptonote; - -struct DumpContext { - std::ofstream &f; - size_t level; - std::vector<std::string> close; - - DumpContext(std::ofstream &f): f(f), level(0) {} -}; - -template<typename S> static void start_compound(DumpContext &d, S key, bool array, bool print = false) -{ - if (print) - LOG_PRINT_L0("Dumping " << key << "..."); - d.f << std::string(d.level*2, ' '); - d.f << "\"" << key << "\": " << (array ? "[" : "{") << " \n"; - d.close.push_back(array ? "]" : "}"); - d.level++; -} - -template<typename S> static void start_array(DumpContext &d, S key, bool print = false) { start_compound(d, key, true, print); } -template<typename S> static void start_struct(DumpContext &d, S key, bool print = false) { start_compound(d, key, false, print); } - -static void end_compound(DumpContext &d) -{ - d.level--; - d.f << std::string(d.level*2, ' '); - d.f << d.close.back() << ",\n"; - d.close.pop_back(); -} - -template<typename S, typename T> static void write_pod(DumpContext &d, S key, const T &t) -{ - d.f << std::string(d.level*2, ' '); - d.f << "\"" << key << "\": "; - d.f << t; - d.f << ",\n"; -} - -template<typename T> static void write_pod(DumpContext &d, const T &t) -{ - d.f << std::string(d.level*2, ' '); - d.f << t; - d.f << ",\n"; -} - -int main(int argc, char* argv[]) -{ - uint32_t log_level = 0; - uint64_t block_stop = 0; - - tools::sanitize_locale(); - - boost::filesystem::path default_data_path {tools::get_default_data_dir()}; - boost::filesystem::path default_testnet_data_path {default_data_path / "testnet"}; - boost::filesystem::path output_file_path; - - po::options_description desc_cmd_only("Command line options"); - po::options_description desc_cmd_sett("Command line options and settings options"); - const command_line::arg_descriptor<std::string> arg_output_file = {"output-file", "Specify output file", "", true}; - const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", log_level}; - const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop}; - const command_line::arg_descriptor<std::string> arg_db_type = { - "db-type" - , "Specify database type" - , DEFAULT_DB_TYPE - }; - const command_line::arg_descriptor<bool> arg_include_db_only_data = { - "include-db-only-data" - , "Include data that is only in a database version." - , false - }; - const command_line::arg_descriptor<bool> arg_testnet_on = { - "testnet" - , "Run on testnet." - , false - }; - - - command_line::add_arg(desc_cmd_sett, command_line::arg_data_dir, default_data_path.string()); - command_line::add_arg(desc_cmd_sett, command_line::arg_testnet_data_dir, default_testnet_data_path.string()); - command_line::add_arg(desc_cmd_sett, arg_output_file); - command_line::add_arg(desc_cmd_sett, arg_db_type); - command_line::add_arg(desc_cmd_sett, arg_include_db_only_data); - command_line::add_arg(desc_cmd_sett, arg_testnet_on); - command_line::add_arg(desc_cmd_sett, arg_log_level); - command_line::add_arg(desc_cmd_sett, arg_block_stop); - - command_line::add_arg(desc_cmd_only, command_line::arg_help); - - po::options_description desc_options("Allowed options"); - desc_options.add(desc_cmd_only).add(desc_cmd_sett); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc_options, [&]() - { - po::store(po::parse_command_line(argc, argv, desc_options), vm); - po::notify(vm); - return true; - }); - if (! r) - return 1; - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL; - std::cout << desc_options << std::endl; - return 1; - } - - log_level = command_line::get_arg(vm, arg_log_level); - block_stop = command_line::get_arg(vm, arg_block_stop); - - log_space::get_set_log_detalisation_level(true, log_level); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - LOG_PRINT_L0("Starting..."); - LOG_PRINT_L0("Setting log level = " << log_level); - - bool opt_testnet = command_line::get_arg(vm, arg_testnet_on); - bool opt_include_db_only_data = command_line::get_arg(vm, arg_include_db_only_data); - - std::string m_config_folder; - - auto data_dir_arg = opt_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir; - m_config_folder = command_line::get_arg(vm, data_dir_arg); - - if (command_line::has_arg(vm, arg_output_file)) - output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file)); - else - output_file_path = boost::filesystem::path(m_config_folder) / "dump" / "blockchain.json"; - LOG_PRINT_L0("Export output file: " << output_file_path.string()); - - const boost::filesystem::path dir_path = output_file_path.parent_path(); - if (!dir_path.empty()) - { - if (boost::filesystem::exists(dir_path)) - { - if (!boost::filesystem::is_directory(dir_path)) - { - LOG_PRINT_RED_L0("dump directory path is a file: " << dir_path); - return 1; - } - } - else - { - if (!boost::filesystem::create_directory(dir_path)) - { - LOG_PRINT_RED_L0("Failed to create directory " << dir_path); - return 1; - } - } - } - - std::ofstream raw_data_file; - raw_data_file.open(output_file_path.string(), std::ios_base::out | std::ios::trunc); - if (raw_data_file.fail()) - return 1; - - - // If we wanted to use the memory pool, we would set up a fake_core. - - // Use Blockchain instead of lower-level BlockchainDB for two reasons: - // 1. Blockchain has the init() method for easy setup - // 2. exporter needs to use get_current_blockchain_height(), get_block_id_by_height(), get_block_by_hash() - // - // cannot match blockchain_storage setup above with just one line, - // e.g. - // Blockchain* core_storage = new Blockchain(NULL); - // because unlike blockchain_storage constructor, which takes a pointer to - // tx_memory_pool, Blockchain's constructor takes tx_memory_pool object. - LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)"); - Blockchain *core_storage = NULL; - tx_memory_pool m_mempool(*core_storage); - core_storage = new Blockchain(m_mempool); - - BlockchainDB* db; - int mdb_flags = 0; - std::string db_type = command_line::get_arg(vm, arg_db_type); - if (db_type.empty() || db_type == "lmdb") - { - db = new BlockchainLMDB(); - mdb_flags |= MDB_RDONLY; - } -#ifdef BERKELEY_DB - else if (db_type == "berkeley") - { - db = new BlockchainBDB(); - // can't open readonly due to the way flags are split in db_bdb.cpp - } -#endif - else - { - LOG_PRINT_L0("Invalid db type: " << db_type); - return 1; - } - boost::filesystem::path folder(m_config_folder); - folder /= db->get_db_name(); - const std::string filename = folder.string(); - uint64_t base_idx = db->get_indexing_base(); - - LOG_PRINT_L0("Loading blockchain from folder " << filename << " ..."); - try - { - db->open(filename, mdb_flags); - } - catch (const std::exception& e) - { - LOG_PRINT_L0("Error opening database: " << e.what()); - return 1; - } - r = core_storage->init(db, opt_testnet); - - CHECK_AND_ASSERT_MES(r, false, "Failed to initialize source blockchain storage"); - LOG_PRINT_L0("Source blockchain storage initialized OK"); - LOG_PRINT_L0("Dumping blockchain..."); - - DumpContext d(raw_data_file); - - start_struct(d,"blockchain"); - uint64_t height = core_storage->get_current_blockchain_height(); - write_pod(d, "height", height); - start_array(d,"blockids", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,core_storage->get_block_id_by_height(h)); - end_compound(d); - start_array(d,"txids", true); - { - std::vector<crypto::hash> txids; - core_storage->for_all_transactions([&txids](const crypto::hash &hash, const cryptonote::transaction &tx)->bool{txids.push_back(hash); return true;}); - std::sort(txids.begin(), txids.end(), - [](const crypto::hash &txid0, const crypto::hash &txid1) {return memcmp(txid0.data, txid1.data, sizeof(crypto::hash::data)) < 0;}); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d, txids[n]); - } - end_compound(d); - start_struct(d,"transactions", true); - { - for (uint64_t h = 0; h < height; ++h) - { - start_array(d, boost::lexical_cast<std::string>(h)); - std::list<cryptonote::block> blocks; - std::list<cryptonote::transaction> transactions, miner_tx; - core_storage->get_blocks(h, 1, blocks, transactions); - if (blocks.size() != 1) - throw std::string("Expected 1 block at height ") + boost::lexical_cast<std::string>(h); - crypto::hash txid = cryptonote::get_transaction_hash(blocks.front().miner_tx); - write_pod(d, string_tools::pod_to_hex(txid).c_str(), obj_to_json_str(blocks.front().miner_tx)); - std::vector<std::pair<crypto::hash, cryptonote::transaction>> txes; - for (std::list<cryptonote::transaction>::iterator i = transactions.begin(); i != transactions.end(); ++i) - txes.push_back(std::make_pair(cryptonote::get_transaction_hash(*i), *i)); - std::sort(txes.begin(), txes.end(), - [](const std::pair<crypto::hash, cryptonote::transaction> &tx0, const std::pair<crypto::hash, cryptonote::transaction> &tx1) {return memcmp(tx0.first.data, tx1.first.data, sizeof(crypto::key_image::data)) < 0;}); - for (std::vector<std::pair<crypto::hash, cryptonote::transaction>>::iterator i = txes.begin(); i != txes.end(); ++i) - { - write_pod(d, string_tools::pod_to_hex((*i).first).c_str(), obj_to_json_str((*i).second)); - } - end_compound(d); - } - } - end_compound(d); - start_struct(d,"blocks", true); - { - std::vector<crypto::hash> blockids; - core_storage->for_all_blocks([&](uint64_t height, const crypto::hash &hash, const cryptonote::block &b)->bool{ - start_struct(d, boost::lexical_cast<std::string>(height)); - write_pod(d, "hash", string_tools::pod_to_hex(hash)); - cryptonote::block block = b; - write_pod(d, "block", obj_to_json_str(block)); - end_compound(d); - return true; - }); - } - end_compound(d); - start_array(d,"key_images", true); - { - std::vector<crypto::key_image> key_images; - core_storage->for_all_key_images([&key_images](const crypto::key_image &k_image)->bool{key_images.push_back(k_image); return true;}); - std::sort(key_images.begin(), key_images.end(), - [](const crypto::key_image &k0, const crypto::key_image &k1) {return memcmp(k0.data, k1.data, sizeof(crypto::key_image::data)) < 0;}); - for (size_t n = 0; n < key_images.size(); ++n) - write_pod(d,key_images[n]); - } - end_compound(d); - if (opt_include_db_only_data) - { - start_struct(d, "block_timestamps", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast<std::string>(h),db->get_block_timestamp(h)); - end_compound(d); - start_struct(d, "block_difficulties", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast<std::string>(h),db->get_block_cumulative_difficulty(h)); - end_compound(d); - start_struct(d, "block_sizes", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast<std::string>(h),db->get_block_size(h)); - end_compound(d); - start_struct(d, "block_coins", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d,boost::lexical_cast<std::string>(h),db->get_block_already_generated_coins(h)); - end_compound(d); - start_struct(d, "block_heights", true); - for (uint64_t h = 0; h < height; ++h) - { - const crypto::hash hash = core_storage->get_block_id_by_height(h); - write_pod(d,boost::lexical_cast<std::string>(h),db->get_block_height(hash)); - } - end_compound(d); - { - std::vector<crypto::hash> txids; - core_storage->for_all_transactions([&txids](const crypto::hash &hash, const cryptonote::transaction &tx)->bool{txids.push_back(hash); return true;}); - std::sort(txids.begin(), txids.end(), - [](const crypto::hash &txid0, const crypto::hash &txid1) {return memcmp(txid0.data, txid1.data, sizeof(crypto::hash::data)) < 0;}); - start_struct(d, "transaction_unlock_times", true); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d,string_tools::pod_to_hex(txids[n]),db->get_tx_unlock_time(txids[n])); - end_compound(d); - start_struct(d, "transaction_block_heights", true); - for (size_t n = 0; n < txids.size(); ++n) - write_pod(d,string_tools::pod_to_hex(txids[n]),db->get_tx_block_height(txids[n])); - end_compound(d); - } - start_array(d, "tx_and_index_from_global", true); - for (uint64_t idx = 0; ; ++idx) - { - try - { - tx_out_index toi = db->get_output_tx_and_index_from_global(idx + base_idx); - start_struct(d, boost::lexical_cast<std::string>(idx)); - write_pod(d, "tx_hash", string_tools::pod_to_hex(toi.first)); - write_pod(d, "tx_index", string_tools::pod_to_hex(toi.second)); - end_compound(d); - } - catch (const OUTPUT_DNE &) { break; } - } - end_compound(d); - start_struct(d, "outputs_amounts", true); - for (uint64_t base = 1; base <= (uint64_t)10000000000000000000ul; base *= 10) for (uint64_t digit = 1; digit <= 9; ++digit) { - uint64_t amount = digit * base; - write_pod(d, boost::lexical_cast<std::string>(amount), db->get_num_outputs(amount)); - } - end_compound(d); - start_array(d, "output_keys", true); - for (uint64_t idx = 0; ; ++idx) - { - try - { - output_data_t od = db->get_output_key(idx + base_idx); - start_struct(d, boost::lexical_cast<std::string>(idx)); - write_pod(d, "pubkey", string_tools::pod_to_hex(od.pubkey)); - write_pod(d, "unlock_time", od.unlock_time); - write_pod(d, "height", od.height); - end_compound(d); - } - catch (const OUTPUT_DNE &) { break; } - } - end_compound(d); - start_struct(d, "hf_versions", true); - for (uint64_t h = 0; h < height; ++h) - write_pod(d, boost::lexical_cast<std::string>(h), (unsigned int)db->get_hard_fork_version(h)); - end_compound(d); - } - end_compound(d); - - CHECK_AND_ASSERT_MES(r, false, "Failed to dump blockchain"); - - if (raw_data_file.fail()) - return 1; - raw_data_file.flush(); - - LOG_PRINT_L0("Blockchain dump OK"); - - return 0; -} diff --git a/src/blockchain_utilities/cn_deserialize.cpp b/src/blockchain_utilities/cn_deserialize.cpp deleted file mode 100644 index a8448dcee..000000000 --- a/src/blockchain_utilities/cn_deserialize.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "cryptonote_core/cryptonote_basic.h" -#include "cryptonote_core/tx_extra.h" -#include "cryptonote_core/blockchain.h" -#include "blockchain_utilities.h" -#include "common/command_line.h" -#include "version.h" - -namespace po = boost::program_options; -using namespace epee; // log_space - -using namespace cryptonote; - -int main(int argc, char* argv[]) -{ - uint32_t log_level = 0; - std::string input; - - tools::sanitize_locale(); - - boost::filesystem::path output_file_path; - - po::options_description desc_cmd_only("Command line options"); - po::options_description desc_cmd_sett("Command line options and settings options"); - const command_line::arg_descriptor<std::string> arg_output_file = {"output-file", "Specify output file", "", true}; - const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", log_level}; - const command_line::arg_descriptor<std::string> arg_input = {"input", "Specify input has a hexadecimal string", ""}; - - command_line::add_arg(desc_cmd_sett, arg_output_file); - command_line::add_arg(desc_cmd_sett, arg_log_level); - command_line::add_arg(desc_cmd_sett, arg_input); - - command_line::add_arg(desc_cmd_only, command_line::arg_help); - - po::options_description desc_options("Allowed options"); - desc_options.add(desc_cmd_only).add(desc_cmd_sett); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc_options, [&]() - { - po::store(po::parse_command_line(argc, argv, desc_options), vm); - po::notify(vm); - return true; - }); - if (! r) - return 1; - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL; - std::cout << desc_options << std::endl; - return 1; - } - - log_level = command_line::get_arg(vm, arg_log_level); - input = command_line::get_arg(vm, arg_input); - if (input.empty()) - { - std::cerr << "--input is mandatory" << std::endl; - return 1; - } - - log_space::get_set_log_detalisation_level(true, log_level); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - - std::string m_config_folder; - - std::ostream *output; - std::ofstream *raw_data_file = NULL; - if (command_line::has_arg(vm, arg_output_file)) - { - output_file_path = boost::filesystem::path(command_line::get_arg(vm, arg_output_file)); - - const boost::filesystem::path dir_path = output_file_path.parent_path(); - if (!dir_path.empty()) - { - if (boost::filesystem::exists(dir_path)) - { - if (!boost::filesystem::is_directory(dir_path)) - { - std::cerr << "output directory path is a file: " << dir_path << std::endl; - return 1; - } - } - else - { - if (!boost::filesystem::create_directory(dir_path)) - { - std::cerr << "Failed to create directory " << dir_path << std::endl; - return 1; - } - } - } - - raw_data_file = new std::ofstream(); - raw_data_file->open(output_file_path.string(), std::ios_base::out | std::ios::trunc); - if (raw_data_file->fail()) - return 1; - output = raw_data_file; - } - else - { - output_file_path = ""; - output = &std::cout; - } - - cryptonote::blobdata blob; - if (!epee::string_tools::parse_hexstr_to_binbuff(input, blob)) - { - std::cerr << "Invalid hex input" << std::endl; - std::cerr << "Invalid hex input: " << input << std::endl; - return 1; - } - - cryptonote::block block; - cryptonote::transaction tx; - std::vector<cryptonote::tx_extra_field> fields; - if (cryptonote::parse_and_validate_block_from_blob(blob, block)) - { - std::cout << "Parsed block:" << std::endl; - std::cout << cryptonote::obj_to_json_str(block) << std::endl; - } - else if (cryptonote::parse_and_validate_tx_from_blob(blob, tx)) - { - std::cout << "Parsed transaction:" << std::endl; - std::cout << cryptonote::obj_to_json_str(tx) << std::endl; - - if (cryptonote::parse_tx_extra(tx.extra, fields)) - { - std::cout << "tx_extra has " << fields.size() << " field(s)" << std::endl; - for (size_t n = 0; n < fields.size(); ++n) - { - std::cout << "field " << n << ": "; - if (typeid(cryptonote::tx_extra_padding) == fields[n].type()) std::cout << "extra padding: " << boost::get<cryptonote::tx_extra_padding>(fields[n]).size << " bytes"; - else if (typeid(cryptonote::tx_extra_pub_key) == fields[n].type()) std::cout << "extra pub key: " << boost::get<cryptonote::tx_extra_pub_key>(fields[n]).pub_key; - else if (typeid(cryptonote::tx_extra_nonce) == fields[n].type()) std::cout << "extra nonce: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_nonce>(fields[n]).nonce); - else if (typeid(cryptonote::tx_extra_merge_mining_tag) == fields[n].type()) std::cout << "extra merge mining tag: depth " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).depth << ", merkle root " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).merkle_root; - else if (typeid(cryptonote::tx_extra_mysterious_minergate) == fields[n].type()) std::cout << "extra minergate custom: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_mysterious_minergate>(fields[n]).data); - else std::cout << "unknown"; - std::cout << std::endl; - } - } - else - { - std::cout << "Failed to parse tx_extra" << std::endl; - } - } - else - { - std::cerr << "Not a recognized CN type" << std::endl; - return 1; - } - - - - if (output->fail()) - return 1; - output->flush(); - if (raw_data_file) - delete raw_data_file; - - return 0; -} diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 07db59796..b15eb4b90 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1801,12 +1801,8 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc { try { - split_height = m_db->get_block_height(*bl_it); - break; - } - catch (const BLOCK_DNE& e) - { - continue; + if (m_db->block_exists(*bl_it, &split_height)) + break; } catch (const std::exception& e) { @@ -3378,7 +3374,7 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync) store_blockchain(); m_sync_counter = 0; } - else if (m_sync_counter >= m_db_blocks_per_sync) + else if (m_db_blocks_per_sync && m_sync_counter >= m_db_blocks_per_sync) { if(m_db_sync_mode == db_async) { diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 73edde1b7..c289f297b 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -280,8 +280,8 @@ namespace cryptonote { LOG_PRINT_RED_L0("Found old-style blockchain.bin in " << old_files.string()); LOG_PRINT_RED_L0("Monero now uses a new format. You can either remove blockchain.bin to start syncing"); - LOG_PRINT_RED_L0("the blockchain anew, or use blockchain_export and blockchain_import to convert your"); - LOG_PRINT_RED_L0("existing blockchain.bin to the new format. See README.md for instructions."); + LOG_PRINT_RED_L0("the blockchain anew, or use monero-blockchain-export and monero-blockchain-import to"); + LOG_PRINT_RED_L0("convert your existing blockchain.bin to the new format. See README.md for instructions."); return false; } } @@ -372,11 +372,10 @@ namespace cryptonote if(options.size() >= 3 && !safemode) { - blocks_per_sync = atoll(options[2].c_str()); - if(blocks_per_sync > 5000) - blocks_per_sync = 5000; - if(blocks_per_sync == 0) - blocks_per_sync = 1; + char *endptr; + uint64_t bps = strtoull(options[2].c_str(), &endptr, 0); + if (*endptr == '\0') + blocks_per_sync = bps; } bool auto_remove_logs = command_line::get_arg(vm, command_line::arg_db_auto_remove_logs) != 0; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 6f095a76f..f16dad281 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -277,8 +277,11 @@ namespace cryptonote m_core.set_target_blockchain_height(static_cast<int64_t>(hshd.current_height)); int64_t diff = static_cast<int64_t>(hshd.current_height) - static_cast<int64_t>(m_core.get_current_blockchain_height()); + int64_t max_block_height = max(static_cast<int64_t>(hshd.current_height),static_cast<int64_t>(m_core.get_current_blockchain_height())); + int64_t last_block_v1 = 1009826; + int64_t diff_v2 = max_block_height > last_block_v1 ? min(abs(diff), max_block_height - last_block_v1) : 0; LOG_PRINT_CCONTEXT_YELLOW("Sync data returned unknown top block: " << m_core.get_current_blockchain_height() << " -> " << hshd.current_height - << " [" << std::abs(diff) << " blocks (" << diff / (24 * 60 * 60 / DIFFICULTY_TARGET_V1) << " days) " + << " [" << std::abs(diff) << " blocks (" << ((abs(diff) - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) " << (0 <= diff ? std::string("behind") : std::string("ahead")) << "] " << ENDL << "SYNCHRONIZATION started", (is_inital ? LOG_LEVEL_0:LOG_LEVEL_1)); LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id); @@ -703,7 +706,7 @@ namespace cryptonote if(m_synchronized.compare_exchange_strong(val_expected, true)) { LOG_PRINT_L0(ENDL << "**********************************************************************" << ENDL - << "You are now synchronized with the network. You may now start simplewallet." << ENDL + << "You are now synchronized with the network. You may now start monero-wallet-cli." << ENDL << ENDL << "Please note, that the blockchain will be saved only after you quit the daemon with \"exit\" command or if you use \"save\" command." << ENDL << "Otherwise, you will possibly need to synchronize the blockchain again." << ENDL diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e456ccba6..511efcb36 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -105,4 +105,4 @@ target_link_libraries(daemon add_dependencies(daemon version) set_property(TARGET daemon PROPERTY - OUTPUT_NAME "bitmonerod") + OUTPUT_NAME "monerod") diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 166fe04ca..00ea6ef6c 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -225,7 +225,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg { if(!args.size()) { - std::cout << "Please specify a wallet address to mine for: start_mining <addr> [threads=1]" << std::endl; + std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>]" << std::endl; return true; } diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index aabc2f09a..ce8ac44fc 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -92,7 +92,7 @@ t_command_server::t_command_server( m_command_lookup.set_handler( "start_mining" , std::bind(&t_command_parser_executor::start_mining, &m_parser, p::_1) - , "Start mining for specified address, start_mining <addr> [threads=1]" + , "Start mining for specified address, start_mining <addr> [<threads>], default 1 thread" ); m_command_lookup.set_handler( "stop_mining" diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index fba3e5398..f10a5a3a6 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -923,10 +923,10 @@ bool t_rpc_command_executor::print_status() bool daemon_is_alive = m_rpc_client->check_connection(); if(daemon_is_alive) { - tools::success_msg_writer() << "bitmonerod is running"; + tools::success_msg_writer() << "monerod is running"; } else { - tools::fail_msg_writer() << "bitmonerod is NOT running"; + tools::fail_msg_writer() << "monerod is NOT running"; } return true; diff --git a/src/miner/CMakeLists.txt b/src/miner/CMakeLists.txt deleted file mode 100644 index d065b9950..000000000 --- a/src/miner/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2014-2016, The Monero Project -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -set(simpleminer_sources - simpleminer.cpp) - -set(simpleminer_headers) - -set(simpleminer_private_headers - simpleminer.h - simpleminer_protocol_defs.h - target_helper.h) - -bitmonero_private_headers(simpleminer - ${simpleminer_private_headers}) -bitmonero_add_executable(simpleminer - ${simpleminer_sources} - ${simpleminer_headers} - ${simpleminer_private_headers}) -target_link_libraries(simpleminer - LINK_PRIVATE - cryptonote_core - common - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_REGEX_LIBRARY} - ${Boost_CHRONO_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} - ${EXTRA_LIBRARIES}) diff --git a/src/miner/simpleminer.cpp b/src/miner/simpleminer.cpp deleted file mode 100644 index ba956d90b..000000000 --- a/src/miner/simpleminer.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#include "common/command_line.h" -#include "misc_log_ex.h" -#include "simpleminer.h" -#include "target_helper.h" -#include "net/http_server_handlers_map2.h" -#include "simpleminer_protocol_defs.h" -#include "storages/http_abstract_invoke.h" -#include "string_tools.h" -#include "cryptonote_core/account.h" -#include "cryptonote_core/cryptonote_format_utils.h" - -using namespace epee; -namespace po = boost::program_options; - -int main(int argc, char** argv) -{ - string_tools::set_module_name_and_folder(argv[0]); - - //set up logging options - log_space::get_set_log_detalisation_level(true, LOG_LEVEL_4); - log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); - log_space::log_singletone::add_logger(LOGGER_FILE, - log_space::log_singletone::get_default_log_file().c_str(), - log_space::log_singletone::get_default_log_folder().c_str()); - - po::options_description desc("Allowed options"); - command_line::add_arg(desc, command_line::arg_help); - mining::simpleminer::init_options(desc); - - //uint32_t t = mining::get_target_for_difficulty(700000); - - po::variables_map vm; - bool r = command_line::handle_error_helper(desc, [&]() - { - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); - - if (command_line::get_arg(vm, command_line::arg_help)) - { - std::cout << desc << std::endl; - return false; - } - - return true; - }); - if (!r) - return 1; - - mining::simpleminer miner; - r = miner.init(vm); - r = r && miner.run(); // Never returns... - - return 0; -} - - - -namespace mining -{ - const command_line::arg_descriptor<std::string, true> arg_pool_addr = {"pool-addr", ""}; - const command_line::arg_descriptor<std::string, true> arg_login = {"login", ""}; - const command_line::arg_descriptor<std::string, true> arg_pass = {"pass", ""}; - - //----------------------------------------------------------------------------------------------------- - void simpleminer::init_options(boost::program_options::options_description& desc) - { - command_line::add_arg(desc, arg_pool_addr); - command_line::add_arg(desc, arg_login); - command_line::add_arg(desc, arg_pass); - } - bool simpleminer::init(const boost::program_options::variables_map& vm) - { - std::string pool_addr = command_line::get_arg(vm, arg_pool_addr); - //parse ip and address - std::string::size_type p = pool_addr.find(':'); - CHECK_AND_ASSERT_MES(p != std::string::npos && (p + 1 != pool_addr.size()), false, "Wrong srv address syntax"); - m_pool_ip = pool_addr.substr(0, p); - m_pool_port = pool_addr.substr(p + 1, pool_addr.size()); - m_login = command_line::get_arg(vm, arg_login); - m_pass = command_line::get_arg(vm, arg_pass); - return true; - } - - bool simpleminer::text_job_details_to_native_job_details(const job_details& job, simpleminer::job_details_native& native_details) - { - bool r = epee::string_tools::parse_hexstr_to_binbuff(job.blob, native_details.blob); - CHECK_AND_ASSERT_MES(r, false, "wrong buffer sent from pool server"); - r = epee::string_tools::parse_tpod_from_hex_string(job.target, native_details.target); - CHECK_AND_ASSERT_MES(r, false, "wrong buffer sent from pool server"); - native_details.job_id = job.job_id; - return true; - } - - bool simpleminer::run() - { - std::string pool_session_id; - simpleminer::job_details_native job = AUTO_VAL_INIT(job); - uint64_t last_job_ticks = 0; - - while(true) - { - //----------------- - last_job_ticks = epee::misc_utils::get_tick_count(); - if(!m_http_client.is_connected()) - { - LOG_PRINT_L0("Connecting " << m_pool_ip << ":" << m_pool_port << "...."); - if(!m_http_client.connect(m_pool_ip, m_pool_port, 20000)) - { - LOG_PRINT_L0("Failed to connect " << m_pool_ip << ":" << m_pool_port << ", sleep...."); - epee::misc_utils::sleep_no_w(1000); - continue; - } - //DO AUTH - LOG_PRINT_L0("Connected " << m_pool_ip << ":" << m_pool_port << " OK"); - COMMAND_RPC_LOGIN::request req = AUTO_VAL_INIT(req); - req.login = m_login; - req.pass = m_pass; - req.agent = "simpleminer/0.1"; - COMMAND_RPC_LOGIN::response resp = AUTO_VAL_INIT(resp); - if(!epee::net_utils::invoke_http_json_rpc<mining::COMMAND_RPC_LOGIN>("/", req, resp, m_http_client)) - { - LOG_PRINT_L0("Failed to invoke login " << m_pool_ip << ":" << m_pool_port << ", disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - if(resp.status != "OK" || resp.id.empty()) - { - LOG_PRINT_L0("Failed to login " << m_pool_ip << ":" << m_pool_port << ", disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - pool_session_id = resp.id; - //78 - if (resp.job.blob.empty() && resp.job.target.empty() && resp.job.job_id.empty()) - { - LOG_PRINT_L0("Job didn't change"); - continue; - } - else if(!text_job_details_to_native_job_details(resp.job, job)) - { - LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - last_job_ticks = epee::misc_utils::get_tick_count(); - - } - while(epee::misc_utils::get_tick_count() - last_job_ticks < 20000) - { - //uint32_t c = (*((uint32_t*)&job.blob.data()[39])); - ++(*((uint32_t*)&job.blob.data()[39])); - crypto::hash h = cryptonote::null_hash; - crypto::cn_slow_hash(job.blob.data(), job.blob.size(), h); - if( ((uint32_t*)&h)[7] < job.target ) - { - //found! - - COMMAND_RPC_SUBMITSHARE::request submit_request = AUTO_VAL_INIT(submit_request); - COMMAND_RPC_SUBMITSHARE::response submit_response = AUTO_VAL_INIT(submit_response); - submit_request.id = pool_session_id; - submit_request.job_id = job.job_id; - submit_request.nonce = epee::string_tools::pod_to_hex((*((uint32_t*)&job.blob.data()[39]))); - submit_request.result = epee::string_tools::pod_to_hex(h); - LOG_PRINT_L0("Share found: nonce=" << submit_request.nonce << " for job=" << job.job_id << ", submitting..."); - if(!epee::net_utils::invoke_http_json_rpc<mining::COMMAND_RPC_SUBMITSHARE>("/", submit_request, submit_response, m_http_client)) - { - LOG_PRINT_L0("Failed to submit share! disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - break; - } - if(submit_response.status != "OK") - { - LOG_PRINT_L0("Failed to submit share! (submitted share rejected) disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - break; - } - LOG_PRINT_GREEN("Share submitted successfully!", LOG_LEVEL_0); - break; - } - } - //get next job - COMMAND_RPC_GETJOB::request getjob_request = AUTO_VAL_INIT(getjob_request); - COMMAND_RPC_GETJOB::response getjob_response = AUTO_VAL_INIT(getjob_response); - getjob_request.id = pool_session_id; - LOG_PRINT_L0("Getting next job..."); - if(!epee::net_utils::invoke_http_json_rpc<mining::COMMAND_RPC_GETJOB>("/", getjob_request, getjob_response, m_http_client)) - { - LOG_PRINT_L0("Can't get new job! Disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - if (getjob_response.blob.empty() && getjob_response.target.empty() && getjob_response.job_id.empty()) - { - LOG_PRINT_L0("Job didn't change"); - continue; - } - else if(!text_job_details_to_native_job_details(getjob_response, job)) - { - LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep...."); - m_http_client.disconnect(); - epee::misc_utils::sleep_no_w(1000); - continue; - } - last_job_ticks = epee::misc_utils::get_tick_count(); - } - - return true; - - } -} diff --git a/src/miner/simpleminer.h b/src/miner/simpleminer.h deleted file mode 100644 index 177a562b3..000000000 --- a/src/miner/simpleminer.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "net/http_client.h" -#include "cryptonote_protocol/blobdatatype.h" -#include "simpleminer_protocol_defs.h" -namespace mining -{ - class simpleminer - { - public: - static void init_options(boost::program_options::options_description& desc); - bool init(const boost::program_options::variables_map& vm); - bool run(); - private: - struct job_details_native - { - cryptonote::blobdata blob; - uint32_t target; - std::string job_id; - }; - - static bool text_job_details_to_native_job_details(const job_details& job, job_details_native& native_details); - - std::string m_pool_ip; - std::string m_pool_port; - std::string m_login; - std::string m_pass; - epee::net_utils::http::http_simple_client m_http_client; - }; -} diff --git a/src/miner/simpleminer_protocol_defs.h b/src/miner/simpleminer_protocol_defs.h deleted file mode 100644 index 29c5fb3ec..000000000 --- a/src/miner/simpleminer_protocol_defs.h +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "cryptonote_protocol/cryptonote_protocol_defs.h" -#include "cryptonote_core/cryptonote_basic.h" -#include "crypto/hash.h" -#include "net/rpc_method_name.h" - -namespace mining -{ - //----------------------------------------------- -#define CORE_RPC_STATUS_OK "OK" - - - struct job_details - { - std::string blob; - std::string target; - std::string job_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(blob) - KV_SERIALIZE(target) - KV_SERIALIZE(job_id) - END_KV_SERIALIZE_MAP() - }; - - - struct COMMAND_RPC_LOGIN - { - RPC_METHOD_NAME("login"); - - struct request - { - std::string login; - std::string pass; - std::string agent; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(login) - KV_SERIALIZE(pass) - KV_SERIALIZE(agent) - END_KV_SERIALIZE_MAP() - }; - - - struct response - { - std::string status; - std::string id; - job_details job; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - KV_SERIALIZE(id) - KV_SERIALIZE(job) - END_KV_SERIALIZE_MAP() - }; - }; - - struct COMMAND_RPC_GETJOB - { - RPC_METHOD_NAME("getjob"); - - struct request - { - std::string id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(id) - END_KV_SERIALIZE_MAP() - }; - - typedef job_details response; - }; - - struct COMMAND_RPC_SUBMITSHARE - { - RPC_METHOD_NAME("submit"); - - struct request - { - std::string id; - std::string nonce; - std::string result; - std::string job_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(id) - KV_SERIALIZE(nonce) - KV_SERIALIZE(result) - KV_SERIALIZE(job_id) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - std::string status; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - END_KV_SERIALIZE_MAP() - }; - }; -} - diff --git a/src/miner/target_helper.h b/src/miner/target_helper.h deleted file mode 100644 index d12f7edae..000000000 --- a/src/miner/target_helper.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2014-2016, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once -#include "cryptonote_core/difficulty.h" - - -namespace mining -{ - inline uint32_t get_target_for_difficulty(cryptonote::difficulty_type difficulty) - { - if(!difficulty) - return 0xffffffff; - return 0xffffffff/static_cast<uint32_t>(difficulty); - } - -} diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt index 96d812361..97852c3dc 100644 --- a/src/simplewallet/CMakeLists.txt +++ b/src/simplewallet/CMakeLists.txt @@ -57,3 +57,6 @@ target_link_libraries(simplewallet ${EXTRA_LIBRARIES}) add_dependencies(simplewallet version) +set_property(TARGET simplewallet + PROPERTY + OUTPUT_NAME "monero-wallet-cli")
\ No newline at end of file diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 44b5b0c70..421d1f53a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -77,6 +77,8 @@ typedef cryptonote::simple_wallet sw; #define DEFAULT_MIX 4 +#define KEY_IMAGE_EXPORT_FILE_MAGIC "Monero key image export\001" + // workaround for a suspected bug in pthread/kernel on MacOS X #ifdef __APPLE__ #define DEFAULT_MAX_CONCURRENCY 1 @@ -1596,7 +1598,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string tr("Your wallet has been generated!\n" "To start synchronizing with the daemon, use \"refresh\" command.\n" "Use \"help\" command to see the list of available commands.\n" - "Always use \"exit\" command when closing simplewallet to save your\n" + "Always use \"exit\" command when closing monero-wallet-cli to save your\n" "current session's state. Otherwise, you might need to synchronize \n" "your wallet again (your wallet keys are NOT at risk in any case).\n") ; @@ -3583,11 +3585,14 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args) try { std::vector<std::pair<crypto::key_image, crypto::signature>> ski = m_wallet->export_key_images(); - std::string data; + std::string data(KEY_IMAGE_EXPORT_FILE_MAGIC, strlen(KEY_IMAGE_EXPORT_FILE_MAGIC)); + const cryptonote::account_public_address &keys = m_wallet->get_account().get_keys().m_account_address; + data += std::string((const char *)&keys.m_spend_public_key, sizeof(crypto::public_key)); + data += std::string((const char *)&keys.m_view_public_key, sizeof(crypto::public_key)); for (const auto &i: ski) { - data += epee::string_tools::pod_to_hex(i.first); - data += epee::string_tools::pod_to_hex(i.second); + data += std::string((const char *)&i.first, sizeof(crypto::key_image)); + data += std::string((const char *)&i.second, sizeof(crypto::signature)); } bool r = epee::file_io_utils::save_string_to_file(filename, data); if (!r) @@ -3623,34 +3628,41 @@ bool simple_wallet::import_key_images(const std::vector<std::string> &args) fail_msg_writer() << tr("failed to read file ") << filename; return true; } + const size_t magiclen = strlen(KEY_IMAGE_EXPORT_FILE_MAGIC); + if (data.size() < magiclen || memcmp(data.data(), KEY_IMAGE_EXPORT_FILE_MAGIC, magiclen)) + { + fail_msg_writer() << "Bad key image export file magic in " << filename; + return true; + } + const size_t headerlen = magiclen + 2 * sizeof(crypto::public_key); + if (data.size() < headerlen) + { + fail_msg_writer() << "Bad data size from file " << filename; + return true; + } + const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[magiclen]; + const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[magiclen + sizeof(crypto::public_key)]; + const cryptonote::account_public_address &keys = m_wallet->get_account().get_keys().m_account_address; + if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key) + { + fail_msg_writer() << "Key images from " << filename << " are for a different account"; + return true; + } - const size_t record_size = sizeof(crypto::key_image)*2 + sizeof(crypto::signature)*2; - if (data.size() % record_size) + const size_t record_size = sizeof(crypto::key_image) + sizeof(crypto::signature); + if ((data.size() - headerlen) % record_size) { fail_msg_writer() << "Bad data size from file " << filename; return true; } - size_t nki = data.size() / record_size; + size_t nki = (data.size() - headerlen) / record_size; std::vector<std::pair<crypto::key_image, crypto::signature>> ski; ski.reserve(nki); for (size_t n = 0; n < nki; ++n) { - cryptonote::blobdata bd; - - if(!epee::string_tools::parse_hexstr_to_binbuff(std::string(&data[n * record_size], sizeof(crypto::key_image)*2), bd)) - { - fail_msg_writer() << tr("failed to parse key image"); - return false; - } - crypto::key_image key_image = *reinterpret_cast<const crypto::key_image*>(bd.data()); - - if(!epee::string_tools::parse_hexstr_to_binbuff(std::string(&data[n * record_size + sizeof(crypto::key_image)*2], sizeof(crypto::signature)*2), bd)) - { - fail_msg_writer() << tr("failed to parse signature"); - return false; - } - crypto::signature signature = *reinterpret_cast<const crypto::signature*>(bd.data()); + crypto::key_image key_image = *reinterpret_cast<const crypto::key_image*>(&data[headerlen + n * record_size]); + crypto::signature signature = *reinterpret_cast<const crypto::signature*>(&data[headerlen + n * record_size + sizeof(crypto::key_image)]); ski.push_back(std::make_pair(key_image, signature)); } @@ -3734,7 +3746,7 @@ int main(int argc, char* argv[]) return false; } // epee didn't find path to executable from argv[0], so use this default file name. - log_file_name = "simplewallet.log"; + log_file_name = "monero-wallet-cli.log"; // The full path will use cwd because epee also returned an empty default log folder. } default_log /= log_file_name; @@ -3767,7 +3779,7 @@ int main(int argc, char* argv[]) if (command_line::get_arg(vm, command_line::arg_help)) { success_msg_writer() << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"; - success_msg_writer() << sw::tr("Usage:") << " simplewallet [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]"; + success_msg_writer() << sw::tr("Usage:") << " monero-wallet-cli [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]"; success_msg_writer() << desc_all; return false; } @@ -3786,8 +3798,8 @@ int main(int argc, char* argv[]) return 0; // log_file_path - // default: < argv[0] directory >/simplewallet.log - // so if ran as "simplewallet" (no path), log file will be in cwd + // default: < argv[0] directory >/monero-wallet-cli.log + // so if ran as "monero-wallet-cli" (no path), log file will be in cwd // // if log-file argument given: // absolute path diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index c4585f9ee..96653556b 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -27,7 +27,6 @@ # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # include (${PROJECT_SOURCE_DIR}/cmake/libutils.cmake) -include (${PROJECT_SOURCE_DIR}/cmake/MergeStaticLibs.cmake) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -75,10 +74,18 @@ target_link_libraries(wallet ${Boost_REGEX_LIBRARY} ${EXTRA_LIBRARIES}) -set(libs_to_merge wallet cryptonote_core mnemonics common crypto) -merge_static_libs(wallet_merged "${libs_to_merge}") -install(TARGETS wallet_merged - ARCHIVE DESTINATION lib) -install(FILES ${wallet_api_headers} - DESTINATION include/wallet) +# build and install libwallet_merged only if we building for GUI +if (BUILD_GUI_DEPS) + set(libs_to_merge wallet cryptonote_core mnemonics common crypto ringct) + + foreach(lib ${libs_to_merge}) + list(APPEND objlibs $<TARGET_OBJECTS:obj_${lib}>) # matches naming convention in src/CMakeLists.txt + endforeach() + add_library(wallet_merged STATIC ${objlibs}) + install(TARGETS wallet_merged + ARCHIVE DESTINATION lib) + + install(FILES ${wallet_api_headers} + DESTINATION include/wallet) +endif() diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d889720af..a195abde6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2709,6 +2709,8 @@ void wallet2::get_outs(std::vector<std::vector<entry>> &outs, const std::list<tr } } LOG_PRINT_L1("" << num_outs << " outputs of size " << print_money(amount)); + THROW_WALLET_EXCEPTION_IF(num_outs == 0, error::wallet_internal_error, + "histogram reports no outputs for " + boost::lexical_cast<std::string>(amount) + ", not even ours"); if (num_outs <= requested_outputs_count) { @@ -3103,27 +3105,24 @@ static size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs) // rct signatures - // simple + // type size += 1; - // message - size += 32; - // rangeSigs size += (2*64*32+32+64*32) * n_outputs; - // MGs - only the last slot of II is saved, the rest can be reconstructed - size += n_inputs * (32 * (mixin+1) * n_inputs + 32 + 32 * (/*n_inputs+*/1)); + // MGs + size += n_inputs * (32 * (mixin+1) + 32); // mixRing - not serialized, can be reconstructed /* size += 2 * 32 * (mixin+1) * n_inputs; */ // pseudoOuts - size += 32 * n_outputs; + size += 32 * n_inputs; // ecdhInfo - size += 3 * 32 * n_outputs; + size += 2 * 32 * n_outputs; // outPk - only commitment is saved - size += 1 * 32 * n_outputs; + size += 32 * n_outputs; // txnFee size += 4; @@ -3468,7 +3467,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp return ptx_vector; } -std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, const uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon) +std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptonote::account_public_address &address, const size_t fake_outs_count, const uint64_t unlock_time, uint64_t fee_multiplier, const std::vector<uint8_t> extra, bool trusted_daemon) { std::vector<size_t> unused_transfers_indices; std::vector<size_t> unused_dust_indices; @@ -3485,6 +3484,8 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(const cryptono uint64_t upper_transaction_size_limit = get_upper_tranaction_size_limit(); const bool use_rct = use_fork_rules(4, 0); + fee_multiplier = sanitize_fee_multiplier(fee_multiplier); + // gather all our dust and non dust outputs for (size_t i = 0; i < m_transfers.size(); ++i) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 33f5226ef..75e75f258 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,9 @@ # # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +# The docs say this only affects grouping in IDEs +set(folder "tests") + if (WIN32 AND STATIC) add_definitions(-DSTATICLIB) # miniupnp changed their static define @@ -39,24 +42,27 @@ find_package(GTest) if (GTest_FOUND) include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) else () + message(STATUS "GTest not found on the system: will use GTest bundled with this source") add_subdirectory(gtest) include_directories(SYSTEM "${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}") # Emulate the FindGTest module's variable. - set(GTEST_MAIN_LIBRARIES gtest_main) + set(GTEST_LIBRARIES gtest) # Ignore some warnings when building gtest binaries. if(NOT MSVC) - set_property(TARGET gtest gtest_main + set_property(TARGET gtest APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") endif() -endif () -if (NOT DEFINED ENV{TRAVIS}) - add_subdirectory(core_tests) + set_property(TARGET gtest + PROPERTY + FOLDER "${folder}") endif () + +add_subdirectory(core_tests) add_subdirectory(crypto) add_subdirectory(functional_tests) add_subdirectory(performance_tests) @@ -65,9 +71,7 @@ add_subdirectory(unit_tests) add_subdirectory(difficulty) add_subdirectory(hash) add_subdirectory(net_load_tests) - -# Disabled until issue #895 is resolved -#add_subdirectory(libwallet_api_tests) +add_subdirectory(libwallet_api_tests) # add_subdirectory(daemon_tests) @@ -84,17 +88,19 @@ target_link_libraries(hash-target-tests cryptonote_core) set_property(TARGET hash-target-tests PROPERTY - FOLDER "tests") + FOLDER "${folder}") add_test( NAME hash-target COMMAND hash-target-tests) -# Skip the core_tests if we are running in Travis-CI because they will take too long -if (DEFINED ENV{TRAVIS}) - add_custom_target(tests DEPENDS difficulty hash performance_tests core_proxy unit_tests) -else () - add_custom_target(tests DEPENDS coretests difficulty hash performance_tests core_proxy unit_tests) -endif () +set(enabled_tests + coretests + difficulty + hash + performance_tests + core_proxy + unit_tests) -set_property(TARGET gtest gtest_main hash-target-tests tests PROPERTY FOLDER "tests") +add_custom_target(tests DEPENDS enabled_tests) +set_property(TARGET tests PROPERTY FOLDER "${folder}") diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt index 25ca09ce4..ae11ab5d5 100644 --- a/tests/daemon_tests/CMakeLists.txt +++ b/tests/daemon_tests/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries(transfers crypto common epee - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_LIBRARIES}) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_transfers") diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt index e60947084..416192cce 100644 --- a/tests/libwallet_api_tests/CMakeLists.txt +++ b/tests/libwallet_api_tests/CMakeLists.txt @@ -40,7 +40,7 @@ add_executable(libwallet_api_tests target_link_libraries(libwallet_api_tests LINK_PRIVATE wallet - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${EXTRA_LIBRARIES}) set_property(TARGET libwallet_api_tests diff --git a/tests/libwallet_api_tests/scripts/create_wallets.sh b/tests/libwallet_api_tests/scripts/create_wallets.sh index 6abad84f9..e25d2c317 100755 --- a/tests/libwallet_api_tests/scripts/create_wallets.sh +++ b/tests/libwallet_api_tests/scripts/create_wallets.sh @@ -2,7 +2,7 @@ function create_wallet { wallet_name=$1 - echo 0 | simplewallet --testnet --trusted-daemon --daemon-address localhost:38081 --generate-new-wallet $wallet_name --password "" --restore-height=1 + echo 0 | monero-wallet-cli --testnet --trusted-daemon --daemon-address localhost:38081 --generate-new-wallet $wallet_name --password "" --restore-height=1 } diff --git a/tests/libwallet_api_tests/scripts/mining_start.sh b/tests/libwallet_api_tests/scripts/mining_start.sh index 76eabfc55..30e3b7fbb 100755 --- a/tests/libwallet_api_tests/scripts/mining_start.sh +++ b/tests/libwallet_api_tests/scripts/mining_start.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log start_mining +rlwrap monero-wallet-cli --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log start_mining diff --git a/tests/libwallet_api_tests/scripts/mining_stop.sh b/tests/libwallet_api_tests/scripts/mining_stop.sh index 640e56943..fadd68085 100755 --- a/tests/libwallet_api_tests/scripts/mining_stop.sh +++ b/tests/libwallet_api_tests/scripts/mining_stop.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_miner.log stop_mining +rlwrap monero-wallet-cli --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_miner.log stop_mining diff --git a/tests/libwallet_api_tests/scripts/open_wallet_1.sh b/tests/libwallet_api_tests/scripts/open_wallet_1.sh index 08f4e28ab..6e5a373d8 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_1.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_1.sh @@ -1,5 +1,5 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_01.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log +rlwrap monero-wallet-cli --wallet-file wallet_01.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log diff --git a/tests/libwallet_api_tests/scripts/open_wallet_2.sh b/tests/libwallet_api_tests/scripts/open_wallet_2.sh index 8a16a6647..305af2f11 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_2.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_2.sh @@ -1,5 +1,5 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_02.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log +rlwrap monero-wallet-cli --wallet-file wallet_02.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log diff --git a/tests/libwallet_api_tests/scripts/open_wallet_3.sh b/tests/libwallet_api_tests/scripts/open_wallet_3.sh index 64a04b3c4..43df4a906 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_3.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_3.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_03.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_03.log +rlwrap monero-wallet-cli --wallet-file wallet_03.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_03.log diff --git a/tests/libwallet_api_tests/scripts/open_wallet_4.sh b/tests/libwallet_api_tests/scripts/open_wallet_4.sh index 8ebf0a4c7..c48dd5636 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_4.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_4.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log +rlwrap monero-wallet-cli --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log diff --git a/tests/libwallet_api_tests/scripts/open_wallet_5.sh b/tests/libwallet_api_tests/scripts/open_wallet_5.sh index bbeb702c0..820114d48 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_5.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_5.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_05.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_05.log +rlwrap monero-wallet-cli --wallet-file wallet_05.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_05.log diff --git a/tests/libwallet_api_tests/scripts/open_wallet_miner.sh b/tests/libwallet_api_tests/scripts/open_wallet_miner.sh index 07a4e58ea..633e2519c 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_miner.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_miner.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address 127.0.0.1:38081 --log-file wallet_m.log +rlwrap monero-wallet-cli --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address 127.0.0.1:38081 --log-file wallet_m.log diff --git a/tests/libwallet_api_tests/scripts/send_funds.sh b/tests/libwallet_api_tests/scripts/send_funds.sh index 437e4f240..b7f282b71 100755 --- a/tests/libwallet_api_tests/scripts/send_funds.sh +++ b/tests/libwallet_api_tests/scripts/send_funds.sh @@ -6,7 +6,7 @@ function send_funds { local amount=$1 local dest=$(cat "$2.address.txt") - simplewallet --wallet-file wallet_m --password "" \ + monero-wallet-cli --wallet-file wallet_m --password "" \ --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log \ --command transfer $dest $amount } diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt index c3a68d18d..2c97acf51 100644 --- a/tests/net_load_tests/CMakeLists.txt +++ b/tests/net_load_tests/CMakeLists.txt @@ -40,7 +40,7 @@ target_link_libraries(net_load_tests_clt otshell_utils p2p cryptonote_core - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} @@ -62,7 +62,7 @@ target_link_libraries(net_load_tests_srv otshell_utils p2p cryptonote_core - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 3d42809e3..d36c2748c 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -69,7 +69,7 @@ target_link_libraries(unit_tests rpc wallet p2p - ${GTEST_MAIN_LIBRARIES} + ${GTEST_LIBRARIES} ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index a279b6c68..b3bd47687 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -58,7 +58,7 @@ public: virtual void block_txn_stop() {} virtual void block_txn_abort() {} virtual void drop_hard_fork_info() {} - virtual bool block_exists(const crypto::hash& h) const { return false; } + virtual bool block_exists(const crypto::hash& h, uint64_t *height) const { return false; } virtual block get_block(const crypto::hash& h) const { return block(); } virtual uint64_t get_block_height(const crypto::hash& h) const { return 0; } virtual block_header get_block_header(const crypto::hash& h) const { return block_header(); } diff --git a/translations/monero.ts b/translations/monero.ts index 7909266cc..e245c168b 100644 --- a/translations/monero.ts +++ b/translations/monero.ts @@ -311,7 +311,7 @@ Wallet file name: </source> <source>Your wallet has been generated. To start synchronizing with the daemon use "refresh" command. Use "help" command to see the list of available commands. -Always use "exit" command when closing simplewallet to save +Always use "exit" command when closing monero-wallet-cli to save current session's state. Otherwise, you will possibly need to synchronize your wallet again. Your wallet key is NOT under risk anyway. </source> diff --git a/utils/conf/bitmonerod.conf b/utils/conf/bitmonerod.conf deleted file mode 100644 index 64a02741d..000000000 --- a/utils/conf/bitmonerod.conf +++ /dev/null @@ -1,7 +0,0 @@ -# Configuration for bitmonerod -# Syntax: any command line option may be specified as 'clioptionname=value'. -# See 'bitmonerod --help' for all available options. - -data-dir=/var/lib/bitmonero -log-file=/var/log/bitmonero/bitmonero.log -log-level=0 diff --git a/utils/conf/monerod.conf b/utils/conf/monerod.conf new file mode 100644 index 000000000..9b391dfa1 --- /dev/null +++ b/utils/conf/monerod.conf @@ -0,0 +1,7 @@ +# Configuration for monerod +# Syntax: any command line option may be specified as 'clioptionname=value'. +# See 'monerod --help' for all available options. + +data-dir=/var/lib/monero +log-file=/var/log/monero/monero.log +log-level=0 diff --git a/utils/systemd/bitmonerod.service b/utils/systemd/monerod.service index da012c4e3..182878ebb 100644 --- a/utils/systemd/bitmonerod.service +++ b/utils/systemd/monerod.service @@ -1,16 +1,16 @@ [Unit] -Description=Monero cryptocurrency node +Description=Monero Full Node After=network.target [Service] -User=bitmonero -Group=bitmonero +User=monero +Group=monero WorkingDirectory=~ Type=forking -ExecStart=/usr/bin/bitmonerod --config-file /etc/bitmonerod.conf --detach +ExecStart=/usr/bin/monerod --config-file /etc/monerod.conf --detach -# This is necessary because bitmonerod does not yet support +# This is necessary because monerod does not yet support # writing a PID file, which means systemd tries to guess the PID # by default, but it guesses wrong (sometimes, depending on # random timing of events), because the daemon forks twice. |