forked from lthn/blockchain
Centralised chain config (#4)
This commit is contained in:
parent
bf22a89733
commit
b02addf264
18 changed files with 384 additions and 94 deletions
17
Makefile
17
Makefile
|
|
@ -47,6 +47,20 @@ ifeq ($(OS),Windows_NT)
|
|||
endif
|
||||
endif
|
||||
|
||||
testnet-genesis-new:
|
||||
$(eval command += $(cmake_release) $(testnet))
|
||||
$(call CMAKE,$(dir_release),$(command) -DGENERATE_PREMINE_WALLET=1 -DPREMINE_WALLET_PASSWORD=12345678) && cmake --build ./src --target premine_wallet || true
|
||||
$(eval command += $(cmake_release) $(testnet))
|
||||
$(call CMAKE,$(dir_release),$(command) -DGENERATE_FRESH_GENESIS=1) && cmake --build ./src --target genesis_generator
|
||||
$(eval command += $(cmake_release) $(testnet))
|
||||
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
|
||||
|
||||
genesis-new:
|
||||
$(eval command += $(cmake_release))
|
||||
$(call CMAKE,$(dir_release),$(command) -DGENERATE_FRESH_GENESIS=1) && cmake --build ./src --target genesis_generator
|
||||
$(eval command += $(cmake_release))
|
||||
$(call CMAKE,$(dir_release),$(command)) && $(MAKE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Safety net – ensure we always have a positive integer.
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -54,6 +68,7 @@ CPU_CORES := $(or $(CPU_CORES),1)
|
|||
CPU_CORES := $(shell expr $(CPU_CORES) + 0 2>/dev/null || echo 1)
|
||||
CONAN_CPU_COUNT=$(CPU_CORES)
|
||||
|
||||
|
||||
PROFILES := $(patsubst cmake/profiles/%,%,$(wildcard cmake/profiles/*))
|
||||
SORTED_PROFILES := $(sort $(PROFILES))
|
||||
CONAN_CACHE := $(CURDIR)/build/sdk
|
||||
|
|
@ -61,8 +76,6 @@ DEFAULT_CONAN_PROFILE := $(CONAN_CACHE)/cmake/profiles/default
|
|||
|
||||
all: help
|
||||
|
||||
|
||||
|
||||
release: conan-profile-detect
|
||||
@echo "Building profile: release"
|
||||
CONAN_HOME=$(CONAN_CACHE) conan install . --output-folder=build/release --build=missing -s build_type=Release
|
||||
|
|
|
|||
57
cmake/check-config-vars.cmake
Normal file
57
cmake/check-config-vars.cmake
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
if (NOT DEFINED currency_display_decimal_point)
|
||||
message(FATAL_ERROR "currency_display_decimal_point not set")
|
||||
endif()
|
||||
if (NOT DEFINED coin)
|
||||
message(FATAL_ERROR "coin not set")
|
||||
endif()
|
||||
if (NOT DEFINED base_reward_dust_threshold)
|
||||
message(FATAL_ERROR "base_reward_dust_threshold not set")
|
||||
endif()
|
||||
if (NOT DEFINED default_dust_threshold)
|
||||
message(FATAL_ERROR "default_dust_threshold not set")
|
||||
endif()
|
||||
if (NOT DEFINED tx_default_fee)
|
||||
message(FATAL_ERROR "tx_default_fee not set")
|
||||
endif()
|
||||
if (NOT DEFINED tx_minimum_fee)
|
||||
message(FATAL_ERROR "tx_minimum_fee not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_pow_starter)
|
||||
message(FATAL_ERROR "difficulty_pow_starter not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_pos_target)
|
||||
message(FATAL_ERROR "difficulty_pos_target not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_pow_target)
|
||||
message(FATAL_ERROR "difficulty_pow_target not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_window)
|
||||
message(FATAL_ERROR "difficulty_window not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_lag)
|
||||
message(FATAL_ERROR "difficulty_lag not set")
|
||||
endif()
|
||||
if (NOT DEFINED difficulty_cut)
|
||||
message(FATAL_ERROR "difficulty_cut not set")
|
||||
endif()
|
||||
if (NOT DEFINED p2p_default_port)
|
||||
message(FATAL_ERROR "p2p_default_port not set")
|
||||
endif()
|
||||
if (NOT DEFINED rpc_default_port)
|
||||
message(FATAL_ERROR "rpc_default_port not set")
|
||||
endif()
|
||||
if (NOT DEFINED stratum_default_port)
|
||||
message(FATAL_ERROR "stratum_default_port not set")
|
||||
endif()
|
||||
if (NOT DEFINED p2p_maintainers_pub_key)
|
||||
message(FATAL_ERROR "p2p_maintainers_pub_key not set")
|
||||
endif()
|
||||
if (NOT DEFINED currency_name_abr)
|
||||
message(FATAL_ERROR "currency_name_abr not set")
|
||||
endif()
|
||||
if (NOT DEFINED currency_name_base)
|
||||
message(FATAL_ERROR "currency_name_base not set")
|
||||
endif()
|
||||
if (NOT DEFINED currency_name_short_base)
|
||||
message(FATAL_ERROR "currency_name_short_base not set")
|
||||
endif()
|
||||
20
cmake/config-vars.cmake
Normal file
20
cmake/config-vars.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
set(currency_display_decimal_point 12 CACHE STRING "CURRENCY_DISPLAY_DECIMAL_POINT" )
|
||||
set(coin 1000000000000 CACHE STRING "COIN" )
|
||||
set(base_reward_dust_threshold 1000000 CACHE STRING "BASE_REWARD_DUST_THRESHOLD")
|
||||
set(default_dust_threshold 0 CACHE STRING "DEFAULT_DUST_THRESHOLD" )
|
||||
set(tx_default_fee 10000000000 CACHE STRING "TX_DEFAULT_FEE" )
|
||||
set(tx_minimum_fee 10000000000 CACHE STRING "TX_MINIMUM_FEE" )
|
||||
set(difficulty_pow_starter 1 CACHE STRING "DIFFICULTY_POW_STARTER" )
|
||||
set(difficulty_pos_target 120 CACHE STRING "DIFFICULTY_POS_TARGET" )
|
||||
set(difficulty_pow_target 120 CACHE STRING "DIFFICULTY_POW_TARGET" )
|
||||
set(difficulty_window 720 CACHE STRING "DIFFICULTY_WINDOW" )
|
||||
set(difficulty_lag 15 CACHE STRING "DIFFICULTY_LAG" )
|
||||
set(difficulty_cut 60 CACHE STRING "DIFFICULTY_CUT" )
|
||||
set(p2p_default_port 36942 CACHE STRING "P2P_DEFAULT_PORT" )
|
||||
set(rpc_default_port 36941 CACHE STRING "RPC_DEFAULT_PORT" )
|
||||
set(stratum_default_port 36940 CACHE STRING "STRATUM_DEFAULT_PORT" )
|
||||
set(p2p_maintainers_pub_key "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607" CACHE STRING "P2P_MAINTAINERS_PUB_KEY" )
|
||||
set(currency_name_abr "FAKE" CACHE STRING "CURRENCY_NAME_ABR" )
|
||||
set(currency_name_base "Fake" CACHE STRING "CURRENCY_NAME_BASE" )
|
||||
set(currency_name_short_base "Fake" CACHE STRING "CURRENCY_NAME_SHORT_BASE" )
|
||||
set(premine_amount 4000000000000000000 CACHE STRING "PREMINE_AMOUNT" )
|
||||
20
cmake/currency_configs/example.cmake
Normal file
20
cmake/currency_configs/example.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
set(currency_display_decimal_point 12)
|
||||
set(coin 1000000000000)
|
||||
set(base_reward_dust_threshold 1000000)
|
||||
set(default_dust_threshold 0)
|
||||
set(tx_default_fee 10000000000)
|
||||
set(tx_minimum_fee 10000000000)
|
||||
set(difficulty_pow_starter 1)
|
||||
set(difficulty_pos_target 120)
|
||||
set(difficulty_pow_target 120)
|
||||
set(difficulty_window 720)
|
||||
set(difficulty_lag 15)
|
||||
set(difficulty_cut 60)
|
||||
set(p2p_default_port 36942)
|
||||
set(rpc_default_port 36941)
|
||||
set(stratum_default_port 36940)
|
||||
set(p2p_maintainers_pub_key "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607")
|
||||
set(currency_name_abr "NF")
|
||||
set(currency_name_base "NotFake")
|
||||
set(currency_name_short_base "NotFake")
|
||||
set(premine_amount 4000000000000000000)
|
||||
|
|
@ -50,6 +50,12 @@ MACRO(ENABLE_SHARED_PCH_EXECUTABLE target)
|
|||
ENDMACRO(ENABLE_SHARED_PCH_EXECUTABLE)
|
||||
##### End of Precompiled Headers macros ######
|
||||
|
||||
include_directories (${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/src/currency_core)
|
||||
include(../cmake/config-vars.cmake)
|
||||
include(../cmake/currency_configs/example.cmake)
|
||||
include(../cmake/check-config-vars.cmake)
|
||||
configure_file("currency_core/currency_config.h.in" "currency_core/currency_config.h")
|
||||
|
||||
|
||||
file(GLOB_RECURSE PCH pch/*)
|
||||
file(GLOB_RECURSE COMMON common/*)
|
||||
|
|
@ -65,6 +71,7 @@ file(GLOB_RECURSE SIMPLEWALLET simplewallet/*)
|
|||
file(GLOB_RECURSE CONN_TOOL connectivity_tool/*)
|
||||
file(GLOB_RECURSE WALLET wallet/*)
|
||||
file(GLOB_RECURSE MINER miner/*)
|
||||
file(GLOB_RECURSE GENESIS_GENERATOR genesis_generator/*)
|
||||
|
||||
|
||||
source_group(pch FILES ${PCH})
|
||||
|
|
@ -79,6 +86,7 @@ source_group(stratum FILES ${STRATUM})
|
|||
source_group(simplewallet FILES ${SIMPLEWALLET})
|
||||
source_group(connectivity-tool FILES ${CONN_TOOL})
|
||||
source_group(wallet FILES ${WALLET})
|
||||
source_group(genesis_generator FILES ${GENESIS_GENERATOR})
|
||||
|
||||
|
||||
INIT_SHARED_PCH()
|
||||
|
|
@ -154,6 +162,63 @@ ENABLE_SHARED_PCH(stratum STRATUM)
|
|||
|
||||
target_link_libraries(currency_core lmdb mdbx)
|
||||
|
||||
# CAUTION - wallet generation will only work properly in UNIX line environment
|
||||
set(GENERATE_FRESH_GENESIS OFF CACHE BOOL "Generate new genesis block")
|
||||
|
||||
set(GENESIS_PREMINE_ADDRESS "" CACHE STRING "Premine wallet address")
|
||||
set(GENESIS_PROOF "" CACHE STRING "Genesis proof string")
|
||||
|
||||
set(GENERATE_PREMINE_WALLET OFF CACHE BOOL "Generate premine wallet")
|
||||
set(PREMINE_WALLET_PASSWORD "" CACHE STRING "Premine wallet password")
|
||||
|
||||
if (GENERATE_PREMINE_WALLET AND GENERATE_FRESH_GENESIS)
|
||||
message(FATAL_ERROR "Genesis can be generatet together with premine wallet")
|
||||
endif()
|
||||
|
||||
if (GENERATE_PREMINE_WALLET)
|
||||
unset(GENERATE_PREMINE_WALLET CACHE)
|
||||
message(WARNING "Generating premine wallet")
|
||||
|
||||
if (NOT DEFINED PREMINE_WALLET_PASSWORD OR PREMINE_WALLET_PASSWORD STREQUAL "")
|
||||
message(FATAL_ERROR "set PREMINE_WALLET_PASSWORD or GENESIS_PREMINE_ADDRESS to generate genesis block")
|
||||
endif()
|
||||
|
||||
# Make wallet directory
|
||||
add_custom_target(
|
||||
premine_wallet
|
||||
"${CMAKE_COMMAND}" -E make_directory "${CMAKE_SOURCE_DIR}/premine_wallet"
|
||||
COMMENT "Creating premine wallet directory"
|
||||
)
|
||||
|
||||
# Generate wallet
|
||||
add_custom_command(TARGET premine_wallet POST_BUILD
|
||||
COMMAND echo ${PREMINE_WALLET_PASSWORD} | ${CMAKE_BINARY_DIR}/src/simplewallet --generate-new-wallet ${CMAKE_SOURCE_DIR}/premine_wallet/premine_wallet
|
||||
COMMENT "Generating premine wallet in ${CMAKE_SOURCE_DIR}/premine_wallet"
|
||||
)
|
||||
|
||||
add_dependencies(premine_wallet simplewallet)
|
||||
endif()
|
||||
|
||||
if (GENERATE_FRESH_GENESIS)
|
||||
unset(GENERATE_FRESH_GENESIS CACHE)
|
||||
add_executable(genesis_generator ${GENESIS_GENERATOR})
|
||||
target_link_libraries(genesis_generator currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
if (NOT DEFINED GENESIS_PREMINE_ADDRESS OR GENESIS_PREMINE_ADDRESS STREQUAL "")
|
||||
message(WARNING "GENESIS_PREMINE_ADDRESS not set, loading from ${CMAKE_SOURCE_DIR}/premine_wallet/premine_wallet.address")
|
||||
file(READ "${CMAKE_SOURCE_DIR}/premine_wallet/premine_wallet.address" GENESIS_PREMINE_ADDRESS)
|
||||
if (NOT DEFINED GENESIS_PREMINE_ADDRESS OR GENESIS_PREMINE_ADDRESS STREQUAL "")
|
||||
message(FATAL_ERROR "GENESIS_PREMINE_ADDRESS not set")
|
||||
endif()
|
||||
else()
|
||||
add_custom_command(TARGET genesis_generator POST_BUILD
|
||||
COMMAND ${CMAKE_BINARY_DIR}/src/genesis_generator --address ${GENESIS_PREMINE_ADDRESS} --proof ${GENESIS_PROOF} --output ${CMAKE_SOURCE_DIR}/src/currency_core/generated/
|
||||
COMMENT "Generating genesis data in ${CMAKE_SOURCE_DIR}/src/currency_core/"
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL})
|
||||
add_dependencies(daemon version)
|
||||
target_link_libraries(daemon rpc stratum currency_core crypto common miniupnpc::miniupnpc ZLIB::ZLIB ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
|
|
|||
|
|
@ -56,15 +56,15 @@
|
|||
#define CURRENCY_COINBASE_BLOB_RESERVED_SIZE 1100
|
||||
#define CURRENCY_MAX_TRANSACTION_BLOB_SIZE (CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE - CURRENCY_COINBASE_BLOB_RESERVED_SIZE*2)
|
||||
#define CURRENCY_FREE_TX_MAX_BLOB_SIZE 1024 // soft txpool-based limit for free-of-charge txs (such as BC_OFFERS_SERVICE_INSTRUCTION_DEL)
|
||||
#define CURRENCY_DISPLAY_DECIMAL_POINT 12
|
||||
#define CURRENCY_DISPLAY_DECIMAL_POINT @currency_display_decimal_point@
|
||||
|
||||
// COIN - number of smallest units in one coin
|
||||
#define COIN ((uint64_t)1000000000000) // pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
|
||||
#define BASE_REWARD_DUST_THRESHOLD ((uint64_t)1000000) // pow(10, 6) - change this will cause hard-fork!
|
||||
#define DEFAULT_DUST_THRESHOLD ((uint64_t)0)
|
||||
#define COIN ((uint64_t)@coin@) // pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
|
||||
#define BASE_REWARD_DUST_THRESHOLD ((uint64_t)@base_reward_dust_threshold@) // pow(10, 6) - change this will cause hard-fork!
|
||||
#define DEFAULT_DUST_THRESHOLD ((uint64_t)@default_dust_threshold@)
|
||||
|
||||
#define TX_DEFAULT_FEE ((uint64_t)10000000000) // .01
|
||||
#define TX_MINIMUM_FEE ((uint64_t)10000000000) // .01
|
||||
#define TX_DEFAULT_FEE ((uint64_t)@tx_default_fee@) // .01
|
||||
#define TX_MINIMUM_FEE ((uint64_t)@tx_minimum_fee@) // .01
|
||||
|
||||
#define CURRENCY_BLOCK_REWARD 1000000000000 // 1.0 coin == pow(10, CURRENCY_DISPLAY_DECIMAL_POINT)
|
||||
|
||||
|
|
@ -73,13 +73,13 @@
|
|||
#define CURRENCY_MINER_TX_MAX_OUTS CURRENCY_TX_MAX_ALLOWED_OUTS
|
||||
#define CURRENCY_TX_OUTS_RND_SPLIT_DIGITS_TO_KEEP 3
|
||||
|
||||
#define DIFFICULTY_POW_STARTER 1
|
||||
#define DIFFICULTY_POS_TARGET 120 // seconds
|
||||
#define DIFFICULTY_POW_TARGET 120 // seconds
|
||||
#define DIFFICULTY_POW_STARTER @difficulty_pow_starter@
|
||||
#define DIFFICULTY_POS_TARGET @difficulty_pos_target@ // seconds
|
||||
#define DIFFICULTY_POW_TARGET @difficulty_pow_target@ // seconds
|
||||
#define DIFFICULTY_TOTAL_TARGET ((DIFFICULTY_POS_TARGET + DIFFICULTY_POW_TARGET) / 4)
|
||||
#define DIFFICULTY_WINDOW 720 // blocks
|
||||
#define DIFFICULTY_LAG 15 // !!!
|
||||
#define DIFFICULTY_CUT 60 // timestamps to cut after sorting
|
||||
#define DIFFICULTY_WINDOW @difficulty_window@ // blocks
|
||||
#define DIFFICULTY_LAG @difficulty_lag@ // !!!
|
||||
#define DIFFICULTY_CUT @difficulty_cut@ // timestamps to cut after sorting
|
||||
#define DIFFICULTY_BLOCKS_COUNT (DIFFICULTY_WINDOW + DIFFICULTY_LAG)
|
||||
|
||||
#define CURRENCY_BLOCKS_PER_DAY ((60*60*24)/(DIFFICULTY_TOTAL_TARGET))
|
||||
|
|
@ -113,20 +113,20 @@
|
|||
|
||||
|
||||
#ifndef TESTNET
|
||||
#define P2P_DEFAULT_PORT 11121
|
||||
#define RPC_DEFAULT_PORT 11211
|
||||
#define STRATUM_DEFAULT_PORT 11777
|
||||
#define P2P_NETWORK_ID_TESTNET_FLAG 0
|
||||
#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607"
|
||||
#define DIFFICULTY_POS_STARTER 1
|
||||
#else
|
||||
#define P2P_DEFAULT_PORT (11211 + CURRENCY_FORMATION_VERSION)
|
||||
#define RPC_DEFAULT_PORT 12111
|
||||
#define STRATUM_DEFAULT_PORT 11888
|
||||
#define STRARUM_DEFAULT_PORT 51113
|
||||
#define P2P_DEFAULT_PORT (36942 + CURRENCY_FORMATION_VERSION)
|
||||
#define RPC_DEFAULT_PORT 36941
|
||||
#define STRATUM_DEFAULT_PORT 36940
|
||||
//#define STRARUM_DEFAULT_PORT 51113
|
||||
#define P2P_NETWORK_ID_TESTNET_FLAG 1
|
||||
#define P2P_MAINTAINERS_PUB_KEY "aaa2d7aabc8d383fd53a3ae898697b28f236ceade6bafc1eecff413a6a02272a"
|
||||
#define DIFFICULTY_POS_STARTER 1
|
||||
#else
|
||||
#define P2P_DEFAULT_PORT @p2p_default_port@
|
||||
#define RPC_DEFAULT_PORT @rpc_default_port@
|
||||
#define STRATUM_DEFAULT_PORT @stratum_default_port@
|
||||
#define P2P_NETWORK_ID_TESTNET_FLAG 0
|
||||
#define P2P_MAINTAINERS_PUB_KEY "@p2p_maintainers_pub_key@"
|
||||
#define DIFFICULTY_POS_STARTER 1
|
||||
#endif
|
||||
|
||||
#define P2P_NETWORK_ID_VER (CURRENCY_FORMATION_VERSION+0)
|
||||
|
|
@ -195,9 +195,9 @@
|
|||
|
||||
|
||||
|
||||
#define CURRENCY_NAME_ABR "ZANO"
|
||||
#define CURRENCY_NAME_BASE "Zano"
|
||||
#define CURRENCY_NAME_SHORT_BASE "Zano"
|
||||
#define CURRENCY_NAME_ABR "@currency_name_abr@"
|
||||
#define CURRENCY_NAME_BASE "@currency_name_base@"
|
||||
#define CURRENCY_NAME_SHORT_BASE "@currency_name_short_base@"
|
||||
#ifndef TESTNET
|
||||
#define CURRENCY_NAME CURRENCY_NAME_BASE
|
||||
#define CURRENCY_NAME_SHORT CURRENCY_NAME_SHORT_BASE
|
||||
|
|
@ -207,7 +207,7 @@
|
|||
#endif
|
||||
|
||||
//premine
|
||||
#define PREMINE_AMOUNT (17517203000000000000U) // 13827203.0 reserved for coinswap, 3690000.0 - premine
|
||||
#define PREMINE_AMOUNT (@premine_amount@U) // 13827203.0 reserved for coinswap, 3690000.0 - premine
|
||||
|
||||
//alias registration wallet
|
||||
#define ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
|
||||
|
|
@ -317,7 +317,7 @@ static_assert(CURRENCY_MINER_TX_MAX_OUTS <= CURRENCY_TX_MAX_ALLOWED_OUTS, "Miner
|
|||
static_assert(PREMINE_AMOUNT / WALLET_MAX_ALLOWED_OUTPUT_AMOUNT < CURRENCY_MINER_TX_MAX_OUTS, "Premine can't be divided into reasonable number of outs");
|
||||
|
||||
#define CURRENCY_RELAY_TXS_MAX_COUNT 5
|
||||
|
||||
// FIXME
|
||||
#ifndef TESTNET
|
||||
#define WALLET_ASSETS_WHITELIST_URL "https://api.zano.org/assets_whitelist.json"
|
||||
#else
|
||||
3
src/currency_core/generated/_genesis.cpp.gen
Normal file
3
src/currency_core/generated/_genesis.cpp.gen
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
const genesis_tx_raw_data ggenesis_tx_raw = {{
|
||||
0xe980800100000101,0xfbfa3a0316deb183,0x0e4d0bf7103b2df2,0x682df55627fc33ed,0xcd945b3d70689611,0x16050066b218269a,0x34af8b24a9c955d2,0x3f514b3a2be34ee9,0xb6525b442410e776,0x256d4d83666fb42a,0x6b61742074496b13,0x6e61766461207365,0x20666f2065676174,0x7574616e20656874,0x6e6920666f206572,0x6f6974616d726f66,0x20676e696562206e,0x206f742079736165,0x6220646165727073,0x2064726168207475,0x6c66697473206f74,0x746153202d202e65,0x6b614e206968736f,0x0b00156f746f6d61},
|
||||
{0x02,0x8a,0x56,0x0e,0x0a,0x00,0x00}};
|
||||
5
src/currency_core/generated/_genesis.h.gen
Normal file
5
src/currency_core/generated/_genesis.h.gen
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
struct genesis_tx_raw_data
|
||||
{
|
||||
uint64_t const v[42];
|
||||
uint8_t const r[42];
|
||||
};
|
||||
6
src/currency_core/generated/_genesis_acc.cpp.gen
Normal file
6
src/currency_core/generated/_genesis_acc.cpp.gen
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
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}
|
||||
};
|
||||
6
src/currency_core/generated/_genesis_acc_tn.cpp.gen
Normal file
6
src/currency_core/generated/_genesis_acc_tn.cpp.gen
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const std::string ggenesis_tx_pub_key_str = "e6e4c44e117ea47e355ad871cbbf0d0a8aed15c8cd44b9d02a21c90b8831e7f6";
|
||||
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] = {
|
||||
{12209970162623619798ULL,0}
|
||||
};
|
||||
3
src/currency_core/generated/_genesis_tn.cpp.gen
Normal file
3
src/currency_core/generated/_genesis_tn.cpp.gen
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
const genesis_tx_raw_data ggenesis_tx_raw = {{
|
||||
0xc080800100000101,0x8c0337c1b6d9e9ec,0x4e22a822e89151ed,0x945d81f56c551f9e,0x5a84b14938248553,0x00671298a0463d3a,0x7e114ec4e4e61605,0xbfcb71d85a357ea4,0x44cdc815ed8a0a0d,0x31880bc9212ad0b9,0x6d776f770c13f6e7,0x666f6f7270686375,0x0a0e36ce020b0015},
|
||||
{0x00,0x00}};
|
||||
5
src/currency_core/generated/_genesis_tn.h.gen
Normal file
5
src/currency_core/generated/_genesis_tn.h.gen
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
struct genesis_tx_raw_data
|
||||
{
|
||||
uint64_t const v[13];
|
||||
uint8_t const r[2];
|
||||
};
|
||||
|
|
@ -7,12 +7,8 @@
|
|||
namespace currency
|
||||
{
|
||||
#ifndef TESTNET
|
||||
const genesis_tx_raw_data ggenesis_tx_raw = { {
|
||||
0xa080801a00000101,0x800326b0b4a0f2fd,0xeebe5a6d44a03ed5,0x0e146a5322076dcf,0x992269ec1e34796e,0x003b14d1fe6c757e,0xb0b4a0f2fda08080,0xfd92adf982e70326,0xd8d4b6458b60e1a4,0xa69adb9475e808ed,0x4c383fcedfb6e20a,0xf2fda08080003458,0x8b177f0326b0b4a0,0xef9769ed70d152cd,0x04097d0daa65d123,0x9cd9f8e708f25bbc,0x8080005dfb23beac,0x0326b0b4a0f2fda0,0x6752077f8e75fc8a,0x437f68e0bf774836,0x5a38b52ff21c01c0,0x2d3727ec82ce1425,0xb4f89aecdce08000,0xa07d9fe35f0326b0,0x6c742533eb3b4261,0xfc2ed631332e5e16,0x3d025449393e538b,0x93dc80800015e433,0x70a20307d0ffc2e0,0xb81808dc5029bd46,0x04129413283e31f1,0x143e631cc81020b0,0x80008519d1377ae3,0x05c6c5bc97b1a080,0xf71887a841a72a03,0x681b659b8d2832d4,0x5677f9b15d11d1e6,0xffb2ad80c02a341c,0xbc97b1a08080003f,0xf9cebe7c0305c6c5,0xee223954dc682820,0x8194d2bac0dff6d6,0x86d8a55a30e30183,0xa08080006775f5f0,0x220305c6c5bc97b1,0x3c36e1ebdcee584a,0x4e9ed1a89532ef46,0xf0cb8b411bf6d579,0x00d0e6392ada64d4,0xc6c5bc97b1a08080,0x2fc2b05779450305,0xc9cf47618cc5283e,0xa9e088224807a77e,0xda854e29d2f49646,0x97b1a08080002e74,0xed35180305c6c5bc,0xa78d5545117b8293,0x5c3f8babc16e7062,0xef9324ecd7f86e39,0x808000231900ee9c,0x0305c6c5bc97b1a0,0x0c5bfd9450e89e30,0x194b86e8316970bc,0x5dd8c2e3c2af6ff1,0x4d2ba46f683df89c,0xc5bc97b1a0808000,0xc7cc22ad390305c6,0x891b500cb0799642,0xf5884473a7c01f07,0xeb88d74972d8e36f,0x91ed808000b5d239,0x535a0302fddecd95,0x791c7275cd15d685,0xc2536511d4132e01,0x0c9ad1ee9196aa77,0x80002d55a4efc7d3,0x018e8df2b7f0a080,0x0848b53f974a6a03,0x96b2572cb6015b7d,0xa71b18d2755de52c,0x075e4ca4bd0e4487,0xef93bf82808000ca,0xe23077bc730308f0,0x266a622b7bd9de26,0x4b80410b36c32203,0xb3026d0a2610916c,0xfe8480800084746d,0x6f34b90311e1dea6,0xeb38aee70a8febba,0x8b45df519f0df12e,0x258f0a71e83385da,0x8080000b85701a76,0xdf0308f0ef93bf82,0xb3170ab580f881a3,0x07f0a33f0756a3f4,0xf0721645b2b2bd7b,0x00b0077e03f43a85,0x08f0ef93bf828080,0xf91c1f6308c00f03,0x901a68f4adcc918b,0xad0346f5b7869662,0xd3ed49961fccd915,0xafeaa69a808000f0,0x2c99a01fe90301e3,0xd28642bcae6728d9,0xa6f38c4c630c2b6c,0x2c8a361de6b9294f,0xa69a8080002191e8,0xe134670301e3afea,0x6cf0798aeae985c8,0x4c9b90e1ff211b81,0xc32a954ce05a738b,0x8080009fd2412c6f,0x790301e3afeaa69a,0xb3b0062d6c27a6bb,0x12e133832172b705,0xf3f7d1dfdf336fb8,0x00922d0a879c6027,0x03c6dfd4ccb48080,0x7aa13f278feecf03,0x464f78f86a3e4553,0xa5a464e65c4cf651,0x18f07e7ed8bdd351,0xef93bf82808000dd,0x70b4e3ebae0308f0,0x74c452ecdce312d9,0xca3fb591982461fc,0x3e01aaf9b53ede69,0xfe84808000a4fa65,0x20e5ba0311e1dea6,0xb3e07ec0aabd06a5,0x7bf14a03bf83ccfd,0x6024154f95fd3220,0x808000c13077fa8b,0x5c580316deb183e9,0xc2c948248ab422c3,0xebd3db36bad27d52,0x5fe30392c1525a4e,0x1e00952287d66a6d,0x163df474d5ba8816,0x86f8892015449a71,0x22c93333d9ecb472,0x64fa5516bddfebb3,0x3234373061401303,0x3934353331623633,0x3063626435643130,0x6334636130633932,0x3831383439633530,0x3330336634336332,0x3963306232336630,0x3261623765656133,0x80c9170015633537,0x4c17fba117829117,0x17624a17d2f21711,0xfec81731f9178ced,0x9c17624117a36017,0x1786df17edda1708,0x9ffa17d6e1171b42,0x8b17aa69177ff417,0x179815170a83170c,0xc7e8171ce317da27 },
|
||||
{ 0x17,0x86,0xd6,0x0e,0x0a,0x00,0x00 } };
|
||||
#include "generated/_genesis.cpp.gen"
|
||||
#else
|
||||
const genesis_tx_raw_data ggenesis_tx_raw = {{
|
||||
0xd880800500000101,0x0301f2ee9fa8ff8a,0xac88983c159856b0,0x6334c7d1b567f262,0x284f7f961a7b1266,0x8c0c68c45bab62fc,0xe1dea6fe84808000,0x337be98b45240311,0xab6cd1e4c66e5a33,0x70e889d98e70fd57,0xb97de43fb09861d4,0xf9f0cde08000d574,0x0270187703048dba,0xcac58027c0851473,0xaa10d864c4c87b46,0x820d371e2ba469e8,0xfea08000fce35acc,0x357903049598bddf,0x15df9e58bd0002aa,0xc940a97b60484e8d,0xf94f171e77d0b2d9,0x80003602c681487a,0x0304c38fbab1f8e0,0xc2529eba91cf7476,0x0bbee139aab295f9,0xf1cb8c58a828a2ca,0xcac8f5469af83932,0x5c8a1027cc160900,0x50bdcc9348baf32a,0xa7bd03751819d9fd,0xd6acc8dbbb0d9b29,0x3730614013368b02,0x3533316236333234,0x6264356431303934,0x6361306339323063,0x3834396335306334,0x3366343363323831,0x3062323366303330,0x6237656561333963,0x1700156335373261,0xce5017baa917a8f0,0x0a0eefcc17975617},
|
||||
{0x00,0x00}};
|
||||
#include "generated/_genesis_tn.cpp.gen"
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,9 @@ namespace currency
|
|||
{
|
||||
#pragma pack(push, 1)
|
||||
#ifndef TESTNET
|
||||
struct genesis_tx_raw_data
|
||||
{
|
||||
uint64_t const v[161];
|
||||
uint8_t const r[7];
|
||||
};
|
||||
|
||||
#include "generated/_genesis.h.gen"
|
||||
#else
|
||||
struct genesis_tx_raw_data
|
||||
{
|
||||
uint64_t const v[42];
|
||||
uint8_t const r[2];
|
||||
};
|
||||
#include "generated/_genesis_tn.h.gen"
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
extern const genesis_tx_raw_data ggenesis_tx_raw;
|
||||
|
|
|
|||
|
|
@ -10,51 +10,8 @@
|
|||
namespace currency
|
||||
{
|
||||
#ifndef TESTNET
|
||||
const std::string ggenesis_tx_pub_key_str = "88bad574f43d16719a44152089f88672b4ecd93333c922b3ebdfbd1655fa6403";
|
||||
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
|
||||
const genesis_tx_dictionary_entry ggenesis_dict[26] = {
|
||||
{ 898363347618325980ULL,7 },
|
||||
{ 1234271292339965434ULL,1 },
|
||||
{ 2785329203593578547ULL,12 },
|
||||
{ 2912579291078040461ULL,18 },
|
||||
{ 3515932779881697835ULL,17 },
|
||||
{ 4955366495399988463ULL,11 },
|
||||
{ 5233257582118330150ULL,5 },
|
||||
{ 5931539148443336682ULL,24 },
|
||||
{ 6436517662239927298ULL,19 },
|
||||
{ 6604452700210763953ULL,13 },
|
||||
{ 7200550178847042641ULL,15 },
|
||||
{ 8712326356392296687ULL,9 },
|
||||
{ 8863158309745010598ULL,4 },
|
||||
{ 9048445805125559105ULL,16 },
|
||||
{ 9527474759752332295ULL,2 },
|
||||
{ 9647541513390373765ULL,20 },
|
||||
{ 9921730437908704447ULL,8 },
|
||||
{ 10751885755236960099ULL,25 },
|
||||
{ 11032572278436047420ULL,22 },
|
||||
{ 11109691972771859220ULL,0 },
|
||||
{ 13554174209305230569ULL,23 },
|
||||
{ 14297297752337562678ULL,3 },
|
||||
{ 15636081871140663679ULL,21 },
|
||||
{ 15951161519112687845ULL,6 },
|
||||
{ 17146058209502212345ULL,14 },
|
||||
{ 17472133472787764818ULL,10 }
|
||||
};
|
||||
#include "generated/_genesis_acc.cpp.gen"
|
||||
#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 }
|
||||
};
|
||||
#include "generated/_genesis_acc_tn.cpp.gen"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ struct genesis_tx_dictionary_entry {
|
|||
#pragma pack(pop)
|
||||
|
||||
#ifndef TESTNET
|
||||
extern const genesis_tx_dictionary_entry ggenesis_dict[26];
|
||||
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
|
||||
#else
|
||||
extern const genesis_tx_dictionary_entry ggenesis_dict[5];
|
||||
extern const genesis_tx_dictionary_entry ggenesis_dict[1];
|
||||
#endif
|
||||
|
||||
extern const crypto::public_key ggenesis_tx_pub_key;
|
||||
|
|
|
|||
142
src/genesis_generator/generate_test_genesis.cpp
Normal file
142
src/genesis_generator/generate_test_genesis.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "misc_log_ex.h"
|
||||
#include "currency_core/currency_format_utils.h"
|
||||
#include "common/command_line.h"
|
||||
#include <boost/multiprecision/integer.hpp>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
bool generate_test_genesis(std::string address, std::string proof, std::string out_dir)
|
||||
{
|
||||
using namespace std;
|
||||
currency::block bl = boost::value_initialized<currency::block>();
|
||||
|
||||
#ifndef TESTNET
|
||||
constexpr auto posfix = "";
|
||||
#else
|
||||
constexpr auto posfix = "_tn";
|
||||
#endif
|
||||
|
||||
vector<currency::tx_destination_entry> destinations;
|
||||
currency::tx_destination_entry de = AUTO_VAL_INIT(de);
|
||||
de.addr.resize(1);
|
||||
|
||||
bool r = get_account_address_from_str(de.addr.back(), address);
|
||||
CHECK_AND_ASSERT_MES(r, false, "wrong address string: " << address);
|
||||
|
||||
de.amount = PREMINE_AMOUNT;
|
||||
destinations.push_back(de);
|
||||
|
||||
//make sure it initialized with zeros
|
||||
uint64_t summary_premine_coins = de.amount;
|
||||
|
||||
const currency::account_public_address dummy_address = AUTO_VAL_INIT(dummy_address);
|
||||
uint64_t block_reward_without_fee = 0;
|
||||
uint64_t block_reward = 0;
|
||||
construct_miner_tx(0, 0, 0, 0, 0,
|
||||
dummy_address, dummy_address, bl.miner_tx, block_reward_without_fee, block_reward,
|
||||
TRANSACTION_VERSION_PRE_HF4, 0, proof, CURRENCY_MINER_TX_MAX_OUTS, false, currency::pos_entry(),
|
||||
nullptr, nullptr, destinations);
|
||||
|
||||
currency::blobdata txb = tx_to_blob(bl.miner_tx);
|
||||
|
||||
//self validate block
|
||||
if (currency::get_outs_money_amount(bl.miner_tx) != summary_premine_coins )
|
||||
{
|
||||
LOG_ERROR("Internal error: total_this = " << summary_premine_coins << " didn't match with miner_tx total = " << currency::get_outs_money_amount(bl.miner_tx));
|
||||
}
|
||||
|
||||
string hex_tx_represent = epee::string_tools::buff_to_hex_nodelimer(txb);
|
||||
|
||||
auto ret = epee::file_io_utils::save_string_to_file(out_dir + ".genesis.txt", hex_tx_represent);
|
||||
CHECK_AND_ASSERT_MES_NO_RET(ret, "failed to create " << out_dir << ".genesis.txt");
|
||||
|
||||
uint64_t* parray = (uint64_t*)txb.data();
|
||||
size_t count = txb.size() / sizeof(uint64_t);
|
||||
size_t rest_bytes = txb.size() - count * sizeof(uint64_t);
|
||||
|
||||
basic_stringstream<char> genesis_h_stream;
|
||||
basic_stringstream<char> genesis_cpp_stream;
|
||||
genesis_h_stream << "struct genesis_tx_raw_data" << ENDL
|
||||
<< "{" << ENDL
|
||||
<< " uint64_t const v[" << count << "];" << ENDL
|
||||
<< " uint8_t const r[" << rest_bytes << "];" << ENDL
|
||||
<< "};" << ENDL;
|
||||
|
||||
genesis_cpp_stream << "const genesis_tx_raw_data ggenesis_tx_raw = {{" << ENDL;
|
||||
|
||||
for (size_t i = 0; i != count; i++)
|
||||
{
|
||||
genesis_cpp_stream << (i == 0 ? "0x":",0x")<< hex << setw(16) << setfill('0') << parray[i];
|
||||
}
|
||||
genesis_cpp_stream << "}," << ENDL << "{";
|
||||
uint8_t* ptail_array = (uint8_t*)&parray[count];
|
||||
for (size_t i = 0; i != rest_bytes; i++)
|
||||
{
|
||||
genesis_cpp_stream << (i == 0 ? "0x":",0x") << hex << setw(2) << setfill('0') << +ptail_array[i];
|
||||
}
|
||||
genesis_cpp_stream << "}};" << ENDL;
|
||||
|
||||
// Generate _genesis.cpp.gen
|
||||
// Generate _genesis.h.gen
|
||||
ret = epee::file_io_utils::save_string_to_file(out_dir + "_genesis" + posfix + ".h.gen", genesis_h_stream.str());
|
||||
CHECK_AND_ASSERT_MES_NO_RET(ret, "failed to create " << out_dir << "_genesis.h.gen");
|
||||
|
||||
ret = epee::file_io_utils::save_string_to_file(out_dir + "_genesis" + posfix + ".cpp.gen", genesis_cpp_stream.str());
|
||||
CHECK_AND_ASSERT_MES_NO_RET(ret, "failed to create " << out_dir << "_genesis.cpp.gen");
|
||||
|
||||
// Single address for now
|
||||
uint64_t key = currency::get_string_uint64_hash(address);
|
||||
|
||||
// Generate _genesis_acc.cpp.gen
|
||||
basic_stringstream<char> genesis_acc_stream;
|
||||
genesis_acc_stream << "const std::string ggenesis_tx_pub_key_str = \"" <<
|
||||
epee::string_tools::pod_to_hex(get_tx_pub_key_from_extra(bl.miner_tx)) << "\";" << ENDL;
|
||||
genesis_acc_stream << "const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);" << ENDL
|
||||
<< "extern const genesis_tx_dictionary_entry ggenesis_dict[" << 1 << "];" << ENDL
|
||||
<< "const genesis_tx_dictionary_entry ggenesis_dict[" << 1 << "] = {";
|
||||
genesis_acc_stream << "" << ENDL << "{" << key << "ULL," << 0 << "}";
|
||||
genesis_acc_stream << ENDL << "};" << ENDL;
|
||||
|
||||
ret = epee::file_io_utils::save_string_to_file(out_dir + "_genesis_acc" + posfix + ".cpp.gen", genesis_acc_stream.str());
|
||||
CHECK_AND_ASSERT_MES_NO_RET(ret, "failed to create " << out_dir << ".genesis.dictionary.txt");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
const command_line::arg_descriptor<std::string> arg_target_address("address", "Premine wallet address");
|
||||
const command_line::arg_descriptor<std::string> arg_proof("proof", "Genesis proof string");
|
||||
const command_line::arg_descriptor<std::string> arg_dir("output", "Direcory output for generated files");
|
||||
po::options_description desc_cmd("Command line options");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
command_line::add_arg(desc_cmd, arg_target_address);
|
||||
command_line::add_arg(desc_cmd, arg_proof);
|
||||
command_line::add_arg(desc_cmd, arg_dir);
|
||||
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
po::variables_map vm;
|
||||
bool r = command_line::handle_error_helper(desc_cmd, [&]()
|
||||
{
|
||||
po::store(po::parse_command_line(argc, argv, desc_cmd), vm);
|
||||
po::notify(vm);
|
||||
return true;
|
||||
});
|
||||
if (!r) {
|
||||
LOG_ERROR("Param parsing failed!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string premine_address = command_line::get_arg(vm, arg_target_address);
|
||||
std::string proof = command_line::get_arg(vm, arg_proof);
|
||||
std::string dir = command_line::get_arg(vm, arg_dir);
|
||||
|
||||
LOG_PRINT_L0("addr:" << premine_address << " proof:" << proof << " amount:" << PREMINE_AMOUNT);
|
||||
generate_test_genesis(premine_address, proof, dir);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -634,6 +634,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas
|
|||
if (m_do_not_set_date)
|
||||
m_wallet->reset_creation_time(0);
|
||||
|
||||
epee::file_io_utils::save_string_to_file(wallet_file + ".address", m_wallet->get_account().get_public_address_str());
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue