mirror of https://github.com/oxen-io/oxen-core.git
rename ons_owners_by_names merge wallet and session name check
This commit is contained in:
parent
4dd3825e66
commit
3993e6594c
|
@ -659,6 +659,9 @@ namespace cryptonote
|
|||
}
|
||||
|
||||
auto ons_db_file_path = folder / "ons.db";
|
||||
if(std::filesystem::exists(folder / "lns.db"))
|
||||
ons_db_file_path = folder / "lns.db";
|
||||
|
||||
|
||||
folder /= db->get_db_name();
|
||||
MGINFO("Loading blockchain from folder " << folder << " ...");
|
||||
|
|
|
@ -823,9 +823,9 @@ bool validate_ons_name(mapping_type type, std::string name, std::string *reason)
|
|||
reason, "ONS type=", type, ", specifies mapping from name->value where the domain name contains more than the permitted alphanumeric or hyphen characters, name=", name))
|
||||
return false;
|
||||
}
|
||||
else if (type == mapping_type::session)
|
||||
else if (type == mapping_type::session || type == mapping_type::wallet)
|
||||
{
|
||||
// SESSION
|
||||
// SESSION & WALLET
|
||||
// Name has to start with a (alphanumeric or underscore), and can have (alphanumeric, hyphens or underscores) in between and must end with a (alphanumeric or underscore)
|
||||
// ^[a-z0-9_]([a-z0-9-_]*[a-z0-9_])?$
|
||||
|
||||
|
@ -846,28 +846,6 @@ bool validate_ons_name(mapping_type type, std::string name, std::string *reason)
|
|||
reason, "ONS type=", type, ", specifies mapping from name->value where the name contains more than the permitted alphanumeric, underscore or hyphen characters, name=", name))
|
||||
return false;
|
||||
}
|
||||
else if (type == mapping_type::wallet)
|
||||
{
|
||||
// WALLET
|
||||
// Name has to start with a (alphanumeric or underscore), and can have (alphanumeric, hyphens or underscores) in between and must end with a (alphanumeric or underscore)
|
||||
// ^[a-z0-9_]([a-z0-9-_]*[a-z0-9_])?$
|
||||
// Must start with (alphanumeric or underscore)
|
||||
if (check_condition(!char_is_alphanum_or<'_'>(name_view.front()), reason, "ONS type=", type, ", specifies mapping from name->value where the name does not start with an alphanumeric or underscore character, name=", name))
|
||||
return false;
|
||||
name_view.remove_prefix(1);
|
||||
|
||||
if (!name_view.empty()) {
|
||||
// Must NOT end with a hyphen '-'
|
||||
if (check_condition(!char_is_alphanum_or<'_'>(name_view.back()), reason, "ONS type=", type, ", specifies mapping from name->value where the last character is a hyphen '-' which is disallowed, name=", name))
|
||||
return false;
|
||||
name_view.remove_suffix(1);
|
||||
}
|
||||
|
||||
// Inbetween start and preceding suffix, (alphanumeric, hyphen or underscore) characters permitted
|
||||
if (check_condition(!std::all_of(name_view.begin(), name_view.end(), char_is_alphanum_or<'-', '_'>),
|
||||
reason, "ONS type=", type, ", specifies mapping from name->value where the name contains more than the permitted alphanumeric, underscore or hyphen characters, name=", name))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MERROR("Type not implemented");
|
||||
|
|
|
@ -261,8 +261,8 @@ namespace
|
|||
|
||||
const char* USAGE_ONS_ENCRYPT("ons_encrypt [type=session|lokinet] <name> <value>");
|
||||
const char* USAGE_ONS_MAKE_UPDATE_MAPPING_SIGNATURE("ons_make_update_mapping_signature [type=session|lokinet] [owner=<value>] [backup_owner=<value>] [value=<encrypted_ons_value>] <name>");
|
||||
const char* USAGE_ONS_PRINT_OWNERS_TO_NAMES("ons_print_owners_to_names [<owner> ...]");
|
||||
const char* USAGE_ONS_PRINT_NAME_TO_OWNERS("ons_print_name_to_owners [type=session|lokinet] <name> [<name> ...]");
|
||||
const char* USAGE_ONS_BY_OWNER("ons_by_owner [<owner> ...]");
|
||||
const char* USAGE_ONS_LOOKUP("ons_lookup [type=session|wallet|lokinet] <name> [<name> ...]");
|
||||
|
||||
#if defined (OXEN_ENABLE_INTEGRATION_TEST_HOOKS)
|
||||
std::string input_line(const std::string &prompt, bool yesno = false)
|
||||
|
@ -3169,14 +3169,14 @@ Pending or Failed: "failed"|"pending", "out", Lock, Checkpointed, Time, Amount*
|
|||
tr(USAGE_ONS_ENCRYPT),
|
||||
tr("Encrypts a ONS mapping value with a given name; primarily intended for use with external mapping update signing"));
|
||||
|
||||
m_cmd_binder.set_handler("ons_print_owners_to_names",
|
||||
[this](const auto& x) { return ons_print_owners_to_names(x); },
|
||||
tr(USAGE_ONS_PRINT_OWNERS_TO_NAMES),
|
||||
m_cmd_binder.set_handler("ons_by_owner",
|
||||
[this](const auto& x) { return ons_by_owner(x); },
|
||||
tr(USAGE_ONS_BY_OWNER),
|
||||
tr("Query the Oxen Name Service names that the keys have purchased. If no keys are specified, it defaults to the current wallet."));
|
||||
|
||||
m_cmd_binder.set_handler("ons_print_name_to_owners",
|
||||
[this](const auto& x) { return ons_print_name_to_owners(x); },
|
||||
tr(USAGE_ONS_PRINT_NAME_TO_OWNERS),
|
||||
m_cmd_binder.set_handler("ons_lookup",
|
||||
[this](const auto& x) { return ons_lookup(x); },
|
||||
tr(USAGE_ONS_LOOKUP),
|
||||
tr("Query the ed25519 public keys that own the Oxen Name System names."));
|
||||
|
||||
m_cmd_binder.set_handler("ons_make_update_mapping_signature",
|
||||
|
@ -6871,14 +6871,14 @@ bool simple_wallet::ons_make_update_mapping_signature(std::vector<std::string> a
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::ons_print_name_to_owners(std::vector<std::string> args)
|
||||
bool simple_wallet::ons_lookup(std::vector<std::string> args)
|
||||
{
|
||||
if (!try_connect_to_daemon())
|
||||
return false;
|
||||
|
||||
if (args.empty())
|
||||
{
|
||||
PRINT_USAGE(USAGE_ONS_PRINT_NAME_TO_OWNERS);
|
||||
PRINT_USAGE(USAGE_ONS_LOOKUP);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6921,7 +6921,7 @@ bool simple_wallet::ons_print_name_to_owners(std::vector<std::string> args)
|
|||
|
||||
if (args.empty())
|
||||
{
|
||||
PRINT_USAGE(USAGE_ONS_PRINT_NAME_TO_OWNERS);
|
||||
PRINT_USAGE(USAGE_ONS_LOOKUP);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6996,7 +6996,7 @@ bool simple_wallet::ons_print_name_to_owners(std::vector<std::string> args)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::ons_print_owners_to_names(const std::vector<std::string>& args)
|
||||
bool simple_wallet::ons_by_owner(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!try_connect_to_daemon())
|
||||
return false;
|
||||
|
|
|
@ -186,8 +186,8 @@ namespace cryptonote
|
|||
bool ons_update_mapping(std::vector<std::string> args);
|
||||
bool ons_encrypt(std::vector<std::string> args);
|
||||
bool ons_make_update_mapping_signature(std::vector<std::string> args);
|
||||
bool ons_print_owners_to_names(const std::vector<std::string> &args);
|
||||
bool ons_print_name_to_owners(std::vector<std::string> args);
|
||||
bool ons_by_owner(const std::vector<std::string> &args);
|
||||
bool ons_lookup(std::vector<std::string> args);
|
||||
|
||||
enum class sweep_type_t { stake, register_stake, all_or_below, single };
|
||||
bool sweep_main_internal(sweep_type_t sweep_type, std::vector<tools::wallet2::pending_tx> &ptx_vector, cryptonote::address_parse_info const &dest, bool blink);
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
using namespace cryptonote;
|
||||
|
||||
TEST(ADDRESS, empty) { EXPECT_FALSE(cryptonote::is_valid_address("")); }
|
||||
TEST(ADDRESS, empty) { EXPECT_FALSE(cryptonote::is_valid_address("", cryptonote::MAINNET)); }
|
||||
|
||||
TEST(ADDRESS, short_mainnet_address) { EXPECT_FALSE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STr")); }
|
||||
TEST(ADDRESS, long_mainnet_address) { EXPECT_FALSE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STrzz")); }
|
||||
TEST(ADDRESS, short_mainnet_address) { EXPECT_FALSE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STr", cryptonote::MAINNET)); }
|
||||
TEST(ADDRESS, long_mainnet_address) { EXPECT_FALSE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STrzz", cryptonote::MAINNET)); }
|
||||
|
||||
TEST(ADDRESS, valid_test_address) { EXPECT_TRUE(cryptonote::is_valid_address("T6TzkJb5EiASaCkcH7idBEi1HSrpSQJE1Zq3aL65ojBMPZvqHNYPTL56i3dncGVNEYCG5QG5zrBmRiVwcg6b1cRM1SRNqbp44")); }
|
||||
TEST(ADDRESS, valid_mainnet_address) { EXPECT_TRUE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STrz")); }
|
||||
TEST(ADDRESS, valid_test_address) { EXPECT_TRUE(cryptonote::is_valid_address("T6TzkJb5EiASaCkcH7idBEi1HSrpSQJE1Zq3aL65ojBMPZvqHNYPTL56i3dncGVNEYCG5QG5zrBmRiVwcg6b1cRM1SRNqbp44", cryptonote::TESTNET)); }
|
||||
TEST(ADDRESS, valid_mainnet_address) { EXPECT_TRUE(cryptonote::is_valid_address("LDBEN6Ut4NkMwyaXWZ7kBEAx8X64o6YtDhLXUP26uLHyYT4nFmcaPU2Z2fauqrhTLh4Qfr61pUUZVLaTHqAdycETKM1STrz", cryptonote::MAINNET)); }
|
||||
|
|
Loading…
Reference in New Issue