1
0
Fork 0
forked from lthn/blockchain

Merge branch 'LetheanMovement-main' into iTw3

This commit is contained in:
Snider 2024-03-21 13:16:56 +00:00
commit 36008ecb18
152 changed files with 2956 additions and 2159 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
build
.idea

2
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,2 @@
github: [letheanVPN]
open_collective: lthn

161
.github/workflows/cli-testnet.yml vendored Normal file
View file

@ -0,0 +1,161 @@
name: cli-testnet
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
CCACHE_SETTINGS: |
ccache --max-size=150M
ccache --set-config=compression=true
jobs:
linux-amd64:
runs-on: ubuntu-20.04
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-cli
restore-keys: ccache-${{ runner.os }}-build-testnet-cli
- name: update apt
run: sudo apt update
- name: install dependencies
run: sudo apt-get install -y python-dev autotools-dev libboost-all-dev libicu-dev libbz2-dev git screen checkinstall zlib1g-dev ccache miniupnpc
- name: build server
run: |
${{env.CCACHE_SETTINGS}}
./utils/build/testnet_linux_cli.sh
- name: Move Tarball
run: cd build/release && mv lethean-linux-cli-*.tar.bz2 ../../
- uses: actions/upload-artifact@v3
with:
name: lethean-linux-cli
if-no-files-found: error
path: lethean-linux-cli-*.tar.bz2
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.workspace }}/lethean-linux-cli-*.tar.bz2
macos-amd64:
runs-on: macos-latest
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-cli
restore-keys: ccache-${{ runner.os }}-build-testnet-cli
- name: install dependencies
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl boost icu4c ccache miniupnpc
- name: build server
env:
PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig"
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3"
ZANO_BOOST_ROOT: "/opt/homebrew/opt/boost"
ZANO_BOOST_LIBS_PATH: "/opt/homebrew/opt/boost/lib"
CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk"
run: |
${{env.CCACHE_SETTINGS}}
export LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/icu4c/lib
./utils/build/testnet_mac_osx_cli.sh
- name: Move Tarball
run: cd build/release && mv lethean-macos-cli-*.tar.bz2 ../../
- uses: actions/upload-artifact@v3
with:
name: lethean-macos-cli
if-no-files-found: error
path: lethean-macos-cli-*.tar.bz2
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.workspace }}/lethean-macos-cli-*.tar.bz2
windows-amd64:
runs-on: windows-latest
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-cli
restore-keys: ccache-${{ runner.os }}-build-testnet-cli
- name: Eat the Choco
run: |
choco install openssl --version 1.1.1.1500 -y
choco install ccache -y
choco install zip -y
- name: install msvc toolset
uses: ilammy/msvc-dev-cmd@v1
- name: Install boost
uses: MarkusJx/install-boost@v2.4.1
id: install-boost
with:
# REQUIRED: Specify the required boost version
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
boost_version: 1.80.0
platform_version: 2022
toolset: msvc
link: static
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: build server
env:
QT_PREFIX_PATH: C:\ProgramData\chocolatey\lib\Qt5.11.2\5.11.2
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
LOCAL_BOOST_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}
OPENSSL_ROOT_DIR: "C:\\Program Files\\OpenSSL-Win64"
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
run: |
refreshenv
${{env.CCACHE_SETTINGS}}
.\utils\build\testnet_windows_cli.bat
- uses: actions/upload-artifact@v3
with:
name: lethean-windows-cli
if-no-files-found: error
path: ${{ github.workspace }}\lethean-win-cli-*.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
lethean-win-cli-*

67
.github/workflows/dockerhub-testnet.yml vendored Normal file
View file

@ -0,0 +1,67 @@
name: chain-itw3:testnet
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches:
- main
tags:
- v*
paths-ignore:
- '**.md'
pull_request:
branches:
- main
tags:
- v*
paths-ignore:
- '**.md'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to GitHub Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Build
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v3
with:
context: .
file: utils/docker/Dockerfile
cache-to: ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.ref_name }}
cache-from: ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.ref_name }}
push: true
tags: lthn/chain:testnet-${{ github.ref_name }},ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.ref_name }}
- name: Docker Build
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
context: .
file: utils/docker/Dockerfile
cache-to: ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.head_ref }}
cache-from: ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.head_ref }}
push: true
tags: lthn/chain:testnet-${{ github.head_ref }},ghcr.io/letheanvpn/blockchain-itw3:testnet-${{ github.head_ref }}

170
.github/workflows/gui-testnet.yml vendored Normal file
View file

@ -0,0 +1,170 @@
name: "gui-testnet"
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
CCACHE_SETTINGS: |
ccache --max-size=150M
ccache --set-config=compression=true
jobs:
linux-amd64:
runs-on: ubuntu-20.04
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-gui
restore-keys: ccache-${{ runner.os }}-build-testnet-gui
- name: update apt
run: sudo apt update
- name: install dependencies
run: sudo apt-get install -y qt5-default qtwebengine5-dev libqt5websockets5-dev python-dev autotools-dev libboost-all-dev libicu-dev libbz2-dev git screen checkinstall zlib1g-dev ccache miniupnpc
- name: build server
env:
QT_PREFIX_PATH: /usr/lib/qt5
run: |
${{env.CCACHE_SETTINGS}}
./utils/build/testnet_linux_gui.sh
- uses: actions/upload-artifact@v3
with:
name: lethean-gui-bundle-linux-testnet-x86_64
if-no-files-found: error
path: lethean-gui-bundle-linux-testnet-x86_64.tar.bz2
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.workspace }}/lethean-gui-bundle-linux-testnet-x86_64.tar.bz2
macos-amd64:
runs-on: macos-latest
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-gui
restore-keys: ccache-${{ runner.os }}-build-testnet-gui
- name: install dependencies
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl boost icu4c ccache miniupnpc qt@5
- name: build server
env:
PKG_CONFIG_PATH: "/usr/local/opt/openssl@3/lib/pkgconfig"
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl@3"
ZANO_BOOST_ROOT: "/usr/local/opt/boost"
ZANO_BOOST_LIBS_PATH: "/usr/local/opt/boost/lib"
ZANO_QT_PATH: "/usr/local/opt/qt@5"
CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk"
run: |
${{env.CCACHE_SETTINGS}}
export LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/icu4c/lib
./utils/build/testnet_mac_osx_gui.sh
- uses: actions/upload-artifact@v3
with:
name: lethean-gui-bundle-macos-testnet-i386
if-no-files-found: error
path: lethean-gui-bundle-macos-testnet-i386.tar.bz2
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.workspace }}/lethean-gui-bundle-macos-testnet-i386.tar.bz2
windows-amd64:
runs-on: windows-latest
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: cCache Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-build-testnet-gui
restore-keys: ccache-${{ runner.os }}-build-testnet-gui
- name: Eat the Choco
run: |
choco install openssl --version 1.1.1.1500 -y
choco install ccache -y
choco install zip -y
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '5.15.2'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
dir: '${{ github.workspace }}/example/'
modules: 'qtcharts qtwebengine'
tools: 'tools_cmake tools_vcredist'
cache: true
- name: install msvc toolset
uses: ilammy/msvc-dev-cmd@v1
- name: Install boost
uses: MarkusJx/install-boost@v2.4.1
id: install-boost
with:
# REQUIRED: Specify the required boost version
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
boost_version: 1.80.0
platform_version: 2022
toolset: msvc
link: static
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: build server
env:
QT_PREFIX_PATH: ${{ github.workspace }}/example/Qt/5.15.2/win64_msvc2019_64
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
LOCAL_BOOST_PATH: ${{ steps.install-boost.outputs.BOOST_ROOT }}
OPENSSL_ROOT_DIR: "C:\\Program Files\\OpenSSL-Win64"
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
run: |
${{env.CCACHE_SETTINGS}}
.\utils\build\testnet_windows_gui.bat
- uses: actions/upload-artifact@v3
with:
name: lethean-gui-bundle-win-testnet-x64
if-no-files-found: error
path: ${{ github.workspace }}\lethean-gui-bundle-win-testnet-x64.zip
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
lethean-gui-bundle-win-testnet-*

1
.gitignore vendored
View file

