1
0
Fork 0
forked from lthn/blockchain
This commit is contained in:
Snider 2025-10-10 11:19:25 +00:00 committed by GitHub
commit b08a63ee69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 329 additions and 174 deletions

View file

@ -157,7 +157,7 @@ docs-dev: configure
clean:
@cmake -P cmake/CleanBuild.cmake
clean-build:
clean-build: clean
rm -rf build
tags:

244
README.md
View file

@ -1,196 +1,98 @@
[![Coverity Scan](https://scan.coverity.com/projects/18767/badge.svg)](https://scan.coverity.com/projects/zanoproject)
[![Discord](https://img.shields.io/discord/538361472691077130?label=discord&logo=discord)](https://discord.gg/wE3rmYY)
[![Discord](https://img.shields.io/discord/379876792003067906?label=discord&logo=discord)](https://discord.gg/pfgT2Kz)
### Dependencies
| component / version | minimum <br>(not recommended but may work) | recommended | most recent of what we have ever tested |
|-----------------------------------------------------------------------------|--------------------------------------------|----------------|-----------------------------------------|
| gcc (Linux) | 8.4.0 | 9.4.0 | 12.3.0 |
| llvm/clang (Linux) | UNKNOWN | 7.0.1 | 8.0.0 |
| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2017 (15.9.30) | 2022 (17.11.5) | 2022 (17.12.3) |
| [XCode](https://developer.apple.com/downloads/) (macOS) | 12.3 | 14.3 | 15.2 |
| [CMake](https://cmake.org/download/) | 3.26.3 | 3.26.3 | 3.31.6 |
## Cloning
Be sure to clone the repository properly:\
`$ git clone --recursive https://github.com/hyle-team/zano.git`
Be sure to clone the repository properly, with `--recursive` flag, or you'll get angry:
`git clone --recursive https://github.com/letheanVPN/blockchain.git`
# Building
--------
The project uses a `Makefile` that provides a simple and powerful interface for building. It automatically handles dependency installation with Conan and compilation with CMake.
### Dependencies
| component / version | minimum <br>(not recommended but may work) | recommended | most recent of what we have ever tested |
|-----------------------------------------------------------------------------------------------------|--------------------------------------------|----------------|-----------------------------------------|
| gcc (Linux) | 8.4.0 | 9.4.0 | 12.3.0 |
| llvm/clang (Linux) | UNKNOWN | 7.0.1 | 8.0.0 |
| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2017 (15.9.30) | 2022 (17.11.5) | 2022 (17.12.3) |
| [XCode](https://developer.apple.com/downloads/) (macOS) | 12.3 | 14.3 | 15.2 |
| [CMake](https://cmake.org/download/) | 3.26.3 | 3.26.3 | 3.31.6 |
| [Boost](https://www.boost.org/users/download/) | 1.75 | 1.84 | 1.84 |
| [OpenSSL](https://www.openssl.org/source/) [(win)](https://slproweb.com/products/Win32OpenSSL.html) | 1.1.1n | 1.1.1w | 3.4 |
| [Qt](https://download.qt.io/archive/qt/) (*only for GUI*) | 6.8.3 | 6.8.3 | 6.8.3 |
## Simple Workflow Builds (Recommended)
Note:\
[*server version*] denotes steps required for building command-line tools (daemon, simplewallet, etc.).\
[*GUI version*] denotes steps required for building Zano executable with GUI.
For most use cases, these two commands are all you need. They handle the entire build process from start to finish.
<br />
* **Build for Mainnet:**
```shell
make mainnet
```
### Linux
* **Build for Testnet:**
```shell
make testnet
```
Recommended OS versions: Ubuntu 20.04, 22.04 LTS.
## Custom Builds
1. Prerequisites
You can use the `make build` target with variables for more control over the final binaries.
[*server version*]
sudo apt-get install -y build-essential g++ curl autotools-dev libicu-dev libbz2-dev cmake git screen checkinstall zlib1g-dev libssl-dev bzip2
[*GUI version*]
## Creating Release Packages
sudo apt-get install -y build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev cmake git screen checkinstall zlib1g-dev libssl-dev bzip2 mesa-common-dev libglu1-mesa-dev
To create distributable packages (e.g., `.zip`, `.msi`, `.pkg`, `.deb`), run the `release` target. This will build the project, build the documentation, and then package everything.
Make sure you have correct versions installed (see 'Dependencies' section above):
```shell
make release TESTNET=1
```
The final packages will be located in the `build/packages/` directory
cmake --version && gcc --version
## Advanced Build Customization (Makefile Variables)
3. Clone Zano into a local folder\
(If for some reason you need to use alternative Zano branch, change 'master' to the required branch name.)
git clone --recursive https://github.com/hyle-team/zano.git -b master
For advanced use cases, you can override variables in the `Makefile` to customize the build process.
In the following steps we assume that you cloned Zano into '~/zano' folder in your home directory.
* **Build a `testnet` version:**
```shell
make build TESTNET=1
```
* **Build a statically-linked version:**
```shell
make build STATIC=1
```
* **Build a Debug build with 8 compile threads:**
```shell
make build BUILD_TYPE=Debug CPU_CORES=8
```
* **Use custom CMakePresets:**
```shell
make build PRESET_CONFIGURE=my-config-preset PRESET_BUILD=my-build-preset
```
4. Download and build Boost\
(Assuming you have cloned Zano into the 'zano' folder. If you used a different location for Zano, **edit line 4** accordingly.)
| Variable | Description | Default Value |
|--------------------|------------------------------------------------------------------------|-------------------------|
| `BUILD_TYPE` | Sets the build configuration (e.g., `Release`, `Debug`). | `Release` |
| `TESTNET` | Set to `1` to build for the test network. | `0` |
| `STATIC` | Set to `1` to link libraries statically. | `0` |
| `CPU_CORES` | Number of CPU cores to use for parallel compilation. | Auto-detected |
| `BUILD_VERSION` | The version string to embed in the binaries. | `6.0.1` |
| `BUILD_FOLDER` | The output directory for the build. | `build/release` |
| `PRESET_CONFIGURE` | The CMake preset to use for the `configure` step. | `conan-release` |
| `PRESET_BUILD` | The CMake preset to use for the `build` step. | `conan-release` |
| `CONAN_CACHE` | The path for the local Conan cache, where the dependencies are stored. | `./build/sdk` |
| `CONAN_EXECUTABLE` | The path to the usable Conan executable. | `./build/bin/conan` |
| `CONAN_URL` | The URL for the Conan remote repository. | `artifacts.host.uk.com` |
| `CONAN_USER` | The username for the Conan remote. | `public` |
| `CONAN_PASSWORD` | The password for the Conan remote. | |
curl -OL https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.bz2
echo "cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454 boost_1_84_0.tar.bz2" | shasum -c && tar -xjf boost_1_84_0.tar.bz2
rm boost_1_84_0.tar.bz2 && cd boost_1_84_0
./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,chrono,regex,serialization,atomic,program_options,locale,timer,log
./b2 && cd ..
Make sure that you see "The Boost C++ Libraries were successfully built!" message at the end.
## Cleaning the Build Directory
5. Install Qt\
(*GUI version only, skip this step if you're building server version*)
ALWAYS USE `make clean` to clean the build directory, manually deleting the `build/release`, `build/SOME_FOLDER` will cause you issues.
[*GUI version*]
Our `make clean` triggers a cmake script that completely resets the build directory &amp; dynamically added CMakePresets to its cached warm-up state,
the selective clean script can be edited here: `cmake/CleanBuild.cmake` or directly run from the repo root `cmake -P cmake/CleanBuild.cmake`
curl -L -O https://download.qt.io/official_releases/online_installers/qt-online-installer-linux-x64-online.run &&
chmod u+x qt-online-installer-linux-x64-online.run
./qt-online-installer-linux-x64-online.run \
--accept-licenses \
--default-answer \
--confirm-command install \
qt.qt6.683.linux_gcc_64 \
qt.qt6.683.addons.qt5compat.linux_gcc_64 \
qt.qt6.683.addons.qtpositioning.linux_gcc_64 \
qt.qt6.683.addons.qtwebchannel.linux_gcc_64 \
qt.qt6.683.addons.qtwebsockets.linux_gcc_64 \
qt.qt6.683.addons.qtwebengine.linux_gcc_64 \
qt.qt6.683.addons.qtwebview.linux_gcc_64
This will download the online installer and perform an unattended installation with the Chromium-based WebEngine
You can NUKE the build directory with `make clean-build` which is `rm -rf build`.
If you do manually delete build folders and get CMake errors (if you have compiled anything previously, you will),
the ConanPresets.json file has entries in the `include` property, delete them all and try again.
6. Install OpenSSL
We recommend installing OpenSSL v1.1.1w locally unless you would like to use the same version system-wide.\
(Assuming that `$HOME` environment variable is set to your home directory. Otherwise, edit line 4 accordingly.)
curl -OL https://www.openssl.org/source/openssl-1.1.1w.tar.gz
echo "cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 openssl-1.1.1w.tar.gz" | shasum -c && tar xaf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
./config --prefix=$HOME/openssl --openssldir=$HOME/openssl shared zlib
make && make test && make install && cd ..
7. [*OPTIONAL*] Set global environment variables for convenient use\
For instance, by adding the following lines to `~/.bashrc`
[*server version*]
export BOOST_ROOT=/home/user/boost_1_84_0
export OPENSSL_ROOT_DIR=/home/user/openssl
[*GUI version*]
export BOOST_ROOT=/home/user/boost_1_84_0
export OPENSSL_ROOT_DIR=/home/user/openssl
export QT_PREFIX_PATH=/home/user/Qt5.11.2/5.11.2/gcc_64
**NOTICE: Please edit the lines above according to your actual paths.**
**NOTICE 2:** Make sure you've restarted your terminal session (by reopening the terminal window or reconnecting the server) to apply these changes.
8. Build the binaries
1. If you skipped step 6 and did not set the environment variables:
cd zano && mkdir build && cd build
BOOST_ROOT=$HOME/boost_1_84_0 OPENSSL_ROOT_DIR=$HOME/openssl cmake ..
make -j1 daemon simplewallet
2. If you set the variables in step 6:
cd zano && mkdir build && cd build
cmake ..
make -j1 daemon simplewallet
or simply:
cd zano && make -j1
**NOTICE**: If you are building on a machine with a relatively high amount of RAM or with the proper setting of virtual memory, then you can use `-j2` or `-j` option to speed up the building process. Use with caution.
**NOTICE 2**: If you'd like to build binaries for the testnet, use `cmake -D TESTNET=TRUE ..` instead of `cmake ..` .
1. Build GUI:
cd zano
utils/build_script_linux.sh
Look for the binaries in `build` folder
<br />
### Windows
Recommended OS version: Windows 7 x64, Windows 11 x64.
1. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
2. Edit paths in `utils/configure_local_paths.cmd`.
3. Run one of `utils/configure_win64_msvsNNNN_gui.cmd` according to your MSVC version.
4. Go to the build folder and open generated Zano.sln in MSVC.
5. Build.
In order to correctly deploy Qt GUI application, you also need to do the following:
6. Run `PATH_TO_QT\bin\windeployqt.exe PATH_TO_PROJECT_ROOT\build\src\Debug\Zano.exe` (choose the Debug or Release folder depending on the configuration you built).
7. You can now run the application using one of the following options:
* Start the program from Visual Studio
* Run `Zano.exe --html-path=PATH_TO_HTML`, where PATH_TO_HTML is by default located at PATH_TO_PROJECT_ROOT\src\gui\qt-daemon\layout\html
* Copy the contents of PATH_TO_PROJECT_ROOT\src\gui\qt-daemon\layout\html to a folder named "html" located in the same directory as the Zano.exe binary.
<br />
### macOS
Recommended OS version: macOS Big Sur 11.4 x64.
1. Install required prerequisites.
2. Set environment variables as stated in `utils/macosx_build_config.command`.
3. `mkdir build` <br> `cd build` <br> `cmake ..` <br> `make`
To build GUI application:
1. Create self-signing certificate via Keychain Access:\
a. Run Keychain Access.\
b. Choose Keychain Access > Certificate Assistant > Create a Certificate.\
c. Use “Zano” (without quotes) as certificate name.\
d. Choose “Code Signing” in “Certificate Type” field.\
e. Press “Create”, then “Done”.\
f. Make sure the certificate was added to keychain "System". If not—move it to "System".\
g. Double click the certificate you've just added, enter the trust section and under "When using this certificate" select "Always trust".\
h. Unfold the certificate in Keychain Access window and double click the underlying private key "Zano". Select "Access Control" tab, then select "Allow all applications to access this item". Click "Save Changes".
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`
<br />
<br />
## Supporting project/donations
ZANO @dev<br />
BTC bc1qpa8w8eaehlplfepmnzpd7v9j046899nktxnkxp<br />
BCH qqgq078vww5exd9kt3frx6krdyznmp80hcygzlgqzd<br />
ETH 0x206c52b78141498e74FF074301ea90888C40c178<br />
XMR 45gp9WTobeB5Km3kLQgVmPJkvm9rSmg4gdyHheXqXijXYMjUY48kLgL7QEz5Ar8z9vQioQ68WYDKsQsjAEonSeFX4UeLSiX<br />
This happens because CMakePresets.json includes ConanPresets.json, that has the list of toolchains to use that gets populated during the CMake config step,
when you manually delete a folder, the toolchain is now a broken path, and CMake throws a fatal error.

View file

@ -26,7 +26,9 @@ class BlockchainConan(ConanFile):
"boost/1.85.0",
"openssl/3.2.0",
"miniupnpc/2.2.5",
"jwt-cpp/0.7.1"
"jwt-cpp/0.7.1",
"oatpp/1.3.0.latest",
"oatpp-swagger/1.3.0.latest"
]
def generate(self):

2
docs

@ -1 +1 @@
Subproject commit 12e20efce7eaf51e38d8953c318633b1c5189256
Subproject commit e40a78d5020661f05d9bae64f2edd4519d9d98b3

View file

@ -85,6 +85,7 @@ INIT_SHARED_PCH()
add_subdirectory(config)
add_subdirectory(genesis)
add_subdirectory(api)
add_library(common ${COMMON})
add_dependencies(common version config ${PCH_LIB_NAME})

37
src/api/ApiServer.hpp Normal file
View file

@ -0,0 +1,37 @@
#ifndef ApiServer_hpp
#define ApiServer_hpp
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include "oatpp/core/macro/component.hpp"
#include "oatpp-swagger/Resources.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#include "oatpp-swagger/Model.hpp"
class ApiServer {
public:
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
return oatpp::network::tcp::server::ConnectionProvider::createShared({"0.0.0.0", 8000, oatpp::network::Address::IP_4});
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] {
return oatpp::web::server::HttpRouter::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, serverConnectionHandler)([] {
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
return oatpp::web::server::HttpConnectionHandler::createShared(router);
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] {
return oatpp::parser::json::mapping::ObjectMapper::createShared();
}());
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::swagger::Resources>, swaggerResources)([] {
return oatpp::swagger::Resources::loadResources(OATPP_SWAGGER_RES_PATH);
}());
};
#endif /* ApiServer_hpp */

30
src/api/CMakeLists.txt Normal file
View file

@ -0,0 +1,30 @@
if(NOT PROJECT_NAME)
project(lethean-api)
endif()
find_package(oatpp 1.3.0 REQUIRED)
if(oatpp_FOUND)
message(STATUS "Found oatpp version: ${oatpp_VERSION_STRING}")
else()
message(FATAL_ERROR "Could not find oatpp")
endif()
find_package(oatpp-swagger 1.3.0 REQUIRED)
if(oatpp-swagger_FOUND)
message(STATUS "Found oatpp-swagger version: ${oatpp-swagger_VERSION_STRING}")
else()
message(FATAL_ERROR "Could not find oatpp-swagger")
endif()
add_library(lthn_api INTERFACE)
add_library(lthn::api ALIAS lthn_api)
target_include_directories(lthn_api INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${oatpp_INCLUDE_DIRS})
include_directories(${oatpp-swagger_INCLUDE_DIRS})
add_executable(lethean-api main.cpp)
target_link_libraries(lethean-api PRIVATE lthn::api PUBLIC oatpp::oatpp oatpp::oatpp-swagger)
add_definitions(-DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res")
#add_subdirectory(tests)

View file

@ -0,0 +1,34 @@
#ifndef RootController_hpp
#define RootController_hpp
#include "./info/InfoController.hpp"
#include "../dto/DTOs.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"
#include OATPP_CODEGEN_BEGIN(ApiController)
class RootController : public oatpp::web::server::api::ApiController {
private:
std::shared_ptr<InfoController> m_infoController;
public:
RootController(OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
: oatpp::web::server::api::ApiController(objectMapper),
m_infoController(std::make_shared<InfoController>(objectMapper))
{}
public:
ENDPOINT("GET", "/hello", root) {
auto dto = MyDto::createShared();
dto->message = "Hello World!";
return createDtoResponse(Status::CODE_200, dto);
}
};
#include OATPP_CODEGEN_END(ApiController)
#endif /* RootController_hpp */

View file

@ -0,0 +1,37 @@
#ifndef InfoController_hpp
#define InfoController_hpp
#include "oatpp/web/server/api/ApiController.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"
#include OATPP_CODEGEN_BEGIN(ApiController)
class InfoController : public oatpp::web::server::api::ApiController {
public:
InfoController(OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
: oatpp::web::server::api::ApiController(objectMapper)
{}
public:
ENDPOINT_INFO(version) {
info->summary = "Get API version";
info->description = "Returns the current version of the API.";
}
ENDPOINT("GET", "/version", version) {
return createResponse(Status::CODE_200, "v0.0.1");
}
ENDPOINT_INFO(root) {
info->summary = "Get info root";
info->description = "Returns a placeholder for the info root.";
}
ENDPOINT("GET", "/", root) {
return createResponse(Status::CODE_200, "Info root");
}
};
#include OATPP_CODEGEN_END(ApiController)
#endif /* InfoController_hpp */

36
src/api/dto/DTOs.hpp Normal file
View file

@ -0,0 +1,36 @@
// Copyright (c) 2014-2018 Zano Project
// Copyright (c) 2014-2018 The Louisdor Project
// Copyright (c) 2012-2013 The Boolberry developers
// Copyright (c) 2017-2025 Lethean (https://lt.hn)
//
// Licensed under the European Union Public Licence (EUPL) version 1.2.
// You may obtain a copy of the licence at:
//
// https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
//
// The EUPL is a copyleft licence that is compatible with the MIT/X11
// licence used by the original projects; the MIT terms are therefore
// considered “grandfathered” under the EUPL for this code.
//
// SPDXLicenseIdentifier: EUPL-1.2
//
#ifndef DTOs_hpp
#define DTOs_hpp
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/Types.hpp"
#include OATPP_CODEGEN_BEGIN(DTO)
class MyDto : public oatpp::DTO {
DTO_INIT(MyDto, DTO);
DTO_FIELD(String, message);
};
#include OATPP_CODEGEN_END(DTO)
#endif /* DTOs_hpp */

76
src/api/main.cpp Normal file
View file

@ -0,0 +1,76 @@
#include "controller/RootController.hpp"
#include "ApiServer.hpp"
#include "oatpp/network/Server.hpp"
#include "oatpp-swagger/Controller.hpp"
#include <iostream>
void run() {
/* Register Components in scope of run() method */
ApiServer components;
/* Get router component */
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
/* Create RootController and add all of its endpoints to router */
auto rootController = std::make_shared<RootController>();
router->addController(rootController);
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::swagger::DocumentInfo>, swaggerDocumentInfo)([] {
oatpp::swagger::DocumentInfo::Builder builder;
builder
.setTitle("Lethean Blockchain API")
.setDescription("New API layer for Lethean")
.setVersion("1.0")
.setContactName("Lethean")
.setContactUrl("https://lt.hn/")
.setLicenseName("EUPL-1.2")
.setLicenseUrl("https://joinup.ec.europa.eu/software/page/eupl/licence-eupl")
.addServer("http://localhost:8000", "server on localhost");
// When you are using the AUTHENTICATION() Endpoint-Macro you must add an SecurityScheme object (https://swagger.io/specification/#securitySchemeObject)
// For basic-authentication you can use the default Basic-Authorization-Security-Scheme like this
// For more complex authentication schemes you can use the oatpp::swagger::DocumentInfo::SecuritySchemeBuilder builder
// Don't forget to add info->addSecurityRequirement("basic_auth") to your ENDPOINT_INFO() Macro!
//.addSecurityScheme("basic_auth", oatpp::swagger::DocumentInfo::SecuritySchemeBuilder::DefaultBasicAuthorizationSecurityScheme());
return builder.build();
}());
/* Create Swagger-UI controller and add its endpoints to router */
auto swaggerController = oatpp::swagger::Controller::createShared(rootController->getEndpoints());
router->addController(swaggerController);
/* Get connection handler component */
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, connectionHandler);
/* Get connection provider component */
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, connectionProvider);
/* Create server which takes provided TCP connections and passes them to HTTP connection handler */
oatpp::network::Server server(connectionProvider, connectionHandler);
/* Print server port */
OATPP_LOGI("lethean-api", "Server running on port %s", connectionProvider->getProperty("port").getData());
/* Run server */
server.run();
}
int main(int argc, const char * argv[]) {
oatpp::base::Environment::init();
run();
/* Destroy oatpp Environment */
oatpp::base::Environment::destroy();
return 0;
}