Compare commits

...
Sign in to create a new pull request.

53 commits
dev ... iTw3

Author SHA1 Message Date
Snider
8d5c87e871
Update Makefile 2024-03-27 13:50:25 +00:00
5da1065df9 cleanup 2024-03-26 21:14:50 +00:00
66e4263136 CI environments -.- 2024-03-26 20:54:23 +00:00
9a08bfce0e install conan 2024-03-26 20:34:17 +00:00
0fb180fa96 path fix 2024-03-26 20:29:58 +00:00
7627ff1bc5 disables failing builds + last win test 2024-03-26 20:24:29 +00:00
435a8f03f7 removes GUI submodule 2024-03-26 20:18:06 +00:00
df4b9440b1 removes Zano GUI 2024-03-26 20:17:07 +00:00
16ef883aa0 installs conan user settings 2024-03-26 18:42:14 +00:00
e4ac49304f install conan if not installed 2024-03-26 18:38:52 +00:00
a20a575647 install conan if not installed 2024-03-26 18:37:55 +00:00
3b8a03dd08 adds gcc 9.4.0 2024-03-26 18:37:44 +00:00
8b4f166926 path fix for build script 2024-03-26 18:35:40 +00:00
4bbf42483f make clean fix 2024-03-26 18:35:17 +00:00
08b9208f56 ci build update 2024-03-26 18:22:52 +00:00
Snider
b400c827cc
Merge pull request #3 from bodane/iTw3
add windows-amd64 profile
2024-03-25 15:36:07 +00:00
darbs@lt.hn
40726e43f1
add windows-amd64 profile 2024-03-26 01:49:46 +11:00
Snider
3efe81cc29
Merge pull request #2 from bodane/iTw3
makefile updates for windows testnet
2024-03-24 18:12:30 +00:00
darbs@lt.hn
6b86f09909
makefile updates for windows testnet 2024-03-25 03:59:37 +11:00
a4463bb093 disables failing ci builds. 2024-03-22 15:52:10 +00:00
cc085dc1c3 ci-linux now uses pre-defined host/target profile 2024-03-22 11:01:17 +00:00
4ef1324e2c ci-linux now uses pre-defined host/target profile 2024-03-22 10:58:03 +00:00
04c8a9b5b6 ci-linux now uses pre-defined host/target profile 2024-03-22 10:55:09 +00:00
76521b0d0d ci-linux now uses pre-defined host/target profile 2024-03-22 10:51:46 +00:00
9c2e8c232a windows testnet build 2024-03-22 09:33:44 +00:00
7cefd8d664 windows testnet build 2024-03-22 09:14:35 +00:00
28302b5941 windows build 2024-03-22 09:09:42 +00:00
3f2337cfb4 macos CMAKE_OSX_SYSROOT: env 2024-03-22 08:51:37 +00:00
Snider
b94860a3c8 macos builds 2024-03-22 01:02:34 +00:00
Snider
016580a889 macos builds 2024-03-22 00:57:03 +00:00
Snider
d5f984a75f macos builds 2024-03-22 00:39:51 +00:00
cc18d11a28 cache test 2024-03-21 20:45:46 +00:00
7c14a9fadf canary builds + requirements.txt 2024-03-21 20:11:51 +00:00
4f4a142c63 adds pip cache 2024-03-21 20:08:27 +00:00
7ea697ac0d moves conan settings into Makefile 2024-03-21 20:04:59 +00:00
70c79745f1 ci host/target cache keys 2024-03-21 19:28:22 +00:00
2503764329 ci + upstream tx patch 2024-03-21 19:20:27 +00:00
c9a86d9aff adds ci make target 2024-03-21 19:14:23 +00:00
5f8b9a446e rename simplewallet to lethean-wallet-cli 2024-03-21 19:13:31 +00:00
ba1311e15c cmake JetBrains settings 2024-03-21 18:16:01 +00:00
39e7eafe5e gha conan cache 2024-03-21 17:37:35 +00:00
2a20bef11b gha conan cache save always 2024-03-21 17:27:48 +00:00
0778c03e82 gha runner git clone recursive 2024-03-21 17:15:40 +00:00
53f6798a6a gha runner base dependancy update 2024-03-21 17:03:22 +00:00
600b50193d gha fail-fast: false 2024-03-21 16:50:04 +00:00
1bb64edc57 workaround for conan semver bug 2024-03-21 16:45:36 +00:00
a18535696e workaround for conan semver bug 2024-03-21 16:33:20 +00:00
a7ecf70452 Adds Conan to auto find or compile needed libs. 2024-03-21 16:23:28 +00:00
c994eac501 gitmodule fix 2024-03-21 16:21:30 +00:00
47d851f11d clearing .idea files 2024-03-21 16:21:10 +00:00
dfcc5058ac compile fixes 2024-03-21 16:19:19 +00:00
36008ecb18 Merge branch 'LetheanMovement-main' into iTw3 2024-03-21 13:16:56 +00:00
62a4961549 lethean updates 2024-03-21 13:16:33 +00:00
155 changed files with 3391 additions and 2224 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

6
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

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

@ -0,0 +1,247 @@
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:
CMAKE_OSX_SYSROOT: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.2.1.sdk"
CCACHE_SETTINGS: |
ccache --max-size=150M
ccache --set-config=compression=true
jobs:
compile:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest]
include:
- os: ubuntu-latest
target: linux-amd64
net: testnet
# - os: macos-11
# target: macos-amd64
# net: testnet
# - os: macos-12
# target: macos-amd64
# net: testnet
# - os: windows-2019
# target: windows-amd64
# net: testnet
env:
CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
CONAN_HOME: "${{ github.workspace }}/build/"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
if: ${{ matrix.os == 'windows-2019' }}
name: setup msvc vcvars
- name: install dependencies
run: |
sudo apt update
sudo apt-get install -y git ccache
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Install autotools on macOS
run: brew install automake
if: ${{ matrix.os == 'macos-13' }}
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{ runner.os }}-${{ matrix.target }}-build-testnet-cli
- name: Cache Conan
id: github-cache-conan
uses: actions/cache@v4
env:
cache-name: cache-conan-modules
with:
save-always: true
path: ${{ github.workspace }}/build/p
key: host-${{ runner.os }}-target-${{ matrix.target }}-${{ hashFiles('contrib/cmake/conanfile.py') }}
- name: Install Conan
run: pip install conan pytest && conan --version
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Call make release-testnet
run: |
make ci-${{ matrix.target }}-testnet
- name: Release Tag
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: '*ethean-${{ matrix.target }}-cli.*'
- name: Release Branch
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/heads/iTw3')
with:
tag_name: canary
prerelease: true
files: '*ethean-${{ matrix.target }}-cli.*'
# 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 }}/testnet-lethean-linux-cli-*.tar.bz2
# - name: Release Tag
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# files: '*ethean-${{ matrix.target }}-cli.*'
# - name: Release Branch
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/heads/iTw3')
# with:
# tag_name: canary
# prerelease: true
# files: '*ethean-${{ matrix.target }}-cli.*'
# 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 ccache -y
# choco install zip -y
# - name: Cache Conan
# id: github-cache-conan
# uses: actions/cache@v4
# env:
# cache-name: cache-conan-modules
# with:
# save-always: true
# path: ${{ github.workspace }}\build\p
# key: host-${{ runner.os }}-target-windows-${{ hashFiles('contrib/cmake/conanfile.py') }}
# - name: install msvc toolset
# uses: ilammy/msvc-dev-cmd@v1
#
# - name: Set up Visual Studio shell
# uses: egor-tensin/vs-shell@v2
# with:
# arch: x64
# - name: build server
# env:
# CCACHE_TEMPDIR: ${{ github.workspace }}/ccache
# run: |
# ${{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 }}

1
.gitignore vendored
View file

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

8
.gitmodules vendored
View file

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

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" ENABLED="true" GENERATION_DIR="build/debug" CONFIG_NAME="Debug" GENERATION_OPTIONS="-G &quot;Unix Makefiles&quot; -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=&quot;contrib/cmake/conan_provider.cmake&quot;" />
<configuration PROFILE_NAME="Release" ENABLED="true" GENERATION_DIR="build/release" CONFIG_NAME="Release" GENERATION_OPTIONS="-G &quot;Unix Makefiles&quot; -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=&quot;contrib/cmake/conan_provider.cmake&quot;" />
</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>

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>

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) 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}") option (USE_CCACHE "Use ccache if a usable instance is found" ON)
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}") if (USE_CCACHE)
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}") 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") if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
add_definitions(-DMOBILE_WALLET_BUILD) add_definitions(-DMOBILE_WALLET_BUILD)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" ) if(CMAKE_SYSTEM_NAME STREQUAL "iOS" )
add_definitions(-DIOS_BUILD) add_definitions(-DIOS_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode") 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() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android") if(CMAKE_SYSTEM_NAME STREQUAL "Android")
add_definitions(-DANDROID_BUILD) add_definitions(-DANDROID_BUILD)
message("Android sdk prefix: ${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}") message("Android sdk prefix: ${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}")
message("Android CMAKE_CXX_COMPILER prefix: ${CMAKE_CXX_COMPILER}") message("Android CMAKE_CXX_COMPILER prefix: ${CMAKE_CXX_COMPILER}")
message("Android ANDROID_LD: ${ANDROID_LD}") message("Android ANDROID_LD: ${ANDROID_LD}")
endif() endif()
endif() endif()
@ -49,16 +79,16 @@ if (UNIX AND NOT APPLE)
endif() endif()
else() else()
# multi configurations for MSVC and XCode # multi configurations for MSVC and XCode
if(CMAKE_SYSTEM_NAME STREQUAL "iOS") if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_CONFIGURATION_TYPES "Release") set(CMAKE_CONFIGURATION_TYPES "Release")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(CMAKE_CONFIGURATION_TYPES "Debug;Release") set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
else() else()
set(CMAKE_CONFIGURATION_TYPES "Debug;Release") set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
endif() endif()
endif() endif()
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}") message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}")
enable_testing() enable_testing()
set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically
@ -66,12 +96,13 @@ find_package(OpenSSL REQUIRED)
if(APPLE) if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version")
endif() endif()
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers") 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(DISABLE_TOR FALSE CACHE BOOL "Disable TOR library(and related tor-connect submodule)")
set(TESTNET FALSE CACHE BOOL "Compile for testnet") 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") 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") 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) add_definitions(-DSTATICLIB)
if(TESTNET) if(TESTNET)
message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!") message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!")
add_definitions(-DTESTNET) 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() endif()
if(CAKEWALLET) if(CAKEWALLET)
message("NOTICE: Building libraries for CAKEWALLET") message("NOTICE: Building libraries for CAKEWALLET")
add_definitions(-DCAKEWALLET) add_definitions(-DCAKEWALLET)
endif() endif()
set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically set(OPENSSL_USE_STATIC_LIBS TRUE) # link statically
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
if(DISABLE_TOR) if(DISABLE_TOR)
message("NOTICE: Building with disabled TOR support!") message("NOTICE: Building with disabled TOR support!")
add_definitions(-DDISABLE_TOR) add_definitions(-DDISABLE_TOR)
endif() 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") set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
# Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail # 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}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
if(STATIC) if(STATIC)
if(APPLE) 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() else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif() endif()
@ -214,12 +258,12 @@ if(MSVC)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
endif() endif()
if(STATIC) if(STATIC)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON) # set(Boost_USE_STATIC_RUNTIME ON)
endif() endif()
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
if(CMAKE_SYSTEM_NAME STREQUAL "iOS") if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.00) set(CMAKE_OSX_DEPLOYMENT_TARGET 12.00)
set(Boost_LIBRARIES "libboost.a") set(Boost_LIBRARIES "libboost.a")
@ -250,8 +294,8 @@ if(MINGW)
elseif(NOT MSVC) elseif(NOT MSVC)
if(NOT APPLE) if(NOT APPLE)
set(Boost_LIBRARIES "${Boost_LIBRARIES};") set(Boost_LIBRARIES "${Boost_LIBRARIES};")
if(STATIC) if(STATIC)
message("NOTICE: Including static ICU libraries") message("NOTICE: Including static ICU libraries")
set(Boost_LIBRARIES "${Boost_LIBRARIES};icui18n.a;icuuc.a;icudata.a;dl") set(Boost_LIBRARIES "${Boost_LIBRARIES};icui18n.a;icuuc.a;icudata.a;dl")
endif() endif()
endif() endif()
@ -259,7 +303,13 @@ endif()
if(BUILD_GUI) if(BUILD_GUI)
cmake_minimum_required(VERSION 3.1) 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() endif()
set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version") set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
@ -288,13 +338,13 @@ else()
endif() endif()
endif() endif()
set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests") set(BUILD_TESTS FALSE CACHE BOOL "Build Lethean tests")
set(DISABLE_MDBX FALSE CACHE BOOL "Exclude mdbx from build(need for a first time)") set(DISABLE_MDBX FALSE CACHE BOOL "Exclude mdbx from build(need for a first time)")
if(NOT DISABLE_MDBX) if(NOT DISABLE_MDBX)
add_definitions(-DENABLED_ENGINE_MDBX) add_definitions(-DENABLED_ENGINE_MDBX)
endif() endif()
add_subdirectory(contrib) add_subdirectory(contrib)
add_subdirectory(src) 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.

114
Makefile
View file