@ -5,5 +5,6 @@
._.DS_Store
Thumbs.db
._*
out
.idea
.vs/*

4
.gitmodules vendored
View file

@ -1,6 +1,10 @@
[submodule "contrib/miniupnp"]
path = contrib/miniupnp
url = https://github.com/miniupnp/miniupnp
[submodule "contrib/tor-connect"]
path = contrib/tor-connect
url = https://github.com/letheanVPN/tor-connect.git
branch = main
[submodule "src/gui/qt-daemon/layout"]
path = src/gui/qt-daemon/layout
url = https://github.com/hyle-team/zano_ui.git

1
.idea/.name generated Normal file
View file

@ -0,0 +1 @@
Lethean

2
.idea/blockchain-iTw3.iml generated Normal file
View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

9
.idea/cmake.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeSharedSettings">
<configurations>
<configuration PROFILE_NAME="Debug-gcc" ENABLED="false" GENERATION_DIR="build" CONFIG_NAME="Debug" TOOLCHAIN_NAME="gcc" GENERATION_OPTIONS="-G &quot;Unix Makefiles&quot; -D TESTNET=TRUE" />
<configuration PROFILE_NAME="Release" ENABLED="true" GENERATION_DIR="build" CONFIG_NAME="Release" GENERATION_OPTIONS="-D TESTNET=TRUE -DBUILD_GUI=true" NO_GENERATOR="true" />
</configurations>
</component>
</project>

6
.idea/code-comments.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CodeComments" version="1">
<comments />
</component>
</project>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

4
.idea/misc.xml generated Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

9
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/blockchain.iml" filepath="$PROJECT_DIR$/.idea/blockchain.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/blockchain-iTw3.iml" filepath="$PROJECT_DIR$/.idea/blockchain-iTw3.iml" />
</modules>
</component>
</project>

7
.idea/runConfigurations/daemon.xml generated Normal file
View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="daemon" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="--data-dir $ProjectFileDir$" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Project" TARGET_NAME="daemon" CONFIG_NAME="Release" RUN_TARGET_PROJECT_NAME="Project" RUN_TARGET_NAME="daemon">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View file

@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="docker-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="lthn/chain-itw3:testnet" />
<option name="buildCliOptions" value="--platform linux/x86_64 --build-arg THREADS=4" />
<option name="buildKitEnabled" value="true" />
<option name="containerName" value="" />
<option name="contextFolderPath" value="." />
<option name="sourceFilePath" value="utils/docker/Dockerfile" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="simplewallet" type="CMakeRunConfiguration" factoryName="Application" singleton="false" PROGRAM_PARAMS="--wallet-file $USER_HOME$/Desktop/arg" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$CMakeCurrentLocalGenerationDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Project" TARGET_NAME="simplewallet" CONFIG_NAME="Release" RUN_TARGET_PROJECT_NAME="Project" RUN_TARGET_NAME="simplewallet">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

7
.idea/runConfigurations/wallet.xml generated Normal file
View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="wallet" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="--generate-new-wallet test" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$CMakeCurrentLocalGenerationDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Project" TARGET_NAME="wallet" CONFIG_NAME="Release" RUN_TARGET_PROJECT_NAME="Project" RUN_TARGET_NAME="simplewallet">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

9
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/contrib/miniupnp" vcs="Git" />
<mapping directory="$PROJECT_DIR$/contrib/tor-connect" vcs="Git" />
<mapping directory="$PROJECT_DIR$/src/gui/qt-daemon/layout" vcs="Git" />
</component>
</project>

View file

@ -1,11 +1,41 @@
cmake_minimum_required(VERSION 3.5)
PROJECT(Zano)
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake")
PROJECT(Lethean)
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
option (USE_CCACHE "Use ccache if a usable instance is found" ON)
if (USE_CCACHE)
include(FindCcache) # Has to be included after the project() macro, to be able to read the CXX variable.
else()
message(STATUS "ccache deselected")
endif()
option (USE_COMPILATION_TIME_PROFILER "Use compilation time profiler (for CLang >= 9 only)" OFF)
if (USE_COMPILATION_TIME_PROFILER)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(FATAL_ERROR "The flag USE_COMPILATION_TIME_PROFILER is meant to be set only for CLang compiler!")
endif()
add_compile_options("-ftime-trace")
endif()
if (${CMAKE_VERSION} VERSION_GREATER "3.0.0" AND CMAKE_MAKE_PROGRAM MATCHES "ninja")
set(CCACHE_PARALLEL_COMPILE_JOBS "" CACHE STRING "The maximum number of concurrent compilation jobs.")
if (CCACHE_PARALLEL_COMPILE_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${CCACHE_PARALLEL_COMPILE_JOBS})
set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
endif ()
set(CCACHE_PARALLEL_LINK_JOBS "" CACHE STRING "The maximum number of concurrent link jobs.")
if (CCACHE_PARALLEL_LINK_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${CCACHE_PARALLEL_LINK_JOBS})
set(CMAKE_JOB_POOL_LINK link_job_pool)
endif ()
endif ()
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
@ -26,15 +56,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
add_definitions(-DMOBILE_WALLET_BUILD)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" )
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" )
add_definitions(-DIOS_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
add_definitions(-DANDROID_BUILD)
message("Android sdk prefix: ${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}")
message("Android CMAKE_CXX_COMPILER prefix: ${CMAKE_CXX_COMPILER}")
message("Android sdk prefix: ${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}")
message("Android CMAKE_CXX_COMPILER prefix: ${CMAKE_CXX_COMPILER}")
message("Android ANDROID_LD: ${ANDROID_LD}")
endif()
endif()
@ -49,16 +79,16 @@ if (UNIX AND NOT APPLE)
endif()
else()
# multi configurations for MSVC and XCode
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_CONFIGURATION_TYPES "Release")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
else()
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
endif()
endif()
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}")
enable_testing()
set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically
@ -66,12 +96,13 @@ find_package(OpenSSL REQUIRED)
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version")
endif()
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers")
set(DISABLE_TOR FALSE CACHE BOOL "Disable TOR library(and related tor-connect submodule)")
set(TESTNET FALSE CACHE BOOL "Compile for testnet")
set(MUTE_ERRORS TRUE CACHE BOOL "Disable Error Suppression")
set(BUILD_GUI FALSE CACHE BOOL "Build qt-daemon")
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include ${OPENSSL_INCLUDE_DIR} "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
@ -79,24 +110,37 @@ include_directories(src contrib/eos_portable_archive contrib contrib/epee/includ
add_definitions(-DSTATICLIB)
if(TESTNET)
message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!")
add_definitions(-DTESTNET)
message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!")
add_definitions(-DTESTNET)
if(MUTE_ERRORS)
# shhhhh sleepy time errors, we know...
add_definitions(-w)
endif()
else()
if(MUTE_ERRORS)
# shhhhh sleepy time errors, we know...
add_definitions(-w)
endif()
endif()
if(CAKEWALLET)
message("NOTICE: Building libraries for CAKEWALLET")
add_definitions(-DCAKEWALLET)
message("NOTICE: Building libraries for CAKEWALLET")
add_definitions(-DCAKEWALLET)
endif()
set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically
find_package(OpenSSL REQUIRED)
if(DISABLE_TOR)
message("NOTICE: Building with disabled TOR support!")
add_definitions(-DDISABLE_TOR)
message("NOTICE: Building with disabled TOR support!")
add_definitions(-DDISABLE_TOR)
endif()
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
add_definitions(-DSTATICLIB)
set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
if (UNIX AND NOT APPLE)
# Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail
@ -197,7 +241,7 @@ else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
if(STATIC)
if(APPLE)
message(SEND_ERROR "Static build is not supported on MacOS X")
# message(SEND_ERROR "Static build is not supported on MacOS X")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
@ -214,12 +258,12 @@ if(MSVC)
set(Boost_USE_STATIC_LIBS ON)
endif()
if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
# set(Boost_USE_STATIC_RUNTIME ON)
endif()
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.00)
set(Boost_LIBRARIES "libboost.a")
@ -250,8 +294,8 @@ if(MINGW)
elseif(NOT MSVC)
if(NOT APPLE)
set(Boost_LIBRARIES "${Boost_LIBRARIES};")
if(STATIC)
message("NOTICE: Including static ICU libraries")
if(STATIC)
message("NOTICE: Including static ICU libraries")
set(Boost_LIBRARIES "${Boost_LIBRARIES};icui18n.a;icuuc.a;icudata.a;dl")
endif()
endif()
@ -259,7 +303,13 @@ endif()
if(BUILD_GUI)
cmake_minimum_required(VERSION 3.1)
find_package(Qt5Widgets REQUIRED)
if(APPLE AND NOT CMAKE_PREFIX_PATH)
execute_process(COMMAND brew --prefix qt5 OUTPUT_VARIABLE QT5_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND CMAKE_PREFIX_PATH ${QT5_DIR})
endif()
find_package(Qt5Widgets REQUIRED)
endif()
set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
@ -288,13 +338,13 @@ else()
endif()
endif()
set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests")
set(DISABLE_MDBX FALSE CACHE BOOL "Exclude mdbx from build(need for a first time)")
set(BUILD_TESTS FALSE CACHE BOOL "Build Lethean tests")
set(DISABLE_MDBX FALSE CACHE BOOL "Exclude mdbx from build(need for a first time)")
if(NOT DISABLE_MDBX)
add_definitions(-DENABLED_ENGINE_MDBX)
endif()
add_subdirectory(contrib)
add_subdirectory(src)

2
CODEOWNERS Normal file
View file

@ -0,0 +1,2 @@
* @snider
docs/* @snider @bodane

287
LICENCE Normal file
View file

@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,
- lend and rent the Work or copies thereof,
- sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of the
Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions on
the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed under
a Compatible Licence, this Distribution or Communication can be done under the
terms of this Compatible Licence. For the sake of this clause, Compatible
Licence refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work,
the Licensee will provide a machine-readable copy of the Source Code or indicate
a repository where this Source will be easily and freely available for as long
as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws as
far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website) must
at least provide to the public the information requested by the applicable law
regarding the Licensor, the Licence and the way it may be accessible, concluded,
stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions of
this Licence or updated versions of the Appendix, so far this is required and
reasonable, without reducing the scope of the rights granted by the Licence. New
versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
- any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty on
the Functioning of the European Union,
- any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive jurisdiction
of the competent court where the Licensor resides or conducts its primary
business.
15. Applicable Law
Without prejudice to specific agreement between parties,
- this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
- this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
- GNU General Public License (GPL) v. 2, v. 3
- GNU Affero General Public License (AGPL) v. 3
- Open Software License (OSL) v. 2.1, v. 3.0
- Eclipse Public License (EPL) v. 1.0
- CeCILL v. 2.0, v. 2.1
- Mozilla Public Licence (MPL) v. 2
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above
licences without producing a new version of the EUPL, as long as they provide
the rights granted in Article 2 of this Licence and protect the covered Source
Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new
EUPL version.

View file

@ -11,12 +11,13 @@ endif
cmake = cmake $(cmake_gen)
cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug
cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug -D MUTE_ERRORS=FALSE
cmake_release = $(cmake) -D CMAKE_BUILD_TYPE=Release
cmake_gui = -D BUILD_GUI=ON
cmake_testnet = -D TESTNET=ON
cmake_static = -D STATIC=ON
cmake_tests = -D BUILD_TESTS=ON
cmake_tests = -D BUILD_TESTS=ON -D TESTNET=ON
# Helper macro
define CMAKE
@ -33,15 +34,27 @@ release:
$(eval command += $(cmake_release))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
release-testnet:
$(eval command += $(cmake_release) $(cmake_testnet))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
debug:
$(eval command += $(cmake_debug))
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE)
debug-testnet:
$(eval command += $(cmake_debug) $(cmake_testnet))
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE)
static: static-release
static-release:
$(eval command += $(cmake_release) $(cmake_static))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
static-release-testnet:
$(eval command += $(cmake_release) $(cmake_static) $(cmake_testnet))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
#
# GUI
#
@ -50,6 +63,9 @@ gui: gui-release
gui-release:
$(eval command += $(cmake_release) $(cmake_gui))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
gui-release-testnet:
$(eval command += $(cmake_release) $(cmake_gui) $(cmake_testnet))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
gui-debug:
$(eval command += $(cmake_debug) $(cmake_gui))
@ -60,6 +76,10 @@ gui-release-static:
$(eval command += $(cmake_release) $(cmake_gui) $(cmake_static))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
gui-release-static-testnet:
$(eval command += $(cmake_release) $(cmake_gui) $(cmake_static) $(cmake_testnet))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
#
# Tests
#
@ -76,7 +96,10 @@ test-debug:
clean:
rm -rf build
macos-gui:
bash ./utils/build/testnet_mac_osx_gui.sh
tags:
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest
.PHONY: all release debug static static-release gui gui-release gui-static gui-release-static gui-debug test test-release test-debug clean tags
.PHONY: all release debug static static-release gui gui-release gui-static gui-release-static gui-debug test test-release test-debug clean tags macos-gui

View file

@ -1,10 +1,19 @@
[![Coverity Scan](https://scan.coverity.com/projects/18767/badge.svg)](https://scan.coverity.com/projects/zanoproject)
[![Discord](https://img.shields.io/discord/538361472691077130?label=discord&logo=discord)](https://discord.gg/wE3rmYY)
# Addresses
- `iT`/`0x73f7` - Main prefix
- `iTH`/`0x6af7` - integrated paymennt_id address prefix
- `iTHn`/`0xdeaf7` - auditable wallet address
- `iTHa`/`0x7eaf7` - auditable integrated paymennt_id address prefix
## Ports
- STRATUM: `36941`
- RPC: `36942`
- P2P: `36943`
## Cloning
Be sure to clone the repository properly:\
`$ git clone --recursive https://github.com/hyle-team/zano.git`
`$ git clone --recursive https://github.com/letheanVPN/blockchain-iTw3.git`
# Building
--------
@ -24,7 +33,7 @@ Be sure to clone the repository properly:\
Note:\
[*server version*] denotes steps required for building command-line tools (daemon, simplewallet, etc.).\
[*GUI version*] denotes steps required for building Zano executable with GUI.
[*GUI version*] denotes steps required for building LTHN executable with GUI.
<br />
@ -109,9 +118,10 @@ For instance, by adding the following lines to `~/.bashrc`
BOOST_ROOT=$HOME/boost_1_70_0 OPENSSL_ROOT_DIR=$HOME/openssl cmake ..
make -j1 daemon simplewallet
2. If you set the variables in step 6:
cd zano && mkdir build && cd build
cd lthn/ && make -j1
or
cd lthn && mkdir build && cd build
cmake ..
make -j1 daemon simplewallet
@ -125,7 +135,7 @@ For instance, by adding the following lines to `~/.bashrc`
1. Build GUI:
cd zano
cd lthn
utils/build_script_linux.sh
Look for the binaries in `build` folder
@ -133,19 +143,32 @@ For instance, by adding the following lines to `~/.bashrc`
<br />
### Windows
Recommended OS version: Windows 7 x64, Windows 11 x64.
1. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
2. Edit paths in `utils/configure_local_paths.cmd`.
3. Run one of `utils/configure_win64_msvsNNNN_gui.cmd` according to your MSVC version.
4. Go to the build folder and open generated Zano.sln in MSVC.
5. Build.
Recommended OS versions: Windows 7+ x64, Windows 11 x64.
1. Install [Chocolatey](https://chocolatey.org/install)
2. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
_NOTE: At time of writing the following versions were available on Chocolatey_
```
choco install boost-msvc-14.2 --version 1.74.0 -y
choco install qt5-default --version 5.15.2.20211228 -y
choco install cmake --version 3.23.1 -y
choco install openssl --version 1.1.1.1500 -y
```
3. Clone repository, then complete the following:
1. Edit paths in file `utils/configure_local_paths.cmd.example`.
2. Rename `configure_local_paths.cmd.example` to `configure_local_paths.cmd` (do not commit).
4. Run one of `utils/configure_win64_msvsNNNN_gui.cmd` according to your MSVC version.
5. Go to the build folder and open generated Zano.sln in MSVC.
6. Build.
In order to correctly deploy Qt GUI application, you also need to do the following:
6. Copy Zano.exe to a folder (e.g. `depoy`).
7. Run `PATH_TO_QT\bin\windeployqt.exe deploy\Zano.exe`.
6. Copy Lethean.exe to a folder (e.g. `depoy`).
7. Run `PATH_TO_QT\bin\windeployqt.exe deploy\Lethean.exe`.
8. Copy folder `\src\gui\qt-daemon\html` to `deploy\html`.
9. Now you can run `Zano.exe`
9. Now you can run `Lethean.exe`
<br />
@ -160,12 +183,12 @@ To build GUI application:
1. Create self-signing certificate via Keychain Access:\
a. Run Keychain Access.\
b. Choose Keychain Access > Certificate Assistant > Create a Certificate.\
c. Use “Zano” (without quotes) as certificate name.\
c. Use “LetheanVPN” (without quotes) as certificate name.\
d. Choose “Code Signing” in “Certificate Type” field.\
e. Press “Create”, then “Done”.\
f. Make sure the certificate was added to keychain "System". If not—move it to "System".\
g. Double click the certificate you've just added, enter the trust section and under "When using this certificate" select "Always trust".\
h. Unfold the certificate in Keychain Access window and double click the underlying private key "Zano". Select "Access Control" tab, then select "Allow all applications to access this item". Click "Save Changes".
h. Unfold the certificate in Keychain Access window and double click the underlying private key "LetheanVPN". Select "Access Control" tab, then select "Allow all applications to access this item". Click "Save Changes".
2. Revise building script, comment out unwanted steps and run it: `utils/build_script_mac_osx.sh`
3. The application should be here: `/buid_mac_osx_64/release/src`

View file

@ -14,10 +14,29 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
message("excluded upnp support for IOS build")
return()
endif()
find_package(Miniupnpc REQUIRED)
message(STATUS "Using in-tree miniupnpc")
set(UPNPC_NO_INSTALL TRUE CACHE BOOL "Disable miniupnp installation" FORCE)
add_subdirectory(miniupnp/miniupnpc)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "contrib")
set_property(TARGET libminiupnpc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
if(MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
elseif(NOT MSVC)
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -D_NETBSD_SOURCE")
endif()
set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
#set_property(TARGET libminiupnpc-static PROPERTY FOLDER "contrib")
set_property(TARGET zlibstatic PROPERTY FOLDER "contrib")
set_property(TARGET mdbx PROPERTY FOLDER "contrib")
set_property(TARGET lmdb PROPERTY FOLDER "contrib")
@ -25,7 +44,7 @@ if( NOT DISABLE_TOR)
set_property(TARGET tor-connect PROPERTY FOLDER "contrib")
endif()
set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat PROPERTY FOLDER "unused")
set_property(TARGET mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat PROPERTY FOLDER "unused")
if(MSVC)
#set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused")
@ -33,9 +52,9 @@ endif()
if(MSVC)
set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4244 /wd4267")
# set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4244 /wd4267")
set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4267 /wd4267")
else()
set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ")
set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ")
# set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-ignored-qualifiers ")
set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-ignored-qualifiers ")
endif()

View file

@ -0,0 +1,22 @@
if (APPLE AND NOT IOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
if (NOT OPENSSL_ROOT_DIR)
EXECUTE_PROCESS(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using OpenSSL found at ${OPENSSL_ROOT_DIR}")
endif()
endif()
find_package(OpenSSL REQUIRED)
message(STATUS "Using OpenSSL include dir at ${OPENSSL_INCLUDE_DIR}")
include_directories(${OPENSSL_INCLUDE_DIR})
if(STATIC AND NOT IOS)
if(UNIX)
set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};${CMAKE_DL_LIBS};${CMAKE_THREAD_LIBS_INIT}")
endif()
endif()
if (WIN32)
list(APPEND OPENSSL_LIBRARIES ws2_32 crypt32)
endif()

View file

@ -0,0 +1,67 @@
# Copyright (c) 2014-2022, The Monero Project
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# - Try to find readline include dirs and libraries
#
# Automatically finds ccache build accelerator, if it's found in PATH.
#
# Usage of this module as follows:
#
# project(monero)
# include(FindCcache) # Include AFTER the project() macro to be able to reach the CMAKE_CXX_COMPILER variable
#
# Properties modified by this module:
#
# GLOBAL PROPERTY RULE_LAUNCH_COMPILE set to ccache, when ccache found
# GLOBAL PROPERTY RULE_LAUNCH_LINK set to ccache, when ccache found
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
# Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups)
set(TEST_PROJECT "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp")
file(WRITE "${TEST_PROJECT}/CMakeLists.txt" [=[
cmake_minimum_required(VERSION 3.5)
project(test)
option (CCACHE "")
file(WRITE "${CMAKE_SOURCE_DIR}/test.cpp" "int main() { return 0; }")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE}")
add_executable(main test.cpp)
]=])
try_compile(RET "${TEST_PROJECT}/build" "${TEST_PROJECT}" "test" CMAKE_FLAGS -DCCACHE="${CCACHE_FOUND}")
unset(TEST_PROJECT)
if (${RET})
# Success
message(STATUS "Found usable ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND}")
else()
message(STATUS "Found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
endif()
else()
message(STATUS "ccache NOT found! Please install it for faster rebuilds.")
endif()

View file

@ -0,0 +1,59 @@
# --------------------------------- FindMiniupnpc Start ---------------------------------
# Locate miniupnp library
# This module defines
# MINIUPNP_FOUND, if false, do not try to link to miniupnp
# MINIUPNP_LIBRARY, the miniupnp variant
# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
# MINIUPNPC_VERSION_1_7_OR_HIGHER, set if we detect the version of miniupnpc is 1.7 or higher
#
# Note that the expected include convention is
# #include "miniupnpc.h"
# and not
# #include <miniupnpc/miniupnpc.h>
# This is because, the miniupnpc location is not standardized and may exist
# in locations other than miniupnpc/
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
# Already in cache, be silent
set(MINIUPNP_FIND_QUIETLY TRUE)
endif ()
find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
HINTS $ENV{MINIUPNP_INCLUDE_DIR}
PATH_SUFFIXES miniupnpc
)
find_library(MINIUPNP_LIBRARY miniupnpc
HINTS $ENV{MINIUPNP_LIBRARY}
)
find_library(MINIUPNP_STATIC_LIBRARY libminiupnpc.a
HINTS $ENV{MINIUPNP_STATIC_LIBRARY}
)
set(MINIUPNP_INCLUDE_DIRS ${MINIUPNP_INCLUDE_DIR})
set(MINIUPNP_LIBRARIES ${MINIUPNP_LIBRARY})
set(MINIUPNP_STATIC_LIBRARIES ${MINIUPNP_STATIC_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
MiniUPnPc DEFAULT_MSG
MINIUPNP_INCLUDE_DIR
MINIUPNP_LIBRARY
)
IF(MINIUPNPC_FOUND)
file(STRINGS "${MINIUPNP_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+")
if(MINIUPNPC_API_VERSION_STR MATCHES "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)")
set(MINIUPNPC_API_VERSION "${CMAKE_MATCH_1}")
if (${MINIUPNPC_API_VERSION} GREATER "10" OR ${MINIUPNPC_API_VERSION} EQUAL "10")
message(STATUS "Found miniupnpc API version " ${MINIUPNPC_API_VERSION})
set(MINIUPNP_FOUND true)
set(MINIUPNPC_VERSION_1_7_OR_HIGHER true)
endif()
endif()
ENDIF()
mark_as_advanced(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY MINIUPNP_STATIC_LIBRARY)
# --------------------------------- FindMiniupnpc End ---------------------------------

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
// Copyright (c) 2019, anonimal, <anonimal@lethean.org>
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//

View file

@ -1,5 +1,5 @@
// Copyright (c) 2019, Zano Project
// Copyright (c) 2019, anonimal <anonimal@zano.org>
// Copyright (c) 2019, anonimal <anonimal@lethean.org>
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//

View file

@ -1,4 +1,4 @@
// Copyright (c) 2019, anonimal <anonimal@zano.org>
// Copyright (c) 2019, anonimal <anonimal@lethean.org>
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//

View file

@ -22,7 +22,7 @@
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
#ifndef _STRING_TOOLS_H_
#define _STRING_TOOLS_H_

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -1,75 +0,0 @@
name: zano
base: core18
adopt-info: zano
summary: "Zano coin: official wallet. Secure. Scalable. Easy to Use."
description: |
Zano is a scalable and secure coin, designed for use in e-commerce.
The technology behind our blockchain provides reliability, security,
and flexibility a perfect option for P2P transactions.
More info: http://zano.org
grade: stable
confinement: strict
architectures:
- build-on: amd64
- build-on: i386
parts:
zano:
source: https://github.com/hyle-team/zano.git
plugin: cmake
override-pull: |
snapcraftctl pull
snapcraftctl set-version "$(git describe)"
configflags:
- -DBUILD_GUI=TRUE
override-build: |
snapcraftctl build
mkdir -p $SNAPCRAFT_PART_INSTALL/opt/Zano
cp $SNAPCRAFT_PART_BUILD/src/Zano $SNAPCRAFT_PART_INSTALL/opt/Zano/
cp $SNAPCRAFT_PART_BUILD/src/simplewallet $SNAPCRAFT_PART_INSTALL/opt/Zano/
cp $SNAPCRAFT_PART_BUILD/src/zanod $SNAPCRAFT_PART_INSTALL/opt/Zano/
rsync -a $SNAPCRAFT_PART_SRC/src/gui/qt-daemon/html $SNAPCRAFT_PART_INSTALL/opt/Zano --exclude less --exclude package.json --exclude gulpfile.js
build-packages:
- make
- g++
- libboost-all-dev
- qtwebengine5-dev
- rsync
build-attributes: [keep-execstack]
stage-packages:
- libboost-system1.65.1
- libboost-filesystem1.65.1
- libboost-thread1.65.1
- libboost-date-time1.65.1
- libboost-chrono1.65.1
- libboost-regex1.65.1
- libboost-serialization1.65.1
- libboost-program-options1.65.1
- libboost-locale1.65.1
apps:
zano:
command: opt/Zano/Zano --data-dir $SNAP_USER_COMMON
extensions:
- kde-neon
plugs:
- network
- home
- desktop
- opengl #for QML support
- browser-support #for Qt WebEngine support
- audio-playback
- unity7 #for tray icon support
simplewallet:
command: opt/Zano/simplewallet
plugs:
- network
- home
zanod:
command: opt/Zano/zanod --data-dir $SNAP_USER_COMMON
environment:
LC_ALL: C
plugs:
- network
- network-bind

View file

@ -78,7 +78,13 @@ if(BUILD_GUI)
endif()
list(FILTER QTDAEMON EXCLUDE REGEX "node_modules")
endif()
# if(BUILD_GUI)
# if(APPLE)
# file(GLOB_RECURSE QTSERVER gui/*.cpp gui/*.h gui/*.mm)
# else()
# file(GLOB_RECURSE QTSERVER gui/*.cpp gui/*.h)
# endif()
#endif()
source_group(pch FILES ${PCH})
source_group(common FILES ${COMMON})
@ -94,7 +100,7 @@ source_group(connectivity-tool FILES ${CONN_TOOL})
source_group(wallet FILES ${WALLET})
if(BUILD_GUI)
source_group(qtdaemon FILES ${QTDAEMON})
source_group(qtserver FILES ${QTSERVER})
endif()
@ -165,7 +171,7 @@ add_dependencies(daemon version)
target_link_libraries(daemon rpc stratum currency_core crypto common libminiupnpc-static zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
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} OpenSSL::SSL OpenSSL::Crypto)
@ -173,7 +179,7 @@ ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL)
ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool)
add_executable(simplewallet ${SIMPLEWALLET})
add_dependencies(simplewallet version)
add_dependencies(simplewallet version)
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET)
@ -181,7 +187,8 @@ ENABLE_SHARED_PCH_EXECUTABLE(simplewallet)
set_property(TARGET common crypto currency_core rpc stratum wallet PROPERTY FOLDER "libs")
set_property(TARGET daemon simplewallet connectivity_tool PROPERTY FOLDER "prog")
set_property(TARGET daemon PROPERTY OUTPUT_NAME "zanod")
set_property(TARGET daemon PROPERTY OUTPUT_NAME "letheand")
if(BUILD_GUI)
@ -189,57 +196,34 @@ if(BUILD_GUI)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
endif()
set(AUTORCC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(MACOSX_BUNDLE_ICON_FILE app.icns)
add_executable(Zano WIN32 MACOSX_BUNDLE ${QTDAEMON} )
ENABLE_SHARED_PCH(Zano QTDAEMON)
ENABLE_SHARED_PCH_EXECUTABLE(Zano)
QT5_USE_MODULES(Zano WebEngineWidgets WebChannel)
# SET(MACOSX_BUNDLE_ICON_FILE app.icns)
qt5_add_resources (RCC_SOURCES gui/resources/files.qrc)
add_executable(Lethean WIN32 MACOSX_BUNDLE ${QTSERVER} ${RCC_SOURCES} )
ENABLE_SHARED_PCH(Lethean QTSERVER)
ENABLE_SHARED_PCH_EXECUTABLE(Lethean)
set_property(TARGET Lethean PROPERTY OUTPUT_NAME "lethean-gui-server")
QT5_USE_MODULES(Lethean WebEngineWidgets WebChannel WebSockets)
find_package(Qt5PrintSupport REQUIRED)
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(Lethean wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebSockets Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
if (UNIX AND NOT APPLE)
target_link_libraries(Zano rt)
target_link_libraries(Lethean rt)
endif()
if(APPLE)
target_link_libraries(Zano ${COCOA_LIBRARY})
set_property(TARGET Zano PROPERTY XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)
target_link_libraries(Lethean ${COCOA_LIBRARY})
set_property(TARGET Lethean PROPERTY XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)
endif()
if(MSVC)
target_link_libraries(Zano shlwapi.lib)
target_link_libraries(Lethean shlwapi.lib)
endif()
set_property(TARGET Zano PROPERTY FOLDER "prog")
set_target_properties(Zano PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/gui/qt-daemon/Info.plist.in)
set(HTML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gui/qt-daemon/layout/html)
set_target_properties(Zano PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS "--html-path=${HTML_DIR}")
set_property(TARGET Lethean PROPERTY FOLDER "prog")
set(CMAKE_AUTOMOC OFF)
# GUI convenience "bundle"
# set(GUI_DIR ${CMAKE_CURRENT_BINARY_DIR}/gui)
# set_target_properties(Zano PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${GUI_DIR})
# add_custom_command(TARGET Zano POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${HTML_DIR} ${GUI_DIR}/html)
endif()
if(APPLE)
set(SIMPLE_BUNDLE 1)
endif()
if(SIMPLE_BUNDLE)
set(INSTALL_DIR "${CMAKE_BINARY_DIR}/hp-${VERSION}")
install(TARGETS daemon simplewallet connectivity_tool
RUNTIME DESTINATION "${INSTALL_DIR}" COMPONENT Runtime
)
install(FILES ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} DESTINATION "${INSTALL_DIR}/lib")
if(APPLE)
set(FIXUP_COMMAND ${CMAKE_SOURCE_DIR}/utils/macosx_fixup.sh " " ${INSTALL_DIR})
install(CODE "execute_process(COMMAND ${FIXUP_COMMAND})")
endif()
endif()

View file

@ -6,14 +6,14 @@
#include "command_line.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
namespace command_line
{
const arg_descriptor<bool> arg_help ("help", "Produce help message");
const arg_descriptor<bool> arg_version ("version", "Output version information");
const arg_descriptor<std::string> arg_data_dir ("data-dir", "Specify data directory", "");
const arg_descriptor<int> arg_stop_after_height ( "stop-after-height", "If specified, the daemon will stop immediately after a block with the given height is added", 0 );
const arg_descriptor<std::string> arg_config_file ( "config-file", "Specify configuration file", std::string(CURRENCY_NAME_SHORT ".conf") );

View file

@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "db_backend_selector.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "command_line.h"
#include "db_backend_lmdb.h"
#include "db_backend_mdbx.h"
@ -42,7 +42,7 @@ namespace db
m_engine_type = db_mdbx;
#else
LOG_PRINT_L0(" DB ENGINE: " << ARG_DB_ENGINE_MDBX << " is not suported by this build(see DISABLE_MDBX cmake option), STOPPING");
#endif
#endif
}
else
{
@ -122,7 +122,7 @@ namespace db
std::string db_backend_selector::get_temp_config_folder() const
{
return m_config_folder + "_TEMP";
return m_config_folder + "_TEMP";
}

View file

@ -16,11 +16,11 @@ namespace currency
struct tx_cost_struct
{
std::string usd_needed_for_erc20;
std::string zano_needed_for_erc20;
std::string lethean_needed_for_erc20;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(usd_needed_for_erc20)
KV_SERIALIZE(zano_needed_for_erc20)
KV_SERIALIZE(lethean_needed_for_erc20)
END_KV_SERIALIZE_MAP()
};

View file

@ -4,7 +4,7 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#pragma once
#include <thread>
#include <string>
@ -17,7 +17,7 @@ extern "C" {
}
#include "misc_language.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "version.h"
namespace tools
@ -34,9 +34,9 @@ namespace tools
uint32_t m_external_port;
uint32_t m_internal_port;
uint32_t m_period_ms;
public:
public:
miniupnp_helper():m_devlist(nullptr),
m_urls(AUTO_VAL_INIT(m_urls)),
m_urls(AUTO_VAL_INIT(m_urls)),
m_data(AUTO_VAL_INIT(m_data)),
m_IGD(0),
m_external_port(0),
@ -123,7 +123,7 @@ namespace tools
if(m_devlist)
{
freeUPNPDevlist(m_devlist);
freeUPNPDevlist(m_devlist);
m_devlist = nullptr;
}
@ -156,8 +156,8 @@ namespace tools
if(r!=UPNPCOMMAND_SUCCESS)
{
LOG_PRINT_L1("AddPortMapping with external_port_str= " << external_port_str <<
", internal_port_str=" << internal_port_str <<
LOG_PRINT_L1("AddPortMapping with external_port_str= " << external_port_str <<
", internal_port_str=" << internal_port_str <<
", failed with code=" << r << "(" << strupnperror(r) << ")");
}else
{

View file

@ -21,8 +21,12 @@ namespace tools
};
#ifndef TESTNET
static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.42.247/pre-download/zano_mdbx_95_2500000.pak", "8ffa2cb4213f4f96f97033c65a9e52bc350f683237808597784e79b24d5bfee7", 3242348793, 5905489920 };
static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.42.247/pre-download/zano_lmdb_95_2500000.pak", "5509650e12c8f901e6731a2bfaf3abfd64409e3e1366d3d94cd11db8beddb0c3", 4239505801, 5893566464 };
@todo bookmarking bootstrap file location
// static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.42.247/pre-download/zano_mdbx_95_1161000.pak", "26660ffcdaf80a43a586e64a1a6da042dcb9ff3b58e14ce1ec9a775b995dc146", 1330022593, 2684313600 };
// static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.42.247/pre-download/zano_lmdb_95_1161000.pak", "9dd03f08dea396fe32e6483a8221b292be35fa41c29748f119f11c3275956cdc", 1787475468, 2600247296 };
static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 };
#else
static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 };

View file

@ -9,7 +9,7 @@
using namespace epee;
#include "util.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "version.h"
#ifdef WIN32
@ -18,7 +18,7 @@ using namespace epee;
#include <strsafe.h>
#include <lm.h>
#pragma comment(lib, "netapi32.lib")
#else
#else
#include <sys/utsname.h>
#endif
@ -98,7 +98,7 @@ namespace tools
else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0 && osver.wProductType != VER_NT_WORKSTATION) winver = "Windows Server 2008";
else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0 && osver.wProductType == VER_NT_WORKSTATION) winver = "Windows Vista";
else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2 && osver.wProductType == VER_NT_WORKSTATION
&& sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
&& sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
winver = "Windows XP x64";
else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) winver = "Windows Server 2003";
else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) winver = "Windows XP";
@ -166,13 +166,13 @@ namespace tools
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
osvi.dwMajorVersion > 4 )
{
StringCchCopy(pszOS, BUFSIZE, TEXT("Microsoft "));
@ -196,7 +196,7 @@ namespace tools
}
pGPI = (PGPI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
GetModuleHandle(TEXT("kernel32.dll")),
"GetProductInfo");
pGPI( osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
@ -326,7 +326,7 @@ namespace tools
{
StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
}
else
else
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Server" ));
@ -357,10 +357,10 @@ namespace tools
StringCchCat(pszOS, BUFSIZE, TEXT(", 32-bit"));
}
return pszOS;
return pszOS;
}
else
{
{
printf( "This sample does not support this version of Windows.\n");
return pszOS;
}
@ -386,7 +386,7 @@ namespace tools
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
{
// Create the minidump
// Create the minidump
MINIDUMP_EXCEPTION_INFORMATION mdei;
mdei.ThreadId = GetCurrentThreadId();
@ -416,7 +416,7 @@ namespace tools
{
LOG_PRINT_L0("Minidump file created on path: " << path);
}
// Close the file
// Close the file
CloseHandle(hFile);
}
else
@ -483,9 +483,9 @@ std::string get_nix_version_display_string()
// Windows
#ifdef _M_X64
config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT;
#else
#else
config_folder = get_special_folder_path_utf8(CSIDL_APPDATA, true) + "/" + CURRENCY_NAME_SHORT + "-x86";
#endif
#endif
#else
std::string pathRet;
char* pszHome = getenv("HOME");
@ -517,7 +517,7 @@ std::string get_nix_version_display_string()
std::string get_default_user_dir()
{
//namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username
// Windows < Vista: C:\Documents and Settings\Username
// Windows >= Vista: C:\Users\Username\AppData\Roaming\CURRENCY_NAME_SHORT
// Mac: ~/Library/Application Support/CURRENCY_NAME_SHORT
// Unix: ~/.CURRENCY_NAME_SHORT
@ -691,8 +691,8 @@ std::string get_nix_version_display_string()
return true;
}
//this code was taken from https://stackoverflow.com/a/8594696/5566653
//credits goes to @nijansen: https://stackoverflow.com/users/1056003/nijansen
//this code was taken from https://stackoverflow.com/a/8594696/5566653
//credits goes to @nijansen: https://stackoverflow.com/users/1056003/nijansen
bool copy_dir( boost::filesystem::path const & source, boost::filesystem::path const & destination)
{
namespace fs = boost::filesystem;

View file

@ -35,7 +35,7 @@ namespace crypto
return multiply_de_bruijn_bit_position[((uint32_t)((v & -(int32_t)v) * 0x077CB531U)) >> 27];
}
////////////////////////////////////////
// crypto trait for Zano
////////////////////////////////////////
@ -78,7 +78,7 @@ namespace crypto
static const scalar_t& get_initial_transcript()
{
static scalar_t value = hash_helper_t::hs("Zano BP+ initial transcript");
static scalar_t value = hash_helper_t::hs("Lethean BP+ initial transcript");
return value;
}
@ -110,7 +110,7 @@ namespace crypto
static bool calculated = false;
if (!calculated)
{
scalar_t hash_buf[2] = { hash_helper_t::hs("Zano BP+ generator"), 0 };
scalar_t hash_buf[2] = { hash_helper_t::hs("Lethean BP+ generator"), 0 };
for (size_t i = 0; i < 2 * c_bpp_mn_max; ++i)
{
hash_buf[1].m_u64[0] = i;

View file

@ -8,7 +8,7 @@
#ifndef TESTNET
#define CURRENCY_FORMATION_VERSION 84
#define CURRENCY_FORMATION_VERSION 1
#else
#define CURRENCY_FORMATION_VERSION 97
#endif
@ -16,21 +16,20 @@
#define CURRENCY_GENESIS_NONCE (CURRENCY_FORMATION_VERSION + 101011010121) //bender's nightmare
#define CURRENCY_MAX_BLOCK_NUMBER 500000000
#define CURRENCY_MAX_BLOCK_SIZE 500000000 // block header blob limit, never used!
#define CURRENCY_TX_MAX_ALLOWED_OUTS 2000
#define CURRENCY_TX_MIN_ALLOWED_OUTS 2 // effective starting HF4 Zarcanum
#define CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX 0xc5 // addresses start with 'Zx'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x3678 // integrated addresses start with 'iZ'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX 0x36f8 // integrated addresses start with 'iZ' (new format)
#define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0x98c8 // auditable addresses start with 'aZx'
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX'
#define CURRENCY_TX_MAX_ALLOWED_OUTS 2 // effective starting HF4 Zarcanum
#define CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX 0x73f7 // addresses start with 'iT'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x6af7 // integrated addresses start with 'iTH'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX 0x6af7 // integrated addresses start with 'iTH' (new format)
#define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0xdeaf7 // auditable addresses start with 'iTHn'
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x7eaf7 // auditable integrated addresses start with 'iTHa'
#define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10
#define CURRENT_TRANSACTION_VERSION 2
#define TRANSACTION_VERSION_INITAL 0
#define TRANSACTION_VERSION_PRE_HF4 1
#define TRANSACTION_VERSION_POST_HF4 2
#define TRANSACTION_VERSION_POST_HF4 2
#define HF1_BLOCK_MAJOR_VERSION 1
#define HF3_BLOCK_MAJOR_VERSION 2
#define HF3_BLOCK_MINOR_VERSION 0
@ -53,17 +52,17 @@
#define CURRENCY_COINBASE_BLOB_RESERVED_SIZE 1100
#define CURRENCY_MAX_TRANSACTION_BLOB_SIZE (CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE - CURRENCY_COINBASE_BLOB_RESERVED_SIZE*2)
#define CURRENCY_FREE_TX_MAX_BLOB_SIZE 1024 // soft txpool-based limit for free-of-charge txs (such as BC_OFFERS_SERVICE_INSTRUCTION_DEL)
#define CURRENCY_DISPLAY_DECIMAL_POINT 12
#define CURRENCY_DISPLAY_DECIMAL_POINT 8
// COIN - number of smallest units in one coin
#define COIN ((uint64_t)1000000000000) // pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
#define COIN ((uint64_t)100000000) // pow(8, CURRENCY_DISPLAY_DECIMAL_POINT)
#define BASE_REWARD_DUST_THRESHOLD ((uint64_t)1000000) // pow(10, 6) - change this will cause hard-fork!
#define DEFAULT_DUST_THRESHOLD ((uint64_t)0)
#define TX_DEFAULT_FEE ((uint64_t)10000000000) // .01
#define TX_MINIMUM_FEE ((uint64_t)10000000000) // .01
#define TX_DEFAULT_FEE ((uint64_t)1000000) // .01
#define TX_MINIMUM_FEE ((uint64_t)1000000) // .01
#define CURRENCY_BLOCK_REWARD 1000000000000 // 1.0 coin == pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
#define CURRENCY_BLOCK_REWARD 10000000 // 1.0 coin == pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
#define WALLET_MAX_ALLOWED_OUTPUT_AMOUNT ((uint64_t)0xffffffffffffffffLL)
@ -93,7 +92,7 @@
#define MAX_ALIAS_PER_BLOCK 1000
#define ALIAS_COAST_PERIOD CURRENCY_BLOCKS_PER_DAY*7 //week
#define ALIAS_COAST_RECENT_PERIOD CURRENCY_BLOCKS_PER_DAY*8 //week + 1 day (we guarantee split depth at least 1 day)
#define ALIAS_VERY_INITAL_COAST ((uint64_t)10000) // to avoid split when default fee changed
#define ALIAS_VERY_INITAL_COAST ((uint64_t)1000000000) // to avoid split when default fee changed
#define ALIAS_MEDIAN_RECALC_INTERWAL CURRENCY_BLOCKS_PER_DAY
@ -110,19 +109,23 @@
#ifndef TESTNET
#define P2P_DEFAULT_PORT 11121
#define RPC_DEFAULT_PORT 11211
#define STRATUM_DEFAULT_PORT 11777
#define SEED_NODE_HOST "mainnet.lethean.io"
#define P2P_DEFAULT_PORT (36942 + CURRENCY_FORMATION_VERSION)
#define RPC_DEFAULT_PORT 36942
#define STRATUM_DEFAULT_PORT 36941
#define STRARUM_DEFAULT_PORT 36941
#define P2P_NETWORK_ID_TESTNET_FLAG 0
#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607"
#define DIFFICULTY_POS_STARTER 1
#else
#define P2P_DEFAULT_PORT (11112 + CURRENCY_FORMATION_VERSION)
#define RPC_DEFAULT_PORT 12111
#define STRATUM_DEFAULT_PORT 11888
#define STRARUM_DEFAULT_PORT 51113
#else
#define SEED_NODE_HOST "testnet.lethean.io"
#define SEED_NODE_HOST2 "dev.lthn.network"
#define P2P_DEFAULT_PORT 31122
#define RPC_DEFAULT_PORT 31212
#define STRATUM_DEFAULT_PORT 31778
#define P2P_NETWORK_ID_TESTNET_FLAG 1
#define P2P_MAINTAINERS_PUB_KEY "aaa2d7aabc8d383fd53a3ae898697b28f236ceade6bafc1eecff413a6a02272a"
#define P2P_MAINTAINERS_PUB_KEY "cc6076dd0ba1bdb1dd65c8aedcc4c15705d713060f33c4a12ce301eb86f4c684"
#define DIFFICULTY_POS_STARTER 1
#endif
@ -190,19 +193,19 @@
#define CURRENCY_NAME_ABR "ZANO"
#define CURRENCY_NAME_BASE "Zano"
#define CURRENCY_NAME_SHORT_BASE "Zano"
#define CURRENCY_NAME_ABR "LTHN"
#define CURRENCY_NAME_BASE "Lethean"
#define CURRENCY_NAME_SHORT_BASE "Lethean"
#ifndef TESTNET
#define CURRENCY_NAME CURRENCY_NAME_BASE
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE
#else
#define CURRENCY_NAME CURRENCY_NAME_BASE"_testnet"
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE"_testnet"
#define CURRENCY_NAME CURRENCY_NAME_BASE"_testnet3"
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE"_testnet3"
#endif
//premine
#define PREMINE_AMOUNT (17517203000000000000U) // 13827203.0 reserved for coinswap, 3690000.0 - premine
#define PREMINE_AMOUNT (100000000000000U) // 50% of new emission max supply
//alias registration wallet
#define ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
@ -210,7 +213,7 @@
#define ALIAS_REWARDS_ACCOUNT_VIEW_SEC_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
#define ALIAS_MINIMUM_PUBLIC_SHORT_NAME_ALLOWED 6
#define ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY "37947f7b6a5268c5d0a48bde73d7a426f0b5f24648f74024279540207dc70031"
#define ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY "fc5c69233067971ca4e55cbf21d5cc3fd947393945fa5c2041794a1e17f43c21"
#define ALIAS_NAME_MAX_LEN 255
@ -252,7 +255,7 @@
#ifndef TESTNET
#define WALLET_FILE_SERIALIZATION_VERSION 163
#define WALLET_FILE_LAST_SUPPORTED_VERSION 163
#else
#else
#define WALLET_FILE_LAST_SUPPORTED_VERSION (CURRENCY_FORMATION_VERSION+76)
#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+76)
#endif
@ -264,16 +267,13 @@
#define BLOCK_MINOR_VERSION_GENESIS 0
#define BLOCK_MAJOR_VERSION_INITIAL 0
#ifndef TESTNET
#define ZANO_HARDFORK_01_AFTER_HEIGHT 194624 // 2019-09-21 20:25:16
#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999 // 2021-04-05 09:11:45
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1082577 // 2021-06-01 23:28:10
#define ZANO_HARDFORK_04_AFTER_HEIGHT 2555000 // 2024-03-21 10:16:46 (expected)
#define ZANO_HARDFORK_01_AFTER_HEIGHT 1
#define ZANO_HARDFORK_02_AFTER_HEIGHT 2
#define ZANO_HARDFORK_03_AFTER_HEIGHT 3
#else
/////// Zarcanum Testnet //////////////////////////////
#define ZANO_HARDFORK_01_AFTER_HEIGHT 0
#define ZANO_HARDFORK_02_AFTER_HEIGHT 0
#define ZANO_HARDFORK_03_AFTER_HEIGHT 0
#define ZANO_HARDFORK_04_AFTER_HEIGHT 2440
#define ZANO_HARDFORK_01_AFTER_HEIGHT 1
#define ZANO_HARDFORK_02_AFTER_HEIGHT 2
#define ZANO_HARDFORK_03_AFTER_HEIGHT 3
#endif

View file

@ -11,7 +11,7 @@ using namespace epee;
#include "currency_format_utils.h"
#include "serialization/binary_utils.h"
#include "serialization/stl_containers.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
#include "common/int-util.h"
@ -99,4 +99,4 @@ namespace currency
get_block_longhash(b, p);
return p;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@ using namespace epee;
#include "common/util.h"
#include "warnings.h"
#include "crypto/crypto.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "currency_format_utils.h"
#include "misc_language.h"
#include "string_coding.h"
@ -24,7 +24,7 @@ using namespace epee;
#define MINIMUM_REQUIRED_FREE_SPACE_BYTES (1024 * 1024 * 100)
DISABLE_VS_WARNINGS(4355)
#undef LOG_DEFAULT_CHANNEL
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "core"
ENABLE_CHANNEL_BY_DEFAULT("core");
namespace currency
@ -253,7 +253,7 @@ namespace currency
return false;
}
TIME_MEASURE_FINISH_MS(parse_tx_time);
TIME_MEASURE_START_MS(check_tx_semantic_time);
if(!validate_tx_semantic(tx, tx_blob.size()))
{
@ -277,7 +277,7 @@ namespace currency
st_inf.blockchain_height = m_blockchain_storage.get_current_blockchain_size();
st_inf.tx_pool_size = m_mempool.get_transactions_count();
st_inf.top_block_id_str = epee::string_tools::pod_to_hex(m_blockchain_storage.get_top_block_id());
std::list<block> blocks;
m_blockchain_storage.get_blocks(m_blockchain_storage.get_current_blockchain_size() - pr.chain_len, static_cast<size_t>(pr.chain_len), blocks);
for (auto& b : blocks)
@ -366,12 +366,12 @@ namespace currency
return m_blockchain_storage.create_block_template(params, resp);
}
//-----------------------------------------------------------------------------------------------
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const
{
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, resp);
}
//-----------------------------------------------------------------------------------------------
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
{
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, blocks, total_height, start_height, max_count);
}
@ -616,12 +616,12 @@ namespace currency
return m_blockchain_storage.get_short_chain_history(ids);
}
//-----------------------------------------------------------------------------------------------
bool core::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NOTIFY_RESPONSE_GET_OBJECTS::request& rsp, currency_connection_context& context)const
bool core::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NOTIFY_RESPONSE_GET_OBJECTS::request& rsp, currency_connection_context& context)const
{
return m_blockchain_storage.handle_get_objects(arg, rsp);
}
//-----------------------------------------------------------------------------------------------
crypto::hash core::get_block_id_by_height(uint64_t height)const
crypto::hash core::get_block_id_by_height(uint64_t height)const
{
return m_blockchain_storage.get_block_id_by_height(height);
}
@ -651,14 +651,14 @@ namespace currency
if(!m_starter_message_showed)
{
LOG_PRINT_L0(ENDL
<< "**********************************************************************" << ENDL
<< "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL
<< "**********************************************************************" << ENDL
<< "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL
<< ENDL
<< "You can adjust verbosity by using command: \"set_log <level>\", where 0 is the least verbose and 3 is the most." << ENDL
<< ENDL
<< "Use \"help\" command to list all available commands." << ENDL
<< ENDL
<< "Note: in case you need to interrupt the process, use \"exit\" command. Otherwise, the current progress might not be saved." << ENDL
<< "Note: in case you need to interrupt the process, use \"exit\" command. Otherwise, the current progress might not be saved." << ENDL
<< "**********************************************************************");
m_starter_message_showed = true;
}

View file

@ -66,7 +66,7 @@ namespace currency
}
return true;
}
// okay, have some ZC inputs
CHECK_AND_ASSERT_MES(zc_ins_count == ogc.pseudo_outs_plus_real_out_blinding_masks.size(), false, "zc_ins_count != pseudo_outs_plus_real_out_blinding_masks");
@ -84,7 +84,7 @@ namespace currency
{
const crypto::public_key H = ogc.asset_ids[j].to_public_key();
const crypto::point_t& T = ogc.blinded_asset_ids[j];
std::vector<crypto::point_t> ring;
ring.reserve(zc_ins_count);
size_t secret_index = SIZE_MAX;
@ -172,7 +172,7 @@ namespace currency
if (is_asset_emitting_transaction(tx, &ado))
{
crypto::point_t asset_id_pt{};
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &asset_id_pt, nullptr), false, "get_or_calculate_asset_id failed"); // TODO @#@# expensive operation, consider caching
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &asset_id_pt, nullptr), false, "get_or_calculate_asset_id failed"); // TODO @#@# expensive operation, consider caching
pseudo_outs_blinded_asset_ids.emplace_back(asset_id_pt); // additional ring member for asset emitting tx
}
@ -368,7 +368,7 @@ namespace currency
bool pos /* = false */,
const pos_entry& pe /* = pos_entry() */, // only pe.stake_unlock_time and pe.stake_amount are used now, TODO: consider refactoring -- sowle
tx_generation_context* ogc_ptr /* = nullptr */,
const keypair* tx_one_time_key_to_use /* = nullptr */,
const keypair* tx_one_time_key_to_use /* = nullptr */,
const std::vector<tx_destination_entry>& destinations_ /* = std::vector<tx_destination_entry>() */
)
{
@ -388,7 +388,7 @@ namespace currency
{
block_reward += fee;
}
if (!destinations.size())
{
//
@ -454,7 +454,7 @@ namespace currency
if (!add_tx_extra_userdata(tx, extra_nonce))
return false;
//at this moment we do apply_unlock_time only for coin_base transactions
//at this moment we do apply_unlock_time only for coin_base transactions
apply_unlock_time(destinations, tx);
//we always add extra_padding with 2 bytes length to make possible for get_block_template to adjust cumulative size
tx.extra.push_back(extra_padding());
@ -504,7 +504,7 @@ namespace currency
tx_gen_context.amount_commitments_sum += tx_gen_context.amount_commitments[output_index];
++output_index;
}
if (tx.attachment.size())
add_attachments_info_to_extra(tx.extra, tx.attachment);
@ -521,7 +521,7 @@ namespace currency
if (tx.version > TRANSACTION_VERSION_PRE_HF4 && !pos)
{
// This is for PoW blocks only, because PoS blocks proofs are handled in wallet2::prepare_and_sign_pos_block() due to the necessity of making Zarcanum proofs first
//
//
// tx hash should be sealed by now
crypto::hash tx_id = get_transaction_hash(tx);
@ -684,7 +684,7 @@ namespace currency
}
return true;
}
// pre-HF4 txs
return check_tx_bare_balance(tx, additional_inputs_amount_and_fees_for_mining_tx);
}
@ -824,7 +824,7 @@ namespace currency
if (ts < WALLET_BRAIN_DATE_OFFSET)
return false;
creation_timestamp = ts;
}
@ -854,7 +854,7 @@ namespace currency
uint64_t amount_in = 0;
uint64_t amount_out = get_outs_money_amount(tx);
for(auto& in : tx.vin)
amount_in += get_amount_from_variant(in);
@ -870,9 +870,9 @@ namespace currency
fee += ztd.fee;
return true; // continue
};
bool r = process_type_in_variant_container<zarcanum_tx_data_v1>(tx.extra, cb, false);
if (!r)
{
fee = 0;
@ -1147,7 +1147,7 @@ namespace currency
//a.meta_info;
//if (a.owner != b.owner) return false;
if (new_ado.hidden_supply != prev_ado.hidden_supply) return false;
return true;
}
//---------------------------------------------------------------
@ -1200,12 +1200,12 @@ namespace currency
crypto::scalar_t amount_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_AMOUNT_MASK, h);
out.encrypted_amount = de.amount ^ amount_mask.m_u64[0];
CHECK_AND_ASSERT_MES(~de.flags & tx_destination_entry_flags::tdef_explicit_native_asset_id || de.asset_id == currency::native_coin_asset_id, false, "explicit_native_asset_id may be used only with native asset id");
asset_blinding_mask = de.flags & tx_destination_entry_flags::tdef_explicit_native_asset_id ? 0 : crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_ASSET_BLINDING_MASK, h); // s = Hs(domain_sep, Hs(8 * r * V, i))
blinded_asset_id = crypto::point_t(de.asset_id) + asset_blinding_mask * crypto::c_point_X;
out.blinded_asset_id = (crypto::c_scalar_1div8 * blinded_asset_id).to_public_key(); // T = 1/8 * (H_asset + s * X)
amount_blinding_mask = de.flags & tx_destination_entry_flags::tdef_zero_amount_blinding_mask ? 0 : crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_AMOUNT_BLINDING_MASK, h); // y = Hs(domain_sep, Hs(8 * r * V, i))
amount_commitment = de.amount * blinded_asset_id + amount_blinding_mask * crypto::c_point_G;
out.amount_commitment = (crypto::c_scalar_1div8 * amount_commitment).to_public_key(); // E = 1/8 * e * T + 1/8 * y * G
@ -1221,10 +1221,10 @@ namespace currency
out.stealth_address = (h * crypto::c_point_G + crypto::point_t(apa.spend_public_key)).to_public_key();
out.concealing_point = (crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_CONCEALING_POINT, h) * crypto::point_t(apa.view_public_key)).to_public_key(); // Q = 1/8 * Hs(domain_sep, Hs(8 * r * V, i) ) * 8 * V
crypto::scalar_t amount_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_AMOUNT_MASK, h);
out.encrypted_amount = de.amount ^ amount_mask.m_u64[0];
CHECK_AND_ASSERT_MES(~de.flags & tx_destination_entry_flags::tdef_explicit_native_asset_id || de.asset_id == currency::native_coin_asset_id, false, "explicit_native_asset_id may be used only with native asset id");
asset_blinding_mask = de.flags & tx_destination_entry_flags::tdef_explicit_native_asset_id ? 0 : crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_ASSET_BLINDING_MASK, h); // s = Hs(domain_sep, Hs(8 * r * V, i))
blinded_asset_id = crypto::point_t(de.asset_id) + asset_blinding_mask * crypto::c_point_X;
@ -1243,7 +1243,7 @@ namespace currency
DBG_VAL_PRINT(amount_blinding_mask);
DBG_VAL_PRINT(amount_mask);
DBG_VAL_PRINT(amount_commitment);
if (de.addr.front().is_auditable())
out.mix_attr = CURRENCY_TO_KEY_OUT_FORCED_NO_MIX; // override mix_attr to 1 for auditable target addresses
else
@ -1251,7 +1251,7 @@ namespace currency
uint16_t hint = get_derivation_hint(reinterpret_cast<crypto::key_derivation&>(derivation));
if (deriv_cache.count(hint) == 0)
{
{
tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint));
deriv_cache.insert(hint);
}
@ -1283,7 +1283,7 @@ namespace currency
uint16_t hint = get_derivation_hint(derivation);
if (deriv_cache.count(hint) == 0)
{
{
tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint));
deriv_cache.insert(hint);
}
@ -1321,7 +1321,7 @@ namespace currency
if (htlc_dest.htlc_hash == null_hash)
{
//we use deterministic origin, to make possible access origin on different wallets copies
result.htlc_origin = generate_origin_for_htlc(htlc, self);
//calculate hash
@ -1351,7 +1351,7 @@ namespace currency
tk.mix_attr = CURRENCY_TO_KEY_OUT_FORCED_NO_MIX; // override mix_attr to 1 for auditable target addresses
else
tk.mix_attr = tx_outs_attr;
out.target = tk;
}
else
@ -1398,14 +1398,14 @@ namespace currency
eai.cnt = attachment.size();
}
//---------------------------------------------------------------
bool construct_tx(const account_keys& sender_account_keys,
bool construct_tx(const account_keys& sender_account_keys,
const std::vector<tx_source_entry>& sources,
const std::vector<tx_destination_entry>& destinations,
const std::vector<attachment_v>& attachments,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
uint64_t unlock_time,
uint8_t tx_outs_attr,
uint8_t tx_outs_attr,
bool shuffle)
{
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
@ -1538,7 +1538,7 @@ namespace currency
const crypto::key_derivation& rkey;
std::vector<payload_items_v>& rdecrypted_att;
decrypt_attach_visitor(const crypto::key_derivation& key,
std::vector<payload_items_v>& decrypted_att,
std::vector<payload_items_v>& decrypted_att,
const account_keys& acc_keys,
bool is_income,
const transaction& tx,
@ -1546,8 +1546,8 @@ namespace currency
rkey(key),
m_tx(tx),
m_is_income(is_income),
rdecrypted_att(decrypted_att),
m_acc_keys(acc_keys),
rdecrypted_att(decrypted_att),
m_acc_keys(acc_keys),
m_tx_onetime_pubkey(tx_onetime_pubkey)
{}
void operator()(const tx_comment& comment)
@ -1572,7 +1572,7 @@ namespace currency
{
return; // this field invisible for sender
}
//decrypting derivation
//decrypting derivation
derivation_local = *(crypto::key_derivation*)&sa.security[0];
crypto::chacha_crypt(derivation_local, m_acc_keys.spend_secret_key);
}
@ -1591,7 +1591,7 @@ namespace currency
else
{
crypto::chacha_crypt(local_sa.body, derivation_local);
}
}
}
if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY)
@ -1733,11 +1733,11 @@ namespace currency
for (auto& a : tx.attachment)
boost::apply_visitor(v, a);
return true;
}
const crypto::public_key onetime_pub = get_tx_pub_key_from_extra(tx);
const crypto::public_key onetime_pub = get_tx_pub_key_from_extra(tx);
decrypt_payload_items(derivation, tx.extra, decrypted_items, is_income, tx, acc_keys, onetime_pub);
decrypt_payload_items(derivation, tx.attachment, decrypted_items, is_income, tx, acc_keys, onetime_pub);
return true;
@ -1922,7 +1922,7 @@ namespace currency
{
//
//find target account to encrypt attachment.
//for now we use just firs target account that is not sender,
//for now we use just firs target account that is not sender,
//in case if there is no real targets we use sender credentials to encrypt attachments
account_public_address crypt_destination_addr = get_crypt_address_from_destinations(sender_account_keys, destinations);
@ -2182,9 +2182,9 @@ namespace currency
return native_coin_asset_descriptor;
}
bool construct_tx_handle_ado(const account_keys& sender_account_keys,
const finalize_tx_param& ftp,
asset_descriptor_operation& ado,
bool construct_tx_handle_ado(const account_keys& sender_account_keys,
const finalize_tx_param& ftp,
asset_descriptor_operation& ado,
tx_generation_context& gen_context,
const keypair& tx_key,
std::vector<tx_destination_entry>& shuffled_dsts)
@ -2198,7 +2198,7 @@ namespace currency
// old:
// asset_control_key = Hs(CRYPTO_HDS_ASSET_CONTROL_KEY, 8 * tx_key.sec * sender_account_keys.account_address.spend_public_key, 0)
// ado.descriptor.owner = asset_control_key * G
ado.descriptor.owner = sender_account_keys.account_address.spend_public_key;
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &gen_context.ao_asset_id_pt, &gen_context.ao_asset_id), false, "get_or_calculate_asset_id failed");
@ -2252,7 +2252,7 @@ namespace currency
ado.amount_commitment = (crypto::c_scalar_1div8 * gen_context.ao_amount_commitment).to_public_key();
if (ftp.pevents_dispatcher) ftp.pevents_dispatcher->RAISE_DEBUG_EVENT(wde_construct_tx_handle_asset_descriptor_operation_before_burn{ &ado });
}
else
{
@ -2323,7 +2323,7 @@ namespace currency
const uint8_t& tx_outs_attr = ftp.tx_outs_attr;
const bool& shuffle = ftp.shuffle;
const uint64_t& flags = ftp.flags;
bool r = false;
transaction& tx = result.tx;
crypto::secret_key& one_time_tx_secret_key = result.one_time_key;
@ -2348,7 +2348,7 @@ namespace currency
if (flags != 0)
set_tx_flags(tx, flags);
//generate key pair
//generate key pair
if (expiration_time != 0)
set_tx_expiration_time(tx, expiration_time);
}
@ -2474,7 +2474,7 @@ namespace currency
if (src_entr.is_zc())
{
// if at least one decoy output of a ZC input has a non-explicit asset id, then we can't say that all inputs are obviously native coins
// if at least one decoy output of a ZC input has a non-explicit asset id, then we can't say that all inputs are obviously native coins
for (const tx_source_entry::output_entry& oe : in_context.outputs)
{
if (crypto::point_t(oe.blinded_asset_id).modify_mul8() != currency::native_coin_asset_id_pt)
@ -2515,7 +2515,7 @@ namespace currency
CHECK_AND_ASSERT_MES(gen_context.tx_key.pub != null_pkey && gen_context.tx_key.sec != null_skey, false, "In append mode both public and secret keys must be provided");
//separately encrypt attachments without putting extra
result.derivation = get_encryption_key_derivation(true, tx, sender_account_keys);
result.derivation = get_encryption_key_derivation(true, tx, sender_account_keys);
crypto::key_derivation& derivation = result.derivation;
CHECK_AND_ASSERT_MES(derivation != null_derivation, false, "failed to generate_key_derivation");
bool was_attachment_crypted_entries = false;
@ -2545,7 +2545,7 @@ namespace currency
}
//
// OUTs
//
@ -2569,7 +2569,7 @@ namespace currency
if (shuffle)
std::sort(shuffled_dsts.begin(), shuffled_dsts.end(), [](const tx_destination_entry& de1, const tx_destination_entry& de2) { return de1.amount < de2.amount; });
// TODO: consider "Shuffle" inputs
// TODO: consider "Shuffle" inputs
// construct outputs
uint64_t native_coins_output_sum = 0;
@ -2660,7 +2660,7 @@ namespace currency
if (tx.attachment.size())
add_attachments_info_to_extra(tx.extra, tx.attachment);
}
//
// generate proofs and signatures
@ -2677,7 +2677,7 @@ namespace currency
size_t i_mapped = inputs_mapping[i_];
const tx_source_entry& source_entry = sources[i_mapped];
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, i_ + input_starter_index, tx_prefix_hash);
CHECK_AND_ASSERT_MES(tx_hash_for_signature != null_hash, false, "prepare_prefix_hash_for_sign failed");
CHECK_AND_ASSERT_MES(tx_hash_for_signature != null_hash, false, "prepare_prefix_hash_for_sign failed");
std::stringstream ss_ring_s;
if (source_entry.is_zc())
@ -2733,8 +2733,8 @@ namespace currency
aop.opt_amount_commitment_g_proof = aop_g_sig;
tx.proofs.emplace_back(std::move(aop));
}
if(ftp.need_to_generate_ado_proof)
{
if(ftp.need_to_generate_ado_proof)
{
asset_operation_ownership_proof aoop = AUTO_VAL_INIT(aoop);
if (ftp.pthirdparty_sign_handler)
@ -2745,7 +2745,7 @@ namespace currency
}
else
{
//generate signature by wallet account
//generate signature by wallet account
r = crypto::generate_schnorr_sig(tx_prefix_hash, ftp.ado_current_asset_owner, sender_account_keys.spend_secret_key, aoop.gss);
CHECK_AND_ASSERT_MES(r, false, "Failed to sign ado proof");
}
@ -2794,7 +2794,7 @@ namespace currency
VARIANT_CASE_CONST(tx_out_bare, o)
reward += o.amount;
VARIANT_CASE_CONST(tx_out_zarcanum, o)
//@#@
//@#@
VARIANT_SWITCH_END();
}
reward -= income;
@ -2828,7 +2828,7 @@ namespace currency
password_used = false;
}
uint64_t timestamp = count_of_weeks * WALLET_BRAIN_DATE_QUANTUM + WALLET_BRAIN_DATE_OFFSET;
return timestamp;
}
//---------------------------------------------------------------
@ -2896,7 +2896,7 @@ namespace currency
size_t participant_index = std::find(out_ms.keys.begin(), out_ms.keys.end(), ms_in_ephemeral_key.pub) - out_ms.keys.begin();
LOC_CHK(participant_index < out_ms.keys.size(), "Can't find given participant's ms key in ms output keys list");
LOC_CHK(ms_input_index < tx.signatures.size(), "transaction does not have signatures vector entry for ms input #" << ms_input_index);
LOC_CHK(tx.signatures[ms_input_index].type() == typeid(NLSAG_sig), "Wrong type of signature");
auto& sigs = boost::get<NLSAG_sig>(tx.signatures[ms_input_index]).s;
LOC_CHK(!sigs.empty(), "empty signatures container");
@ -2904,7 +2904,7 @@ namespace currency
bool extra_signature_expected = (get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE) && ms_input_index == tx.vin.size() - 1;
size_t allocated_sigs_for_participants = extra_signature_expected ? sigs.size() - 1 : sigs.size();
LOC_CHK(participant_index < allocated_sigs_for_participants, "participant index (" << participant_index << ") is out of bound: " << allocated_sigs_for_participants); // NOTE: this may fail if the input has already been fully signed and 'sigs' was compacted
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, ms_input_index, get_transaction_hash(tx));
LOC_CHK(tx_hash_for_signature != null_hash, "failed to prepare_prefix_hash_for_sign");
@ -2969,7 +2969,7 @@ namespace currency
in.type() == typeid(txin_to_key) ||
in.type() == typeid(txin_multisig) ||
in.type() == typeid(txin_htlc) ||
in.type() == typeid(txin_zc_input),
in.type() == typeid(txin_zc_input),
false, "wrong input type: " << in.type().name() << ", in transaction " << get_transaction_hash(tx));
}
return true;
@ -2978,7 +2978,7 @@ namespace currency
/*
bool add_padding_to_tx(transaction& tx, size_t count)
{
WARNING: potantially unsafe implementation!
1) requires extra_padding being previously added to tx's extra;
2) transaction size may increase by more than 'count' bytes due to varint encoding (thus, if 'count' is 128 it will add 129 bytes)
@ -3039,7 +3039,7 @@ namespace currency
VARIANT_CASE_CONST(tx_out_bare, out)
{
CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
VARIANT_SWITCH_BEGIN(out.target);
VARIANT_CASE_CONST(txout_to_key, tk)
if (!check_key(tk.key))
@ -3253,7 +3253,7 @@ namespace currency
return false;
return true;
}
}
//---------------------------------------------------------------
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<wallet_out_info>& outs, crypto::key_derivation& derivation)
{
@ -3515,7 +3515,7 @@ namespace currency
return ts;
}
}
// next try etc_tx_time
etc_tx_time t = AUTO_VAL_INIT(t);
if (get_type_in_variant_container(b.miner_tx.extra, t))
@ -3564,7 +3564,7 @@ namespace currency
//------------------------------------------------------------------
#define ANTI_OVERFLOW_AMOUNT 1000000
#define GET_PERECENTS_BIG_NUMBERS(per, total) (per/ANTI_OVERFLOW_AMOUNT)*100 / (total/ANTI_OVERFLOW_AMOUNT)
#define GET_PERECENTS_BIG_NUMBERS(per, total) (per/ANTI_OVERFLOW_AMOUNT)*100 / (total/ANTI_OVERFLOW_AMOUNT)
void print_reward_change()
{
@ -3587,7 +3587,7 @@ namespace currency
std::cout << std::left
<< std::setw(10) << day
<< std::setw(19) << print_money(emission_reward)
<< std::setw(4) << print_money(already_generated_coins)
<< std::setw(4) << print_money(already_generated_coins)
<< "(POS: " << boost::lexical_cast<std::string>(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pos, money_was_at_begining_of_year)) << "%"
<< ", POW: " << boost::lexical_cast<std::string>(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pow, money_was_at_begining_of_year)) << "%)"
@ -3622,7 +3622,7 @@ namespace currency
{
// std::cout << std::endl << "Reward change for 20 days:" << std::endl;
// std::cout << std::setw(10) << std::left << "day" << std::setw(19) << "block reward" << std::setw(19) << "generated coins" << std::endl;
//
//
// const boost::multiprecision::uint128_t& already_generated_coins = PREMINE_AMOUNT;
// //uint64_t total_money_supply = TOTAL_MONEY_SUPPLY;
// uint64_t h = 0;
@ -3630,15 +3630,15 @@ namespace currency
// {
// uint64_t emission_reward = 0;
// get_block_reward(h % 2, 0, 0, already_generated_coins, emission_reward, h, (already_generated_coins - PREMINE_AMOUNT) * 140);
//
//
// std::cout << std::left
// << std::setw(10) << day
// << std::setw(19) << print_money(emission_reward)
// << std::setw(4) << print_money(already_generated_coins)//std::string(std::to_string(GET_PERECENTS_BIG_NUMBERS((already_generated_coins), total_money_supply)) + "%")
// << std::endl;
//
//
//
//
//
//
// for (size_t i = 0; i != 720; i++)
// {
// h++;
@ -3649,7 +3649,7 @@ namespace currency
// }
// }
}
std::string print_reward_change_first_blocks(size_t n_of_first_blocks)
{
std::stringstream ss;
@ -3691,7 +3691,7 @@ namespace currency
//------------------------------------------------------------------
void print_currency_details()
{
//for future forks
//for future forks
std::cout << "Currency name: \t\t" << CURRENCY_NAME << "(" << CURRENCY_NAME_SHORT << ")" << std::endl;
std::cout << "Money supply: \t\t " << CURRENCY_BLOCK_REWARD * CURRENCY_BLOCKS_PER_DAY * 365 << " coins per year" << std::endl;
@ -3725,10 +3725,12 @@ namespace currency
#ifndef TESTNET
// std::string genesis_coinbase_tx_hex((const char*)&ggenesis_tx_raw, sizeof(ggenesis_tx_raw));
#else
#else
std::string genesis_coinbase_tx_hex = "";
#endif
// Testnet proof phrase: "It takes advantage of the nature of information being easy to spread but hard to stifle. - Satoshi Nakamoto"
//genesis proof phrase: "Liverpool beat Barcelona: Greatest Champions League comebacks of all time"
//taken from: https://www.bbc.com/sport/football/48163330
//sha3-256 from proof phrase: a074236b1354901d5dbc029c0ac4c05c948182c34f3030f32b0c93aee7ba275c (included in genesis block)
@ -3967,7 +3969,7 @@ namespace currency
}
else// if (ao.type() == typeid(ref_by_id))
{
//disable for the reset at the moment
//disable for the reset at the moment
entry_to_fill.global_indexes.back() = std::numeric_limits<uint64_t>::max();
}
}
@ -3987,7 +3989,7 @@ namespace currency
{
entry_to_fill.multisig_count = boost::get<NLSAG_sig>(tx.signatures[tei.ins.size() - 1]).s.size();
}
}
}
return true;
@ -4034,7 +4036,7 @@ namespace currency
gindices[amount] += 1;
}
VARIANT_CASE_CONST(tx_out_zarcanum, o)
//@#@
//@#@
VARIANT_SWITCH_END();
}
}
@ -4072,7 +4074,7 @@ namespace currency
{
if (!height)
return PREMINE_AMOUNT;
return CURRENCY_BLOCK_REWARD;
}
//-----------------------------------------------------------------------------------------------
@ -4152,12 +4154,12 @@ namespace currency
std::string get_account_address_as_str(const account_public_address& addr)
{
if (addr.flags == 0)
return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr.to_old())); // classic Zano address
return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr.to_old())); // classic Lethean address
if (addr.flags & ACCOUNT_PUBLIC_ADDRESS_FLAG_AUDITABLE)
return tools::base58::encode_addr(CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Zano address (auditable)
return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Zano address (normal)
return tools::base58::encode_addr(CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Lethean address (auditable)
return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Lethean address (normal)
}
//-----------------------------------------------------------------------
bool is_address_like_wrapped(const std::string& addr)
@ -4170,12 +4172,12 @@ namespace currency
std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const payment_id_t& payment_id)
{
if (addr.flags == 0)
return tools::base58::encode_addr(CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr.to_old()) + payment_id); // classic integrated Zano address
return tools::base58::encode_addr(CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr.to_old()) + payment_id); // classic integrated Lethean address
if (addr.flags & ACCOUNT_PUBLIC_ADDRESS_FLAG_AUDITABLE)
return tools::base58::encode_addr(CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr) + payment_id); // new format integrated Zano address (auditable)
return tools::base58::encode_addr(CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX, t_serializable_object_to_blob(addr) + payment_id); // new format integrated Zano address (normal)
return tools::base58::encode_addr(CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr) + payment_id); // new format integrated Lethean address (auditable)
return tools::base58::encode_addr(CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX, t_serializable_object_to_blob(addr) + payment_id); // new format integrated Lethean address (normal)
}
//-----------------------------------------------------------------------
bool get_account_address_from_str(account_public_address& addr, const std::string& str)
@ -4388,12 +4390,12 @@ namespace currency
size_t i = 0;
for (auto& p_out_k : output_keys_ptrs)
s << " " << std::setw(2) << i++ << " " << *p_out_k << ENDL;
s << " signatures (" << sig.size() << ")" << ENDL;
i = 0;
for (auto& sig_el : sig)
s << " " << std::setw(2) << i++ << " " << sig_el << ENDL;
return s.str();
}
@ -4438,7 +4440,7 @@ namespace currency
{
if (a.cnt == b.cnt && a.hsh == b.hsh && a.sz == b.sz)
return true;
else
else
return false;
}
//--------------------------------------------------------------------------------
@ -4540,7 +4542,7 @@ namespace currency
// << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
// << ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
// );
// }
TRY_ENTRY();
@ -4549,7 +4551,7 @@ namespace currency
CATCH_ENTRY_WITH_FORWARDING_EXCEPTION();
}
//--------------------------------------------------------------------------------
// Note: we adjust formula and introduce multiplier,
// Note: we adjust formula and introduce multiplier,
// that let us never dive into floating point calculations (which we can't use in consensus)
// this multiplier should be greater than max multiprecision::uint128_t power 2
@ -4585,7 +4587,7 @@ namespace currency
// << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
// << ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
// );
// }
TRY_ENTRY();

View file

@ -14,7 +14,7 @@
#include "common/int-util.h"
#include "crypto/hash.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "difficulty.h"
#include "profile_tools.h"
@ -55,7 +55,7 @@ namespace currency {
return a + b < a || (c && a + b == (uint64_t)-1);
}
#if defined(_MSC_VER)
#ifdef max
#undef max
@ -98,7 +98,7 @@ namespace currency {
return false;
// usual slow check
boost::multiprecision::uint512_t hashVal = 0;
for(int i = 0; i < 4; i++)
for(int i = 0; i < 4; i++)
{
hashVal <<= 64;
hashVal |= swap64le(((const uint64_t *) &h)[3-i]);
@ -155,7 +155,7 @@ namespace currency {
cut_end = cut_begin + (REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST));
if (cut_end > length)
cut_end = length;
}
CHECK_AND_ASSERT_THROW_MES(/*cut_begin >= 0 &&*/ cut_begin + 2 <= cut_end && cut_end <= length, "validation in next_difficulty is failed");
}
@ -201,11 +201,11 @@ namespace currency {
CHECK_AND_ASSERT_MES(length <= DIFFICULTY_WINDOW, 0, "length <= DIFFICULTY_WINDOW check failed, length=" << length);
sort(timestamps.begin(), timestamps.end(), std::greater<uint64_t>());
static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Cut length is too large");
wide_difficulty_type dif_slow = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW, DIFFICULTY_CUT/2, DIFFICULTY_CUT/2);
wide_difficulty_type dif_medium = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW/3, DIFFICULTY_CUT / 8, DIFFICULTY_CUT / 12);
wide_difficulty_type dif_fast = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW/18, DIFFICULTY_CUT / 10, 2);
wide_difficulty_type dif_fast = get_adjustment_for_zone(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_WINDOW/18, DIFFICULTY_CUT / 10, 2);
uint64_t devider = 1;
wide_difficulty_type summ = dif_slow;
if (dif_medium != 0)

