Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 735a33e8d8 | |||
| e037534f44 | |||
| 9570081ae5 | |||
| e0fa7fa384 | |||
| 9c426a30f9 | |||
| ca9b2493ee | |||
| cf436cde1a | |||
| b99e670f84 | |||
| 88a0985104 | |||
| 4701a78ad1 | |||
| 861895e92d | |||
| 5fc4d57ee5 | |||
| efbd42f9d9 | |||
| 4cbaa6e43d | |||
| f0b3bbf808 | |||
| 33aa05678f | |||
| 37252f6aec | |||
| 67e6c4370b | |||
| 7340300460 | |||
| 7dd11711b0 | |||
| bcf3f6afdd | |||
| 3ebd05d4e5 | |||
| a093092ef7 | |||
| 1eebb82bcc | |||
| fb6a363050 | |||
| 2e2139ffb7 | |||
| 0749a8bd3c | |||
| 1b0afeeb1c | |||
| 418a993618 | |||
| ea7f954381 | |||
| 6e8554221f | |||
| 53df2deb36 | |||
| e67016ddb4 | |||
| 661439f4e0 | |||
| 5fdcda50ee | |||
| 921b0fb11b | |||
| 7ece1550e1 | |||
| 85318e7800 | |||
| a085da3247 | |||
| d8b1ec8b8b | |||
| 02563bf4b9 | |||
| c57a65b246 | |||
| 06d05c21eb |
@@ -26,6 +26,8 @@ env:
|
||||
- HOST=arm-linux-gnueabihf PACKAGES="gperf g++-arm-linux-gnueabihf"
|
||||
# ARM v8
|
||||
- HOST=aarch64-linux-gnu PACKAGES="gperf g++-aarch64-linux-gnu"
|
||||
# i686 Win
|
||||
- HOST=i686-w64-mingw32 PACKAGES="python3 nsis g++-mingw-w64-i686"
|
||||
# i686 Linux
|
||||
- HOST=i686-pc-linux-gnu PACKAGES="gperf cmake g++-multilib bc python3-zmq" RUN_TESTS=true
|
||||
# Win64
|
||||
|
||||
+36
-32
@@ -529,6 +529,40 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(NO_AES "Explicitly disable AES support" ${NO_AES})
|
||||
|
||||
if(NO_AES)
|
||||
message(STATUS "AES support explicitly disabled")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_AES")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_AES")
|
||||
elseif(NOT ARM AND NOT PPC64LE AND NOT PPC64 AND NOT PPC AND NOT S390X)
|
||||
message(STATUS "AES support enabled")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
||||
elseif(PPC64LE OR PPC64 OR PPC)
|
||||
message(STATUS "AES support not available on POWER")
|
||||
elseif(S390X)
|
||||
message(STATUS "AES support not available on s390x")
|
||||
elseif(ARM6)
|
||||
message(STATUS "AES support not available on ARMv6")
|
||||
elseif(ARM7)
|
||||
message(STATUS "AES support not available on ARMv7")
|
||||
elseif(ARM8)
|
||||
CHECK_CXX_ACCEPTS_FLAG("-march=${ARCH}+crypto" ARCH_PLUS_CRYPTO)
|
||||
if(ARCH_PLUS_CRYPTO)
|
||||
message(STATUS "Crypto extensions enabled for ARMv8")
|
||||
set(ARCH_FLAG "-march=${ARCH}+crypto")
|
||||
else()
|
||||
message(STATUS "Crypto extensions unavailable on your ARMv8 device")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "AES support disabled")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAG}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")
|
||||
|
||||
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
|
||||
if(NOT MINGW)
|
||||
set(WARNINGS_AS_ERRORS_FLAG "-Werror")
|
||||
@@ -639,38 +673,8 @@ else()
|
||||
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
|
||||
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")
|
||||
|
||||
option(NO_AES "Explicitly disable AES support" ${NO_AES})
|
||||
|
||||
if(NO_AES)
|
||||
message(STATUS "AES support explicitly disabled")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_AES")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_AES")
|
||||
elseif(NOT ARM AND NOT PPC64LE AND NOT PPC64 AND NOT PPC AND NOT S390X)
|
||||
message(STATUS "AES support enabled")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
||||
elseif(PPC64LE OR PPC64 OR PPC)
|
||||
message(STATUS "AES support not available on POWER")
|
||||
elseif(S390X)
|
||||
message(STATUS "AES support not available on s390x")
|
||||
elseif(ARM6)
|
||||
message(STATUS "AES support not available on ARMv6")
|
||||
elseif(ARM7)
|
||||
message(STATUS "AES support not available on ARMv7")
|
||||
elseif(ARM8)
|
||||
CHECK_CXX_ACCEPTS_FLAG("-march=${ARCH}+crypto" ARCH_PLUS_CRYPTO)
|
||||
if(ARCH_PLUS_CRYPTO)
|
||||
message(STATUS "Crypto extensions enabled for ARMv8")
|
||||
set(ARCH_FLAG "-march=${ARCH}+crypto")
|
||||
else()
|
||||
message(STATUS "Crypto extensions unavailable on your ARMv8 device")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "AES support disabled")
|
||||
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} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${COVERAGE_FLAGS} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${COVERAGE_FLAGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS}")
|
||||
|
||||
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
|
||||
|
||||
@@ -78,5 +78,9 @@ elseif(ARCHITECTURE STREQUAL "aarch64")
|
||||
set(BUILD_64 ON)
|
||||
endif()
|
||||
|
||||
if(ARCHITECTURE STREQUAL "i686" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
SET(LINUX_32 ON)
|
||||
endif()
|
||||
|
||||
#Create a new global cmake flag that indicates building with depends
|
||||
set (DEPENDS true)
|
||||
|
||||
@@ -63,7 +63,8 @@ namespace epee
|
||||
|
||||
~async_stdin_reader()
|
||||
{
|
||||
stop();
|
||||
try { stop(); }
|
||||
catch (...) { /* ignore */ }
|
||||
}
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
|
||||
@@ -275,6 +275,9 @@ public:
|
||||
}
|
||||
virtual ~async_protocol_handler()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
m_deletion_initiated = true;
|
||||
if(m_connection_initialized)
|
||||
{
|
||||
@@ -288,6 +291,9 @@ public:
|
||||
CHECK_AND_ASSERT_MES_NO_RET(0 == boost::interprocess::ipcdetail::atomic_read32(&m_wait_count), "Failed to wait for operation completion. m_wait_count = " << m_wait_count);
|
||||
|
||||
MTRACE(m_connection_context << "~async_protocol_handler()");
|
||||
|
||||
}
|
||||
catch (...) { /* ignore */ }
|
||||
}
|
||||
|
||||
bool start_outer_call()
|
||||
|
||||
@@ -106,7 +106,8 @@ namespace net_utils
|
||||
~blocked_mode_client()
|
||||
{
|
||||
//profile_tools::local_coast lc("~blocked_mode_client()", 3);
|
||||
shutdown();
|
||||
try { shutdown(); }
|
||||
catch(...) { /* ignore */ }
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
@@ -137,7 +137,12 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s
|
||||
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
|
||||
el::Helpers::installPreRollOutCallback([filename_base, max_log_files](const char *name, size_t){
|
||||
std::string rname = generate_log_filename(filename_base.c_str());
|
||||
rename(name, rname.c_str());
|
||||
int ret = rename(name, rname.c_str());
|
||||
if (ret < 0)
|
||||
{
|
||||
// can't log a failure, but don't do the file removal below
|
||||
return;
|
||||
}
|
||||
if (max_log_files != 0)
|
||||
{
|
||||
std::vector<boost::filesystem::path> found_files;
|
||||
|
||||
+2
-2
@@ -1975,11 +1975,11 @@ void VRegistry::setCategories(const char* categories, bool clear) {
|
||||
m_cached_allowed_categories.clear();
|
||||
m_categoriesString.clear();
|
||||
}
|
||||
if (!categories)
|
||||
return;
|
||||
if (!m_categoriesString.empty())
|
||||
m_categoriesString += ",";
|
||||
m_categoriesString += categories;
|
||||
if (!categories)
|
||||
return;
|
||||
|
||||
bool isCat = true;
|
||||
bool isLevel = false;
|
||||
|
||||
Vendored
+1
-1
Submodule external/unbound updated: d3724dfa55...7f23967954
@@ -1145,7 +1145,10 @@ BlockchainLMDB::~BlockchainLMDB()
|
||||
|
||||
// batch transaction shouldn't be active at this point. If it is, consider it aborted.
|
||||
if (m_batch_active)
|
||||
batch_abort();
|
||||
{
|
||||
try { batch_abort(); }
|
||||
catch (...) { /* ignore */ }
|
||||
}
|
||||
if (m_open)
|
||||
close();
|
||||
}
|
||||
@@ -3589,7 +3592,9 @@ void BlockchainLMDB::migrate_0_1()
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for block_heights: ", result).c_str()));
|
||||
if (!i) {
|
||||
MDB_stat ms;
|
||||
mdb_stat(txn, m_block_heights, &ms);
|
||||
result = mdb_stat(txn, m_block_heights, &ms);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to query block_heights table: ", result).c_str()));
|
||||
i = ms.ms_entries;
|
||||
}
|
||||
}
|
||||
@@ -3692,7 +3697,9 @@ void BlockchainLMDB::migrate_0_1()
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for block_timestamps: ", result).c_str()));
|
||||
if (!i) {
|
||||
MDB_stat ms;
|
||||
mdb_stat(txn, m_block_info, &ms);
|
||||
result = mdb_stat(txn, m_block_info, &ms);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to query block_info table: ", result).c_str()));
|
||||
i = ms.ms_entries;
|
||||
}
|
||||
}
|
||||
@@ -3812,7 +3819,9 @@ void BlockchainLMDB::migrate_0_1()
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for spent_keys: ", result).c_str()));
|
||||
if (!i) {
|
||||
MDB_stat ms;
|
||||
mdb_stat(txn, m_hf_versions, &ms);
|
||||
result = mdb_stat(txn, m_hf_versions, &ms);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to query hf_versions table: ", result).c_str()));
|
||||
i = ms.ms_entries;
|
||||
}
|
||||
}
|
||||
@@ -3967,7 +3976,9 @@ void BlockchainLMDB::migrate_0_1()
|
||||
throw0(DB_ERROR(lmdb_error("Failed to open a cursor for txs: ", result).c_str()));
|
||||
if (!i) {
|
||||
MDB_stat ms;
|
||||
mdb_stat(txn, m_txs, &ms);
|
||||
result = mdb_stat(txn, m_txs, &ms);
|
||||
if (result)
|
||||
throw0(DB_ERROR(lmdb_error("Failed to query txs table: ", result).c_str()));
|
||||
i = ms.ms_entries;
|
||||
if (i) {
|
||||
MDB_val_set(pk, "txblk");
|
||||
|
||||
@@ -32,6 +32,8 @@ if(PER_BLOCK_CHECKPOINT)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} --target=x86_64-apple-darwin11 -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*)
|
||||
elseif(APPLE AND NOT DEPENDS)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*)
|
||||
elseif(LINUX_32)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat)
|
||||
else()
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat)
|
||||
endif()
|
||||
|
||||
@@ -401,7 +401,8 @@ static bool for_all_transactions(const std::string &filename, uint64_t &start_id
|
||||
}
|
||||
|
||||
mdb_cursor_close(cur);
|
||||
mdb_txn_commit(txn);
|
||||
dbr = mdb_txn_commit(txn);
|
||||
if (dbr) throw std::runtime_error("Failed to commit db transaction: " + std::string(mdb_strerror(dbr)));
|
||||
tx_active = false;
|
||||
mdb_dbi_close(env, dbi);
|
||||
mdb_env_close(env);
|
||||
@@ -471,7 +472,8 @@ static uint64_t find_first_diverging_transaction(const std::string &first_filena
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
mdb_cursor_close(cur[i]);
|
||||
mdb_txn_commit(txn[i]);
|
||||
dbr = mdb_txn_commit(txn[i]);
|
||||
if (dbr) throw std::runtime_error("Failed to query transaction: " + std::string(mdb_strerror(dbr)));
|
||||
tx_active[i] = false;
|
||||
mdb_dbi_close(env[i], dbi[i]);
|
||||
mdb_env_close(env[i]);
|
||||
@@ -675,7 +677,7 @@ static uint64_t get_ring_subset_instances(MDB_txn *txn, uint64_t amount, const s
|
||||
uint64_t extra = 0;
|
||||
std::vector<uint64_t> subset;
|
||||
subset.reserve(ring.size());
|
||||
for (uint64_t mask = 1; mask < (1u << ring.size()) - 1; ++mask)
|
||||
for (uint64_t mask = 1; mask < (((uint64_t)1) << ring.size()) - 1; ++mask)
|
||||
{
|
||||
subset.resize(0);
|
||||
for (size_t i = 0; i < ring.size(); ++i)
|
||||
|
||||
@@ -30,9 +30,15 @@ if(APPLE)
|
||||
add_library(blocks STATIC blockexports.c)
|
||||
set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C)
|
||||
else()
|
||||
add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat)
|
||||
add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat)
|
||||
add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat)
|
||||
if(LINUX_32)
|
||||
add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat)
|
||||
add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat)
|
||||
add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat)
|
||||
else()
|
||||
add_custom_command(OUTPUT blocks.o MAIN_DEPENDENCY blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat)
|
||||
add_custom_command(OUTPUT testnet_blocks.o MAIN_DEPENDENCY testnet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/testnet_blocks.o testnet_blocks.dat)
|
||||
add_custom_command(OUTPUT stagenet_blocks.o MAIN_DEPENDENCY stagenet_blocks.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/stagenet_blocks.o stagenet_blocks.dat)
|
||||
endif()
|
||||
add_library(blocks STATIC blocks.o testnet_blocks.o stagenet_blocks.o blockexports.c)
|
||||
set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C)
|
||||
endif()
|
||||
|
||||
@@ -37,8 +37,10 @@ set(common_sources
|
||||
expect.cpp
|
||||
util.cpp
|
||||
i18n.cpp
|
||||
notify.cpp
|
||||
password.cpp
|
||||
perf_timer.cpp
|
||||
spawn.cpp
|
||||
threadpool.cpp
|
||||
updates.cpp
|
||||
aligned.c)
|
||||
@@ -61,6 +63,7 @@ set(common_private_headers
|
||||
expect.h
|
||||
http_connection.h
|
||||
int-util.h
|
||||
notify.h
|
||||
pod-class.h
|
||||
rpc_client.h
|
||||
scoped_message_writer.h
|
||||
@@ -70,6 +73,7 @@ set(common_private_headers
|
||||
i18n.h
|
||||
password.h
|
||||
perf_timer.h
|
||||
spawn.h
|
||||
stack_trace.h
|
||||
threadpool.h
|
||||
updates.h
|
||||
|
||||
@@ -46,10 +46,11 @@ namespace bf = boost::filesystem;
|
||||
static const char *DEFAULT_DNS_PUBLIC_ADDR[] =
|
||||
{
|
||||
"194.150.168.168", // CCC (Germany)
|
||||
"81.3.27.54", // Lightning Wire Labs (Germany)
|
||||
"31.3.135.232", // OpenNIC (Switzerland)
|
||||
"80.67.169.40", // FDN (France)
|
||||
"209.58.179.186", // Cyberghost (Singapore)
|
||||
"89.233.43.71", // http://censurfridns.dk (Denmark)
|
||||
"109.69.8.51", // punCAT (Spain)
|
||||
"77.109.148.137", // Xiala.net (Switzerland)
|
||||
"193.58.251.251", // SkyDNS (Russia)
|
||||
};
|
||||
|
||||
static boost::mutex instance_lock;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2018, 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 <boost/algorithm/string.hpp>
|
||||
#include "misc_log_ex.h"
|
||||
#include "file_io_utils.h"
|
||||
#include "spawn.h"
|
||||
#include "notify.h"
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
/*
|
||||
TODO:
|
||||
- Improve tokenization to handle paths containing whitespaces, quotes, etc.
|
||||
- Windows unicode support (implies implementing unicode command line parsing code)
|
||||
*/
|
||||
Notify::Notify(const char *spec)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(spec, "Null spec");
|
||||
|
||||
boost::split(args, spec, boost::is_any_of(" "));
|
||||
CHECK_AND_ASSERT_THROW_MES(args.size() > 0, "Failed to parse spec");
|
||||
filename = args[0];
|
||||
CHECK_AND_ASSERT_THROW_MES(epee::file_io_utils::is_file_exist(filename), "File not found: " << filename);
|
||||
}
|
||||
|
||||
int Notify::notify(const char *parameter)
|
||||
{
|
||||
std::vector<std::string> margs = args;
|
||||
for (std::string &s: margs)
|
||||
boost::replace_all(s, "%s", parameter);
|
||||
|
||||
return tools::spawn(filename.c_str(), margs, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2018, 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
class Notify
|
||||
{
|
||||
public:
|
||||
Notify(const char *spec);
|
||||
|
||||
int notify(const char *parameter);
|
||||
|
||||
private:
|
||||
std::string filename;
|
||||
std::vector<std::string> args;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -221,6 +221,10 @@ namespace tools
|
||||
: m_password(std::move(password))
|
||||
{
|
||||
}
|
||||
password_container::password_container(const epee::wipeable_string& password) noexcept
|
||||
: m_password(password)
|
||||
{
|
||||
}
|
||||
|
||||
password_container::~password_container() noexcept
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace tools
|
||||
|
||||
//! `password` is used as password
|
||||
password_container(std::string&& password) noexcept;
|
||||
password_container(const epee::wipeable_string& password) noexcept;
|
||||
|
||||
//! \return A password from stdin TTY prompt or `std::cin` pipe.
|
||||
static boost::optional<password_container> prompt(bool verify, const char *mesage = "Password", bool hide_input = true);
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// Copyright (c) 2018, 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 <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/scope_exit.hpp>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#include "misc_log_ex.h"
|
||||
#include "spawn.h"
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
int spawn(const char *filename, const std::vector<std::string>& args, bool wait)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string joined = boost::algorithm::join(args, " ");
|
||||
char *commandLine = !joined.empty() ? &joined[0] : nullptr;
|
||||
STARTUPINFOA si = {};
|
||||
si.cb = sizeof(si);
|
||||
PROCESS_INFORMATION pi;
|
||||
if (!CreateProcessA(filename, commandLine, nullptr, nullptr, false, 0, nullptr, nullptr, &si, &pi))
|
||||
{
|
||||
MERROR("CreateProcess failed. Error code " << GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOST_SCOPE_EXIT(&pi)
|
||||
{
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
BOOST_SCOPE_EXIT_END
|
||||
|
||||
if (!wait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD result = WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
if (result != WAIT_OBJECT_0)
|
||||
{
|
||||
MERROR("WaitForSingleObject failed. Result " << result << ", error code " << GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
DWORD exitCode;
|
||||
if (!GetExitCodeProcess(pi.hProcess, &exitCode))
|
||||
{
|
||||
MERROR("GetExitCodeProcess failed. Error code " << GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
MINFO("Child exited with " << exitCode);
|
||||
return static_cast<int>(exitCode);
|
||||
#else
|
||||
char **argv = (char**)alloca(sizeof(char*) * (args.size() + 1));
|
||||
for (size_t n = 0; n < args.size(); ++n)
|
||||
argv[n] = (char*)args[n].c_str();
|
||||
argv[args.size()] = NULL;
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
MERROR("Error forking: " << strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// child
|
||||
if (pid == 0)
|
||||
{
|
||||
char *envp[] = {NULL};
|
||||
execve(filename, argv, envp);
|
||||
MERROR("Failed to execve: " << strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// parent
|
||||
if (pid > 0)
|
||||
{
|
||||
if (!wait)
|
||||
return 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int wstatus = 0;
|
||||
pid_t w = waitpid(pid, &wstatus, WUNTRACED | WCONTINUED);
|
||||
if (w < 0) {
|
||||
MERROR("Error waiting for child: " << strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (WIFEXITED(wstatus))
|
||||
{
|
||||
MINFO("Child exited with " << WEXITSTATUS(wstatus));
|
||||
return WEXITSTATUS(wstatus);
|
||||
}
|
||||
if (WIFSIGNALED(wstatus))
|
||||
{
|
||||
MINFO("Child killed by " << WEXITSTATUS(wstatus));
|
||||
return WEXITSTATUS(wstatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
MERROR("Secret passage found");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2018, 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
int spawn(const char *filename, const std::vector<std::string>& args, bool wait);
|
||||
|
||||
}
|
||||
@@ -57,7 +57,8 @@ threadpool::~threadpool() {
|
||||
has_work.notify_all();
|
||||
}
|
||||
for (size_t i = 0; i<threads.size(); i++) {
|
||||
threads[i].join();
|
||||
try { threads[i].join(); }
|
||||
catch (...) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ namespace cryptonote
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
miner::~miner()
|
||||
{
|
||||
stop();
|
||||
try { stop(); }
|
||||
catch (...) { /* ignore */ }
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height)
|
||||
@@ -198,8 +199,9 @@ namespace cryptonote
|
||||
{
|
||||
uint64_t total_hr = std::accumulate(m_last_hash_rates.begin(), m_last_hash_rates.end(), 0);
|
||||
float hr = static_cast<float>(total_hr)/static_cast<float>(m_last_hash_rates.size());
|
||||
const auto flags = std::cout.flags();
|
||||
const auto precision = std::cout.precision();
|
||||
std::cout << "hashrate: " << std::setprecision(4) << std::fixed << hr << precision << ENDL;
|
||||
std::cout << "hashrate: " << std::setprecision(4) << std::fixed << hr << flags << precision << ENDL;
|
||||
}
|
||||
}
|
||||
m_last_hr_merge_time = misc_utils::get_tick_count();
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "cryptonote_core.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "common/perf_timer.h"
|
||||
#include "common/notify.h"
|
||||
#if defined(PER_BLOCK_CHECKPOINT)
|
||||
#include "blocks/blocks.h"
|
||||
#endif
|
||||
@@ -137,8 +138,8 @@ static const struct {
|
||||
|
||||
{ 6, 971400, 0, 1501709789 },
|
||||
{ 7, 1057027, 0, 1512211236 },
|
||||
{ 8, 1057058, 0, 1515967497 },
|
||||
{ 9, 1057778, 0, 1515967498 },
|
||||
{ 8, 1057058, 0, 1533211200 },
|
||||
{ 9, 1057778, 0, 1533297600 },
|
||||
};
|
||||
static const uint64_t testnet_hard_fork_version_1_till = 624633;
|
||||
|
||||
@@ -3552,6 +3553,10 @@ leave:
|
||||
get_difficulty_for_next_block(); // just to cache it
|
||||
invalidate_block_template_cache();
|
||||
|
||||
std::shared_ptr<tools::Notify> block_notify = m_block_notify;
|
||||
if (block_notify)
|
||||
block_notify->notify(epee::string_tools::pod_to_hex(id).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
#include "cryptonote_basic/hardfork.h"
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
|
||||
namespace tools { class Notify; }
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
class tx_memory_pool;
|
||||
@@ -705,6 +707,13 @@ namespace cryptonote
|
||||
void set_user_options(uint64_t maxthreads, bool sync_on_blocks, uint64_t sync_threshold,
|
||||
blockchain_db_sync_mode sync_mode, bool fast_sync);
|
||||
|
||||
/**
|
||||
* @brief sets a block notify object to call for every new block
|
||||
*
|
||||
* @param notify the notify object to cal at every new block
|
||||
*/
|
||||
void set_block_notify(const std::shared_ptr<tools::Notify> ¬ify) { m_block_notify = notify; }
|
||||
|
||||
/**
|
||||
* @brief Put DB in safe sync mode
|
||||
*/
|
||||
@@ -1032,6 +1041,8 @@ namespace cryptonote
|
||||
uint64_t m_btc_expected_reward;
|
||||
bool m_btc_valid;
|
||||
|
||||
std::shared_ptr<tools::Notify> m_block_notify;
|
||||
|
||||
/**
|
||||
* @brief collects the keys for all outputs being "spent" as an input
|
||||
*
|
||||
|
||||
@@ -53,6 +53,7 @@ using namespace epee;
|
||||
#include "ringct/rctTypes.h"
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "common/notify.h"
|
||||
#include "version.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
@@ -167,6 +168,11 @@ namespace cryptonote
|
||||
, "Set maximum txpool weight in bytes."
|
||||
, DEFAULT_TXPOOL_MAX_WEIGHT
|
||||
};
|
||||
static const command_line::arg_descriptor<std::string> arg_block_notify = {
|
||||
"block-notify"
|
||||
, "Run a program for each new block, '%s' will be replaced by the block hash"
|
||||
, ""
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
core::core(i_cryptonote_protocol* pprotocol):
|
||||
@@ -276,6 +282,7 @@ namespace cryptonote
|
||||
command_line::add_arg(desc, arg_offline);
|
||||
command_line::add_arg(desc, arg_disable_dns_checkpoints);
|
||||
command_line::add_arg(desc, arg_max_txpool_weight);
|
||||
command_line::add_arg(desc, arg_block_notify);
|
||||
|
||||
miner::init_options(desc);
|
||||
BlockchainDB::init_options(desc);
|
||||
@@ -545,6 +552,16 @@ namespace cryptonote
|
||||
m_blockchain_storage.set_user_options(blocks_threads,
|
||||
sync_on_blocks, sync_threshold, sync_mode, fast_sync);
|
||||
|
||||
try
|
||||
{
|
||||
if (!command_line::is_arg_defaulted(vm, arg_block_notify))
|
||||
m_blockchain_storage.set_block_notify(std::shared_ptr<tools::Notify>(new tools::Notify(command_line::get_arg(vm, arg_block_notify).c_str())));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
MERROR("Failed to parse block notify spec");
|
||||
}
|
||||
|
||||
const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)};
|
||||
const cryptonote::test_options regtest_test_options = {
|
||||
regtest_hard_forks
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace cryptonote
|
||||
out_amounts[1] += out_amounts[0];
|
||||
for (size_t n = 1; n < out_amounts.size(); ++n)
|
||||
out_amounts[n - 1] = out_amounts[n];
|
||||
out_amounts.resize(out_amounts.size() - 1);
|
||||
out_amounts.pop_back();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -32,6 +32,8 @@ if(PER_BLOCK_CHECKPOINT)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} --target=x86_64-apple-darwin11 -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*)
|
||||
elseif(APPLE AND NOT DEPENDS)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && touch stub.c && ${CMAKE_C_COMPILER} -o stub.o -c stub.c COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -sectcreate __DATA __blocks_dat ../blocks/checkpoints.dat -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o stub.o && rm -f stub.*)
|
||||
elseif(LINUX_32)
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} -m elf_i386 ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat)
|
||||
else()
|
||||
add_custom_command(OUTPUT blocksdat.o MAIN_DEPENDENCY ../blocks/checkpoints.dat COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ../blocks/checkpoints.dat blocks.dat && ${CMAKE_LINKER} ${LD_RAW_FLAGS} -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocksdat.o blocks.dat && rm -f blocks.dat)
|
||||
endif()
|
||||
|
||||
@@ -442,7 +442,8 @@ bool t_rpc_command_executor::show_status() {
|
||||
}
|
||||
}
|
||||
|
||||
tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us")
|
||||
std::stringstream str;
|
||||
str << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections")
|
||||
% (unsigned long long)ires.height
|
||||
% (unsigned long long)net_height
|
||||
% get_sync_percentage(ires)
|
||||
@@ -455,12 +456,21 @@ bool t_rpc_command_executor::show_status() {
|
||||
% (hfres.state == cryptonote::HardFork::Ready ? "up to date" : hfres.state == cryptonote::HardFork::UpdateNeeded ? "update needed" : "out of date, likely forked")
|
||||
% (unsigned)ires.outgoing_connections_count
|
||||
% (unsigned)ires.incoming_connections_count
|
||||
% (unsigned int)floor(uptime / 60.0 / 60.0 / 24.0)
|
||||
% (unsigned int)floor(fmod((uptime / 60.0 / 60.0), 24.0))
|
||||
% (unsigned int)floor(fmod((uptime / 60.0), 60.0))
|
||||
% (unsigned int)fmod(uptime, 60.0)
|
||||
;
|
||||
|
||||
// restricted RPC does not disclose start time
|
||||
if (ires.start_time)
|
||||
{
|
||||
str << boost::format(", uptime %ud %uh %um %us")
|
||||
% (unsigned int)floor(uptime / 60.0 / 60.0 / 24.0)
|
||||
% (unsigned int)floor(fmod((uptime / 60.0 / 60.0), 24.0))
|
||||
% (unsigned int)floor(fmod((uptime / 60.0), 60.0))
|
||||
% (unsigned int)fmod(uptime, 60.0)
|
||||
;
|
||||
}
|
||||
|
||||
tools::success_msg_writer() << str.str();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,8 @@ static bool generate_multisig(uint32_t threshold, uint32_t total, const std::str
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
po::options_description desc_params(wallet_args::tr("Wallet options"));
|
||||
command_line::add_arg(desc_params, arg_filename_base);
|
||||
command_line::add_arg(desc_params, arg_scheme);
|
||||
@@ -254,5 +256,5 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
//CATCH_ENTRY_L0("main", 1);
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
}
|
||||
|
||||
@@ -3275,7 +3275,9 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet = tools::wallet2::make_from_json(vm, false, m_generate_from_json, password_prompter);
|
||||
auto rc = tools::wallet2::make_from_json(vm, false, m_generate_from_json, password_prompter);
|
||||
m_wallet = std::move(rc.first);
|
||||
password = rc.second.password();
|
||||
m_wallet_file = m_wallet->path();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
@@ -8073,6 +8075,8 @@ void simple_wallet::commit_or_save(std::vector<tools::wallet2::pending_tx>& ptx_
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
#ifdef WIN32
|
||||
// Activate UTF-8 support for Boost filesystem classes on Windows
|
||||
std::locale::global(boost::locale::generator().generate(""));
|
||||
@@ -8167,5 +8171,5 @@ int main(int argc, char* argv[])
|
||||
w.deinit();
|
||||
}
|
||||
return 0;
|
||||
//CATCH_ENTRY_L0("main", 1);
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ bool WalletImpl::recoverFromKeysWithPassword(const std::string &path,
|
||||
LOG_PRINT_L1("Generated new view only wallet from keys");
|
||||
}
|
||||
if(has_spendkey && !has_viewkey) {
|
||||
m_wallet->generate(path, password, spendkey, true, false, false);
|
||||
m_wallet->generate(path, password, spendkey, true, false);
|
||||
setSeedLanguage(language);
|
||||
LOG_PRINT_L1("Generated deterministic wallet from spend key with seed language: " + language);
|
||||
}
|
||||
@@ -623,7 +623,7 @@ bool WalletImpl::recoverFromDevice(const std::string &path, const std::string &p
|
||||
m_recoveringFromDevice = true;
|
||||
try
|
||||
{
|
||||
m_wallet->restore(path, password, device_name, false);
|
||||
m_wallet->restore(path, password, device_name);
|
||||
LOG_PRINT_L1("Generated new wallet from device: " + device_name);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -2146,6 +2146,28 @@ bool WalletImpl::blackballOutputs(const std::vector<std::string> &outputs, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalletImpl::blackballOutput(const std::string &amount, const std::string &offset)
|
||||
{
|
||||
uint64_t raw_amount, raw_offset;
|
||||
if (!epee::string_tools::get_xtype_from_string(raw_amount, amount))
|
||||
{
|
||||
setStatusError(tr("Failed to parse output amount"));
|
||||
return false;
|
||||
}
|
||||
if (!epee::string_tools::get_xtype_from_string(raw_offset, offset))
|
||||
{
|
||||
setStatusError(tr("Failed to parse output offset"));
|
||||
return false;
|
||||
}
|
||||
bool ret = m_wallet->blackball_output(std::make_pair(raw_amount, raw_offset));
|
||||
if (!ret)
|
||||
{
|
||||
setStatusError(tr("Failed to blackball output"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalletImpl::unblackballOutput(const std::string &amount, const std::string &offset)
|
||||
{
|
||||
uint64_t raw_amount, raw_offset;
|
||||
|
||||
@@ -182,7 +182,8 @@ public:
|
||||
virtual std::string getDefaultDataDir() const override;
|
||||
virtual bool lightWalletLogin(bool &isNewWallet) const override;
|
||||
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override;
|
||||
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) override;
|
||||
virtual bool blackballOutputs(const std::vector<std::string> &outputs, bool add) override;
|
||||
virtual bool blackballOutput(const std::string &amount, const std::string &offset) override;
|
||||
virtual bool unblackballOutput(const std::string &amount, const std::string &offset) override;
|
||||
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const override;
|
||||
virtual bool getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) const override;
|
||||
|
||||
@@ -881,7 +881,10 @@ struct Wallet
|
||||
virtual bool rescanSpent() = 0;
|
||||
|
||||
//! blackballs a set of outputs
|
||||
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add) = 0;
|
||||
virtual bool blackballOutputs(const std::vector<std::string> &outputs, bool add) = 0;
|
||||
|
||||
//! blackballs an output
|
||||
virtual bool blackballOutput(const std::string &amount, const std::string &offset) = 0;
|
||||
|
||||
//! unblackballs an output
|
||||
virtual bool unblackballOutput(const std::string &amount, const std::string &offset) = 0;
|
||||
|
||||
+48
-8
@@ -66,6 +66,7 @@ using namespace epee;
|
||||
#include "memwipe.h"
|
||||
#include "common/base58.h"
|
||||
#include "common/dns_utils.h"
|
||||
#include "common/notify.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
#include "ringdb.h"
|
||||
|
||||
@@ -162,6 +163,7 @@ struct options {
|
||||
};
|
||||
const command_line::arg_descriptor<uint64_t> kdf_rounds = {"kdf-rounds", tools::wallet2::tr("Number of rounds for the key derivation function"), 1};
|
||||
const command_line::arg_descriptor<std::string> hw_device = {"hw-device", tools::wallet2::tr("HW device to use"), ""};
|
||||
const command_line::arg_descriptor<std::string> tx_notify = { "tx-notify" , "Run a program for each new incoming transaction, '%s' will be replaced by the transaction hash" , "" };
|
||||
};
|
||||
|
||||
void do_prepare_file_names(const std::string& file_path, std::string& keys_file, std::string& wallet_file)
|
||||
@@ -268,6 +270,17 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
|
||||
boost::filesystem::path ringdb_path = command_line::get_arg(vm, opts.shared_ringdb_dir);
|
||||
wallet->set_ring_database(ringdb_path.string());
|
||||
wallet->device_name(device_name);
|
||||
|
||||
try
|
||||
{
|
||||
if (!command_line::is_arg_defaulted(vm, opts.tx_notify))
|
||||
wallet->set_tx_notify(std::shared_ptr<tools::Notify>(new tools::Notify(command_line::get_arg(vm, opts.tx_notify).c_str())));
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
MERROR("Failed to parse tx notify spec");
|
||||
}
|
||||
|
||||
return wallet;
|
||||
}
|
||||
|
||||
@@ -300,7 +313,7 @@ boost::optional<tools::password_container> get_password(const boost::program_opt
|
||||
return password_prompter(verify ? tr("Enter a new password for the wallet") : tr("Wallet password"), verify);
|
||||
}
|
||||
|
||||
std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file, const boost::program_options::variables_map& vm, bool unattended, const options& opts, const std::function<boost::optional<tools::password_container>(const char *, bool)> &password_prompter)
|
||||
std::pair<std::unique_ptr<tools::wallet2>, tools::password_container> generate_from_json(const std::string& json_file, const boost::program_options::variables_map& vm, bool unattended, const options& opts, const std::function<boost::optional<tools::password_container>(const char *, bool)> &password_prompter)
|
||||
{
|
||||
const bool testnet = command_line::get_arg(vm, opts.testnet);
|
||||
const bool stagenet = command_line::get_arg(vm, opts.stagenet);
|
||||
@@ -310,6 +323,7 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
|
||||
false. Gcc will coerce this into unique_ptr(nullptr), but clang correctly
|
||||
fails. This large wrapper is for the use of that macro */
|
||||
std::unique_ptr<tools::wallet2> wallet;
|
||||
epee::wipeable_string password;
|
||||
const auto do_generate = [&]() -> bool {
|
||||
std::string buf;
|
||||
if (!epee::file_io_utils::load_file_to_string(json_file, buf)) {
|
||||
@@ -447,10 +461,12 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
|
||||
if (!field_seed.empty())
|
||||
{
|
||||
wallet->generate(field_filename, field_password, recovery_key, recover, false, create_address_file);
|
||||
password = field_password;
|
||||
}
|
||||
else if (field_viewkey.empty() && !field_spendkey.empty())
|
||||
{
|
||||
wallet->generate(field_filename, field_password, spendkey, recover, false, create_address_file);
|
||||
password = field_password;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,6 +493,7 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
|
||||
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("Address must be specified in order to create watch-only wallet"));
|
||||
}
|
||||
wallet->generate(field_filename, field_password, address, viewkey, create_address_file);
|
||||
password = field_password;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -484,6 +501,7 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
|
||||
THROW_WALLET_EXCEPTION(tools::error::wallet_internal_error, tools::wallet2::tr("failed to verify spend key secret key"));
|
||||
}
|
||||
wallet->generate(field_filename, field_password, address, spendkey, viewkey, create_address_file);
|
||||
password = field_password;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,9 +514,9 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file,
|
||||
|
||||
if (do_generate())
|
||||
{
|
||||
return wallet;
|
||||
return {std::move(wallet), tools::password_container(password)};
|
||||
}
|
||||
return nullptr;
|
||||
return {nullptr, tools::password_container{}};
|
||||
}
|
||||
|
||||
static void throw_on_rpc_response_error(const boost::optional<std::string> &status, const char *method)
|
||||
@@ -838,9 +856,10 @@ void wallet2::init_options(boost::program_options::options_description& desc_par
|
||||
command_line::add_arg(desc_params, opts.shared_ringdb_dir);
|
||||
command_line::add_arg(desc_params, opts.kdf_rounds);
|
||||
command_line::add_arg(desc_params, opts.hw_device);
|
||||
command_line::add_arg(desc_params, opts.tx_notify);
|
||||
}
|
||||
|
||||
std::unique_ptr<wallet2> wallet2::make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<tools::password_container>(const char *, bool)> &password_prompter)
|
||||
std::pair<std::unique_ptr<wallet2>, tools::password_container> wallet2::make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<tools::password_container>(const char *, bool)> &password_prompter)
|
||||
{
|
||||
const options opts{};
|
||||
return generate_from_json(json_file, vm, unattended, opts, password_prompter);
|
||||
@@ -1325,9 +1344,9 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
// (that is, the prunable stuff may or may not be included)
|
||||
if (!miner_tx && !pool)
|
||||
process_unconfirmed(txid, tx, height);
|
||||
std::vector<size_t> outs;
|
||||
std::unordered_map<cryptonote::subaddress_index, uint64_t> tx_money_got_in_outs; // per receiving subaddress index
|
||||
crypto::public_key tx_pub_key = null_pkey;
|
||||
bool notify = false;
|
||||
|
||||
std::vector<tx_extra_field> local_tx_extra_fields;
|
||||
if (tx_cache_data.tx_extra_fields.empty())
|
||||
@@ -1347,6 +1366,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
uint64_t total_received_1 = 0;
|
||||
while (!tx.vout.empty())
|
||||
{
|
||||
std::vector<size_t> outs;
|
||||
// if tx.vout is not empty, we loop through all tx pubkeys
|
||||
|
||||
tx_extra_pub_key pub_key_field;
|
||||
@@ -1567,6 +1587,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index);
|
||||
}
|
||||
total_received_1 += amount;
|
||||
notify = true;
|
||||
}
|
||||
else if (m_transfers[kit->second].m_spent || m_transfers[kit->second].amount() >= tx_scan_info[o].amount)
|
||||
{
|
||||
@@ -1634,6 +1655,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
m_callback->on_money_received(height, txid, tx, td.m_amount, td.m_subaddr_index);
|
||||
}
|
||||
total_received_1 += extra_amount;
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1707,10 +1729,14 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
}
|
||||
|
||||
// remove change sent to the spending subaddress account from the list of received funds
|
||||
uint64_t sub_change = 0;
|
||||
for (auto i = tx_money_got_in_outs.begin(); i != tx_money_got_in_outs.end();)
|
||||
{
|
||||
if (subaddr_account && i->first.major == *subaddr_account)
|
||||
{
|
||||
sub_change += i->second;
|
||||
i = tx_money_got_in_outs.erase(i);
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
@@ -1755,7 +1781,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t total_received_2 = 0;
|
||||
uint64_t total_received_2 = sub_change;
|
||||
for (const auto& i : tx_money_got_in_outs)
|
||||
total_received_2 += i.second;
|
||||
if (total_received_1 != total_received_2)
|
||||
@@ -1790,6 +1816,13 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
LOG_PRINT_L2("Payment found in " << (pool ? "pool" : "block") << ": " << payment_id << " / " << payment.m_tx_hash << " / " << payment.m_amount);
|
||||
}
|
||||
}
|
||||
|
||||
if (notify)
|
||||
{
|
||||
std::shared_ptr<tools::Notify> tx_notify = m_tx_notify;
|
||||
if (tx_notify)
|
||||
tx_notify->notify(epee::string_tools::pod_to_hex(txid).c_str());
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height)
|
||||
@@ -3282,9 +3315,16 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
|
||||
encrypted_secret_keys = field_encrypted_secret_keys;
|
||||
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, device_name, std::string, String, false, std::string());
|
||||
if (m_device_name.empty() && field_device_name_found)
|
||||
if (m_device_name.empty())
|
||||
{
|
||||
m_device_name = field_device_name;
|
||||
if (field_device_name_found)
|
||||
{
|
||||
m_device_name = field_device_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_device_name = m_key_device_type == hw::device::device_type::LEDGER ? "Ledger" : "default";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace tools
|
||||
{
|
||||
class ringdb;
|
||||
class wallet2;
|
||||
class Notify;
|
||||
|
||||
class wallet_keys_unlocker
|
||||
{
|
||||
@@ -176,7 +177,7 @@ namespace tools
|
||||
static void init_options(boost::program_options::options_description& desc_params);
|
||||
|
||||
//! Uses stdin and stdout. Returns a wallet2 if no errors.
|
||||
static std::unique_ptr<wallet2> make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
|
||||
static std::pair<std::unique_ptr<wallet2>, password_container> make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
|
||||
|
||||
//! Uses stdin and stdout. Returns a wallet2 and password for `wallet_file` if no errors.
|
||||
static std::pair<std::unique_ptr<wallet2>, password_container>
|
||||
@@ -554,7 +555,7 @@ namespace tools
|
||||
* \param device_name name of HW to use
|
||||
* \param create_address_file Whether to create an address file
|
||||
*/
|
||||
void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file);
|
||||
void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false);
|
||||
|
||||
/*!
|
||||
* \brief Creates a multisig wallet
|
||||
@@ -1176,6 +1177,8 @@ namespace tools
|
||||
|
||||
void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
|
||||
|
||||
void set_tx_notify(const std::shared_ptr<tools::Notify> ¬ify) { m_tx_notify = notify; }
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief Stores wallet information to wallet file.
|
||||
@@ -1353,6 +1356,8 @@ namespace tools
|
||||
boost::optional<epee::wipeable_string> m_encrypt_keys_after_refresh;
|
||||
|
||||
bool m_unattended;
|
||||
|
||||
std::shared_ptr<tools::Notify> m_tx_notify;
|
||||
};
|
||||
}
|
||||
BOOST_CLASS_VERSION(tools::wallet2, 25)
|
||||
|
||||
@@ -2173,8 +2173,8 @@ namespace tools
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::payment_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) {
|
||||
if (i->second.m_tx_hash == txid)
|
||||
{
|
||||
fill_transfer_entry(res.transfer, i->second.m_tx_hash, i->first, i->second);
|
||||
return true;
|
||||
res.transfers.resize(res.transfers.size() + 1);
|
||||
fill_transfer_entry(res.transfers.back(), i->second.m_tx_hash, i->first, i->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2183,8 +2183,8 @@ namespace tools
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::const_iterator i = payments_out.begin(); i != payments_out.end(); ++i) {
|
||||
if (i->first == txid)
|
||||
{
|
||||
fill_transfer_entry(res.transfer, i->first, i->second);
|
||||
return true;
|
||||
res.transfers.resize(res.transfers.size() + 1);
|
||||
fill_transfer_entry(res.transfers.back(), i->first, i->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2193,8 +2193,8 @@ namespace tools
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) {
|
||||
if (i->first == txid)
|
||||
{
|
||||
fill_transfer_entry(res.transfer, i->first, i->second);
|
||||
return true;
|
||||
res.transfers.resize(res.transfers.size() + 1);
|
||||
fill_transfer_entry(res.transfers.back(), i->first, i->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2205,11 +2205,17 @@ namespace tools
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::pool_payment_details>>::const_iterator i = pool_payments.begin(); i != pool_payments.end(); ++i) {
|
||||
if (i->second.m_pd.m_tx_hash == txid)
|
||||
{
|
||||
fill_transfer_entry(res.transfer, i->first, i->second);
|
||||
return true;
|
||||
res.transfers.resize(res.transfers.size() + 1);
|
||||
fill_transfer_entry(res.transfers.back(), i->first, i->second);
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.transfers.empty())
|
||||
{
|
||||
res.transfer = res.transfers.front(); // backward compat
|
||||
return true;
|
||||
}
|
||||
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_TXID;
|
||||
er.message = "Transaction not found.";
|
||||
return false;
|
||||
@@ -3352,7 +3358,8 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
wal = tools::wallet2::make_from_json(vm, true, from_json, password_prompt);
|
||||
auto rc = tools::wallet2::make_from_json(vm, true, from_json, password_prompt);
|
||||
wal = std::move(rc.first);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
@@ -3457,6 +3464,8 @@ public:
|
||||
std::string const t_executor::NAME = "Wallet RPC Daemon";
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
TRY_ENTRY();
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
const auto arg_wallet_file = wallet_args::arg_wallet_file();
|
||||
@@ -3500,4 +3509,5 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
return daemonizer::daemonize(argc, const_cast<const char**>(argv), t_executor{}, *vm) ? 0 : 1;
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define WALLET_RPC_VERSION_MAJOR 1
|
||||
#define WALLET_RPC_VERSION_MINOR 3
|
||||
#define WALLET_RPC_VERSION_MINOR 4
|
||||
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
|
||||
namespace tools
|
||||
@@ -1399,9 +1399,11 @@ namespace wallet_rpc
|
||||
struct response
|
||||
{
|
||||
transfer_entry transfer;
|
||||
std::list<transfer_entry> transfers;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(transfer);
|
||||
KV_SERIALIZE(transfers);
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
@@ -46,6 +46,8 @@ static int __AFL_LOOP(int)
|
||||
|
||||
int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cout << "usage: " << argv[0] << " " << "<filename>" << std::endl;
|
||||
@@ -69,4 +71,6 @@ int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
CATCH_ENTRY_L0("run_fuzzer", 1);
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ int main(int argc, char** argv)
|
||||
const command_line::arg_descriptor<bool> arg_verbose = { "verbose", "Verbose output", false };
|
||||
const command_line::arg_descriptor<bool> arg_stats = { "stats", "Including statistics (min/median)", false };
|
||||
const command_line::arg_descriptor<unsigned> arg_loop_multiplier = { "loop-multiplier", "Run for that many times more loops", 1 };
|
||||
command_line::add_arg(desc_options, arg_filter, "");
|
||||
command_line::add_arg(desc_options, arg_verbose, "");
|
||||
command_line::add_arg(desc_options, arg_stats, "");
|
||||
command_line::add_arg(desc_options, arg_loop_multiplier, "");
|
||||
command_line::add_arg(desc_options, arg_filter);
|
||||
command_line::add_arg(desc_options, arg_verbose);
|
||||
command_line::add_arg(desc_options, arg_stats);
|
||||
command_line::add_arg(desc_options, arg_loop_multiplier);
|
||||
|
||||
po::variables_map vm;
|
||||
bool r = command_line::handle_error_helper(desc_options, [&]()
|
||||
|
||||
@@ -109,7 +109,7 @@ TEST(AddressFromURL, Failure)
|
||||
{
|
||||
bool dnssec_result = false;
|
||||
|
||||
std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("example.invalid", dnssec_result);
|
||||
std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("example.veryinvalid", dnssec_result);
|
||||
|
||||
// for a non-existing domain such as "example.invalid", the non-existence is proved with NSEC records
|
||||
ASSERT_TRUE(dnssec_result);
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace cryptonote { template class t_cryptonote_protocol_handler<cryptonote::
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
tools::on_startup();
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
mlog_configure(mlog_get_default_log_path("unit_tests.log"), true);
|
||||
@@ -76,5 +78,7 @@ int main(int argc, char** argv)
|
||||
|
||||
unit_test::data_dir = command_line::get_arg(vm, arg_data_dir);
|
||||
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ TEST(mlocker, distinct_1)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[8 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data), 1);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data) + 2 * page_size, 1);
|
||||
epee::mlocker *m2 = new epee::mlocker(BASE(data) + 3 * page_size, 1);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data), 1)};
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data) + 2 * page_size, 1)};
|
||||
std::shared_ptr<epee::mlocker> m2{new epee::mlocker(BASE(data) + 3 * page_size, 1)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 3);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 3);
|
||||
delete m0;
|
||||
delete m1;
|
||||
delete m2;
|
||||
m0 = NULL;
|
||||
m1 = NULL;
|
||||
m2 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -65,14 +65,14 @@ TEST(mlocker, distinct_full_page)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[8 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data), page_size);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data) + 2 * page_size, page_size);
|
||||
epee::mlocker *m2 = new epee::mlocker(BASE(data) + 3 * page_size, page_size);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data), page_size)};
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data) + 2 * page_size, page_size)};
|
||||
std::shared_ptr<epee::mlocker> m2{new epee::mlocker(BASE(data) + 3 * page_size, page_size)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 3);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 3);
|
||||
delete m0;
|
||||
delete m1;
|
||||
delete m2;
|
||||
m0 = NULL;
|
||||
m1 = NULL;
|
||||
m2 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -84,16 +84,16 @@ TEST(mlocker, identical)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[8 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data) + page_size, 32);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data) + page_size, 32);
|
||||
epee::mlocker *m2 = new epee::mlocker(BASE(data) + page_size, 32);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data) + page_size, 32)};
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data) + page_size, 32)};
|
||||
std::shared_ptr<epee::mlocker> m2{new epee::mlocker(BASE(data) + page_size, 32)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 3);
|
||||
delete m1;
|
||||
m1 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 2);
|
||||
delete m0;
|
||||
delete m2;
|
||||
m0 = NULL;
|
||||
m2 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -105,16 +105,16 @@ TEST(mlocker, overlapping_small)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[8 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data), 32);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data) + 16, 32);
|
||||
epee::mlocker *m2 = new epee::mlocker(BASE(data) + 8, 32);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data), 32)};
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data) + 16, 32)};
|
||||
std::shared_ptr<epee::mlocker> m2{new epee::mlocker(BASE(data) + 8, 32)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 3);
|
||||
delete m1;
|
||||
m1 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 2);
|
||||
delete m2;
|
||||
delete m0;
|
||||
m2 = NULL;
|
||||
m0 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -126,16 +126,16 @@ TEST(mlocker, multi_page)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[8 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data) + page_size, page_size * 3);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data) + page_size, page_size * 3)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 3);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 1);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data) + page_size * 7, page_size);
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data) + page_size * 7, page_size)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 4);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 2);
|
||||
delete m0;
|
||||
m0 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 1);
|
||||
delete m1;
|
||||
m1 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -147,10 +147,10 @@ TEST(mlocker, cross_page)
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[2 * page_size]};
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data) + page_size - 1, 2);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data) + page_size - 1, 2)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 2);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 1);
|
||||
delete m0;
|
||||
m0 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
@@ -158,21 +158,22 @@ TEST(mlocker, cross_page)
|
||||
TEST(mlocker, redundant)
|
||||
{
|
||||
const size_t page_size = epee::mlocker::get_page_size();
|
||||
ASSERT_TRUE(page_size > 0);
|
||||
const size_t base_pages = epee::mlocker::get_num_locked_pages();
|
||||
const size_t base_objects = epee::mlocker::get_num_locked_objects();
|
||||
std::unique_ptr<char[]> data{new char[2 * page_size]};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
epee::mlocker *m0 = new epee::mlocker(BASE(data), 32);
|
||||
std::shared_ptr<epee::mlocker> m0{new epee::mlocker(BASE(data), 32)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 1);
|
||||
epee::mlocker *m1 = new epee::mlocker(BASE(data), 32);
|
||||
std::shared_ptr<epee::mlocker> m1{new epee::mlocker(BASE(data), 32)};
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 2);
|
||||
delete m1;
|
||||
m1 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 1);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 1);
|
||||
delete m0;
|
||||
m0 = NULL;
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_pages(), base_pages + 0);
|
||||
ASSERT_EQ(epee::mlocker::get_num_locked_objects(), base_objects + 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user