@ -11,12 +11,13 @@ endif
cmake = cmake $(cmake_gen) 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_release = $(cmake) -D CMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=contrib/cmake/conan_provider.cmake
cmake_gui = -D BUILD_GUI=ON cmake_testnet = -D TESTNET=ON -D BUILD_TESTS=OFF
cmake_static = -D STATIC=ON cmake_static = -D STATIC=ON
cmake_tests = -D BUILD_TESTS=ON cmake_tests = -D BUILD_TESTS=ON -D TESTNET=ON
# Helper macro # Helper macro
define CMAKE define CMAKE
@ -26,39 +27,98 @@ endef
build = build build = build
dir_debug = $(build)/debug dir_debug = $(build)/debug
dir_release = $(build)/release dir_release = $(build)/release
current_dir := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
export CONAN_HOME = $(current_dir)$(build)
all: release conan_profile_linux = $(CONAN_HOME)/profiles/linux-amd64
conan_profile_windows = $(CONAN_HOME)/profiles/windows-amd64
conan_toolchain = -DCMAKE_TOOLCHAIN_FILE=./build/release/conan/build/Release/generators/conan_toolchain.cmake
release: all: help
release: ## Build release non-static binaries
$(eval command += $(cmake_release)) $(eval command += $(cmake_release))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE) $(call CMAKE,$(dir_release),$(command)) && $(MAKE)
release-testnet: ## Build testnet non-static binaries
$(eval command += $(cmake_release) $(cmake_testnet))
$(call CMAKE,$(dir_release),$(command)) && "$(MAKE)"
debug: debug:
$(eval command += $(cmake_debug)) $(eval command += $(cmake_debug))
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE) $(call CMAKE,$(dir_debug),$(command)) && $(MAKE)
debug-testnet:
$(eval command += $(cmake_debug) $(cmake_testnet))
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE)
static: static-release static: static-release
static-release: static-release: ## Build release static binaries
$(eval command += $(cmake_release) $(cmake_static)) $(eval command += $(cmake_release) $(cmake_static))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE) $(call CMAKE,$(dir_release),$(command)) && $(MAKE)
# static-release-testnet: ## Build testnet release static binaries
# GUI $(eval command += $(cmake_release) $(cmake_static) $(cmake_testnet))
#
gui: gui-release
gui-release:
$(eval command += $(cmake_release) $(cmake_gui))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE) $(call CMAKE,$(dir_release),$(command)) && $(MAKE)
gui-debug: #
$(eval command += $(cmake_debug) $(cmake_gui)) # CI
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE) #
ci-package-linux:
@rm -fr lethean && mkdir -p lethean
@cp -r build/release/src/letheand lethean/letheand
@cp -r build/release/src/lethean-wallet lethean/lethean-wallet
@chmod +x lethean/lethean*
ci-package-windows:
@rm -fr lethean && mkdir -p lethean
@cp -r build\\release\\src\\letheand.exe lethean\\letheand.exe
@cp -r build\\release\\src\\lethean-wallet.exe lethean\\lethean-wallet.exe
ci-windows-amd64-release: static-release ci-package-windows ## Build lethean-windows-amd64-cli.tar.bz2
@tar -cjvf lethean-windows-amd64-cli.tar.bz2 lethean/
ci-linux-amd64-release: static-release ci-package-linux ## Build lethean-linux-amd64-cli.tar.bz2
@tar -cjvf lethean-linux-amd64-cli.tar.bz2 lethean/
ci-macos-amd64-release: static-release ci-package-linux ## Build lethean-macos-amd64-cli.tar.bz2
@tar -cjvf lethean-macos-amd64-cli.tar.bz2 lethean/
ci-macos-arm64-release: static-release ci-package-linux ## Build lethean-macos-arm64-cli.tar.bz2
@tar -cjvf lethean-macos-arm64-cli.tar.bz2 lethean/
ci-linux-amd64-testnet: ## Build testnet-lethean-linux-amd64-cli.tar.bz2
conan install ./contrib/cmake -of=./build/release/conan --profile:build=$(conan_profile_linux) --profile:host=$(conan_profile_linux) --build=missing
(cd build/release && cmake ../../ -DCMAKE_BUILD_TYPE=Release $(conan_toolchain) $(cmake_static) $(cmake_testnet))
(cd build/release && cmake --build .)
@rm -fr lethean && mkdir -p lethean
@cp -r build/release/src/letheand lethean/letheand
@cp -r build/release/src/lethean-wallet lethean/lethean-wallet
@chmod +x lethean/lethean*
@tar -cjvf testnet-lethean-linux-amd64-cli.tar.bz2 lethean/
ci-windows-amd64-testnet: ## Build testnet-lethean-windows-amd64-cli.tar.bz2
conan install ./contrib/cmake -of=./build/release/conan --profile:build=$(conan_profile_windows) --profile:host=$(conan_profile_windows) --build=missing
(cd build/release && cmake ../../ -DCMAKE_BUILD_TYPE=Release $(conan_toolchain) $(cmake_static) $(cmake_testnet))
(cd build/release && cmake --build .)
@rm -fr lethean && mkdir -p lethean
@cp -r build/release/src/letheand lethean/letheand
@cp -r build/release/src/lethean-wallet lethean/lethean-wallet
@chmod +x lethean/lethean*
@tar -cjvf testnet-lethean-windows-amd64-cli.tar.bz2 lethean/
ci-macos-amd64-testnet: static-release-testnet ci-package-linux ## Build testnet-lethean-macos-amd64-cli.tar.bz2
@tar -cjvf testnet-lethean-macos-amd64-cli.tar.bz2 lethean/
ci-macos-arm64-testnet: static-release-testnet ci-package-linux ## Build testnet-lethean-macos-arm64-cli.tar.bz2
@tar -cjvf testnet-lethean-macos-arm64-cli.tar.bz2 lethean/
conan:
@conan config install contrib/cmake/settings_user.yml
gui-static: gui-release-static
gui-release-static:
$(eval command += $(cmake_release) $(cmake_gui) $(cmake_static))
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
# #
# Tests # Tests
@ -74,9 +134,17 @@ test-debug:
$(call CMAKE,$(dir_debug),$(command)) && $(MAKE) && $(MAKE) test $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) && $(MAKE) test
clean: clean:
rm -rf build rm -rf ./build/release/ ./build/debug/
macos-gui:
bash ./utils/build/testnet_mac_osx_gui.sh
tags: tags:
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest 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 help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m make %-30s\033[0m %s\n", $$1, $$2}'
.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 ci-testnet ci-release
.PHONY: ci-package-linux ci-linux-amd64-release ci-macos-amd64-release ci-macos-arm64-release ci-linux-amd64-testnet ci-macos-amd64-testnet ci-macos-arm64-testnet
.PHONY: ci-package-windows ci-windows-amd64-release ci-windows-amd64-testnet

View file

@ -1,10 +1,19 @@
[![Coverity Scan](https://scan.coverity.com/projects/18767/badge.svg)](https://scan.coverity.com/projects/zanoproject) # Addresses
[![Discord](https://img.shields.io/discord/538361472691077130?label=discord&logo=discord)](https://discord.gg/wE3rmYY)
- `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 ## Cloning
Be sure to clone the repository properly:\ 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 # Building
-------- --------
@ -24,7 +33,7 @@ Be sure to clone the repository properly:\
Note:\ Note:\
[*server version*] denotes steps required for building command-line tools (daemon, simplewallet, etc.).\ [*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 /> <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 .. BOOST_ROOT=$HOME/boost_1_70_0 OPENSSL_ROOT_DIR=$HOME/openssl cmake ..
make -j1 daemon simplewallet make -j1 daemon simplewallet
2. If you set the variables in step 6: cd lthn/ && make -j1
or
cd zano && mkdir build && cd build
cd lthn && mkdir build && cd build
cmake .. cmake ..
make -j1 daemon simplewallet make -j1 daemon simplewallet
@ -125,7 +135,7 @@ For instance, by adding the following lines to `~/.bashrc`
1. Build GUI: 1. Build GUI:
cd zano cd lthn
utils/build_script_linux.sh utils/build_script_linux.sh
Look for the binaries in `build` folder Look for the binaries in `build` folder
@ -133,19 +143,32 @@ For instance, by adding the following lines to `~/.bashrc`
<br /> <br />
### Windows ### Windows
Recommended OS version: Windows 7 x64, Windows 11 x64. Recommended OS versions: Windows 7+ x64, Windows 11 x64.
1. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
2. Edit paths in `utils/configure_local_paths.cmd`. 1. Install [Chocolatey](https://chocolatey.org/install)
3. Run one of `utils/configure_win64_msvsNNNN_gui.cmd` according to your MSVC version. 2. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
4. Go to the build folder and open generated Zano.sln in MSVC.
5. Build. _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: 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`). 6. Copy Lethean.exe to a folder (e.g. `depoy`).
7. Run `PATH_TO_QT\bin\windeployqt.exe deploy\Zano.exe`. 7. Run `PATH_TO_QT\bin\windeployqt.exe deploy\Lethean.exe`.
8. Copy folder `\src\gui\qt-daemon\html` to `deploy\html`. 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 /> <br />
@ -160,12 +183,12 @@ To build GUI application:
1. Create self-signing certificate via Keychain Access:\ 1. Create self-signing certificate via Keychain Access:\
a. Run Keychain Access.\ a. Run Keychain Access.\
b. Choose Keychain Access > Certificate Assistant > Create a Certificate.\ 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.\ d. Choose “Code Signing” in “Certificate Type” field.\
e. Press “Create”, then “Done”.\ e. Press “Create”, then “Done”.\
f. Make sure the certificate was added to keychain "System". If not—move it to "System".\ 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".\ 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` 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` 3. The application should be here: `/buid_mac_osx_64/release/src`

View file

@ -0,0 +1,8 @@
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux

View file

@ -0,0 +1,8 @@
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.version=193
os=Windows

5
build/settings_user.yml Normal file
View file

@ -0,0 +1,5 @@
compiler:
gcc:
version: ["9.4.0","11.4.0"]
apple-clang:
version: ["13.0.0.13000029", "14.0.0.14000029", "15.0.0.15000040", "15.0.0.15000309"]

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") message("excluded upnp support for IOS build")
return() return()
endif() 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) add_subdirectory(miniupnp/miniupnpc)
set_property(TARGET libminiupnpc-static PROPERTY FOLDER "contrib") 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 zlibstatic PROPERTY FOLDER "contrib")
set_property(TARGET mdbx PROPERTY FOLDER "contrib") set_property(TARGET mdbx PROPERTY FOLDER "contrib")
set_property(TARGET lmdb 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") set_property(TARGET tor-connect PROPERTY FOLDER "contrib")
endif() 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) if(MSVC)
#set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused") #set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused")
@ -33,9 +52,9 @@ endif()
if(MSVC) 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") set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4267 /wd4267")
else() 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 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-discarded-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() 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

@ -0,0 +1,631 @@
# This file is managed by Conan, contents will be overwritten.
# To keep your changes, remove these comment lines, but the plugin won't be able to modify your requirements
set(CONAN_MINIMUM_VERSION 2.0.5)
function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION)
# it could be cross compilation
message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}")
if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(${OS} Macos PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(${OS} Neutrino PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} cygwin PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} msys2 PARENT_SCOPE)
else()
set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
if(DEFINED ANDROID_PLATFORM)
string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM})
elseif(DEFINED CMAKE_SYSTEM_VERSION)
set(_OS_API_LEVEL ${CMAKE_SYSTEM_VERSION})
endif()
message(STATUS "CMake-Conan: android api level=${_OS_API_LEVEL}")
set(${OS_API_LEVEL} ${_OS_API_LEVEL} PARENT_SCOPE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS")
# CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja
# generators, but just has the original input string for Xcode.
if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT})
set(_OS_SDK ${CMAKE_OSX_SYSROOT})
else()
if(CMAKE_OSX_SYSROOT MATCHES Simulator)
set(apple_platform_suffix simulator)
else()
set(apple_platform_suffix os)
endif()
if(CMAKE_OSX_SYSROOT MATCHES AppleTV)
set(_OS_SDK "appletv${apple_platform_suffix}")
elseif(CMAKE_OSX_SYSROOT MATCHES iPhone)
set(_OS_SDK "iphone${apple_platform_suffix}")
elseif(CMAKE_OSX_SYSROOT MATCHES Watch)
set(_OS_SDK "watch${apple_platform_suffix}")
endif()
endif()
if(DEFINED _OS_SDK)
message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}")
set(${OS_SDK} ${_OS_SDK} PARENT_SCOPE)
endif()
if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(${OS_VERSION} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE)
endif()
endif()
endif()
endfunction()
function(detect_arch ARCH)
# CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one.
# Therefore this code only finds one. If the recipes support multiple architectures, the
# build will work. Otherwise, there will be a linker error for the missing architecture(s).
if(DEFINED CMAKE_OSX_ARCHITECTURES)
string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}")
list(LENGTH apple_arch_list apple_arch_count)
if(apple_arch_count GREATER 1)
message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.")
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
set(host_arch ${CMAKE_OSX_ARCHITECTURES})
elseif(MSVC)
set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})
else()
set(host_arch ${CMAKE_SYSTEM_PROCESSOR})
endif()
if(host_arch MATCHES "aarch64|arm64|ARM64")
set(_ARCH armv8)
elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7")
set(_ARCH armv7)
elseif(host_arch MATCHES armv7s)
set(_ARCH armv7s)
elseif(host_arch MATCHES "i686|i386|X86")
set(_ARCH x86)
elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64")
set(_ARCH x86_64)
endif()
message(STATUS "CMake-Conan: cmake_system_processor=${_ARCH}")
set(${ARCH} ${_ARCH} PARENT_SCOPE)
endfunction()
function(detect_cxx_standard CXX_STANDARD)
set(${CXX_STANDARD} ${CMAKE_CXX_STANDARD} PARENT_SCOPE)
if(CMAKE_CXX_EXTENSIONS)
set(${CXX_STANDARD} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE)
endif()
endfunction()
macro(detect_gnu_libstdcxx)
# _CONAN_IS_GNU_LIBSTDCXX true if GNU libstdc++
check_cxx_source_compiles("
#include <cstddef>
#if !defined(__GLIBCXX__) && !defined(__GLIBCPP__)
static_assert(false);
#endif
int main(){}" _CONAN_IS_GNU_LIBSTDCXX)
# _CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI true if C++11 ABI
check_cxx_source_compiles("
#include <string>
static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\");
int main () {}" _CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI)
set(_CONAN_GNU_LIBSTDCXX_SUFFIX "")
if(_CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI)
set(_CONAN_GNU_LIBSTDCXX_SUFFIX "11")
endif()
unset (_CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI)
endmacro()
macro(detect_libcxx)
# _CONAN_IS_LIBCXX true if LLVM libc++
check_cxx_source_compiles("
#include <cstddef>
#if !defined(_LIBCPP_VERSION)
static_assert(false);
#endif
int main(){}" _CONAN_IS_LIBCXX)
endmacro()
function(detect_lib_cxx LIB_CXX)
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}")
set(${LIB_CXX} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE)
return()
endif()
include(CheckCXXSourceCompiles)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
detect_gnu_libstdcxx()
set(${LIB_CXX} "libstdc++${_CONAN_GNU_LIBSTDCXX_SUFFIX}" PARENT_SCOPE)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
set(${LIB_CXX} "libc++" PARENT_SCOPE)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
# Check for libc++
detect_libcxx()
if(_CONAN_IS_LIBCXX)
set(${LIB_CXX} "libc++" PARENT_SCOPE)
return()
endif()
# Check for libstdc++
detect_gnu_libstdcxx()
if(_CONAN_IS_GNU_LIBSTDCXX)
set(${LIB_CXX} "libstdc++${_CONAN_GNU_LIBSTDCXX_SUFFIX}" PARENT_SCOPE)
return()
endif()
# TODO: it would be an error if we reach this point
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# Do nothing - compiler.runtime and compiler.runtime_type
# should be handled separately: https://github.com/conan-io/cmake-conan/pull/516
return()
else()
# TODO: unable to determine, ask user to provide a full profile file instead
endif()
endfunction()
function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUNTIME_TYPE)
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(_COMPILER ${CMAKE_CXX_COMPILER_ID})
set(_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
else()
if(NOT DEFINED CMAKE_C_COMPILER_ID)
message(FATAL_ERROR "C or C++ compiler not defined")
endif()
set(_COMPILER ${CMAKE_C_COMPILER_ID})
set(_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION})
endif()
message(STATUS "CMake-Conan: CMake compiler=${_COMPILER}")
message(STATUS "CMake-Conan: CMake compiler version=${_COMPILER_VERSION}")
if(_COMPILER MATCHES MSVC)
set(_COMPILER "msvc")
string(SUBSTRING ${MSVC_VERSION} 0 3 _COMPILER_VERSION)
# Configure compiler.runtime and compiler.runtime_type settings for MSVC
if(CMAKE_MSVC_RUNTIME_LIBRARY)
set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY})
else()
set(_msvc_runtime_library MultiThreaded$<$<CONFIG:Debug>:Debug>DLL) # default value documented by CMake
endif()
set(_KNOWN_MSVC_RUNTIME_VALUES "")
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL)
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL)
list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$<CONFIG:Debug>:Debug> MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
# only accept the 6 possible values, otherwise we don't don't know to map this
if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES)
message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings")
endif()
# Runtime is "dynamic" in all cases if it ends in DLL
if(_msvc_runtime_library MATCHES ".*DLL$")
set(_COMPILER_RUNTIME "dynamic")
else()
set(_COMPILER_RUNTIME "static")
endif()
message(STATUS "CMake-Conan: CMake compiler.runtime=${_COMPILER_RUNTIME}")
# Only define compiler.runtime_type when explicitly requested
# If a generator expression is used, let Conan handle it conditional on build_type
if(NOT _msvc_runtime_library MATCHES "<CONFIG:Debug>:Debug>")
if(_msvc_runtime_library MATCHES "Debug")
set(_COMPILER_RUNTIME_TYPE "Debug")
else()
set(_COMPILER_RUNTIME_TYPE "Release")
endif()
message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}")
endif()
unset(_KNOWN_MSVC_RUNTIME_VALUES)
elseif(_COMPILER MATCHES AppleClang)
set(_COMPILER "apple-clang")
string(REPLACE "src" ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
elseif(_COMPILER MATCHES Clang)
set(_COMPILER "clang")
string(REPLACE "src" ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
elseif(_COMPILER MATCHES GNU)
set(_COMPILER "gcc")
string(REPLACE "src" ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
endif()
message(STATUS "CMake-Conan: [settings] compiler=${_COMPILER}")
message(STATUS "CMake-Conan: [settings] compiler.version=${_COMPILER_VERSION}")
if (_COMPILER_RUNTIME)
message(STATUS "CMake-Conan: [settings] compiler.runtime=${_COMPILER_RUNTIME}")
endif()
if (_COMPILER_RUNTIME_TYPE)
message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}")
endif()
set(${COMPILER} ${_COMPILER} PARENT_SCOPE)
set(${COMPILER_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
set(${COMPILER_RUNTIME} ${_COMPILER_RUNTIME} PARENT_SCOPE)
set(${COMPILER_RUNTIME_TYPE} ${_COMPILER_RUNTIME_TYPE} PARENT_SCOPE)
endfunction()
function(detect_build_type BUILD_TYPE)
get_property(_MULTICONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _MULTICONFIG_GENERATOR)
# Only set when we know we are in a single-configuration generator
# Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined
set(${BUILD_TYPE} ${CMAKE_BUILD_TYPE} PARENT_SCOPE)
endif()
endfunction()
macro(set_conan_compiler_if_appleclang lang command output_variable)
if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang")
execute_process(COMMAND xcrun --find ${command}
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE)
cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path)
cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path)
if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}")
set(${output_variable} "")
endif()
unset(_xcrun_out)
unset(_xcrun_toolchain_path)
unset(_compiler_parent_path)
endif()
endmacro()
macro(append_compiler_executables_configuration)
set(_conan_c_compiler "")
set(_conan_cpp_compiler "")
if(CMAKE_C_COMPILER)
set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\",")
set_conan_compiler_if_appleclang(C cc _conan_c_compiler)
else()
message(WARNING "CMake-Conan: The C compiler is not defined. "
"Please define CMAKE_C_COMPILER or enable the C language.")
endif()
if(CMAKE_CXX_COMPILER)
set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"")
set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler)
else()
message(WARNING "CMake-Conan: The C++ compiler is not defined. "
"Please define CMAKE_CXX_COMPILER or enable the C++ language.")
endif()
if(NOT "x${_conan_c_compiler}${_conan_cpp_compiler}" STREQUAL "x")
string(APPEND PROFILE "tools.build:compiler_executables={${_conan_c_compiler}${_conan_cpp_compiler}}\n")
endif()
unset(_conan_c_compiler)
unset(_conan_cpp_compiler)
endmacro()
function(detect_host_profile output_file)
detect_os(MYOS MYOS_API_LEVEL MYOS_SDK MYOS_SUBSYSTEM MYOS_VERSION)
detect_arch(MYARCH)
detect_compiler(MYCOMPILER MYCOMPILER_VERSION MYCOMPILER_RUNTIME MYCOMPILER_RUNTIME_TYPE)
detect_cxx_standard(MYCXX_STANDARD)
detect_lib_cxx(MYLIB_CXX)
detect_build_type(MYBUILD_TYPE)
set(PROFILE "")
string(APPEND PROFILE "[settings]\n")
if(MYARCH)
string(APPEND PROFILE arch=${MYARCH} "\n")
endif()
if(MYOS)
string(APPEND PROFILE os=${MYOS} "\n")
endif()
if(MYOS_API_LEVEL)
string(APPEND PROFILE os.api_level=${MYOS_API_LEVEL} "\n")
endif()
if(MYOS_VERSION)
string(APPEND PROFILE os.version=${MYOS_VERSION} "\n")
endif()
if(MYOS_SDK)
string(APPEND PROFILE os.sdk=${MYOS_SDK} "\n")
endif()
if(MYOS_SUBSYSTEM)
string(APPEND PROFILE os.subsystem=${MYOS_SUBSYSTEM} "\n")
endif()
if(MYCOMPILER)
string(APPEND PROFILE compiler=${MYCOMPILER} "\n")
endif()
if(MYCOMPILER_VERSION)
string(APPEND PROFILE compiler.version=${MYCOMPILER_VERSION} "\n")
endif()
if(MYCOMPILER_RUNTIME)
string(APPEND PROFILE compiler.runtime=${MYCOMPILER_RUNTIME} "\n")
endif()
if(MYCOMPILER_RUNTIME_TYPE)
string(APPEND PROFILE compiler.runtime_type=${MYCOMPILER_RUNTIME_TYPE} "\n")
endif()
if(MYCXX_STANDARD)
string(APPEND PROFILE compiler.cppstd=${MYCXX_STANDARD} "\n")
endif()
if(MYLIB_CXX)
string(APPEND PROFILE compiler.libcxx=${MYLIB_CXX} "\n")
endif()
if(MYBUILD_TYPE)
string(APPEND PROFILE "build_type=${MYBUILD_TYPE}\n")
endif()
if(NOT DEFINED output_file)
set(_FN "${CMAKE_BINARY_DIR}/profile")
else()
set(_FN ${output_file})
endif()
string(APPEND PROFILE "[conf]\n")
string(APPEND PROFILE "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n")
# propagate compilers via profile
append_compiler_executables_configuration()
if(MYOS STREQUAL "Android")
string(APPEND PROFILE "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n")
endif()
message(STATUS "CMake-Conan: Creating profile ${_FN}")
file(WRITE ${_FN} ${PROFILE})
message(STATUS "CMake-Conan: Profile: \n${PROFILE}")
endfunction()
function(conan_profile_detect_default)
message(STATUS "CMake-Conan: Checking if a default profile exists")
execute_process(COMMAND ${CONAN_COMMAND} profile path default
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_stdout
ERROR_VARIABLE conan_stderr
ECHO_ERROR_VARIABLE # show the text output regardless
ECHO_OUTPUT_VARIABLE
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(NOT ${return_code} EQUAL "0")
message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.")
execute_process(COMMAND ${CONAN_COMMAND} profile detect
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_stdout
ERROR_VARIABLE conan_stderr
ECHO_ERROR_VARIABLE # show the text output regardless
ECHO_OUTPUT_VARIABLE
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
endfunction()
function(conan_install)
cmake_parse_arguments(ARGS CONAN_ARGS ${ARGN})
set(CONAN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/conan)
# Invoke "conan install" with the provided arguments
set(CONAN_ARGS ${CONAN_ARGS} -of=${CONAN_OUTPUT_FOLDER})
message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${CONAN_ARGS} ${ARGN}")
# In case there was not a valid cmake executable in the PATH, we inject the
# same we used to invoke the provider to the PATH
if(DEFINED PATH_TO_CMAKE_BIN)
set(_OLD_PATH $ENV{PATH})
set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}")
endif()
execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR}/contrib/cmake ${CONAN_ARGS} ${ARGN} --format=json
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_stdout
ERROR_VARIABLE conan_stderr
ECHO_ERROR_VARIABLE # show the text output regardless
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(DEFINED PATH_TO_CMAKE_BIN)
set(ENV{PATH} "${_OLD_PATH}")
endif()
if(NOT "${return_code}" STREQUAL "0")
message(FATAL_ERROR "Conan install failed='${return_code}'")
endif()
# the files are generated in a folder that depends on the layout used, if
# one is specified, but we don't know a priori where this is.
# TODO: this can be made more robust if Conan can provide this in the json output
string(JSON CONAN_GENERATORS_FOLDER GET ${conan_stdout} graph nodes 0 generators_folder)
cmake_path(CONVERT ${CONAN_GENERATORS_FOLDER} TO_CMAKE_PATH_LIST CONAN_GENERATORS_FOLDER)
# message("conan stdout: ${conan_stdout}")
message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${CONAN_GENERATORS_FOLDER}")
set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${CONAN_GENERATORS_FOLDER}")
# reconfigure on conanfile changes
string(JSON CONANFILE GET ${conan_stdout} graph nodes 0 label)
message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/contrib/cmake/${CONANFILE}")
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/contrib/cmake/${CONANFILE}")
# success
set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE)
endfunction()
function(conan_get_version conan_command conan_current_version)
execute_process(
COMMAND ${conan_command} --version
OUTPUT_VARIABLE conan_output
RESULT_VARIABLE conan_result
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(conan_result)
message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan")
endif()
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output})
set(${conan_current_version} ${conan_version} PARENT_SCOPE)
endfunction()
function(conan_version_check)
set(options )
set(oneValueArgs MINIMUM CURRENT)
set(multiValueArgs )
cmake_parse_arguments(CONAN_VERSION_CHECK
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT CONAN_VERSION_CHECK_MINIMUM)
message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!")
endif()
if(NOT CONAN_VERSION_CHECK_CURRENT)
message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!")
endif()
if(CONAN_VERSION_CHECK_CURRENT VERSION_LESS CONAN_VERSION_CHECK_MINIMUM)
message(FATAL_ERROR "CMake-Conan: Conan version must be ${CONAN_VERSION_CHECK_MINIMUM} or later")
endif()
endfunction()
macro(construct_profile_argument argument_variable profile_list)
set(${argument_variable} "")
if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE")
set(_arg_flag "--profile:host=")
elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE")
set(_arg_flag "--profile:build=")
endif()
set(_profile_list "${${profile_list}}")
list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile")
list(TRANSFORM _profile_list PREPEND ${_arg_flag})
set(${argument_variable} ${_profile_list})
unset(_arg_flag)
unset(_profile_list)
endmacro()
macro(conan_provide_dependency method package_name)
set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE)
get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS)
if(NOT _conan_install_success)
find_program(CONAN_COMMAND "conan" REQUIRED)
conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION)
conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION})
message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan")
if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE)
conan_profile_detect_default()
endif()
if("auto-cmake" IN_LIST CONAN_HOST_PROFILE)
detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile)
endif()
construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE)
construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE)
if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py")
file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile)
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile")
endif()
set(generator "")
elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt")
file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile)
if(NOT "${outfile}" MATCHES ".*CMakeDeps.*")
message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. "
"Please define the generator as it will be mandatory in the future")
endif()
set(generator "-g;CMakeDeps")
endif()
get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _multiconfig_generator)
message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}")
conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator})
else()
message(STATUS "CMake-Conan: Installing both Debug and Release")
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator})
conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator})
endif()
unset(_host_profile_flags)
unset(_build_profile_flags)
unset(_multiconfig_generator)
unset(_conan_install_success)
else()
message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran")
unset(_conan_install_success)
endif()
get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER)
# Ensure that we consider Conan-provided packages ahead of any other,
# irrespective of other settings that modify the search order or search paths
# This follows the guidelines from the find_package documentation
# (https://cmake.org/cmake/help/latest/command/find_package.html):
# find_package (<PackageName> PATHS paths... NO_DEFAULT_PATH)
# find_package (<PackageName>)
# Filter out `REQUIRED` from the argument list, as the first call may fail
set(_find_args_${package_name} "${ARGN}")
list(REMOVE_ITEM _find_args_${package_name} "REQUIRED")
if(NOT "MODULE" IN_LIST _find_args_${package_name})
find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
unset(_find_args_${package_name})
endif()
# Invoke find_package a second time - if the first call succeeded,
# this will simply reuse the result. If not, fall back to CMake default search
# behaviour, also allowing modules to be searched.
if(NOT ${package_name}_FOUND)
list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index)
if(_index EQUAL -1)
list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}")
endif()
unset(_index)
find_package(${package_name} ${ARGN} BYPASS_PROVIDER)
list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}")
endif()
endmacro()
cmake_language(
SET_DEPENDENCY_PROVIDER conan_provide_dependency
SUPPORTED_METHODS FIND_PACKAGE
)
macro(conan_provide_dependency_check)
set(_CONAN_PROVIDE_DEPENDENCY_INVOKED FALSE)
get_property(_CONAN_PROVIDE_DEPENDENCY_INVOKED GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED)
if(NOT _CONAN_PROVIDE_DEPENDENCY_INVOKED)
message(WARNING "Conan is correctly configured as dependency provider, "
"but Conan has not been invoked. Please add at least one "
"call to `find_package()`.")
if(DEFINED CONAN_COMMAND)
# supress warning in case `CONAN_COMMAND` was specified but unused.
set(_CONAN_COMMAND ${CONAN_COMMAND})
unset(_CONAN_COMMAND)
endif()
endif()
unset(_CONAN_PROVIDE_DEPENDENCY_INVOKED)
endmacro()
# Add a deferred call at the end of processing the top-level directory
# to check if the dependency provider was invoked at all.
cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check)
# Configurable variables for Conan profiles
set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile")
set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile")
set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install")
find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
if(NOT _cmake_program)
get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY)
set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is")
endif()