View file

@ -8,13 +8,13 @@
namespace currency
{
#ifndef TESTNET
const genesis_tx_raw_data ggenesis_tx_raw = { {
0xa080801a00000101,0x800326b0b4a0f2fd,0xeebe5a6d44a03ed5,0x0e146a5322076dcf,0x992269ec1e34796e,0x003b14d1fe6c757e,0xb0b4a0f2fda08080,0xfd92adf982e70326,0xd8d4b6458b60e1a4,0xa69adb9475e808ed,0x4c383fcedfb6e20a,0xf2fda08080003458,0x8b177f0326b0b4a0,0xef9769ed70d152cd,0x04097d0daa65d123,0x9cd9f8e708f25bbc,0x8080005dfb23beac,0x0326b0b4a0f2fda0,0x6752077f8e75fc8a,0x437f68e0bf774836,0x5a38b52ff21c01c0,0x2d3727ec82ce1425,0xb4f89aecdce08000,0xa07d9fe35f0326b0,0x6c742533eb3b4261,0xfc2ed631332e5e16,0x3d025449393e538b,0x93dc80800015e433,0x70a20307d0ffc2e0,0xb81808dc5029bd46,0x04129413283e31f1,0x143e631cc81020b0,0x80008519d1377ae3,0x05c6c5bc97b1a080,0xf71887a841a72a03,0x681b659b8d2832d4,0x5677f9b15d11d1e6,0xffb2ad80c02a341c,0xbc97b1a08080003f,0xf9cebe7c0305c6c5,0xee223954dc682820,0x8194d2bac0dff6d6,0x86d8a55a30e30183,0xa08080006775f5f0,0x220305c6c5bc97b1,0x3c36e1ebdcee584a,0x4e9ed1a89532ef46,0xf0cb8b411bf6d579,0x00d0e6392ada64d4,0xc6c5bc97b1a08080,0x2fc2b05779450305,0xc9cf47618cc5283e,0xa9e088224807a77e,0xda854e29d2f49646,0x97b1a08080002e74,0xed35180305c6c5bc,0xa78d5545117b8293,0x5c3f8babc16e7062,0xef9324ecd7f86e39,0x808000231900ee9c,0x0305c6c5bc97b1a0,0x0c5bfd9450e89e30,0x194b86e8316970bc,0x5dd8c2e3c2af6ff1,0x4d2ba46f683df89c,0xc5bc97b1a0808000,0xc7cc22ad390305c6,0x891b500cb0799642,0xf5884473a7c01f07,0xeb88d74972d8e36f,0x91ed808000b5d239,0x535a0302fddecd95,0x791c7275cd15d685,0xc2536511d4132e01,0x0c9ad1ee9196aa77,0x80002d55a4efc7d3,0x018e8df2b7f0a080,0x0848b53f974a6a03,0x96b2572cb6015b7d,0xa71b18d2755de52c,0x075e4ca4bd0e4487,0xef93bf82808000ca,0xe23077bc730308f0,0x266a622b7bd9de26,0x4b80410b36c32203,0xb3026d0a2610916c,0xfe8480800084746d,0x6f34b90311e1dea6,0xeb38aee70a8febba,0x8b45df519f0df12e,0x258f0a71e83385da,0x8080000b85701a76,0xdf0308f0ef93bf82,0xb3170ab580f881a3,0x07f0a33f0756a3f4,0xf0721645b2b2bd7b,0x00b0077e03f43a85,0x08f0ef93bf828080,0xf91c1f6308c00f03,0x901a68f4adcc918b,0xad0346f5b7869662,0xd3ed49961fccd915,0xafeaa69a808000f0,0x2c99a01fe90301e3,0xd28642bcae6728d9,0xa6f38c4c630c2b6c,0x2c8a361de6b9294f,0xa69a8080002191e8,0xe134670301e3afea,0x6cf0798aeae985c8,0x4c9b90e1ff211b81,0xc32a954ce05a738b,0x8080009fd2412c6f,0x790301e3afeaa69a,0xb3b0062d6c27a6bb,0x12e133832172b705,0xf3f7d1dfdf336fb8,0x00922d0a879c6027,0x03c6dfd4ccb48080,0x7aa13f278feecf03,0x464f78f86a3e4553,0xa5a464e65c4cf651,0x18f07e7ed8bdd351,0xef93bf82808000dd,0x70b4e3ebae0308f0,0x74c452ecdce312d9,0xca3fb591982461fc,0x3e01aaf9b53ede69,0xfe84808000a4fa65,0x20e5ba0311e1dea6,0xb3e07ec0aabd06a5,0x7bf14a03bf83ccfd,0x6024154f95fd3220,0x808000c13077fa8b,0x5c580316deb183e9,0xc2c948248ab422c3,0xebd3db36bad27d52,0x5fe30392c1525a4e,0x1e00952287d66a6d,0x163df474d5ba8816,0x86f8892015449a71,0x22c93333d9ecb472,0x64fa5516bddfebb3,0x3234373061401303,0x3934353331623633,0x3063626435643130,0x6334636130633932,0x3831383439633530,0x3330336634336332,0x3963306232336630,0x3261623765656133,0x80c9170015633537,0x4c17fba117829117,0x17624a17d2f21711,0xfec81731f9178ced,0x9c17624117a36017,0x1786df17edda1708,0x9ffa17d6e1171b42,0x8b17aa69177ff417,0x179815170a83170c,0xc7e8171ce317da27 },
{ 0x17,0x86,0xd6,0x0e,0x0a,0x00,0x00 } };
const genesis_tx_raw_data ggenesis_tx_raw = {{
0xe980800100000101,0xfbfa3a0316deb183,0x0e4d0bf7103b2df2,0x682df55627fc33ed,0xcd945b3d70689611,0x16050066b218269a,0x34af8b24a9c955d2,0x3f514b3a2be34ee9,0xb6525b442410e776,0x256d4d83666fb42a,0x6b61742074496b13,0x6e61766461207365,0x20666f2065676174,0x7574616e20656874,0x6e6920666f206572,0x6f6974616d726f66,0x20676e696562206e,0x206f742079736165,0x6220646165727073,0x2064726168207475,0x6c66697473206f74,0x746153202d202e65,0x6b614e206968736f,0x0b00156f746f6d61},
{0x02,0x8a,0x56,0x0e,0x0a,0x00,0x00}};
#else
const genesis_tx_raw_data ggenesis_tx_raw = {{
0xd880800500000101,0x0301f2ee9fa8ff8a,0xac88983c159856b0,0x6334c7d1b567f262,0x284f7f961a7b1266,0x8c0c68c45bab62fc,0xe1dea6fe84808000,0x337be98b45240311,0xab6cd1e4c66e5a33,0x70e889d98e70fd57,0xb97de43fb09861d4,0xf9f0cde08000d574,0x0270187703048dba,0xcac58027c0851473,0xaa10d864c4c87b46,0x820d371e2ba469e8,0xfea08000fce35acc,0x357903049598bddf,0x15df9e58bd0002aa,0xc940a97b60484e8d,0xf94f171e77d0b2d9,0x80003602c681487a,0x0304c38fbab1f8e0,0xc2529eba91cf7476,0x0bbee139aab295f9,0xf1cb8c58a828a2ca,0xcac8f5469af83932,0x5c8a1027cc160900,0x50bdcc9348baf32a,0xa7bd03751819d9fd,0xd6acc8dbbb0d9b29,0x3730614013368b02,0x3533316236333234,0x6264356431303934,0x6361306339323063,0x3834396335306334,0x3366343363323831,0x3062323366303330,0x6237656561333963,0x1700156335373261,0xce5017baa917a8f0,0x0a0eefcc17975617},
{0x00,0x00}};
const genesis_tx_raw_data ggenesis_tx_raw = {{
0xe980800100000101,0xfbfa3a0316deb183,0x0e4d0bf7103b2df2,0x682df55627fc33ed,0xcd945b3d70689611,0x16050066b218269a,0x34af8b24a9c955d2,0x3f514b3a2be34ee9,0xb6525b442410e776,0x256d4d83666fb42a,0x6b61742074496b13,0x6e61766461207365,0x20666f2065676174,0x7574616e20656874,0x6e6920666f206572,0x6f6974616d726f66,0x20676e696562206e,0x206f742079736165,0x6220646165727073,0x2064726168207475,0x6c66697473206f74,0x746153202d202e65,0x6b614e206968736f,0x0b00156f746f6d61},
{0x02,0x8a,0x56,0x0e,0x0a,0x00,0x00}};
#endif
}

