Set valid Hive public key prefix for both mainnet and testnet

This commit is contained in:
serkixenos 2021-10-29 02:55:37 +02:00
parent 524f409f81
commit e964ac2f0f
3 changed files with 10 additions and 4 deletions

View file

@ -7,7 +7,7 @@
namespace graphene { namespace peerplays_sidechain { namespace hive {
#define ADDRESS_PREFIX "TST"
std::string public_key_type::prefix = KEY_PREFIX_STM;
public_key_type::public_key_type() :
key_data(){};
@ -19,8 +19,6 @@ public_key_type::public_key_type(const fc::ecc::public_key &pubkey) :
key_data(pubkey){};
public_key_type::public_key_type(const std::string &base58str) {
std::string prefix(ADDRESS_PREFIX);
const size_t prefix_len = prefix.size();
FC_ASSERT(base58str.size() > prefix_len);
FC_ASSERT(base58str.substr(0, prefix_len) == prefix, "", ("base58str", base58str));
@ -43,7 +41,7 @@ public_key_type::operator std::string() const {
k.data = key_data;
k.check = fc::ripemd160::hash(k.data.data, k.data.size())._hash[0];
auto data = fc::raw::pack(k);
return ADDRESS_PREFIX + fc::to_base58(data.data(), data.size());
return prefix + fc::to_base58(data.data(), data.size());
}
bool operator==(const public_key_type &p1, const fc::ecc::public_key &p2) {

View file

@ -5,6 +5,9 @@
namespace graphene { namespace peerplays_sidechain { namespace hive {
#define KEY_PREFIX_STM "STM"
#define KEY_PREFIX_TST "TST"
enum network {
mainnet,
testnet
@ -30,6 +33,9 @@ typedef fc::safe<int64_t> share_type;
//typedef fixed_string<32> custom_id_type;
struct public_key_type {
static std::string prefix;
struct binary_key {
binary_key() {
}

View file

@ -211,10 +211,12 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
ilog("Running on Hive mainnet, chain id ${chain_id_str}", ("chain_id_str", chain_id_str));
hive::asset::hbd_symbol_ser = HBD_SYMBOL_SER;
hive::asset::hive_symbol_ser = HIVE_SYMBOL_SER;
hive::public_key_type::prefix = KEY_PREFIX_STM;
} else {
ilog("Running on Hive testnet, chain id ${chain_id_str}", ("chain_id_str", chain_id_str));
hive::asset::hbd_symbol_ser = TBD_SYMBOL_SER;
hive::asset::hive_symbol_ser = TESTS_SYMBOL_SER;
hive::public_key_type::prefix = KEY_PREFIX_TST;
}
last_block_received = 0;