View file

@ -0,0 +1,3 @@
requirements:
- "openssl/3.2.1"
- "boost/1.84.0"

View file

@ -0,0 +1,25 @@
# This file is managed by Conan, contents will be overwritten.
# To keep your changes, remove these comment lines, but the plugin won't be able to modify your requirements
import os
from io import StringIO
from conan import ConanFile
from conan.tools.files import load, copy
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain
class ConanApplication(ConanFile):
package_type = "application"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def layout(self):
# The root of the project is one level above
#self.folders.root = os.path.dirname(os.path.dirname('.'))
# The source of the project (the root CMakeLists.txt) is the source folder
#self.folders.source = "."
#self.folders.build = "build"
cmake_layout(self)
def requirements(self):
requirements = self.conan_data.get('requirements', [])
for requirement in requirements:
self.requires(requirement)

View file

@ -0,0 +1,2 @@
conan
pytest

View file

@ -0,0 +1,5 @@
compiler:
gcc:
version: ["11.4.0"]
apple-clang:
version: ["15.0.0.15000040"]

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 // Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved. // All rights reserved.
// //

View file

@ -1,5 +1,5 @@
// Copyright (c) 2019, Zano Project // 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 // Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved. // 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 // Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved. // All rights reserved.
// //

View file

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

@ -50,9 +50,6 @@ MACRO(ENABLE_SHARED_PCH_EXECUTABLE target)
ENDMACRO(ENABLE_SHARED_PCH_EXECUTABLE) ENDMACRO(ENABLE_SHARED_PCH_EXECUTABLE)
##### End of Precompiled Headers macros ###### ##### End of Precompiled Headers macros ######
file(GLOB_RECURSE PCH pch/*) file(GLOB_RECURSE PCH pch/*)
file(GLOB_RECURSE COMMON common/*) file(GLOB_RECURSE COMMON common/*)
file(GLOB_RECURSE CRYPTO crypto/*) file(GLOB_RECURSE CRYPTO crypto/*)
@ -68,17 +65,6 @@ file(GLOB_RECURSE CONN_TOOL connectivity_tool/*)
file(GLOB_RECURSE WALLET wallet/*) file(GLOB_RECURSE WALLET wallet/*)
file(GLOB_RECURSE MINER miner/*) file(GLOB_RECURSE MINER miner/*)
if(BUILD_GUI)
if(MSVC)
file(GLOB_RECURSE QTDAEMON gui/qt-daemon/*.cpp gui/qt-daemon/*.h gui/qt-daemon/app.rc)
elseif(APPLE)
file(GLOB_RECURSE QTDAEMON gui/qt-daemon/*.cpp gui/qt-daemon/*.h gui/qt-daemon/*.mm)
else()
file(GLOB_RECURSE QTDAEMON gui/qt-daemon/*.cpp gui/qt-daemon/*.h)
endif()
list(FILTER QTDAEMON EXCLUDE REGEX "node_modules")
endif()
source_group(pch FILES ${PCH}) source_group(pch FILES ${PCH})
source_group(common FILES ${COMMON}) source_group(common FILES ${COMMON})
@ -89,15 +75,10 @@ source_group(daemon FILES ${DAEMON})
source_group(p2p FILES ${P2P}) source_group(p2p FILES ${P2P})
source_group(rpc FILES ${RPC}) source_group(rpc FILES ${RPC})
source_group(stratum FILES ${STRATUM}) source_group(stratum FILES ${STRATUM})
source_group(simplewallet FILES ${SIMPLEWALLET}) source_group(lethean-cli-wallet FILES ${SIMPLEWALLET})
source_group(connectivity-tool FILES ${CONN_TOOL}) source_group(connectivity-tool FILES ${CONN_TOOL})
source_group(wallet FILES ${WALLET}) source_group(wallet FILES ${WALLET})
if(BUILD_GUI)
source_group(qtdaemon FILES ${QTDAEMON})
endif()
INIT_SHARED_PCH() INIT_SHARED_PCH()
add_library(common ${COMMON}) add_library(common ${COMMON})
@ -134,11 +115,6 @@ if(NOT DISABLE_TOR)
target_link_libraries(wallet tor-connect) target_link_libraries(wallet tor-connect)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "iOS") if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
install(TARGETS wallet currency_core crypto common DESTINATION lib) install(TARGETS wallet currency_core crypto common DESTINATION lib)
message("Generating install for iOS") message("Generating install for iOS")
@ -165,81 +141,20 @@ 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) 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(daemon DAEMON)
ENABLE_SHARED_PCH_EXECUTABLE(daemon) ENABLE_SHARED_PCH_EXECUTABLE(daemon)
add_executable(connectivity_tool ${CONN_TOOL}) add_executable(connectivity_tool ${CONN_TOOL})
add_dependencies(connectivity_tool version) 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) target_link_libraries(connectivity_tool currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL) ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL)
ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool) ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool)
add_executable(simplewallet ${SIMPLEWALLET}) add_executable(lethean-wallet ${SIMPLEWALLET})
add_dependencies(simplewallet version) add_dependencies(lethean-wallet version)
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) target_link_libraries(lethean-wallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET) ENABLE_SHARED_PCH(lethean-wallet SIMPLEWALLET)
ENABLE_SHARED_PCH_EXECUTABLE(simplewallet) ENABLE_SHARED_PCH_EXECUTABLE(lethean-wallet)
set_property(TARGET common crypto currency_core rpc stratum wallet PROPERTY FOLDER "libs") 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 lethean-wallet connectivity_tool PROPERTY FOLDER "prog")
set_property(TARGET daemon PROPERTY OUTPUT_NAME "zanod") set_property(TARGET daemon PROPERTY OUTPUT_NAME "letheand")
if(BUILD_GUI)
if(APPLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
endif()
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)
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)
if (UNIX AND NOT APPLE)
target_link_libraries(Zano rt)
endif()
if(APPLE)
target_link_libraries(Zano ${COCOA_LIBRARY})
set_property(TARGET Zano PROPERTY XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)
endif()
if(MSVC)
target_link_libraries(Zano 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(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

@ -13,7 +13,7 @@ namespace command_line
const arg_descriptor<bool> arg_help ("help", "Produce help message"); const arg_descriptor<bool> arg_help ("help", "Produce help message");
const arg_descriptor<bool> arg_version ("version", "Output version information"); 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<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<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") ); const arg_descriptor<std::string> arg_config_file ( "config-file", "Specify configuration file", std::string(CURRENCY_NAME_SHORT ".conf") );

View file

@ -42,7 +42,7 @@ namespace db
m_engine_type = db_mdbx; m_engine_type = db_mdbx;
#else #else
LOG_PRINT_L0(" DB ENGINE: " << ARG_DB_ENGINE_MDBX << " is not suported by this build(see DISABLE_MDBX cmake option), STOPPING"); LOG_PRINT_L0(" DB ENGINE: " << ARG_DB_ENGINE_MDBX << " is not suported by this build(see DISABLE_MDBX cmake option), STOPPING");
#endif #endif
} }
else else
{ {
@ -122,7 +122,7 @@ namespace db
std::string db_backend_selector::get_temp_config_folder() const 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 struct tx_cost_struct
{ {
std::string usd_needed_for_erc20; std::string usd_needed_for_erc20;
std::string zano_needed_for_erc20; std::string lethean_needed_for_erc20;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(usd_needed_for_erc20) KV_SERIALIZE(usd_needed_for_erc20)
KV_SERIALIZE(zano_needed_for_erc20) KV_SERIALIZE(lethean_needed_for_erc20)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };

View file

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

View file

@ -21,8 +21,12 @@ namespace tools
}; };
#ifndef TESTNET #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 }; //@todo bookmarking bootstrap file location
static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.42.247/pre-download/zano_lmdb_95_2500000.pak", "5509650e12c8f901e6731a2bfaf3abfd64409e3e1366d3d94cd11db8beddb0c3", 4239505801, 5893566464 }; // 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 #else
static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 }; static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 };
static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 }; static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 };

View file

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

View file

@ -99,4 +99,4 @@ namespace currency
get_block_longhash(b, p); get_block_longhash(b, p);
return p; return p;
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,7 @@
#include "serialization/debug_archive.h" #include "serialization/debug_archive.h"
#include "serialization/keyvalue_serialization.h" // epee key-value serialization #include "serialization/keyvalue_serialization.h" // epee key-value serialization
#include "string_tools.h" #include "string_tools.h"
#include "currency_config.h" #include "currency_core/currency_config.h"
#include "crypto/crypto.h" #include "crypto/crypto.h"
#include "crypto/hash.h" #include "crypto/hash.h"
#include "crypto/range_proofs.h" #include "crypto/range_proofs.h"

View file

@ -8,7 +8,7 @@
#ifndef TESTNET #ifndef TESTNET
#define CURRENCY_FORMATION_VERSION 84 #define CURRENCY_FORMATION_VERSION 1
#else #else
#define CURRENCY_FORMATION_VERSION 97 #define CURRENCY_FORMATION_VERSION 97
#endif #endif
@ -16,21 +16,21 @@
#define CURRENCY_GENESIS_NONCE (CURRENCY_FORMATION_VERSION + 101011010121) //bender's nightmare #define CURRENCY_GENESIS_NONCE (CURRENCY_FORMATION_VERSION + 101011010121) //bender's nightmare
#define CURRENCY_MAX_BLOCK_NUMBER 500000000 #define CURRENCY_MAX_BLOCK_NUMBER 500000000
#define CURRENCY_MAX_BLOCK_SIZE 500000000 // block header blob limit, never used! #define CURRENCY_MAX_BLOCK_SIZE 500000000 // block header blob limit, never used!
#define CURRENCY_TX_MAX_ALLOWED_OUTS 2000 #define CURRENCY_TX_MAX_ALLOWED_OUTS 2000 // effective starting HF4 Zarcanum
#define CURRENCY_TX_MIN_ALLOWED_OUTS 2 // effective starting HF4 Zarcanum #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_ADDRESS_BASE58_PREFIX 0x73f7 // addresses start with 'iT'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x3678 // integrated addresses start with 'iZ' #define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x6af7 // integrated addresses start with 'iTH'
#define CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX 0x36f8 // integrated addresses start with 'iZ' (new format) #define CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX 0x6af7 // integrated addresses start with 'iTH' (new format)
#define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0x98c8 // auditable addresses start with 'aZx' #define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0xdeaf7 // auditable addresses start with 'iTHn'
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX' #define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x7eaf7 // auditable integrated addresses start with 'iTHa'
#define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10 #define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10
#define CURRENT_TRANSACTION_VERSION 2 #define CURRENT_TRANSACTION_VERSION 2
#define TRANSACTION_VERSION_INITAL 0 #define TRANSACTION_VERSION_INITAL 0
#define TRANSACTION_VERSION_PRE_HF4 1 #define TRANSACTION_VERSION_PRE_HF4 1
#define TRANSACTION_VERSION_POST_HF4 2 #define TRANSACTION_VERSION_POST_HF4 ((uint64_t)2)
#define HF1_BLOCK_MAJOR_VERSION 1 #define HF1_BLOCK_MAJOR_VERSION 1
#define HF3_BLOCK_MAJOR_VERSION 2 #define HF3_BLOCK_MAJOR_VERSION 2
#define HF3_BLOCK_MINOR_VERSION 0 #define HF3_BLOCK_MINOR_VERSION 0
@ -53,17 +53,17 @@
#define CURRENCY_COINBASE_BLOB_RESERVED_SIZE 1100 #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_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_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 // 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 BASE_REWARD_DUST_THRESHOLD ((uint64_t)1000000) // pow(10, 6) - change this will cause hard-fork!
#define DEFAULT_DUST_THRESHOLD ((uint64_t)0) #define DEFAULT_DUST_THRESHOLD ((uint64_t)0)
#define TX_DEFAULT_FEE ((uint64_t)10000000000) // .01 #define TX_DEFAULT_FEE ((uint64_t)1000000) // .01
#define TX_MINIMUM_FEE ((uint64_t)10000000000) // .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) #define WALLET_MAX_ALLOWED_OUTPUT_AMOUNT ((uint64_t)0xffffffffffffffffLL)
@ -93,7 +93,7 @@
#define MAX_ALIAS_PER_BLOCK 1000 #define MAX_ALIAS_PER_BLOCK 1000
#define ALIAS_COAST_PERIOD CURRENCY_BLOCKS_PER_DAY*7 //week #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_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 #define ALIAS_MEDIAN_RECALC_INTERWAL CURRENCY_BLOCKS_PER_DAY
@ -110,19 +110,23 @@
#ifndef TESTNET #ifndef TESTNET
#define P2P_DEFAULT_PORT 11121 #define SEED_NODE_HOST "mainnet.lethean.io"
#define RPC_DEFAULT_PORT 11211 #define SEED_NODE_HOST2 "dev.network"
#define STRATUM_DEFAULT_PORT 11777 #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_NETWORK_ID_TESTNET_FLAG 0
#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607" #define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607"
#define DIFFICULTY_POS_STARTER 1 #define DIFFICULTY_POS_STARTER 1
#else #else
#define P2P_DEFAULT_PORT (11112 + CURRENCY_FORMATION_VERSION) #define SEED_NODE_HOST "testnet.lethean.io"
#define RPC_DEFAULT_PORT 12111 #define SEED_NODE_HOST2 "dev.lthn.network"
#define STRATUM_DEFAULT_PORT 11888 #define P2P_DEFAULT_PORT 31122
#define STRARUM_DEFAULT_PORT 51113 #define RPC_DEFAULT_PORT 31212
#define STRATUM_DEFAULT_PORT 31778
#define P2P_NETWORK_ID_TESTNET_FLAG 1 #define P2P_NETWORK_ID_TESTNET_FLAG 1
#define P2P_MAINTAINERS_PUB_KEY "aaa2d7aabc8d383fd53a3ae898697b28f236ceade6bafc1eecff413a6a02272a" #define P2P_MAINTAINERS_PUB_KEY "cc6076dd0ba1bdb1dd65c8aedcc4c15705d713060f33c4a12ce301eb86f4c684"
#define DIFFICULTY_POS_STARTER 1 #define DIFFICULTY_POS_STARTER 1
#endif #endif
@ -190,19 +194,19 @@
#define CURRENCY_NAME_ABR "ZANO" #define CURRENCY_NAME_ABR "LTHN"
#define CURRENCY_NAME_BASE "Zano" #define CURRENCY_NAME_BASE "Lethean"
#define CURRENCY_NAME_SHORT_BASE "Zano" #define CURRENCY_NAME_SHORT_BASE "Lethean"
#ifndef TESTNET #ifndef TESTNET
#define CURRENCY_NAME CURRENCY_NAME_BASE #define CURRENCY_NAME CURRENCY_NAME_BASE
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE #define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE
#else #else
#define CURRENCY_NAME CURRENCY_NAME_BASE"_testnet" #define CURRENCY_NAME CURRENCY_NAME_BASE"_testnet3"
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE"_testnet" #define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE"_testnet3"
#endif #endif
//premine //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 //alias registration wallet
#define ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money #define ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
@ -210,7 +214,7 @@
#define ALIAS_REWARDS_ACCOUNT_VIEW_SEC_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money #define ALIAS_REWARDS_ACCOUNT_VIEW_SEC_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
#define ALIAS_MINIMUM_PUBLIC_SHORT_NAME_ALLOWED 6 #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 #define ALIAS_NAME_MAX_LEN 255
@ -252,7 +256,7 @@
#ifndef TESTNET #ifndef TESTNET
#define WALLET_FILE_SERIALIZATION_VERSION 163 #define WALLET_FILE_SERIALIZATION_VERSION 163
#define WALLET_FILE_LAST_SUPPORTED_VERSION 163 #define WALLET_FILE_LAST_SUPPORTED_VERSION 163
#else #else
#define WALLET_FILE_LAST_SUPPORTED_VERSION (CURRENCY_FORMATION_VERSION+76) #define WALLET_FILE_LAST_SUPPORTED_VERSION (CURRENCY_FORMATION_VERSION+76)
#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+76) #define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+76)
#endif #endif
@ -264,16 +268,15 @@
#define BLOCK_MINOR_VERSION_GENESIS 0 #define BLOCK_MINOR_VERSION_GENESIS 0
#define BLOCK_MAJOR_VERSION_INITIAL 0 #define BLOCK_MAJOR_VERSION_INITIAL 0
#ifndef TESTNET #ifndef TESTNET
#define ZANO_HARDFORK_01_AFTER_HEIGHT 194624 // 2019-09-21 20:25:16 #define ZANO_HARDFORK_01_AFTER_HEIGHT 1
#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999 // 2021-04-05 09:11:45 #define ZANO_HARDFORK_02_AFTER_HEIGHT 2
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1082577 // 2021-06-01 23:28:10 #define ZANO_HARDFORK_03_AFTER_HEIGHT 3
#define ZANO_HARDFORK_04_AFTER_HEIGHT 2555000 // 2024-03-21 10:16:46 (expected) #define ZANO_HARDFORK_04_AFTER_HEIGHT 3
#else #else
/////// Zarcanum Testnet ////////////////////////////// #define ZANO_HARDFORK_01_AFTER_HEIGHT 1
#define ZANO_HARDFORK_01_AFTER_HEIGHT 0 #define ZANO_HARDFORK_02_AFTER_HEIGHT 2
#define ZANO_HARDFORK_02_AFTER_HEIGHT 0 #define ZANO_HARDFORK_03_AFTER_HEIGHT 3
#define ZANO_HARDFORK_03_AFTER_HEIGHT 0 #define ZANO_HARDFORK_04_AFTER_HEIGHT 3
#define ZANO_HARDFORK_04_AFTER_HEIGHT 2440
#endif #endif

View file

@ -24,7 +24,7 @@ using namespace epee;
#define MINIMUM_REQUIRED_FREE_SPACE_BYTES (1024 * 1024 * 100) #define MINIMUM_REQUIRED_FREE_SPACE_BYTES (1024 * 1024 * 100)
DISABLE_VS_WARNINGS(4355) DISABLE_VS_WARNINGS(4355)
#undef LOG_DEFAULT_CHANNEL #undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "core" #define LOG_DEFAULT_CHANNEL "core"
ENABLE_CHANNEL_BY_DEFAULT("core"); ENABLE_CHANNEL_BY_DEFAULT("core");
namespace currency namespace currency
@ -163,6 +163,8 @@ namespace currency
r = m_blockchain_storage.init(m_config_folder, vm); r = m_blockchain_storage.init(m_config_folder, vm);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage"); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
m_mempool.remove_incompatible_txs();
r = m_miner.init(vm); r = m_miner.init(vm);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner"); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner");
@ -253,7 +255,7 @@ namespace currency
return false; return false;
} }
TIME_MEASURE_FINISH_MS(parse_tx_time); TIME_MEASURE_FINISH_MS(parse_tx_time);
TIME_MEASURE_START_MS(check_tx_semantic_time); TIME_MEASURE_START_MS(check_tx_semantic_time);
if(!validate_tx_semantic(tx, tx_blob.size())) if(!validate_tx_semantic(tx, tx_blob.size()))
{ {
@ -277,7 +279,7 @@ namespace currency
st_inf.blockchain_height = m_blockchain_storage.get_current_blockchain_size(); st_inf.blockchain_height = m_blockchain_storage.get_current_blockchain_size();
st_inf.tx_pool_size = m_mempool.get_transactions_count(); 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()); st_inf.top_block_id_str = epee::string_tools::pod_to_hex(m_blockchain_storage.get_top_block_id());
std::list<block> blocks; 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); 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) for (auto& b : blocks)
@ -366,12 +368,12 @@ namespace currency
return m_blockchain_storage.create_block_template(params, resp); 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); 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); return m_blockchain_storage.find_blockchain_supplement(qblock_ids, blocks, total_height, start_height, max_count);
} }
@ -616,12 +618,12 @@ namespace currency
return m_blockchain_storage.get_short_chain_history(ids); 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); 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); return m_blockchain_storage.get_block_id_by_height(height);
} }
@ -651,14 +653,14 @@ namespace currency
if(!m_starter_message_showed) if(!m_starter_message_showed)
{ {
LOG_PRINT_L0(ENDL LOG_PRINT_L0(ENDL
<< "**********************************************************************" << ENDL << "**********************************************************************" << ENDL
<< "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL << "The daemon will start synchronizing with the network. It may take up to several hours." << ENDL
<< ENDL << ENDL
<< "You can adjust verbosity by using command: \"set_log <level>\", where 0 is the least verbose and 3 is the most." << ENDL << "You can adjust verbosity by using command: \"set_log <level>\", where 0 is the least verbose and 3 is the most." << ENDL
<< ENDL << ENDL
<< "Use \"help\" command to list all available commands." << ENDL << "Use \"help\" command to list all available commands." << ENDL
<< 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; m_starter_message_showed = true;
} }

View file

@ -66,7 +66,7 @@ namespace currency
} }
return true; return true;
} }
// okay, have some ZC inputs // 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"); 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::public_key H = ogc.asset_ids[j].to_public_key();
const crypto::point_t& T = ogc.blinded_asset_ids[j]; const crypto::point_t& T = ogc.blinded_asset_ids[j];
std::vector<crypto::point_t> ring; std::vector<crypto::point_t> ring;
ring.reserve(zc_ins_count); ring.reserve(zc_ins_count);
size_t secret_index = SIZE_MAX; size_t secret_index = SIZE_MAX;
@ -172,7 +172,7 @@ namespace currency
if (is_asset_emitting_transaction(tx, &ado)) if (is_asset_emitting_transaction(tx, &ado))
{ {
crypto::point_t asset_id_pt{}; 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 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 */, 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 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 */, 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>() */ const std::vector<tx_destination_entry>& destinations_ /* = std::vector<tx_destination_entry>() */
) )
{ {
@ -388,7 +388,7 @@ namespace currency
{ {
block_reward += fee; block_reward += fee;
} }
if (!destinations.size()) if (!destinations.size())
{ {
// //
@ -454,7 +454,7 @@ namespace currency
if (!add_tx_extra_userdata(tx, extra_nonce)) if (!add_tx_extra_userdata(tx, extra_nonce))
return false; 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); 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 //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()); 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]; tx_gen_context.amount_commitments_sum += tx_gen_context.amount_commitments[output_index];
++output_index; ++output_index;
} }
if (tx.attachment.size()) if (tx.attachment.size())
add_attachments_info_to_extra(tx.extra, tx.attachment); add_attachments_info_to_extra(tx.extra, tx.attachment);
@ -521,7 +521,7 @@ namespace currency
if (tx.version > TRANSACTION_VERSION_PRE_HF4 && !pos) 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 // 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 // tx hash should be sealed by now
crypto::hash tx_id = get_transaction_hash(tx); crypto::hash tx_id = get_transaction_hash(tx);
@ -684,7 +684,7 @@ namespace currency
} }
return true; return true;
} }
// pre-HF4 txs // pre-HF4 txs
return check_tx_bare_balance(tx, additional_inputs_amount_and_fees_for_mining_tx); 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) if (ts < WALLET_BRAIN_DATE_OFFSET)
return false; return false;
creation_timestamp = ts; creation_timestamp = ts;
} }
@ -854,7 +854,7 @@ namespace currency
uint64_t amount_in = 0; uint64_t amount_in = 0;
uint64_t amount_out = get_outs_money_amount(tx); uint64_t amount_out = get_outs_money_amount(tx);
for(auto& in : tx.vin) for(auto& in : tx.vin)
amount_in += get_amount_from_variant(in); amount_in += get_amount_from_variant(in);
@ -870,9 +870,9 @@ namespace currency
fee += ztd.fee; fee += ztd.fee;
return true; // continue return true; // continue
}; };
bool r = process_type_in_variant_container<zarcanum_tx_data_v1>(tx.extra, cb, false); bool r = process_type_in_variant_container<zarcanum_tx_data_v1>(tx.extra, cb, false);
if (!r) if (!r)
{ {
fee = 0; fee = 0;
@ -1147,7 +1147,7 @@ namespace currency
//a.meta_info; //a.meta_info;
//if (a.owner != b.owner) return false; //if (a.owner != b.owner) return false;
if (new_ado.hidden_supply != prev_ado.hidden_supply) return false; if (new_ado.hidden_supply != prev_ado.hidden_supply) return false;
return true; return true;
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
@ -1200,12 +1200,12 @@ namespace currency
crypto::scalar_t amount_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_OUT_AMOUNT_MASK, h); 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]; 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"); 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)) 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; 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) 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_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; 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 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.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 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); 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]; 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"); 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)) 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; 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_blinding_mask);
DBG_VAL_PRINT(amount_mask); DBG_VAL_PRINT(amount_mask);
DBG_VAL_PRINT(amount_commitment); DBG_VAL_PRINT(amount_commitment);
if (de.addr.front().is_auditable()) 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 out.mix_attr = CURRENCY_TO_KEY_OUT_FORCED_NO_MIX; // override mix_attr to 1 for auditable target addresses
else else
@ -1251,7 +1251,7 @@ namespace currency
uint16_t hint = get_derivation_hint(reinterpret_cast<crypto::key_derivation&>(derivation)); uint16_t hint = get_derivation_hint(reinterpret_cast<crypto::key_derivation&>(derivation));
if (deriv_cache.count(hint) == 0) if (deriv_cache.count(hint) == 0)
{ {
tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint)); tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint));
deriv_cache.insert(hint); deriv_cache.insert(hint);
} }
@ -1283,7 +1283,7 @@ namespace currency
uint16_t hint = get_derivation_hint(derivation); uint16_t hint = get_derivation_hint(derivation);
if (deriv_cache.count(hint) == 0) if (deriv_cache.count(hint) == 0)
{ {
tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint)); tx.extra.push_back(make_tx_derivation_hint_from_uint16(hint));
deriv_cache.insert(hint); deriv_cache.insert(hint);
} }
@ -1321,7 +1321,7 @@ namespace currency
if (htlc_dest.htlc_hash == null_hash) if (htlc_dest.htlc_hash == null_hash)
{ {
//we use deterministic origin, to make possible access origin on different wallets copies //we use deterministic origin, to make possible access origin on different wallets copies
result.htlc_origin = generate_origin_for_htlc(htlc, self); result.htlc_origin = generate_origin_for_htlc(htlc, self);
//calculate hash //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 tk.mix_attr = CURRENCY_TO_KEY_OUT_FORCED_NO_MIX; // override mix_attr to 1 for auditable target addresses
else else
tk.mix_attr = tx_outs_attr; tk.mix_attr = tx_outs_attr;
out.target = tk; out.target = tk;
} }
else else
@ -1398,14 +1398,14 @@ namespace currency
eai.cnt = attachment.size(); 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_source_entry>& sources,
const std::vector<tx_destination_entry>& destinations, const std::vector<tx_destination_entry>& destinations,
const std::vector<attachment_v>& attachments, const std::vector<attachment_v>& attachments,
transaction& tx, transaction& tx,
uint64_t tx_version, uint64_t tx_version,
uint64_t unlock_time, uint64_t unlock_time,
uint8_t tx_outs_attr, uint8_t tx_outs_attr,
bool shuffle) bool shuffle)
{ {
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key); 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; const crypto::key_derivation& rkey;
std::vector<payload_items_v>& rdecrypted_att; std::vector<payload_items_v>& rdecrypted_att;
decrypt_attach_visitor(const crypto::key_derivation& key, 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, const account_keys& acc_keys,
bool is_income, bool is_income,
const transaction& tx, const transaction& tx,
@ -1546,8 +1546,8 @@ namespace currency
rkey(key), rkey(key),
m_tx(tx), m_tx(tx),
m_is_income(is_income), m_is_income(is_income),
rdecrypted_att(decrypted_att), rdecrypted_att(decrypted_att),
m_acc_keys(acc_keys), m_acc_keys(acc_keys),
m_tx_onetime_pubkey(tx_onetime_pubkey) m_tx_onetime_pubkey(tx_onetime_pubkey)
{} {}
void operator()(const tx_comment& comment) void operator()(const tx_comment& comment)
@ -1572,7 +1572,7 @@ namespace currency
{ {
return; // this field invisible for sender return; // this field invisible for sender
} }
//decrypting derivation //decrypting derivation
derivation_local = *(crypto::key_derivation*)&sa.security[0]; derivation_local = *(crypto::key_derivation*)&sa.security[0];
crypto::chacha_crypt(derivation_local, m_acc_keys.spend_secret_key); crypto::chacha_crypt(derivation_local, m_acc_keys.spend_secret_key);
} }
@ -1591,7 +1591,7 @@ namespace currency
else else
{ {
crypto::chacha_crypt(local_sa.body, derivation_local); crypto::chacha_crypt(local_sa.body, derivation_local);
} }
} }
if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY) if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY)
@ -1733,11 +1733,11 @@ namespace currency
for (auto& a : tx.attachment) for (auto& a : tx.attachment)
boost::apply_visitor(v, a); boost::apply_visitor(v, a);
return true; 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.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); decrypt_payload_items(derivation, tx.attachment, decrypted_items, is_income, tx, acc_keys, onetime_pub);
return true; return true;
@ -1922,7 +1922,7 @@ namespace currency
{ {
// //
//find target account to encrypt attachment. //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 //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); 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; return native_coin_asset_descriptor;
} }
bool construct_tx_handle_ado(const account_keys& sender_account_keys, bool construct_tx_handle_ado(const account_keys& sender_account_keys,
const finalize_tx_param& ftp, const finalize_tx_param& ftp,
asset_descriptor_operation& ado, asset_descriptor_operation& ado,
tx_generation_context& gen_context, tx_generation_context& gen_context,
const keypair& tx_key, const keypair& tx_key,
std::vector<tx_destination_entry>& shuffled_dsts) std::vector<tx_destination_entry>& shuffled_dsts)
@ -2198,7 +2198,7 @@ namespace currency
// old: // old:
// asset_control_key = Hs(CRYPTO_HDS_ASSET_CONTROL_KEY, 8 * tx_key.sec * sender_account_keys.account_address.spend_public_key, 0) // 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 = asset_control_key * G
ado.descriptor.owner = sender_account_keys.account_address.spend_public_key; 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"); 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(); 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 }); if (ftp.pevents_dispatcher) ftp.pevents_dispatcher->RAISE_DEBUG_EVENT(wde_construct_tx_handle_asset_descriptor_operation_before_burn{ &ado });
} }
else else
{ {
@ -2323,7 +2323,7 @@ namespace currency
const uint8_t& tx_outs_attr = ftp.tx_outs_attr; const uint8_t& tx_outs_attr = ftp.tx_outs_attr;
const bool& shuffle = ftp.shuffle; const bool& shuffle = ftp.shuffle;
const uint64_t& flags = ftp.flags; const uint64_t& flags = ftp.flags;
bool r = false; bool r = false;
transaction& tx = result.tx; transaction& tx = result.tx;
crypto::secret_key& one_time_tx_secret_key = result.one_time_key; crypto::secret_key& one_time_tx_secret_key = result.one_time_key;
@ -2348,7 +2348,7 @@ namespace currency
if (flags != 0) if (flags != 0)
set_tx_flags(tx, flags); set_tx_flags(tx, flags);
//generate key pair //generate key pair
if (expiration_time != 0) if (expiration_time != 0)
set_tx_expiration_time(tx, expiration_time); set_tx_expiration_time(tx, expiration_time);
} }
@ -2474,7 +2474,7 @@ namespace currency
if (src_entr.is_zc()) 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) 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) 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"); 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 //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; crypto::key_derivation& derivation = result.derivation;
CHECK_AND_ASSERT_MES(derivation != null_derivation, false, "failed to generate_key_derivation"); CHECK_AND_ASSERT_MES(derivation != null_derivation, false, "failed to generate_key_derivation");
bool was_attachment_crypted_entries = false; bool was_attachment_crypted_entries = false;
@ -2545,7 +2545,7 @@ namespace currency
} }
// //
// OUTs // OUTs
// //
@ -2569,7 +2569,7 @@ namespace currency
if (shuffle) 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; }); 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 // construct outputs
uint64_t native_coins_output_sum = 0; uint64_t native_coins_output_sum = 0;
@ -2660,7 +2660,7 @@ namespace currency
if (tx.attachment.size()) if (tx.attachment.size())
add_attachments_info_to_extra(tx.extra, tx.attachment); add_attachments_info_to_extra(tx.extra, tx.attachment);
} }
// //
// generate proofs and signatures // generate proofs and signatures
@ -2677,7 +2677,7 @@ namespace currency
size_t i_mapped = inputs_mapping[i_]; size_t i_mapped = inputs_mapping[i_];
const tx_source_entry& source_entry = sources[i_mapped]; 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); 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; std::stringstream ss_ring_s;
if (source_entry.is_zc()) if (source_entry.is_zc())
@ -2733,8 +2733,8 @@ namespace currency
aop.opt_amount_commitment_g_proof = aop_g_sig; aop.opt_amount_commitment_g_proof = aop_g_sig;
tx.proofs.emplace_back(std::move(aop)); 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); asset_operation_ownership_proof aoop = AUTO_VAL_INIT(aoop);
if (ftp.pthirdparty_sign_handler) if (ftp.pthirdparty_sign_handler)
@ -2745,7 +2745,7 @@ namespace currency
} }
else 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); 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"); CHECK_AND_ASSERT_MES(r, false, "Failed to sign ado proof");
} }
@ -2794,7 +2794,7 @@ namespace currency
VARIANT_CASE_CONST(tx_out_bare, o) VARIANT_CASE_CONST(tx_out_bare, o)
reward += o.amount; reward += o.amount;
VARIANT_CASE_CONST(tx_out_zarcanum, o) VARIANT_CASE_CONST(tx_out_zarcanum, o)
//@#@ //@#@
VARIANT_SWITCH_END(); VARIANT_SWITCH_END();
} }
reward -= income; reward -= income;
@ -2828,7 +2828,7 @@ namespace currency
password_used = false; password_used = false;
} }
uint64_t timestamp = count_of_weeks * WALLET_BRAIN_DATE_QUANTUM + WALLET_BRAIN_DATE_OFFSET; uint64_t timestamp = count_of_weeks * WALLET_BRAIN_DATE_QUANTUM + WALLET_BRAIN_DATE_OFFSET;
return timestamp; 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(); 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(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(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"); 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; auto& sigs = boost::get<NLSAG_sig>(tx.signatures[ms_input_index]).s;
LOC_CHK(!sigs.empty(), "empty signatures container"); 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; 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(); 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 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)); 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"); 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_to_key) ||
in.type() == typeid(txin_multisig) || in.type() == typeid(txin_multisig) ||
in.type() == typeid(txin_htlc) || 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)); false, "wrong input type: " << in.type().name() << ", in transaction " << get_transaction_hash(tx));
} }
return true; return true;
@ -2978,7 +2978,7 @@ namespace currency
/* /*
bool add_padding_to_tx(transaction& tx, size_t count) bool add_padding_to_tx(transaction& tx, size_t count)
{ {
WARNING: potantially unsafe implementation! WARNING: potantially unsafe implementation!
1) requires extra_padding being previously added to tx's extra; 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) 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) 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)); 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_SWITCH_BEGIN(out.target);
VARIANT_CASE_CONST(txout_to_key, tk) VARIANT_CASE_CONST(txout_to_key, tk)
if (!check_key(tk.key)) if (!check_key(tk.key))
@ -3253,7 +3253,7 @@ namespace currency
return false; return false;
return true; return true;
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
bool lookup_acc_outs(const account_keys& acc, const transaction& tx, std::vector<wallet_out_info>& outs, crypto::key_derivation& derivation) 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; return ts;
} }
} }
// next try etc_tx_time // next try etc_tx_time
etc_tx_time t = AUTO_VAL_INIT(t); etc_tx_time t = AUTO_VAL_INIT(t);
if (get_type_in_variant_container(b.miner_tx.extra, t)) if (get_type_in_variant_container(b.miner_tx.extra, t))
@ -3564,7 +3564,7 @@ namespace currency
//------------------------------------------------------------------ //------------------------------------------------------------------
#define ANTI_OVERFLOW_AMOUNT 1000000 #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() void print_reward_change()
{ {
@ -3587,7 +3587,7 @@ namespace currency
std::cout << std::left std::cout << std::left
<< std::setw(10) << day << std::setw(10) << day
<< std::setw(19) << print_money(emission_reward) << 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)) << "%" << "(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)) << "%)" << ", 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::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; // 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; // const boost::multiprecision::uint128_t& already_generated_coins = PREMINE_AMOUNT;
// //uint64_t total_money_supply = TOTAL_MONEY_SUPPLY; // //uint64_t total_money_supply = TOTAL_MONEY_SUPPLY;
// uint64_t h = 0; // uint64_t h = 0;
@ -3630,15 +3630,15 @@ namespace currency
// { // {
// uint64_t emission_reward = 0; // uint64_t emission_reward = 0;
// get_block_reward(h % 2, 0, 0, already_generated_coins, emission_reward, h, (already_generated_coins - PREMINE_AMOUNT) * 140); // get_block_reward(h % 2, 0, 0, already_generated_coins, emission_reward, h, (already_generated_coins - PREMINE_AMOUNT) * 140);
// //
// std::cout << std::left // std::cout << std::left
// << std::setw(10) << day // << std::setw(10) << day
// << std::setw(19) << print_money(emission_reward) // << 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::setw(4) << print_money(already_generated_coins)//std::string(std::to_string(GET_PERECENTS_BIG_NUMBERS((already_generated_coins), total_money_supply)) + "%")
// << std::endl; // << std::endl;
// //
// //
// //
// for (size_t i = 0; i != 720; i++) // for (size_t i = 0; i != 720; i++)
// { // {
// h++; // h++;
@ -3649,7 +3649,7 @@ namespace currency
// } // }
// } // }
} }
std::string print_reward_change_first_blocks(size_t n_of_first_blocks) std::string print_reward_change_first_blocks(size_t n_of_first_blocks)
{ {
std::stringstream ss; std::stringstream ss;
@ -3691,7 +3691,7 @@ namespace currency
//------------------------------------------------------------------ //------------------------------------------------------------------
void print_currency_details() 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 << "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; 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 #ifndef TESTNET
// std::string genesis_coinbase_tx_hex((const char*)&ggenesis_tx_raw, sizeof(ggenesis_tx_raw)); // std::string genesis_coinbase_tx_hex((const char*)&ggenesis_tx_raw, sizeof(ggenesis_tx_raw));
#else #else
std::string genesis_coinbase_tx_hex = ""; std::string genesis_coinbase_tx_hex = "";
#endif #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" //genesis proof phrase: "Liverpool beat Barcelona: Greatest Champions League comebacks of all time"
//taken from: https://www.bbc.com/sport/football/48163330 //taken from: https://www.bbc.com/sport/football/48163330
//sha3-256 from proof phrase: a074236b1354901d5dbc029c0ac4c05c948182c34f3030f32b0c93aee7ba275c (included in genesis block) //sha3-256 from proof phrase: a074236b1354901d5dbc029c0ac4c05c948182c34f3030f32b0c93aee7ba275c (included in genesis block)
@ -3967,7 +3969,7 @@ namespace currency
} }
else// if (ao.type() == typeid(ref_by_id)) 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(); 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(); entry_to_fill.multisig_count = boost::get<NLSAG_sig>(tx.signatures[tei.ins.size() - 1]).s.size();
} }
} }
} }
return true; return true;
@ -4034,7 +4036,7 @@ namespace currency
gindices[amount] += 1; gindices[amount] += 1;
} }
VARIANT_CASE_CONST(tx_out_zarcanum, o) VARIANT_CASE_CONST(tx_out_zarcanum, o)
//@#@ //@#@
VARIANT_SWITCH_END(); VARIANT_SWITCH_END();
} }
} }
@ -4072,7 +4074,7 @@ namespace currency
{ {
if (!height) if (!height)
return PREMINE_AMOUNT; return PREMINE_AMOUNT;
return CURRENCY_BLOCK_REWARD; return CURRENCY_BLOCK_REWARD;
} }
//----------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------
@ -4152,12 +4154,12 @@ namespace currency
std::string get_account_address_as_str(const account_public_address& addr) std::string get_account_address_as_str(const account_public_address& addr)
{ {
if (addr.flags == 0) 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) 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_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 Zano address (normal) 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) 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) 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) 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) 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_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 Zano address (normal) 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) bool get_account_address_from_str(account_public_address& addr, const std::string& str)
@ -4388,12 +4390,12 @@ namespace currency
size_t i = 0; size_t i = 0;
for (auto& p_out_k : output_keys_ptrs) for (auto& p_out_k : output_keys_ptrs)
s << " " << std::setw(2) << i++ << " " << *p_out_k << ENDL; s << " " << std::setw(2) << i++ << " " << *p_out_k << ENDL;
s << " signatures (" << sig.size() << ")" << ENDL; s << " signatures (" << sig.size() << ")" << ENDL;
i = 0; i = 0;
for (auto& sig_el : sig) for (auto& sig_el : sig)
s << " " << std::setw(2) << i++ << " " << sig_el << ENDL; s << " " << std::setw(2) << i++ << " " << sig_el << ENDL;
return s.str(); return s.str();
} }
@ -4438,7 +4440,7 @@ namespace currency
{ {
if (a.cnt == b.cnt && a.hsh == b.hsh && a.sz == b.sz) if (a.cnt == b.cnt && a.hsh == b.hsh && a.sz == b.sz)
return true; return true;
else else
return false; return false;
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@ -4540,7 +4542,7 @@ namespace currency
// << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL // << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL // << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
// << ", a_pow_cumulative_difficulty:" << a_pow_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(); TRY_ENTRY();
@ -4549,7 +4551,7 @@ namespace currency
CATCH_ENTRY_WITH_FORWARDING_EXCEPTION(); 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) // 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 // 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 // << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL // << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
// << ", a_pow_cumulative_difficulty:" << a_pow_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(); TRY_ENTRY();

View file

@ -55,7 +55,7 @@ namespace currency {
return a + b < a || (c && a + b == (uint64_t)-1); return a + b < a || (c && a + b == (uint64_t)-1);
} }
#if defined(_MSC_VER) #if defined(_MSC_VER)
#ifdef max #ifdef max
#undef max #undef max
@ -98,7 +98,7 @@ namespace currency {
return false; return false;
// usual slow check // usual slow check
boost::multiprecision::uint512_t hashVal = 0; boost::multiprecision::uint512_t hashVal = 0;
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {
hashVal <<= 64; hashVal <<= 64;
hashVal |= swap64le(((const uint64_t *) &h)[3-i]); 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)); cut_end = cut_begin + (REDEF_DIFFICULTY_WINDOW - (REDEF_DIFFICULTY_CUT_OLD + REDEF_DIFFICULTY_CUT_LAST));
if (cut_end > length) if (cut_end > length)
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"); 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); CHECK_AND_ASSERT_MES(length <= DIFFICULTY_WINDOW, 0, "length <= DIFFICULTY_WINDOW check failed, length=" << length);
sort(timestamps.begin(), timestamps.end(), std::greater<uint64_t>()); sort(timestamps.begin(), timestamps.end(), std::greater<uint64_t>());
static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Cut length is too large"); 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_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_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; uint64_t devider = 1;
wide_difficulty_type summ = dif_slow; wide_difficulty_type summ = dif_slow;
if (dif_medium != 0) if (dif_medium != 0)

View file

@ -8,13 +8,13 @@
namespace currency namespace currency
{ {
#ifndef TESTNET #ifndef TESTNET
const genesis_tx_raw_data ggenesis_tx_raw = { { 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 }, 0xe980800100000101,0xfbfa3a0316deb183,0x0e4d0bf7103b2df2,0x682df55627fc33ed,0xcd945b3d70689611,0x16050066b218269a,0x34af8b24a9c955d2,0x3f514b3a2be34ee9,0xb6525b442410e776,0x256d4d83666fb42a,0x6b61742074496b13,0x6e61766461207365,0x20666f2065676174,0x7574616e20656874,0x6e6920666f206572,0x6f6974616d726f66,0x20676e696562206e,0x206f742079736165,0x6220646165727073,0x2064726168207475,0x6c66697473206f74,0x746153202d202e65,0x6b614e206968736f,0x0b00156f746f6d61},
{ 0x17,0x86,0xd6,0x0e,0x0a,0x00,0x00 } }; {0x02,0x8a,0x56,0x0e,0x0a,0x00,0x00}};
#else #else
const genesis_tx_raw_data ggenesis_tx_raw = {{ 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}, 0xe980800100000101,0xfbfa3a0316deb183,0x0e4d0bf7103b2df2,0x682df55627fc33ed,0xcd945b3d70689611,0x16050066b218269a,0x34af8b24a9c955d2,0x3f514b3a2be34ee9,0xb6525b442410e776,0x256d4d83666fb42a,0x6b61742074496b13,0x6e61766461207365,0x20666f2065676174,0x7574616e20656874,0x6e6920666f206572,0x6f6974616d726f66,0x20676e696562206e,0x206f742079736165,0x6220646165727073,0x2064726168207475,0x6c66697473206f74,0x746153202d202e65,0x6b614e206968736f,0x0b00156f746f6d61},
{0x00,0x00}}; {0x02,0x8a,0x56,0x0e,0x0a,0x00,0x00}};
#endif #endif
} }

View file

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

View file

@ -10,48 +10,21 @@
namespace currency namespace currency
{ {
#ifndef TESTNET #ifndef TESTNET
const std::string ggenesis_tx_pub_key_str = "88bad574f43d16719a44152089f88672b4ecd93333c922b3ebdfbd1655fa6403"; 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); 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] = { extern const genesis_tx_dictionary_entry ggenesis_dict[1];
{ 898363347618325980ULL,7 }, const genesis_tx_dictionary_entry ggenesis_dict[1] = {
{ 1234271292339965434ULL,1 }, {1056117391700764468ULL,0}
{ 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 }
}; };
#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) #pragma pack(pop)
#ifndef TESTNET #ifndef TESTNET
extern const genesis_tx_dictionary_entry ggenesis_dict[26]; extern const genesis_tx_dictionary_entry ggenesis_dict[1];
#else #else
extern const genesis_tx_dictionary_entry ggenesis_dict[5]; extern const genesis_tx_dictionary_entry ggenesis_dict[1];
#endif #endif
extern const crypto::public_key ggenesis_tx_pub_key; extern const crypto::public_key ggenesis_tx_pub_key;

View file

@ -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 #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" #define LOG_DEFAULT_CHANNEL "tx_pool"
ENABLE_CHANNEL_BY_DEFAULT("tx_pool"); ENABLE_CHANNEL_BY_DEFAULT("tx_pool");
@ -52,7 +52,7 @@ namespace currency
m_db(nullptr, m_dummy_rw_lock), m_db(nullptr, m_dummy_rw_lock),
m_db_transactions(m_db), m_db_transactions(m_db),
m_db_black_tx_list(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_key_images_set(m_db),
m_db_alias_names(m_db), m_db_alias_names(m_db),
m_db_alias_addresses(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]); 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)) 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); LOG_ERROR("Related multisig tx not found, multisig_out_id=" << ms_in.multisig_out_id);
return false; return false;
} }
auto related_tx_ptr = m_blockchain.get_tx_chain_entry(related_tx_id); auto related_tx_ptr = m_blockchain.get_tx_chain_entry(related_tx_id);
if (!related_tx_ptr) 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); << "(discovered by reviewing tx " << get_transaction_hash(tx) <<") tx not found in blockchain, multisig_out_id=" << ms_in.multisig_out_id);
return false; return false;
} }
if (get_tx_fee(tx) < get_tx_fee(related_tx_ptr->tx)) 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)); 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 // defaults
tvc.m_added_to_pool = false; tvc.m_added_to_pool = false;
tvc.m_verification_failed = true; tvc.m_verification_failed = true;
if (!kept_by_block && !from_core && m_blockchain.is_in_checkpoint_zone()) 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 // 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) << ")"); ", diff: " << epee::misc_utils::get_time_interval_string(ts_median + TX_EXPIRATION_MEDIAN_SHIFT - tx_expiration_time) << ")");
tvc.m_verification_failed = true; tvc.m_verification_failed = true;
return false; return false;
} }
TIME_MEASURE_FINISH_PD(expiration_validate_time); TIME_MEASURE_FINISH_PD(expiration_validate_time);
@ -170,7 +169,7 @@ namespace currency
{ {
if(!validate_tx_semantic(tx, blob_size)) if(!validate_tx_semantic(tx, blob_size))
{ {
// tx semantics check failed // tx semantics check failed
LOG_PRINT_RED_L0("Transaction " << id << " semantics check failed "); LOG_PRINT_RED_L0("Transaction " << id << " semantics check failed ");
tvc.m_verification_failed = true; tvc.m_verification_failed = true;
@ -188,13 +187,13 @@ namespace currency
{ {
//if (is_valid_contract_finalization_tx(tx)) //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 // 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 // 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. // fee rules had been changed, so it's ok, let it in.
//} //}
//else //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)); 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_verification_failed = false;
tvc.m_should_be_relayed = false; tvc.m_should_be_relayed = false;
@ -225,7 +224,6 @@ namespace currency
TIME_MEASURE_FINISH_PD(check_inputs_time); 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); 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); TIME_MEASURE_FINISH_PD(tx_processing_time);
tvc.m_added_to_pool = true; 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) 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); extra_alias_entry eai2 = AUTO_VAL_INIT(eai2);
bool already_have_alias_registered = m_blockchain.get_alias_info(eai.m_alias, eai2); bool already_have_alias_registered = m_blockchain.get_alias_info(eai.m_alias, eai2);
//size_t alias_size = eai.m_alias.size(); //size_t alias_size = eai.m_alias.size();
if (!is_in_block && !eai.m_sign.size() && already_have_alias_registered) 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"); 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() && if (!is_in_block && !eai.m_sign.size() &&
prev_alias.size()) prev_alias.size())
{ {
LOG_PRINT_L0("Address \"" << get_account_address_as_str(eai.m_address) LOG_PRINT_L0("Address \"" << get_account_address_as_str(eai.m_address)
<< "\" already registered with \""<< prev_alias << "\" already registered with \""<< prev_alias
<< "\" alias in blockchain (new alias: \"" << eai.m_alias << "\"), transaction rejected"); << "\" alias in blockchain (new alias: \"" << eai.m_alias << "\"), transaction rejected");
r = false; r = false;
return false; // stop handling 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) bool tx_memory_pool::take_tx(const crypto::hash &id, transaction &tx, size_t& blob_size, uint64_t& fee)
{ {
m_db_transactions.begin_transaction(); m_db_transactions.begin_transaction();
misc_utils::auto_scope_leave_caller seh = misc_utils::create_scope_leave_handler([&](){m_db_transactions.commit_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); auto txe_tr = m_db_transactions.find(id);
if (txe_tr == m_db_transactions.end()) if (txe_tr == m_db_transactions.end())
return false; return false;
@ -431,13 +429,13 @@ namespace currency
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::remove_stuck_transactions() bool tx_memory_pool::remove_stuck_transactions()
{ {
if (!CRITICAL_SECTION_TRY_LOCK(m_remove_stuck_txs_lock)) if (!CRITICAL_SECTION_TRY_LOCK(m_remove_stuck_txs_lock))
return true; return true;
CRITICAL_REGION_LOCAL(m_remove_stuck_txs_lock); CRITICAL_REGION_LOCAL(m_remove_stuck_txs_lock);
CRITICAL_SECTION_UNLOCK(m_remove_stuck_txs_lock);// release try_lock iteration CRITICAL_SECTION_UNLOCK(m_remove_stuck_txs_lock);// release try_lock iteration
m_db_transactions.begin_transaction(); m_db_transactions.begin_transaction();
misc_utils::auto_scope_leave_caller seh = misc_utils::create_scope_leave_handler([&](){m_db_transactions.commit_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; transaction tx;
bool kept_by_block; bool kept_by_block;
}; };
std::vector<tx_to_delete_entry> to_delete; std::vector<tx_to_delete_entry> to_delete;
const uint64_t tx_expiration_ts_median = m_blockchain.get_tx_expiration_median(); 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) 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, //never remove transactions which related to alt blocks,
//or we can get network split as a worst case (impossible to switch to //or we can get network split as a worst case (impossible to switch to
//altchain if it won, and node stuck forever). //altchain if it won, and node stuck forever).
if (m_blockchain.is_tx_related_to_altblock(h)) if (m_blockchain.is_tx_related_to_altblock(h))
return true; return true;
@ -503,7 +501,7 @@ namespace currency
return true; return true;
}); });
for (auto& e : to_delete) for (auto& e : to_delete)
{ {
m_db_transactions.erase(e.hash); m_db_transactions.erase(e.hash);
@ -514,7 +512,7 @@ namespace currency
return true; 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(); 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); m_blockchain.fill_tx_rpc_details(trei, ptei->tx, nullptr, id, ptei->receive_time, false);
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::get_transaction(const crypto::hash& id, transaction& tx) const 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 bool tx_memory_pool::have_tx(const crypto::hash &id) const
{ {
if(m_db_transactions.get(id)) if(m_db_transactions.get(id))
return true; return true;
@ -746,21 +744,21 @@ namespace currency
} }
return false; return false;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::on_tx_add(crypto::hash tx_id, const transaction& tx, bool kept_by_block) 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_key_images(tx_id, tx, kept_by_block);
insert_alias_info(tx); insert_alias_info(tx);
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::on_tx_remove(const crypto::hash &id, const transaction& tx, bool kept_by_block) 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_key_images(id, tx, kept_by_block);
remove_alias_info(tx); remove_alias_info(tx);
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::insert_alias_info(const transaction& tx) bool tx_memory_pool::insert_alias_info(const transaction& tx)
{ {
tx_extra_info ei = AUTO_VAL_INIT(ei); tx_extra_info ei = AUTO_VAL_INIT(ei);
@ -774,10 +772,10 @@ namespace currency
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::remove_alias_info(const transaction& tx) bool tx_memory_pool::remove_alias_info(const transaction& tx)
{ {
tx_extra_info ei = AUTO_VAL_INIT(ei); tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(tx, 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"); CHECK_AND_ASSERT_MES(r, false, "failed to validate transaction extra on unprocess_blockchain_tx_extra");
@ -789,7 +787,7 @@ namespace currency
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::remove_key_images(const crypto::hash &tx_id, const transaction& tx, bool kept_by_block) 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); CRITICAL_REGION_LOCAL(m_key_images_lock);
@ -797,7 +795,7 @@ namespace currency
{ {
crypto::key_image k_image = AUTO_VAL_INIT(k_image); crypto::key_image k_image = AUTO_VAL_INIT(k_image);
if (get_key_image_from_txin_v(in, 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 it_map = epee::misc_utils::it_get_or_insert_value_initialized(m_key_images, k_image);
auto& id_set = it_map->second; auto& id_set = it_map->second;
size_t count_before = id_set.size(); 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 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) m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{ {
for (auto& in : tx_entry.tx.vin) for (auto& in : tx_entry.tx.vin)
@ -854,7 +852,7 @@ namespace currency
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
void tx_memory_pool::purge_transactions() void tx_memory_pool::purge_transactions()
{ {
m_db.begin_transaction(); m_db.begin_transaction();
m_db_transactions.clear(); m_db_transactions.clear();
m_db.commit_transaction(); m_db.commit_transaction();
@ -871,7 +869,7 @@ namespace currency
CIRITCAL_OPERATION(m_key_images,clear()); 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 :( //not the best implementation at this time, sorry :(
@ -914,7 +912,7 @@ namespace currency
{ {
return false; return false;
} }
if (!check_tx_multisig_ins_and_outs(txd.tx, false)) if (!check_tx_multisig_ins_and_outs(txd.tx, false))
return false; return false;
@ -923,7 +921,7 @@ namespace currency
return true; 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(); LOCAL_READONLY_TRANSACTION();
for(size_t i = 0; i!= tx.vin.size(); i++) for(size_t i = 0; i!= tx.vin.size(); i++)
@ -952,14 +950,14 @@ namespace currency
return true; 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; std::stringstream ss;
if (short_format) if (short_format)
{ {
std::list<std::pair<crypto::hash, tx_details>> txs; 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; }); 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()) if (txs.empty())
@ -967,7 +965,7 @@ namespace currency
// sort output by receive time // 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; }); 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; 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; size_t i = 0;
for (auto& tx : txs) for (auto& tx : txs)
{ {
@ -990,9 +988,9 @@ namespace currency
} }
return ss.str(); return ss.str();
} }
// long format // long format
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry) m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{ {
auto& txd = tx_entry; auto& txd = tx_entry;
@ -1012,32 +1010,32 @@ namespace currency
return ss.str(); return ss.str();
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
bool tx_memory_pool::fill_block_template(block &bl, bool tx_memory_pool::fill_block_template(block &bl,
bool pos, bool pos,
size_t median_size, size_t median_size,
const boost::multiprecision::uint128_t& already_generated_coins, const boost::multiprecision::uint128_t& already_generated_coins,
size_t &total_size, size_t &total_size,
uint64_t &fee, uint64_t &fee,
uint64_t height, uint64_t height,
const std::list<transaction>& explicit_txs const std::list<transaction>& explicit_txs
) )
{ {
LOCAL_READONLY_TRANSACTION(); LOCAL_READONLY_TRANSACTION();
//typedef transactions_container::value_type txv; //typedef transactions_container::value_type txv;
typedef std::pair<crypto::hash, std::shared_ptr<const tx_details> > txv; typedef std::pair<crypto::hash, std::shared_ptr<const tx_details> > txv;
std::vector<txv> txs_v; std::vector<txv> txs_v;
txs_v.reserve(m_db_transactions.size()); txs_v.reserve(m_db_transactions.size());
std::vector<size_t> txs; // selected transactions, vector of indices of txs_v 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;}); 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); txs.resize(txs_v.size(), SIZE_MAX);
for (uint64_t i = 0; i != txs_v.size(); i++) for (uint64_t i = 0; i != txs_v.size(); i++)
{ {
auto& k = txs_v[i].first; auto& k = txs_v[i].first;
txs_v[i].second = m_db_transactions.get(k); txs_v[i].second = m_db_transactions.get(k);
if (!txs_v[i].second) if (!txs_v[i].second)
@ -1048,8 +1046,8 @@ namespace currency
txs[i] = i; txs[i] = i;
} }
std::sort(txs.begin(), txs.end(), [&txs_v](size_t a, size_t b) -> bool { std::sort(txs.begin(), txs.end(), [&txs_v](size_t a, size_t b) -> bool {
boost::multiprecision::uint128_t a_, b_; boost::multiprecision::uint128_t a_, b_;
a_ = boost::multiprecision::uint128_t(txs_v[a].second->fee) * txs_v[b].second->blob_size; 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 // scan txs for alias reg requests - if there are such requests, don't process alias updates
bool alias_regs_exist = false; bool alias_regs_exist = false;
for (auto txi : txs) for (auto txi : txs)
{ {
tx_extra_info ei = AUTO_VAL_INIT(ei); tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(txs_v[txi].second->tx, ei); bool r = parse_and_validate_tx_extra(txs_v[txi].second->tx, ei);
@ -1097,8 +1095,8 @@ namespace currency
{ {
txs[i] = SIZE_MAX; txs[i] = SIZE_MAX;
continue; continue;
} }
// alias checks // alias checks
tx_extra_info ei = AUTO_VAL_INIT(ei); tx_extra_info ei = AUTO_VAL_INIT(ei);
bool r = parse_and_validate_tx_extra(tx.second->tx, 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 //do check if it's changed and reassign it to db if needed
tx_details local_copy_txd = *(tx.second); tx_details local_copy_txd = *(tx.second);
bool is_tx_ready_to_go_result = is_transaction_ready_to_go(local_copy_txd, tx.first); 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)) (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(); m_db_transactions.begin_transaction();
@ -1169,7 +1167,7 @@ namespace currency
} }
} }
} }
// add explicit transactions // add explicit transactions
for (const auto& tx : explicit_txs) for (const auto& tx : explicit_txs)
{ {
fee += get_tx_fee(tx); fee += get_tx_fee(tx);
@ -1212,7 +1210,7 @@ namespace currency
} }
const std::string db_folder_path = dbbs.get_pool_db_folder_path(); const std::string db_folder_path = dbbs.get_pool_db_folder_path();
LOG_PRINT_L0("Loading blockchain from " << db_folder_path << "..."); LOG_PRINT_L0("Loading blockchain from " << db_folder_path << "...");
bool db_opened_okay = false; 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) if (m_db_storage_major_compatibility_version > 0 && m_db_storage_major_compatibility_version != TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION)
{ {
need_reinit = true; 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) if (need_reinit)
@ -1293,10 +1291,31 @@ namespace currency
return true; return true;
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
void tx_memory_pool::remove_incompatible_txs()
{
std::vector<crypto::hash> invalid_tx_ids;
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& h, const tx_details &tx_entry)
{
if (!m_blockchain.validate_tx_for_hardfork_specific_terms(tx_entry.tx, h))
invalid_tx_ids.push_back(h);
return true;
});
for(const auto& id : invalid_tx_ids)
{
transaction tx{};
size_t blob_size = 0;
uint64_t fee = 0;
take_tx(id, tx, blob_size, fee);
LOG_PRINT_L0("tx " << id << " was incompatible with the hardfork rules and removed");
}
}
//---------------------------------------------------------------------------------
bool tx_memory_pool::load_keyimages_cache() bool tx_memory_pool::load_keyimages_cache()
{ {
CRITICAL_REGION_LOCAL(m_key_images_lock); 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() bool tx_memory_pool::deinit()
@ -1366,9 +1385,9 @@ namespace currency
return false; 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(); LOCAL_READONLY_TRANSACTION();
std::vector<ms_out_info> ms_ids; std::vector<ms_out_info> ms_ids;
collect_multisig_ids_from_tx(tx, ms_ids); collect_multisig_ids_from_tx(tx, ms_ids);
@ -1394,7 +1413,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 << 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)); " that is already in the pool in tx " << get_transaction_hash(tx_entry.tx));
return false; return false;
} }
return true; return true;
}); });
if (has_found) if (has_found)
@ -1406,7 +1425,7 @@ namespace currency
} }
} }
#undef LOG_DEFAULT_CHANNEL #undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL NULL #define LOG_DEFAULT_CHANNEL NULL

View file

@ -138,6 +138,8 @@ namespace currency
bool remove_stuck_transactions(); // made public to be called from coretests bool remove_stuck_transactions(); // made public to be called from coretests
void remove_incompatible_txs(); // made public to be called after the BCS is loaded and hardfork info is ready
private: private:
bool on_tx_add(crypto::hash tx_id, const transaction& tx, bool kept_by_block); bool on_tx_add(crypto::hash tx_id, const transaction& tx, bool kept_by_block);
bool on_tx_remove(const crypto::hash &tx_id, const transaction& tx, bool kept_by_block); bool on_tx_remove(const crypto::hash &tx_id, const transaction& tx, bool kept_by_block);

View file

@ -29,7 +29,7 @@
#include <stdint.h> #include <stdint.h>
#include <math.h> #include <math.h>
#include "currency_core/currency_config.h" #include "currency_core/currency_config.h"
#define GUI_LINK_NAME "Zano" #define GUI_LINK_NAME "Lethean"
#ifdef WIN32 #ifdef WIN32
#ifdef _WIN32_WINNT #ifdef _WIN32_WINNT
@ -245,24 +245,24 @@ namespace gui_tools
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m // based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl); LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl) LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
{ {
SInt32 macos_ver_maj, macos_ver_min; SInt32 macos_ver_maj, macos_ver_min;
Gestalt(gestaltSystemVersionMajor, &macos_ver_maj); // very old and deprecated, consider change Gestalt(gestaltSystemVersionMajor, &macos_ver_maj); // very old and deprecated, consider change
Gestalt(gestaltSystemVersionMinor, &macos_ver_min); // 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 // loop through the list of startup items and try to find the bitcoin app
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL); CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL);
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
CFURLRef currentItemURL = NULL; CFURLRef currentItemURL = NULL;
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100 #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))) 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) 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 #else
LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL); LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
#endif #endif
if(currentItemURL && CFEqual(currentItemURL, findUrl)) { if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
// found // found
CFRelease(currentItemURL); CFRelease(currentItemURL);
@ -285,7 +285,7 @@ namespace gui_tools
} }
return NULL; return NULL;
} }
bool GetStartOnSystemStartup() bool GetStartOnSystemStartup()
{ {
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
@ -293,13 +293,13 @@ namespace gui_tools
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
return !!foundItem; // return boolified object return !!foundItem; // return boolified object
} }
bool SetStartOnSystemStartup(bool fAutoStart) bool SetStartOnSystemStartup(bool fAutoStart)
{ {
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
if(fAutoStart && !foundItem) { if(fAutoStart && !foundItem) {
// add bitcoin app to startup item list // add bitcoin app to startup item list
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, NULL, NULL, bitcoinAppUrl, NULL, NULL); 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(); 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 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(); \ #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" #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) std::wstring convert_to_lower_via_qt(const std::wstring& w)
@ -100,8 +79,6 @@ MainWindow::MainWindow()
: m_gui_deinitialize_done_1(false) : m_gui_deinitialize_done_1(false)
, m_backend_stopped_2(false) , m_backend_stopped_2(false)
, m_system_shutdown(false) , m_system_shutdown(false)
, m_view(nullptr)
, m_channel(nullptr)
, m_ui_dispatch_id_counter(0) , m_ui_dispatch_id_counter(0)
{ {
#ifndef _MSC_VER #ifndef _MSC_VER
@ -113,17 +90,7 @@ MainWindow::MainWindow()
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
m_backend.subscribe_to_core_events(nullptr); 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()) if (m_ipc_worker.joinable())
{ {
m_ipc_worker.join(); m_ipc_worker.join();
@ -288,12 +255,12 @@ QString MainWindow::call_rpc(const QString& params)
query_info.m_URI = "/json_rpc"; query_info.m_URI = "/json_rpc";
query_info.m_body = params.toStdString(); query_info.m_body = params.toStdString();
m_backend.get_rpc_server().handle_http_request(query_info, response_info, dummy_context); m_backend.get_rpc_server().handle_http_request(query_info, response_info, dummy_context);
if (response_info.m_response_code != 200) if (response_info.m_response_code != 200)
{ {
epee::json_rpc::error_response rsp; epee::json_rpc::error_response rsp;
rsp.jsonrpc = "2.0"; rsp.jsonrpc = "2.0";
rsp.error.code = response_info.m_response_code; rsp.error.code = response_info.m_response_code;
rsp.error.message = response_info.m_response_comment; 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))); 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() void MainWindow::tray_quit_requested()
{ {
TRY_ENTRY(); 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("{}"); emit quit_requested("{}");
CATCH_ENTRY2(void()); CATCH_ENTRY2(void());
} }
@ -331,7 +298,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
TRY_ENTRY(); TRY_ENTRY();
LOG_PRINT_L0("[GUI] CLOSE EVENT"); 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); << "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) else if (m_gui_deinitialize_done_1 && m_backend_stopped_2)
{ {
store_pos(true);
store_app_config(); store_app_config();
event->accept(); event->accept();
} }
@ -377,53 +343,6 @@ std::string state_to_text(int s)
CATCH_ENTRY2(""); 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() bool MainWindow::store_app_config()
{ {
TRY_ENTRY(); TRY_ENTRY();
@ -448,42 +367,21 @@ bool MainWindow::load_app_config()
bool MainWindow::init(const std::string& html_path) bool MainWindow::init(const std::string& html_path)
{ {
TRY_ENTRY(); TRY_ENTRY();
//QtWebEngine::initialize();
init_tray_icon(html_path);
set_html_path(html_path);
m_threads_pool.init(2); m_threads_pool.init(2);
m_backend.subscribe_to_core_events(this); m_backend.subscribe_to_core_events(this);
bool r = QSslSocket::supportsSsl(); bool r = QSslSocket::supportsSsl();
if (r) if (r) {
{
LOG_PRINT_GREEN("[Support SSL]: YES", LOG_LEVEL_0); LOG_PRINT_GREEN("[Support SSL]: YES", LOG_LEVEL_0);
} } else {
else
{
// QMessageBox::question(this, "OpenSSL support disabled.", "OpenSSL support disabled.",
// QMessageBox::Ok);
LOG_PRINT_RED("[Support SSL]: NO", LOG_LEVEL_0); LOG_PRINT_RED("[Support SSL]: NO", LOG_LEVEL_0);
} }
//----
this->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
m_view->setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
return true; return true;
CATCH_ENTRY2(false); CATCH_ENTRY2(false);
} }
void MainWindow::on_menu_show() void MainWindow::init_tray_icon()
{
TRY_ENTRY();
qDebug() << "Context menu: show()";
this->show();
this->activateWindow();
CATCH_ENTRY2(void());
}
void MainWindow::init_tray_icon(const std::string& html_path)
{ {
TRY_ENTRY(); TRY_ENTRY();
if (!QSystemTrayIcon::isSystemTrayAvailable()) if (!QSystemTrayIcon::isSystemTrayAvailable())
@ -492,40 +390,26 @@ void MainWindow::init_tray_icon(const std::string& html_path)
return; 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)); m_quit_action = std::unique_ptr<QAction>(new QAction(tr("&Quit"), this));
connect(m_quit_action.get(), SIGNAL(triggered()), this, SLOT(tray_quit_requested())); 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 = std::unique_ptr<QMenu>(new QMenu());
m_tray_icon_menu->addAction(m_minimize_action.get());
//m_tray_icon_menu->addAction(m_restore_action.get()); //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_menu->addAction(m_quit_action.get());
m_tray_icon = std::unique_ptr<QSystemTrayIcon>(new QSystemTrayIcon(this)); m_tray_icon = std::unique_ptr<QSystemTrayIcon>(new QSystemTrayIcon(this));
m_tray_icon->setContextMenu(m_tray_icon_menu.get()); m_tray_icon->setContextMenu(m_tray_icon_menu.get());
//setup icon //setup icon
#ifdef TARGET_OS_MAC #ifdef TARGET_OS_MAC
m_normal_icon_path = html_path + "/files/app22macos.png"; // X11 tray icon size is 22x22 QIcon qi( ":/lthn.png" );
m_blocked_icon_path = html_path + "/files/app22macos_blocked.png"; // X11 tray icon size is 22x22
#else #else
m_normal_icon_path = html_path + "/files/app22windows.png"; // X11 tray icon size is 22x22 QIcon qi( ":/lthn.png" );
m_blocked_icon_path = html_path + "/files/app22windows_blocked.png"; // X11 tray icon size
#endif #endif
//setWindowIcon(QIcon(iconPath.c_str())); //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->setIcon(qi);
m_tray_icon->setToolTip(CURRENCY_NAME_BASE); m_tray_icon->setToolTip( "Lethean Blockchain API Server");
connect(m_tray_icon.get(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
m_tray_icon->show(); m_tray_icon->show();
CATCH_ENTRY2(void()); CATCH_ENTRY2(void());
} }
@ -682,35 +566,6 @@ QString MainWindow::on_request_quit()
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); 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() bool MainWindow::on_backend_stopped()
{ {
@ -721,7 +576,7 @@ bool MainWindow::on_backend_stopped()
// if (m_quit_requested) // if (m_quit_requested)
// { // {
/*bool r = */QMetaObject::invokeMethod(this, "do_close", Qt::QueuedConnection); // /*bool r = */QMetaObject::invokeMethod(this, "do_close", Qt::QueuedConnection);
// } // }
return true; return true;
CATCH_ENTRY2(false); 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) void qt_log_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{ {
QByteArray local_msg = msg.toLocal8Bit(); QByteArray local_msg = msg.toLocal8Bit();
@ -790,13 +637,13 @@ bool MainWindow::remove_ipc()
} }
return true; return true;
} }
bool MainWindow::init_ipc_server() 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 //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 //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 //let channel to close, so it will fail later on creating channel
remove_ipc(); remove_ipc();
#define GUI_IPC_BUFFER_SIZE 10000 #define GUI_IPC_BUFFER_SIZE 10000
@ -825,7 +672,7 @@ bool MainWindow::init_ipc_server()
buff.resize(recvd_size, '*'); buff.resize(recvd_size, '*');
handle_ipc_event(buff);//todo process token handle_ipc_event(buff);//todo process token
} }
} }
remove_ipc(); remove_ipc();
LOG_PRINT_L0("IPC Handling thread finished"); LOG_PRINT_L0("IPC Handling thread finished");
} }
@ -903,20 +750,12 @@ bool MainWindow::init_backend(int argc, char* argv[])
return false; 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)) if (!m_backend.init(this))
{ {
this->show_msg_box("Failed to initialize backend, check debug logs for more details."); this->show_msg_box("Failed to initialize backend, check debug logs for more details.");
return false; return false;
} }
if (m_backend.is_qt_logs_enabled()) if (m_backend.is_qt_logs_enabled())
{ {
qInstallMessageHandler(qt_log_message_handler); qInstallMessageHandler(qt_log_message_handler);
@ -929,6 +768,8 @@ bool MainWindow::init_backend(int argc, char* argv[])
return false; return false;
} }
init_tray_icon();
return true; return true;
CATCH_ENTRY2(false); CATCH_ENTRY2(false);
} }
@ -995,11 +836,11 @@ bool MainWindow::update_wallet_status(const view::wallet_status_info& wsi)
{ {
TRY_ENTRY(); TRY_ENTRY();
m_wallet_states->operator [](wsi.wallet_id) = wsi.wallet_state; m_wallet_states->operator [](wsi.wallet_id) = wsi.wallet_state;
std::string json_str_pub; 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); 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); LOG_PRINT_L0(get_wallet_log_prefix(wsi.wallet_id) + "SENDING SIGNAL -> [update_wallet_status]:" << std::endl << json_str_pub);
std::string json_str; std::string json_str;
epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf); 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())); 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; std::string json_str;
epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf); 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 ); 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())); QMetaObject::invokeMethod(this, "update_wallets_info", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
return true; return true;
CATCH_ENTRY2(false); CATCH_ENTRY2(false);
@ -1123,7 +964,7 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei)
else if (tei.ti.unlock_time) else if (tei.ti.unlock_time)
msg += m_localization[localization_id_locked]; msg += m_localization[localization_id_locked];
show_notification(title, msg); show_notification(title, msg);
return true; return true;
@ -1154,21 +995,6 @@ bool MainWindow::wallet_sync_progress(const view::wallet_sync_progres_param& p)
CATCH_ENTRY2(false); 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) bool MainWindow::pos_block_found(const currency::block& block_found)
{ {
TRY_ENTRY(); 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) std::string get_events_que_json_string(const std::list<currency::core_event>& eq, std::string& methods_list)
{ {
TRY_ENTRY(); 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 //there is no hope to make serialization with variant list, lets handle it manual
std::stringstream ss; std::stringstream ss;
ss << "{ \"events\" : ["; ss << "{ \"events\" : [";
@ -1385,13 +1211,13 @@ void MainWindow::on_complete_events()
TIME_MEASURE_START_MS(json_buff_generate_time); TIME_MEASURE_START_MS(json_buff_generate_time);
std::string json_buff = get_events_que_json_string(m_events.m_que, methods_list); std::string json_buff = get_events_que_json_string(m_events.m_que, methods_list);
TIME_MEASURE_FINISH_MS(json_buff_generate_time); TIME_MEASURE_FINISH_MS(json_buff_generate_time);
QMetaObject::invokeMethod(this, "on_core_event", QMetaObject::invokeMethod(this, "on_core_event",
Qt::QueuedConnection, Qt::QueuedConnection,
Q_ARG(QString, QString(json_buff.c_str()))); Q_ARG(QString, QString(json_buff.c_str())));
TIME_MEASURE_FINISH_MS(core_events_handl_time); 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); << ", 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); LOG_PRINT_L2("CORE_EVENTS sent signal details: " << ENDL << json_buff);
m_events.m_que.clear(); 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 filename = m_backend.get_config_folder() + "/" + GUI_SECURE_CONFIG_FILENAME;
std::string res_body; 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) if (rsp_code != API_RETURN_CODE_OK)
{ {
view::api_response ar; 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 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_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); crypto::hash pwd_hash = crypto::cn_fast_hash(&pwd_pre_hash, sizeof pwd_pre_hash);
if (m_master_password != pwd.pass) if (m_master_password != pwd.pass)
{ {
ar.error_code = API_RETURN_CODE_WRONG_PASSWORD; 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; return API_RETURN_CODE_ACCESS_DENIED;
} }
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); 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); epee::log_space::get_set_log_detalisation_level(true, lvl.v);
default_ar.error_code = API_RETURN_CODE_OK; default_ar.error_code = API_RETURN_CODE_OK;
LOG_PRINT("[LOG LEVEL]: set to " << lvl.v, LOG_LEVEL_MIN); LOG_PRINT("[LOG LEVEL]: set to " << lvl.v, LOG_LEVEL_MIN);
return MAKE_RESPONSE(default_ar); return MAKE_RESPONSE(default_ar);
CATCH_ENTRY_FAIL_API_RESPONCE(); CATCH_ENTRY_FAIL_API_RESPONCE();
} }
@ -1759,23 +1585,23 @@ QString MainWindow::set_enable_tor(const QString& param)
// QString path = QFileDialog::getOpenFileName(this, "Select file", // QString path = QFileDialog::getOpenFileName(this, "Select file",
// "", // "",
// ""); // "");
// //
// if (!path.length()) // if (!path.length())
// { // {
// ar.error_code = API_RETURN_CODE_CANCELED; // ar.error_code = API_RETURN_CODE_CANCELED;
// return MAKE_RESPONSE(ar); // return MAKE_RESPONSE(ar);
// } // }
// //
// currency::COMMAND_RPC_GET_OFFERS_EX::response rp = AUTO_VAL_INIT(rp); // currency::COMMAND_RPC_GET_OFFERS_EX::response rp = AUTO_VAL_INIT(rp);
// ar.error_code = m_backend.get_all_offers(rp); // ar.error_code = m_backend.get_all_offers(rp);
// //
// std::string buff = epee::serialization::store_t_to_json(rp); // std::string buff = epee::serialization::store_t_to_json(rp);
// bool r = file_io_utils::save_string_to_file(path.toStdString(), buff); // bool r = file_io_utils::save_string_to_file(path.toStdString(), buff);
// if (!r) // if (!r)
// ar.error_code = API_RETURN_CODE_FAIL; // ar.error_code = API_RETURN_CODE_FAIL;
// else // else
// ar.error_code = API_RETURN_CODE_OK; // ar.error_code = API_RETURN_CODE_OK;
// //
// return MAKE_RESPONSE(ar); // return MAKE_RESPONSE(ar);
// } // }
@ -1787,55 +1613,6 @@ QString MainWindow::webkit_launched_script()
CATCH_ENTRY2(API_RETURN_CODE_INTERNAL_ERROR); 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) 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); ar.error_code = m_backend.push_offer(a.wallet_id, a.od, res_tx);
if (ar.error_code != API_RETURN_CODE_OK) if (ar.error_code != API_RETURN_CODE_OK)
return MAKE_RESPONSE(ar); return MAKE_RESPONSE(ar);
ar.response_data.success = true; 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_hash = string_tools::pod_to_hex(currency::get_transaction_hash(res_tx));
ar.response_data.tx_blob_size = currency::get_object_blobsize(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(); 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) QString MainWindow::print_log(const QString& param)
{ {
@ -2394,9 +2134,9 @@ void MainWindow::show_notification(const std::string& title, const std::string&
{ {
TRY_ENTRY(); TRY_ENTRY();
LOG_PRINT_L1("system notification: \"" << title << "\", \"" << message << "\""); LOG_PRINT_L1("system notification: \"" << title << "\", \"" << message << "\"");
// it's expected that title and message are utf-8 encoded! // it's expected that title and message are utf-8 encoded!
#if !defined(__APPLE__) #if !defined(__APPLE__)
// use Qt tray icon to show messages on Windows and Linux // 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!"); 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 #endif
CATCH_ENTRY2(void()); 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 // class MediatorObject : public QObject
// { // {
// Q_OBJECT // Q_OBJECT
// //
// public: // public:
// //
// signals : // signals :
// /*! // /*!
// This signal is emitted from the C++ side and the text displayed on the HTML client side. // 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); // void from_c_to_html(const QString &text);
// //
// public slots: // public slots:
// /*! // /*!
// This slot is invoked from the HTML client side and the text displayed on the server side. // 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 currency::i_core_event_handler,
public view::i_view, public view::i_view,
public QAbstractNativeEventFilter public QAbstractNativeEventFilter
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(); MainWindow();
~MainWindow(); ~MainWindow();
bool init_backend(int argc, char* argv[]); bool init_backend(int argc, char* argv[]);
bool show_inital();
void show_notification(const std::string& title, const std::string& message); void show_notification(const std::string& title, const std::string& message);
bool handle_ipc_event(const std::string& arguments); bool handle_ipc_event(const std::string& arguments);
struct app_config struct app_config
{ {
epee::kvserializable_pair<int64_t, int64_t> m_window_position; epee::kvserializable_pair<int64_t, int64_t> m_window_position;
epee::kvserializable_pair<int64_t, int64_t> m_window_size; epee::kvserializable_pair<int64_t, int64_t> m_window_size;
bool is_maximazed; bool is_maximazed;
@ -86,12 +85,9 @@ public:
protected slots: protected slots:
void on_load_finished(bool ok); void on_load_finished(bool ok);
bool do_close();
public slots: public slots:
QString show_openfile_dialog(const QString& param);
QString show_savefile_dialog(const QString& param);
QString open_wallet(const QString& param); QString open_wallet(const QString& param);
QString get_my_offers(const QString& param); QString get_my_offers(const QString& param);
QString get_fav_offers(const QString& param); QString get_fav_offers(const QString& param);
@ -157,7 +153,6 @@ public:
QString toggle_autostart(const QString& param); QString toggle_autostart(const QString& param);
QString is_valid_restore_wallet_text(const QString& param); QString is_valid_restore_wallet_text(const QString& param);
QString get_seed_phrase_info(const QString& param); QString get_seed_phrase_info(const QString& param);
QString print_text(const QString& param);
QString print_log(const QString& param); QString print_log(const QString& param);
QString set_clipboard(const QString& param); QString set_clipboard(const QString& param);
QString set_localization_strings(const QString str); QString set_localization_strings(const QString str);
@ -167,16 +162,15 @@ public:
QString get_exchange_last_top(const QString& params); QString get_exchange_last_top(const QString& params);
QString get_tx_pool_info(); QString get_tx_pool_info();
QString get_default_fee(); QString get_default_fee();
QString get_options(); QString get_options();
void bool_toggle_icon(const QString& param); 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 remove_custom_asset_id(const QString& param);
QString get_wallet_info(const QString& param); QString get_wallet_info(const QString& param);
QString create_ionic_swap_proposal(const QString& param); QString create_ionic_swap_proposal(const QString& param);
QString get_ionic_swap_proposal_info(const QString& param); QString get_ionic_swap_proposal_info(const QString& param);
QString accept_ionic_swap_proposal(const QString& param); QString accept_ionic_swap_proposal(const QString& param);
bool get_is_disabled_notifications(); bool get_is_disabled_notifications();
bool set_is_disabled_notifications(const bool& param); bool set_is_disabled_notifications(const bool& param);
QString export_wallet_history(const QString& param); QString export_wallet_history(const QString& param);
@ -184,15 +178,13 @@ public:
//QString check_available_sources(const QString& param); //QString check_available_sources(const QString& param);
QString open_url_in_browser(const QString& param); QString open_url_in_browser(const QString& param);
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void tray_quit_requested(); void tray_quit_requested();
void on_menu_show();
QString is_remnotenode_mode_preconfigured(); QString is_remnotenode_mode_preconfigured();
QString start_backend(const QString& params); QString start_backend(const QString& params);
QString async_call(const QString& func_name, const QString& params); QString async_call(const QString& func_name, const QString& params);
QString sync_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 //for test purposes onlys
QString request_dummy(); QString request_dummy();
@ -223,7 +215,6 @@ private:
//------- i_view --------- //------- i_view ---------
virtual bool update_daemon_status(const view::daemon_status_info& info); virtual bool update_daemon_status(const view::daemon_status_info& info);
virtual bool on_backend_stopped(); 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_wallet_status(const view::wallet_status_info& wsi);
virtual bool update_wallets_info(const view::wallets_summary_info& wsi); virtual bool update_wallets_info(const view::wallets_summary_info& wsi);
virtual bool money_transfer(const view::transfer_event_info& tei); virtual bool money_transfer(const view::transfer_event_info& tei);
@ -239,35 +230,24 @@ private:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void contextMenuEvent(QContextMenuEvent * event);
void changeEvent(QEvent *e);
void on_maximized(); void on_maximized();
bool handle_deeplink_params_in_commandline(); bool handle_deeplink_params_in_commandline();
//void setOrientation(Qt::ScreenOrientation orientation); //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); bool set_html_path(const std::string& path);
void load_file(const QString &fileName); 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 store_app_config();
bool load_app_config(); bool load_app_config();
bool init_window(); bool init_window();
bool init_ipc_server(); bool init_ipc_server();
bool remove_ipc(); bool remove_ipc();
std::string get_wallet_log_prefix(size_t wallet_id) const { return m_backend.get_wallet_log_prefix(wallet_id); } 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 // DATA
wallets_manager m_backend; wallets_manager m_backend;
//std::atomic<bool> m_quit_requested; //std::atomic<bool> m_quit_requested;
@ -279,7 +259,6 @@ private:
std::string m_master_password; std::string m_master_password;
app_config m_config; app_config m_config;
epee::locked_object<std::map<uint64_t, uint64_t>> m_wallet_states; epee::locked_object<std::map<uint64_t, uint64_t>> m_wallet_states;
@ -287,7 +266,7 @@ private:
struct events_que_struct struct events_que_struct
{ {
std::list<currency::core_event> m_que; std::list<currency::core_event> m_que;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_que) KV_SERIALIZE(m_que)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
@ -299,10 +278,10 @@ private:
enum localization_string_indices enum localization_string_indices
{ {
// order is surprisingly important here! (see also updateLocalisation in AppController.js) // 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_received,
localization_id_is_confirmed, localization_id_is_confirmed,
localization_id_income_transfer_unconfirmed, localization_id_income_transfer_unconfirmed,
localization_id_income_transfer_confirmed, localization_id_income_transfer_confirmed,
localization_id_mined, localization_id_mined,
localization_id_locked, 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"

@ -1 +0,0 @@
Subproject commit f8e9556fbaccd49841ce91afc3c90c8e3142ac95

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

@ -30,8 +30,8 @@
#include "currency_core/currency_config.h" #include "currency_core/currency_config.h"
using namespace epee; using namespace epee;
#undef LOG_DEFAULT_CHANNEL #undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "p2p" #define LOG_DEFAULT_CHANNEL "p2p"
ENABLE_CHANNEL_BY_DEFAULT(LOG_DEFAULT_CHANNEL); ENABLE_CHANNEL_BY_DEFAULT(LOG_DEFAULT_CHANNEL);
#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+13) #define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+13)
@ -64,13 +64,13 @@ namespace nodetool
public: public:
typedef t_payload_net_handler payload_net_handler; typedef t_payload_net_handler payload_net_handler;
// Some code // Some code
node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler), node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler),
m_allow_local_ip(false), m_allow_local_ip(false),
m_hide_my_port(false), m_hide_my_port(false),
m_offline_mode(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_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_startup_time(time(nullptr)),
m_config{}, m_config{},
m_have_address(false), m_have_address(false),
@ -99,7 +99,7 @@ namespace nodetool
template <class Archive, class t_version_type> template <class Archive, class t_version_type>
void serialize(Archive &a, const t_version_type ver) void serialize(Archive &a, const t_version_type ver)
{ {
if(ver < CURRENT_P2P_STORAGE_ARCHIVE_VER) if(ver < CURRENT_P2P_STORAGE_ARCHIVE_VER)
return; return;
time_t local_time = time(nullptr); time_t local_time = time(nullptr);
a & local_time; a & local_time;
@ -202,7 +202,7 @@ namespace nodetool
size_t get_random_index_with_fixed_probability(size_t max_index); size_t get_random_index_with_fixed_probability(size_t max_index);
bool is_peer_id_used(const peerid_type id); bool is_peer_id_used(const peerid_type id);
bool is_peer_used(const peerlist_entry& peer); 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> template<class t_callback>
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback& cb); 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); bool make_expected_connections_count(bool white_list, size_t expected_connections);
@ -222,7 +222,7 @@ namespace nodetool
//debug functions //debug functions
std::string print_connections_container(); std::string print_connections_container();
typedef net_utils::boosted_tcp_server<levin::async_protocol_handler<p2p_connection_context> > net_server; typedef net_utils::boosted_tcp_server<levin::async_protocol_handler<p2p_connection_context> > net_server;
struct config 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<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*30, false> m_peerlist_store_interval;
math_helper::once_a_time_seconds<60> m_remove_dead_conn_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*/ /*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<60, false> m_calm_alert_interval;
math_helper::once_a_time_seconds<10, false> m_urgent_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; maintainers_entry m_maintainers_entry_local;
uint8_t m_alert_mode; uint8_t m_alert_mode;
critical_section m_maintainers_local_lock; critical_section m_maintainers_local_lock;
critical_section m_blocked_ips_lock; critical_section m_blocked_ips_lock;
std::map<uint32_t, time_t> m_blocked_ips; std::map<uint32_t, time_t> m_blocked_ips;

View file

@ -22,7 +22,7 @@
namespace nodetool namespace nodetool
{ {
//zero network before launch //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 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<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<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<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_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<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); 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_allow_local_ip);
command_line::add_arg(desc, arg_p2p_add_peer); 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_add_priority_node);
command_line::add_arg(desc, arg_p2p_seed_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_hide_my_port);
command_line::add_arg(desc, arg_p2p_offline_mode); 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_disable_debug_reqs);
command_line::add_arg(desc, arg_p2p_use_only_priority_nodes); 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; std::string state_file_path = m_config_folder + "/" + P2P_NET_DATA_FILENAME;
boost::system::error_code ec = AUTO_VAL_INIT(ec); boost::system::error_code ec = AUTO_VAL_INIT(ec);
std::time_t last_update_time = boost::filesystem::last_write_time(state_file_path, 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, //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 //then it outdated and we need to fetch peerlist from seed nodes
if (!ec && time(nullptr) - last_update_time < 86400 * 14) if (!ec && time(nullptr) - last_update_time < 86400 * 14)
{ {
tools::unserialize_obj_from_file(*this, state_file_path); tools::unserialize_obj_from_file(*this, state_file_path);
} }
@ -80,7 +80,7 @@ namespace nodetool
m_config.m_peer_id = crypto::rand<uint64_t>(); m_config.m_peer_id = crypto::rand<uint64_t>();
handle_alert_conditions(); handle_alert_conditions();
//at this moment we have hardcoded config //at this moment we have hardcoded config
m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL; m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT; m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT;
@ -111,7 +111,7 @@ namespace nodetool
if (!m_ip_auto_blocking_enabled) if (!m_ip_auto_blocking_enabled)
return true; return true;
return !is_ip_in_blacklist(addr); return !is_ip_in_blacklist(addr);
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
@ -204,7 +204,7 @@ namespace nodetool
} }
if (command_line::has_arg(vm, arg_p2p_add_peer)) if (command_line::has_arg(vm, arg_p2p_add_peer))
{ {
std::vector<std::string> perrs = command_line::get_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) for(const std::string& pr_str: perrs)
{ {
@ -217,7 +217,7 @@ namespace nodetool
} }
if (command_line::has_arg(vm, arg_p2p_add_priority_node)) 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); std::vector<std::string> perrs = command_line::get_arg(vm, arg_p2p_add_priority_node);
for(const std::string& pr_str: perrs) for(const std::string& pr_str: perrs)
{ {
@ -243,8 +243,8 @@ namespace nodetool
} }
} }
if(command_line::has_arg(vm, arg_p2p_hide_my_port)) if(command_line::has_arg(vm, arg_p2p_hide_my_port))
m_hide_my_port = true; m_hide_my_port = true;
return true; return true;
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
@ -311,27 +311,12 @@ namespace nodetool
{ {
#ifndef TESTNET #ifndef TESTNET
//TODO: //TODO:
//ADD_HARDCODED_SEED_NODE(std::string("0.0.0.0:") + std::to_string(P2P_DEFAULT_PORT)); ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST, P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.43.225", P2P_DEFAULT_PORT); ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST2, 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);
#else #else
// TESTNET ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST, P2P_DEFAULT_PORT);
ADD_HARDCODED_SEED_NODE("95.217.43.225", P2P_DEFAULT_PORT); ADD_HARDCODED_SEED_NODE(SEED_NODE_HOST2, 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);
#endif #endif
bool res = handle_command_line(vm); bool res = handle_command_line(vm);
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");
m_config_folder = command_line::get_arg(vm, command_line::arg_data_dir); 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) for(auto& p: m_command_line_peers)
m_peerlist.append_with_peer_white(p); m_peerlist.append_with_peer_white(p);
//only in case if we really sure that we have external visible ip //only in case if we really sure that we have external visible ip
m_have_address = true; m_have_address = true;
m_ip_address = 0; m_ip_address = 0;
@ -423,7 +408,7 @@ namespace nodetool
} }
std::string state_file_path = m_config_folder + "/" + P2P_NET_DATA_FILENAME; 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); CATCH_ENTRY_L0("node_server<t_payload_net_handler>::save", false);
return true; return true;
} }
@ -502,11 +487,11 @@ namespace nodetool
get_local_node_data(arg.node_data); get_local_node_data(arg.node_data);
m_payload_handler.get_payload_sync_data(arg.payload_data); m_payload_handler.get_payload_sync_data(arg.payload_data);
fill_maintainers_entry(arg.maintrs_entry); fill_maintainers_entry(arg.maintrs_entry);
simple_event ev; simple_event ev;
std::atomic<bool> hsh_result(false); 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) [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();}); 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); m_payload_handler.get_payload_sync_data(arg.payload_data);
fill_maintainers_entry(arg.maintrs_entry); 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) [this](int code, const typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context)
{ {
if(code < 0) 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); 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; return true;
} }
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
template<class t_payload_net_handler> template<class t_payload_net_handler>
void node_server<t_payload_net_handler>::cache_connect_fail_info(const net_address& addr) 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")); 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)) if(!try_to_connect_and_handshake_with_new_peer(pe.adr, false, pe.last_seen, use_white_list))
{ {
cache_connect_fail_info(pe.adr); cache_connect_fail_info(pe.adr);
@ -855,7 +840,7 @@ namespace nodetool
size_t try_count = 0; size_t try_count = 0;
size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size(); size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size();
while(true) while(true)
{ {
if(m_net_server.is_stop_signal_sent()) if(m_net_server.is_stop_signal_sent())
return false; 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) 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"); 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;
} }
return true; return true;
@ -1076,7 +1061,7 @@ namespace nodetool
node_data.peer_id = m_config.m_peer_id; node_data.peer_id = m_config.m_peer_id;
if(!m_hide_my_port) if(!m_hide_my_port)
node_data.my_port = m_external_port ? m_external_port : m_listenning_port; node_data.my_port = m_external_port ? m_external_port : m_listenning_port;
else else
node_data.my_port = 0; node_data.my_port = 0;
node_data.network_id = P2P_NETWORK_ID; node_data.network_id = P2P_NETWORK_ID;
return true; return true;

View file

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

View file

@ -19,7 +19,7 @@ namespace nodetool
typedef std::string blobdata; typedef std::string blobdata;
#pragma pack (push, 1) #pragma pack (push, 1)
struct net_address struct net_address
{ {
uint32_t ip; uint32_t ip;
@ -59,7 +59,7 @@ namespace nodetool
{ {
return memcmp(&a, &b, sizeof(a)) == 0; return memcmp(&a, &b, sizeof(a)) == 0;
} }
inline inline
std::string print_peerlist_to_string(const std::list<peerlist_entry>& pl) std::string print_peerlist_to_string(const std::list<peerlist_entry>& pl)
{ {
time_t now_time = 0; time_t now_time = 0;
@ -94,7 +94,7 @@ namespace nodetool
struct basic_node_data struct basic_node_data
{ {
uuid network_id; uuid network_id;
int64_t local_time; int64_t local_time;
uint32_t my_port; uint32_t my_port;
peerid_type peer_id; peerid_type peer_id;
@ -106,7 +106,7 @@ namespace nodetool
KV_SERIALIZE(my_port) KV_SERIALIZE(my_port)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
#define P2P_COMMANDS_POOL_BASE 1000 #define P2P_COMMANDS_POOL_BASE 1000
@ -129,7 +129,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_N(if_build_less_then, "build") KV_SERIALIZE_N(if_build_less_then, "build")
KV_SERIALIZE_N(alert_mode, "mode") KV_SERIALIZE_N(alert_mode, "mode")
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
struct maintainers_info struct maintainers_info
@ -242,7 +242,7 @@ namespace nodetool
{ {
int64_t local_time; int64_t local_time;
t_playload_type payload_data; t_playload_type payload_data;
std::list<peerlist_entry> local_peerlist; std::list<peerlist_entry> local_peerlist;
maintainers_entry maintrs_entry; maintainers_entry maintrs_entry;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
@ -261,7 +261,7 @@ namespace nodetool
struct COMMAND_PING 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, 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. and ONLY in case when peer has accepted connection and answered to ping.
*/ */
@ -285,13 +285,13 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(status) KV_SERIALIZE(status)
KV_SERIALIZE(peer_id) KV_SERIALIZE(peer_id)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
}; };
#ifdef ALLOW_DEBUG_COMMANDS #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. //Anyone who feel unsafe with this commands can disable the ALLOW_GET_STAT_COMMAND macro.
struct proof_of_trust struct proof_of_trust
@ -302,9 +302,9 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(peer_id) KV_SERIALIZE(peer_id)
KV_SERIALIZE(time) KV_SERIALIZE(time)
KV_SERIALIZE_VAL_POD_AS_BLOB(sign) KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
@ -320,9 +320,9 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(pr) KV_SERIALIZE(pr)
KV_SERIALIZE(tr) KV_SERIALIZE(tr)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
struct response struct response
{ {
std::string version; std::string version;
@ -337,7 +337,7 @@ namespace nodetool
KV_SERIALIZE(incoming_connections_count) KV_SERIALIZE(incoming_connections_count)
KV_SERIALIZE(current_log_size) KV_SERIALIZE(current_log_size)
KV_SERIALIZE(payload_info) KV_SERIALIZE(payload_info)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
}; };
@ -354,14 +354,14 @@ namespace nodetool
proof_of_trust tr; proof_of_trust tr;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tr) KV_SERIALIZE(tr)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
struct response struct response
{ {
std::list<peerlist_entry> local_peerlist_white; std::list<peerlist_entry> local_peerlist_white;
std::list<peerlist_entry> local_peerlist_gray; std::list<peerlist_entry> local_peerlist_gray;
std::list<connection_entry> connections_list; std::list<connection_entry> connections_list;
peerid_type my_id; peerid_type my_id;
uint64_t local_time; uint64_t local_time;
uint64_t up_time; uint64_t up_time;
@ -372,7 +372,7 @@ namespace nodetool
KV_SERIALIZE(my_id) KV_SERIALIZE(my_id)
KV_SERIALIZE(local_time) KV_SERIALIZE(local_time)
KV_SERIALIZE(up_time) KV_SERIALIZE(up_time)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
}; };
@ -386,7 +386,7 @@ namespace nodetool
struct request struct request
{ {
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
struct response struct response
@ -395,7 +395,7 @@ namespace nodetool
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(my_id) KV_SERIALIZE(my_id)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
}; };
@ -466,7 +466,7 @@ namespace nodetool
}; };
#endif // #ifdef ALLOW_DEBUG_COMMANDS #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("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("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("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("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_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"); 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_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_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); m_no_password_confirmations = command_line::get_arg(vm, arg_no_password_confirmations);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
#define PASSWORD_CONFIRMATION_ATTEMPTS 3 #define PASSWORD_CONFIRMATION_ATTEMPTS 3
@ -663,7 +663,7 @@ bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::st
"Your wallet has been restored.\n" << "Your wallet has been restored.\n" <<
"To start synchronizing with the daemon use \"refresh\" command.\n" << "To start synchronizing with the daemon use \"refresh\" command.\n" <<
"Use \"help\" command to see the list of available commands.\n" << "Use \"help\" command to see the list of available commands.\n" <<
"Always use \"exit\" command when closing simplewallet to save\n" << "Always use \"exit\" command when closing lethean-cli-wallet to save\n" <<
"current session's state. Otherwise, you will possibly need to synchronize \n" << "current session's state. Otherwise, you will possibly need to synchronize \n" <<
"your wallet again. Your wallet keys is NOT under risk anyway.\n" << "your wallet again. Your wallet keys is NOT under risk anyway.\n" <<
"**********************************************************************"; "**********************************************************************";
@ -874,7 +874,7 @@ void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_inf
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT; uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points); 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; << 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; uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points); 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 ") << (st.is_income ? "Received " : "Sent ")
<< print_money(st.amount, decimal_points) << token_info; << print_money(st.amount, decimal_points) << token_info;
} }
} }
return true; return true;
} }
@ -1175,7 +1175,7 @@ bool simple_wallet::show_staking_history(const std::vector<std::string>& args)
if (n_days) if (n_days)
timestamp = static_cast<uint64_t>(time(nullptr)) - (n_days * 60 * 60 * 24); timestamp = static_cast<uint64_t>(time(nullptr)) - (n_days * 60 * 60 * 24);
uint64_t amount_total_staked = 0; uint64_t amount_total_staked = 0;
bool transfers_found = false; bool transfers_found = false;
for (auto it = transfers.rbegin(); it != transfers.rend(); it++) 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); is_coinbase(td.m_ptx_wallet_info->m_tx, pos_coinbase);
if (!pos_coinbase) if (!pos_coinbase)
continue; continue;
if (!transfers_found) if (!transfers_found)
{ {
message_writer() << " amount \tspent\tglobal index\t tx id"; 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); success_msg_writer() << "Total staked: " << print_money(amount_total_staked);
} }
return true; return true;
} }
@ -1513,18 +1513,18 @@ bool simple_wallet::validate_wrap_status(uint64_t amount)
currency::void_struct req = AUTO_VAL_INIT(req); currency::void_struct req = AUTO_VAL_INIT(req);
currency::rpc_get_wrap_info_response res = AUTO_VAL_INIT(res); 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) if (!r)
{ {
fail_msg_writer() << "Failed to request wrap status from server, check internet connection"; fail_msg_writer() << "Failed to request wrap status from server, check internet connection";
return false; return false;
} }
//check if amount is bigger then erc20 fee //check if amount is bigger then erc20 fee
uint64_t zano_needed_for_wrap = std::stoll(res.tx_cost.zano_needed_for_erc20); uint64_t lethean_needed_for_wrap = std::stoll(res.tx_cost.lethean_needed_for_erc20);
if (amount <= zano_needed_for_wrap) if (amount <= lethean_needed_for_wrap)
{ {
fail_msg_writer() << "Too small amount to cover ERC20 fee. ERC20 cost is: " 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 << ")"; "($" << res.tx_cost.usd_needed_for_erc20 << ")";
return false; return false;
} }
@ -1532,11 +1532,11 @@ bool simple_wallet::validate_wrap_status(uint64_t amount)
if (amount > unwrapped_coins_left) if (amount > unwrapped_coins_left)
{ {
fail_msg_writer() << "Amount is bigger than ERC20 tokens left available: " 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; 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)"; success_msg_writer(false) << "Proceed? (yes/no)";
while (true) while (true)
{ {
@ -1613,7 +1613,7 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
{ {
std::string integrated_payment_id; std::string integrated_payment_id;
currency::tx_destination_entry de = AUTO_VAL_INIT(de); 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]); bool ok = currency::parse_amount(de.amount, local_args[i + 1]);
if (!ok || 0 == de.amount) 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]; fail_msg_writer() << "address is wrong: " << local_args[i];
return true; return true;
} }
//check if address looks like wrapped address //check if address looks like wrapped address
if (is_address_like_wrapped(local_args[i])) 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) << "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)) 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 (!m_wallet->is_watch_only())
{ {
if(wrapped_transaction) 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 else
success_msg_writer(true) << "Transaction successfully sent, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; success_msg_writer(true) << "Transaction successfully sent, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes";
} }
else 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() SIMPLE_WALLET_CATCH_TRY_ENTRY()
return true; 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 << "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 << "Max emission: " << print_fixed_decimal_point(adb.total_max_supply, adb.decimal_point) << ENDL
; ;
SIMPLE_WALLET_CATCH_TRY_ENTRY(); SIMPLE_WALLET_CATCH_TRY_ENTRY();
return true; return true;
} }
@ -2254,7 +2254,7 @@ bool simple_wallet::add_custom_asset_id(const std::vector<std::string> &args)
} }
else 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 << " id: " << asset_id << ENDL
<< " title: " << asset_descriptor.full_name << ENDL << " title: " << asset_descriptor.full_name << ENDL
<< " ticker: " << asset_descriptor.ticker << ENDL << " ticker: " << asset_descriptor.ticker << ENDL
@ -2306,7 +2306,7 @@ bool simple_wallet::generate_ionic_swap_proposal(const std::vector<std::string>
return true; return true;
} }
else else
{ {
success_msg_writer() << "Generated proposal: " << ENDL << epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(proposal)); success_msg_writer() << "Generated proposal: " << ENDL << epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(proposal));
} }
SIMPLE_WALLET_CATCH_TRY_ENTRY(); 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; size_t outs_total = 0, outs_swept = 0;
uint64_t amount_total = 0, amount_swept = 0; uint64_t amount_total = 0, amount_swept = 0;
currency::transaction result_tx = AUTO_VAL_INIT(result_tx); 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); 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) 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_set_timeout);
command_line::add_arg(desc_params, arg_voting_config_file); command_line::add_arg(desc_params, arg_voting_config_file);
command_line::add_arg(desc_params, arg_no_password_confirmations); command_line::add_arg(desc_params, arg_no_password_confirmations);
tools::wallet_rpc_server::init_options(desc_params); tools::wallet_rpc_server::init_options(desc_params);
@ -2695,7 +2695,7 @@ int main(int argc, char* argv[])
if (command_line::get_arg(vm, command_line::arg_help)) if (command_line::get_arg(vm, command_line::arg_help))
{ {
success_msg_writer() << "Usage: simplewallet [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]"; success_msg_writer() << "Usage: lethean-cli-wallet [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]";
success_msg_writer() << desc_all << '\n' << sw->get_commands_str(); success_msg_writer() << desc_all << '\n' << sw->get_commands_str();
return false; return false;
} }
@ -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); 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); tools::wallet_rpc_server wrpc(wallet_ptr);
bool r = wrpc.init(vm); bool r = wrpc.init(vm);