View file

@ -4,24 +4,23 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#pragma once
#include <string>
namespace currency
{
#pragma pack(push, 1)
#ifndef TESTNET
struct genesis_tx_raw_data
{
uint64_t const v[161];
uint8_t const r[7];
};
struct genesis_tx_raw_data
{
uint64_t const v[42];
uint8_t const r[2];
};
#else
struct genesis_tx_raw_data
{
uint64_t const v[42];
uint8_t const r[2];
};
struct genesis_tx_raw_data
{
uint64_t const v[24];
uint8_t const r[7];
};
#endif
#pragma pack(pop)
extern const genesis_tx_raw_data ggenesis_tx_raw;

View file

@ -10,48 +10,21 @@
namespace currency
{
#ifndef TESTNET
const std::string ggenesis_tx_pub_key_str = "88bad574f43d16719a44152089f88672b4ecd93333c922b3ebdfbd1655fa6403";
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
const genesis_tx_dictionary_entry ggenesis_dict[26] = {
{ 898363347618325980ULL,7 },
{ 1234271292339965434ULL,1 },
{ 2785329203593578547ULL,12 },
{ 2912579291078040461ULL,18 },
{ 3515932779881697835ULL,17 },
{ 4955366495399988463ULL,11 },
{ 5233257582118330150ULL,5 },
{ 5931539148443336682ULL,24 },
{ 6436517662239927298ULL,19 },
{ 6604452700210763953ULL,13 },
{ 7200550178847042641ULL,15 },
{ 8712326356392296687ULL,9 },
{ 8863158309745010598ULL,4 },
{ 9048445805125559105ULL,16 },
{ 9527474759752332295ULL,2 },
{ 9647541513390373765ULL,20 },
{ 9921730437908704447ULL,8 },
{ 10751885755236960099ULL,25 },
{ 11032572278436047420ULL,22 },
{ 11109691972771859220ULL,0 },
{ 13554174209305230569ULL,23 },
{ 14297297752337562678ULL,3 },
{ 15636081871140663679ULL,21 },
{ 15951161519112687845ULL,6 },
{ 17146058209502212345ULL,14 },
{ 17472133472787764818ULL,10 }
};
#else
const std::string ggenesis_tx_pub_key_str = "cc27108a5c2af3ba4893ccbd50fdd919187503bda7299b0dbbdbc8acd6028b36";
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
const genesis_tx_dictionary_entry ggenesis_dict[5] = {
{ 4413532107669521528ULL, 2 },
{ 4848259848862559835ULL, 4 },
{ 4891306118630423916ULL, 1 },
{ 6536034028979999929ULL, 0 },
{ 15528122346224653564ULL, 3 }
const std::string ggenesis_tx_pub_key_str = "d255c9a9248baf34e94ee32b3a4b513f76e71024445b52b62ab46f66834d6d25";
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
const genesis_tx_dictionary_entry ggenesis_dict[1] = {
{1056117391700764468ULL,0}
};
#endif
#else
const std::string ggenesis_tx_pub_key_str = "d255c9a9248baf34e94ee32b3a4b513f76e71024445b52b62ab46f66834d6d25";
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
const genesis_tx_dictionary_entry ggenesis_dict[1] = {
{1056117391700764468ULL,0}
};
#endif
}

View file

@ -23,9 +23,9 @@ struct genesis_tx_dictionary_entry {
#pragma pack(pop)
#ifndef TESTNET
extern const genesis_tx_dictionary_entry ggenesis_dict[26];
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
#else
extern const genesis_tx_dictionary_entry ggenesis_dict[5];
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
#endif
extern const crypto::public_key ggenesis_tx_pub_key;

View file

@ -12,7 +12,7 @@
#include "common/db_backend_selector.h"
#include "tx_pool.h"
#include "currency_boost_serialization.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "blockchain_storage.h"
#include "common/boost_serialization_helper.h"
#include "common/int-util.h"
@ -37,7 +37,7 @@ DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated
#define CONFLICT_KEY_IMAGE_SPENT_DEPTH_TO_REMOVE_TX_FROM_POOL 50 // if there's a conflict in key images between tx in the pool and in the blockchain this much depth in required to remove correspongin tx from pool
#undef LOG_DEFAULT_CHANNEL
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "tx_pool"
ENABLE_CHANNEL_BY_DEFAULT("tx_pool");
@ -52,7 +52,7 @@ namespace currency
m_db(nullptr, m_dummy_rw_lock),
m_db_transactions(m_db),
m_db_black_tx_list(m_db),
m_db_solo_options(m_db),
m_db_solo_options(m_db),
// m_db_key_images_set(m_db),
m_db_alias_names(m_db),
m_db_alias_addresses(m_db),
@ -69,13 +69,13 @@ namespace currency
}
const txin_multisig& ms_in = boost::get<const txin_multisig>(tx.vin[0]);
crypto::hash related_tx_id = null_hash; uint64_t out_no = 0;
crypto::hash related_tx_id = null_hash; uint64_t out_no = 0;
if (!m_blockchain.get_multisig_id_details(ms_in.multisig_out_id, related_tx_id, out_no))
{
LOG_ERROR("Related multisig tx not found, multisig_out_id=" << ms_in.multisig_out_id);
return false;
}
auto related_tx_ptr = m_blockchain.get_tx_chain_entry(related_tx_id);
if (!related_tx_ptr)
{
@ -83,7 +83,7 @@ namespace currency
<< "(discovered by reviewing tx " << get_transaction_hash(tx) <<") tx not found in blockchain, multisig_out_id=" << ms_in.multisig_out_id);
return false;
}
if (get_tx_fee(tx) < get_tx_fee(related_tx_ptr->tx))
{
LOG_ERROR("Tx " << get_transaction_hash(tx) << " fee=" << get_tx_fee(tx) << " less then parent multisig tx " << related_tx_id << " fee= " << get_tx_fee(related_tx_ptr->tx));
@ -109,7 +109,6 @@ namespace currency
// defaults
tvc.m_added_to_pool = false;
tvc.m_verification_failed = true;
if (!kept_by_block && !from_core && m_blockchain.is_in_checkpoint_zone())
{
// BCS is in CP zone, tx verification is impossible until it gets synchronized
@ -139,7 +138,7 @@ namespace currency
", diff: " << epee::misc_utils::get_time_interval_string(ts_median + TX_EXPIRATION_MEDIAN_SHIFT - tx_expiration_time) << ")");
tvc.m_verification_failed = true;
return false;
}
}
TIME_MEASURE_FINISH_PD(expiration_validate_time);
@ -170,7 +169,7 @@ namespace currency
{
if(!validate_tx_semantic(tx, blob_size))
{
{
// tx semantics check failed
LOG_PRINT_RED_L0("Transaction " << id << " semantics check failed ");
tvc.m_verification_failed = true;
@ -188,13 +187,13 @@ namespace currency
{
//if (is_valid_contract_finalization_tx(tx))
//{
// that means tx has less fee then allowed by current tx pull rules, but this transaction is actually
// a finalization of contract, and template of this contract finalization tx was prepared actually before
// that means tx has less fee then allowed by current tx pull rules, but this transaction is actually
// a finalization of contract, and template of this contract finalization tx was prepared actually before
// fee rules had been changed, so it's ok, let it in.
//}
//else
{
// this tx has no fee
// this tx has no fee
LOG_PRINT_RED_L0("Transaction " << id << " has too small fee: " << print_money_brief(tx_fee) << ", minimum fee: " << print_money_brief(m_blockchain.get_core_runtime_config().tx_pool_min_fee));
tvc.m_verification_failed = false;
tvc.m_should_be_relayed = false;
@ -225,7 +224,6 @@ namespace currency
TIME_MEASURE_FINISH_PD(check_inputs_time);
do_insert_transaction(tx, id, blob_size, kept_by_block, tx_fee, ch_inp_res ? max_used_block_id : null_hash, ch_inp_res ? max_used_block_height : 0);
TIME_MEASURE_FINISH_PD(tx_processing_time);
tvc.m_added_to_pool = true;
tvc.m_should_be_relayed = ch_inp_res; // relay tx only if it has valid inputs (i.e. do not relay kept_by_block tx with wrong inputs)
@ -348,7 +346,7 @@ namespace currency
extra_alias_entry eai2 = AUTO_VAL_INIT(eai2);
bool already_have_alias_registered = m_blockchain.get_alias_info(eai.m_alias, eai2);
//size_t alias_size = eai.m_alias.size();
if (!is_in_block && !eai.m_sign.size() && already_have_alias_registered)
{
LOG_PRINT_L0("Alias \"" << eai.m_alias << "\" already registered in blockchain, transaction rejected");
@ -360,8 +358,8 @@ namespace currency
if (!is_in_block && !eai.m_sign.size() &&
prev_alias.size())
{
LOG_PRINT_L0("Address \"" << get_account_address_as_str(eai.m_address)
<< "\" already registered with \""<< prev_alias
LOG_PRINT_L0("Address \"" << get_account_address_as_str(eai.m_address)
<< "\" already registered with \""<< prev_alias
<< "\" alias in blockchain (new alias: \"" << eai.m_alias << "\"), transaction rejected");
r = false;
return false; // stop handling
@ -408,10 +406,10 @@ namespace currency
//---------------------------------------------------------------------------------
bool tx_memory_pool::take_tx(const crypto::hash &id, transaction &tx, size_t& blob_size, uint64_t& fee)
{
m_db_transactions.begin_transaction();
misc_utils::auto_scope_leave_caller seh = misc_utils::create_scope_leave_handler([&](){m_db_transactions.commit_transaction();});
auto txe_tr = m_db_transactions.find(id);
if (txe_tr == m_db_transactions.end())
return false;
@ -431,13 +429,13 @@ namespace currency
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::remove_stuck_transactions()
{
{
if (!CRITICAL_SECTION_TRY_LOCK(m_remove_stuck_txs_lock))
return true;
CRITICAL_REGION_LOCAL(m_remove_stuck_txs_lock);
CRITICAL_SECTION_UNLOCK(m_remove_stuck_txs_lock);// release try_lock iteration
m_db_transactions.begin_transaction();
misc_utils::auto_scope_leave_caller seh = misc_utils::create_scope_leave_handler([&](){m_db_transactions.commit_transaction(); });
@ -450,14 +448,14 @@ namespace currency
transaction tx;
bool kept_by_block;
};
std::vector<tx_to_delete_entry> to_delete;
const uint64_t tx_expiration_ts_median = m_blockchain.get_tx_expiration_median();
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{
//never remove transactions which related to alt blocks,
//or we can get network split as a worst case (impossible to switch to
//never remove transactions which related to alt blocks,
//or we can get network split as a worst case (impossible to switch to
//altchain if it won, and node stuck forever).
if (m_blockchain.is_tx_related_to_altblock(h))
return true;
@ -503,7 +501,7 @@ namespace currency
return true;
});
for (auto& e : to_delete)
{
m_db_transactions.erase(e.hash);
@ -514,7 +512,7 @@ namespace currency
return true;
}
//---------------------------------------------------------------------------------
size_t tx_memory_pool::get_transactions_count() const
size_t tx_memory_pool::get_transactions_count() const
{
return m_db_transactions.size();
}
@ -628,7 +626,7 @@ namespace currency
m_blockchain.fill_tx_rpc_details(trei, ptei->tx, nullptr, id, ptei->receive_time, false);
return true;
}
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::get_transaction(const crypto::hash& id, transaction& tx) const
{
@ -703,7 +701,7 @@ namespace currency
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::have_tx(const crypto::hash &id) const
{
{
if(m_db_transactions.get(id))
return true;
@ -746,21 +744,21 @@ namespace currency
}
return false;
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
bool tx_memory_pool::on_tx_add(crypto::hash tx_id, const transaction& tx, bool kept_by_block)
{
insert_key_images(tx_id, tx, kept_by_block);
insert_alias_info(tx);
return true;
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
bool tx_memory_pool::on_tx_remove(const crypto::hash &id, const transaction& tx, bool kept_by_block)
{
remove_key_images(id, tx, kept_by_block);
remove_alias_info(tx);
return true;
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
bool tx_memory_pool::insert_alias_info(const transaction& tx)
{
tx_extra_info ei = AUTO_VAL_INIT(ei);
@ -774,10 +772,10 @@ namespace currency
return true;
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
bool tx_memory_pool::remove_alias_info(const transaction& tx)
{
tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(tx, ei);
CHECK_AND_ASSERT_MES(r, false, "failed to validate transaction extra on unprocess_blockchain_tx_extra");
@ -789,7 +787,7 @@ namespace currency
return true;
}
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
bool tx_memory_pool::remove_key_images(const crypto::hash &tx_id, const transaction& tx, bool kept_by_block)
{
CRITICAL_REGION_LOCAL(m_key_images_lock);
@ -797,7 +795,7 @@ namespace currency
{
crypto::key_image k_image = AUTO_VAL_INIT(k_image);
if (get_key_image_from_txin_v(in, k_image))
{
{
auto it_map = epee::misc_utils::it_get_or_insert_value_initialized(m_key_images, k_image);
auto& id_set = it_map->second;
size_t count_before = id_set.size();
@ -816,7 +814,7 @@ namespace currency
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::get_key_images_from_tx_pool(key_image_cache& key_images) const
{
{
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{
for (auto& in : tx_entry.tx.vin)
@ -854,7 +852,7 @@ namespace currency
//---------------------------------------------------------------------------------
void tx_memory_pool::purge_transactions()
{
m_db.begin_transaction();
m_db_transactions.clear();
m_db.commit_transaction();
@ -871,7 +869,7 @@ namespace currency
CIRITCAL_OPERATION(m_key_images,clear());
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::is_transaction_ready_to_go(tx_details& txd, const crypto::hash& id)const
bool tx_memory_pool::is_transaction_ready_to_go(tx_details& txd, const crypto::hash& id)const
{
//not the best implementation at this time, sorry :(
@ -914,7 +912,7 @@ namespace currency
{
return false;
}
if (!check_tx_multisig_ins_and_outs(txd.tx, false))
return false;
@ -923,7 +921,7 @@ namespace currency
return true;
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::have_key_images(const std::unordered_set<crypto::key_image>& k_images, const transaction& tx)const
bool tx_memory_pool::have_key_images(const std::unordered_set<crypto::key_image>& k_images, const transaction& tx)const
{
LOCAL_READONLY_TRANSACTION();
for(size_t i = 0; i!= tx.vin.size(); i++)
@ -952,14 +950,14 @@ namespace currency
return true;
}
//---------------------------------------------------------------------------------
std::string tx_memory_pool::print_pool(bool short_format)const
std::string tx_memory_pool::print_pool(bool short_format)const
{
std::stringstream ss;
if (short_format)
{
std::list<std::pair<crypto::hash, tx_details>> txs;
{
m_db_transactions.enumerate_items([&txs](uint64_t i, const crypto::hash& h, const tx_details &tx_entry) { txs.push_back(std::make_pair(h, tx_entry)); return true; });
}
if (txs.empty())
@ -967,7 +965,7 @@ namespace currency
// sort output by receive time
txs.sort([](const std::pair<crypto::hash, tx_details>& lhs, const std::pair<crypto::hash, tx_details>& rhs) -> bool { return lhs.second.receive_time < rhs.second.receive_time; });
ss << "# | transaction id | size | fee | ins | outs | outs money | live_time | max used block | last failed block | kept by a block?" << ENDL;
// 1234 f99fe6d4335fc0ddd69e6880a4d95e0f6ea398de0324a6837021a61c6a31cacd 87157 0.10000111 2000 2000 112000.12345678 d0.h10.m16.s17 123456 <12345..> 123456 <12345..> YES
// 1234 f99fe6d4335fc0ddd69e6880a4d95e0f6ea398de0324a6837021a61c6a31cacd 87157 0.10000111 2000 2000 112000.12345678 d0.h10.m16.s17 123456 <12345..> 123456 <12345..> YES
size_t i = 0;
for (auto& tx : txs)
{
@ -990,9 +988,9 @@ namespace currency
}
return ss.str();
}
// long format
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{
auto& txd = tx_entry;
@ -1012,32 +1010,32 @@ namespace currency
return ss.str();
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::fill_block_template(block &bl,
bool pos,
size_t median_size,
bool tx_memory_pool::fill_block_template(block &bl,
bool pos,
size_t median_size,
const boost::multiprecision::uint128_t& already_generated_coins,
size_t &total_size,
uint64_t &fee,
uint64_t height,
size_t &total_size,
uint64_t &fee,
uint64_t height,
const std::list<transaction>& explicit_txs
)
{
LOCAL_READONLY_TRANSACTION();
//typedef transactions_container::value_type txv;
typedef std::pair<crypto::hash, std::shared_ptr<const tx_details> > txv;
std::vector<txv> txs_v;
txs_v.reserve(m_db_transactions.size());
std::vector<size_t> txs; // selected transactions, vector of indices of txs_v
//keep getting it as a values cz db items cache will keep it as unserialised object stored by shared ptrs
//keep getting it as a values cz db items cache will keep it as unserialised object stored by shared ptrs
m_db_transactions.enumerate_keys([&](uint64_t i, crypto::hash& k){txs_v.resize(i + 1); txs_v[i].first = k; return true;});
txs.resize(txs_v.size(), SIZE_MAX);
for (uint64_t i = 0; i != txs_v.size(); i++)
{
{
auto& k = txs_v[i].first;
txs_v[i].second = m_db_transactions.get(k);
if (!txs_v[i].second)
@ -1048,8 +1046,8 @@ namespace currency
txs[i] = i;
}
std::sort(txs.begin(), txs.end(), [&txs_v](size_t a, size_t b) -> bool {
boost::multiprecision::uint128_t a_, b_;
a_ = boost::multiprecision::uint128_t(txs_v[a].second->fee) * txs_v[b].second->blob_size;
@ -1073,7 +1071,7 @@ namespace currency
// scan txs for alias reg requests - if there are such requests, don't process alias updates
bool alias_regs_exist = false;
for (auto txi : txs)
for (auto txi : txs)
{
tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(txs_v[txi].second->tx, ei);
@ -1097,8 +1095,8 @@ namespace currency
{
txs[i] = SIZE_MAX;
continue;
}
}
// alias checks
tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(tx.second->tx, ei);
@ -1114,11 +1112,11 @@ namespace currency
}
}
//is_transaction_ready_to_go can change tx_details in case of some errors, so we make local copy,
//is_transaction_ready_to_go can change tx_details in case of some errors, so we make local copy,
//do check if it's changed and reassign it to db if needed
tx_details local_copy_txd = *(tx.second);
bool is_tx_ready_to_go_result = is_transaction_ready_to_go(local_copy_txd, tx.first);
if (!is_tx_ready_to_go_result &&
if (!is_tx_ready_to_go_result &&
(local_copy_txd.last_failed_height != tx.second->last_failed_height || local_copy_txd.last_failed_id != tx.second->last_failed_id))
{
m_db_transactions.begin_transaction();
@ -1169,7 +1167,7 @@ namespace currency
}
}
}
// add explicit transactions
// add explicit transactions
for (const auto& tx : explicit_txs)
{
fee += get_tx_fee(tx);
@ -1212,7 +1210,7 @@ namespace currency
}
const std::string db_folder_path = dbbs.get_pool_db_folder_path();
LOG_PRINT_L0("Loading blockchain from " << db_folder_path << "...");
bool db_opened_okay = false;
@ -1248,7 +1246,7 @@ namespace currency
if (m_db_storage_major_compatibility_version > 0 && m_db_storage_major_compatibility_version != TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION)
{
need_reinit = true;
LOG_PRINT_MAGENTA("Tx pool DB needs reinit because it has major compatibility ver is " << m_db_storage_major_compatibility_version << ", expected: " << TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION, LOG_LEVEL_0);
LOG_PRINT_MAGENTA("Tx pool DB needs reinit because it has major compatibility ver is " << m_db_storage_major_compatibility_version << ", expected: " << TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION, LOG_LEVEL_0);
}
if (need_reinit)
@ -1296,7 +1294,7 @@ namespace currency
bool tx_memory_pool::load_keyimages_cache()
{
CRITICAL_REGION_LOCAL(m_key_images_lock);
return get_key_images_from_tx_pool(m_key_images);
return get_key_images_from_tx_pool(m_key_images);
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::deinit()
@ -1366,9 +1364,9 @@ namespace currency
return false;
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::check_tx_multisig_ins_and_outs(const transaction& tx, bool check_against_pool_txs) const
bool tx_memory_pool::check_tx_multisig_ins_and_outs(const transaction& tx, bool check_against_pool_txs) const
{
LOCAL_READONLY_TRANSACTION();
std::vector<ms_out_info> ms_ids;
collect_multisig_ids_from_tx(tx, ms_ids);
@ -1394,7 +1392,7 @@ namespace currency
LOG_PRINT_L0("Transaction " << get_transaction_hash(tx) << (el.is_input ? " : input #" : " : output #") << el.input_output_index << " has multisig id " << el.multisig_id <<
" that is already in the pool in tx " << get_transaction_hash(tx_entry.tx));
return false;
}
}
return true;
});
if (has_found)
@ -1406,7 +1404,7 @@ namespace currency
}
}
#undef LOG_DEFAULT_CHANNEL
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL NULL

View file

@ -28,8 +28,8 @@
// #endif
#include <stdint.h>
#include <math.h>
#include "currency_core/currency_config.h"
#define GUI_LINK_NAME "Zano"
#include "currency_config.h"
#define GUI_LINK_NAME "Lethean"
#ifdef WIN32
#ifdef _WIN32_WINNT
@ -245,24 +245,24 @@ namespace gui_tools
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
{
SInt32 macos_ver_maj, macos_ver_min;
Gestalt(gestaltSystemVersionMajor, &macos_ver_maj); // very old and deprecated, consider change
Gestalt(gestaltSystemVersionMinor, &macos_ver_min); // very old and deprecated, consider change
// loop through the list of startup items and try to find the bitcoin app
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL);
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
CFURLRef currentItemURL = NULL;
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100
if (&LSSharedFileListItemCopyResolvedURL != NULL && (macos_ver_maj > 10 || (macos_ver_maj == 10 && macos_ver_min >= 10)))
currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL); // this is available only on macOS 10.10-10.11 (then deprecated)
@ -273,7 +273,7 @@ namespace gui_tools
#else
LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
#endif
if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
// found
CFRelease(currentItemURL);
@ -285,7 +285,7 @@ namespace gui_tools
}
return NULL;
}
bool GetStartOnSystemStartup()
{
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
@ -293,13 +293,13 @@ namespace gui_tools
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
return !!foundItem; // return boolified object
}
bool SetStartOnSystemStartup(bool fAutoStart)
{
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
if(fAutoStart && !foundItem) {
// add bitcoin app to startup item list
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, NULL, NULL, bitcoinAppUrl, NULL, NULL);

49
src/gui/main.cpp Normal file
View file

@ -0,0 +1,49 @@
#include "websocketclientwrapper.h"
#include "websockettransport.h"
#include "mainwindow.h"
#include "include_base_utils.h"
#include <QApplication>
#include <QUrl>
#include <QWebChannel>
#include <QWebSocketServer>
#ifdef Q_OS_DARWIN
# include "urleventfilter.h"
#endif
int main(int argc, char** argv)
{
// epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_0);
// epee::log_space::get_set_need_thread_id(true, true);
// epee::log_space::log_singletone::enable_channels("core,currency_protocol,tx_pool,p2p,wallet");
QApplication app(argc, argv, Qt::SubWindow);
// setup the QWebSocketServer
QWebSocketServer webSocketServer(QStringLiteral("Lethean GUI Backend Server"), QWebSocketServer::NonSecureMode);
if(!webSocketServer.listen(QHostAddress::LocalHost, 12345)) {
qWarning() << "Failed to open web socket server." << webSocketServer.errorString();
return 1;
}
WebSocketClientWrapper clientWrapper(&webSocketServer);
// setup the channel
QWebChannel channel;
QObject::connect(&clientWrapper, &WebSocketClientWrapper::clientConnected,
&channel, &QWebChannel::connectTo);
MainWindow viewer;
// register QObjects to be exposed to JavaScript
if(!viewer.init_backend(argc, argv)) {
return 1;
}
channel.registerObject(QStringLiteral("mediator_object"), &viewer);
#ifdef Q_OS_DARWIN
URLEventFilter url_event_filter(&viewer);
app.installEventFilter(&url_event_filter);
#endif
app.installNativeEventFilter(&viewer);
return app.exec();
}

View file

@ -41,7 +41,7 @@ QString make_response_dbg(const T& r, const std::string& location)
return str.c_str();
}
#define PREPARE_RESPONSE(rsp_type, var_name) view::api_response_t<rsp_type> var_name = AUTO_VAL_INIT(var_name)
#define PREPARE_RESPONSE(rsp_type, var_name) view::api_response_t<rsp_type> var_name = AUTO_VAL_INIT(var_name)
#define MAKE_RESPONSE(r) (r.error_code == API_RETURN_CODE_OK || r.error_code == API_RETURN_CODE_TRUE) ? make_response(r) : make_response_dbg(r, LOCATION_STR)
#define LOG_API_TIMING() const char* pfunc_call_name = LOCAL_FUNCTION_DEF__; LOG_PRINT_BLUE("[API:" << pfunc_call_name << "]-->>", LOG_LEVEL_0); uint64_t ticks_before_start = epee::misc_utils::get_tick_count(); \
@ -67,27 +67,6 @@ QString make_response_dbg(const T& r, const std::string& location)
}
#include "mainwindow.h"
//
// void MediatorObject::from_html_to_c(const QString &text)
// {
// from_c_to_html(text);
// }
//
// template<typename Arg, typename R, typename C>
// struct InvokeWrapper {
// R *receiver;
// void (C::*memberFun)(Arg);
// void operator()(Arg result) {
// (receiver->*memberFun)(result);
// }
// };
//
// template<typename Arg, typename R, typename C>
// InvokeWrapper<Arg, R, C> invoke(R *receiver, void (C::*memberFun)(Arg))
// {
// InvokeWrapper<Arg, R, C> wrapper = { receiver, memberFun };
// return wrapper;
// }
std::wstring convert_to_lower_via_qt(const std::wstring& w)
@ -100,8 +79,6 @@ MainWindow::MainWindow()
: m_gui_deinitialize_done_1(false)
, m_backend_stopped_2(false)
, m_system_shutdown(false)
, m_view(nullptr)
, m_channel(nullptr)
, m_ui_dispatch_id_counter(0)
{
#ifndef _MSC_VER
@ -113,17 +90,7 @@ MainWindow::MainWindow()
MainWindow::~MainWindow()
{
m_backend.subscribe_to_core_events(nullptr);
if (m_view)
{
m_view->page()->setWebChannel(nullptr);
m_view = nullptr;
}
if (m_channel)
{
m_channel->deregisterObject(this);
delete m_channel;
m_channel = nullptr;
}
if (m_ipc_worker.joinable())
{
m_ipc_worker.join();
@ -288,12 +255,12 @@ QString MainWindow::call_rpc(const QString& params)
query_info.m_URI = "/json_rpc";
query_info.m_body = params.toStdString();
m_backend.get_rpc_server().handle_http_request(query_info, response_info, dummy_context);
if (response_info.m_response_code != 200)
{
epee::json_rpc::error_response rsp;
rsp.jsonrpc = "2.0";
epee::json_rpc::error_response rsp;
rsp.jsonrpc = "2.0";
rsp.error.code = response_info.m_response_code;
rsp.error.message = response_info.m_response_comment;
return QString::fromStdString(epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp)));
@ -322,7 +289,7 @@ QString MainWindow::get_options()
void MainWindow::tray_quit_requested()
{
TRY_ENTRY();
LOG_PRINT_MAGENTA("[GUI]->[HTML] tray_quit_requested", LOG_LEVEL_0);
LOG_PRINT_MAGENTA("[GUI]->[HTML] tray_quit_requested", LOG_LEVEL_0);
emit quit_requested("{}");
CATCH_ENTRY2(void());
}
@ -331,7 +298,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{
TRY_ENTRY();
LOG_PRINT_L0("[GUI] CLOSE EVENT");
CHECK_AND_ASSERT_MES(m_gui_deinitialize_done_1 == m_backend_stopped_2, void(), "m_gui_deinitialize_done_1 != m_backend_stopped_2, m_gui_deinitialize_done_1 = " << m_gui_deinitialize_done_1
CHECK_AND_ASSERT_MES(m_gui_deinitialize_done_1 == m_backend_stopped_2, void(), "m_gui_deinitialize_done_1 != m_backend_stopped_2, m_gui_deinitialize_done_1 = " << m_gui_deinitialize_done_1
<< "m_backend_stopped_2 = " << m_backend_stopped_2);
@ -344,7 +311,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
}
else if (m_gui_deinitialize_done_1 && m_backend_stopped_2)
{
store_pos(true);
store_app_config();
event->accept();
}
@ -377,53 +343,6 @@ std::string state_to_text(int s)
CATCH_ENTRY2("");
}
void MainWindow::changeEvent(QEvent *e)
{
TRY_ENTRY();
switch (e->type())
{
case QEvent::WindowStateChange:
{
QWindowStateChangeEvent* event = static_cast< QWindowStateChangeEvent* >(e);
qDebug() << "Old state: " << state_to_text(event->oldState()).c_str() << ", new state: " << state_to_text(this->windowState()).c_str();
if (event->oldState() & Qt::WindowMinimized && !(this->windowState() & Qt::WindowMinimized))
{
qDebug() << "Window restored (to normal or maximized state)!";
if (m_tray_icon)
{
//QTimer::singleShot(250, this, SLOT(show()));
}
restore_pos();
}
else if (!(event->oldState() & Qt::WindowMinimized) && (this->windowState() & Qt::WindowMinimized))
{
store_pos();
qDebug() << "Window minimized";
show_notification(m_localization[localization_id_minimized_title], m_localization[localization_id_minimized_text]);
}
else if (!(event->oldState() & Qt::WindowFullScreen) && (this->windowState() & Qt::WindowFullScreen))
{
//maximize
store_window_pos();
this->update();
}
else if ((event->oldState() & Qt::WindowFullScreen) && !(this->windowState() & Qt::WindowFullScreen))
{
//restore
this->update();
}
break;
}
default:
break;
}
QWidget::changeEvent(e);
CATCH_ENTRY2(void());
}
bool MainWindow::store_app_config()
{
TRY_ENTRY();
@ -448,42 +367,21 @@ bool MainWindow::load_app_config()
bool MainWindow::init(const std::string& html_path)
{
TRY_ENTRY();
//QtWebEngine::initialize();
init_tray_icon(html_path);
set_html_path(html_path);
m_threads_pool.init(2);
m_backend.subscribe_to_core_events(this);
bool r = QSslSocket::supportsSsl();
if (r)
{
if (r) {
LOG_PRINT_GREEN("[Support SSL]: YES", LOG_LEVEL_0);
}
else
{
// QMessageBox::question(this, "OpenSSL support disabled.", "OpenSSL support disabled.",
// QMessageBox::Ok);
} else {
LOG_PRINT_RED("[Support SSL]: NO", LOG_LEVEL_0);
}
//----
this->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
m_view->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
return true;
CATCH_ENTRY2(false);
}
void MainWindow::on_menu_show()
{
TRY_ENTRY();
qDebug() << "Context menu: show()";
this->show();
this->activateWindow();
CATCH_ENTRY2(void());
}
void MainWindow::init_tray_icon(const std::string& html_path)
void MainWindow::init_tray_icon()
{
TRY_ENTRY();
if (!QSystemTrayIcon::isSystemTrayAvailable())
@ -492,40 +390,26 @@ void MainWindow::init_tray_icon(const std::string& html_path)
return;
}
m_restore_action = std::unique_ptr<QAction>(new QAction(tr("&Restore"), this));
connect(m_restore_action.get(), SIGNAL(triggered()), this, SLOT(on_menu_show()));
m_quit_action = std::unique_ptr<QAction>(new QAction(tr("&Quit"), this));
connect(m_quit_action.get(), SIGNAL(triggered()), this, SLOT(tray_quit_requested()));
m_minimize_action = std::unique_ptr<QAction>(new QAction(tr("minimizeAction"), this));
connect(m_minimize_action.get(), SIGNAL(triggered()), this, SLOT(showMinimized()));
m_tray_icon_menu = std::unique_ptr<QMenu>(new QMenu(this));
m_tray_icon_menu->addAction(m_minimize_action.get());
m_tray_icon_menu = std::unique_ptr<QMenu>(new QMenu());
//m_tray_icon_menu->addAction(m_restore_action.get());
m_tray_icon_menu->addSeparator();
m_tray_icon_menu->addAction(m_quit_action.get());
m_tray_icon = std::unique_ptr<QSystemTrayIcon>(new QSystemTrayIcon(this));
m_tray_icon->setContextMenu(m_tray_icon_menu.get());
//setup icon
#ifdef TARGET_OS_MAC
m_normal_icon_path = html_path + "/files/app22macos.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = html_path + "/files/app22macos_blocked.png"; // X11 tray icon size is 22x22
QIcon qi( ":/lthn.png" );
#else
m_normal_icon_path = html_path + "/files/app22windows.png"; // X11 tray icon size is 22x22
m_blocked_icon_path = html_path + "/files/app22windows_blocked.png"; // X11 tray icon size
QIcon qi( ":/lthn.png" );
#endif
//setWindowIcon(QIcon(iconPath.c_str()));
QIcon qi( QString::fromWCharArray(epee::string_encoding::utf8_to_wstring(m_normal_icon_path).c_str()) );
qi.setIsMask(true);
//qi.setIsMask(true);
m_tray_icon->setIcon(qi);
m_tray_icon->setToolTip(CURRENCY_NAME_BASE);
connect(m_tray_icon.get(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
m_tray_icon->setToolTip( "Lethean Blockchain API Server");
m_tray_icon->show();
CATCH_ENTRY2(void());
}
@ -682,35 +566,6 @@ QString MainWindow::on_request_quit()
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR);
}
bool MainWindow::do_close()
{
TRY_ENTRY();
this->close();
return true;
CATCH_ENTRY2(false);
}
bool MainWindow::show_inital()
{
TRY_ENTRY();
if (load_app_config())
restore_pos(true);
else
{
m_config = AUTO_VAL_INIT(m_config);
this->show();
QSize sz = AUTO_VAL_INIT(sz);
sz.setHeight(770);
sz.setWidth(1200);
this->resize(sz);
store_window_pos();
m_config.is_maximazed = false;
m_config.is_showed = true;
m_config.disable_notifications = false;
}
return true;
CATCH_ENTRY2(false);
}
bool MainWindow::on_backend_stopped()
{
@ -721,7 +576,7 @@ bool MainWindow::on_backend_stopped()
// if (m_quit_requested)
// {
/*bool r = */QMetaObject::invokeMethod(this, "do_close", Qt::QueuedConnection);
// /*bool r = */QMetaObject::invokeMethod(this, "do_close", Qt::QueuedConnection);
// }
return true;
CATCH_ENTRY2(false);
@ -747,14 +602,6 @@ bool MainWindow::update_daemon_status(const view::daemon_status_info& info)
}
bool MainWindow::show_msg_box(const std::string& message)
{
TRY_ENTRY();
QMessageBox::information(this, "Error", message.c_str(), QMessageBox::Ok);
return true;
CATCH_ENTRY2(false);
}
void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray local_msg = msg.toLocal8Bit();
@ -790,13 +637,13 @@ bool MainWindow::remove_ipc()
}
return true;
}
bool MainWindow::init_ipc_server()
{
//in case previous instance wasn't close graceful, ipc channel will remain open and new creation will fail, so we
//trying to close it anyway before open, to make sure there are no dead channels. If there are another running instance, it wom't
//in case previous instance wasn't close graceful, ipc channel will remain open and new creation will fail, so we
//trying to close it anyway before open, to make sure there are no dead channels. If there are another running instance, it wom't
//let channel to close, so it will fail later on creating channel
remove_ipc();
#define GUI_IPC_BUFFER_SIZE 10000
@ -825,7 +672,7 @@ bool MainWindow::init_ipc_server()
buff.resize(recvd_size, '*');
handle_ipc_event(buff);//todo process token
}
}
}
remove_ipc();
LOG_PRINT_L0("IPC Handling thread finished");
}
@ -903,20 +750,12 @@ bool MainWindow::init_backend(int argc, char* argv[])
return false;
}
if (!init_window())
{
this->show_msg_box("Failed to main screen launch, check logs for the more detais.");
return false;
}
if (!m_backend.init(this))
{
this->show_msg_box("Failed to initialize backend, check debug logs for more details.");
return false;
}
if (m_backend.is_qt_logs_enabled())
{
qInstallMessageHandler(qt_log_message_handler);
@ -929,6 +768,8 @@ bool MainWindow::init_backend(int argc, char* argv[])
return false;
}
init_tray_icon();
return true;
CATCH_ENTRY2(false);
}
@ -995,11 +836,11 @@ bool MainWindow::update_wallet_status(const view::wallet_status_info& wsi)
{
TRY_ENTRY();
m_wallet_states->operator [](wsi.wallet_id) = wsi.wallet_state;
std::string json_str_pub;
epee::serialization::store_t_to_json(static_cast<const view::wallet_status_info_base&>(wsi), json_str_pub, 0, epee::serialization::eol_lf);
LOG_PRINT_L0(get_wallet_log_prefix(wsi.wallet_id) + "SENDING SIGNAL -> [update_wallet_status]:" << std::endl << json_str_pub);
std::string json_str;
epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf);
QMetaObject::invokeMethod(this, "update_wallet_status", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
@ -1069,7 +910,7 @@ bool MainWindow::update_wallets_info(const view::wallets_summary_info& wsi)
std::string json_str;
epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf);
LOG_PRINT_L0("SENDING SIGNAL -> [update_wallets_info]"<< std::endl << json_str );
QMetaObject::invokeMethod(this, "update_wallets_info", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
return true;
CATCH_ENTRY2(false);
@ -1123,7 +964,7 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei)
else if (tei.ti.unlock_time)
msg += m_localization[localization_id_locked];
show_notification(title, msg);
return true;
@ -1154,21 +995,6 @@ bool MainWindow::wallet_sync_progress(const view::wallet_sync_progres_param& p)
CATCH_ENTRY2(false);
}
bool MainWindow::set_html_path(const std::string& path)
{
TRY_ENTRY();
//init_tray_icon(path);
#ifdef _MSC_VER
QString url = QString::fromUtf8(path.c_str()) + "/index.html";
load_file(url);
#else
// load_file(QString((std::string("file://") + path + "/index.html").c_str()));
load_file(QString((std::string("") + path + "/index.html").c_str()));
#endif
return true;
CATCH_ENTRY2(false);
}
bool MainWindow::pos_block_found(const currency::block& block_found)
{
TRY_ENTRY();
@ -1353,7 +1179,7 @@ void MainWindow::on_core_event(const std::string event_name, const currency::cor
std::string get_events_que_json_string(const std::list<currency::core_event>& eq, std::string& methods_list)
{
TRY_ENTRY();
//t the moment portable_storage is not supporting polymorphic objects lists, so
//t the moment portable_storage is not supporting polymorphic objects lists, so
//there is no hope to make serialization with variant list, lets handle it manual
std::stringstream ss;
ss << "{ \"events\" : [";
@ -1385,13 +1211,13 @@ void MainWindow::on_complete_events()
TIME_MEASURE_START_MS(json_buff_generate_time);
std::string json_buff = get_events_que_json_string(m_events.m_que, methods_list);
TIME_MEASURE_FINISH_MS(json_buff_generate_time);
QMetaObject::invokeMethod(this, "on_core_event",
Qt::QueuedConnection,
Q_ARG(QString, QString(json_buff.c_str())));
TIME_MEASURE_FINISH_MS(core_events_handl_time);
LOG_PRINT_L0("SENT SIGNAL -> [CORE_EVENTS]: " << m_events.m_que.size()
LOG_PRINT_L0("SENT SIGNAL -> [CORE_EVENTS]: " << m_events.m_que.size()
<< ", handle_time: " << core_events_handl_time << "(json: " << json_buff_generate_time << ")ms, json_buff size = " << json_buff.size() << ", methods: " << methods_list);
LOG_PRINT_L2("CORE_EVENTS sent signal details: " << ENDL << json_buff);
m_events.m_que.clear();
@ -1451,7 +1277,7 @@ QString MainWindow::get_secure_app_data(const QString& param)
std::string filename = m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME;
std::string res_body;
std::string rsp_code = tools::load_encrypted_file(filename, pwd.pass, res_body, APP_DATA_FILE_BINARY_SIGNATURE);
std::string rsp_code = tools::load_encrypted_file(filename, pwd.pass, res_body, APP_DATA_FILE_BINARY_SIGNATURE);
if (rsp_code != API_RETURN_CODE_OK)
{
view::api_response ar;
@ -1510,7 +1336,7 @@ QString MainWindow::check_master_password(const QString& param)
crypto::hash master_password_hash = crypto::cn_fast_hash(&master_password_pre_hash, sizeof master_password_pre_hash);
crypto::hash pwd_pre_hash = crypto::cn_fast_hash(pwd.pass.c_str(), pwd.pass.length());
crypto::hash pwd_hash = crypto::cn_fast_hash(&pwd_pre_hash, sizeof pwd_pre_hash);
if (m_master_password != pwd.pass)
{
ar.error_code = API_RETURN_CODE_WRONG_PASSWORD;
@ -1596,7 +1422,7 @@ QString MainWindow::store_to_file(const QString& path, const QString& buff)
return API_RETURN_CODE_ACCESS_DENIED;
}
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR);
}
@ -1721,7 +1547,7 @@ QString MainWindow::set_log_level(const QString& param)
epee::log_space::get_set_log_detalisation_level(true, lvl.v);
default_ar.error_code = API_RETURN_CODE_OK;
LOG_PRINT("[LOG LEVEL]: set to " << lvl.v, LOG_LEVEL_MIN);
return MAKE_RESPONSE(default_ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
@ -1759,23 +1585,23 @@ QString MainWindow::set_enable_tor(const QString& param)
// QString path = QFileDialog::getOpenFileName(this, "Select file",
// "",
// "");
//
//
// if (!path.length())
// {
// ar.error_code = API_RETURN_CODE_CANCELED;
// return MAKE_RESPONSE(ar);
// }
//
//
// currency::COMMAND_RPC_GET_OFFERS_EX::response rp = AUTO_VAL_INIT(rp);
// ar.error_code = m_backend.get_all_offers(rp);
//
//
// std::string buff = epee::serialization::store_t_to_json(rp);
// bool r = file_io_utils::save_string_to_file(path.toStdString(), buff);
// if (!r)
// ar.error_code = API_RETURN_CODE_FAIL;
// else
// ar.error_code = API_RETURN_CODE_OK;
//
//
// return MAKE_RESPONSE(ar);
// }
@ -1787,55 +1613,6 @@ QString MainWindow::webkit_launched_script()
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR);
}
////////////////////
QString MainWindow::show_openfile_dialog(const QString& param)
{
TRY_ENTRY();
view::system_filedialog_request ofdr = AUTO_VAL_INIT(ofdr);
view::system_filedialog_response ofdres = AUTO_VAL_INIT(ofdres);
if (!epee::serialization::load_t_from_json(ofdr, param.toStdString()))
{
ofdres.error_code = API_RETURN_CODE_BAD_ARG;
return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str();
}
QString path = QFileDialog::getOpenFileName(this, ofdr.caption.c_str(),
ofdr.default_dir.c_str(),
ofdr.filemask.c_str());
if (!path.length())
{
ofdres.error_code = API_RETURN_CODE_CANCELED;
return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str();
}
ofdres.error_code = API_RETURN_CODE_OK;
ofdres.path = path.toStdString();
return MAKE_RESPONSE(ofdres);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::show_savefile_dialog(const QString& param)
{
TRY_ENTRY();
PREPARE_ARG_FROM_JSON(view::system_filedialog_request, ofdr);
view::system_filedialog_response ofdres = AUTO_VAL_INIT(ofdres);
QString path = QFileDialog::getSaveFileName(this, ofdr.caption.c_str(),
ofdr.default_dir.c_str(),
ofdr.filemask.c_str());
if (!path.length())
{
ofdres.error_code = API_RETURN_CODE_CANCELED;
return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str();
}
ofdres.error_code = API_RETURN_CODE_OK;
ofdres.path = path.toStdString();
return MAKE_RESPONSE(ofdres);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::close_wallet(const QString& param)
{
@ -2051,7 +1828,7 @@ QString MainWindow::push_offer(const QString& param)
ar.error_code = m_backend.push_offer(a.wallet_id, a.od, res_tx);
if (ar.error_code != API_RETURN_CODE_OK)
return MAKE_RESPONSE(ar);
ar.response_data.success = true;
ar.response_data.tx_hash = string_tools::pod_to_hex(currency::get_transaction_hash(res_tx));
ar.response_data.tx_blob_size = currency::get_object_blobsize(res_tx);
@ -2340,43 +2117,6 @@ QString MainWindow::get_seed_phrase_info(const QString& param)
CATCH_ENTRY_FAIL_API_RESPONCE();
}
void MainWindow::contextMenuEvent(QContextMenuEvent * event)
{
TRY_ENTRY();
CATCH_ENTRY2(void());
}
QString MainWindow::print_text(const QString& param)
{
TRY_ENTRY();
LOG_API_TIMING();
PREPARE_ARG_FROM_JSON(view::print_text_param, ptp);
//in >> htmlContent;
QTextDocument *document = new QTextDocument();
document->setHtml(ptp.html_text.c_str());
QPrinter printer;
default_ar.error_code = API_RETURN_CODE_CANCELED;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setOptions(QAbstractPrintDialog::PrintToFile);
auto res = dialog->exec();
if (res != QDialog::Accepted)
{
LOG_PRINT_L0("[PRINT_TEXT] exec != QDialog::Accepted, res=" << res);
return MAKE_RESPONSE(default_ar);
}
document->print(&printer);
delete document;
default_ar.error_code = API_RETURN_CODE_OK;
LOG_PRINT_L0("[PRINT_TEXT] default_ar.error_code = " << default_ar.error_code);
return MAKE_RESPONSE(default_ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::print_log(const QString& param)
{
@ -2394,9 +2134,9 @@ void MainWindow::show_notification(const std::string& title, const std::string&
{
TRY_ENTRY();
LOG_PRINT_L1("system notification: \"" << title << "\", \"" << message << "\"");
// it's expected that title and message are utf-8 encoded!
#if !defined(__APPLE__)
// use Qt tray icon to show messages on Windows and Linux
CHECK_AND_ASSERT_MES(m_tray_icon != nullptr, (void)(0), "m_tray_icon is null!");
@ -2407,5 +2147,13 @@ void MainWindow::show_notification(const std::string& title, const std::string&
#endif
CATCH_ENTRY2(void());
}
QString MainWindow::get_wallet_info(const QString& param)
{
TRY_ENTRY();
LOG_API_TIMING();
PREPARE_ARG_FROM_JSON(view::wallet_id_obj, waid);
PREPARE_RESPONSE(view::wallet_info, ar);
ar.error_code = m_backend.get_wallet_info(waid.wallet_id, ar.response_data);
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}

View file

@ -32,15 +32,15 @@ QT_END_NAMESPACE
// class MediatorObject : public QObject
// {
// Q_OBJECT
//
//
// public:
//
//
// signals :
// /*!
// This signal is emitted from the C++ side and the text displayed on the HTML client side.
// */
// void from_c_to_html(const QString &text);
//
//
// public slots:
// /*!
// This slot is invoked from the HTML client side and the text displayed on the server side.
@ -49,25 +49,24 @@ QT_END_NAMESPACE
// };
//
class MainWindow : public QMainWindow,
class MainWindow : public QObject,
public currency::i_core_event_handler,
public view::i_view,
public view::i_view,
public QAbstractNativeEventFilter
{
Q_OBJECT
public:
public:
MainWindow();
~MainWindow();
bool init_backend(int argc, char* argv[]);
bool show_inital();
void show_notification(const std::string& title, const std::string& message);
bool handle_ipc_event(const std::string& arguments);
struct app_config
{
epee::kvserializable_pair<int64_t, int64_t> m_window_position;
epee::kvserializable_pair<int64_t, int64_t> m_window_size;
bool is_maximazed;
@ -86,12 +85,9 @@ public:
protected slots:
void on_load_finished(bool ok);
bool do_close();
public slots:
QString show_openfile_dialog(const QString& param);
QString show_savefile_dialog(const QString& param);
QString open_wallet(const QString& param);
QString get_my_offers(const QString& param);
QString get_fav_offers(const QString& param);
@ -157,7 +153,6 @@ public:
QString toggle_autostart(const QString& param);
QString is_valid_restore_wallet_text(const QString& param);
QString get_seed_phrase_info(const QString& param);
QString print_text(const QString& param);
QString print_log(const QString& param);
QString set_clipboard(const QString& param);
QString set_localization_strings(const QString str);
@ -167,16 +162,15 @@ public:
QString get_exchange_last_top(const QString& params);
QString get_tx_pool_info();
QString get_default_fee();
QString get_options();
QString get_options();
void bool_toggle_icon(const QString& param);
QString add_custom_asset_id(const QString& param);
QString add_custom_asset_id(const QString& param);
QString remove_custom_asset_id(const QString& param);
QString get_wallet_info(const QString& param);
QString create_ionic_swap_proposal(const QString& param);
QString get_ionic_swap_proposal_info(const QString& param);
QString accept_ionic_swap_proposal(const QString& param);
bool get_is_disabled_notifications();
bool set_is_disabled_notifications(const bool& param);
QString export_wallet_history(const QString& param);
@ -184,15 +178,13 @@ public:
//QString check_available_sources(const QString& param);
QString open_url_in_browser(const QString& param);
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void tray_quit_requested();
void on_menu_show();
QString is_remnotenode_mode_preconfigured();
QString start_backend(const QString& params);
QString async_call(const QString& func_name, const QString& params);
QString sync_call(const QString& func_name, const QString& params);
QString get_wallet_info(const QString& param);
//for test purposes onlys
QString request_dummy();
@ -223,7 +215,6 @@ private:
//------- i_view ---------
virtual bool update_daemon_status(const view::daemon_status_info& info);
virtual bool on_backend_stopped();
virtual bool show_msg_box(const std::string& message);
virtual bool update_wallet_status(const view::wallet_status_info& wsi);
virtual bool update_wallets_info(const view::wallets_summary_info& wsi);
virtual bool money_transfer(const view::transfer_event_info& tei);
@ -239,35 +230,24 @@ private:
void closeEvent(QCloseEvent *event);
void contextMenuEvent(QContextMenuEvent * event);
void changeEvent(QEvent *e);
void on_maximized();
bool handle_deeplink_params_in_commandline();
//void setOrientation(Qt::ScreenOrientation orientation);
void init_tray_icon(const std::string& htmlPath);
void init_tray_icon();
bool set_html_path(const std::string& path);
void load_file(const QString &fileName);
void store_pos(bool consider_showed = false);
void store_window_pos();
void restore_pos(bool consider_showed = false);
bool store_app_config();
bool load_app_config();
bool init_window();
bool init_ipc_server();
bool remove_ipc();
std::string get_wallet_log_prefix(size_t wallet_id) const { return m_backend.get_wallet_log_prefix(wallet_id); }
//MediatorObject mo;
// UI
QWebEngineView *m_view;
QWebChannel* m_channel;
// DATA
wallets_manager m_backend;
//std::atomic<bool> m_quit_requested;
@ -279,7 +259,6 @@ private:
std::string m_master_password;
app_config m_config;
epee::locked_object<std::map<uint64_t, uint64_t>> m_wallet_states;
@ -287,7 +266,7 @@ private:
struct events_que_struct
{
std::list<currency::core_event> m_que;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_que)
END_KV_SERIALIZE_MAP()
@ -299,10 +278,10 @@ private:
enum localization_string_indices
{
// order is surprisingly important here! (see also updateLocalisation in AppController.js)
localization_id_quit = 0,
localization_id_quit = 0,
localization_id_is_received,
localization_id_is_confirmed,
localization_id_income_transfer_unconfirmed,
localization_id_is_confirmed,
localization_id_income_transfer_unconfirmed,
localization_id_income_transfer_confirmed,
localization_id_mined,
localization_id_locked,

View file

@ -1 +0,0 @@
*.user

View file

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSEnvironment</key>
<dict>
</dict>
<key>BuildMachineOSBuild</key>
<string>14E46</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Zano</string>
<key>CFBundleIconFile</key>
<string>app.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>Zano</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6E35b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14D125</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0640</string>
<key>DTXcodeBuild</key>
<string>6E35b</string>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>ZanoApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>zano</string>
</array>
</dict>
</array>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

View file

@ -1,5 +0,0 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>app.ico</file>
</qresource>
</RCC>

View file

@ -1,2 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "app.ico"

View file

@ -1,133 +0,0 @@
// Copyright (c) 2014-2018 Zano Project
// Copyright (c) 2014-2018 The Louisdor 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 <sstream>
//#define QT_CONSOLE_STREAM qDebug()
#define QT_CONSOLE_STREAM(s) \
{std::stringstream ss; ss << s; fputs(ss.str().c_str(), stderr); fflush(stderr);}
//fputs(buf.c_str(), stderr);
//fflush(stderr);
void customHandler(QtMsgType type, const char* msg) {
fputs(msg, stderr);
fflush(stderr);
}
class qt_console_stream : public epee::log_space::ibase_log_stream
{
QDebug db;
public:
qt_console_stream() : db(qDebug())
{
// Somewhere in your program
//qInstallMsgHandler(customHandler);
}
~qt_console_stream()
{
}
int get_type(){ return LOGGER_CONSOLE; }
inline void set_console_color(int color, bool bright)
{
switch (color)
{
case epee::log_space::console_color_default:
if (bright)
{QT_CONSOLE_STREAM("\033[1;37m");}
else
{QT_CONSOLE_STREAM("\033[0m");}
break;
case epee::log_space::console_color_white:
if (bright)
{QT_CONSOLE_STREAM("\033[1;37m");}
else
{QT_CONSOLE_STREAM("\033[0;37m");}
break;
case epee::log_space::console_color_red:
if (bright)
{QT_CONSOLE_STREAM("\033[1;31m");}
else
{QT_CONSOLE_STREAM("\033[0;31m");}
break;
case epee::log_space::console_color_green:
if (bright)
{QT_CONSOLE_STREAM("\033[1;32m");}
else
{QT_CONSOLE_STREAM("\033[0;32m");}
break;
case epee::log_space::console_color_blue:
if (bright)
{QT_CONSOLE_STREAM("\033[1;34m");}
else
{QT_CONSOLE_STREAM("\033[0;34m");}
break;
case epee::log_space::console_color_cyan:
if (bright)
{QT_CONSOLE_STREAM("\033[1;36m");}
else
{QT_CONSOLE_STREAM("\033[0;36m");}
break;
case epee::log_space::console_color_magenta:
if (bright)
{QT_CONSOLE_STREAM("\033[1;35m");}
else
{QT_CONSOLE_STREAM("\033[0;35m");}
break;
case epee::log_space::console_color_yellow:
if (bright)
{QT_CONSOLE_STREAM("\033[1;33m");}
else
{QT_CONSOLE_STREAM("\033[0;33m");}
break;
}
}
inline void reset_console_color()
{
{QT_CONSOLE_STREAM("\033[0m");}
}
virtual bool out_buffer(const char* buffer, int buffer_len, int log_level, int color, const char* plog_name = NULL)
{
if (plog_name)
return true; //skip alternative logs from console
set_console_color(color, log_level < 1);
std::string buf(buffer, buffer_len);
for (size_t i = 0; i != buf.size(); i++)
{
if (buf[i] == 7 || buf[i] == -107)
buf[i] = '^';
//remove \n
//if (i == buf.size()-1)
// buf[i] = ' ';
}
QT_CONSOLE_STREAM(buf.c_str());
reset_console_color();
return true;
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -0,0 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>app22macos.png</file>
<file>app22windows.png</file>
<file>lthn.png</file>
</qresource>
</RCC>

BIN
src/gui/resources/lthn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View file

@ -0,0 +1,34 @@
#include "websocketclientwrapper.h"
#include "websockettransport.h"
#include <QWebSocketServer>
/*!
\brief Wraps connected QWebSockets clients in WebSocketTransport objects.
This code is all that is required to connect incoming WebSockets to the WebChannel. Any kind
of remote JavaScript client that supports WebSockets can thus receive messages and access the
published objects.
*/
/*!
Construct the client wrapper with the given parent.
All clients connecting to the QWebSocketServer will be automatically wrapped
in WebSocketTransport objects.
*/
WebSocketClientWrapper::WebSocketClientWrapper(QWebSocketServer *server, QObject *parent)
: QObject(parent)
, m_server(server)
{
connect(server, &QWebSocketServer::newConnection,
this, &WebSocketClientWrapper::handleNewConnection);
}
/*!
Wrap an incoming WebSocket connection in a WebSocketTransport object.
*/
void WebSocketClientWrapper::handleNewConnection()
{
emit clientConnected(new WebSocketTransport(m_server->nextPendingConnection()));
}

View file

@ -0,0 +1,29 @@
#ifndef WEBSOCKETCLIENTWRAPPER_H
#define WEBSOCKETCLIENTWRAPPER_H
#include <QObject>
class WebSocketTransport;
QT_BEGIN_NAMESPACE
class QWebSocketServer;
QT_END_NAMESPACE
class WebSocketClientWrapper : public QObject
{
Q_OBJECT
public:
explicit WebSocketClientWrapper(QWebSocketServer *server, QObject *parent = nullptr);
signals:
void clientConnected(WebSocketTransport *client);
private slots:
void handleNewConnection();
private:
QWebSocketServer *m_server;
};
#endif // WEBSOCKETCLIENTWRAPPER_H

View file

@ -0,0 +1,64 @@
#include "websockettransport.h"
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QWebSocket>
/*!
\brief QWebChannelAbstractSocket implementation that uses a QWebSocket internally.
The transport delegates all messages received over the QWebSocket over its
textMessageReceived signal. Analogously, all calls to sendTextMessage will
be send over the QWebSocket to the remote client.
*/
/*!
Construct the transport object and wrap the given socket.
The socket is also set as the parent of the transport object.
*/
WebSocketTransport::WebSocketTransport(QWebSocket *socket)
: QWebChannelAbstractTransport(socket)
, m_socket(socket)
{
connect(socket, &QWebSocket::textMessageReceived,
this, &WebSocketTransport::textMessageReceived);
connect(socket, &QWebSocket::disconnected,
this, &WebSocketTransport::deleteLater);
}
/*!
Destroys the WebSocketTransport.
*/
WebSocketTransport::~WebSocketTransport()
{
m_socket->deleteLater();
}
/*!
Serialize the JSON message and send it as a text message via the WebSocket to the client.
*/
void WebSocketTransport::sendMessage(const QJsonObject &message)
{
QJsonDocument doc(message);
m_socket->sendTextMessage(QString::fromUtf8(doc.toJson(QJsonDocument::Compact)));
}
/*!
Deserialize the stringified JSON messageData and emit messageReceived.
*/
void WebSocketTransport::textMessageReceived(const QString &messageData)
{
QJsonParseError error;
QJsonDocument message = QJsonDocument::fromJson(messageData.toUtf8(), &error);
if (error.error) {
qWarning() << "Failed to parse text message as JSON object:" << messageData
<< "Error is:" << error.errorString();
return;
} else if (!message.isObject()) {
qWarning() << "Received JSON message that is not an object: " << messageData;
return;
}
emit messageReceived(message.object(), this);
}

View file

@ -0,0 +1,26 @@
#ifndef WEBSOCKETTRANSPORT_H
#define WEBSOCKETTRANSPORT_H
#include <QWebChannelAbstractTransport>
QT_BEGIN_NAMESPACE
class QWebSocket;
QT_END_NAMESPACE
class WebSocketTransport : public QWebChannelAbstractTransport
{
Q_OBJECT
public:
explicit WebSocketTransport(QWebSocket *socket);
virtual ~WebSocketTransport();
void sendMessage(const QJsonObject &message) override;
private slots:
void textMessageReceived(const QString &message);
private:
QWebSocket *m_socket;
};
#endif // WEBSOCKETTRANSPORT_H

View file

@ -27,11 +27,11 @@
#include "math_helper.h"
#include "net_node_common.h"
#include "maintainers_info_boost_serialization.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
using namespace epee;
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "p2p"
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "p2p"
ENABLE_CHANNEL_BY_DEFAULT(LOG_DEFAULT_CHANNEL);
#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+13)
@ -64,13 +64,13 @@ namespace nodetool
public:
typedef t_payload_net_handler payload_net_handler;
// Some code
node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler),
m_allow_local_ip(false),
m_hide_my_port(false),
node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler),
m_allow_local_ip(false),
m_hide_my_port(false),
m_offline_mode(false),
m_alert_mode(0),
m_alert_mode(0),
m_maintainers_entry_local(AUTO_VAL_INIT(m_maintainers_entry_local)),
m_maintainers_info_local(AUTO_VAL_INIT(m_maintainers_info_local)),
m_maintainers_info_local(AUTO_VAL_INIT(m_maintainers_info_local)),
m_startup_time(time(nullptr)),
m_config{},
m_have_address(false),
@ -99,7 +99,7 @@ namespace nodetool
template <class Archive, class t_version_type>
void serialize(Archive &a, const t_version_type ver)
{
if(ver < CURRENT_P2P_STORAGE_ARCHIVE_VER)
if(ver < CURRENT_P2P_STORAGE_ARCHIVE_VER)
return;
time_t local_time = time(nullptr);
a & local_time;
@ -202,7 +202,7 @@ namespace nodetool
size_t get_random_index_with_fixed_probability(size_t max_index);
bool is_peer_id_used(const peerid_type id);
bool is_peer_used(const peerlist_entry& peer);
bool is_addr_connected(const net_address& peer);
bool is_addr_connected(const net_address& peer);
template<class t_callback>
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback& cb);
bool make_expected_connections_count(bool white_list, size_t expected_connections);
@ -222,7 +222,7 @@ namespace nodetool
//debug functions
std::string print_connections_container();
typedef net_utils::boosted_tcp_server<levin::async_protocol_handler<p2p_connection_context> > net_server;
struct config
@ -262,7 +262,7 @@ namespace nodetool
math_helper::once_a_time_seconds<1> m_connections_maker_interval;
math_helper::once_a_time_seconds<60*30, false> m_peerlist_store_interval;
math_helper::once_a_time_seconds<60> m_remove_dead_conn_interval;
/*this code is temporary here(to show regular message if need), until we get normal GUI*/
math_helper::once_a_time_seconds<60, false> m_calm_alert_interval;
math_helper::once_a_time_seconds<10, false> m_urgent_alert_interval;
@ -289,7 +289,7 @@ namespace nodetool
maintainers_entry m_maintainers_entry_local;
uint8_t m_alert_mode;
critical_section m_maintainers_local_lock;
critical_section m_blocked_ips_lock;
std::map<uint32_t, time_t> m_blocked_ips;

View file

@ -22,7 +22,7 @@
namespace nodetool
{
//zero network before launch
const static boost::uuids::uuid P2P_NETWORK_ID = { { 0x11, 0x10, 0x01, 0x11, 0x01, 0x01, 0x11, 0x01, 0x10, 0x11, P2P_NETWORK_ID_TESTNET_FLAG, 0x11, 0x01, 0x11, 0x21, P2P_NETWORK_ID_VER} };
const static boost::uuids::uuid P2P_NETWORK_ID = { { 0x03, 0x06, 0x09, 0x11, 0x03, 0x06, 0x09, 0x11, 0x10, 0x11, P2P_NETWORK_ID_TESTNET_FLAG, 0x11, 0x01, 0x11, 0x21, P2P_NETWORK_ID_VER} };
namespace
{
@ -34,7 +34,7 @@ namespace nodetool
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_priority_node ("add-priority-node", "Specify list of peers to connect to and attempt to keep the connection open");
const command_line::arg_descriptor<bool> arg_p2p_use_only_priority_nodes ("use-only-priority-nodes", "Connect only to priority nodes");
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node ("seed-node", "Connect to a node to retrieve peer addresses, and disconnect");
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port ("hide-my-port", "Do not announce yourself as peerlist candidate");
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port ("hide-my-port", "Do not announce yourself as peerlist candidate");
const command_line::arg_descriptor<bool> arg_p2p_offline_mode ( "offline-mode", "Don't connect to any node and reject any connections");
const command_line::arg_descriptor<bool> arg_p2p_disable_debug_reqs ( "disable-debug-p2p-requests", "Disable p2p debug requests");
const command_line::arg_descriptor<uint32_t> arg_p2p_ip_auto_blocking ( "p2p-ip-auto-blocking", "Enable (1) or disable (0) peers auto-blocking by IP <0|1>. Default: 0", 1);
@ -50,8 +50,8 @@ namespace nodetool
command_line::add_arg(desc, arg_p2p_allow_local_ip);
command_line::add_arg(desc, arg_p2p_add_peer);
command_line::add_arg(desc, arg_p2p_add_priority_node);
command_line::add_arg(desc, arg_p2p_seed_node);
command_line::add_arg(desc, arg_p2p_hide_my_port);
command_line::add_arg(desc, arg_p2p_seed_node);
command_line::add_arg(desc, arg_p2p_hide_my_port);
command_line::add_arg(desc, arg_p2p_offline_mode);
command_line::add_arg(desc, arg_p2p_disable_debug_reqs);
command_line::add_arg(desc, arg_p2p_use_only_priority_nodes);
@ -69,10 +69,10 @@ namespace nodetool
std::string state_file_path = m_config_folder + "/" + P2P_NET_DATA_FILENAME;
boost::system::error_code ec = AUTO_VAL_INIT(ec);
std::time_t last_update_time = boost::filesystem::last_write_time(state_file_path, ec);
//let's assume that if p2p peer list file stored more then 2 weeks ago,
//then it outdated and we need to fetch peerlist from seed nodes
//let's assume that if p2p peer list file stored more then 2 weeks ago,
//then it outdated and we need to fetch peerlist from seed nodes
if (!ec && time(nullptr) - last_update_time < 86400 * 14)
{
{
tools::unserialize_obj_from_file(*this, state_file_path);
}
@ -80,7 +80,7 @@ namespace nodetool
m_config.m_peer_id = crypto::rand<uint64_t>();
handle_alert_conditions();
//at this moment we have hardcoded config
m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT;
@ -111,7 +111,7 @@ namespace nodetool
if (!m_ip_auto_blocking_enabled)
return true;
return !is_ip_in_blacklist(addr);
}
//-----------------------------------------------------------------------------------
@ -204,7 +204,7 @@ namespace nodetool
}
if (command_line::has_arg(vm, arg_p2p_add_peer))
{
{
std::vector<std::string> perrs = command_line::get_arg(vm, arg_p2p_add_peer);
for(const std::string& pr_str: perrs)
{
@ -217,7 +217,7 @@ namespace nodetool
}
if (command_line::has_arg(vm, arg_p2p_add_priority_node))
{
{
std::vector<std::string> perrs = command_line::get_arg(vm, arg_p2p_add_priority_node);
for(const std::string& pr_str: perrs)
{
@ -243,8 +243,8 @@ namespace nodetool
}
}
if(command_line::has_arg(vm, arg_p2p_hide_my_port))
m_hide_my_port = true;
m_hide_my_port = true;
return true;
}
//-----------------------------------------------------------------------------------
@ -311,27 +311,12 @@ namespace nodetool
{
#ifndef TESTNET
//TODO:
//ADD_HARDCODED_SEED_NODE(std::string("0.0.0.0:") + std::to_string(P2P_DEFAULT_PORT));
ADD_HARDCODED_SEED_NODE("95.217.43.225", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("94.130.137.230", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.42.247", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("94.130.160.115", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("195.201.107.230", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.46.49", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("159.69.76.144", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("144.76.183.143", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST, P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST2, P2P_DEFAULT_PORT);
#else
// TESTNET
ADD_HARDCODED_SEED_NODE("95.217.43.225", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("94.130.137.230", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.42.247", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("94.130.160.115", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("195.201.107.230", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.46.49", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("159.69.76.144", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("144.76.183.143", P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST, P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST2, P2P_DEFAULT_PORT);
#endif
bool res = handle_command_line(vm);
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");
m_config_folder = command_line::get_arg(vm, command_line::arg_data_dir);
@ -345,7 +330,7 @@ namespace nodetool
for(auto& p: m_command_line_peers)
m_peerlist.append_with_peer_white(p);
//only in case if we really sure that we have external visible ip
m_have_address = true;
m_ip_address = 0;
@ -423,7 +408,7 @@ namespace nodetool
}
std::string state_file_path = m_config_folder + "/" + P2P_NET_DATA_FILENAME;
tools::serialize_obj_to_file(*this, state_file_path);
tools::serialize_obj_to_file(*this, state_file_path);
CATCH_ENTRY_L0("node_server<t_payload_net_handler>::save", false);
return true;
}
@ -502,11 +487,11 @@ namespace nodetool
get_local_node_data(arg.node_data);
m_payload_handler.get_payload_sync_data(arg.payload_data);
fill_maintainers_entry(arg.maintrs_entry);
simple_event ev;
std::atomic<bool> hsh_result(false);
bool r = net_utils::async_invoke_remote_command2<typename COMMAND_HANDSHAKE::response>(context_.m_connection_id, COMMAND_HANDSHAKE::ID, arg, m_net_server.get_config_object(),
bool r = net_utils::async_invoke_remote_command2<typename COMMAND_HANDSHAKE::response>(context_.m_connection_id, COMMAND_HANDSHAKE::ID, arg, m_net_server.get_config_object(),
[this, &pi, &ev, &hsh_result, &just_take_peerlist](int code, const typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context)
{
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&](){ev.raise();});
@ -596,7 +581,7 @@ namespace nodetool
m_payload_handler.get_payload_sync_data(arg.payload_data);
fill_maintainers_entry(arg.maintrs_entry);
bool r = net_utils::async_invoke_remote_command2<typename COMMAND_TIMED_SYNC::response>(context_.m_connection_id, COMMAND_TIMED_SYNC::ID, arg, m_net_server.get_config_object(),
bool r = net_utils::async_invoke_remote_command2<typename COMMAND_TIMED_SYNC::response>(context_.m_connection_id, COMMAND_TIMED_SYNC::ID, arg, m_net_server.get_config_object(),
[this](int code, const typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context)
{
if(code < 0)
@ -752,7 +737,7 @@ namespace nodetool
LOG_PRINT_CC_GREEN(con, "CONNECTION HANDSHAKED OK with peer " << string_tools::get_ip_string_from_int32(na.ip) << ":" << string_tools::num_to_string_fast(na.port), LOG_LEVEL_2);
return true;
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
void node_server<t_payload_net_handler>::cache_connect_fail_info(const net_address& addr)
{
@ -831,7 +816,7 @@ namespace nodetool
}
LOG_PRINT_L1("Selected peer: " << pe.id << " " << string_tools::get_ip_string_from_int32(pe.adr.ip) << ":" << boost::lexical_cast<std::string>(pe.adr.port) << "[white=" << use_white_list << "] last_seen: " << (pe.last_seen ? misc_utils::get_time_interval_string(time(NULL) - pe.last_seen) : "never"));
if(!try_to_connect_and_handshake_with_new_peer(pe.adr, false, pe.last_seen, use_white_list))
{
cache_connect_fail_info(pe.adr);
@ -855,7 +840,7 @@ namespace nodetool
size_t try_count = 0;
size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size();
while(true)
{
{
if(m_net_server.is_stop_signal_sent())
return false;
@ -953,7 +938,7 @@ namespace nodetool
if(curr_time - cntx.m_last_recv > P2P_IDLE_CONNECTION_KILL_INTERVAL && curr_time - cntx.m_last_send > P2P_IDLE_CONNECTION_KILL_INTERVAL)
{
LOG_PRINT_CC_L1(cntx, "Connection dropped due to idle");
m_net_server.get_config_object().close(cntx.m_connection_id);
m_net_server.get_config_object().close(cntx.m_connection_id);
return true;
}
return true;
@ -1076,7 +1061,7 @@ namespace nodetool
node_data.peer_id = m_config.m_peer_id;
if(!m_hide_my_port)
node_data.my_port = m_external_port ? m_external_port : m_listenning_port;
else
else
node_data.my_port = 0;
node_data.network_id = P2P_NETWORK_ID;
return true;

View file

@ -24,7 +24,7 @@
#include "syncobj.h"
#include "net/local_ip.h"
#include "p2p_protocol_defs.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "net_peerlist_boost_serialization.h"
#include "common/boost_serialization_helper.h"
@ -39,7 +39,7 @@ namespace nodetool
/************************************************************************/
class peerlist_manager
{
public:
public:
bool init(bool allow_local_ip);
bool deinit();
size_t get_white_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_white.size();}
@ -58,7 +58,7 @@ namespace nodetool
void trim_gray_peerlist();
bool remove_peers_by_ip_from_all(const uint32_t ip);
private:
struct by_time{};
struct by_id{};
@ -105,11 +105,11 @@ namespace nodetool
boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<peerlist_entry,net_address,&peerlist_entry::adr> >,
// sort by peerlist_entry::last_seen<
boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,time_t,&peerlist_entry::last_seen> >
>
>
> peers_indexed;
public:
public:
template <class Archive, class t_version_type>
void serialize(Archive &ar, const t_version_type ver)
{
@ -138,7 +138,7 @@ namespace nodetool
time_t now = 0;
time(&now);
m_allow_local_ip = allow_local_ip;
//adjust local time if it somehow was shifted
CRITICAL_REGION_LOCAL(m_peerlist_lock);
peers_indexed::index<by_time>::type& by_time_index = m_peers_white.get<by_time>();
@ -165,7 +165,7 @@ namespace nodetool
return true;
}
}
//--------------------------------------------------------------------------------------------------
inline
bool peerlist_manager::deinit()
@ -193,7 +193,7 @@ namespace nodetool
}
}
//--------------------------------------------------------------------------------------------------
inline
inline
bool peerlist_manager::merge_peerlist(const std::list<peerlist_entry>& outer_bs)
{
CRITICAL_REGION_LOCAL(m_peerlist_lock);
@ -202,7 +202,7 @@ namespace nodetool
append_with_peer_gray(be);
}
// delete extra elements
trim_gray_peerlist();
trim_gray_peerlist();
return true;
}
//--------------------------------------------------------------------------------------------------
@ -230,7 +230,7 @@ namespace nodetool
return true;
}
//--------------------------------------------------------------------------------------------------
inline
inline
bool peerlist_manager::is_ip_allowed(uint32_t ip)
{
//never allow loopback ip
@ -243,10 +243,10 @@ namespace nodetool
return true;
}
//--------------------------------------------------------------------------------------------------
inline
inline
bool peerlist_manager::get_peerlist_head(std::list<peerlist_entry>& bs_head, uint32_t depth)
{
CRITICAL_REGION_LOCAL(m_peerlist_lock);
peers_indexed::index<by_time>::type& by_time_index=m_peers_white.get<by_time>();
uint32_t cnt = 0;
@ -254,7 +254,7 @@ namespace nodetool
{
if(!vl.last_seen)
continue;
bs_head.push_back(vl);
bs_head.push_back(vl);
if(cnt++ > depth)
break;
}
@ -263,18 +263,18 @@ namespace nodetool
//--------------------------------------------------------------------------------------------------
inline
bool peerlist_manager::get_peerlist_full(std::list<peerlist_entry>& pl_gray, std::list<peerlist_entry>& pl_white)
{
{
CRITICAL_REGION_LOCAL(m_peerlist_lock);
peers_indexed::index<by_time>::type& by_time_index_gr=m_peers_gray.get<by_time>();
BOOST_REVERSE_FOREACH(const peers_indexed::value_type& vl, by_time_index_gr)
{
pl_gray.push_back(vl);
pl_gray.push_back(vl);
}
peers_indexed::index<by_time>::type& by_time_index_wt=m_peers_white.get<by_time>();
BOOST_REVERSE_FOREACH(const peers_indexed::value_type& vl, by_time_index_wt)
{
pl_white.push_back(vl);
pl_white.push_back(vl);
}
return true;
@ -320,8 +320,8 @@ namespace nodetool
trim_white_peerlist();
}else
{
//update record in white list
m_peers_white.replace(by_addr_it_wt, ple);
//update record in white list
m_peers_white.replace(by_addr_it_wt, ple);
}
//remove from gray list, if need
auto by_addr_it_gr = m_peers_gray.get<by_addr>().find(ple.adr);
@ -352,11 +352,11 @@ namespace nodetool
{
//put new record into white list
m_peers_gray.insert(ple);
trim_gray_peerlist();
trim_gray_peerlist();
}else
{
//update record in white list
m_peers_gray.replace(by_addr_it_gr, ple);
//update record in white list
m_peers_gray.replace(by_addr_it_gr, ple);
}
return true;
CATCH_ENTRY_L0("peerlist_manager::append_with_peer_gray()", false);
@ -377,7 +377,7 @@ namespace nodetool
else
++it;
}
for (auto it = m_peers_gray.begin(); it != m_peers_gray.end();)
{
if (it->adr.ip == ip)

View file

@ -9,7 +9,7 @@
#include <boost/uuid/uuid.hpp>
#include "serialization/keyvalue_serialization.h"
#include "misc_language.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "crypto/crypto.h"
namespace nodetool
@ -19,7 +19,7 @@ namespace nodetool
typedef std::string blobdata;
#pragma pack (push, 1)
struct net_address
{
uint32_t ip;
@ -59,7 +59,7 @@ namespace nodetool
{
return memcmp(&a, &b, sizeof(a)) == 0;
}
inline
inline
std::string print_peerlist_to_string(const std::list<peerlist_entry>& pl)
{
time_t now_time = 0;
@ -94,7 +94,7 @@ namespace nodetool
struct basic_node_data
{
uuid network_id;
uuid network_id;
int64_t local_time;
uint32_t my_port;
peerid_type peer_id;
@ -106,7 +106,7 @@ namespace nodetool
KV_SERIALIZE(my_port)
END_KV_SERIALIZE_MAP()
};
#define P2P_COMMANDS_POOL_BASE 1000
@ -129,7 +129,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_N(if_build_less_then, "build")
KV_SERIALIZE_N(alert_mode, "mode")
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
struct maintainers_info
@ -242,7 +242,7 @@ namespace nodetool
{
int64_t local_time;
t_playload_type payload_data;
std::list<peerlist_entry> local_peerlist;
std::list<peerlist_entry> local_peerlist;
maintainers_entry maintrs_entry;
BEGIN_KV_SERIALIZE_MAP()
@ -261,7 +261,7 @@ namespace nodetool
struct COMMAND_PING
{
/*
Used to make "callback" connection, to be sure that opponent node
Used to make "callback" connection, to be sure that opponent node
have accessible connection point. Only other nodes can add peer to peerlist,
and ONLY in case when peer has accepted connection and answered to ping.
*/
@ -285,13 +285,13 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(status)
KV_SERIALIZE(peer_id)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
};
#ifdef ALLOW_DEBUG_COMMANDS
//These commands are considered as insecure, and made in debug purposes for a limited lifetime.
//These commands are considered as insecure, and made in debug purposes for a limited lifetime.
//Anyone who feel unsafe with this commands can disable the ALLOW_GET_STAT_COMMAND macro.
struct proof_of_trust
@ -302,9 +302,9 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(peer_id)
KV_SERIALIZE(time)
KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
END_KV_SERIALIZE_MAP()
KV_SERIALIZE(time)
KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
END_KV_SERIALIZE_MAP()
};
@ -320,9 +320,9 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(pr)
KV_SERIALIZE(tr)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
struct response
{
std::string version;
@ -337,7 +337,7 @@ namespace nodetool
KV_SERIALIZE(incoming_connections_count)
KV_SERIALIZE(current_log_size)
KV_SERIALIZE(payload_info)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
};
@ -354,14 +354,14 @@ namespace nodetool
proof_of_trust tr;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tr)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
struct response
{
std::list<peerlist_entry> local_peerlist_white;
std::list<peerlist_entry> local_peerlist_gray;
std::list<connection_entry> connections_list;
std::list<peerlist_entry> local_peerlist_white;
std::list<peerlist_entry> local_peerlist_gray;
std::list<connection_entry> connections_list;
peerid_type my_id;
uint64_t local_time;
uint64_t up_time;
@ -372,7 +372,7 @@ namespace nodetool
KV_SERIALIZE(my_id)
KV_SERIALIZE(local_time)
KV_SERIALIZE(up_time)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
};
@ -386,7 +386,7 @@ namespace nodetool
struct request
{
BEGIN_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
struct response
@ -395,7 +395,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(my_id)
END_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP()
};
};
@ -466,7 +466,7 @@ namespace nodetool
};
#endif // #ifdef ALLOW_DEBUG_COMMANDS
}

View file

@ -287,7 +287,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("start_mining", boost::bind(&simple_wallet::start_mining, this, ph::_1), "start_mining <threads_count> - Start mining in daemon");
m_cmd_binder.set_handler("stop_mining", boost::bind(&simple_wallet::stop_mining, this, ph::_1), "Stop mining in daemon");
m_cmd_binder.set_handler("refresh", boost::bind(&simple_wallet::refresh, this, ph::_1), "Resynchronize transactions and balance");
m_cmd_binder.set_handler("balance", boost::bind(&simple_wallet::show_balance, this, ph::_1), "Show current wallet balance");
m_cmd_binder.set_handler("balance", boost::bind(&simple_wallet::show_balance, this, ph::_1), "Show current wallet balance");
m_cmd_binder.set_handler("show_staking_history", boost::bind(&simple_wallet::show_staking_history, this, ph::_1), "show_staking_history [2] - Show staking transfers, if option provided - number of days for history to display");
m_cmd_binder.set_handler("incoming_transfers", boost::bind(&simple_wallet::show_incoming_transfers, this, ph::_1), "incoming_transfers [available|unavailable] - Show incoming transfers - all of them or filter them by availability");
m_cmd_binder.set_handler("incoming_counts", boost::bind(&simple_wallet::show_incoming_transfers_counts, this, ph::_1), "incoming_transfers counts");
@ -540,8 +540,8 @@ void simple_wallet::handle_command_line(const boost::program_options::variables_
m_disable_tor = command_line::get_arg(vm, arg_disable_tor_relay);
m_voting_config_file = command_line::get_arg(vm, arg_voting_config_file);
m_no_password_confirmations = command_line::get_arg(vm, arg_no_password_confirmations);
}
}
//----------------------------------------------------------------------------------------------------
#define PASSWORD_CONFIRMATION_ATTEMPTS 3
@ -874,7 +874,7 @@ void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_inf
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points);
message_writer(epee::log_space::console_color_cyan, false) << " "
message_writer(epee::log_space::console_color_cyan, false) << " "
<< std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(st.amount, decimal_points) << (st.is_income ? " received," : " spent") << " " << token_info;
}
}
@ -1047,11 +1047,11 @@ bool simple_wallet::print_wti(const tools::wallet_public::wallet_transfer_info&
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points);
success_msg_writer(cl)
success_msg_writer(cl)
<< (st.is_income ? "Received " : "Sent ")
<< print_money(st.amount, decimal_points) << token_info;
}
}
return true;
}
@ -1175,7 +1175,7 @@ bool simple_wallet::show_staking_history(const std::vector<std::string>& args)
if (n_days)
timestamp = static_cast<uint64_t>(time(nullptr)) - (n_days * 60 * 60 * 24);
uint64_t amount_total_staked = 0;
bool transfers_found = false;
for (auto it = transfers.rbegin(); it != transfers.rend(); it++)
@ -1192,7 +1192,7 @@ bool simple_wallet::show_staking_history(const std::vector<std::string>& args)
is_coinbase(td.m_ptx_wallet_info->m_tx, pos_coinbase);
if (!pos_coinbase)
continue;
if (!transfers_found)
{
message_writer() << " amount \tspent\tglobal index\t tx id";
@ -1215,7 +1215,7 @@ bool simple_wallet::show_staking_history(const std::vector<std::string>& args)
success_msg_writer() << "Total staked: " << print_money(amount_total_staked);
}
return true;
}
@ -1513,18 +1513,18 @@ bool simple_wallet::validate_wrap_status(uint64_t amount)
currency::void_struct req = AUTO_VAL_INIT(req);
currency::rpc_get_wrap_info_response res = AUTO_VAL_INIT(res);
bool r = epee::net_utils::invoke_http_json_remote_command2("http://wrapped.zano.org/api2/get_wrap_info", req, res, http_client, 10000);
bool r = epee::net_utils::invoke_http_json_remote_command2("http://wrapped.lethean.org/api2/get_wrap_info", req, res, http_client, 10000);
if (!r)
{
fail_msg_writer() << "Failed to request wrap status from server, check internet connection";
return false;
}
//check if amount is bigger then erc20 fee
uint64_t zano_needed_for_wrap = std::stoll(res.tx_cost.zano_needed_for_erc20);
if (amount <= zano_needed_for_wrap)
uint64_t lethean_needed_for_wrap = std::stoll(res.tx_cost.lethean_needed_for_erc20);
if (amount <= lethean_needed_for_wrap)
{
fail_msg_writer() << "Too small amount to cover ERC20 fee. ERC20 cost is: "
<< print_money(zano_needed_for_wrap) << " Zano" <<
<< print_money(lethean_needed_for_wrap) << " Lethean" <<
"($" << res.tx_cost.usd_needed_for_erc20 << ")";
return false;
}
@ -1532,11 +1532,11 @@ bool simple_wallet::validate_wrap_status(uint64_t amount)
if (amount > unwrapped_coins_left)
{
fail_msg_writer() << "Amount is bigger than ERC20 tokens left available: "
<< print_money(unwrapped_coins_left) << " wZano";
<< print_money(unwrapped_coins_left) << " wLethean";
return false;
}
success_msg_writer(false) << "You'll receive estimate " << print_money(amount - zano_needed_for_wrap) << " wZano (" << print_money(zano_needed_for_wrap)<< " Zano will be used to cover ERC20 fee)";
success_msg_writer(false) << "You'll receive estimate " << print_money(amount - lethean_needed_for_wrap) << " wLethean (" << print_money(lethean_needed_for_wrap)<< " Lethean will be used to cover ERC20 fee)";
success_msg_writer(false) << "Proceed? (yes/no)";
while (true)
{
@ -1613,7 +1613,7 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
{
std::string integrated_payment_id;
currency::tx_destination_entry de = AUTO_VAL_INIT(de);
de.addr.resize(1);
de.addr.resize(1);
bool ok = currency::parse_amount(de.amount, local_args[i + 1]);
if (!ok || 0 == de.amount)
@ -1628,13 +1628,13 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
fail_msg_writer() << "address is wrong: " << local_args[i];
return true;
}
//check if address looks like wrapped address
if (is_address_like_wrapped(local_args[i]))
{
success_msg_writer(false) << "Address " << local_args[i] << " recognized as wrapped address, creating wrapping transaction.";
success_msg_writer(false) << "This transaction will create wZano (\"Wrapped Zano\") which will be sent to the specified address on the Ethereum network.";
success_msg_writer(false) << "This transaction will create wLethean (\"Wrapped Lethean\") which will be sent to the specified address on the Ethereum network.";
if (!validate_wrap_status(de.amount))
{
@ -1693,14 +1693,14 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
if (!m_wallet->is_watch_only())
{
if(wrapped_transaction)
success_msg_writer(true) << "Transaction successfully sent to wZano custody wallet, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes";
success_msg_writer(true) << "Transaction successfully sent to wLethean custody wallet, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes";
else
success_msg_writer(true) << "Transaction successfully sent, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes";
}
else
{
success_msg_writer(true) << "Transaction prepared for signing and saved into \"zano_tx_unsigned\" file, use full wallet to sign transfer and then use \"submit_transfer\" on this wallet to broadcast the transaction to the network";
}
success_msg_writer(true) << "Transaction prepared for signing and saved into \"lethean_tx_unsigned\" file, use full wallet to sign transfer and then use \"submit_transfer\" on this wallet to broadcast the transaction to the network";
}
SIMPLE_WALLET_CATCH_TRY_ENTRY()
return true;
@ -2071,7 +2071,7 @@ bool simple_wallet::deploy_new_asset(const std::vector<std::string> &args)
<< "Emitted: " << print_fixed_decimal_point(adb.current_supply, adb.decimal_point) << ENDL
<< "Max emission: " << print_fixed_decimal_point(adb.total_max_supply, adb.decimal_point) << ENDL
;
SIMPLE_WALLET_CATCH_TRY_ENTRY();
return true;
}
@ -2254,7 +2254,7 @@ bool simple_wallet::add_custom_asset_id(const std::vector<std::string> &args)
}
else
{
success_msg_writer() << "The following custom asset was successfully added to the wallet:" << ENDL
success_msg_writer() << "The following custom asset was successfully added to the wallet:" << ENDL
<< " id: " << asset_id << ENDL
<< " title: " << asset_descriptor.full_name << ENDL
<< " ticker: " << asset_descriptor.ticker << ENDL
@ -2306,7 +2306,7 @@ bool simple_wallet::generate_ionic_swap_proposal(const std::vector<std::string>
return true;
}
else
{
{
success_msg_writer() << "Generated proposal: " << ENDL << epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(proposal));
}
SIMPLE_WALLET_CATCH_TRY_ENTRY();
@ -2494,7 +2494,7 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args)
size_t outs_total = 0, outs_swept = 0;
uint64_t amount_total = 0, amount_swept = 0;
currency::transaction result_tx = AUTO_VAL_INIT(result_tx);
std::string filename = "zano_tx_unsigned";
std::string filename = "lethean_tx_unsigned";
m_wallet->sweep_below(fake_outs_count, addr, amount, payment_id, fee, outs_total, amount_total, outs_swept, amount_swept, &result_tx, &filename);
success_msg_writer(false) << outs_swept << " outputs (" << print_money_brief(amount_swept) << " coins) of " << outs_total << " total (" << print_money_brief(amount_total)
@ -2675,9 +2675,9 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_params, arg_set_timeout);
command_line::add_arg(desc_params, arg_voting_config_file);
command_line::add_arg(desc_params, arg_no_password_confirmations);
tools::wallet_rpc_server::init_options(desc_params);
@ -2850,8 +2850,8 @@ int main(int argc, char* argv[])
LOG_PRINT_YELLOW("PoS reward will be sent to another address: " << arg_pos_mining_reward_address_str, LOG_LEVEL_0);
}
}
tools::wallet_rpc_server wrpc(wallet_ptr);
bool r = wrpc.init(vm);

View file

@ -6,14 +6,14 @@
#include "stratum_server.h"
#include "stratum_helpers.h"
#include "net/abstract_tcp_server2.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "currency_core/currency_core.h"
#include "common/command_line.h"
#include "common/int-util.h"
#include "version.h"
#include "currency_protocol/currency_protocol_handler.h"
#undef LOG_DEFAULT_CHANNEL
#undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "stratum"
ENABLE_CHANNEL_BY_DEFAULT("stratum");
@ -46,11 +46,11 @@ namespace
const command_line::arg_descriptor<std::string> arg_stratum_miner_address = {"stratum-miner-address", "Stratum server: miner address. All workers"
" will mine to this address. If not set here, ALL workers should use the very same wallet address as username."
" If set here - they're allowed to log in with username '" WORKER_ALLOWED_USERNAME "' instead of address."};
const command_line::arg_descriptor<size_t> arg_stratum_block_template_update_period = {"stratum-template-update-period",
"Stratum server: if there are no new blocks, update block template this often (sec.)", STRATUM_BLOCK_TEMPLATE_UPD_PERIOD_DEFAULT };
const command_line::arg_descriptor<uint64_t> arg_stratum_hr_print_interval ("stratum-hr-print-interval", "Stratum server: how often to print hashrate stats (sec.)", STRATUM_TOTAL_HR_PRINT_INTERVAL_S_DEFAULT );
const command_line::arg_descriptor<uint64_t> arg_stratum_vdiff_target_min ("stratum-vdiff-target-min", "Stratum server: minimum worker difficulty", VDIFF_TARGET_MIN_DEFAULT );
const command_line::arg_descriptor<uint64_t> arg_stratum_vdiff_target_max ("stratum-vdiff-target-max", "Stratum server: maximum worker difficulty", VDIFF_TARGET_MAX_DEFAULT );
const command_line::arg_descriptor<uint64_t> arg_stratum_vdiff_target_time ("stratum-vdiff-target-time", "Stratum server: target time per share (i.e. try to get one share per this many seconds)", VDIFF_TARGET_TIME_DEFAULT );
@ -98,7 +98,7 @@ namespace
, variance_percent(0)
{}
vdiff_params_t(uint64_t target_min, uint64_t target_max, uint64_t target_time_s, uint64_t retarget_time_s, uint64_t retarget_shares_count, uint64_t variance_percent)
vdiff_params_t(uint64_t target_min, uint64_t target_max, uint64_t target_time_s, uint64_t retarget_time_s, uint64_t retarget_shares_count, uint64_t variance_percent)
: target_min(target_min)
, target_max(target_max)
, target_time_ms(target_time_s * 1000)
@ -140,7 +140,7 @@ namespace
CRITICAL_REGION_LOCAL(m_lock);
return (epee::misc_utils::get_tick_count() - m_ts_started) / 1000;
}
uint64_t estimate_worker_hashrate()
{
CRITICAL_REGION_LOCAL(m_lock);
@ -225,7 +225,7 @@ namespace
new_d = m_vd_params.target_min;
if (new_d > m_vd_params.target_max)
new_d = m_vd_params.target_max;
if (new_d != m_worker_difficulty)
{
LP_CC_WORKER_YELLOW((*this), "difficulty update: " << m_worker_difficulty << " -> " << new_d <<
@ -388,7 +388,7 @@ namespace
m_p_core->get_blockchain_top(stub, top_block_id);
if (!enforce_update && top_block_id == m_blockchain_last_block_id && epee::misc_utils::get_tick_count() - m_block_template_update_ts < m_block_template_update_pediod_ms)
return false;// no new blocks since last update, keep the same work
LOG_PRINT("stratum_protocol_handler_config::update_block_template(" << (enforce_update ? "true" : "false") << ")", LOG_LEVEL_4);
m_block_template = AUTO_VAL_INIT(m_block_template);
wide_difficulty_type block_template_difficulty;
@ -457,7 +457,7 @@ namespace
{
LP_CC_WORKER_YELLOW(p_ph->get_context(), "core is NOT synchronized, respond with empty job package", LOG_LEVEL_2);
}
if (!updated)
p_ph->set_work(get_work_json(p_ph->get_context().get_worker_difficulty()));
}
@ -474,7 +474,7 @@ namespace
p_ph->send_response_default(id);
return true;
}
const uint64_t height = get_block_height(m_block_template);
// make sure worker sent work with correct block ethash
@ -606,7 +606,7 @@ namespace
LP_CC_WORKER_GREEN(p_ph->get_context(), "logged in with username " << user_str << ", start difficulty: " << (start_difficulty != 0 ? std::to_string(start_difficulty) : "default"), LOG_LEVEL_0);
p_ph->send_response_default(id);
// send initial work
update_work(p_ph);
@ -615,7 +615,7 @@ namespace
bool handle_submit_hashrate(protocol_handler_t* p_ph, uint64_t rate, const crypto::hash& rate_submit_id)
{
LP_CC_WORKER_CYAN(p_ph->get_context(), "reported hashrate: " << HR_TO_STREAM_IN_MHS_3P(rate) << " Mh/s" <<
LP_CC_WORKER_CYAN(p_ph->get_context(), "reported hashrate: " << HR_TO_STREAM_IN_MHS_3P(rate) << " Mh/s" <<
", estimated hashrate: " << HR_TO_STREAM_IN_MHS_3P(p_ph->get_context().estimate_worker_hashrate()) << " Mh/s, run time: " <<
epee::misc_utils::get_time_interval_string(p_ph->get_context().get_hr_estimate_duration()), LOG_LEVEL_3);
return true;
@ -992,7 +992,7 @@ namespace
// JSON-RPC 2.0 spec: "A Notification is a Request object without an "id" member."
send(R"({"jsonrpc":"2.0",)" + json + "}" "\n"); // LF character is not specified by JSON-RPC standard, but it is REQUIRED by ethminer 0.12 to work
}
void send_response_method(const jsonrpc_id_t& id, const std::string& method, const std::string& response)
{
send_response(id, std::string(R"("method":")") + method + R"(",)" + response);
@ -1073,7 +1073,7 @@ namespace
typedef bool (this_t::*method_handler_func_t)(const jsonrpc_id_t& id, epee::serialization::portable_storage& ps, epee::serialization::portable_storage::hsection params_section);
static std::unordered_map<std::string, method_handler_func_t> m_methods_handlers;
std::atomic<bool> m_connection_initialized;
}; // class stratum_protocol_handler
//==============================================================================================================================
@ -1143,7 +1143,7 @@ bool stratum_server::init(const boost::program_options::variables_map& vm)
auto& config = m_impl->server.get_config_object();
config.set_core(m_p_core);
if (command_line::has_arg(vm, arg_stratum_always_online))
{
config.set_is_core_always_online(command_line::get_arg(vm, arg_stratum_always_online));

View file

@ -3,11 +3,11 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_MAJOR_VERSION "2"
#define PROJECT_MINOR_VERSION "0"
#define PROJECT_MAJOR_VERSION "1"
#define PROJECT_MINOR_VERSION "5"
#define PROJECT_REVISION "0"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 280
#define PROJECT_VERSION_BUILD_NO 143
#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 "]"

View file

@ -8,7 +8,7 @@
#endif
#include "plain_wallet_api.h"
#include "plain_wallet_api_defs.h"
#include "currency_core/currency_config.h"
#include "currency_config.h"
#include "version.h"
#include "string_tools.h"
#include "currency_core/currency_format_utils.h"
@ -18,10 +18,9 @@
#include "static_helpers.h"
#include "wallet_helpers.h"
#define ANDROID_PACKAGE_NAME "com.zano_mobile"
#define ANDROID_PACKAGE_NAME "com.lethean_mobile"
#define LOGS_FOLDER "logs"
#define WALLETS_FOLDER_NAME "wallets"
#define APP_CONFIG_FOLDER "app_config"
#define APP_CONFIG_FILENAME "app_cfg.bin"
@ -93,11 +92,11 @@ namespace plain_wallet
{
get_set_working_dir(true, dir);
}
std::string get_wallets_folder()
{
#ifdef CAKEWALLET
std::string path = "";
#ifdef CAKEWALLET
std::string path = "";
#elif WIN32
std::string path = get_bundle_working_dir() + "/" + WALLETS_FOLDER_NAME + "/";
#else
@ -108,7 +107,7 @@ namespace plain_wallet
std::string get_app_config_folder()
{
#ifdef CAKEWALLET
#ifdef CAKEWALLET
std::string path = "";
#elif WIN32
std::string path = get_bundle_working_dir() + "/" + APP_CONFIG_FOLDER + "/";
@ -165,7 +164,7 @@ namespace plain_wallet
//wait other callers finish
local_ptr->gjobs_lock.lock();
local_ptr->gjobs_lock.unlock();
bool r = local_ptr->gwm.quick_stop_no_save();
bool r = local_ptr->gwm.quick_stop_no_save();
LOG_PRINT_L0("[QUICK_STOP_NO_SAVE] return " << r);
//let's prepare wallet manager for quick shutdown
local_ptr.reset();
@ -181,7 +180,6 @@ namespace plain_wallet
return epee::serialization::store_t_to_json(ok_response);
}
std::string init(const std::string& ip, const std::string& port, const std::string& working_dir, int log_level)
{
auto local_ptr = std::atomic_load(&ginstance_ptr);
@ -200,7 +198,7 @@ namespace plain_wallet
set_bundle_working_dir(working_dir);
initialize_logs(log_level);
std::string argss_1 = std::string("--remote-node=") + ip + ":" + port;
std::string argss_1 = std::string("--remote-node=") + ip + ":" + port;
std::string argss_2 = std::string("--disable-logs-init");
char * args[4];
static const char* arg0_stub = "stub";
@ -214,7 +212,7 @@ namespace plain_wallet
LOG_ERROR("Failed to init wallets_manager");
return GENERAL_INTERNAL_ERRROR_INIT;
}
ptr->gwm.set_use_deffered_global_outputs(true);
if(!ptr->gwm.start())
@ -308,7 +306,7 @@ namespace plain_wallet
std::string generate_random_key(uint64_t lenght)
{
std::string buff;
std::string buff;
buff.resize(lenght);
crypto::generate_random_bytes(lenght, const_cast<char*>(buff.data()));
return tools::base58::encode(buff);
@ -361,7 +359,7 @@ namespace plain_wallet
{
const std::string src_folder_path = get_bundle_working_dir();
boost::system::error_code ec;
const std::string full_target_path = target_dir + "/Zano_export" + std::to_string(epee::misc_utils::get_tick_count());
const std::string full_target_path = target_dir + "/Lethean_export" + std::to_string(epee::misc_utils::get_tick_count());
boost::filesystem::create_directory(full_target_path, ec);
if (ec)
{
@ -419,7 +417,7 @@ namespace plain_wallet
std::stringstream res;
res << "{ \"valid\": " << (valid?"true":"false") << ", \"auditable\": "
<< (apa.is_auditable() ? "true" : "false")
<< ",\"payment_id\": " << (pid.size() ? "true" : "false")
<< ",\"payment_id\": " << (pid.size() ? "true" : "false")
<< ",\"wrap\": " << (wrap ? "true" : "false")
<< "}";
return res.str();
@ -603,7 +601,7 @@ namespace plain_wallet
rsp.error_code = tools::get_seed_phrase_info(sip.seed_phrase, sip.seed_password, rsp.response_data);
res = epee::serialization::store_t_to_json(rsp);
}
}
}
else if (method_name == "invoke")
{
res = invoke(instance_id, params);
@ -628,7 +626,7 @@ namespace plain_wallet
{
auto inst_ptr = std::atomic_load(&ginstance_ptr);
if (!inst_ptr)
{
{
return "{\"status\": \"canceled\"}";
}
//TODO: need refactoring
@ -676,4 +674,4 @@ namespace plain_wallet
{
return TX_DEFAULT_FEE;
}
}
}

View file

@ -7327,7 +7327,7 @@ void wallet2::transfer(construct_tx_param& ctp,
if (m_watch_only)
{
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);
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 : "lethean_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;

View file

@ -74,7 +74,7 @@ wallets_manager::wallets_manager():m_pview(&m_view_stub),
m_rpc_proxy(new tools::core_fast_rpc_proxy(m_rpc_server)),
m_offers_service(nullptr),
m_wallet_rpc_server(this),
#else
#else
m_rpc_proxy(new tools::default_http_core_proxy()),
#endif
@ -175,7 +175,7 @@ bool wallets_manager::init_command_line(int argc, char* argv[], std::string& fai
command_line::add_arg(desc_cmd_sett, command_line::arg_log_level);
command_line::add_arg(desc_cmd_sett, command_line::arg_console);
command_line::add_arg(desc_cmd_only, command_line::arg_show_details);
command_line::add_arg(desc_cmd_sett, arg_alloc_win_console);
command_line::add_arg(desc_cmd_sett, arg_sandbox_disable);
command_line::add_arg(desc_cmd_sett, arg_html_folder);
@ -1044,7 +1044,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
w->set_votes_config_path(m_data_dir + "/" + CURRENCY_VOTING_CONFIG_DEFAULT_FILENAME);
std::string return_code = API_RETURN_CODE_OK;
while (true)
{
@ -1662,10 +1662,10 @@ std::string wallets_manager::get_wallet_info(uint64_t wallet_id, view::wallet_in
std::string wallets_manager::get_wallet_info_extra(uint64_t wallet_id, view::wallet_info_extra& wi)
{
GET_WALLET_OPT_BY_ID(wallet_id, wo);
auto locker_object = wo.w.lock();
tools::wallet2& rw = *(*(*locker_object)); //this looks a bit crazy, i know
auto& keys = rw.get_account().get_keys();
wi.view_private_key = epee::string_tools::pod_to_hex(keys.view_secret_key);
@ -1810,7 +1810,7 @@ std::string wallets_manager::reset_wallet_password(uint64_t wallet_id, const std
}
std::string wallets_manager::use_whitelisting(uint64_t wallet_id, bool use)
{
GET_WALLET_OPT_BY_ID(wallet_id, w);
GET_WALLET_OPT_BY_ID(wallet_id, w);
w.w->get()->set_use_assets_whitelisting(use);
return API_RETURN_CODE_OK;
}
@ -2079,11 +2079,11 @@ void wallets_manager::on_mw_get_wallets(std::vector<tools::wallet_public::wallet
}
bool wallets_manager::on_mw_select_wallet(uint64_t wallet_id)
{
SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock);
auto it = m_wallets.find(wallet_id);
if (it == m_wallets.end())
return false;
SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock);
auto it = m_wallets.find(wallet_id);
if (it == m_wallets.end())
return false;
#ifndef MOBILE_WALLET_BUILD
m_rpc_selected_wallet_id = wallet_id;
#endif
@ -2104,7 +2104,7 @@ bool wallets_manager::on_mw_select_wallet(const tools::wallet_public::COMMAND_MW
}
void wallets_manager::lock()
void wallets_manager::lock()
{
#ifndef MOBILE_WALLET_BUILD
{
@ -2119,7 +2119,7 @@ void wallets_manager::lock()
#endif
}
void wallets_manager::unlock()
void wallets_manager::unlock()
{
#ifndef MOBILE_WALLET_BUILD
m_current_wallet_locked_object.reset();

View file

@ -1638,7 +1638,7 @@ multisig_and_checkpoints::multisig_and_checkpoints()
bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
currency::checkpoints checkpoints;
checkpoints.add_checkpoint(15, "6f9194c144afd73077478e7f04e947c50160b5673558e6f696a4f662a3ca261e");
checkpoints.add_checkpoint(15, "3e163f0828e08aea66775a3a92ead64298a67e0de66e6aa5453673716f2a5970");
c.set_checkpoints(std::move(checkpoints));
return true;

View file

@ -222,8 +222,8 @@ bool test_transactions()
{
if(!test_transaction_generation_and_ring_signature())
return false;
if(!test_block_creation())
return false;
// if(!test_block_creation())
// return false;
if (!test_example_key_derivation())
return false;

View file

@ -572,7 +572,7 @@ TEST(crypto, constants)
point_t HpG = H + G;
point_t HmG = H - G;
point_t Hd8 = c_scalar_1div8 * H;
ASSERT_EQ(scalar_t(8) * Hd8, H);
// print them
@ -1046,115 +1046,115 @@ TEST(crypto, hp)
LOG_PRINT_L0("cn_fast_hash('') * G = " << zG.to_public_key() << " (pub_key)");
ASSERT_EQ(zG, point_from_str("7849297236cd7c0d6c69a3c8c179c038d3c1c434735741bb3c8995c3c9d6f2ac"));
crypto::cn_fast_hash("zano", 4, hash);
LOG_PRINT_L0("cn_fast_hash('zano') = " << hash);
crypto::cn_fast_hash("lethean", 4, hash);
LOG_PRINT_L0("cn_fast_hash('lethean') = " << hash);
ASSERT_EQ(hash, hash_from_str("23cea10abfdf3ace0b7132291d51e4eb5a392afb2147e67f907ff4f8f5dd4f9f"));
z = hash;
zG = z * c_point_G;
LOG_PRINT_L0("cn_fast_hash('zano') * G = " << zG.to_public_key() << " (pub_key)");
LOG_PRINT_L0("cn_fast_hash('lethean') * G = " << zG.to_public_key() << " (pub_key)");
ASSERT_EQ(zG, point_from_str("71407d59e9d671fa02f26a6a7f4726c3087d8f1732453396638a1dc2929fb57a"));
char buf[2000];
for (size_t i = 0; i < sizeof buf; i += 4)
*(uint32_t*)&buf[i] = *(uint32_t*)"zano";
*(uint32_t*)&buf[i] = *(uint32_t*)"lethean";
crypto::cn_fast_hash(buf, sizeof buf, (char*)&hash);
LOG_PRINT_L0("cn_fast_hash('zano' x 500) = " << hash);
LOG_PRINT_L0("cn_fast_hash('lethean' x 500) = " << hash);
ASSERT_EQ(hash, hash_from_str("16d87120c601a6ef3e4ffa5e58176a36b814288199f23ec09ef178c554e8879b"));
z = hash;
zG = z * c_point_G;
LOG_PRINT_L0("cn_fast_hash('zano' x 500) * G = " << zG.to_public_key() << " (pub_key)");
LOG_PRINT_L0("cn_fast_hash('lethean' x 500) * G = " << zG.to_public_key() << " (pub_key)");
ASSERT_EQ(zG, point_from_str("dd93067a02fb8661aa64504ac1503402a34426f43650d970c35147cec4b61d55"));
return true;
}
TEST(crypto, cn_fast_hash_perf)
{
//return true;
const crypto::hash h_initial = *(crypto::hash*)(&scalar_t::random());
std::vector<std::vector<uint8_t>> test_data;
test_data.push_back(std::vector<uint8_t>(32, 0));
test_data.push_back(std::vector<uint8_t>(63, 0));
test_data.push_back(std::vector<uint8_t>(127, 0));
test_data.push_back(std::vector<uint8_t>(135, 0));
test_data.push_back(std::vector<uint8_t>(255, 0));
test_data.push_back(std::vector<uint8_t>(271, 0)); // 271 = 136 * 2 - 1
test_data.push_back(std::vector<uint8_t>(2030, 0));
for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
crypto::generate_random_bytes(test_data[j].size(), test_data[j].data());
struct times_t
{
uint64_t t_old{ 0 }, t_new{ 0 };
crypto::hash h_old{};
double diff{ 0 };
};
std::vector<times_t> results(test_data.size());
size_t n = 50000;
double diff_sum = 0;
for (size_t k = 0; k < 50; ++k)
{
for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
{
crypto::hash h = h_initial;
TIME_MEASURE_START(t_old);
for (size_t i = 0; i < n; ++i)
{
*(crypto::hash*)(test_data[j].data()) = h;
cn_fast_hash_old(test_data[j].data(), test_data[j].size(), (char*)&h);
}
TIME_MEASURE_FINISH(t_old);
results[j].t_old = t_old;
results[j].h_old = h;
}
for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
{
crypto::hash h = h_initial;
TIME_MEASURE_START(t_new);
for (size_t i = 0; i < n; ++i)
{
*(crypto::hash*)(test_data[j].data()) = h;
cn_fast_hash(test_data[j].data(), test_data[j].size(), (char*)&h);
}
TIME_MEASURE_FINISH(t_new);
results[j].t_new = t_new;
ASSERT_EQ(h, results[j].h_old);
}
std::stringstream ss;
double diff_round = 0;
for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
{
double diff = ((int64_t)results[j].t_old - (int64_t)results[j].t_new) / (double)n;
ss << std::fixed << std::setprecision(3) << results[j].t_old / (double)n << "/" <<
std::fixed << std::setprecision(3) << results[j].t_new / (double)n << " ";
results[j].diff += diff;
diff_round += diff;
}
diff_sum += diff_round;
LOG_PRINT_L0("cn_fast_hash (old/new) [" << std::setw(2) << k << "]: " << ss.str() << " mcs, diff_round = " << std::fixed << std::setprecision(4) << diff_round <<
" diff_sum = " << std::fixed << std::setprecision(4) << diff_sum);
}
std::stringstream ss;
for (size_t j = 0, sz = results.size(); j < sz; ++j)
ss << std::fixed << std::setprecision(4) << results[j].diff << " ";
LOG_PRINT_L0(" " << ss.str());
return true;
}
//TEST(crypto, cn_fast_hash_perf)
//{
// return true;
// const crypto::hash h_initial = *(crypto::hash*)(&scalar_t::random());
//
// std::vector<std::vector<uint8_t>> test_data;
// test_data.push_back(std::vector<uint8_t>(32, 0));
// test_data.push_back(std::vector<uint8_t>(63, 0));
// test_data.push_back(std::vector<uint8_t>(127, 0));
// test_data.push_back(std::vector<uint8_t>(135, 0));
// test_data.push_back(std::vector<uint8_t>(255, 0));
// test_data.push_back(std::vector<uint8_t>(271, 0)); // 271 = 136 * 2 - 1
// test_data.push_back(std::vector<uint8_t>(2030, 0));
//
// for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
// crypto::generate_random_bytes(test_data[j].size(), test_data[j].data());
//
// struct times_t
// {
// uint64_t t_old{ 0 }, t_new{ 0 };
// crypto::hash h_old{};
// double diff{ 0 };
// };
// std::vector<times_t> results(test_data.size());
//
// size_t n = 50000;
// double diff_sum = 0;
//
// for (size_t k = 0; k < 50; ++k)
// {
// for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
// {
// crypto::hash h = h_initial;
// TIME_MEASURE_START(t_old);
// for (size_t i = 0; i < n; ++i)
// {
// *(crypto::hash*)(test_data[j].data()) = h;
// cn_fast_hash_old(test_data[j].data(), test_data[j].size(), (char*)&h);
// }
// TIME_MEASURE_FINISH(t_old);
// results[j].t_old = t_old;
// results[j].h_old = h;
// }
//
// for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
// {
// crypto::hash h = h_initial;
// TIME_MEASURE_START(t_new);
// for (size_t i = 0; i < n; ++i)
// {
// *(crypto::hash*)(test_data[j].data()) = h;
// cn_fast_hash(test_data[j].data(), test_data[j].size(), (char*)&h);
// }
// TIME_MEASURE_FINISH(t_new);
// results[j].t_new = t_new;
// ASSERT_EQ(h, results[j].h_old);
// }
//
// std::stringstream ss;
// double diff_round = 0;
// for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
// {
// double diff = ((int64_t)results[j].t_old - (int64_t)results[j].t_new) / (double)n;
//
// ss << std::fixed << std::setprecision(3) << results[j].t_old / (double)n << "/" <<
// std::fixed << std::setprecision(3) << results[j].t_new / (double)n << " ";
//
// results[j].diff += diff;
// diff_round += diff;
// }
//
// diff_sum += diff_round;
//
// LOG_PRINT_L0("cn_fast_hash (old/new) [" << std::setw(2) << k << "]: " << ss.str() << " mcs, diff_round = " << std::fixed << std::setprecision(4) << diff_round <<
// " diff_sum = " << std::fixed << std::setprecision(4) << diff_sum);
// }
//
// std::stringstream ss;
// for (size_t j = 0, sz = results.size(); j < sz; ++j)
// ss << std::fixed << std::setprecision(4) << results[j].diff << " ";
// LOG_PRINT_L0(" " << ss.str());
//
// return true;
//}
//
TEST(crypto, sc_invert_performance)
@ -1279,7 +1279,7 @@ TEST(crypto, neg_identity)
ASSERT_TRUE(validate_key_image(z_ki));
key_image z_neg_ki = z_ki;
((unsigned char*)&z_neg_ki)[31] = 0x80; // set sign bit manually
((unsigned char*)&z_neg_ki)[31] = 0x80; // set sign the bit manually
ASSERT_FALSE(validate_key_image(z_neg_ki)); // negative identity should not be loaded
@ -1287,7 +1287,7 @@ TEST(crypto, neg_identity)
// also do zero-byte pub key / key image checks
public_key zzz_pk;
memset(&zzz_pk, 0, sizeof(public_key));
memset(&zzz_pk, 0, sizeof( public_key));
ASSERT_TRUE(check_key(zzz_pk));
@ -1296,7 +1296,7 @@ TEST(crypto, neg_identity)
ASSERT_FALSE(zzz.is_in_main_subgroup());
key_image zzz_ki;
memset(&zzz_ki, 0, sizeof(key_image));
memset(&zzz_ki, 0, sizeof( key_image));
ASSERT_FALSE(validate_key_image(zzz_ki));
@ -1466,7 +1466,7 @@ TEST(crypto, point_is_zero)
ASSERT_TRUE(p.is_zero());
memset(&p.m_p3, 0, sizeof p.m_p3);
memcpy(&p.m_p3.Y, f_x, sizeof p.m_p3.Y);
memcpy(&p.m_p3.Z, f_x, sizeof p.m_p3.Z);
@ -1489,7 +1489,7 @@ TEST(crypto, point_is_zero)
memcpy(&p.m_p3.Y, f_x, sizeof p.m_p3.Y);
memcpy(&p.m_p3.Z, f_x, sizeof p.m_p3.Z);
memcpy(&p.m_p3.T, fancy_p_plus_1, sizeof p.m_p3.T);
// {0, x, x, !0} is not a valid point (incorrect non-zero T)
// {0, x, x, !0} is not a valid point (incorrect non-zero T)
ASSERT_FALSE(p.is_zero());
@ -1603,7 +1603,7 @@ TEST(crypto, schnorr_sig)
ASSERT_EQ(tmp, ss.c);
ASSERT_FALSE(verify_schnorr_sig<gt_X>(m, A, bad_ss));
// binary serialization
// binary serialization
std::string blob = t_serializable_object_to_blob(ss);
generate_random_bytes(sizeof ss, &ss);
ASSERT_TRUE(t_unserializable_object_from_blob(ss, blob));
@ -1858,7 +1858,7 @@ bool check_generator_precomp(const point_pc_t& generator, const char* generator_
{
B += A;
// restore ge_p3 from ge_precomp using native NaCl functions...
// restore ge_p3 from ge_precomp using native NaCl functions...
point_t restored_pt{};
ge_p1p1 p1p1{};
ge_madd(&p1p1, &random_point.m_p3, &((*generator.m_precomp_data_p)[i][j]));

View file

@ -71,7 +71,7 @@ void run_plain_wallet_api_test()
// LOG_PRINT_L0("Generating wallet...");
// view::open_wallet_request owr = AUTO_VAL_INIT(owr);
// owr.path = "E:\\tmp\\zano_testwallet_745ss65030.zan";
// owr.path = "E:\\tmp\\lethean_testwallet_745ss65030.zan";
// owr.pass = "";
// std::string job_id_str = plain_wallet::async_call("open", 0, epee::serialization::store_t_to_json(owr));
//
@ -96,7 +96,7 @@ void run_plain_wallet_api_test()
//
//
//std::string rsp = plain_wallet::open(std::string("E:\\tmp\\zano_testwallet_745ss65030.zan"), "");
//std::string rsp = plain_wallet::open(std::string("E:\\tmp\\lethean_testwallet_745ss65030.zan"), "");
//LOG_PRINT_L0("RESPONSE:" << ENDL << rsp);
//epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
//epee::serialization::load_t_from_json(ok_response, rsp);
@ -144,7 +144,7 @@ void run_plain_wallet_api_test()
// LOG_PRINT_L0("Creating instance..." << std::hex << hw);
//
// LOG_PRINT_L0("Generating wallet...");
// std::string rsp = plain_wallet::open(hw, std::string("E:\\tmp\\zano_testwallet_74565030.zan"), "");
// std::string rsp = plain_wallet::open(hw, std::string("E:\\tmp\\lethean_testwallet_74565030.zan"), "");
// LOG_PRINT_L0("RESPONSE:" << ENDL << rsp);
// epee::json_rpc::response<plain_wallet::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
// epee::serialization::load_t_from_json(ok_response, rsp);
@ -217,7 +217,7 @@ void run_plain_wallet_api_test()
// LOG_PRINT_L0("Creating instance..." << std::hex << hw);
//
// LOG_PRINT_L0("Generating wallet...");
// std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", "");
// std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\lethean_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", "");
// LOG_PRINT_L0("RESPONSE:" << ENDL << rsp);
// epee::json_rpc::response<plain_wallet::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
// epee::serialization::load_t_from_json(ok_response, rsp);

View file

@ -21,7 +21,6 @@ using namespace epee;
using namespace currency;
namespace ph = boost::placeholders;
#define TESTS_DEFAULT_FEE TX_DEFAULT_FEE
std::string get_random_hex_text(size_t len)
@ -312,7 +311,7 @@ void wait_receive_and_unlock_money(tools::wallet2& w, uint64_t amount_to_wait)
class flow_test_console_cmmands_handler
{
epee::console_handlers_binder m_cmd_binder;
flow_test_context& m_context;
public:
@ -453,7 +452,7 @@ bool transactions_flow_test(
LOG_PRINT_GREEN("Transfers: " << get_incoming_transfers_str(w1), LOG_LEVEL_0);
uint64_t transfer_size = TX_DEFAULT_FEE;//amount_to_transfer / transactions_count;
tools::transfer_container incoming_transfers;
tools::transfer_container incoming_transfers;
size_t prepared_transfers = 0;

View file

@ -444,23 +444,23 @@ namespace
std::string test_keys_addr_str = "ZxDqHy6WnyYY5yQcdApjMb8tVPik5BC3LFdaevfbGq7X1KY5vdsWmUi5UQgse2GBZFbMsb47TFqBmPpdFHDDwDxR2ZuZ6zX4W"; // correct str address depends on CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX value
}
TEST(get_account_address_as_str, works_correctly)
{
currency::account_public_address addr;
ASSERT_TRUE(serialization::parse_binary(test_serialized_keys, addr));
std::string addr_str = currency::get_account_address_as_str(addr);
ASSERT_EQ(addr_str, test_keys_addr_str);
}
//TEST(get_account_address_as_str, works_correctly)
//{
// currency::account_public_address addr;
// ASSERT_TRUE(serialization::parse_binary(test_serialized_keys, addr));
// std::string addr_str = currency::get_account_address_as_str(addr);
// ASSERT_EQ(addr_str, test_keys_addr_str);
//}
TEST(get_account_address_from_str, handles_valid_address)
{
currency::account_public_address addr;
ASSERT_TRUE(currency::get_account_address_from_str(addr, test_keys_addr_str));
std::string blob;
ASSERT_TRUE(serialization::dump_binary(addr, blob));
ASSERT_EQ(blob, test_serialized_keys);
}
//TEST(get_account_address_from_str, handles_valid_address)
//{
// currency::account_public_address addr;
// ASSERT_TRUE(currency::get_account_address_from_str(addr, test_keys_addr_str));
//
// std::string blob;
// ASSERT_TRUE(serialization::dump_binary(addr, blob));
// ASSERT_EQ(blob, test_serialized_keys);
//}
TEST(get_account_address_from_str, fails_on_invalid_address_format)
{
@ -564,7 +564,7 @@ addr_entry_t addr_entries[] =
{
{
// classic normal address
"ZxD5aoLDPTdcaRx4uCpyW4XiLfEXejepAVz8cSY2fwHNEiJNu6NmpBBDLGTJzCsUvn3acCVDVDPMV8yQXdPooAp338Se7AxeH", // address
"iTxtRCUWE11j74KgQDGKRKAjTfWJywnvM1ZRGv9yX9o89N8qGedHKLheKPmtkLpTmpBWGDT3ZuLUmNVvz3LmU5LrA3gGiWL8wW", // address
"a3f208c8f9ba49bab28eed62b35b0f6be0a297bcd85c2faa1eb1820527bcf7e3", // view_pub_key
"9f5e1fa93630d4b281b18bb67a3db79e9622fc703cc3ad4a453a82e0a36d51fa", // spend_pub_key
"", // payment_id_hex
@ -626,8 +626,8 @@ void check_add_entry(const addr_entry_t& ae)
ASSERT_EQ(ae.spend_pub_key, epee::string_tools::pod_to_hex(addr.spend_public_key));
}
TEST(auditable_addresses, basic)
{
//TEST(auditable_addresses, basic)
//{
/*
currency::account_keys keys = AUTO_VAL_INIT(keys);
epee::string_tools::parse_tpod_from_hex_string("248b019d145d485576ecb0367d92b5a12e8aa15084b59ef15014a7a22d1f3b0c", keys.spend_secret_key);
@ -645,7 +645,7 @@ TEST(auditable_addresses, basic)
*/
for (size_t i = 0; i < sizeof addr_entries / sizeof addr_entries[0]; ++i)
check_add_entry(addr_entries[i]);
// for (size_t i = 0; i < sizeof addr_entries / sizeof addr_entries[0]; ++i)
// check_add_entry(addr_entries[i]);
}
//}

View file

@ -132,11 +132,11 @@ TEST(validate_parse_amount_case, validate_parse_amount)
uint64_t res = 0;
bool r = currency::parse_amount(res, "0.0001");
ASSERT_TRUE(r);
ASSERT_EQ(res, 100000000);
ASSERT_EQ(res, 10000);
r = currency::parse_amount(res, "100.0001");
ASSERT_TRUE(r);
ASSERT_EQ(res, 100000100000000);
ASSERT_EQ(res, 10000010000);
r = currency::parse_amount(res, "000.0000");
ASSERT_TRUE(r);
@ -149,11 +149,11 @@ TEST(validate_parse_amount_case, validate_parse_amount)
r = currency::parse_amount(res, " 100.0001 ");
ASSERT_TRUE(r);
ASSERT_EQ(res, 100000100000000);
ASSERT_EQ(res, 10000010000);
r = currency::parse_amount(res, " 100.0000 ");
ASSERT_TRUE(r);
ASSERT_EQ(res, 100000000000000);
ASSERT_EQ(res, 10000000000);
r = currency::parse_amount(res, " 100. 0000 ");
ASSERT_FALSE(r);

2
utils/.gitignore vendored
View file

@ -1 +1 @@
configure_local_paths.cmd
build/extras/win/configure_local_paths.cmd

View file

@ -11,7 +11,7 @@ git pull --ff-only
build_no_before=`cat $version_file_path | grep 'PROJECT_VERSION_BUILD_NO ' | awk {'print $3'}`
../../zano-tools-last-build/connectivity_tool --increment-build-no=$version_file_path
../../lethean-tools-last-build/connectivity_tool --increment-build-no=$version_file_path
build_no_after=`cat $version_file_path | grep 'PROJECT_VERSION_BUILD_NO ' | awk {'print $3'}`

View file

@ -7,12 +7,12 @@ export QT_PLUGIN_PATH=$script_dir/lib
echo $LD_LIBRARY_PATH
echo $QT_PLUGIN_PATH
out_file_name=~/.local/share/applications/Zano.desktop
out_file_name=~/.local/share/applications/Lethean.desktop
call_app()
{
pushd $script_dir
./Zano "$@"
./Lethean "$@"
popd
exit
}
@ -25,20 +25,20 @@ create_desktop_icon()
rm -f $target_file_name
echo [Desktop Entry] | tee -a $target_file_name > /dev/null
echo Version=1.0 | tee -a $target_file_name > /dev/null
echo Name=Zano | tee -a $target_file_name > /dev/null
echo GenericName=Zano | tee -a $target_file_name > /dev/null
echo Name=Lethean | tee -a $target_file_name > /dev/null
echo GenericName=Lethean | tee -a $target_file_name > /dev/null
echo Comment=Privacy blockchain | tee -a $target_file_name > /dev/null
echo Icon=$script_dir/html/files/desktop_linux_icon.png | tee -a $target_file_name > /dev/null
echo Exec=$script_dir/Zano.sh --deeplink-params=%u | tee -a $target_file_name > /dev/null
echo Exec=$script_dir/Lethean.sh --deeplink-params=%u | tee -a $target_file_name > /dev/null
echo Terminal=true | tee -a $target_file_name > /dev/null
echo Type=Application | tee -a $target_file_name > /dev/null
echo "Categories=Qt;Utility;" | tee -a $target_file_name > /dev/null
echo "MimeType=x-scheme-handler/zano;" | tee -a $target_file_name > /dev/null
echo "MimeType=x-scheme-handler/lthn;" | tee -a $target_file_name > /dev/null
}
create_desktop_icon $out_file_name
xdg-mime default Zano.desktop x-scheme-handler/zano
xdg-mime default Lethean.desktop x-scheme-handler/lthn
call_app "$@"

Some files were not shown because too many files have changed in this diff Show more