TARAXA
tools.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <json/json.h>
4 #include <libdevcrypto/Common.h>
5 
6 #include <string>
7 
8 #include "cli/config.hpp"
9 #include "common/vrf_wrapper.hpp"
10 
11 namespace taraxa::cli::tools {
12 
13 constexpr const char* DEFAULT_TARAXA_DIR_NAME = ".taraxa";
14 constexpr const char* DEFAULT_TARAXA_DATA_DIR_NAME = ".taraxa/data";
15 constexpr const char* DEFAULT_WALLET_FILE_NAME = "wallet.json";
16 constexpr const char* DEFAULT_CONFIG_FILE_NAME = "config.json";
17 constexpr const char* DEFAULT_GENESIS_FILE_NAME = "genesis.json";
18 const std::filesystem::path configs_path = std::filesystem::current_path() / "config_jsons";
19 
20 // Account generation
21 void generateAccount();
22 void generateAccount(const dev::KeyPair& account);
23 void generateAccountFromKey(const std::string& key);
24 
25 // VRF generation
26 void generateVrf();
28 void generateVrfFromKey(const std::string& key);
29 
30 // Generate default config and wallet files
31 int getChainIdFromString(std::string& chain_str);
32 void getConfig(const std::string& config, cli::Config::ChainIdType chain_id);
33 Json::Value getConfig(Config::ChainIdType chain_id);
34 Json::Value getGenesis(Config::ChainIdType chain_id);
35 void generateWallet(const std::string& wallet);
36 
37 // Override existing config and wallet files
38 Json::Value overrideConfig(Json::Value& config, std::string& data_dir, const std::vector<std::string>& boot_nodes,
39  const std::vector<std::string>& log_channels,
40  const std::vector<std::string>& log_configurations,
41  const std::vector<std::string>& boot_nodes_append,
42  const std::vector<std::string>& log_channels_append);
43 Json::Value overrideWallet(Json::Value& wallet, const std::string& node_key, const std::string& vrf_key);
44 
45 std::string getHomeDir();
46 std::string getTaraxaDefaultDir();
47 std::string getTaraxaDataDefaultDir();
48 std::string getTaraxaDefaultConfigFile();
49 std::string getTaraxaDefaultWalletFile();
50 std::string getTaraxaDefaultGenesisFile();
51 Json::Value createWalletJson(const dev::KeyPair& account, const taraxa::vrf_wrapper::vrf_sk_t& sk,
53 
54 } // namespace taraxa::cli::tools
Definition: Common.h:154
ChainIdType
Definition: config.hpp:20
Definition: tools.hpp:11
void generateAccount()
Definition: tools.cpp:198
constexpr const char * DEFAULT_TARAXA_DIR_NAME
Definition: tools.hpp:13
void getConfig(const std::string &config, cli::Config::ChainIdType chain_id)
Json::Value overrideConfig(Json::Value &config, std::string &data_dir, const std::vector< std::string > &boot_nodes, const std::vector< std::string > &log_channels, const std::vector< std::string > &log_configurations, const std::vector< std::string > &boot_nodes_append, const std::vector< std::string > &log_channels_append)
Json::Value createWalletJson(const dev::KeyPair &account, const taraxa::vrf_wrapper::vrf_sk_t &sk, const taraxa::vrf_wrapper::vrf_pk_t &pk)
Definition: tools.cpp:222
int getChainIdFromString(std::string &chain_str)
Definition: tools.cpp:17
constexpr const char * DEFAULT_GENESIS_FILE_NAME
Definition: tools.hpp:17
std::string getTaraxaDataDefaultDir()
Definition: tools.cpp:238
std::string getTaraxaDefaultConfigFile()
Definition: tools.cpp:242
void generateVrfFromKey(const std::string &key)
std::string getTaraxaDefaultWalletFile()
Definition: tools.cpp:240
void generateVrf()
Definition: tools.cpp:211
std::string getHomeDir()
Definition: tools.cpp:234
const std::filesystem::path configs_path
Definition: tools.hpp:18
constexpr const char * DEFAULT_CONFIG_FILE_NAME
Definition: tools.hpp:16
constexpr const char * DEFAULT_TARAXA_DATA_DIR_NAME
Definition: tools.hpp:14
Json::Value getGenesis(Config::ChainIdType chain_id)
Definition: tools.cpp:47
void generateAccountFromKey(const std::string &key)
Json::Value overrideWallet(Json::Value &wallet, const std::string &node_key, const std::string &vrf_key)
Definition: tools.cpp:173
void generateWallet(const std::string &wallet)
std::string getTaraxaDefaultGenesisFile()
Definition: tools.cpp:244
constexpr const char * DEFAULT_WALLET_FILE_NAME
Definition: tools.hpp:15
std::string getTaraxaDefaultDir()
Definition: tools.cpp:236