View file

@ -13,7 +13,7 @@
#include "version.h" #include "version.h"
#include "currency_protocol/currency_protocol_handler.h" #include "currency_protocol/currency_protocol_handler.h"
#undef LOG_DEFAULT_CHANNEL #undef LOG_DEFAULT_CHANNEL
#define LOG_DEFAULT_CHANNEL "stratum" #define LOG_DEFAULT_CHANNEL "stratum"
ENABLE_CHANNEL_BY_DEFAULT("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" 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." " 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."}; " 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", 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 }; "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_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_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_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 ); 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) , 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_min(target_min)
, target_max(target_max) , target_max(target_max)
, target_time_ms(target_time_s * 1000) , target_time_ms(target_time_s * 1000)
@ -140,7 +140,7 @@ namespace
CRITICAL_REGION_LOCAL(m_lock); CRITICAL_REGION_LOCAL(m_lock);
return (epee::misc_utils::get_tick_count() - m_ts_started) / 1000; return (epee::misc_utils::get_tick_count() - m_ts_started) / 1000;
} }
uint64_t estimate_worker_hashrate() uint64_t estimate_worker_hashrate()
{ {
CRITICAL_REGION_LOCAL(m_lock); CRITICAL_REGION_LOCAL(m_lock);
@ -225,7 +225,7 @@ namespace
new_d = m_vd_params.target_min; new_d = m_vd_params.target_min;
if (new_d > m_vd_params.target_max) if (new_d > m_vd_params.target_max)
new_d = m_vd_params.target_max; new_d = m_vd_params.target_max;
if (new_d != m_worker_difficulty) if (new_d != m_worker_difficulty)
{ {
LP_CC_WORKER_YELLOW((*this), "difficulty update: " << m_worker_difficulty << " -> " << new_d << 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); 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) 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 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); 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); m_block_template = AUTO_VAL_INIT(m_block_template);
wide_difficulty_type block_template_difficulty; 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); LP_CC_WORKER_YELLOW(p_ph->get_context(), "core is NOT synchronized, respond with empty job package", LOG_LEVEL_2);
} }
if (!updated) if (!updated)
p_ph->set_work(get_work_json(p_ph->get_context().get_worker_difficulty())); 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); p_ph->send_response_default(id);
return true; return true;
} }
const uint64_t height = get_block_height(m_block_template); const uint64_t height = get_block_height(m_block_template);
// make sure worker sent work with correct block ethash // 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); 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); p_ph->send_response_default(id);
// send initial work // send initial work
update_work(p_ph); 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) 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: " << ", 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); epee::misc_utils::get_time_interval_string(p_ph->get_context().get_hr_estimate_duration()), LOG_LEVEL_3);
return true; return true;
@ -992,7 +992,7 @@ namespace
// JSON-RPC 2.0 spec: "A Notification is a Request object without an "id" member." // 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 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) 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); 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); 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; static std::unordered_map<std::string, method_handler_func_t> m_methods_handlers;
std::atomic<bool> m_connection_initialized; std::atomic<bool> m_connection_initialized;
}; // class stratum_protocol_handler }; // 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(); auto& config = m_impl->server.get_config_object();
config.set_core(m_p_core); config.set_core(m_p_core);
if (command_line::has_arg(vm, arg_stratum_always_online)) 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)); 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 BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_MAJOR_VERSION "2" #define PROJECT_MAJOR_VERSION "1"
#define PROJECT_MINOR_VERSION "0" #define PROJECT_MINOR_VERSION "5"
#define PROJECT_REVISION "0" #define PROJECT_REVISION "0"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION #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_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"

