forked from lthn/blockchain
Merge branch 'develop' into develop_mobile
This commit is contained in:
commit
d17571b972
56 changed files with 2253 additions and 180 deletions
|
|
@ -55,7 +55,7 @@ if(APPLE)
|
|||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10.5)
|
||||
endif()
|
||||
|
||||
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers for MSVC")
|
||||
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers")
|
||||
|
||||
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ Recommended OS version: Ubuntu 18.04 LTS.
|
|||
|
||||
3. Install Qt
|
||||
|
||||
wget https://download.qt.io/archive/qt/5.11/5.11.2/qt-opensource-linux-x64-5.11.2.run
|
||||
wget https://download.qt.io/new_archive/qt/5.11/5.11.2/qt-opensource-linux-x64-5.11.2.run
|
||||
chmod +x qt-opensource-linux-x64-5.11.2.run
|
||||
./qt-opensource-linux-x64-5.11.2.run
|
||||
Then follow the instructions in Wizard. Don't forget to tick WebEngine module!
|
||||
|
|
|
|||
|
|
@ -670,7 +670,9 @@ namespace log_space
|
|||
boost::filesystem::create_directories(m_default_log_path_w, ec);
|
||||
boost::filesystem::ofstream* pstream = new boost::filesystem::ofstream;
|
||||
|
||||
std::wstring target_path = m_default_log_path_w + L"/" + epee::string_encoding::utf8_to_wstring(pstream_name);
|
||||
std::wstring target_path = epee::string_encoding::utf8_to_wstring(pstream_name);
|
||||
if (!m_default_log_path_w.empty())
|
||||
target_path = m_default_log_path_w + L"/" + target_path;
|
||||
|
||||
pstream->open( target_path.c_str(), std::ios_base::out | std::ios::app /*ios_base::trunc */);
|
||||
if(pstream->fail())
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ bool connection<t_protocol_handler>::do_send(const void* ptr, size_t cb)
|
|||
|
||||
boost::asio::async_write(socket_, boost::asio::buffer(m_send_que.front().data(), m_send_que.front().size()),
|
||||
//strand_.wrap(
|
||||
boost::bind(&connection<t_protocol_handler>::handle_write, self, _1, _2)
|
||||
boost::bind(&connection<t_protocol_handler>::handle_write, self, boost::placeholders::_1, boost::placeholders::_2)
|
||||
//)
|
||||
);
|
||||
|
||||
|
|
@ -404,7 +404,7 @@ void connection<t_protocol_handler>::handle_write(const boost::system::error_cod
|
|||
//have more data to send
|
||||
boost::asio::async_write(socket_, boost::asio::buffer(m_send_que.front().data(), m_send_que.front().size()),
|
||||
//strand_.wrap(
|
||||
boost::bind(&connection<t_protocol_handler>::handle_write, connection<t_protocol_handler>::shared_from_this(), _1, _2));
|
||||
boost::bind(&connection<t_protocol_handler>::handle_write, connection<t_protocol_handler>::shared_from_this(), boost::placeholders::_1, boost::placeholders::_2));
|
||||
//);
|
||||
}
|
||||
CRITICAL_REGION_END();
|
||||
|
|
|
|||
|
|
@ -73,19 +73,6 @@ namespace epee
|
|||
gregexplock.get_lock().lock().unlock();\
|
||||
}
|
||||
|
||||
// #define STATIC_REGEXP_EXPR_2(var_name, xpr_text, reg_exp_flags) \
|
||||
// static volatile uint32_t regexp_initialized_2 = 0;\
|
||||
// volatile uint32_t local_is_initialized_2 = regexp_initialized_2;\
|
||||
// if(!local_is_initialized_2)\
|
||||
// gregexplock.get_lock().lock().lock();\
|
||||
// static const boost::regex var_name(xpr_text , reg_exp_flags);\
|
||||
// if(!local_is_initialized_2)\
|
||||
// {\
|
||||
// boost::interprocess::ipcdetail::atomic_write32(®exp_initialized_2, 1);\
|
||||
// gregexplock.get_lock().lock().unlock();\
|
||||
// }
|
||||
|
||||
|
||||
#define STATIC_REGEXP_EXPR_3(var_name, xpr_text, reg_exp_flags) \
|
||||
static volatile uint32_t regexp_initialized_3 = 0;\
|
||||
volatile uint32_t local_is_initialized_3 = regexp_initialized_3;\
|
||||
|
|
|
|||
|
|
@ -2,38 +2,52 @@
|
|||
# cmake_policy(SET CMP0043 OLD)
|
||||
# endif()
|
||||
|
||||
###########
|
||||
# using shared PCH -- this is unusual case for MSVC... so mystery, such hack, many wow. See also: https://stackoverflow.com/questions/645747/sharing-precompiled-headers-between-projects-in-visual-studio/4170902#4170902
|
||||
##### Precompiled Headers ######
|
||||
# define USE_PCH to YES for using precomiled headers
|
||||
|
||||
MACRO(INIT_SHARED_PCH pch_cpp_file)
|
||||
IF(MSVC AND USE_PCH)
|
||||
set_property(SOURCE ${pch_cpp_file} APPEND_STRING PROPERTY COMPILE_FLAGS " /Fo$(OutDir) /Z7 /Fd$(OutDir)vc$(PlatformToolsetVersion).pdb /Ycstdafx.h /Fp$(TargetDir)pch.pch")
|
||||
ENDIF(MSVC AND USE_PCH)
|
||||
# Windows: using custom-made shared PCH -- this is unusual case for MSVC... so mystery, such hack, many wow. See also: https://stackoverflow.com/questions/645747/sharing-precompiled-headers-between-projects-in-visual-studio/4170902#4170902
|
||||
# Linux: using CMake-enabled shared PCH (which appeared in CMake 3.16)
|
||||
MACRO(INIT_SHARED_PCH)
|
||||
IF(USE_PCH)
|
||||
MESSAGE( STATUS " ...... enabling precompiled headers, making new library: pch" )
|
||||
add_library(pch ${PCH})
|
||||
set(PCH_LIB_NAME pch)
|
||||
IF(MSVC)
|
||||
set_property(SOURCE "pch/stdafx.cpp" APPEND_STRING PROPERTY COMPILE_FLAGS " /Fo$(OutDir) /Z7 /Fd$(OutDir)vc$(PlatformToolsetVersion).pdb /Ycstdafx.h /Fp$(TargetDir)pch.pch")
|
||||
ELSEIF(APPLE OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_precompile_headers(pch PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pch/stdafx.h")
|
||||
ENDIF()
|
||||
ENDIF(USE_PCH)
|
||||
ENDMACRO(INIT_SHARED_PCH)
|
||||
|
||||
MACRO(ENABLE_SHARED_PCH sources_var)
|
||||
IF(MSVC AND USE_PCH)
|
||||
MESSAGE( STATUS " ...... enabling precompiled headers for: " ${sources_var} )
|
||||
SET(precompiled_binary "$(TargetDir)pch.pch")
|
||||
SET(precompiled_header "${CMAKE_CURRENT_SOURCE_DIR}/pch/stdafx.h")
|
||||
SET(sources ${${sources_var}})
|
||||
foreach(src ${sources})
|
||||
if(NOT ${src} MATCHES "\\.rc$") # skip *.rc files
|
||||
SET_SOURCE_FILES_PROPERTIES(${src}
|
||||
PROPERTIES COMPILE_FLAGS "/Z7 /Fd$(OutDir)vc$(PlatformToolsetVersion).pdb /Yu\"${precompiled_header}\" /FI\"${precompiled_header}\" /Fp\"${precompiled_binary}\""
|
||||
OBJECT_DEPENDS "${precompiled_binary}")
|
||||
endif()
|
||||
endforeach()
|
||||
ENDIF(MSVC AND USE_PCH)
|
||||
MACRO(ENABLE_SHARED_PCH target sources_var)
|
||||
IF(USE_PCH)
|
||||
IF(MSVC)
|
||||
MESSAGE( STATUS " ...... enabling precompiled headers for: " ${sources_var} )
|
||||
SET(precompiled_binary "$(TargetDir)pch.pch")
|
||||
SET(precompiled_header "${CMAKE_CURRENT_SOURCE_DIR}/pch/stdafx.h")
|
||||
SET(sources ${${sources_var}})
|
||||
foreach(src ${sources})
|
||||
if(NOT ${src} MATCHES "\\.rc$") # skip *.rc files
|
||||
SET_SOURCE_FILES_PROPERTIES(${src}
|
||||
PROPERTIES COMPILE_FLAGS "/Z7 /Fd$(OutDir)vc$(PlatformToolsetVersion).pdb /Yu\"${precompiled_header}\" /FI\"${precompiled_header}\" /Fp\"${precompiled_binary}\""
|
||||
OBJECT_DEPENDS "${precompiled_binary}")
|
||||
endif()
|
||||
endforeach()
|
||||
ELSEIF(APPLE OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
MESSAGE( STATUS " ...... enabling precompiled headers for: " ${target} )
|
||||
target_precompile_headers(${target} REUSE_FROM pch)
|
||||
ENDIF()
|
||||
ENDIF(USE_PCH)
|
||||
ENDMACRO(ENABLE_SHARED_PCH)
|
||||
|
||||
MACRO(ENABLE_SHARED_PCH_EXECUTABLE target)
|
||||
IF(MSVC AND USE_PCH)
|
||||
SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "$(OutDir)stdafx.obj")
|
||||
ENDIF(MSVC AND USE_PCH)
|
||||
IF(USE_PCH)
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "$(OutDir)stdafx.obj")
|
||||
ENDIF()
|
||||
ENDIF(USE_PCH)
|
||||
ENDMACRO(ENABLE_SHARED_PCH_EXECUTABLE)
|
||||
###########
|
||||
##### End of Precompiled Headers macros ######
|
||||
|
||||
|
||||
|
||||
|
|
@ -82,15 +96,11 @@ if(BUILD_GUI)
|
|||
endif()
|
||||
|
||||
|
||||
if (USE_PCH)
|
||||
add_library(pch ${PCH})
|
||||
set(PCH_LIB_NAME pch)
|
||||
endif()
|
||||
INIT_SHARED_PCH("pch/stdafx.cpp")
|
||||
INIT_SHARED_PCH()
|
||||
|
||||
add_library(common ${COMMON})
|
||||
add_dependencies(common version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(COMMON)
|
||||
ENABLE_SHARED_PCH(common COMMON)
|
||||
|
||||
if(NOT MSVC AND NOT APPLE AND NOT CLANG) # TODO(unassigned): do we really need the clang equivalent?
|
||||
target_compile_options(common PRIVATE -fno-var-tracking-assignments)
|
||||
|
|
@ -100,7 +110,7 @@ add_library(crypto ${CRYPTO})
|
|||
|
||||
add_library(currency_core ${CURRENCY_CORE})
|
||||
add_dependencies(currency_core version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(CURRENCY_CORE)
|
||||
ENABLE_SHARED_PCH(currency_core CURRENCY_CORE)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android" )
|
||||
add_library(wallet ${WALLET})
|
||||
|
|
@ -109,7 +119,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android" )
|
|||
else()
|
||||
add_library(wallet ${WALLET})
|
||||
add_dependencies(wallet version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(WALLET)
|
||||
ENABLE_SHARED_PCH(wallet WALLET)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
@ -129,11 +139,11 @@ endif()
|
|||
|
||||
add_library(rpc ${RPC})
|
||||
add_dependencies(rpc version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(RPC)
|
||||
ENABLE_SHARED_PCH(rpc RPC)
|
||||
|
||||
add_library(stratum ${STRATUM})
|
||||
add_dependencies(stratum version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(STRATUM)
|
||||
ENABLE_SHARED_PCH(stratum STRATUM)
|
||||
|
||||
|
||||
target_link_libraries(currency_core lmdb mdbx)
|
||||
|
|
@ -141,19 +151,19 @@ target_link_libraries(currency_core lmdb mdbx)
|
|||
add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL})
|
||||
add_dependencies(daemon version)
|
||||
target_link_libraries(daemon rpc stratum currency_core crypto common libminiupnpc-static zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
ENABLE_SHARED_PCH(DAEMON)
|
||||
ENABLE_SHARED_PCH(daemon DAEMON)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(daemon)
|
||||
|
||||
add_executable(connectivity_tool ${CONN_TOOL})
|
||||
add_dependencies(connectivity_tool version)
|
||||
target_link_libraries(connectivity_tool currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
ENABLE_SHARED_PCH(CONN_TOOL)
|
||||
ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool)
|
||||
|
||||
add_executable(simplewallet ${SIMPLEWALLET})
|
||||
add_dependencies(simplewallet version)
|
||||
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
ENABLE_SHARED_PCH(SIMPLEWALLET)
|
||||
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(simplewallet)
|
||||
|
||||
set_property(TARGET common crypto currency_core rpc stratum wallet PROPERTY FOLDER "libs")
|
||||
|
|
@ -170,7 +180,7 @@ if(BUILD_GUI)
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(MACOSX_BUNDLE_ICON_FILE app.icns)
|
||||
add_executable(Zano WIN32 MACOSX_BUNDLE ${QTDAEMON} )
|
||||
ENABLE_SHARED_PCH(QTDAEMON)
|
||||
ENABLE_SHARED_PCH(Zano QTDAEMON)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(Zano)
|
||||
|
||||
QT5_USE_MODULES(Zano WebEngineWidgets WebChannel)
|
||||
|
|
|
|||
7
src/common/encryption_filter.cpp
Normal file
7
src/common/encryption_filter.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
#include "encryption_filter.h"
|
||||
#include "crypto/chacha8_stream.h"
|
||||
244
src/common/encryption_filter.h
Normal file
244
src/common/encryption_filter.h
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <type_traits>
|
||||
#include <boost/iostreams/categories.hpp> // sink_tag
|
||||
#include <boost/iostreams/operations.hpp> // boost::iostreams::write, boost::iostreams::read
|
||||
#include "include_base_utils.h"
|
||||
#include "crypto/chacha8.h"
|
||||
#include "crypto/chacha8_stream.h"
|
||||
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
class encrypt_chacha_processer_base
|
||||
{
|
||||
public:
|
||||
typedef char char_type;
|
||||
//typedef boost::iostreams::multichar_output_filter_tag category;
|
||||
//typedef boost::iostreams::flushable_tag category;
|
||||
static const uint32_t block_size = ECRYPT_BLOCKLENGTH;
|
||||
|
||||
encrypt_chacha_processer_base(std::string const &pass, const crypto::chacha8_iv& iv) :m_iv(iv), m_ctx(AUTO_VAL_INIT(m_ctx))
|
||||
{
|
||||
crypto::generate_chacha8_key(pass, m_key);
|
||||
ECRYPT_keysetup(&m_ctx, &m_key.data[0], sizeof(m_key.data) * 8, sizeof(m_iv.data) * 8);
|
||||
ECRYPT_ivsetup(&m_ctx, &m_iv.data[0]);
|
||||
}
|
||||
~encrypt_chacha_processer_base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename cb_handler>
|
||||
std::streamsize process(char_type const * const buf, std::streamsize const n, cb_handler cb) const
|
||||
{
|
||||
if (n == 0)
|
||||
return n;
|
||||
if (n%ECRYPT_BLOCKLENGTH == 0 && m_buff.empty())
|
||||
{
|
||||
std::vector<char_type> buff(n);
|
||||
ECRYPT_encrypt_blocks(&m_ctx, (u8*)buf, (u8*)&buff[0], (u32)(n / ECRYPT_BLOCKLENGTH));
|
||||
cb(&buff[0], n);
|
||||
//m_underlying_stream.write(&buff[0], n);
|
||||
return n;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buff.append(buf, n);
|
||||
size_t encr_count = m_buff.size() - m_buff.size() % ECRYPT_BLOCKLENGTH;
|
||||
if (!encr_count)
|
||||
return n;
|
||||
std::vector<char_type> buff(encr_count);
|
||||
ECRYPT_encrypt_blocks(&m_ctx, (u8*)m_buff.data(), (u8*)&buff[0], (u32)(m_buff.size() / ECRYPT_BLOCKLENGTH));
|
||||
//m_underlying_stream.write(&buff[0], encr_count);
|
||||
cb(&buff[0], encr_count);
|
||||
m_buff.erase(0, encr_count);
|
||||
return encr_count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename cb_handler>
|
||||
bool flush(cb_handler cb)
|
||||
{
|
||||
if (m_buff.empty())
|
||||
return true;
|
||||
|
||||
std::vector<char_type> buff(m_buff.size());
|
||||
ECRYPT_encrypt_bytes(&m_ctx, (u8*)m_buff.data(), (u8*)&buff[0], (u32)m_buff.size());
|
||||
cb(&buff[0], m_buff.size());
|
||||
//m_underlying_stream.write(&buff[0], m_buff.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
const crypto::chacha8_iv& m_iv;
|
||||
mutable ECRYPT_ctx m_ctx;
|
||||
//std::ostream &m_underlying_stream;
|
||||
crypto::chacha8_key m_key;
|
||||
mutable std::string m_buff;
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
|
||||
class encrypt_chacha_out_filter : public encrypt_chacha_processer_base
|
||||
{
|
||||
public:
|
||||
typedef char char_type;
|
||||
struct category :
|
||||
public boost::iostreams::multichar_output_filter_tag,
|
||||
public boost::iostreams::flushable_tag
|
||||
{ };
|
||||
|
||||
encrypt_chacha_out_filter(std::string const &pass, const crypto::chacha8_iv& iv) :encrypt_chacha_processer_base(pass, iv)
|
||||
{
|
||||
}
|
||||
~encrypt_chacha_out_filter()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename t_sink>
|
||||
std::streamsize write(t_sink& snk, char_type const * const buf, std::streamsize const n) const
|
||||
{
|
||||
return encrypt_chacha_processer_base::process(buf, n, [&](char_type const * const buf_lambda, std::streamsize const n_lambda) {
|
||||
boost::iostreams::write(snk, &buf_lambda[0], n_lambda);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
bool flush(Sink& snk)
|
||||
{
|
||||
|
||||
encrypt_chacha_processer_base::flush([&](char_type const * const buf_lambda, std::streamsize const n_lambda) {
|
||||
boost::iostreams::write(snk, &buf_lambda[0], n_lambda);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
class encrypt_chacha_in_filter : public encrypt_chacha_processer_base
|
||||
{
|
||||
public:
|
||||
typedef char char_type;
|
||||
struct category : //public boost::iostreams::seekable_device_tag,
|
||||
public boost::iostreams::multichar_input_filter_tag,
|
||||
public boost::iostreams::flushable_tag
|
||||
//public boost::iostreams::seekable_filter_tag
|
||||
{ };
|
||||
encrypt_chacha_in_filter(std::string const &pass, const crypto::chacha8_iv& iv) :encrypt_chacha_processer_base(pass, iv), m_was_eof(false)
|
||||
{
|
||||
}
|
||||
~encrypt_chacha_in_filter()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char* s, std::streamsize n)
|
||||
{
|
||||
if (m_buff.size() >= static_cast<size_t>(n))
|
||||
{
|
||||
return withdraw_to_read_buff(s, n);
|
||||
}
|
||||
if (m_was_eof && m_buff.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::streamsize size_to_read_for_decrypt = (n - m_buff.size());
|
||||
size_to_read_for_decrypt += size_to_read_for_decrypt % encrypt_chacha_processer_base::block_size;
|
||||
size_t offset_in_buff = m_buff.size();
|
||||
m_buff.resize(m_buff.size() + size_to_read_for_decrypt);
|
||||
|
||||
std::streamsize result = boost::iostreams::read(src, (char*)&m_buff.data()[offset_in_buff], size_to_read_for_decrypt);
|
||||
if (result == size_to_read_for_decrypt)
|
||||
{
|
||||
//regular read proocess, readed data enought to get decrypteds
|
||||
encrypt_chacha_processer_base::process(&m_buff.data()[offset_in_buff], size_to_read_for_decrypt, [&](char_type const* const buf_lambda, std::streamsize const n_lambda)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(n_lambda == size_to_read_for_decrypt, "Error in decrypt: check n_lambda == size_to_read_for_decrypt failed");
|
||||
std::memcpy((char*)&m_buff.data()[offset_in_buff], buf_lambda, n_lambda);
|
||||
});
|
||||
return withdraw_to_read_buff(s, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
//been read some size_but it's basically might be eof
|
||||
if (!m_was_eof)
|
||||
{
|
||||
size_t offset_before_flush = offset_in_buff;
|
||||
if (result != -1)
|
||||
{
|
||||
//eof
|
||||
encrypt_chacha_processer_base::process(&m_buff.data()[offset_in_buff], result, [&](char_type const* const buf_lambda, std::streamsize const n_lambda) {
|
||||
std::memcpy((char*)&m_buff.data()[offset_in_buff], buf_lambda, n_lambda);
|
||||
offset_before_flush = offset_in_buff + n_lambda;
|
||||
});
|
||||
}
|
||||
|
||||
encrypt_chacha_processer_base::flush([&](char_type const* const buf_lambda, std::streamsize const n_lambda) {
|
||||
if (n_lambda + offset_before_flush > m_buff.size())
|
||||
{
|
||||
m_buff.resize(n_lambda + offset_before_flush);
|
||||
}
|
||||
std::memcpy((char*)&m_buff.data()[offset_before_flush], buf_lambda, n_lambda);
|
||||
m_buff.resize(offset_before_flush + n_lambda);
|
||||
});
|
||||
|
||||
//just to make sure that it's over
|
||||
std::string buff_stub(10, ' ');
|
||||
std::streamsize r = boost::iostreams::read(src, (char*)&buff_stub.data()[0], 10);
|
||||
CHECK_AND_ASSERT_THROW_MES(r == -1, "expected EOF");
|
||||
m_was_eof = true;
|
||||
return withdraw_to_read_buff(s, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename Sink>
|
||||
bool flush(Sink& snk)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::streamsize withdraw_to_read_buff(char* s, std::streamsize n)
|
||||
{
|
||||
|
||||
size_t copy_size = m_buff.size() > static_cast<size_t>(n) ? static_cast<size_t>(n) : m_buff.size();
|
||||
std::memcpy(s, m_buff.data(), copy_size);
|
||||
m_buff.erase(0, copy_size);
|
||||
return copy_size;
|
||||
}
|
||||
|
||||
std::string m_buff;
|
||||
bool m_was_eof;
|
||||
};
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#define API_RETURN_CODE_ACCESS_DENIED "ACCESS_DENIED"
|
||||
#define API_RETURN_CODE_INTERNAL_ERROR "INTERNAL_ERROR"
|
||||
#define API_RETURN_CODE_NOT_ENOUGH_MONEY "NOT_ENOUGH_MONEY"
|
||||
#define API_RETURN_CODE_NOT_ENOUGH_OUTPUTS_FOR_MIXING "NOT_ENOUGH_OUTPUTS_FOR_MIXING"
|
||||
#define API_RETURN_CODE_INTERNAL_ERROR_QUE_FULL "INTERNAL_ERROR_QUE_FULL"
|
||||
#define API_RETURN_CODE_BAD_ARG "BAD_ARG"
|
||||
#define API_RETURN_CODE_BAD_ARG_EMPTY_DESTINATIONS "BAD_ARG_EMPTY_DESTINATIONS"
|
||||
|
|
@ -21,7 +22,7 @@
|
|||
#define API_RETURN_CODE_WRONG_PASSWORD "WRONG_PASSWORD"
|
||||
#define API_RETURN_CODE_WALLET_WRONG_ID "WALLET_WRONG_ID"
|
||||
#define API_RETURN_CODE_WALLET_WATCH_ONLY_NOT_SUPPORTED "WALLET_WATCH_ONLY_NOT_SUPPORTED"
|
||||
#define API_RETURN_CODE_WALLET_AUDITABLE_NOT_SUPPORTED "WALLET_AUDITABLE_NOT_SUPPORTED"
|
||||
#define API_RETURN_CODE_WALLET_AUDITABLE_NOT_SUPPORTED "WALLET_AUDITABLE_NOT_SUPPORTED"
|
||||
#define API_RETURN_CODE_FILE_NOT_FOUND "FILE_NOT_FOUND"
|
||||
#define API_RETURN_CODE_ALREADY_EXISTS "ALREADY_EXISTS"
|
||||
#define API_RETURN_CODE_CANCELED "CANCELED"
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ namespace tools
|
|||
static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_lmdb_94_599999.pak", "6ab4f17cb9252f5cb576e8b212b5b95ad4b3e801a9612de574d7d01204777830", 1023060357, 1491427328 };
|
||||
static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_mdbx_94_599999.pak", "7cf41d2881fa4002a159974d988a0c605ccb801888b18f0352c9a94586c9f935", 795428926, 1610588160 };
|
||||
#else
|
||||
static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_testnet_lmdb_96_349999.pak", "300a52c4c681f3d01f9d52eaca0461397a13d5507fc56438e18c3dfcb9459ebb", 345490545, 506789888 };
|
||||
static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_testnet_mdbx_96_349999.pak", "0a3e56e915fde6b0b656014909f91726489f9478b04d39d7f4ac30fd49732909", 253066780, 536862720 };
|
||||
static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_testnet_lmdb_97_449999.pak", "923b5c59359807b7e375e34cdf9327216c34ab71550669f9535a552c441b285a", 427062309, 641089536 };
|
||||
static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_testnet_mdbx_97_449999.pak", "ab8b9e9fdedbf47dcbc01c7816191951f3b154b1eb7e5dd0da3df0872e0cd80a", 308152196, 805294080 };
|
||||
#endif
|
||||
|
||||
static constexpr uint64_t pre_download_min_size_difference = 512 * 1024 * 1024; // minimum difference in size between local DB and the downloadable one to start downloading
|
||||
|
|
|
|||
115
src/crypto/chacha8_stream.c
Normal file
115
src/crypto/chacha8_stream.c
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
chacha-ref.c version 20080118
|
||||
D. J. Bernstein
|
||||
Public domain.
|
||||
*/
|
||||
|
||||
#include "ecrypt-sync.h"
|
||||
|
||||
#define ROTATE(v,c) (ROTL32(v,c))
|
||||
#define XOR(v,w) ((v) ^ (w))
|
||||
#define PLUS(v,w) (U32V((v) + (w)))
|
||||
#define PLUSONE(v) (PLUS((v),1))
|
||||
|
||||
#define QUARTERROUND(a,b,c,d) \
|
||||
x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]),16); \
|
||||
x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]),12); \
|
||||
x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]), 8); \
|
||||
x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]), 7);
|
||||
|
||||
static void salsa20_wordtobyte(u8 output[64], const u32 input[16])
|
||||
{
|
||||
u32 x[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; ++i) x[i] = input[i];
|
||||
for (i = 8; i > 0; i -= 2) {
|
||||
QUARTERROUND(0, 4, 8, 12)
|
||||
QUARTERROUND(1, 5, 9, 13)
|
||||
QUARTERROUND(2, 6, 10, 14)
|
||||
QUARTERROUND(3, 7, 11, 15)
|
||||
QUARTERROUND(0, 5, 10, 15)
|
||||
QUARTERROUND(1, 6, 11, 12)
|
||||
QUARTERROUND(2, 7, 8, 13)
|
||||
QUARTERROUND(3, 4, 9, 14)
|
||||
}
|
||||
for (i = 0; i < 16; ++i) x[i] = PLUS(x[i], input[i]);
|
||||
for (i = 0; i < 16; ++i) U32TO8_LITTLE(output + 4 * i, x[i]);
|
||||
}
|
||||
|
||||
void ECRYPT_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static const char sigma[16] = "expand 32-byte k";
|
||||
static const char tau[16] = "expand 16-byte k";
|
||||
|
||||
void ECRYPT_keysetup(ECRYPT_ctx *x, const u8 *k, u32 kbits, u32 ivbits)
|
||||
{
|
||||
const char *constants;
|
||||
|
||||
x->input[4] = U8TO32_LITTLE(k + 0);
|
||||
x->input[5] = U8TO32_LITTLE(k + 4);
|
||||
x->input[6] = U8TO32_LITTLE(k + 8);
|
||||
x->input[7] = U8TO32_LITTLE(k + 12);
|
||||
if (kbits == 256) { /* recommended */
|
||||
k += 16;
|
||||
constants = sigma;
|
||||
}
|
||||
else { /* kbits == 128 */
|
||||
constants = tau;
|
||||
}
|
||||
x->input[8] = U8TO32_LITTLE(k + 0);
|
||||
x->input[9] = U8TO32_LITTLE(k + 4);
|
||||
x->input[10] = U8TO32_LITTLE(k + 8);
|
||||
x->input[11] = U8TO32_LITTLE(k + 12);
|
||||
x->input[0] = U8TO32_LITTLE(constants + 0);
|
||||
x->input[1] = U8TO32_LITTLE(constants + 4);
|
||||
x->input[2] = U8TO32_LITTLE(constants + 8);
|
||||
x->input[3] = U8TO32_LITTLE(constants + 12);
|
||||
}
|
||||
|
||||
void ECRYPT_ivsetup(ECRYPT_ctx *x, const u8 *iv)
|
||||
{
|
||||
x->input[12] = 0;
|
||||
x->input[13] = 0;
|
||||
x->input[14] = U8TO32_LITTLE(iv + 0);
|
||||
x->input[15] = U8TO32_LITTLE(iv + 4);
|
||||
}
|
||||
|
||||
void ECRYPT_encrypt_bytes(ECRYPT_ctx *x, const u8 *m, u8 *c, u32 bytes)
|
||||
{
|
||||
u8 output[64];
|
||||
int i;
|
||||
|
||||
if (!bytes) return;
|
||||
for (;;) {
|
||||
salsa20_wordtobyte(output, x->input);
|
||||
x->input[12] = PLUSONE(x->input[12]);
|
||||
if (!x->input[12]) {
|
||||
x->input[13] = PLUSONE(x->input[13]);
|
||||
/* stopping at 2^70 bytes per nonce is user's responsibility */
|
||||
}
|
||||
if (bytes <= 64) {
|
||||
for (i = 0; i < bytes; ++i) c[i] = m[i] ^ output[i];
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < 64; ++i) c[i] = m[i] ^ output[i];
|
||||
bytes -= 64;
|
||||
c += 64;
|
||||
m += 64;
|
||||
}
|
||||
}
|
||||
|
||||
void ECRYPT_decrypt_bytes(ECRYPT_ctx *x, const u8 *c, u8 *m, u32 bytes)
|
||||
{
|
||||
ECRYPT_encrypt_bytes(x, c, m, bytes);
|
||||
}
|
||||
|
||||
void ECRYPT_keystream_bytes(ECRYPT_ctx *x, u8 *stream, u32 bytes)
|
||||
{
|
||||
u32 i;
|
||||
for (i = 0; i < bytes; ++i) stream[i] = 0;
|
||||
ECRYPT_encrypt_bytes(x, stream, stream, bytes);
|
||||
}
|
||||
289
src/crypto/chacha8_stream.h
Normal file
289
src/crypto/chacha8_stream.h
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
/* ecrypt-sync.h */
|
||||
|
||||
/*
|
||||
* Header file for synchronous stream ciphers without authentication
|
||||
* mechanism.
|
||||
*
|
||||
* *** Please only edit parts marked with "[edit]". ***
|
||||
*/
|
||||
|
||||
#ifndef ECRYPT_SYNC
|
||||
#define ECRYPT_SYNC
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "ecrypt-portable.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Cipher parameters */
|
||||
|
||||
/*
|
||||
* The name of your cipher.
|
||||
*/
|
||||
#define ECRYPT_NAME "ChaCha8"
|
||||
#define ECRYPT_PROFILE "_____"
|
||||
|
||||
/*
|
||||
* Specify which key and IV sizes are supported by your cipher. A user
|
||||
* should be able to enumerate the supported sizes by running the
|
||||
* following code:
|
||||
*
|
||||
* for (i = 0; ECRYPT_KEYSIZE(i) <= ECRYPT_MAXKEYSIZE; ++i)
|
||||
* {
|
||||
* keysize = ECRYPT_KEYSIZE(i);
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* All sizes are in bits.
|
||||
*/
|
||||
|
||||
#define ECRYPT_MAXKEYSIZE 256 /* [edit] */
|
||||
#define ECRYPT_KEYSIZE(i) (128 + (i)*128) /* [edit] */
|
||||
|
||||
#define ECRYPT_MAXIVSIZE 64 /* [edit] */
|
||||
#define ECRYPT_IVSIZE(i) (64 + (i)*64) /* [edit] */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Data structures */
|
||||
|
||||
/*
|
||||
* ECRYPT_ctx is the structure containing the representation of the
|
||||
* internal state of your cipher.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 input[16]; /* could be compressed */
|
||||
/*
|
||||
* [edit]
|
||||
*
|
||||
* Put here all state variable needed during the encryption process.
|
||||
*/
|
||||
} ECRYPT_ctx;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Mandatory functions */
|
||||
|
||||
/*
|
||||
* Key and message independent initialization. This function will be
|
||||
* called once when the program starts (e.g., to build expanded S-box
|
||||
* tables).
|
||||
*/
|
||||
void ECRYPT_init();
|
||||
|
||||
/*
|
||||
* Key setup. It is the user's responsibility to select the values of
|
||||
* keysize and ivsize from the set of supported values specified
|
||||
* above.
|
||||
*/
|
||||
void ECRYPT_keysetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* key,
|
||||
u32 keysize, /* Key size in bits. */
|
||||
u32 ivsize); /* IV size in bits. */
|
||||
|
||||
/*
|
||||
* IV setup. After having called ECRYPT_keysetup(), the user is
|
||||
* allowed to call ECRYPT_ivsetup() different times in order to
|
||||
* encrypt/decrypt different messages with the same key but different
|
||||
* IV's.
|
||||
*/
|
||||
void ECRYPT_ivsetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv);
|
||||
|
||||
/*
|
||||
* Encryption/decryption of arbitrary length messages.
|
||||
*
|
||||
* For efficiency reasons, the API provides two types of
|
||||
* encrypt/decrypt functions. The ECRYPT_encrypt_bytes() function
|
||||
* (declared here) encrypts byte strings of arbitrary length, while
|
||||
* the ECRYPT_encrypt_blocks() function (defined later) only accepts
|
||||
* lengths which are multiples of ECRYPT_BLOCKLENGTH.
|
||||
*
|
||||
* The user is allowed to make multiple calls to
|
||||
* ECRYPT_encrypt_blocks() to incrementally encrypt a long message,
|
||||
* but he is NOT allowed to make additional encryption calls once he
|
||||
* has called ECRYPT_encrypt_bytes() (unless he starts a new message
|
||||
* of course). For example, this sequence of calls is acceptable:
|
||||
*
|
||||
* ECRYPT_keysetup();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
*
|
||||
* The following sequence is not:
|
||||
*
|
||||
* ECRYPT_keysetup();
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
*/
|
||||
|
||||
void ECRYPT_encrypt_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 msglen); /* Message length in bytes. */
|
||||
|
||||
void ECRYPT_decrypt_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 msglen); /* Message length in bytes. */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Optional features */
|
||||
|
||||
/*
|
||||
* For testing purposes it can sometimes be useful to have a function
|
||||
* which immediately generates keystream without having to provide it
|
||||
* with a zero plaintext. If your cipher cannot provide this function
|
||||
* (e.g., because it is not strictly a synchronous cipher), please
|
||||
* reset the ECRYPT_GENERATES_KEYSTREAM flag.
|
||||
*/
|
||||
|
||||
#define ECRYPT_GENERATES_KEYSTREAM
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
void ECRYPT_keystream_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
u8* keystream,
|
||||
u32 length); /* Length of keystream in bytes. */
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Optional optimizations */
|
||||
|
||||
/*
|
||||
* By default, the functions in this section are implemented using
|
||||
* calls to functions declared above. However, you might want to
|
||||
* implement them differently for performance reasons.
|
||||
*/
|
||||
|
||||
/*
|
||||
* All-in-one encryption/decryption of (short) packets.
|
||||
*
|
||||
* The default definitions of these functions can be found in
|
||||
* "ecrypt-sync.c". If you want to implement them differently, please
|
||||
* undef the ECRYPT_USES_DEFAULT_ALL_IN_ONE flag.
|
||||
*/
|
||||
#define ECRYPT_USES_DEFAULT_ALL_IN_ONE /* [edit] */
|
||||
|
||||
void ECRYPT_encrypt_packet(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 msglen);
|
||||
|
||||
void ECRYPT_decrypt_packet(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 msglen);
|
||||
|
||||
/*
|
||||
* Encryption/decryption of blocks.
|
||||
*
|
||||
* By default, these functions are defined as macros. If you want to
|
||||
* provide a different implementation, please undef the
|
||||
* ECRYPT_USES_DEFAULT_BLOCK_MACROS flag and implement the functions
|
||||
* declared below.
|
||||
*/
|
||||
|
||||
#define ECRYPT_BLOCKLENGTH 64 /* [edit] */
|
||||
|
||||
#define ECRYPT_USES_DEFAULT_BLOCK_MACROS /* [edit] */
|
||||
#ifdef ECRYPT_USES_DEFAULT_BLOCK_MACROS
|
||||
|
||||
#define ECRYPT_encrypt_blocks(ctx, plaintext, ciphertext, blocks) \
|
||||
ECRYPT_encrypt_bytes(ctx, plaintext, ciphertext, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#define ECRYPT_decrypt_blocks(ctx, ciphertext, plaintext, blocks) \
|
||||
ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
#define ECRYPT_keystream_blocks(ctx, keystream, blocks) \
|
||||
ECRYPT_keystream_bytes(ctx, keystream, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
void ECRYPT_encrypt_blocks(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 blocks); /* Message length in blocks. */
|
||||
|
||||
void ECRYPT_decrypt_blocks(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 blocks); /* Message length in blocks. */
|
||||
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
void ECRYPT_keystream_blocks(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* keystream,
|
||||
u32 blocks); /* Keystream length in blocks. */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If your cipher can be implemented in different ways, you can use
|
||||
* the ECRYPT_VARIANT parameter to allow the user to choose between
|
||||
* them at compile time (e.g., gcc -DECRYPT_VARIANT=3 ...). Please
|
||||
* only use this possibility if you really think it could make a
|
||||
* significant difference and keep the number of variants
|
||||
* (ECRYPT_MAXVARIANT) as small as possible (definitely not more than
|
||||
* 10). Note also that all variants should have exactly the same
|
||||
* external interface (i.e., the same ECRYPT_BLOCKLENGTH, etc.).
|
||||
*/
|
||||
#define ECRYPT_MAXVARIANT 1 /* [edit] */
|
||||
|
||||
#ifndef ECRYPT_VARIANT
|
||||
#define ECRYPT_VARIANT 1
|
||||
#endif
|
||||
|
||||
#if (ECRYPT_VARIANT > ECRYPT_MAXVARIANT)
|
||||
#error this variant does not exist
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
//extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
272
src/crypto/ecrypt-config.h
Normal file
272
src/crypto/ecrypt-config.h
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
/* ecrypt-config.h */
|
||||
|
||||
/* *** Normally, it should not be necessary to edit this file. *** */
|
||||
|
||||
#ifndef ECRYPT_CONFIG
|
||||
#define ECRYPT_CONFIG
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Guess the endianness of the target architecture. */
|
||||
|
||||
/*
|
||||
* The LITTLE endian machines:
|
||||
*/
|
||||
#if defined(__ultrix) /* Older MIPS */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(__alpha) /* Alpha */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(i386) /* x86 (gcc) */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(__i386) /* x86 (gcc) */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(_M_IX86) /* x86 (MSC, Borland) */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(_MSC_VER) /* x86 (surely MSC) */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
#elif defined(__INTEL_COMPILER) /* x86 (surely Intel compiler icl.exe) */
|
||||
#define ECRYPT_LITTLE_ENDIAN
|
||||
|
||||
/*
|
||||
* The BIG endian machines:
|
||||
*/
|
||||
#elif defined(sun) /* Newer Sparc's */
|
||||
#define ECRYPT_BIG_ENDIAN
|
||||
#elif defined(__ppc__) /* PowerPC */
|
||||
#define ECRYPT_BIG_ENDIAN
|
||||
|
||||
/*
|
||||
* Finally machines with UNKNOWN endianness:
|
||||
*/
|
||||
#elif defined (_AIX) /* RS6000 */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#elif defined(__hpux) /* HP-PA */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#elif defined(__aux) /* 68K */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#elif defined(__dgux) /* 88K (but P6 in latest boxes) */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#elif defined(__sgi) /* Newer MIPS */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#else /* Any other processor */
|
||||
#define ECRYPT_UNKNOWN
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Find minimal-width types to store 8-bit, 16-bit, 32-bit, and 64-bit
|
||||
* integers.
|
||||
*
|
||||
* Note: to enable 64-bit types on 32-bit compilers, it might be
|
||||
* necessary to switch from ISO C90 mode to ISO C99 mode (e.g., gcc
|
||||
* -std=c99).
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/* --- check char --- */
|
||||
|
||||
#if (UCHAR_MAX / 0xFU > 0xFU)
|
||||
#ifndef I8T
|
||||
#define I8T char
|
||||
#define U8C(v) (v##U)
|
||||
|
||||
#if (UCHAR_MAX == 0xFFU)
|
||||
#define ECRYPT_I8T_IS_BYTE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (UCHAR_MAX / 0xFFU > 0xFFU)
|
||||
#ifndef I16T
|
||||
#define I16T char
|
||||
#define U16C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (UCHAR_MAX / 0xFFFFU > 0xFFFFU)
|
||||
#ifndef I32T
|
||||
#define I32T char
|
||||
#define U32C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (UCHAR_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
|
||||
#ifndef I64T
|
||||
#define I64T char
|
||||
#define U64C(v) (v##U)
|
||||
#define ECRYPT_NATIVE64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* --- check short --- */
|
||||
|
||||
#if (USHRT_MAX / 0xFU > 0xFU)
|
||||
#ifndef I8T
|
||||
#define I8T short
|
||||
#define U8C(v) (v##U)
|
||||
|
||||
#if (USHRT_MAX == 0xFFU)
|
||||
#define ECRYPT_I8T_IS_BYTE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (USHRT_MAX / 0xFFU > 0xFFU)
|
||||
#ifndef I16T
|
||||
#define I16T short
|
||||
#define U16C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (USHRT_MAX / 0xFFFFU > 0xFFFFU)
|
||||
#ifndef I32T
|
||||
#define I32T short
|
||||
#define U32C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (USHRT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
|
||||
#ifndef I64T
|
||||
#define I64T short
|
||||
#define U64C(v) (v##U)
|
||||
#define ECRYPT_NATIVE64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* --- check int --- */
|
||||
|
||||
#if (UINT_MAX / 0xFU > 0xFU)
|
||||
#ifndef I8T
|
||||
#define I8T int
|
||||
#define U8C(v) (v##U)
|
||||
|
||||
#if (ULONG_MAX == 0xFFU)
|
||||
#define ECRYPT_I8T_IS_BYTE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (UINT_MAX / 0xFFU > 0xFFU)
|
||||
#ifndef I16T
|
||||
#define I16T int
|
||||
#define U16C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (UINT_MAX / 0xFFFFU > 0xFFFFU)
|
||||
#ifndef I32T
|
||||
#define I32T int
|
||||
#define U32C(v) (v##U)
|
||||
#endif
|
||||
|
||||
#if (UINT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
|
||||
#ifndef I64T
|
||||
#define I64T int
|
||||
#define U64C(v) (v##U)
|
||||
#define ECRYPT_NATIVE64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* --- check long --- */
|
||||
|
||||
#if (ULONG_MAX / 0xFUL > 0xFUL)
|
||||
#ifndef I8T
|
||||
#define I8T long
|
||||
#define U8C(v) (v##UL)
|
||||
|
||||
#if (ULONG_MAX == 0xFFUL)
|
||||
#define ECRYPT_I8T_IS_BYTE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (ULONG_MAX / 0xFFUL > 0xFFUL)
|
||||
#ifndef I16T
|
||||
#define I16T long
|
||||
#define U16C(v) (v##UL)
|
||||
#endif
|
||||
|
||||
#if (ULONG_MAX / 0xFFFFUL > 0xFFFFUL)
|
||||
#ifndef I32T
|
||||
#define I32T long
|
||||
#define U32C(v) (v##UL)
|
||||
#endif
|
||||
|
||||
#if (ULONG_MAX / 0xFFFFFFFFUL > 0xFFFFFFFFUL)
|
||||
#ifndef I64T
|
||||
#define I64T long
|
||||
#define U64C(v) (v##UL)
|
||||
#define ECRYPT_NATIVE64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* --- check long long --- */
|
||||
|
||||
#ifdef ULLONG_MAX
|
||||
|
||||
#if (ULLONG_MAX / 0xFULL > 0xFULL)
|
||||
#ifndef I8T
|
||||
#define I8T long long
|
||||
#define U8C(v) (v##ULL)
|
||||
|
||||
#if (ULLONG_MAX == 0xFFULL)
|
||||
#define ECRYPT_I8T_IS_BYTE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (ULLONG_MAX / 0xFFULL > 0xFFULL)
|
||||
#ifndef I16T
|
||||
#define I16T long long
|
||||
#define U16C(v) (v##ULL)
|
||||
#endif
|
||||
|
||||
#if (ULLONG_MAX / 0xFFFFULL > 0xFFFFULL)
|
||||
#ifndef I32T
|
||||
#define I32T long long
|
||||
#define U32C(v) (v##ULL)
|
||||
#endif
|
||||
|
||||
#if (ULLONG_MAX / 0xFFFFFFFFULL > 0xFFFFFFFFULL)
|
||||
#ifndef I64T
|
||||
#define I64T long long
|
||||
#define U64C(v) (v##ULL)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* --- check __int64 --- */
|
||||
|
||||
#ifdef _UI64_MAX
|
||||
|
||||
#if (_UI64_MAX / 0xFFFFFFFFui64 > 0xFFFFFFFFui64)
|
||||
#ifndef I64T
|
||||
#define I64T __int64
|
||||
#define U64C(v) (v##ui64)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
46
src/crypto/ecrypt-machine.h
Normal file
46
src/crypto/ecrypt-machine.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* ecrypt-machine.h */
|
||||
|
||||
/*
|
||||
* This file is included by 'ecrypt-portable.h'. It allows to override
|
||||
* the default macros for specific platforms. Please carefully check
|
||||
* the machine code generated by your compiler (with optimisations
|
||||
* turned on) before deciding to edit this file.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if (defined(ECRYPT_DEFAULT_ROT) && !defined(ECRYPT_MACHINE_ROT))
|
||||
|
||||
#define ECRYPT_MACHINE_ROT
|
||||
|
||||
#if (defined(WIN32) && defined(_MSC_VER))
|
||||
|
||||
#undef ROTL32
|
||||
#undef ROTR32
|
||||
#undef ROTL64
|
||||
#undef ROTR64
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ROTL32(v, n) _lrotl(v, n)
|
||||
#define ROTR32(v, n) _lrotr(v, n)
|
||||
#define ROTL64(v, n) _rotl64(v, n)
|
||||
#define ROTR64(v, n) _rotr64(v, n)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if (defined(ECRYPT_DEFAULT_SWAP) && !defined(ECRYPT_MACHINE_SWAP))
|
||||
|
||||
#define ECRYPT_MACHINE_SWAP
|
||||
|
||||
/*
|
||||
* If you want to overwrite the default swap macros, put it here. And so on.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
303
src/crypto/ecrypt-portable.h
Normal file
303
src/crypto/ecrypt-portable.h
Normal file
|
|
@ -0,0 +1,303 @@
|
|||
/* ecrypt-portable.h */
|
||||
|
||||
/*
|
||||
* WARNING: the conversions defined below are implemented as macros,
|
||||
* and should be used carefully. They should NOT be used with
|
||||
* parameters which perform some action. E.g., the following two lines
|
||||
* are not equivalent:
|
||||
*
|
||||
* 1) ++x; y = ROTL32(x, n);
|
||||
* 2) y = ROTL32(++x, n);
|
||||
*/
|
||||
|
||||
/*
|
||||
* *** Please do not edit this file. ***
|
||||
*
|
||||
* The default macros can be overridden for specific architectures by
|
||||
* editing 'ecrypt-machine.h'.
|
||||
*/
|
||||
|
||||
#ifndef ECRYPT_PORTABLE
|
||||
#define ECRYPT_PORTABLE
|
||||
|
||||
#include "ecrypt-config.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* The following types are defined (if available):
|
||||
*
|
||||
* u8: unsigned integer type, at least 8 bits
|
||||
* u16: unsigned integer type, at least 16 bits
|
||||
* u32: unsigned integer type, at least 32 bits
|
||||
* u64: unsigned integer type, at least 64 bits
|
||||
*
|
||||
* s8, s16, s32, s64 -> signed counterparts of u8, u16, u32, u64
|
||||
*
|
||||
* The selection of minimum-width integer types is taken care of by
|
||||
* 'ecrypt-config.h'. Note: to enable 64-bit types on 32-bit
|
||||
* compilers, it might be necessary to switch from ISO C90 mode to ISO
|
||||
* C99 mode (e.g., gcc -std=c99).
|
||||
*/
|
||||
|
||||
#ifdef I8T
|
||||
typedef signed I8T s8;
|
||||
typedef unsigned I8T u8;
|
||||
#endif
|
||||
|
||||
#ifdef I16T
|
||||
typedef signed I16T s16;
|
||||
typedef unsigned I16T u16;
|
||||
#endif
|
||||
|
||||
#ifdef I32T
|
||||
typedef signed I32T s32;
|
||||
typedef unsigned I32T u32;
|
||||
#endif
|
||||
|
||||
#ifdef I64T
|
||||
typedef signed I64T s64;
|
||||
typedef unsigned I64T u64;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following macros are used to obtain exact-width results.
|
||||
*/
|
||||
|
||||
#define U8V(v) ((u8)(v) & U8C(0xFF))
|
||||
#define U16V(v) ((u16)(v) & U16C(0xFFFF))
|
||||
#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
|
||||
#define U64V(v) ((u64)(v) & U64C(0xFFFFFFFFFFFFFFFF))
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* The following macros return words with their bits rotated over n
|
||||
* positions to the left/right.
|
||||
*/
|
||||
|
||||
#define ECRYPT_DEFAULT_ROT
|
||||
|
||||
#define ROTL8(v, n) \
|
||||
(U8V((v) << (n)) | ((v) >> (8 - (n))))
|
||||
|
||||
#define ROTL16(v, n) \
|
||||
(U16V((v) << (n)) | ((v) >> (16 - (n))))
|
||||
|
||||
#define ROTL32(v, n) \
|
||||
(U32V((v) << (n)) | ((v) >> (32 - (n))))
|
||||
|
||||
#define ROTL64(v, n) \
|
||||
(U64V((v) << (n)) | ((v) >> (64 - (n))))
|
||||
|
||||
#define ROTR8(v, n) ROTL8(v, 8 - (n))
|
||||
#define ROTR16(v, n) ROTL16(v, 16 - (n))
|
||||
#define ROTR32(v, n) ROTL32(v, 32 - (n))
|
||||
#define ROTR64(v, n) ROTL64(v, 64 - (n))
|
||||
|
||||
#include "ecrypt-machine.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* The following macros return a word with bytes in reverse order.
|
||||
*/
|
||||
|
||||
#define ECRYPT_DEFAULT_SWAP
|
||||
|
||||
#define SWAP16(v) \
|
||||
ROTL16(v, 8)
|
||||
|
||||
#define SWAP32(v) \
|
||||
((ROTL32(v, 8) & U32C(0x00FF00FF)) | \
|
||||
(ROTL32(v, 24) & U32C(0xFF00FF00)))
|
||||
|
||||
#ifdef ECRYPT_NATIVE64
|
||||
#define SWAP64(v) \
|
||||
((ROTL64(v, 8) & U64C(0x000000FF000000FF)) | \
|
||||
(ROTL64(v, 24) & U64C(0x0000FF000000FF00)) | \
|
||||
(ROTL64(v, 40) & U64C(0x00FF000000FF0000)) | \
|
||||
(ROTL64(v, 56) & U64C(0xFF000000FF000000)))
|
||||
#else
|
||||
#define SWAP64(v) \
|
||||
(((u64)SWAP32(U32V(v)) << 32) | (u64)SWAP32(U32V(v >> 32)))
|
||||
#endif
|
||||
|
||||
#include "ecrypt-machine.h"
|
||||
|
||||
#define ECRYPT_DEFAULT_WTOW
|
||||
|
||||
#ifdef ECRYPT_LITTLE_ENDIAN
|
||||
#define U16TO16_LITTLE(v) (v)
|
||||
#define U32TO32_LITTLE(v) (v)
|
||||
#define U64TO64_LITTLE(v) (v)
|
||||
|
||||
#define U16TO16_BIG(v) SWAP16(v)
|
||||
#define U32TO32_BIG(v) SWAP32(v)
|
||||
#define U64TO64_BIG(v) SWAP64(v)
|
||||
#endif
|
||||
|
||||
#ifdef ECRYPT_BIG_ENDIAN
|
||||
#define U16TO16_LITTLE(v) SWAP16(v)
|
||||
#define U32TO32_LITTLE(v) SWAP32(v)
|
||||
#define U64TO64_LITTLE(v) SWAP64(v)
|
||||
|
||||
#define U16TO16_BIG(v) (v)
|
||||
#define U32TO32_BIG(v) (v)
|
||||
#define U64TO64_BIG(v) (v)
|
||||
#endif
|
||||
|
||||
#include "ecrypt-machine.h"
|
||||
|
||||
/*
|
||||
* The following macros load words from an array of bytes with
|
||||
* different types of endianness, and vice versa.
|
||||
*/
|
||||
|
||||
#define ECRYPT_DEFAULT_BTOW
|
||||
|
||||
#if (!defined(ECRYPT_UNKNOWN) && defined(ECRYPT_I8T_IS_BYTE))
|
||||
|
||||
#define U8TO16_LITTLE(p) U16TO16_LITTLE(((u16*)(p))[0])
|
||||
#define U8TO32_LITTLE(p) U32TO32_LITTLE(((u32*)(p))[0])
|
||||
#define U8TO64_LITTLE(p) U64TO64_LITTLE(((u64*)(p))[0])
|
||||
|
||||
#define U8TO16_BIG(p) U16TO16_BIG(((u16*)(p))[0])
|
||||
#define U8TO32_BIG(p) U32TO32_BIG(((u32*)(p))[0])
|
||||
#define U8TO64_BIG(p) U64TO64_BIG(((u64*)(p))[0])
|
||||
|
||||
#define U16TO8_LITTLE(p, v) (((u16*)(p))[0] = U16TO16_LITTLE(v))
|
||||
#define U32TO8_LITTLE(p, v) (((u32*)(p))[0] = U32TO32_LITTLE(v))
|
||||
#define U64TO8_LITTLE(p, v) (((u64*)(p))[0] = U64TO64_LITTLE(v))
|
||||
|
||||
#define U16TO8_BIG(p, v) (((u16*)(p))[0] = U16TO16_BIG(v))
|
||||
#define U32TO8_BIG(p, v) (((u32*)(p))[0] = U32TO32_BIG(v))
|
||||
#define U64TO8_BIG(p, v) (((u64*)(p))[0] = U64TO64_BIG(v))
|
||||
|
||||
#else
|
||||
|
||||
#define U8TO16_LITTLE(p) \
|
||||
(((u16)((p)[0]) ) | \
|
||||
((u16)((p)[1]) << 8))
|
||||
|
||||
#define U8TO32_LITTLE(p) \
|
||||
(((u32)((p)[0]) ) | \
|
||||
((u32)((p)[1]) << 8) | \
|
||||
((u32)((p)[2]) << 16) | \
|
||||
((u32)((p)[3]) << 24))
|
||||
|
||||
#ifdef ECRYPT_NATIVE64
|
||||
#define U8TO64_LITTLE(p) \
|
||||
(((u64)((p)[0]) ) | \
|
||||
((u64)((p)[1]) << 8) | \
|
||||
((u64)((p)[2]) << 16) | \
|
||||
((u64)((p)[3]) << 24) | \
|
||||
((u64)((p)[4]) << 32) | \
|
||||
((u64)((p)[5]) << 40) | \
|
||||
((u64)((p)[6]) << 48) | \
|
||||
((u64)((p)[7]) << 56))
|
||||
#else
|
||||
#define U8TO64_LITTLE(p) \
|
||||
((u64)U8TO32_LITTLE(p) | ((u64)U8TO32_LITTLE((p) + 4) << 32))
|
||||
#endif
|
||||
|
||||
#define U8TO16_BIG(p) \
|
||||
(((u16)((p)[0]) << 8) | \
|
||||
((u16)((p)[1]) ))
|
||||
|
||||
#define U8TO32_BIG(p) \
|
||||
(((u32)((p)[0]) << 24) | \
|
||||
((u32)((p)[1]) << 16) | \
|
||||
((u32)((p)[2]) << 8) | \
|
||||
((u32)((p)[3]) ))
|
||||
|
||||
#ifdef ECRYPT_NATIVE64
|
||||
#define U8TO64_BIG(p) \
|
||||
(((u64)((p)[0]) << 56) | \
|
||||
((u64)((p)[1]) << 48) | \
|
||||
((u64)((p)[2]) << 40) | \
|
||||
((u64)((p)[3]) << 32) | \
|
||||
((u64)((p)[4]) << 24) | \
|
||||
((u64)((p)[5]) << 16) | \
|
||||
((u64)((p)[6]) << 8) | \
|
||||
((u64)((p)[7]) ))
|
||||
#else
|
||||
#define U8TO64_BIG(p) \
|
||||
(((u64)U8TO32_BIG(p) << 32) | (u64)U8TO32_BIG((p) + 4))
|
||||
#endif
|
||||
|
||||
#define U16TO8_LITTLE(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) ); \
|
||||
(p)[1] = U8V((v) >> 8); \
|
||||
} while (0)
|
||||
|
||||
#define U32TO8_LITTLE(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) ); \
|
||||
(p)[1] = U8V((v) >> 8); \
|
||||
(p)[2] = U8V((v) >> 16); \
|
||||
(p)[3] = U8V((v) >> 24); \
|
||||
} while (0)
|
||||
|
||||
#ifdef ECRYPT_NATIVE64
|
||||
#define U64TO8_LITTLE(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) ); \
|
||||
(p)[1] = U8V((v) >> 8); \
|
||||
(p)[2] = U8V((v) >> 16); \
|
||||
(p)[3] = U8V((v) >> 24); \
|
||||
(p)[4] = U8V((v) >> 32); \
|
||||
(p)[5] = U8V((v) >> 40); \
|
||||
(p)[6] = U8V((v) >> 48); \
|
||||
(p)[7] = U8V((v) >> 56); \
|
||||
} while (0)
|
||||
#else
|
||||
#define U64TO8_LITTLE(p, v) \
|
||||
do { \
|
||||
U32TO8_LITTLE((p), U32V((v) )); \
|
||||
U32TO8_LITTLE((p) + 4, U32V((v) >> 32)); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define U16TO8_BIG(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) ); \
|
||||
(p)[1] = U8V((v) >> 8); \
|
||||
} while (0)
|
||||
|
||||
#define U32TO8_BIG(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) >> 24); \
|
||||
(p)[1] = U8V((v) >> 16); \
|
||||
(p)[2] = U8V((v) >> 8); \
|
||||
(p)[3] = U8V((v) ); \
|
||||
} while (0)
|
||||
|
||||
#ifdef ECRYPT_NATIVE64
|
||||
#define U64TO8_BIG(p, v) \
|
||||
do { \
|
||||
(p)[0] = U8V((v) >> 56); \
|
||||
(p)[1] = U8V((v) >> 48); \
|
||||
(p)[2] = U8V((v) >> 40); \
|
||||
(p)[3] = U8V((v) >> 32); \
|
||||
(p)[4] = U8V((v) >> 24); \
|
||||
(p)[5] = U8V((v) >> 16); \
|
||||
(p)[6] = U8V((v) >> 8); \
|
||||
(p)[7] = U8V((v) ); \
|
||||
} while (0)
|
||||
#else
|
||||
#define U64TO8_BIG(p, v) \
|
||||
do { \
|
||||
U32TO8_BIG((p), U32V((v) >> 32)); \
|
||||
U32TO8_BIG((p) + 4, U32V((v) )); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "ecrypt-machine.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
258
src/crypto/ecrypt-sync.h
Normal file
258
src/crypto/ecrypt-sync.h
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/* ecrypt-sync.h */
|
||||
|
||||
/*
|
||||
* Header file for synchronous stream ciphers without authentication
|
||||
* mechanism.
|
||||
*
|
||||
* *** Please only edit parts marked with "[edit]". ***
|
||||
*/
|
||||
|
||||
#ifndef ECRYPT_SYNC_AE
|
||||
#define ECRYPT_SYNC_AE
|
||||
|
||||
#include "ecrypt-portable.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Cipher parameters */
|
||||
|
||||
/*
|
||||
* The name of your cipher.
|
||||
*/
|
||||
#define ECRYPT_NAME "Salsa20 stream cipher" /* [edit] */
|
||||
|
||||
/*
|
||||
* Specify which key and IV sizes are supported by your cipher. A user
|
||||
* should be able to enumerate the supported sizes by running the
|
||||
* following code:
|
||||
*
|
||||
* for (i = 0; ECRYPT_KEYSIZE(i) <= ECRYPT_MAXKEYSIZE; ++i)
|
||||
* {
|
||||
* keysize = ECRYPT_KEYSIZE(i);
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* All sizes are in bits.
|
||||
*/
|
||||
|
||||
#define ECRYPT_MAXKEYSIZE 256 /* [edit] */
|
||||
#define ECRYPT_KEYSIZE(i) (128 + (i)*128) /* [edit] */
|
||||
|
||||
#define ECRYPT_MAXIVSIZE 64 /* [edit] */
|
||||
#define ECRYPT_IVSIZE(i) (64 + (i)*64) /* [edit] */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Data structures */
|
||||
|
||||
/*
|
||||
* ECRYPT_ctx is the structure containing the representation of the
|
||||
* internal state of your cipher.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 input[16]; /* could be compressed */
|
||||
/*
|
||||
* [edit]
|
||||
*
|
||||
* Put here all state variable needed during the encryption process.
|
||||
*/
|
||||
} ECRYPT_ctx;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Mandatory functions */
|
||||
|
||||
/*
|
||||
* Key and message independent initialization. This function will be
|
||||
* called once when the program starts (e.g., to build expanded S-box
|
||||
* tables).
|
||||
*/
|
||||
void ECRYPT_init();
|
||||
|
||||
/*
|
||||
* Key setup. It is the user's responsibility to select the values of
|
||||
* keysize and ivsize from the set of supported values specified
|
||||
* above.
|
||||
*/
|
||||
void ECRYPT_keysetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* key,
|
||||
u32 keysize, /* Key size in bits. */
|
||||
u32 ivsize); /* IV size in bits. */
|
||||
|
||||
/*
|
||||
* IV setup. After having called ECRYPT_keysetup(), the user is
|
||||
* allowed to call ECRYPT_ivsetup() different times in order to
|
||||
* encrypt/decrypt different messages with the same key but different
|
||||
* IV's.
|
||||
*/
|
||||
void ECRYPT_ivsetup(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv);
|
||||
|
||||
/*
|
||||
* Encryption/decryption of arbitrary length messages.
|
||||
*
|
||||
* For efficiency reasons, the API provides two types of
|
||||
* encrypt/decrypt functions. The ECRYPT_encrypt_bytes() function
|
||||
* (declared here) encrypts byte strings of arbitrary length, while
|
||||
* the ECRYPT_encrypt_blocks() function (defined later) only accepts
|
||||
* lengths which are multiples of ECRYPT_BLOCKLENGTH.
|
||||
*
|
||||
* The user is allowed to make multiple calls to
|
||||
* ECRYPT_encrypt_blocks() to incrementally encrypt a long message,
|
||||
* but he is NOT allowed to make additional encryption calls once he
|
||||
* has called ECRYPT_encrypt_bytes() (unless he starts a new message
|
||||
* of course). For example, this sequence of calls is acceptable:
|
||||
*
|
||||
* ECRYPT_keysetup();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
*
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
*
|
||||
* The following sequence is not:
|
||||
*
|
||||
* ECRYPT_keysetup();
|
||||
* ECRYPT_ivsetup();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
* ECRYPT_encrypt_bytes();
|
||||
* ECRYPT_encrypt_blocks();
|
||||
*/
|
||||
|
||||
void ECRYPT_encrypt_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 msglen); /* Message length in bytes. */
|
||||
|
||||
void ECRYPT_decrypt_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 msglen); /* Message length in bytes. */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Optional features */
|
||||
|
||||
/*
|
||||
* For testing purposes it can sometimes be useful to have a function
|
||||
* which immediately generates keystream without having to provide it
|
||||
* with a zero plaintext. If your cipher cannot provide this function
|
||||
* (e.g., because it is not strictly a synchronous cipher), please
|
||||
* reset the ECRYPT_GENERATES_KEYSTREAM flag.
|
||||
*/
|
||||
|
||||
#define ECRYPT_GENERATES_KEYSTREAM
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
void ECRYPT_keystream_bytes(
|
||||
ECRYPT_ctx* ctx,
|
||||
u8* keystream,
|
||||
u32 length); /* Length of keystream in bytes. */
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Optional optimizations */
|
||||
|
||||
/*
|
||||
* By default, the functions in this section are implemented using
|
||||
* calls to functions declared above. However, you might want to
|
||||
* implement them differently for performance reasons.
|
||||
*/
|
||||
|
||||
/*
|
||||
* All-in-one encryption/decryption of (short) packets.
|
||||
*
|
||||
* The default definitions of these functions can be found in
|
||||
* "ecrypt-sync.c". If you want to implement them differently, please
|
||||
* undef the ECRYPT_USES_DEFAULT_ALL_IN_ONE flag.
|
||||
*/
|
||||
#define ECRYPT_USES_DEFAULT_ALL_IN_ONE /* [edit] */
|
||||
|
||||
void ECRYPT_encrypt_packet(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 msglen);
|
||||
|
||||
void ECRYPT_decrypt_packet(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* iv,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 msglen);
|
||||
|
||||
/*
|
||||
* Encryption/decryption of blocks.
|
||||
*
|
||||
* By default, these functions are defined as macros. If you want to
|
||||
* provide a different implementation, please undef the
|
||||
* ECRYPT_USES_DEFAULT_BLOCK_MACROS flag and implement the functions
|
||||
* declared below.
|
||||
*/
|
||||
|
||||
#define ECRYPT_BLOCKLENGTH 64 /* [edit] */
|
||||
|
||||
#define ECRYPT_USES_DEFAULT_BLOCK_MACROS /* [edit] */
|
||||
#ifdef ECRYPT_USES_DEFAULT_BLOCK_MACROS
|
||||
|
||||
#define ECRYPT_encrypt_blocks(ctx, plaintext, ciphertext, blocks) \
|
||||
ECRYPT_encrypt_bytes(ctx, plaintext, ciphertext, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#define ECRYPT_decrypt_blocks(ctx, ciphertext, plaintext, blocks) \
|
||||
ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
#define ECRYPT_keystream_blocks(ctx, keystream, blocks) \
|
||||
ECRYPT_AE_keystream_bytes(ctx, keystream, \
|
||||
(blocks) * ECRYPT_BLOCKLENGTH)
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
void ECRYPT_encrypt_blocks(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* plaintext,
|
||||
u8* ciphertext,
|
||||
u32 blocks); /* Message length in blocks. */
|
||||
|
||||
void ECRYPT_decrypt_blocks(
|
||||
ECRYPT_ctx* ctx,
|
||||
const u8* ciphertext,
|
||||
u8* plaintext,
|
||||
u32 blocks); /* Message length in blocks. */
|
||||
|
||||
#ifdef ECRYPT_GENERATES_KEYSTREAM
|
||||
|
||||
void ECRYPT_keystream_blocks(
|
||||
ECRYPT_AE_ctx* ctx,
|
||||
const u8* keystream,
|
||||
u32 blocks); /* Keystream length in blocks. */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
|
|
@ -81,7 +81,7 @@ namespace currency
|
|||
if (m_keys.account_address.flags & ACCOUNT_PUBLIC_ADDRESS_FLAG_AUDITABLE)
|
||||
auditable_flag = 1;
|
||||
|
||||
uint64_t auditable_flag_and_checksum = (auditable_flag & 1) | (checksum << 1);
|
||||
uint32_t auditable_flag_and_checksum = (auditable_flag & 1) | (checksum << 1);
|
||||
std::string auditable_flag_and_checksum_word = tools::mnemonic_encoding::word_by_num(auditable_flag_and_checksum);
|
||||
|
||||
return keys_seed_text + " " + timestamp_word + " " + auditable_flag_and_checksum_word;
|
||||
|
|
@ -148,7 +148,7 @@ namespace currency
|
|||
if (auditable_flag_and_checksum != UINT64_MAX)
|
||||
{
|
||||
auditable_flag = (auditable_flag_and_checksum & 1) != 0; // auditable flag is the lower 1 bit
|
||||
uint16_t checksum = auditable_flag_and_checksum >> 1; // checksum -- everything else
|
||||
uint16_t checksum = static_cast<uint16_t>(auditable_flag_and_checksum >> 1); // checksum -- everything else
|
||||
constexpr uint16_t checksum_max = tools::mnemonic_encoding::NUMWORDS >> 1; // maximum value of checksum
|
||||
crypto::hash h = crypto::cn_fast_hash(keys_seed_binary.data(), keys_seed_binary.size());
|
||||
*reinterpret_cast<uint64_t*>(&h) = m_creation_timestamp;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "currency_boost_serialization.h"
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace serialization
|
||||
|
|
@ -21,6 +23,8 @@ namespace boost
|
|||
ar & te.m_spent_flags;
|
||||
}
|
||||
|
||||
// The following method is used in tests only atm
|
||||
// TODO: Consider to remove completely
|
||||
template<class archive_t>
|
||||
void serialize(archive_t & ar, currency::block_extended_info& ei, const unsigned int version)
|
||||
{
|
||||
|
|
@ -32,6 +36,11 @@ namespace boost
|
|||
ar & ei.block_cumulative_size;
|
||||
ar & ei.already_generated_coins;
|
||||
ar & ei.stake_hash;
|
||||
|
||||
ar & ei.cumulative_diff_precise_adjusted;
|
||||
//ar & ei.version;
|
||||
ar & ei.this_block_tx_fee_median;
|
||||
ar & ei.effective_tx_fee_median;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace currency
|
|||
ADD_CHECKPOINT(50000, "cb05a7bdc7f78c5cdb6ef1048f85b27c569f44879233903ce5f5a4e5bd590a3d");
|
||||
ADD_CHECKPOINT(100000, "6b8b54356a9d44f6c1ebdacb8593d8f5ab2e2e2ca4493e7ae7baf4b3755c5e16");
|
||||
ADD_CHECKPOINT(350000, "885841f079e5a38f1921f4a5319f0d52fdbab64bb2026ca3cabad1c032d22db7");
|
||||
ADD_CHECKPOINT(450000, "e8b789b909d59ed8a2a1e3eceb6d0b19accfe0d45cc31621b1929de80adfa702");
|
||||
#else
|
||||
// MAINNET
|
||||
ADD_CHECKPOINT(425000, "46a6c36d5dec2d484d5e4845a8525ca322aafc06915ed9c8da2a241b51b7d1e8");
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ namespace boost
|
|||
inline void serialize(Archive &a, currency::keypair &kp, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & kp.pub;
|
||||
a & kp.sec;
|
||||
a & kp.sec;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@
|
|||
|
||||
#define WALLET_FILE_SIGNATURE_OLD 0x1111012101101011LL // Bender's nightmare
|
||||
#define WALLET_FILE_SIGNATURE_V2 0x1111011201101011LL // another Bender's nightmare
|
||||
#define WALLET_FILE_MAX_BODY_SIZE 0x88888888L //2GB
|
||||
#define WALLET_FILE_BINARY_HEADER_VERSION 1001
|
||||
|
||||
#define WALLET_FILE_MAX_KEYS_SIZE 10000 //
|
||||
#define WALLET_BRAIN_DATE_OFFSET 1543622400
|
||||
#define WALLET_BRAIN_DATE_QUANTUM 604800 //by last word we encode a number of week since launch of the project,
|
||||
|
|
|
|||
|
|
@ -1739,7 +1739,12 @@ namespace currency
|
|||
{
|
||||
CHECK_AND_ASSERT_MES(bl_entry.tx_global_outs.size() == bl_entry.txs.size(), false, "tx_global_outs count " << bl_entry.tx_global_outs.size() << " count missmatch with bl_entry.txs count " << bl_entry.txs.size());
|
||||
}
|
||||
|
||||
if (bl_entry.coinbase_global_outs.size())
|
||||
{
|
||||
std::shared_ptr<currency::transaction_chain_entry> tche_ptr(new currency::transaction_chain_entry());
|
||||
tche_ptr->m_global_output_indexes = bl_entry.coinbase_global_outs;
|
||||
bdde.coinbase_ptr = tche_ptr;
|
||||
}
|
||||
for (const auto& tx_blob : bl_entry.txs)
|
||||
{
|
||||
std::shared_ptr<currency::transaction_chain_entry> tche_ptr(new currency::transaction_chain_entry());
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ namespace currency
|
|||
{
|
||||
blobdata block;
|
||||
std::list<blobdata> txs;
|
||||
std::vector<uint64_t> coinbase_global_outs;
|
||||
std::vector<struct_with_one_t_type<std::vector<uint64_t> > > tx_global_outs;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(block)
|
||||
KV_SERIALIZE(txs)
|
||||
KV_SERIALIZE(coinbase_global_outs)
|
||||
KV_SERIALIZE(tx_global_outs)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -317,21 +317,24 @@ private:
|
|||
std::cout << "specified key_image parameter '" << args[0] << "' is wrong" << ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
currency::blockchain_storage& bcs = m_srv.get_payload_object().get_core().get_blockchain_storage();
|
||||
|
||||
std::list<std::string> res_list;
|
||||
crypto::hash tx_id = currency::null_hash;
|
||||
auto tx_chain_entry = m_srv.get_payload_object().get_core().get_blockchain_storage().find_key_image_and_related_tx(ki, tx_id);
|
||||
auto tx_chain_entry = bcs.find_key_image_and_related_tx(ki, tx_id);
|
||||
|
||||
if (tx_chain_entry)
|
||||
{
|
||||
LOG_PRINT_L0("Found tx: " << ENDL << obj_to_json_str(tx_chain_entry->tx) << ENDL << "height: " << tx_chain_entry->m_keeper_block_height);
|
||||
}
|
||||
if (tx_id == currency::null_hash)
|
||||
{
|
||||
LOG_PRINT_L0("Not found any related tx.");
|
||||
currency::block_extended_info bei = AUTO_VAL_INIT(bei);
|
||||
CHECK_AND_ASSERT_MES(bcs.get_block_extended_info_by_height(tx_chain_entry->m_keeper_block_height, bei), false, "cannot find block by height " << tx_chain_entry->m_keeper_block_height);
|
||||
|
||||
LOG_PRINT_L0("Key image found in tx: " << tx_id << " height " << tx_chain_entry->m_keeper_block_height << " (ts: " << epee::misc_utils::get_time_str_v2(currency::get_actual_timestamp(bei.bl)) << ")" << ENDL
|
||||
<< obj_to_json_str(tx_chain_entry->tx));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_PRINT_L0("TxID: " << tx_id);
|
||||
LOG_PRINT_L0("Not found any related tx.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,8 +405,8 @@ bool MainWindow::init(const std::string& html_path)
|
|||
}
|
||||
|
||||
//----
|
||||
//this->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
|
||||
//m_view->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
|
||||
this->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
|
||||
m_view->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
|
||||
|
||||
return true;
|
||||
CATCH_ENTRY2(false);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -81,6 +81,7 @@ export class BackendService {
|
|||
error_translate = 'ERRORS.NO_MONEY';
|
||||
}
|
||||
break;
|
||||
case 'NOT_ENOUGH_OUTPUTS_FOR_MIXING':
|
||||
case 'INTERNAL_ERROR:not enough outputs to mix':
|
||||
error_translate = 'ERRORS.NOT_ENOUGH_OUTPUTS_TO_MIX';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
Watch-only
|
||||
</div>
|
||||
<div class="content auditable-watch-only" *ngIf="wallet.is_auditable && wallet.is_watch_only">
|
||||
Auditable Watch-Only
|
||||
Tracking
|
||||
</div>
|
||||
</div>
|
||||
<div class="close-wallet-wrapper">
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2014-2020 Zano Project
|
||||
// Copyright (c) 2014-2017 The The Louisdor Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ namespace currency
|
|||
}
|
||||
|
||||
blockchain_storage::blocks_direct_container bs;
|
||||
if (!m_core.get_blockchain_storage().find_blockchain_supplement(req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT, req.minimum_height))
|
||||
if (!m_core.get_blockchain_storage().find_blockchain_supplement(req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT, req.minimum_height, req.need_global_indexes))
|
||||
{
|
||||
res.status = API_RETURN_CODE_FAIL;
|
||||
return false;
|
||||
|
|
@ -328,6 +328,8 @@ namespace currency
|
|||
res.blocks.back().block = block_to_blob(b.first->bl);
|
||||
if (req.need_global_indexes)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(b.third.get(), false, "Internal error on handling COMMAND_RPC_GET_BLOCKS_FAST: b.third is empty, ie coinbase info is not prepared");
|
||||
res.blocks.back().coinbase_global_outs = b.third->m_global_output_indexes;
|
||||
res.blocks.back().tx_global_outs.resize(b.second.size());
|
||||
}
|
||||
size_t i = 0;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace
|
|||
const command_line::arg_descriptor<uint32_t> arg_log_level = {"set-log", "", 0, true};
|
||||
const command_line::arg_descriptor<bool> arg_do_pos_mining = { "do-pos-mining", "Do PoS mining", false, false };
|
||||
const command_line::arg_descriptor<std::string> arg_pos_mining_reward_address = { "pos-mining-reward-address", "Block reward will be sent to the giving address if specified", "" };
|
||||
const command_line::arg_descriptor<std::string> arg_restore_wallet = { "restore-wallet", "Restore wallet from the seed phrase and save it to <arg>", "" };
|
||||
const command_line::arg_descriptor<std::string> arg_restore_wallet = { "restore-wallet", "Restore wallet from seed phrase or tracking seed and save it to <arg>", "" };
|
||||
const command_line::arg_descriptor<bool> arg_offline_mode = { "offline-mode", "Don't connect to daemon, work offline (for cold-signing process)", false, true };
|
||||
|
||||
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
|
||||
|
|
@ -220,7 +220,7 @@ simple_wallet::simple_wallet()
|
|||
|
||||
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), "Get transaction one-time secret key (r) for a given <txid>");
|
||||
|
||||
m_cmd_binder.set_handler("tracking_seed", boost::bind(&simple_wallet::tracking_seed, this, _1), "For auditable wallets: prints auditable watch-only blob for wallet's audit by a third party");
|
||||
m_cmd_binder.set_handler("tracking_seed", boost::bind(&simple_wallet::tracking_seed, this, _1), "For auditable wallets: prints tracking seed for wallet's audit by a third party");
|
||||
|
||||
m_cmd_binder.set_handler("save", boost::bind(&simple_wallet::save, this, _1), "Save wallet synchronized data");
|
||||
m_cmd_binder.set_handler("save_watch_only", boost::bind(&simple_wallet::save_watch_only, this, _1), "save_watch_only <filename> <password> - save as watch-only wallet file.");
|
||||
|
|
@ -275,7 +275,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
|
||||
if (m_wallet_file.empty() && m_generate_new.empty() && m_restore_wallet.empty() && m_generate_new_aw.empty())
|
||||
{
|
||||
fail_msg_writer() << "you must specify --wallet-file, --generate-new-wallet, --generate-new-auditable-wallet, --restore-wallet or --restore-awo-wallet";
|
||||
fail_msg_writer() << "you must specify --wallet-file, --generate-new-wallet, --generate-new-auditable-wallet, --restore-wallet";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||
}
|
||||
|
||||
tools::password_container restore_seed_container;
|
||||
if (!restore_seed_container.read_password("please, enter wallet seed phrase or an auditable wallet tracking key:\n"))
|
||||
if (!restore_seed_container.read_password("please, enter wallet seed phrase or an auditable wallet's tracking seed:\n"))
|
||||
{
|
||||
fail_msg_writer() << "failed to read seed phrase";
|
||||
return false;
|
||||
|
|
@ -395,6 +395,8 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas
|
|||
m_wallet->generate(epee::string_encoding::utf8_to_wstring(m_wallet_file), password, create_auditable_wallet);
|
||||
message_writer(epee::log_space::console_color_white, true) << "Generated new " << (create_auditable_wallet ? "AUDITABLE" : "") << " wallet: " << m_wallet->get_account().get_public_address_str();
|
||||
std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().view_secret_key) << std::endl << std::flush;
|
||||
if (m_wallet->is_auditable())
|
||||
std::cout << "tracking seed: " << std::endl << m_wallet->get_account().get_tracking_seed() << std::endl << std::flush;
|
||||
if (m_do_not_set_date)
|
||||
m_wallet->reset_creation_time(0);
|
||||
|
||||
|
|
@ -420,33 +422,36 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool auditable_watch_only)
|
||||
bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool tracking_wallet)
|
||||
{
|
||||
m_wallet_file = wallet_file;
|
||||
|
||||
m_wallet.reset(new tools::wallet2());
|
||||
m_wallet->callback(this->shared_from_this());
|
||||
m_wallet->set_do_rise_transfer(false);
|
||||
m_wallet->set_do_rise_transfer(true);
|
||||
try
|
||||
{
|
||||
if (auditable_watch_only)
|
||||
if (tracking_wallet)
|
||||
{
|
||||
// auditable watch-only aka tracking wallet
|
||||
m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_tracking_seed, true);
|
||||
message_writer(epee::log_space::console_color_white, true) << "Auditable watch-only wallet restored: " << m_wallet->get_account().get_public_address_str();
|
||||
message_writer(epee::log_space::console_color_white, true) << "Tracking wallet restored: " << m_wallet->get_account().get_public_address_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal wallet
|
||||
// normal or auditable wallet
|
||||
m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, seed_or_tracking_seed, false);
|
||||
message_writer(epee::log_space::console_color_white, true) << "Wallet restored: " << m_wallet->get_account().get_public_address_str();
|
||||
message_writer(epee::log_space::console_color_white, true) << (m_wallet->is_auditable() ? "Auditable wallet" : "Wallet") << " restored: " << m_wallet->get_account().get_public_address_str();
|
||||
std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().view_secret_key) << std::endl << std::flush;
|
||||
if (m_wallet->is_auditable())
|
||||
std::cout << "tracking seed: " << std::endl << m_wallet->get_account().get_tracking_seed() << std::endl << std::flush;
|
||||
}
|
||||
if (m_do_not_set_date)
|
||||
m_wallet->reset_creation_time(0);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
fail_msg_writer() << "failed to restore wallet, check your " << (auditable_watch_only ? "awo blob!" : "seed phrase!") << ENDL << e.what();
|
||||
fail_msg_writer() << "failed to restore wallet, check your " << (tracking_wallet ? "tracking seed!" : "seed phrase!") << ENDL << e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +464,7 @@ bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::st
|
|||
"Use \"help\" command to see the list of available commands.\n" <<
|
||||
"Always use \"exit\" command when closing simplewallet to save\n" <<
|
||||
"current session's state. Otherwise, you will possibly need to synchronize \n" <<
|
||||
"your wallet again. Your wallet key is NOT under risk anyway.\n" <<
|
||||
"your wallet again. Your wallet keys is NOT under risk anyway.\n" <<
|
||||
"**********************************************************************";
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1493,6 +1498,7 @@ bool simple_wallet::tracking_seed(const std::vector<std::string> &args_)
|
|||
|
||||
success_msg_writer() << "Auditable watch-only tracking seed for this wallet is:";
|
||||
std::cout << m_wallet->get_account().get_tracking_seed() << ENDL;
|
||||
success_msg_writer() << "Anyone having this tracking seed is able to watch your balance and transaction history, but unable to spend coins.";
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace currency
|
|||
|
||||
bool new_wallet(const std::string &wallet_file, const std::string& password, bool create_auditable_wallet);
|
||||
bool open_wallet(const std::string &wallet_file, const std::string& password);
|
||||
bool restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool auditable_watch_only);
|
||||
bool restore_wallet(const std::string& wallet_file, const std::string& seed_or_tracking_seed, const std::string& password, bool tracking_wallet);
|
||||
bool close_wallet();
|
||||
|
||||
bool help(const std::vector<std::string> &args = std::vector<std::string>());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@
|
|||
#define PROJECT_REVISION "7"
|
||||
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
|
||||
|
||||
#define PROJECT_VERSION_BUILD_NO 95
|
||||
#define PROJECT_VERSION_BUILD_NO 97
|
||||
#define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
|
||||
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace tools
|
|||
currency::COMMAND_RPC_GET_BLOCKS_FAST::request req;
|
||||
req.block_ids = rqt.block_ids;
|
||||
req.minimum_height = rqt.minimum_height;
|
||||
req.need_global_indexes = rqt.need_global_indexes;
|
||||
currency::COMMAND_RPC_GET_BLOCKS_FAST::response res = AUTO_VAL_INIT(res);
|
||||
bool r = call_COMMAND_RPC_GET_BLOCKS_FAST(req, res);
|
||||
rsp.status = res.status;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@
|
|||
#include "core_rpc_proxy.h"
|
||||
#include "storages/http_abstract_invoke.h"
|
||||
|
||||
#define WALLET_RCP_CONNECTION_TIMEOUT 3000
|
||||
#ifdef NDEBUG
|
||||
#define WALLET_RCP_CONNECTION_TIMEOUT 5000
|
||||
#else
|
||||
#define WALLET_RCP_CONNECTION_TIMEOUT 100000
|
||||
#endif
|
||||
#define WALLET_RCP_COUNT_ATTEMNTS 3
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <numeric>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <iostream>
|
||||
#include <boost/utility/value_init.hpp>
|
||||
|
|
@ -26,6 +28,7 @@ using namespace epee;
|
|||
#include "serialization/binary_utils.h"
|
||||
#include "currency_core/bc_payments_id_service.h"
|
||||
#include "version.h"
|
||||
#include "common/encryption_filter.h"
|
||||
using namespace currency;
|
||||
|
||||
#define MINIMUM_REQUIRED_WALLET_FREE_SPACE_BYTES (100*1024*1024) // 100 MB
|
||||
|
|
@ -522,7 +525,6 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
|
|||
td.m_ptx_wallet_info = pwallet_info;
|
||||
td.m_internal_output_index = o;
|
||||
td.m_key_image = ki;
|
||||
LOG_PRINT_L0("pglobal_indexes = " << pglobal_indexes);
|
||||
if (m_use_deffered_global_outputs)
|
||||
{
|
||||
if (pglobal_indexes && pglobal_indexes->size() > o)
|
||||
|
|
@ -1487,7 +1489,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic<bool>& stop
|
|||
}
|
||||
}
|
||||
|
||||
WLT_LOG_L1("[PULL BLOCKS] " << res.start_height << " --> " << get_blockchain_current_size());
|
||||
WLT_LOG_L2("[PULL BLOCKS] " << res.start_height << " --> " << get_blockchain_current_size() - 1);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
uint64_t wallet2::get_sync_progress()
|
||||
|
|
@ -1882,12 +1884,16 @@ void wallet2::refresh(size_t & blocks_fetched, bool& received_money, std::atomic
|
|||
if (++try_count > 3)
|
||||
return;
|
||||
WLT_LOG_L2("no connection to the daemon, wait and try pull_blocks again (try_count: " << try_count << ", blocks_fetched: " << blocks_fetched << ")");
|
||||
if (m_wcallback)
|
||||
m_wcallback->on_message(tools::i_wallet2_callback::ms_red, "no connection to daemon");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
blocks_fetched += added_blocks;
|
||||
WLT_LOG_ERROR("refresh->pull_blocks failed, try_count: " << try_count << ", blocks_fetched: " << blocks_fetched << ", exception: " << e.what());
|
||||
if (m_wcallback)
|
||||
m_wcallback->on_message(tools::i_wallet2_callback::ms_red, std::string("error on pulling blocks: ") + e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1907,7 +1913,7 @@ void wallet2::refresh(size_t & blocks_fetched, bool& received_money, std::atomic
|
|||
}
|
||||
|
||||
|
||||
WLT_LOG_L1("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money(balance()) << ", unlocked: " << print_money(unlocked_balance()));
|
||||
WLT_LOG("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money(balance()) << ", unlocked: " << print_money(unlocked_balance()), blocks_fetched > 0 ? LOG_LEVEL_1 : LOG_LEVEL_2);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::handle_expiration_list(uint64_t tx_expiration_ts_median)
|
||||
|
|
@ -2120,7 +2126,7 @@ bool wallet2::reset_all()
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::store_keys(std::string& buff, const std::string& password, bool store_as_watch_only /* = false */)
|
||||
bool wallet2::store_keys(std::string& buff, const std::string& password, wallet2::keys_file_data& keys_file_data, bool store_as_watch_only /* = false */)
|
||||
{
|
||||
currency::account_base acc = m_account;
|
||||
if (store_as_watch_only)
|
||||
|
|
@ -2130,8 +2136,6 @@ bool wallet2::store_keys(std::string& buff, const std::string& password, bool st
|
|||
bool r = epee::serialization::store_t_to_binary(acc, account_data);
|
||||
WLT_CHECK_AND_ASSERT_MES(r, false, "failed to serialize wallet keys");
|
||||
|
||||
wallet2::keys_file_data keys_file_data = boost::value_initialized<wallet2::keys_file_data>();
|
||||
|
||||
crypto::chacha8_key key;
|
||||
crypto::generate_chacha8_key(password, key);
|
||||
std::string cipher;
|
||||
|
|
@ -2148,7 +2152,8 @@ bool wallet2::store_keys(std::string& buff, const std::string& password, bool st
|
|||
bool wallet2::backup_keys(const std::string& path)
|
||||
{
|
||||
std::string buff;
|
||||
bool r = store_keys(buff, m_password);
|
||||
wallet2::keys_file_data keys_file_data = AUTO_VAL_INIT(keys_file_data);
|
||||
bool r = store_keys(buff, m_password, keys_file_data);
|
||||
WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to store keys");
|
||||
|
||||
r = file_io_utils::save_string_to_file(path, buff);
|
||||
|
|
@ -2234,10 +2239,9 @@ bool wallet2::prepare_file_names(const std::wstring& file_path)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::load_keys(const std::string& buff, const std::string& password, uint64_t file_signature)
|
||||
void wallet2::load_keys(const std::string& buff, const std::string& password, uint64_t file_signature, keys_file_data& kf_data)
|
||||
{
|
||||
bool r = false;
|
||||
wallet2::keys_file_data kf_data = AUTO_VAL_INIT(kf_data);
|
||||
if (file_signature == WALLET_FILE_SIGNATURE_OLD)
|
||||
{
|
||||
wallet2::keys_file_data_old kf_data_old;
|
||||
|
|
@ -2299,18 +2303,18 @@ void wallet2::generate(const std::wstring& path, const std::string& pass, bool a
|
|||
store();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool auditable_watch_only)
|
||||
void wallet2::restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool tracking_wallet)
|
||||
{
|
||||
bool r = false;
|
||||
clear();
|
||||
prepare_file_names(path);
|
||||
m_password = pass;
|
||||
|
||||
if (auditable_watch_only)
|
||||
if (tracking_wallet)
|
||||
{
|
||||
r = m_account.restore_from_tracking_seed(seed_or_tracking_seed);
|
||||
init_log_prefix();
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "Could not load auditable watch-only wallet from a given blob: invalid awo blob");
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "Could not load tracking wallet from a given seed: invalid tracking seed");
|
||||
m_watch_only = true;
|
||||
}
|
||||
else
|
||||
|
|
@ -2356,16 +2360,30 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password)
|
|||
THROW_IF_TRUE_WALLET_EX(data_file.fail(), error::file_read_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
|
||||
THROW_IF_TRUE_WALLET_EX(wbh.m_signature != WALLET_FILE_SIGNATURE_OLD && wbh.m_signature != WALLET_FILE_SIGNATURE_V2, error::file_read_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
THROW_IF_TRUE_WALLET_EX(wbh.m_cb_body > WALLET_FILE_MAX_BODY_SIZE ||
|
||||
THROW_IF_TRUE_WALLET_EX(
|
||||
wbh.m_cb_keys > WALLET_FILE_MAX_KEYS_SIZE, error::file_read_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
|
||||
|
||||
keys_buff.resize(wbh.m_cb_keys);
|
||||
data_file.read((char*)keys_buff.data(), wbh.m_cb_keys);
|
||||
wallet2::keys_file_data kf_data = AUTO_VAL_INIT(kf_data);
|
||||
load_keys(keys_buff, password, wbh.m_signature, kf_data);
|
||||
|
||||
load_keys(keys_buff, password, wbh.m_signature);
|
||||
|
||||
bool need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, data_file);
|
||||
bool need_to_resync = false;
|
||||
if (wbh.m_ver == 1000)
|
||||
{
|
||||
need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, data_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
tools::encrypt_chacha_in_filter decrypt_filter(password, kf_data.iv);
|
||||
boost::iostreams::filtering_istream in;
|
||||
in.push(decrypt_filter);
|
||||
in.push(data_file);
|
||||
need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, in);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (m_watch_only && !is_auditable())
|
||||
load_keys2ki(true, need_to_resync);
|
||||
|
|
@ -2405,7 +2423,8 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor
|
|||
|
||||
//prepare data
|
||||
std::string keys_buff;
|
||||
bool r = store_keys(keys_buff, password, m_watch_only);
|
||||
wallet2::keys_file_data keys_file_data = AUTO_VAL_INIT(keys_file_data);
|
||||
bool r = store_keys(keys_buff, password, keys_file_data, m_watch_only);
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "failed to store_keys for wallet " << ascii_path_to_save);
|
||||
|
||||
//store data
|
||||
|
|
@ -2413,7 +2432,7 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor
|
|||
wbh.m_signature = WALLET_FILE_SIGNATURE_V2;
|
||||
wbh.m_cb_keys = keys_buff.size();
|
||||
//@#@ change it to proper
|
||||
wbh.m_cb_body = 1000;
|
||||
wbh.m_ver = WALLET_FILE_BINARY_HEADER_VERSION;
|
||||
std::string header_buff((const char*)&wbh, sizeof(wbh));
|
||||
|
||||
uint64_t ts = m_core_runtime_config.get_core_time();
|
||||
|
|
@ -2428,8 +2447,13 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor
|
|||
data_file << header_buff << keys_buff;
|
||||
|
||||
WLT_LOG_L0("Storing to temporary file " << tmp_file_path.string() << " ...");
|
||||
//creating encryption stream
|
||||
tools::encrypt_chacha_out_filter decrypt_filter(m_password, keys_file_data.iv);
|
||||
boost::iostreams::filtering_ostream out;
|
||||
out.push(decrypt_filter);
|
||||
out.push(data_file);
|
||||
|
||||
r = tools::portble_serialize_obj_to_stream(*this, data_file);
|
||||
r = tools::portble_serialize_obj_to_stream(*this, out);
|
||||
if (!r)
|
||||
{
|
||||
data_file.close();
|
||||
|
|
@ -3863,7 +3887,7 @@ bool wallet2::prepare_tx_sources_for_packing(uint64_t items_to_pack, size_t fake
|
|||
bool wallet2::prepare_tx_sources(uint64_t needed_money, size_t fake_outputs_count, uint64_t dust_threshold, std::vector<currency::tx_source_entry>& sources, std::vector<uint64_t>& selected_indicies, uint64_t& found_money)
|
||||
{
|
||||
found_money = select_transfers(needed_money, fake_outputs_count, dust_threshold, selected_indicies);
|
||||
THROW_IF_FALSE_WALLET_EX_MES(found_money >= needed_money, error::not_enough_money, "wallet_dump: " << ENDL << dump_trunsfers(false), found_money, needed_money, 0);
|
||||
WLT_THROW_IF_FALSE_WALLET_EX_MES(found_money >= needed_money, error::not_enough_money, "", found_money, needed_money, 0);
|
||||
return prepare_tx_sources(fake_outputs_count, sources, selected_indicies, found_money);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -4667,7 +4691,7 @@ void wallet2::transfer(const std::vector<currency::tx_destination_entry>& dsts,
|
|||
bool shuffle,
|
||||
uint8_t flags,
|
||||
bool send_to_network,
|
||||
std::string* p_signed_tx_blob_str)
|
||||
std::string* p_unsigned_filename_or_tx_blob_str)
|
||||
{
|
||||
//TIME_MEASURE_START(precalculation_time);
|
||||
construct_tx_param ctp = AUTO_VAL_INIT(ctp);
|
||||
|
|
@ -4686,7 +4710,7 @@ void wallet2::transfer(const std::vector<currency::tx_destination_entry>& dsts,
|
|||
ctp.tx_outs_attr = tx_outs_attr;
|
||||
ctp.unlock_time = unlock_time;
|
||||
//TIME_MEASURE_FINISH(precalculation_time);
|
||||
transfer(ctp, tx, send_to_network, p_signed_tx_blob_str);
|
||||
transfer(ctp, tx, send_to_network, p_unsigned_filename_or_tx_blob_str);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -4767,7 +4791,7 @@ void wallet2::check_and_throw_if_self_directed_tx_with_payment_id_requested(cons
|
|||
void wallet2::transfer(const construct_tx_param& ctp,
|
||||
currency::transaction &tx,
|
||||
bool send_to_network,
|
||||
std::string* p_signed_tx_blob_str)
|
||||
std::string* p_unsigned_filename_or_tx_blob_str)
|
||||
{
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(!is_auditable() || !is_watch_only(), "You can't initiate coins transfer using an auditable watch-only wallet."); // btw, watch-only wallets can call transfer() within cold-signing process
|
||||
|
||||
|
|
@ -4780,7 +4804,7 @@ void wallet2::transfer(const construct_tx_param& ctp,
|
|||
|
||||
if (m_watch_only)
|
||||
{
|
||||
bool r = store_unsigned_tx_to_file_and_reserve_transfers(ftp, "zano_tx_unsigned", p_signed_tx_blob_str);
|
||||
bool r = store_unsigned_tx_to_file_and_reserve_transfers(ftp, (p_unsigned_filename_or_tx_blob_str != nullptr ? *p_unsigned_filename_or_tx_blob_str : "zano_tx_unsigned"), p_unsigned_filename_or_tx_blob_str);
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(r, "failed to store unsigned tx");
|
||||
WLT_LOG_GREEN("[wallet::transfer]" << " prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3), LOG_LEVEL_0);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits<uint64
|
|||
#define LOG_DEFAULT_CHANNEL "wallet"
|
||||
|
||||
// wallet-specific logging functions
|
||||
#define WLT_LOG(msg, level) LOG_PRINT("[W:" << m_log_prefix << "] " << msg, level)
|
||||
#define WLT_LOG_L0(msg) LOG_PRINT_L0("[W:" << m_log_prefix << "] " << msg)
|
||||
#define WLT_LOG_L1(msg) LOG_PRINT_L1("[W:" << m_log_prefix << "] " << msg)
|
||||
#define WLT_LOG_L2(msg) LOG_PRINT_L2("[W:" << m_log_prefix << "] " << msg)
|
||||
|
|
@ -78,6 +79,7 @@ const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits<uint64
|
|||
#define WLT_CHECK_AND_ASSERT_MES_NO_RET(expr, msg) CHECK_AND_ASSERT_MES_NO_RET(expr, "[W:" << m_log_prefix << "] " << msg)
|
||||
#define WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_INT_ERR_EX(cond, "[W:" << m_log_prefix << "] " << msg)
|
||||
#define WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, msg) THROW_IF_FALSE_WALLET_CMN_ERR_EX(cond, "[W:" << m_log_prefix << "] " << msg)
|
||||
#define WLT_THROW_IF_FALSE_WALLET_EX_MES(cond, exception_t, msg, ...) THROW_IF_FALSE_WALLET_EX_MES(cond, exception_t, "[W:" << m_log_prefix << "] " << msg, ## __VA_ARGS__)
|
||||
|
||||
class test_generator;
|
||||
|
||||
|
|
@ -88,7 +90,9 @@ namespace tools
|
|||
{
|
||||
uint64_t m_signature;
|
||||
uint16_t m_cb_keys;
|
||||
uint64_t m_cb_body;
|
||||
//uint64_t m_cb_body; <-- this field never used, soo replace it with two other variables "m_ver" + and "m_reserved"
|
||||
uint32_t m_ver;
|
||||
uint32_t m_reserved; //for future use
|
||||
};
|
||||
#pragma pack (pop)
|
||||
|
||||
|
|
@ -466,13 +470,13 @@ namespace tools
|
|||
|
||||
void assign_account(const currency::account_base& acc);
|
||||
void generate(const std::wstring& path, const std::string& password, bool auditable_wallet);
|
||||
void restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool auditable_watch_only);
|
||||
void restore(const std::wstring& path, const std::string& pass, const std::string& seed_or_tracking_seed, bool tracking_wallet);
|
||||
void load(const std::wstring& path, const std::string& password);
|
||||
void store();
|
||||
void store(const std::wstring& path);
|
||||
void store(const std::wstring& path, const std::string& password);
|
||||
void store_watch_only(const std::wstring& path, const std::string& password) const;
|
||||
bool store_keys(std::string& buff, const std::string& password, bool store_as_watch_only = false);
|
||||
bool store_keys(std::string& buff, const std::string& password, wallet2::keys_file_data& keys_file_data, bool store_as_watch_only = false);
|
||||
std::wstring get_wallet_path()const { return m_wallet_file; }
|
||||
std::string get_wallet_password()const { return m_password; }
|
||||
currency::account_base& get_account() { return m_account; }
|
||||
|
|
@ -543,7 +547,7 @@ namespace tools
|
|||
bool shuffle = true,
|
||||
uint8_t flags = 0,
|
||||
bool send_to_network = true,
|
||||
std::string* p_signed_tx_blob_str = nullptr);
|
||||
std::string* p_unsigned_filename_or_tx_blob_str = nullptr);
|
||||
|
||||
void transfer(const std::vector<currency::tx_destination_entry>& dsts,
|
||||
size_t fake_outputs_count,
|
||||
|
|
@ -563,7 +567,7 @@ namespace tools
|
|||
void transfer(const construct_tx_param& ctp,
|
||||
currency::transaction &tx,
|
||||
bool send_to_network,
|
||||
std::string* p_signed_tx_blob_str);
|
||||
std::string* p_unsigned_filename_or_tx_blob_str);
|
||||
|
||||
template<typename destination_split_strategy_t>
|
||||
void transfer_from_contract(
|
||||
|
|
@ -803,7 +807,7 @@ private:
|
|||
|
||||
void add_transfers_to_expiration_list(const std::vector<uint64_t>& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id);
|
||||
void remove_transfer_from_expiration_list(uint64_t transfer_index);
|
||||
void load_keys(const std::string& keys_file_name, const std::string& password, uint64_t file_signature);
|
||||
void load_keys(const std::string& keys_file_name, const std::string& password, uint64_t file_signature, keys_file_data& kf_data);
|
||||
void process_new_transaction(const currency::transaction& tx, uint64_t height, const currency::block& b, const std::vector<uint64_t>* pglobal_indexes);
|
||||
void fetch_tx_global_indixes(const currency::transaction& tx, std::vector<uint64_t>& goutputs_indexes);
|
||||
void fetch_tx_global_indixes(const std::list<std::reference_wrapper<const currency::transaction>>& txs, std::vector<std::vector<uint64_t>>& goutputs_indexes);
|
||||
|
|
@ -1243,6 +1247,7 @@ namespace tools
|
|||
} // namespace tools
|
||||
|
||||
#if !defined(KEEP_WALLET_LOG_MACROS)
|
||||
#undef WLT_LOG
|
||||
#undef WLT_LOG_L0
|
||||
#undef WLT_LOG_L1
|
||||
#undef WLT_LOG_L2
|
||||
|
|
@ -1257,7 +1262,9 @@ namespace tools
|
|||
#undef WLT_LOG_YELLOW
|
||||
#undef WLT_CHECK_AND_ASSERT_MES
|
||||
#undef WLT_CHECK_AND_ASSERT_MES_NO_RET
|
||||
// TODO update this list
|
||||
#undef WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX
|
||||
#undef WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX
|
||||
#undef WLT_THROW_IF_FALSE_WALLET_EX_MES
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,13 @@ namespace tools
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_transfer(const wallet_public::COMMAND_RPC_TRANSFER::request& req, wallet_public::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
if (req.fee < m_wallet.get_core_runtime_config().tx_pool_min_fee)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT;
|
||||
er.message = std::string("Given fee is too low: ") + epee::string_tools::num_to_string_fast(req.fee) + ", minimum is: " + epee::string_tools::num_to_string_fast(m_wallet.get_core_runtime_config().tx_pool_min_fee);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string payment_id;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id))
|
||||
{
|
||||
|
|
@ -306,12 +313,12 @@ namespace tools
|
|||
|
||||
currency::transaction tx;
|
||||
|
||||
std::string signed_tx_blob_str;
|
||||
m_wallet.transfer(dsts, req.mixin, 0/*req.unlock_time*/, req.fee, extra, attachments, detail::ssi_digit, tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, CURRENCY_TO_KEY_OUT_RELAXED, true, 0, true, &signed_tx_blob_str);
|
||||
std::string unsigned_tx_blob_str;
|
||||
m_wallet.transfer(dsts, req.mixin, 0/*req.unlock_time*/, req.fee, extra, attachments, detail::ssi_digit, tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, CURRENCY_TO_KEY_OUT_RELAXED, true, 0, true, &unsigned_tx_blob_str);
|
||||
if (m_wallet.is_watch_only())
|
||||
{
|
||||
res.tx_unsigned_hex = epee::string_tools::buff_to_hex_nodelimer(signed_tx_blob_str); // watch-only wallets can't sign and relay transactions
|
||||
// leave res.tx_hash empty, because tx has will change after signing
|
||||
res.tx_unsigned_hex = epee::string_tools::buff_to_hex_nodelimer(unsigned_tx_blob_str); // watch-only wallets could not sign and relay transactions
|
||||
// leave res.tx_hash empty, because tx hash will change after signing
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -853,7 +853,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
|
|||
w->load(path, password);
|
||||
if (w->is_watch_only() && !w->is_auditable())
|
||||
return API_RETURN_CODE_WALLET_WATCH_ONLY_NOT_SUPPORTED;
|
||||
#ifndef MOBILE_WALLET_BUILD
|
||||
#ifdef MOBILE_WALLET_BUILD
|
||||
//disable auditable wallets for now in mobile wallet
|
||||
if (w->is_auditable())
|
||||
{
|
||||
|
|
@ -1063,7 +1063,7 @@ std::string wallets_manager::restore_wallet(const std::wstring& path, const std:
|
|||
{
|
||||
bool auditable_watch_only = restore_key.find(':') != std::string::npos;
|
||||
w->restore(path, password, restore_key, auditable_watch_only);
|
||||
#ifndef MOBILE_WALLET_BUILD
|
||||
#ifdef MOBILE_WALLET_BUILD
|
||||
//disable auditable wallets for now in mobile wallet
|
||||
if (w->is_auditable())
|
||||
{
|
||||
|
|
@ -1354,7 +1354,16 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par
|
|||
}
|
||||
}
|
||||
w->get()->transfer(dsts, tp.mixin_count, unlock_time ? unlock_time + 1 : 0, fee, extra, attachments, res_tx);
|
||||
//update_wallets_info();
|
||||
}
|
||||
catch (const tools::error::not_enough_money& e)
|
||||
{
|
||||
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "Transfer error: not enough money: " << e.what());
|
||||
return API_RETURN_CODE_NOT_ENOUGH_MONEY;
|
||||
}
|
||||
catch (const tools::error::not_enough_outs_to_mix& e)
|
||||
{
|
||||
LOG_ERROR(get_wallet_log_prefix(wallet_id) + "Transfer error: not outs to mix: " << e.what());
|
||||
return API_RETURN_CODE_NOT_ENOUGH_OUTPUTS_FOR_MIXING;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
@ -1617,8 +1626,12 @@ std::string wallets_manager::get_mining_history(uint64_t wallet_id, tools::walle
|
|||
std::string wallets_manager::get_wallet_restore_info(uint64_t wallet_id, std::string& restore_key)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
|
||||
if (wo.wallet_state != view::wallet_status_info::wallet_state_ready || wo.long_refresh_in_progress)
|
||||
return API_RETURN_CODE_CORE_BUSY;
|
||||
|
||||
restore_key = wo.w->get()->get_account().get_seed_phrase();
|
||||
// restore_key = tools::base58::encode(rst_data);
|
||||
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
void wallets_manager::prepare_wallet_status_info(wallet_vs_options& wo, view::wallet_status_info& wsi)
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ add_executable(net_load_tests_srv net_load_tests/srv.cpp)
|
|||
|
||||
add_dependencies(coretests version)
|
||||
|
||||
target_link_libraries(coretests rpc currency_core common crypto wallet zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(functional_tests rpc wallet currency_core crypto common zlibstatic ethash libminiupnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(hash-tests crypto ethash)
|
||||
target_link_libraries(hash-target-tests crypto currency_core ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(performance_tests currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(unit_tests wallet currency_core crypto common gtest_main zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(unit_tests wallet currency_core common crypto gtest_main zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(net_load_tests_clt currency_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(net_load_tests_srv currency_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ bool chain_switching_when_gindex_spent_in_both_chains::generate(std::vector<test
|
|||
// 0 1 11 12 13 14 < height
|
||||
// (0 )- (1 )...(1r)- (2 )- (3 )- < main chain
|
||||
// ^ \ tx_1 < txs
|
||||
// | \
|
||||
// | \
|
||||
// | \-(2a)- (3a)- (4a)- < alt chain
|
||||
// + tx_1 < txs
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ bool alt_chain_coins_pow_mined_then_spent::generate(std::vector<test_event_entry
|
|||
|
||||
// 0 1 2 12 13
|
||||
// (0 )- (1 )- . . . (1r)-
|
||||
// \
|
||||
// \
|
||||
// \- (2a)...(2ra)- (3a)-
|
||||
// |
|
||||
// +-------------tx_1 tx_1 spents 2a.miner_tx output
|
||||
|
|
@ -540,7 +540,7 @@ bool alt_blocks_validation_and_same_new_amount_in_two_txs::generate(std::vector<
|
|||
|
||||
// 0 1 11 12 13
|
||||
// (0 )- (1 )-...(1r)- (2 )- (3 )-
|
||||
// \
|
||||
// \
|
||||
// \- (2a)- (3a)-
|
||||
// tx_1
|
||||
// tx_2
|
||||
|
|
@ -573,7 +573,7 @@ bool alt_blocks_with_the_same_txs::generate(std::vector<test_event_entry>& event
|
|||
// 0 1 11 12 13 14
|
||||
// (0 )- (1 )-...(1r)- (2 )- (3 )-
|
||||
// \ tx_0
|
||||
// \
|
||||
// \
|
||||
// \- (2a)- (3a)- (4 )-
|
||||
// tx_0
|
||||
|
||||
|
|
|
|||
|
|
@ -923,7 +923,7 @@ bool pos_altblocks_validation::generate(std::vector<test_event_entry>& events) c
|
|||
// +-----------------------+
|
||||
// | tx_0 tx_0 spends all outputs in blk_1 (main chain)
|
||||
// (0 )- (1 )-...(1r)- (2 )- (3 )-...(3r)- (4 )- (5 )- <- main chain
|
||||
// | \
|
||||
// | \
|
||||
// | \- (2a)- <- alt chain
|
||||
// +--------------+ PoS block 2a uses stake already spent in main chain
|
||||
|
||||
|
|
@ -941,7 +941,7 @@ bool pos_altblocks_validation::generate(std::vector<test_event_entry>& events) c
|
|||
// +-----------------------+
|
||||
// | tx_0 tx_0 spends all outputs in blk_1 (main chain)
|
||||
// (0 )- (1 )-...(1r)- (2 )- (3 )-...(3r)- (4 )- (5 )- <- main chain
|
||||
// || \
|
||||
// || \
|
||||
// || \- (2a)- #3a#- <- alt chain
|
||||
// |+--------------+ | PoS block 2a uses stake already spent in main chain (okay)
|
||||
// +-----------------------+ PoS block 3a uses stake already spent in current alt chain (fail)
|
||||
|
|
@ -962,11 +962,11 @@ bool pos_altblocks_validation::generate(std::vector<test_event_entry>& events) c
|
|||
// +-----------------------+
|
||||
// | tx_0 tx_0 spends all outputs in blk_1 (main chain)
|
||||
// (0 )- (1 )-...(1r)- (2 )- (3 )- ........ (3r)- (4 )- (5 )- <- main chain
|
||||
// || \
|
||||
// || \
|
||||
// || \- (2a)- #3a#- <- alt chain
|
||||
// |+--------------+ \ | PoS block 2a uses stake already spent in main chain (okay)
|
||||
// +---------------|-------+ PoS block 3a uses stake already spent in current alt chain (fail)
|
||||
// | \
|
||||
// | \
|
||||
// | \ ...... (2br)- (3b)- <- alt chain
|
||||
// | |
|
||||
// +-----------------------+ PoS block 3b uses as stake an output, created in current alt chain (2a)
|
||||
|
|
@ -989,7 +989,7 @@ bool pos_altblocks_validation::generate(std::vector<test_event_entry>& events) c
|
|||
// || \- (2a)- #3a#- | <- alt chain
|
||||
// |+--------------+ \ | \ PoS block 2a uses stake already spent in main chain (okay)
|
||||
// +---------------|-------+ \ PoS block 3a uses stake already spent in current alt chain (fail)
|
||||
// | \ \
|
||||
// | \ \
|
||||
// | \ ...... (2br)- (3b)- #4b# <- alt chain
|
||||
// | |
|
||||
// +-----------------------+ PoS block 3b uses as stake an output, created in current alt chain (2a)
|
||||
|
|
|
|||
|
|
@ -1379,7 +1379,7 @@ bool tx_expiration_time_and_chain_switching::generate(std::vector<test_event_ent
|
|||
// 0 ... 20 21 22 23 24 <- height
|
||||
// (0 )- (0r)- (1 )- <- chain A
|
||||
// | tx_1
|
||||
// \
|
||||
// \
|
||||
// \ (1b)- (2b)- <- chain B (became main after 2b)
|
||||
//
|
||||
MAKE_NEXT_BLOCK(events, blk_1b, blk_0r, miner_acc);
|
||||
|
|
@ -1393,7 +1393,7 @@ bool tx_expiration_time_and_chain_switching::generate(std::vector<test_event_ent
|
|||
// 0 ... 20 21 22 23 24 <- height
|
||||
// (0 )- (0r)- (1 )- <- chain A
|
||||
// | tx_1
|
||||
// \
|
||||
// \
|
||||
// \ (1b)- (2b)- !3b!- <- chain B, block 3b is rejected because tx_1 is already expired
|
||||
// tx_1
|
||||
|
||||
|
|
@ -1411,7 +1411,7 @@ bool tx_expiration_time_and_chain_switching::generate(std::vector<test_event_ent
|
|||
// 0 ... 20 21 22 23 24 <- height
|
||||
// (0 )- (0r)- (1 )- <- chain A
|
||||
// | tx_1
|
||||
// |\
|
||||
// |\
|
||||
// | \ (1b)- (2b)- <- chain B
|
||||
// |
|
||||
// \- (1c)- (2c)- (3c)- <- chain C
|
||||
|
|
@ -1432,7 +1432,7 @@ bool tx_expiration_time_and_chain_switching::generate(std::vector<test_event_ent
|
|||
// 0 ... 20 21 22 23 24 <- height
|
||||
// (0 )- (0r)- (1 )- <- chain A
|
||||
// | tx_1
|
||||
// |\
|
||||
// |\
|
||||
// | \ (1b)- (2b)- (3b)- (4b)- <- chain B
|
||||
// |
|
||||
// \- (1c)- (2c)- (3c)- <- chain C
|
||||
|
|
|
|||
186
tests/performance_tests/chacha_stream_performance_test.cpp
Normal file
186
tests/performance_tests/chacha_stream_performance_test.cpp
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
// Copyright (c) 2014-2015 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/iostreams/invert.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
||||
#include "common/encryption_filter.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "currency_core/blockchain_storage_basic.h"
|
||||
#include "currency_core/blockchain_storage_boost_serialization.h"
|
||||
#include "common/boost_serialization_helper.h"
|
||||
|
||||
|
||||
bool perform_crypt_stream_iteration(const std::list<currency::block_extended_info>& test_list, const crypto::chacha8_iv& iv)
|
||||
{
|
||||
std::list<currency::block_extended_info> verification_list;
|
||||
boost::filesystem::ofstream store_data_file;
|
||||
store_data_file.open("./test.bin", std::ios_base::binary | std::ios_base::out | std::ios::trunc);
|
||||
tools::encrypt_chacha_out_filter encrypt_filter("pass", iv);
|
||||
boost::iostreams::filtering_ostream out;
|
||||
out.push(encrypt_filter);
|
||||
out.push(store_data_file);
|
||||
|
||||
|
||||
//out << buff;
|
||||
bool res = tools::portble_serialize_obj_to_stream(test_list, out);
|
||||
|
||||
out.flush();
|
||||
store_data_file.close();
|
||||
|
||||
boost::filesystem::ifstream data_file;
|
||||
data_file.open("./test.bin", std::ios_base::binary | std::ios_base::in);
|
||||
tools::encrypt_chacha_in_filter decrypt_filter("pass", iv);
|
||||
|
||||
boost::iostreams::filtering_istream in;
|
||||
in.push(decrypt_filter);
|
||||
in.push(data_file);
|
||||
try {
|
||||
|
||||
bool res2 = tools::portable_unserialize_obj_from_stream(verification_list, in);
|
||||
CHECK_AND_ASSERT_MES(res, false, "Failed to unserialize wallet");
|
||||
size_t i = 0;
|
||||
CHECK_AND_ASSERT_MES(test_list.size() == verification_list.size(), false, "restored list is wrong size");
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& err)
|
||||
{
|
||||
LOG_ERROR("Exception: " << err.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool perform_just_substream_stream_iteration(const std::list<currency::block_extended_info>& test_list, const crypto::chacha8_iv& iv)
|
||||
{
|
||||
std::list<currency::block_extended_info> verification_list;
|
||||
boost::filesystem::ofstream store_data_file;
|
||||
store_data_file.open("./test3.bin", std::ios_base::binary | std::ios_base::out | std::ios::trunc);
|
||||
//encrypt_chacha_out_filter encrypt_filter("pass", iv);
|
||||
boost::iostreams::filtering_ostream out;
|
||||
//out.push(encrypt_filter);
|
||||
out.push(store_data_file);
|
||||
|
||||
|
||||
//out << buff;
|
||||
bool res = tools::portble_serialize_obj_to_stream(test_list, out);
|
||||
|
||||
out.flush();
|
||||
store_data_file.close();
|
||||
|
||||
boost::filesystem::ifstream data_file;
|
||||
data_file.open("./test3.bin", std::ios_base::binary | std::ios_base::in);
|
||||
//encrypt_chacha_in_filter decrypt_filter("pass", iv);
|
||||
|
||||
boost::iostreams::filtering_istream in;
|
||||
//in.push(decrypt_filter);
|
||||
in.push(data_file);
|
||||
try {
|
||||
|
||||
bool res2 = tools::portable_unserialize_obj_from_stream(verification_list, in);
|
||||
CHECK_AND_ASSERT_MES(res, false, "Failed to unserialize wallet");
|
||||
size_t i = 0;
|
||||
CHECK_AND_ASSERT_MES(test_list.size() == verification_list.size(), false, "restored list is wrong size");
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& err)
|
||||
{
|
||||
LOG_ERROR("Exception: " << err.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool perform_no_crypt_stream_iteration(const std::list<currency::block_extended_info>& test_list, const crypto::chacha8_iv& iv)
|
||||
{
|
||||
std::list<currency::block_extended_info> verification_list;
|
||||
boost::filesystem::ofstream store_data_file;
|
||||
store_data_file.open("./test2.bin", std::ios_base::binary | std::ios_base::out | std::ios::trunc);
|
||||
// encrypt_chacha_out_filter encrypt_filter("pass", iv);
|
||||
// boost::iostreams::filtering_ostream out;
|
||||
// out.push(encrypt_filter);
|
||||
// out.push(store_data_file);
|
||||
|
||||
|
||||
//out << buff;
|
||||
bool res = tools::portble_serialize_obj_to_stream(test_list, store_data_file);
|
||||
|
||||
store_data_file.flush();
|
||||
store_data_file.close();
|
||||
|
||||
boost::filesystem::ifstream data_file;
|
||||
data_file.open("./test2.bin", std::ios_base::binary | std::ios_base::in);
|
||||
// encrypt_chacha_in_filter decrypt_filter("pass", iv);
|
||||
|
||||
// boost::iostreams::filtering_istream in;
|
||||
// in.push(decrypt_filter);
|
||||
// in.push(data_file);
|
||||
try {
|
||||
|
||||
bool res2 = tools::portable_unserialize_obj_from_stream(verification_list, data_file);
|
||||
CHECK_AND_ASSERT_MES(res, false, "Failed to unserialize wallet");
|
||||
size_t i = 0;
|
||||
CHECK_AND_ASSERT_MES(test_list.size() == verification_list.size(), false, "restored list is wrong size");
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& err)
|
||||
{
|
||||
LOG_ERROR("Exception: " << err.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool do_chacha_stream_performance_test()
|
||||
{
|
||||
LOG_PRINT_L0("chacha_stream_test");
|
||||
std::list<currency::block_extended_info> test_list;
|
||||
for (size_t i = 0; i != 10000; i++) {
|
||||
test_list.push_back(currency::block_extended_info());
|
||||
test_list.back().height = i;
|
||||
test_list.back().this_block_tx_fee_median = i;
|
||||
}
|
||||
|
||||
|
||||
crypto::chacha8_iv iv = crypto::rand<crypto::chacha8_iv>();
|
||||
LOG_PRINT_L0("Running substream stream performance tests...");
|
||||
TIME_MEASURE_START(substream_version);
|
||||
for (size_t i = 0; i != 100; i++)
|
||||
{
|
||||
bool r = perform_just_substream_stream_iteration(test_list, iv);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to perform_crypt_stream_iteration");
|
||||
}
|
||||
TIME_MEASURE_FINISH(substream_version);
|
||||
LOG_PRINT_L0("OK.time: " << substream_version);
|
||||
LOG_PRINT_L0("Running crypt stream performance tests...");
|
||||
TIME_MEASURE_START(crypted_version);
|
||||
for (size_t i = 0; i != 100; i++)
|
||||
{
|
||||
bool r = perform_crypt_stream_iteration(test_list, iv);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to perform_crypt_stream_iteration");
|
||||
}
|
||||
TIME_MEASURE_FINISH(crypted_version);
|
||||
LOG_PRINT_L0("OK.time: " << crypted_version);
|
||||
LOG_PRINT_L0("Running non-crypt stream performance tests...");
|
||||
TIME_MEASURE_START(non_crypted_version);
|
||||
for (size_t i = 0; i != 100; i++)
|
||||
{
|
||||
bool r = perform_no_crypt_stream_iteration(test_list, iv);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to perform_crypt_stream_iteration");
|
||||
}
|
||||
TIME_MEASURE_FINISH(non_crypted_version);
|
||||
LOG_PRINT_L0("OK.time: " << non_crypted_version);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
7
tests/performance_tests/chacha_stream_performance_test.h
Normal file
7
tests/performance_tests/chacha_stream_performance_test.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2014-2015 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#pragma once
|
||||
|
||||
bool do_chacha_stream_performance_test();
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include "is_out_to_acc.h"
|
||||
#include "core_market_performance_test.h"
|
||||
#include "serialization_performance_test.h"
|
||||
#include "chacha_stream_performance_test.h"
|
||||
#include "keccak_test.h"
|
||||
#include "blake2_test.h"
|
||||
#include "print_struct_to_json.h"
|
||||
|
|
@ -38,9 +39,10 @@ int main(int argc, char** argv)
|
|||
set_process_affinity(1);
|
||||
set_thread_high_priority();
|
||||
|
||||
do_chacha_stream_performance_test();
|
||||
//test_blake2();
|
||||
|
||||
free_space_check();
|
||||
//free_space_check();
|
||||
|
||||
//print_struct_to_json();
|
||||
|
||||
|
|
|
|||
142
tests/unit_tests/chacha_stream_test.cpp
Normal file
142
tests/unit_tests/chacha_stream_test.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
// Copyright (c) 2012-2014 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/iostreams/invert.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
||||
#include "common/encryption_filter.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "currency_core/blockchain_storage_basic.h"
|
||||
#include "currency_core/blockchain_storage_boost_serialization.h"
|
||||
#include "common/boost_serialization_helper.h"
|
||||
|
||||
|
||||
TEST(chacha_stream_test, basic_test_with_serialization_on_top)
|
||||
{
|
||||
LOG_PRINT_L0("chacha_stream_test");
|
||||
std::list<currency::block_extended_info> test_list;
|
||||
for(size_t i = 0; i != 1000; i++) {
|
||||
test_list.push_back(currency::block_extended_info());
|
||||
test_list.back().height = i;
|
||||
test_list.back().this_block_tx_fee_median = i;
|
||||
}
|
||||
|
||||
std::list<currency::block_extended_info> verification_list;
|
||||
crypto::chacha8_iv iv = crypto::rand<crypto::chacha8_iv>();
|
||||
boost::filesystem::ofstream store_data_file;
|
||||
store_data_file.open("./test.bin", std::ios_base::binary | std::ios_base::out | std::ios::trunc);
|
||||
tools::encrypt_chacha_out_filter encrypt_filter("pass", iv);
|
||||
boost::iostreams::filtering_ostream out;
|
||||
out.push(encrypt_filter);
|
||||
out.push(store_data_file);
|
||||
|
||||
|
||||
//out << buff;
|
||||
bool res = tools::portble_serialize_obj_to_stream(test_list, out);
|
||||
|
||||
out.flush();
|
||||
store_data_file.close();
|
||||
|
||||
boost::filesystem::ifstream data_file;
|
||||
data_file.open("./test.bin", std::ios_base::binary | std::ios_base::in);
|
||||
tools::encrypt_chacha_in_filter decrypt_filter("pass", iv);
|
||||
|
||||
boost::iostreams::filtering_istream in;
|
||||
in.push(decrypt_filter);
|
||||
in.push(data_file);
|
||||
try {
|
||||
|
||||
bool res2 = tools::portable_unserialize_obj_from_stream(verification_list, in);
|
||||
ASSERT_TRUE(res2);
|
||||
size_t i = 0;
|
||||
for(auto vle: verification_list) {
|
||||
ASSERT_TRUE(vle.height == i);
|
||||
ASSERT_TRUE(vle.this_block_tx_fee_median == i);
|
||||
i++;
|
||||
}
|
||||
//if(verification_list != test_list)
|
||||
}
|
||||
catch (std::exception& err)
|
||||
{
|
||||
std::cout << err.what();
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST(chacha_stream_test, diversity_test_on_different_stream_behaviour)
|
||||
{
|
||||
LOG_PRINT_L0("chacha_stream_test");
|
||||
//prepare buff
|
||||
const size_t buff_size = 10000;
|
||||
std::string buff(buff_size, ' ');
|
||||
for(size_t i = 0; i != buff_size; i++) {
|
||||
buff[i] = i % 255;
|
||||
}
|
||||
|
||||
crypto::chacha8_iv iv = crypto::rand<crypto::chacha8_iv>();
|
||||
boost::filesystem::ofstream store_data_file;
|
||||
store_data_file.open("./test.bin", std::ios_base::binary | std::ios_base::out | std::ios::trunc);
|
||||
tools::encrypt_chacha_out_filter encrypt_filter("pass", iv);
|
||||
//boost::iostreams::stream<encrypt_chacha_sink> outputStream(sink_encrypt);
|
||||
boost::iostreams::filtering_ostream out;
|
||||
out.push(encrypt_filter);
|
||||
out.push(store_data_file);
|
||||
|
||||
out << buff;
|
||||
|
||||
out.flush();
|
||||
store_data_file.close();
|
||||
for (size_t d = 0; d != 1000; d++)
|
||||
{
|
||||
boost::filesystem::ifstream data_file;
|
||||
data_file.open("./test.bin", std::ios_base::binary | std::ios_base::in);
|
||||
tools::encrypt_chacha_in_filter decrypt_filter("pass", iv);
|
||||
|
||||
boost::iostreams::filtering_istream in;
|
||||
in.push(decrypt_filter);
|
||||
in.push(data_file);
|
||||
|
||||
std::string str(buff_size + 100, ' ');
|
||||
try {
|
||||
|
||||
size_t offset = 0;
|
||||
while (offset < buff_size+1)
|
||||
{
|
||||
std::streamsize count = std::rand() % 100;
|
||||
// if (count + offset > buff_size)
|
||||
// {
|
||||
// count = buff_size - offset;
|
||||
// }
|
||||
in.read((char*)&str.data()[offset], count);
|
||||
//self check
|
||||
size_t readed_sz = in.gcount();
|
||||
if (!(count + offset > buff_size || readed_sz == count))
|
||||
{
|
||||
ASSERT_TRUE(count + offset > buff_size || readed_sz == count);
|
||||
}
|
||||
offset += readed_sz;
|
||||
if (!in) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in) {
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
std::cout << "OK";
|
||||
}
|
||||
catch (std::exception& err) {
|
||||
std::cout << err.what();
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
}
|
||||
std::cout << "Finished OK!";
|
||||
|
||||
}
|
||||
86
utils/munin_plugins/_link_munin_plugins.sh
Executable file
86
utils/munin_plugins/_link_munin_plugins.sh
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
|
||||
# Note: if using MDBX engine uncomment corresponding lines below
|
||||
|
||||
|
||||
cd /etc/munin/plugins/
|
||||
|
||||
rm -f aliases
|
||||
rm -f alt_blocks_count
|
||||
rm -f block_size
|
||||
rm -f blockchain_lmdb_data_file_size
|
||||
rm -f blockchain_mdbx_data_file_size
|
||||
rm -f db_map_size
|
||||
rm -f db_transactions_count
|
||||
rm -f emission
|
||||
rm -f grey_peerlist_size
|
||||
rm -f hashrate
|
||||
rm -f height
|
||||
rm -f incoming_connections_count
|
||||
rm -f market
|
||||
rm -f outgoing_connections_count
|
||||
rm -f outs_stat
|
||||
rm -f performance_block
|
||||
rm -f performance_pool
|
||||
rm -f performance_transaction
|
||||
rm -f performance_transaction_inp
|
||||
rm -f performance_transaction_inp_loop
|
||||
rm -f performance_transaction_inp_loop_scan_loop
|
||||
rm -f poolstate_lmdb_data_file_size
|
||||
rm -f poolstate_mdbx_data_file_size
|
||||
rm -f pos_block_ts_shift_vs_actual
|
||||
rm -f pos_dif_to_total_coins
|
||||
rm -f pos_difficulty
|
||||
rm -f pow_difficulty
|
||||
rm -f reward
|
||||
rm -f seconds_per_blocks
|
||||
rm -f sequence_factor
|
||||
rm -f timestamps
|
||||
rm -f tx_count
|
||||
rm -f tx_daily_count
|
||||
rm -f tx_daily_volume
|
||||
rm -f tx_per_block
|
||||
rm -f tx_pool_size
|
||||
rm -f white_peerlist_size
|
||||
|
||||
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/aliases
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/alt_blocks_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/block_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/blockchain_lmdb_data_file_size
|
||||
#ln -s /home/project/zano_for_munin/utils/munin_plugins/blockchain_mdbx_data_file_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/db_map_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/db_transactions_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/emission
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/grey_peerlist_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/hashrate
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/height
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/incoming_connections_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/market
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/outgoing_connections_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/outs_stat
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_block
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_pool
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_transaction
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_transaction_inp
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_transaction_inp_loop
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/performance_transaction_inp_loop_scan_loop
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/poolstate_lmdb_data_file_size
|
||||
#ln -s /home/project/zano_for_munin/utils/munin_plugins/poolstate_mdbx_data_file_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/pos_block_ts_shift_vs_actual
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/pos_dif_to_total_coins
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/pos_difficulty
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/pow_difficulty
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/reward
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/seconds_per_blocks
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/sequence_factor
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/timestamps
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/tx_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/tx_daily_count
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/tx_daily_volume
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/tx_per_block
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/tx_pool_size
|
||||
ln -s /home/project/zano_for_munin/utils/munin_plugins/white_peerlist_size
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title blockchain_data_file_size
|
||||
graph_vlabel blockchain_data_file_size
|
||||
graph_category daemon
|
||||
blockchain_data_file_size.label blockchain_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "blockchain_data_file_size.value "
|
||||
#sudo ls -l /tmp/ttt | cut -d" " -f5
|
||||
sudo ls -l /root/.Zano/blockchain/data.mdb | cut -d" " -f5
|
||||
15
utils/munin_plugins/blockchain_lmdb_data_file_size
Executable file
15
utils/munin_plugins/blockchain_lmdb_data_file_size
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title blockchain_lmdb_data_file_size
|
||||
graph_vlabel blockchain_lmdb_data_file_size
|
||||
graph_category daemon
|
||||
blockchain_lmdb_data_file_size.label blockchain_lmdb_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "blockchain_lmdb_data_file_size.value "
|
||||
sudo ls -l /root/.Zano/blockchain_lmdb_v1/data.mdb | cut -d" " -f5
|
||||
15
utils/munin_plugins/blockchain_mdbx_data_file_size
Executable file
15
utils/munin_plugins/blockchain_mdbx_data_file_size
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title blockchain_mdbx_data_file_size
|
||||
graph_vlabel blockchain_mdbx_data_file_size
|
||||
graph_category daemon
|
||||
blockchain_mdbx_data_file_size.label blockchain_mdbx_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "blockchain_mdbx_data_file_size.value "
|
||||
sudo ls -l /root/.Zano/blockchain_mdbx_v1/mdbx.dat | cut -d" " -f5
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title poolstate_data_file_size
|
||||
graph_vlabel poolstate_data_file_size
|
||||
graph_category daemon
|
||||
poolstate_data_file_size.label poolstate_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "poolstate_data_file_size.value "
|
||||
#sudo ls -l /tmp/ttt | cut -d" " -f5
|
||||
sudo ls -l /root/.Zano/poolstate/data.mdb | cut -d" " -f5
|
||||
15
utils/munin_plugins/poolstate_lmdb_data_file_size
Executable file
15
utils/munin_plugins/poolstate_lmdb_data_file_size
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title poolstate_lmdb_data_file_size
|
||||
graph_vlabel poolstate_lmdb_data_file_size
|
||||
graph_category daemon
|
||||
poolstate_lmdb_data_file_size.label poolstate_lmdb_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "poolstate_lmdb_data_file_size.value "
|
||||
sudo ls -l /root/.Zano/poolstate_lmdb_v1/data.mdb | cut -d" " -f5
|
||||
15
utils/munin_plugins/poolstate_mdbx_data_file_size
Executable file
15
utils/munin_plugins/poolstate_mdbx_data_file_size
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
config)
|
||||
cat <<'EOM'
|
||||
graph_title poolstate_mdbx_data_file_size
|
||||
graph_vlabel poolstate_mdbx_data_file_size
|
||||
graph_category daemon
|
||||
poolstate_mdbx_data_file_size.label poolstate_mdbx_data_file_size
|
||||
EOM
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
printf "poolstate_mdbx_data_file_size.value "
|
||||
sudo ls -l /root/.Zano/poolstate_mdbx_v1/mdbx.dat | cut -d" " -f5
|
||||
0
utils/munin_plugins/sequence_factor
Normal file → Executable file
0
utils/munin_plugins/sequence_factor
Normal file → Executable file
Loading…
Add table
Reference in a new issue