Use enum_field for type to use lns::mapping_type

This commit is contained in:
Doyle 2020-02-19 12:35:10 +11:00
parent 086cd874bd
commit 2ee128c47a
11 changed files with 188 additions and 171 deletions

View File

@ -62,6 +62,17 @@
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
namespace lns
{
enum struct mapping_type : uint16_t
{
session = 0,
wallet = 1,
lokinet = 2,
_count,
};
};
namespace service_nodes {
enum class new_state : uint16_t
{
@ -388,18 +399,19 @@ namespace cryptonote
{
buy = 0,
update = 1,
_count,
};
uint8_t version = 0;
uint8_t command;
command_t command;
lns::mapping_type type; // alias to lns::mapping_type
crypto::ed25519_public_key owner; // only serialized if command == command_t::buy
crypto::ed25519_signature signature; // only serialized if command == command_t::update
uint16_t type; // alias to lns::mapping_type
std::string name;
std::string value; // binary format of the name->value mapping
crypto::hash prev_txid = crypto::null_hash; // previous txid that purchased the mapping
static tx_extra_loki_name_system make_buy(crypto::ed25519_public_key const &owner, uint16_t type, std::string const &name, std::string const &value, crypto::hash const &prev_txid)
static tx_extra_loki_name_system make_buy(crypto::ed25519_public_key const &owner, lns::mapping_type type, std::string const &name, std::string const &value, crypto::hash const &prev_txid)
{
tx_extra_loki_name_system result = {};
result.owner = owner;
@ -407,11 +419,11 @@ namespace cryptonote
result.name = name;
result.value = value;
result.prev_txid = prev_txid;
result.command = static_cast<uint8_t>(tx_extra_loki_name_system::command_t::buy);
result.command = tx_extra_loki_name_system::command_t::buy;
return result;
}
static tx_extra_loki_name_system make_update(crypto::ed25519_signature const &signature, uint16_t type, std::string const &name, std::string const &value, crypto::hash const &prev_txid)
static tx_extra_loki_name_system make_update(crypto::ed25519_signature const &signature, lns::mapping_type type, std::string const &name, std::string const &value, crypto::hash const &prev_txid)
{
tx_extra_loki_name_system result = {};
result.signature = signature;
@ -419,18 +431,18 @@ namespace cryptonote
result.name = name;
result.value = value;
result.prev_txid = prev_txid;
result.command = static_cast<uint8_t>(tx_extra_loki_name_system::command_t::update);
result.command = tx_extra_loki_name_system::command_t::update;
return result;
}
BEGIN_SERIALIZE()
FIELD(version)
FIELD(command)
if (command == static_cast<uint8_t>(command_t::buy))
ENUM_FIELD(type, type < lns::mapping_type::_count)
ENUM_FIELD(command, command < command_t::_count)
if (command == command_t::buy)
FIELD(owner)
else
FIELD(signature)
FIELD(type)
FIELD(name)
FIELD(value)
FIELD(prev_txid)

View File

@ -132,7 +132,11 @@ static bool sql_run_statement(cryptonote::network_type nettype, lns_sql_type typ
case lns_sql_type::get_mapping:
{
mapping_record tmp_entry = {};
tmp_entry.type = static_cast<uint16_t>(sqlite3_column_int(statement, static_cast<int>(mapping_record_row::type)));
int type_int = static_cast<uint16_t>(sqlite3_column_int(statement, static_cast<int>(mapping_record_row::type)));
if (type_int >= tools::enum_count<mapping_type>)
return false;
tmp_entry.type = static_cast<mapping_type>(type_int);
tmp_entry.register_height = static_cast<uint16_t>(sqlite3_column_int(statement, static_cast<int>(mapping_record_row::register_height)));
tmp_entry.owner_id = sqlite3_column_int(statement, static_cast<int>(mapping_record_row::owner_id));
@ -197,7 +201,7 @@ static bool sql_run_statement(cryptonote::network_type nettype, lns_sql_type typ
bool mapping_record::active(cryptonote::network_type nettype, uint64_t blockchain_height) const
{
if (!loaded) return false;
if (type != static_cast<uint16_t>(mapping_type::lokinet)) return true;
if (type != mapping_type::lokinet) return true;
uint64_t expiry_blocks = lns::lokinet_expiry_blocks(nettype);
uint64_t const last_active_height = register_height + expiry_blocks;
return last_active_height >= (blockchain_height - 1);
@ -324,15 +328,15 @@ static bool char_is_alphanum(char c)
return result;
}
bool validate_lns_name(uint16_t type, std::string const &name, std::string *reason)
bool validate_lns_name(mapping_type type, std::string const &name, std::string *reason)
{
std::stringstream err_stream;
LOKI_DEFER { if (reason) *reason = err_stream.str(); };
size_t max_name_len = lns::GENERIC_NAME_MAX;
if (type == static_cast<uint16_t>(mapping_type::session)) max_name_len = lns::SESSION_DISPLAY_NAME_MAX;
else if (type == static_cast<uint16_t>(mapping_type::wallet)) max_name_len = lns::WALLET_NAME_MAX;
else if (type == static_cast<uint16_t>(mapping_type::lokinet)) max_name_len = lns::LOKINET_DOMAIN_NAME_MAX;
if (type == mapping_type::session) max_name_len = lns::SESSION_DISPLAY_NAME_MAX;
else if (type == mapping_type::wallet) max_name_len = lns::WALLET_NAME_MAX;
else if (type == mapping_type::lokinet) max_name_len = lns::LOKINET_DOMAIN_NAME_MAX;
// NOTE: Validate name length
if (name.empty() || name.size() > max_name_len)
@ -345,10 +349,10 @@ bool validate_lns_name(uint16_t type, std::string const &name, std::string *reas
}
// NOTE: Validate domain specific requirements
if (type == static_cast<uint16_t>(mapping_type::session))
if (type == mapping_type::session)
{
}
else if (type == static_cast<uint16_t>(mapping_type::lokinet))
else if (type == mapping_type::lokinet)
{
// Domain has to start with a letter or digit, and can have letters, digits, or hyphens in between and must end with a .loki
// ^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.loki$
@ -413,7 +417,7 @@ bool validate_lns_name(uint16_t type, std::string const &name, std::string *reas
return true;
}
static bool check_lengths(uint16_t type, std::string const &value, size_t max, bool require_exact_len, std::string *reason)
static bool check_lengths(mapping_type type, std::string const &value, size_t max, bool require_exact_len, std::string *reason)
{
bool result = true;
if (require_exact_len)
@ -445,7 +449,7 @@ static bool check_lengths(uint16_t type, std::string const &value, size_t max, b
return result;
}
bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::string const &value, lns_value *blob, std::string *reason)
bool validate_lns_value(cryptonote::network_type nettype, mapping_type type, std::string const &value, lns_value *blob, std::string *reason)
{
if (blob) *blob = {};
std::stringstream err_stream;
@ -455,7 +459,7 @@ bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::st
static_assert(GENERIC_VALUE_MAX >= SESSION_PUBLIC_KEY_BINARY_LENGTH, "lns_value assumes the largest blob size required, all other values should be able to fit into this buffer");
static_assert(GENERIC_VALUE_MAX >= LOKINET_ADDRESS_BINARY_LENGTH, "lns_value assumes the largest blob size required, all other values should be able to fit into this buffer");
static_assert(GENERIC_VALUE_MAX >= sizeof(addr_info.address), "lns_value assumes the largest blob size required, all other values should be able to fit into this buffer");
if (type == static_cast<uint16_t>(mapping_type::wallet))
if (type == mapping_type::wallet)
{
if (value.empty() || !get_account_address_from_str(addr_info, nettype, value))
{
@ -479,15 +483,15 @@ bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::st
{
int max_value_len = lns::GENERIC_VALUE_MAX;
bool value_require_exact_len = true;
if (type == static_cast<uint16_t>(mapping_type::lokinet)) max_value_len = (LOKINET_ADDRESS_BINARY_LENGTH * 2);
else if (type == static_cast<uint16_t>(mapping_type::session)) max_value_len = (SESSION_PUBLIC_KEY_BINARY_LENGTH * 2);
if (type == mapping_type::lokinet) max_value_len = (LOKINET_ADDRESS_BINARY_LENGTH * 2);
else if (type == mapping_type::session) max_value_len = (SESSION_PUBLIC_KEY_BINARY_LENGTH * 2);
else value_require_exact_len = false;
if (!check_lengths(type, value, max_value_len, value_require_exact_len, reason))
return false;
}
if (type == static_cast<uint16_t>(mapping_type::wallet))
if (type == mapping_type::wallet)
{
if (blob)
{
@ -495,7 +499,7 @@ bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::st
memcpy(blob->buffer.data(), &addr_info.address, blob->len);
}
}
else if (type == static_cast<uint16_t>(mapping_type::lokinet))
else if (type == mapping_type::lokinet)
{
if (value.size() != 52)
{
@ -557,7 +561,7 @@ bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::st
}
}
if (type == static_cast<uint16_t>(mapping_type::session))
if (type == mapping_type::session)
{
if (!(value[0] == '0' && value[1] == '5')) // NOTE: Session public keys are 33 bytes, with the first byte being 0x05 and the remaining 32 being the public key.
{
@ -573,19 +577,19 @@ bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::st
return true;
}
bool validate_lns_value_binary(uint16_t type, std::string const &value, std::string *reason)
bool validate_lns_value_binary(mapping_type type, std::string const &value, std::string *reason)
{
int max_value_len = lns::GENERIC_VALUE_MAX;
bool value_require_exact_len = true;
if (type == static_cast<uint16_t>(mapping_type::lokinet)) max_value_len = LOKINET_ADDRESS_BINARY_LENGTH;
else if (type == static_cast<uint16_t>(mapping_type::session)) max_value_len = SESSION_PUBLIC_KEY_BINARY_LENGTH;
else if (type == static_cast<uint16_t>(mapping_type::wallet)) max_value_len = sizeof(cryptonote::account_public_address);
if (type == mapping_type::lokinet) max_value_len = LOKINET_ADDRESS_BINARY_LENGTH;
else if (type == mapping_type::session) max_value_len = SESSION_PUBLIC_KEY_BINARY_LENGTH;
else if (type == mapping_type::wallet) max_value_len = sizeof(cryptonote::account_public_address);
else value_require_exact_len = false;
if (!check_lengths(type, value, max_value_len, value_require_exact_len, reason))
return false;
if (type == static_cast<uint16_t>(lns::mapping_type::wallet))
if (type == lns::mapping_type::wallet)
{
// TODO(doyle): Better address validation? Is it a valid address, is it a valid nettype address?
cryptonote::account_public_address address;
@ -613,12 +617,12 @@ static std::stringstream &print_tx(std::stringstream &stream, cryptonote::transa
static std::stringstream &print_loki_name_system_extra(std::stringstream &stream, cryptonote::tx_extra_loki_name_system const &data)
{
stream << "LNS Extra={";
if (data.command == static_cast<uint8_t>(cryptonote::tx_extra_loki_name_system::command_t::buy))
if (data.command == cryptonote::tx_extra_loki_name_system::command_t::buy)
stream << "owner=" << data.owner;
else
stream << "signature=" << epee::string_tools::pod_to_hex(data.signature);
stream << ", type=" << (int)data.type << ", name=" << data.name << "}";
stream << ", type=" << data.type << ", name=" << data.name << "}";
return stream;
}
@ -635,7 +639,7 @@ static bool validate_against_previous_mapping(lns::name_system_db const &lns_db,
crypto::hash expected_prev_txid = crypto::null_hash;
lns::mapping_record mapping = lns_db.get_mapping(data.type, data.name);
const bool updating = data.command == static_cast<uint8_t>(cryptonote::tx_extra_loki_name_system::command_t::update);
const bool updating = data.command == cryptonote::tx_extra_loki_name_system::command_t::update;
if (updating && !mapping)
{
if (reason)
@ -651,7 +655,7 @@ static bool validate_against_previous_mapping(lns::name_system_db const &lns_db,
expected_prev_txid = mapping.txid;
if (updating)
{
if (data.type == static_cast<uint16_t>(lns::mapping_type::lokinet) && !mapping.active(lns_db.network_type(), blockchain_height))
if (data.type == lns::mapping_type::lokinet && !mapping.active(lns_db.network_type(), blockchain_height))
{
// Updating, we can always update unless the mapping has expired
if (reason)
@ -690,7 +694,7 @@ static bool validate_against_previous_mapping(lns::name_system_db const &lns_db,
}
else
{
if (data.type != static_cast<uint16_t>(lns::mapping_type::lokinet))
if (data.type != lns::mapping_type::lokinet)
{
if (reason)
{
@ -809,7 +813,7 @@ bool name_system_db::validate_lns_tx(uint8_t hf_version, uint64_t blockchain_hei
{
if (reason)
{
print_tx_and_extra(err_stream, tx, *entry) << ", specifying type=" << static_cast<uint16_t>(entry->type) << " that is disallowed";
print_tx_and_extra(err_stream, tx, *entry) << ", specifying type=" << entry->type << " that is disallowed";
*reason = err_stream.str();
}
return false;
@ -824,9 +828,8 @@ bool name_system_db::validate_lns_tx(uint8_t hf_version, uint64_t blockchain_hei
return false;
uint64_t burn = cryptonote::get_burned_amount_from_tx_extra(tx.extra);
auto lns_type = static_cast<mapping_type>(entry->type);
uint64_t const burn_required = entry->command == static_cast<uint8_t>(cryptonote::tx_extra_loki_name_system::command_t::buy)
? burn_requirement_in_atomic_loki(hf_version, mapping_type_to_burn_type(lns_type))
uint64_t const burn_required = entry->command == cryptonote::tx_extra_loki_name_system::command_t::buy
? burn_requirement_in_atomic_loki(hf_version, mapping_type_to_burn_type(entry->type))
: 0;
if (burn != burn_required)
{
@ -842,7 +845,7 @@ bool name_system_db::validate_lns_tx(uint8_t hf_version, uint64_t blockchain_hei
return true;
}
bool validate_mapping_type(std::string const &type, uint16_t *mapping_type, std::string *reason)
bool validate_mapping_type(std::string const &type, lns::mapping_type *mapping_type, std::string *reason)
{
std::string type_lowered = type;
for (char &ch : type_lowered)
@ -851,19 +854,19 @@ bool validate_mapping_type(std::string const &type, uint16_t *mapping_type, std:
ch = ch + ('a' - 'A');
}
uint16_t mapping_type_ = 0;
if (type_lowered == "session") mapping_type_ = static_cast<uint16_t>(lns::mapping_type::session);
lns::mapping_type mapping_type_ = lns::mapping_type::session;
if (type_lowered == "session") mapping_type_ = lns::mapping_type::session;
else
{
try
{
size_t value = std::stoul(type_lowered);
if (value > std::numeric_limits<uint16_t>::max())
if (value > tools::enum_count<lns::mapping_type>)
{
if (reason) *reason = "LNS type specifies value too large, must be from 0-65535: " + std::to_string(value);
if (reason) *reason = "LNS type specifies value too large, must be from [0-" + std::to_string(tools::enum_count<lns::mapping_type>) + "): " + std::to_string(value);
return false;
}
mapping_type_ = static_cast<uint16_t>(value);
mapping_type_ = static_cast<lns::mapping_type>(value);
}
catch (std::exception const &)
{
@ -1033,7 +1036,7 @@ static bool add_lns_entry(lns::name_system_db &lns_db, uint64_t height, cryptono
if (owner_record owner = lns_db.get_owner_by_key(entry.owner)) owner_id = owner.id;
if (owner_id == 0)
{
if (entry.command == static_cast<uint8_t>(cryptonote::tx_extra_loki_name_system::command_t::update))
if (entry.command == cryptonote::tx_extra_loki_name_system::command_t::update)
{
MERROR("Owner does not exist but TX received is trying to update an existing mapping (i.e. owner should already exist). TX=" << tx_hash << " should have failed validation prior.");
return false;
@ -1041,7 +1044,7 @@ static bool add_lns_entry(lns::name_system_db &lns_db, uint64_t height, cryptono
if (!lns_db.save_owner(entry.owner, &owner_id))
{
LOG_PRINT_L1("Failed to save LNS owner to DB tx: " << tx_hash << ", type: " << (uint16_t)entry.type << ", name: " << entry.name << ", owner: " << entry.owner);
LOG_PRINT_L1("Failed to save LNS owner to DB tx: " << tx_hash << ", type: " << entry.type << ", name: " << entry.name << ", owner: " << entry.owner);
return false;
}
}
@ -1049,7 +1052,7 @@ static bool add_lns_entry(lns::name_system_db &lns_db, uint64_t height, cryptono
if (!lns_db.save_mapping(tx_hash, entry, height, owner_id))
{
LOG_PRINT_L1("Failed to save LNS entry to DB tx: " << tx_hash << ", type: " << (uint16_t)entry.type << ", name: " << entry.name << ", owner: " << entry.owner);
LOG_PRINT_L1("Failed to save LNS entry to DB tx: " << tx_hash << ", type: " << entry.type << ", name: " << entry.name << ", owner: " << entry.owner);
return false;
}
@ -1259,11 +1262,11 @@ owner_record name_system_db::get_owner_by_id(int64_t owner_id) const
return result;
}
mapping_record name_system_db::get_mapping(uint16_t type, std::string const &name) const
mapping_record name_system_db::get_mapping(mapping_type type, std::string const &name) const
{
sqlite3_stmt *statement = get_mapping_sql;
sqlite3_clear_bindings(statement);
sqlite3_bind_int(statement, 1 /*sql param index*/, type);
sqlite3_bind_int(statement, 1 /*sql param index*/, static_cast<int>(type));
sqlite3_bind_text(statement, 2 /*sql param index*/, name.data(), name.size(), nullptr /*destructor*/);
mapping_record result = {};

View File

@ -4,6 +4,7 @@
#include "crypto/crypto.h"
#include "cryptonote_config.h"
#include "span.h"
#include "cryptonote_basic/tx_extra.h"
#include <string>
@ -36,16 +37,6 @@ struct lns_value
size_t len;
};
enum struct mapping_type : uint16_t
{
session = 0,
wallet = 1,
lokinet = 2,
};
constexpr bool mapping_type_allowed(uint8_t /*hf_version*/, uint16_t type) { return type == static_cast<uint16_t>(mapping_type::session); }
constexpr bool mapping_type_allowed(uint8_t hf_version, mapping_type type) { return mapping_type_allowed(hf_version, static_cast<uint16_t>(type)); }
enum struct burn_type
{
none,
@ -56,17 +47,30 @@ enum struct burn_type
custom,
};
inline std::ostream &operator<<(std::ostream &os, mapping_type type)
{
switch(type)
{
case mapping_type::lokinet: os << "lokinet"; break;
case mapping_type::session: os << "session"; break;
case mapping_type::wallet: os << "wallet"; break;
default: assert(false); os << "xx_unhandled_type"; break;
}
return os;
}
constexpr bool mapping_type_allowed(uint8_t hf_version, mapping_type type) { return type == mapping_type::session; }
burn_type mapping_type_to_burn_type(mapping_type in);
uint64_t burn_requirement_in_atomic_loki(uint8_t hf_version, burn_type type);
sqlite3 *init_loki_name_system(char const *file_path);
uint64_t lokinet_expiry_blocks(cryptonote::network_type nettype, uint64_t *renew_window = nullptr);
crypto::hash tx_extra_signature_hash(epee::span<const uint8_t> blob, crypto::hash const &prev_txid);
bool validate_lns_name(uint16_t type, std::string const &name, std::string *reason = nullptr);
bool validate_lns_name(mapping_type type, std::string const &name, std::string *reason = nullptr);
// blob: if set, validate_lns_value will convert the value into the binary format suitable for storing into the LNS DB.
bool validate_lns_value(cryptonote::network_type nettype, uint16_t type, std::string const &value, lns_value *blob = nullptr, std::string *reason = nullptr);
bool validate_lns_value_binary(uint16_t type, std::string const &value, std::string *reason = nullptr);
bool validate_mapping_type(std::string const &type, uint16_t *mapping_type, std::string *reason);
bool validate_lns_value(cryptonote::network_type nettype, mapping_type type, std::string const &value, lns_value *blob = nullptr, std::string *reason = nullptr);
bool validate_lns_value_binary(mapping_type type, std::string const &value, std::string *reason = nullptr);
bool validate_mapping_type(std::string const &type, lns::mapping_type *mapping_type, std::string *reason);
struct owner_record
{
@ -98,7 +102,7 @@ struct mapping_record
operator bool() const { return loaded; }
bool loaded;
uint16_t type; // alias to lns::mapping_type
mapping_type type; // alias to lns::mapping_type
std::string name;
std::string value;
uint64_t register_height;
@ -124,7 +128,7 @@ struct name_system_db
owner_record get_owner_by_key (crypto::ed25519_public_key const &key) const;
owner_record get_owner_by_id (int64_t owner_id) const;
mapping_record get_mapping (uint16_t type, std::string const &name) const;
mapping_record get_mapping (mapping_type type, std::string const &name) const;
std::vector<mapping_record> get_mappings (std::vector<uint16_t> const &types, std::string const &name) const;
std::vector<mapping_record> get_mappings_by_owner (crypto::ed25519_public_key const &key) const;
std::vector<mapping_record> get_mappings_by_owners(std::vector<crypto::ed25519_public_key> const &keys) const;

View File

@ -3378,7 +3378,7 @@ namespace cryptonote
res.entries.emplace_back();
COMMAND_RPC_GET_LNS_NAMES_TO_OWNERS::response_entry &entry = res.entries.back();
entry.entry_index = request_index;
entry.type = record.type;
entry.type = static_cast<uint16_t>(record.type);
entry.owner = epee::string_tools::pod_to_hex(record.owner);
entry.value = extract_lns_mapping_value(record);
entry.register_height = record.register_height;
@ -3431,7 +3431,7 @@ namespace cryptonote
}
entry.request_index = it->second;
entry.type = mapping.type;
entry.type = static_cast<uint16_t>(mapping.type);
entry.name = mapping.name;
entry.value = extract_lns_mapping_value(mapping);
entry.register_height = mapping.register_height;

View File

@ -6746,14 +6746,14 @@ bool simple_wallet::print_lns_name_to_owners(const std::vector<std::string>& arg
for (std::string const &type : split_types)
{
uint16_t mapping_type = 0;
lns::mapping_type mapping_type;
std::string reason;
if (!lns::validate_mapping_type(type, &mapping_type, &reason))
{
fail_msg_writer() << reason;
return false;
}
requested_types.push_back(mapping_type);
requested_types.push_back(static_cast<uint16_t>(mapping_type));
}
}
}

View File

@ -8543,7 +8543,7 @@ wallet2::request_stake_unlock_result wallet2::can_request_stake_unlock(const cry
}
static bool prepare_tx_extra_loki_name_system_values(cryptonote::network_type nettype,
uint16_t type,
lns::mapping_type type,
uint32_t priority,
std::string const &name,
std::string const &value,
@ -8571,7 +8571,7 @@ static bool prepare_tx_extra_loki_name_system_values(cryptonote::network_type ne
request.entries.emplace_back();
auto &request_entry = request.entries.back();
request_entry.name = name;
request_entry.types.push_back(type);
request_entry.types.push_back(static_cast<uint16_t>(type));
}
boost::optional<std::string> failed;
@ -8600,7 +8600,7 @@ static bool prepare_tx_extra_loki_name_system_values(cryptonote::network_type ne
return true;
}
std::vector<wallet2::pending_tx> wallet2::create_buy_lns_mapping_tx(uint16_t type,
std::vector<wallet2::pending_tx> wallet2::create_buy_lns_mapping_tx(lns::mapping_type type,
std::string const &owner,
std::string const &name,
std::string const &value,
@ -8661,7 +8661,7 @@ std::vector<wallet2::pending_tx> wallet2::create_buy_lns_mapping_tx(std::string
uint32_t account_index,
std::set<uint32_t> subaddr_indices)
{
uint16_t mapping_type = 0;
lns::mapping_type mapping_type = lns::mapping_type::session;
if (!lns::validate_mapping_type(type, &mapping_type, reason))
return {};
@ -8678,10 +8678,9 @@ std::vector<wallet2::pending_tx> wallet2::update_lns_mapping_tx(lns::mapping_typ
uint32_t account_index,
std::set<uint32_t> subaddr_indices)
{
uint16_t type16 = static_cast<uint16_t>(type);
crypto::hash prev_txid;
lns::lns_value value_blob;
if (!prepare_tx_extra_loki_name_system_values(nettype(), type16, priority, name, value, *this, prev_txid, value_blob, reason))
if (!prepare_tx_extra_loki_name_system_values(nettype(), type, priority, name, value, *this, prev_txid, value_blob, reason))
return {};
crypto::ed25519_public_key pkey;
@ -8704,7 +8703,7 @@ std::vector<wallet2::pending_tx> wallet2::update_lns_mapping_tx(lns::mapping_typ
}
std::vector<uint8_t> extra;
auto entry = cryptonote::tx_extra_loki_name_system::make_update(signature_binary, type16, name, std::string(reinterpret_cast<char const *>(value_blob.buffer.data()), value_blob.len), prev_txid);
auto entry = cryptonote::tx_extra_loki_name_system::make_update(signature_binary, type, name, std::string(reinterpret_cast<char const *>(value_blob.buffer.data()), value_blob.len), prev_txid);
add_loki_name_system_to_tx_extra(extra, entry);
boost::optional<uint8_t> hf_version = get_hard_fork_version();

View File

@ -1550,7 +1550,7 @@ private:
pending_tx ptx;
};
request_stake_unlock_result can_request_stake_unlock(const crypto::public_key &sn_key);
std::vector<wallet2::pending_tx> create_buy_lns_mapping_tx(uint16_t type, std::string const &owner, std::string const &name, std::string const &value, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {});
std::vector<wallet2::pending_tx> create_buy_lns_mapping_tx(lns::mapping_type type, std::string const &owner, std::string const &name, std::string const &value, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {});
std::vector<wallet2::pending_tx> create_buy_lns_mapping_tx(std::string const &type, std::string const &owner, std::string const &name, std::string const &value, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {});
std::vector<wallet2::pending_tx> update_lns_mapping_tx(lns::mapping_type type, std::string const &name, std::string const &value, std::string const *signature, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {});

View File

@ -283,7 +283,7 @@ void loki_chain_generator::add_tx(cryptonote::transaction const &tx, bool can_be
cryptonote::transaction
loki_chain_generator::create_and_add_loki_name_system_tx(cryptonote::account_base const &src,
uint16_t type,
lns::mapping_type type,
std::string const &value,
std::string const &name,
crypto::ed25519_public_key const *owner,
@ -295,7 +295,7 @@ loki_chain_generator::create_and_add_loki_name_system_tx(cryptonote::account_bas
}
cryptonote::transaction loki_chain_generator::create_and_add_loki_name_system_tx_update(cryptonote::account_base const &src,
uint16_t type,
lns::mapping_type type,
std::string const &value,
std::string const &name,
bool kept_by_block)
@ -512,7 +512,7 @@ cryptonote::checkpoint_t loki_chain_generator::create_service_node_checkpoint(ui
}
cryptonote::transaction loki_chain_generator::create_loki_name_system_tx(cryptonote::account_base const &src,
uint16_t type,
lns::mapping_type type,
std::string const &value,
std::string const &name,
crypto::ed25519_public_key const *owner,
@ -533,8 +533,7 @@ cryptonote::transaction loki_chain_generator::create_loki_name_system_tx(crypton
uint64_t new_height = get_block_height(top().block) + 1;
uint8_t new_hf_version = get_hf_version_at(new_height);
if (burn == LNS_AUTO_BURN)
burn = lns::burn_requirement_in_atomic_loki(new_hf_version,
lns::mapping_type_to_burn_type(static_cast<lns::mapping_type>(type)));
burn = lns::burn_requirement_in_atomic_loki(new_hf_version, lns::mapping_type_to_burn_type(type));
crypto::hash prev_txid = crypto::null_hash;
if (lns::mapping_record mapping = lns_db_.get_mapping(type, name))
@ -555,7 +554,7 @@ cryptonote::transaction loki_chain_generator::create_loki_name_system_tx(crypton
}
cryptonote::transaction loki_chain_generator::create_loki_name_system_tx_update(cryptonote::account_base const &src,
uint16_t type,
lns::mapping_type type,
std::string const &value,
std::string const &name,
crypto::ed25519_signature *signature,

View File

@ -1421,8 +1421,8 @@ struct loki_chain_generator
// NOTE: Add constructed TX to events_ and assume that it is valid to add to the blockchain. If the TX is meant to be unaddable to the blockchain use the individual create + add functions to
// be able to mark the add TX event as something that should trigger a failure.
cryptonote::transaction create_and_add_loki_name_system_tx(cryptonote::account_base const &src, uint16_t type, std::string const &value, std::string const &name, crypto::ed25519_public_key const *owner = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_loki_name_system_tx_update(cryptonote::account_base const &src, uint16_t type, std::string const &value, std::string const &name, bool kept_by_block = false);
cryptonote::transaction create_and_add_loki_name_system_tx(cryptonote::account_base const &src, lns::mapping_type type, std::string const &value, std::string const &name, crypto::ed25519_public_key const *owner = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_loki_name_system_tx_update(cryptonote::account_base const &src, lns::mapping_type type, std::string const &value, std::string const &name, bool kept_by_block = false);
cryptonote::transaction create_and_add_tx (const cryptonote::account_base& src, const cryptonote::account_public_address& dest, uint64_t amount, uint64_t fee = TESTS_DEFAULT_FEE, bool kept_by_block = false);
cryptonote::transaction create_and_add_state_change_tx(service_nodes::new_state state, const crypto::public_key& pub_key, uint64_t height = -1, const std::vector<uint64_t>& voters = {}, uint64_t fee = 0, bool kept_by_block = false);
cryptonote::transaction create_and_add_registration_tx(const cryptonote::account_base& src, const cryptonote::keypair& sn_keys = cryptonote::keypair::generate(hw::get_device("default")), bool kept_by_block = false);
@ -1443,8 +1443,8 @@ struct loki_chain_generator
// value: Takes the binary value NOT the human readable version, of the name->value mapping
static const uint64_t LNS_AUTO_BURN = static_cast<uint64_t>(-1);
cryptonote::transaction create_loki_name_system_tx (cryptonote::account_base const &src, uint16_t type, std::string const &value, std::string const &name, crypto::ed25519_public_key const *owner = nullptr, uint64_t burn = LNS_AUTO_BURN) const;
cryptonote::transaction create_loki_name_system_tx_update(cryptonote::account_base const &src, uint16_t type, std::string const &value, std::string const &name, crypto::ed25519_signature *signature = nullptr, bool use_asserts = false) const;
cryptonote::transaction create_loki_name_system_tx (cryptonote::account_base const &src, lns::mapping_type type, std::string const &value, std::string const &name, crypto::ed25519_public_key const *owner = nullptr, uint64_t burn = LNS_AUTO_BURN) const;
cryptonote::transaction create_loki_name_system_tx_update(cryptonote::account_base const &src, lns::mapping_type type, std::string const &value, std::string const &name, crypto::ed25519_signature *signature = nullptr, bool use_asserts = false) const;
cryptonote::transaction create_loki_name_system_tx_update_w_extra(cryptonote::account_base const &src, cryptonote::tx_extra_loki_name_system const &lns_extra) const;
loki_blockchain_entry create_genesis_block(const cryptonote::account_base &miner, uint64_t timestamp);

View File

@ -1004,7 +1004,7 @@ bool loki_name_system_disallow_reserved_type::generate(std::vector<test_event_en
std::string mapping_value = "asdf";
auto unusable_type = static_cast<uint16_t>(-1);
auto unusable_type = static_cast<lns::mapping_type>(-1);
assert(!lns::mapping_type_allowed(gen.hardfork(), unusable_type));
cryptonote::transaction tx1 = gen.create_loki_name_system_tx(miner, unusable_type, mapping_value, "FriendlyName");
gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can't create a LNS TX that requests a LNS type that is unused but reserved by the protocol");
@ -1058,7 +1058,7 @@ bool loki_name_system_expiration::generate(std::vector<test_event_entry> &events
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
std::string const name = "mydomain.loki";
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, name);
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, name);
gen.create_and_add_next_block({tx});
uint64_t height_of_lns_entry = gen.height();
@ -1074,9 +1074,9 @@ bool loki_name_system_expiration::generate(std::vector<test_event_entry> &events
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::lokinet, name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings.name, name);
CHECK_EQ(mappings.value, miner_key.lokinet_value);
CHECK_EQ(mappings.register_height, height_of_lns_entry);
@ -1098,10 +1098,10 @@ bool loki_name_system_expiration::generate(std::vector<test_event_entry> &events
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::lokinet, name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.active(cryptonote::FAKECHAIN, blockchain_height), false);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings.name, name);
CHECK_EQ(mappings.value, miner_key.lokinet_value);
CHECK_EQ(mappings.register_height, height_of_lns_entry);
@ -1135,8 +1135,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
std::string session_name1 = "MyName";
std::string session_name2 = "AnotherName";
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name2, &bob_key.ed_key);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, bob_key.session_value, session_name2, &bob_key.ed_key);
gen.create_and_add_next_block({tx1, tx2});
}
uint64_t session_height = gen.height();
@ -1147,8 +1147,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::lokinet), bob_key.lokinet_value, lokinet_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), bob_key.lokinet_value, lokinet_name2, &bob_key.ed_key);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::lokinet, bob_key.lokinet_value, lokinet_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, bob_key.lokinet_value, lokinet_name2, &bob_key.ed_key);
gen.create_and_add_next_block({tx1, tx2});
}
}
@ -1161,8 +1161,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
{
{
std::string bob_addr = cryptonote::get_account_address_as_str(cryptonote::FAKECHAIN, false, bob.get_keys().m_account_address);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::wallet), bob_key.wallet_value, wallet_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::wallet), bob_key.wallet_value, wallet_name2, &bob_key.ed_key);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::wallet, bob_key.wallet_value, wallet_name1);
cryptonote::transaction tx2 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::wallet, bob_key.wallet_value, wallet_name2, &bob_key.ed_key);
gen.create_and_add_next_block({tx1, tx2});
}
}
@ -1192,8 +1192,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
CHECK_EQ(records[1].register_height, session_height);
CHECK_EQ(records[0].value, bob_key.session_value);
CHECK_EQ(records[1].value, bob_key.session_value);
CHECK_EQ(records[0].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[1].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[0].type, lns::mapping_type::session);
CHECK_EQ(records[1].type, lns::mapping_type::session);
}
if (lns::mapping_type_allowed(c.get_blockchain_storage().get_current_hard_fork_version(), lns::mapping_type::lokinet))
@ -1204,8 +1204,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
CHECK_EQ(records[3].register_height, lokinet_height);
CHECK_EQ(records[2].value, bob_key.lokinet_value);
CHECK_EQ(records[3].value, bob_key.lokinet_value);
CHECK_EQ(records[2].type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(records[3].type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(records[2].type, lns::mapping_type::lokinet);
CHECK_EQ(records[3].type, lns::mapping_type::lokinet);
}
if (lns::mapping_type_allowed(c.get_blockchain_storage().get_current_hard_fork_version(), lns::mapping_type::wallet))
@ -1216,8 +1216,8 @@ bool loki_name_system_get_mappings_by_owner::generate(std::vector<test_event_ent
CHECK_EQ(records[5].register_height, wallet_height);
CHECK_EQ(records[4].value, bob_key.wallet_value);
CHECK_EQ(records[5].value, bob_key.wallet_value);
CHECK_EQ(records[4].type, static_cast<uint16_t>(lns::mapping_type::wallet));
CHECK_EQ(records[5].type, static_cast<uint16_t>(lns::mapping_type::wallet));
CHECK_EQ(records[4].type, lns::mapping_type::wallet);
CHECK_EQ(records[5].type, lns::mapping_type::wallet);
}
return true;
});
@ -1249,7 +1249,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
std::string session_name1 = "MyName";
crypto::hash session_tx_hash1;
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name1);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name1);
session_tx_hash1 = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -1258,7 +1258,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
std::string session_name2 = "MyName2";
crypto::hash session_tx_hash2;
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name2);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name2);
session_tx_hash2 = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -1267,7 +1267,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
std::string session_name3 = "MyName3";
crypto::hash session_tx_hash3;
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, session_name3);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, miner_key.session_value, session_name3);
session_tx_hash3 = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -1286,7 +1286,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
std::sort(records.begin(), records.end(), [](lns::mapping_record const &lhs, lns::mapping_record const &rhs) {
return lhs.register_height < rhs.register_height;
});
CHECK_EQ(records[0].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[0].type, lns::mapping_type::session);
CHECK_EQ(records[0].name, session_name1);
CHECK_EQ(records[0].value, bob_key.session_value);
CHECK_EQ(records[0].register_height, session_height1);
@ -1294,7 +1294,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
CHECK_EQ(records[0].txid, session_tx_hash1);
CHECK_EQ(records[0].owner, bob_key.ed_key);
CHECK_EQ(records[1].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[1].type, lns::mapping_type::session);
CHECK_EQ(records[1].name, session_name2);
CHECK_EQ(records[1].value, bob_key.session_value);
CHECK_EQ(records[1].register_height, session_height2);
@ -1302,7 +1302,7 @@ bool loki_name_system_get_mappings_by_owners::generate(std::vector<test_event_en
CHECK_EQ(records[1].txid, session_tx_hash2);
CHECK_EQ(records[1].owner, bob_key.ed_key);
CHECK_EQ(records[2].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[2].type, lns::mapping_type::session);
CHECK_EQ(records[2].name, session_name3);
CHECK_EQ(records[2].value, miner_key.session_value);
CHECK_EQ(records[2].register_height, session_height3);
@ -1338,7 +1338,7 @@ bool loki_name_system_get_mappings::generate(std::vector<test_event_entry> &even
std::string session_name1 = "MyName";
crypto::hash session_tx_hash;
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name1);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name1);
session_tx_hash = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -1350,7 +1350,7 @@ bool loki_name_system_get_mappings::generate(std::vector<test_event_entry> &even
lns::name_system_db const &lns_db = c.get_blockchain_storage().name_system_db();
std::vector<lns::mapping_record> records = lns_db.get_mappings({static_cast<uint16_t>(lns::mapping_type::session)}, session_name1);
CHECK_EQ(records.size(), 1);
CHECK_EQ(records[0].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[0].type, lns::mapping_type::session);
CHECK_EQ(records[0].name, session_name1);
CHECK_EQ(records[0].value, bob_key.session_value);
CHECK_EQ(records[0].register_height, session_height);
@ -1382,10 +1382,10 @@ bool loki_name_system_handles_duplicate_in_lns_db::generate(std::vector<test_eve
lns_keys_t miner_key = make_lns_keys(miner);
lns_keys_t bob_key = make_lns_keys(bob);
std::string session_name = "myfriendlydisplayname.loki";
uint16_t custom_type = 3928;
auto custom_type = static_cast<lns::mapping_type>(3928);
{
// NOTE: Allow duplicates with the same name but different type
cryptonote::transaction bar = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name);
cryptonote::transaction bar = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, bob_key.session_value, session_name);
std::vector<cryptonote::transaction> txs;
txs.push_back(bar);
@ -1398,7 +1398,7 @@ bool loki_name_system_handles_duplicate_in_lns_db::generate(std::vector<test_eve
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
cryptonote::transaction bar3 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, session_name);
cryptonote::transaction bar3 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, session_name);
txs.push_back(bar3);
}
@ -1407,7 +1407,7 @@ bool loki_name_system_handles_duplicate_in_lns_db::generate(std::vector<test_eve
uint64_t height_of_lns_entry = gen.height();
{
cryptonote::transaction bar6 = gen.create_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name);
cryptonote::transaction bar6 = gen.create_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name);
gen.add_tx(bar6, false /*can_be_added_to_blockchain*/, "Duplicate name requested by new owner: original already exists in lns db");
}
@ -1421,9 +1421,9 @@ bool loki_name_system_handles_duplicate_in_lns_db::generate(std::vector<test_eve
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::session), session_name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::session, session_name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(mappings.type, lns::mapping_type::session);
CHECK_EQ(mappings.name, session_name);
CHECK_EQ(mappings.value, bob_key.session_value);
CHECK_EQ(mappings.register_height, height_of_lns_entry);
@ -1431,9 +1431,9 @@ bool loki_name_system_handles_duplicate_in_lns_db::generate(std::vector<test_eve
if (lns::mapping_type_allowed(c.get_blockchain_storage().get_current_hard_fork_version(), lns::mapping_type::lokinet))
{
lns::mapping_record mappings2 = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), session_name);
lns::mapping_record mappings2 = lns_db.get_mapping(lns::mapping_type::lokinet, session_name);
CHECK_EQ(mappings2.loaded, true);
CHECK_EQ(mappings2.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings2.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings2.name, session_name);
CHECK_EQ(mappings2.value, miner_key.lokinet_value);
CHECK_EQ(mappings2.register_height, height_of_lns_entry);
@ -1479,16 +1479,16 @@ bool loki_name_system_handles_duplicate_in_tx_pool::generate(std::vector<test_ev
lns_keys_t bob_key = make_lns_keys(bob);
std::string session_name = "myfriendlydisplayname.loki";
uint16_t custom_type = 3928;
auto custom_type = static_cast<lns::mapping_type>(3928);
{
// NOTE: Allow duplicates with the same name but different type
cryptonote::transaction bar = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name);
cryptonote::transaction bar = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, bob_key.session_value, session_name);
if (lns::mapping_type_allowed(gen.hardfork(), custom_type))
cryptonote::transaction bar2 = gen.create_and_add_loki_name_system_tx(miner, custom_type, bob_key.session_value, session_name);
// NOTE: Make duplicate in the TX pool, this should be rejected
cryptonote::transaction bar4 = gen.create_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name);
cryptonote::transaction bar4 = gen.create_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, session_name);
gen.add_tx(bar4, false /*can_be_added_to_blockchain*/, "Duplicate name requested by new owner: original already exists in tx pool");
}
return true;
@ -1535,7 +1535,7 @@ bool loki_name_system_invalid_tx_extra_params::generate(std::vector<test_event_e
cryptonote::tx_extra_loki_name_system valid_data = {};
valid_data.owner = miner_key.ed_key;
valid_data.type = static_cast<uint16_t>(lns::mapping_type::wallet);
valid_data.type = lns::mapping_type::wallet;
valid_data.value = miner_key.wallet_value;
valid_data.name = "my_lns_name";
@ -1565,7 +1565,7 @@ bool loki_name_system_invalid_tx_extra_params::generate(std::vector<test_event_e
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
valid_data.type = static_cast<uint16_t>(lns::mapping_type::lokinet);
valid_data.type = lns::mapping_type::lokinet;
// Lokinet domain name too long
{
cryptonote::tx_extra_loki_name_system data = valid_data;
@ -1605,7 +1605,7 @@ bool loki_name_system_invalid_tx_extra_params::generate(std::vector<test_event_e
// Session value invalid, session keys require a 33 byte key where the first byte is a 0x05
std::stringstream stream;
valid_data.type = static_cast<uint16_t>(lns::mapping_type::session);
valid_data.type = lns::mapping_type::session;
{
cryptonote::tx_extra_loki_name_system data = valid_data;
data.value[0] = 'a';
@ -1653,7 +1653,7 @@ bool loki_name_system_invalid_tx_extra_params::generate(std::vector<test_event_e
make_lns_tx_with_custom_extra(gen, events, miner, data, false, "(Session) User id, name too long");
}
uint16_t custom_type = 1111;
auto custom_type = static_cast<lns::mapping_type>(1111);
if (lns::mapping_type_allowed(gen.hardfork(), custom_type))
{
cryptonote::tx_extra_loki_name_system data = valid_data;
@ -1720,18 +1720,18 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
// NOTE: Generate and add the (transactions + block) to the blockchain
{
std::vector<cryptonote::transaction> txs;
cryptonote::transaction session_tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, miner_session_name1);
cryptonote::transaction session_tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, miner_key.session_value, miner_session_name1);
txs.push_back(session_tx);
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::wallet))
{
cryptonote::transaction wallet_tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::wallet), miner_key.wallet_value, miner_wallet_name1);
cryptonote::transaction wallet_tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::wallet, miner_key.wallet_value, miner_wallet_name1);
txs.push_back(wallet_tx);
}
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
cryptonote::transaction lokinet_tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, miner_lokinet_domain1);
cryptonote::transaction lokinet_tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, miner_lokinet_domain1);
txs.push_back(lokinet_tx);
}
gen.create_and_add_next_block(txs);
@ -1759,19 +1759,19 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
for (lns::mapping_record const &record : records)
{
if (record.type == static_cast<uint16_t>(lns::mapping_type::session))
if (record.type == lns::mapping_type::session)
{
CHECK_EQ(record.name, miner_session_name1);
CHECK_EQ(record.register_height, first_lns_height);
CHECK_EQ(record.value, miner_key.session_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::lokinet))
else if (record.type == lns::mapping_type::lokinet)
{
CHECK_EQ(record.name, miner_lokinet_domain1);
CHECK_EQ(record.register_height, first_lns_height);
CHECK_EQ(record.value, miner_key.lokinet_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::wallet))
else if (record.type == lns::mapping_type::wallet)
{
CHECK_EQ(record.name, miner_wallet_name1);
CHECK_EQ(record.register_height, first_lns_height);
@ -1795,11 +1795,11 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
std::string const bob_session_name1 = "I Like Session";
{
std::vector<cryptonote::transaction> txs;
txs.push_back(gen.create_and_add_loki_name_system_tx(bob, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, bob_session_name1));
txs.push_back(gen.create_and_add_loki_name_system_tx(bob, lns::mapping_type::session, bob_key.session_value, bob_session_name1));
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
txs.push_back(gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, miner_lokinet_domain1));
txs.push_back(gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, miner_lokinet_domain1));
}
gen.create_and_add_next_block(txs);
}
@ -1817,19 +1817,19 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
std::vector<lns::mapping_record> records = lns_db.get_mappings_by_owner(miner_key.ed_key);
for (lns::mapping_record const &record : records)
{
if (record.type == static_cast<uint16_t>(lns::mapping_type::session))
if (record.type == lns::mapping_type::session)
{
CHECK_EQ(record.name, miner_session_name1);
CHECK_EQ(record.register_height, first_lns_height);
CHECK_EQ(record.value, miner_key.session_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::lokinet))
else if (record.type == lns::mapping_type::lokinet)
{
CHECK_EQ(record.name, miner_lokinet_domain1);
CHECK_EQ(record.register_height, second_lns_height);
CHECK_EQ(record.value, miner_key.lokinet_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::wallet))
else if (record.type == lns::mapping_type::wallet)
{
CHECK_EQ(record.name, miner_wallet_name1);
CHECK_EQ(record.register_height, first_lns_height);
@ -1849,7 +1849,7 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
CHECK_EQ(records[0].name, bob_session_name1);
CHECK_EQ(records[0].register_height, second_lns_height);
CHECK_EQ(records[0].value, bob_key.session_value);
CHECK_EQ(records[0].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[0].type, lns::mapping_type::session);
}
return true;
@ -1886,19 +1886,19 @@ bool loki_name_system_large_reorg::generate(std::vector<test_event_entry> &event
for (lns::mapping_record const &record : records)
{
if (record.type == static_cast<uint16_t>(lns::mapping_type::session))
if (record.type == lns::mapping_type::session)
{
CHECK_EQ(record.name, miner_session_name1);
CHECK_EQ(record.register_height, first_lns_height);
CHECK_EQ(record.value, miner_key.session_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::lokinet))
else if (record.type == lns::mapping_type::lokinet)
{
CHECK_EQ(record.name, miner_lokinet_domain1);
CHECK_EQ(record.register_height, first_lns_height);
CHECK_EQ(record.value, miner_key.lokinet_value);
}
else if (record.type == static_cast<uint16_t>(lns::mapping_type::wallet))
else if (record.type == lns::mapping_type::wallet)
{
CHECK_EQ(record.name, miner_wallet_name1);
CHECK_EQ(record.register_height, first_lns_height);
@ -1955,7 +1955,7 @@ bool loki_name_system_name_renewal::generate(std::vector<test_event_entry> &even
lns_keys_t miner_key = make_lns_keys(miner);
std::string const name = "mydomain.loki";
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, name);
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, name);
gen.create_and_add_next_block({tx});
crypto::hash prev_txid = get_transaction_hash(tx);
@ -1974,9 +1974,9 @@ bool loki_name_system_name_renewal::generate(std::vector<test_event_entry> &even
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::lokinet, name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings.name, name);
CHECK_EQ(mappings.value, miner_key.lokinet_value);
CHECK_EQ(mappings.register_height, height_of_lns_entry);
@ -1989,7 +1989,7 @@ bool loki_name_system_name_renewal::generate(std::vector<test_event_entry> &even
gen.create_and_add_next_block();
// In the renewal window, try and renew the lokinet entry
cryptonote::transaction renew_tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, name);
cryptonote::transaction renew_tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, name);
gen.create_and_add_next_block({renew_tx});
uint64_t renewal_height = gen.height();
@ -2003,9 +2003,9 @@ bool loki_name_system_name_renewal::generate(std::vector<test_event_entry> &even
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::lokinet, name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings.name, name);
CHECK_EQ(mappings.value, miner_key.lokinet_value);
CHECK_EQ(mappings.register_height, renewal_height);
@ -2058,7 +2058,7 @@ bool loki_name_system_name_value_max_lengths::generate(std::vector<test_event_en
// Blockchain
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::wallet))
{
data.type = static_cast<uint16_t>(lns::mapping_type::wallet);
data.type = lns::mapping_type::wallet;
data.name = std::string(lns::WALLET_NAME_MAX, 'A');
data.value = miner_key.wallet_value;
make_lns_tx_with_custom_extra(gen, events, miner, data);
@ -2067,7 +2067,7 @@ bool loki_name_system_name_value_max_lengths::generate(std::vector<test_event_en
// Lokinet
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
data.type = static_cast<uint16_t>(lns::mapping_type::lokinet);
data.type = lns::mapping_type::lokinet;
data.name = "doyle.loki";
data.value = std::string(lns::LOKINET_ADDRESS_BINARY_LENGTH, 'a');
make_lns_tx_with_custom_extra(gen, events, miner, data);
@ -2075,7 +2075,7 @@ bool loki_name_system_name_value_max_lengths::generate(std::vector<test_event_en
// Session
{
data.type = static_cast<uint16_t>(lns::mapping_type::session);
data.type = lns::mapping_type::session;
data.name = std::string(lns::SESSION_DISPLAY_NAME_MAX, 'A');
data.value = std::string(lns::SESSION_PUBLIC_KEY_BINARY_LENGTH, 'a');
data.value[0] = '0';
@ -2086,7 +2086,7 @@ bool loki_name_system_name_value_max_lengths::generate(std::vector<test_event_en
// Generic
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
data.type = 1111;
data.type = static_cast<lns::mapping_type>(1111);
data.name = std::string(lns::GENERIC_NAME_MAX, 'A');
data.value = std::string(lns::GENERIC_VALUE_MAX, 'a');
make_lns_tx_with_custom_extra(gen, events, miner, data);
@ -2109,7 +2109,7 @@ bool loki_name_system_update_mapping_after_expiry_fails::generate(std::vector<te
if (lns::mapping_type_allowed(gen.hardfork(), lns::mapping_type::lokinet))
{
std::string const name = "mydomain.loki";
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), miner_key.lokinet_value, name);
cryptonote::transaction tx = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::lokinet, miner_key.lokinet_value, name);
gen.create_and_add_next_block({tx});
uint64_t height_of_lns_entry = gen.height();
@ -2119,7 +2119,7 @@ bool loki_name_system_update_mapping_after_expiry_fails::generate(std::vector<te
gen.create_and_add_next_block();
lns_keys_t bob_key = make_lns_keys(gen.add_account());
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::lokinet), bob_key.lokinet_value, name);
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, lns::mapping_type::lokinet, bob_key.lokinet_value, name);
gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can not update a LNS record that is already expired");
loki_register_callback(events, "check_still_expired", [&events, height_of_lns_entry, miner_key, name](cryptonote::core &c, size_t ev_index)
@ -2132,9 +2132,9 @@ bool loki_name_system_update_mapping_after_expiry_fails::generate(std::vector<te
CHECK_EQ(owner.id, 1);
CHECK_EQ(miner_key.ed_key, owner.key);
lns::mapping_record mappings = lns_db.get_mapping(static_cast<uint16_t>(lns::mapping_type::lokinet), name);
lns::mapping_record mappings = lns_db.get_mapping(lns::mapping_type::lokinet, name);
CHECK_EQ(mappings.loaded, true);
CHECK_EQ(mappings.type, static_cast<uint16_t>(lns::mapping_type::lokinet));
CHECK_EQ(mappings.type, lns::mapping_type::lokinet);
CHECK_EQ(mappings.name, name);
CHECK_EQ(mappings.value, miner_key.lokinet_value);
CHECK_EQ(mappings.register_height, height_of_lns_entry);
@ -2161,7 +2161,7 @@ bool loki_name_system_update_mapping::generate(std::vector<test_event_entry> &ev
crypto::hash session_tx_hash1;
std::string session_name1 = "MyName";
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, session_name1);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, miner_key.session_value, session_name1);
session_tx_hash1 = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -2169,13 +2169,13 @@ bool loki_name_system_update_mapping::generate(std::vector<test_event_entry> &ev
// Test update mapping with same name fails
{
crypto::hash session_tx_hash2;
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, session_name1);
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, lns::mapping_type::session, miner_key.session_value, session_name1);
gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can not add a LNS TX that re-updates the underlying value to same value");
}
crypto::hash session_tx_hash2;
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, session_name1);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, lns::mapping_type::session, bob_key.session_value, session_name1);
session_tx_hash2 = cryptonote::get_transaction_hash(tx1);
gen.create_and_add_next_block({tx1});
}
@ -2187,7 +2187,7 @@ bool loki_name_system_update_mapping::generate(std::vector<test_event_entry> &ev
lns::name_system_db const &lns_db = c.get_blockchain_storage().name_system_db();
std::vector<lns::mapping_record> records = lns_db.get_mappings({static_cast<uint16_t>(lns::mapping_type::session)}, session_name1);
CHECK_EQ(records.size(), 1);
CHECK_EQ(records[0].type, static_cast<uint16_t>(lns::mapping_type::session));
CHECK_EQ(records[0].type, lns::mapping_type::session);
CHECK_EQ(records[0].name, session_name1);
CHECK_EQ(records[0].value, bob_key.session_value);
CHECK_EQ(records[0].register_height, session_height2);
@ -2210,7 +2210,7 @@ bool loki_name_system_update_mapping_non_existent_name_fails::generate(std::vect
cryptonote::account_base miner = gen.first_miner_;
lns_keys_t miner_key = make_lns_keys(miner);
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, "Hello World", nullptr /*signature*/, false /*use_asserts*/);
cryptonote::transaction tx1 = gen.create_loki_name_system_tx_update(miner, lns::mapping_type::session, miner_key.session_value, "Hello World", nullptr /*signature*/, false /*use_asserts*/);
gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can not add a updating LNS TX referencing a non-existent LNS entry");
return true;
}
@ -2227,12 +2227,12 @@ bool loki_name_system_update_mapping_invalid_signature::generate(std::vector<tes
lns_keys_t miner_key = make_lns_keys(miner);
std::string const name = "Hello World";
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, name);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, miner_key.session_value, name);
gen.create_and_add_next_block({tx1});
lns_keys_t bob_key = make_lns_keys(gen.add_account());
crypto::ed25519_signature invalid_signature = {};
cryptonote::transaction tx2 = gen.create_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, name, &invalid_signature, false /*use_asserts*/);
cryptonote::transaction tx2 = gen.create_loki_name_system_tx_update(miner, lns::mapping_type::session, bob_key.session_value, name, &invalid_signature, false /*use_asserts*/);
gen.add_tx(tx2, false /*can_be_added_to_blockchain*/, "Can not add a updating LNS TX with an invalid signature");
return true;
}
@ -2253,14 +2253,14 @@ bool loki_name_system_update_mapping_replay::generate(std::vector<test_event_ent
std::string const name = "Hello World";
// Make LNS Mapping
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, static_cast<uint16_t>(lns::mapping_type::session), miner_key.session_value, name);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx(miner, lns::mapping_type::session, miner_key.session_value, name);
gen.create_and_add_next_block({tx1});
}
// (1) Update LNS Mapping
cryptonote::tx_extra_loki_name_system lns_entry = {};
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), bob_key.session_value, name);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, lns::mapping_type::session, bob_key.session_value, name);
gen.create_and_add_next_block({tx1});
assert(cryptonote::get_loki_name_system_from_tx_extra(tx1.extra, lns_entry));
}
@ -2273,7 +2273,7 @@ bool loki_name_system_update_mapping_replay::generate(std::vector<test_event_ent
// (2) Update Again
{
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, static_cast<uint16_t>(lns::mapping_type::session), alice_key.session_value, name);
cryptonote::transaction tx1 = gen.create_and_add_loki_name_system_tx_update(miner, lns::mapping_type::session, alice_key.session_value, name);
gen.create_and_add_next_block({tx1});
}
@ -2336,7 +2336,7 @@ bool loki_name_system_wrong_burn::generate(std::vector<test_event_entry> &events
if (under_burn) burn -= 1;
else burn += 1;
cryptonote::transaction tx = gen.create_loki_name_system_tx(miner, static_cast<uint16_t>(type), value, name, nullptr /*owner*/, burn);
cryptonote::transaction tx = gen.create_loki_name_system_tx(miner, type, value, name, nullptr /*owner*/, burn);
gen.add_tx(tx, false /*can_be_added_to_blockchain*/, "Wrong burn for a LNS tx", false /*kept_by_block*/);
}
}
@ -2358,7 +2358,7 @@ bool loki_name_system_wrong_version::generate(std::vector<test_event_entry> &eve
cryptonote::tx_extra_loki_name_system data = {};
data.version = 0xFF;
data.owner = miner_key.ed_key;
data.type = static_cast<uint16_t>(lns::mapping_type::session);
data.type = lns::mapping_type::session;
data.value = miner_key.session_value;
data.name = "my_lns_name";

View File

@ -8,7 +8,7 @@ TEST(loki_name_system, lokinet_domain_names)
char domain_edkeys[lns::LOKINET_ADDRESS_BINARY_LENGTH * 2] = {};
memset(domain_edkeys, 'a', sizeof(domain_edkeys));
uint16_t const lokinet = static_cast<uint16_t>(lns::mapping_type::lokinet);
lns::mapping_type const lokinet = lns::mapping_type::lokinet;
// Should work
{