View file

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

View file

@ -7327,7 +7327,7 @@ void wallet2::transfer(construct_tx_param& ctp,
if (m_watch_only) 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_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); WLT_LOG_GREEN("[wallet::transfer]" << " prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3), LOG_LEVEL_0);
return; 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_rpc_proxy(new tools::core_fast_rpc_proxy(m_rpc_server)),
m_offers_service(nullptr), m_offers_service(nullptr),
m_wallet_rpc_server(this), m_wallet_rpc_server(this),
#else #else
m_rpc_proxy(new tools::default_http_core_proxy()), m_rpc_proxy(new tools::default_http_core_proxy()),
#endif #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_log_level);
command_line::add_arg(desc_cmd_sett, command_line::arg_console); 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_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_alloc_win_console);
command_line::add_arg(desc_cmd_sett, arg_sandbox_disable); command_line::add_arg(desc_cmd_sett, arg_sandbox_disable);
command_line::add_arg(desc_cmd_sett, arg_html_folder); 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); w->set_votes_config_path(m_data_dir + "/" + CURRENCY_VOTING_CONFIG_DEFAULT_FILENAME);
std::string return_code = API_RETURN_CODE_OK; std::string return_code = API_RETURN_CODE_OK;
while (true) 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) 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); GET_WALLET_OPT_BY_ID(wallet_id, wo);
auto locker_object = wo.w.lock(); auto locker_object = wo.w.lock();
tools::wallet2& rw = *(*(*locker_object)); //this looks a bit crazy, i know tools::wallet2& rw = *(*(*locker_object)); //this looks a bit crazy, i know
auto& keys = rw.get_account().get_keys(); auto& keys = rw.get_account().get_keys();
wi.view_private_key = epee::string_tools::pod_to_hex(keys.view_secret_key); 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) 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); w.w->get()->set_use_assets_whitelisting(use);
return API_RETURN_CODE_OK; 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) bool wallets_manager::on_mw_select_wallet(uint64_t wallet_id)
{ {
SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock); SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock);
auto it = m_wallets.find(wallet_id); auto it = m_wallets.find(wallet_id);
if (it == m_wallets.end()) if (it == m_wallets.end())
return false; return false;
#ifndef MOBILE_WALLET_BUILD #ifndef MOBILE_WALLET_BUILD
m_rpc_selected_wallet_id = wallet_id; m_rpc_selected_wallet_id = wallet_id;
#endif #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 #ifndef MOBILE_WALLET_BUILD
{ {
@ -2119,7 +2119,7 @@ void wallets_manager::lock()
#endif #endif
} }
void wallets_manager::unlock() void wallets_manager::unlock()
{ {
#ifndef MOBILE_WALLET_BUILD #ifndef MOBILE_WALLET_BUILD
m_current_wallet_locked_object.reset(); 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) bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{ {
currency::checkpoints checkpoints; currency::checkpoints checkpoints;
checkpoints.add_checkpoint(15, "6f9194c144afd73077478e7f04e947c50160b5673558e6f696a4f662a3ca261e"); checkpoints.add_checkpoint(15, "3e163f0828e08aea66775a3a92ead64298a67e0de66e6aa5453673716f2a5970");
c.set_checkpoints(std::move(checkpoints)); c.set_checkpoints(std::move(checkpoints));
return true; return true;

View file

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

View file

@ -572,7 +572,7 @@ TEST(crypto, constants)
point_t HpG = H + G; point_t HpG = H + G;
point_t HmG = H - G; point_t HmG = H - G;
point_t Hd8 = c_scalar_1div8 * H; point_t Hd8 = c_scalar_1div8 * H;
ASSERT_EQ(scalar_t(8) * Hd8, H); ASSERT_EQ(scalar_t(8) * Hd8, H);
// print them // print them
@ -1046,115 +1046,115 @@ TEST(crypto, hp)
LOG_PRINT_L0("cn_fast_hash('') * G = " << zG.to_public_key() << " (pub_key)"); LOG_PRINT_L0("cn_fast_hash('') * G = " << zG.to_public_key() << " (pub_key)");
ASSERT_EQ(zG, point_from_str("7849297236cd7c0d6c69a3c8c179c038d3c1c434735741bb3c8995c3c9d6f2ac")); ASSERT_EQ(zG, point_from_str("7849297236cd7c0d6c69a3c8c179c038d3c1c434735741bb3c8995c3c9d6f2ac"));
crypto::cn_fast_hash("zano", 4, hash); crypto::cn_fast_hash("lethean", 4, hash);
LOG_PRINT_L0("cn_fast_hash('zano') = " << hash); LOG_PRINT_L0("cn_fast_hash('lethean') = " << hash);
ASSERT_EQ(hash, hash_from_str("23cea10abfdf3ace0b7132291d51e4eb5a392afb2147e67f907ff4f8f5dd4f9f")); ASSERT_EQ(hash, hash_from_str("23cea10abfdf3ace0b7132291d51e4eb5a392afb2147e67f907ff4f8f5dd4f9f"));
z = hash; z = hash;
zG = z * c_point_G; 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")); ASSERT_EQ(zG, point_from_str("71407d59e9d671fa02f26a6a7f4726c3087d8f1732453396638a1dc2929fb57a"));
char buf[2000]; char buf[2000];
for (size_t i = 0; i < sizeof buf; i += 4) 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); 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")); ASSERT_EQ(hash, hash_from_str("16d87120c601a6ef3e4ffa5e58176a36b814288199f23ec09ef178c554e8879b"));
z = hash; z = hash;
zG = z * c_point_G; 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")); ASSERT_EQ(zG, point_from_str("dd93067a02fb8661aa64504ac1503402a34426f43650d970c35147cec4b61d55"));
return true; return true;
} }
TEST(crypto, cn_fast_hash_perf) //TEST(crypto, cn_fast_hash_perf)
{ //{
//return true; // return true;
const crypto::hash h_initial = *(crypto::hash*)(&scalar_t::random()); // const crypto::hash h_initial = *(crypto::hash*)(&scalar_t::random());
//
std::vector<std::vector<uint8_t>> test_data; // 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>(32, 0));
test_data.push_back(std::vector<uint8_t>(63, 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>(127, 0));
test_data.push_back(std::vector<uint8_t>(135, 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>(255, 0));
test_data.push_back(std::vector<uint8_t>(271, 0)); // 271 = 136 * 2 - 1 // test_data.push_back(std::vector<uint8_t>(271, 0)); // 271 = 136 * 2 - 1
test_data.push_back(std::vector<uint8_t>(2030, 0)); // test_data.push_back(std::vector<uint8_t>(2030, 0));
//
for (size_t j = 0, sz = test_data.size(); j < sz; ++j) // for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
crypto::generate_random_bytes(test_data[j].size(), test_data[j].data()); // crypto::generate_random_bytes(test_data[j].size(), test_data[j].data());
//
struct times_t // struct times_t
{ // {
uint64_t t_old{ 0 }, t_new{ 0 }; // uint64_t t_old{ 0 }, t_new{ 0 };
crypto::hash h_old{}; // crypto::hash h_old{};
double diff{ 0 }; // double diff{ 0 };
}; // };
std::vector<times_t> results(test_data.size()); // std::vector<times_t> results(test_data.size());
//
size_t n = 50000; // size_t n = 50000;
double diff_sum = 0; // double diff_sum = 0;
//
for (size_t k = 0; k < 50; ++k) // for (size_t k = 0; k < 50; ++k)
{ // {
for (size_t j = 0, sz = test_data.size(); j < sz; ++j) // for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
{ // {
crypto::hash h = h_initial; // crypto::hash h = h_initial;
TIME_MEASURE_START(t_old); // TIME_MEASURE_START(t_old);
for (size_t i = 0; i < n; ++i) // for (size_t i = 0; i < n; ++i)
{ // {
*(crypto::hash*)(test_data[j].data()) = h; // *(crypto::hash*)(test_data[j].data()) = h;
cn_fast_hash_old(test_data[j].data(), test_data[j].size(), (char*)&h); // cn_fast_hash_old(test_data[j].data(), test_data[j].size(), (char*)&h);
} // }
TIME_MEASURE_FINISH(t_old); // TIME_MEASURE_FINISH(t_old);
results[j].t_old = t_old; // results[j].t_old = t_old;
results[j].h_old = h; // results[j].h_old = h;
} // }
//
for (size_t j = 0, sz = test_data.size(); j < sz; ++j) // for (size_t j = 0, sz = test_data.size(); j < sz; ++j)
{ // {
crypto::hash h = h_initial; // crypto::hash h = h_initial;
TIME_MEASURE_START(t_new); // TIME_MEASURE_START(t_new);
for (size_t i = 0; i < n; ++i) // for (size_t i = 0; i < n; ++i)
{ // {
*(crypto::hash*)(test_data[j].data()) = h; // *(crypto::hash*)(test_data[j].data()) = h;
cn_fast_hash(test_data[j].data(), test_data[j].size(), (char*)&h); // cn_fast_hash(test_data[j].data(), test_data[j].size(), (char*)&h);
} // }
TIME_MEASURE_FINISH(t_new); // TIME_MEASURE_FINISH(t_new);
results[j].t_new = t_new; // results[j].t_new = t_new;
ASSERT_EQ(h, results[j].h_old); // ASSERT_EQ(h, results[j].h_old);
} // }
//
std::stringstream ss; // std::stringstream ss;
double diff_round = 0; // double diff_round = 0;
for (size_t j = 0, sz = test_data.size(); j < sz; ++j) // 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; // 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 << "/" << // ss << std::fixed << std::setprecision(3) << results[j].t_old / (double)n << "/" <<
std::fixed << std::setprecision(3) << results[j].t_new / (double)n << " "; // std::fixed << std::setprecision(3) << results[j].t_new / (double)n << " ";
//
results[j].diff += diff; // results[j].diff += diff;
diff_round += diff; // diff_round += diff;
} // }
//
diff_sum += diff_round; // 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 << // 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); // " diff_sum = " << std::fixed << std::setprecision(4) << diff_sum);
} // }
//
std::stringstream ss; // std::stringstream ss;
for (size_t j = 0, sz = results.size(); j < sz; ++j) // for (size_t j = 0, sz = results.size(); j < sz; ++j)
ss << std::fixed << std::setprecision(4) << results[j].diff << " "; // ss << std::fixed << std::setprecision(4) << results[j].diff << " ";
LOG_PRINT_L0(" " << ss.str()); // LOG_PRINT_L0(" " << ss.str());
//
return true; // return true;
} //}
//
TEST(crypto, sc_invert_performance) TEST(crypto, sc_invert_performance)
@ -1279,7 +1279,7 @@ TEST(crypto, neg_identity)
ASSERT_TRUE(validate_key_image(z_ki)); ASSERT_TRUE(validate_key_image(z_ki));
key_image z_neg_ki = 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 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 // also do zero-byte pub key / key image checks
public_key zzz_pk; public_key zzz_pk;
memset(&zzz_pk, 0, sizeof(public_key)); memset(&zzz_pk, 0, sizeof( public_key));
ASSERT_TRUE(check_key(zzz_pk)); ASSERT_TRUE(check_key(zzz_pk));
@ -1296,7 +1296,7 @@ TEST(crypto, neg_identity)
ASSERT_FALSE(zzz.is_in_main_subgroup()); ASSERT_FALSE(zzz.is_in_main_subgroup());
key_image zzz_ki; 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)); ASSERT_FALSE(validate_key_image(zzz_ki));
@ -1466,7 +1466,7 @@ TEST(crypto, point_is_zero)
ASSERT_TRUE(p.is_zero()); ASSERT_TRUE(p.is_zero());
memset(&p.m_p3, 0, sizeof p.m_p3); 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.Y, f_x, sizeof p.m_p3.Y);
memcpy(&p.m_p3.Z, f_x, sizeof p.m_p3.Z); 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.Y, f_x, sizeof p.m_p3.Y);
memcpy(&p.m_p3.Z, f_x, sizeof p.m_p3.Z); 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); 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()); ASSERT_FALSE(p.is_zero());
@ -1603,7 +1603,7 @@ TEST(crypto, schnorr_sig)
ASSERT_EQ(tmp, ss.c); ASSERT_EQ(tmp, ss.c);
ASSERT_FALSE(verify_schnorr_sig<gt_X>(m, A, bad_ss)); ASSERT_FALSE(verify_schnorr_sig<gt_X>(m, A, bad_ss));
// binary serialization // binary serialization
std::string blob = t_serializable_object_to_blob(ss); std::string blob = t_serializable_object_to_blob(ss);
generate_random_bytes(sizeof ss, &ss); generate_random_bytes(sizeof ss, &ss);
ASSERT_TRUE(t_unserializable_object_from_blob(ss, blob)); 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; 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{}; point_t restored_pt{};
ge_p1p1 p1p1{}; ge_p1p1 p1p1{};
ge_madd(&p1p1, &random_point.m_p3, &((*generator.m_precomp_data_p)[i][j])); 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..."); // LOG_PRINT_L0("Generating wallet...");
// view::open_wallet_request owr = AUTO_VAL_INIT(owr); // 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 = ""; // owr.pass = "";
// std::string job_id_str = plain_wallet::async_call("open", 0, epee::serialization::store_t_to_json(owr)); // 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); //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::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); //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("Creating instance..." << std::hex << hw);
// //
// LOG_PRINT_L0("Generating wallet..."); // 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); // 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::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); // 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("Creating instance..." << std::hex << hw);
// //
// LOG_PRINT_L0("Generating wallet..."); // 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); // 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::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); // epee::serialization::load_t_from_json(ok_response, rsp);

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