rebrand lns -> ons

This commit is contained in:
Sean Darcy 2021-02-12 15:19:30 +11:00
parent 928ad2c668
commit 8023b59867
54 changed files with 1332 additions and 1332 deletions

View File

@ -458,7 +458,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Error opening database: " << e.what());
return 1;
}
r = core_storage->init(db, nullptr /*lns_db*/, net_type);
r = core_storage->init(db, nullptr /*ons_db*/, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");

View File

@ -142,7 +142,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Error opening database: " << e.what());
return 1;
}
r = core_storage->init(db, nullptr /*lns_db*/, net_type);
r = core_storage->init(db, nullptr /*ons_db*/, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");

View File

@ -572,7 +572,7 @@ int main(int argc, char* argv[])
MERROR("Error opening database: " << e.what());
return 1;
}
r = core_storage[n]->init(db, nullptr /*lns_db*/, net_type);
r = core_storage[n]->init(db, nullptr /*ons_db*/, net_type);
std::string source_dest = n == 0 ? "source" : "pruned";
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize " << source_dest << " blockchain storage");

View File

@ -188,7 +188,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Error opening database: " << e.what());
return 1;
}
r = core_storage->init(db, nullptr /*lns_db*/, net_type);
r = core_storage->init(db, nullptr /*ons_db*/, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");

View File

@ -144,7 +144,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Error opening database: " << e.what());
return 1;
}
r = core_storage->init(db, nullptr /*lns_db*/, net_type);
r = core_storage->init(db, nullptr /*ons_db*/, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");

View File

@ -172,7 +172,7 @@ int main(int argc, char* argv[])
return 1;
}
r = core_storage->init(db, nullptr /*lns_db*/, net_type);
r = core_storage->init(db, nullptr /*ons_db*/, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");

View File

@ -529,7 +529,7 @@ namespace cryptonote
constexpr txtype transaction_prefix::get_max_type_for_hf(uint8_t hf_version)
{
txtype result = txtype::standard;
if (hf_version >= network_version_15_lns) result = txtype::oxen_name_system;
if (hf_version >= network_version_15_ons) result = txtype::oxen_name_system;
else if (hf_version >= network_version_14_blink) result = txtype::stake;
else if (hf_version >= network_version_11_infinite_staking) result = txtype::key_image_unlock;
else if (hf_version >= network_version_9_service_nodes) result = txtype::state_change;

View File

@ -123,7 +123,7 @@ namespace cryptonote {
uint64_t base_reward =
version >= network_version_17 ? BLOCK_REWARD_HF17 :
version >= network_version_15_lns ? BLOCK_REWARD_HF15 :
version >= network_version_15_ons ? BLOCK_REWARD_HF15 :
version >= network_version_8 ? block_reward_unpenalized_formula_v8(height) :
block_reward_unpenalized_formula_v7(already_generated_coins, height);

View File

@ -1544,20 +1544,20 @@ namespace cryptonote
}
std::string lns::generic_owner::to_string(cryptonote::network_type nettype) const
std::string ons::generic_owner::to_string(cryptonote::network_type nettype) const
{
if (type == lns::generic_owner_sig_type::monero)
if (type == ons::generic_owner_sig_type::monero)
return cryptonote::get_account_address_as_str(nettype, wallet.is_subaddress, wallet.address);
else
return tools::type_to_hex(ed25519);
}
bool lns::generic_owner::operator==(generic_owner const &other) const
bool ons::generic_owner::operator==(generic_owner const &other) const
{
if (type != other.type)
return false;
if (type == lns::generic_owner_sig_type::monero)
if (type == ons::generic_owner_sig_type::monero)
return wallet.is_subaddress == other.wallet.is_subaddress && wallet.address == other.wallet.address;
else
return ed25519 == other.ed25519;

View File

@ -72,7 +72,7 @@ static constexpr HardFork::Params mainnet_hard_forks[] =
{ network_version_12_checkpointing, 321467, 0, 1563940800 }, // 2019-07-24 14:00AEDT
{ network_version_13_enforce_checkpoints, 385824, 0, 1571850000 }, // 2019-10-23 19:00AEDT
{ network_version_14_blink, 442333, 0, 1578528000 }, // 2020-01-09 00:00UTC
{ network_version_15_lns, 496969, 0, 1585105200 }, // 2020-03-25 14:00AEDT (03:00UTC)
{ network_version_15_ons, 496969, 0, 1585105200 }, // 2020-03-25 14:00AEDT (03:00UTC)
{ network_version_16_pulse, 641111, 0, 1602464400 }, // 2020-10-12 12:00AEDT (01:00UTC)
{ network_version_17, 641111 + BLOCKS_EXPECTED_IN_DAYS(180), 0, 1602464400 + 180*24*60*60 }, // HF16 + 180 days
};
@ -87,7 +87,7 @@ static constexpr HardFork::Params testnet_hard_forks[] =
{ network_version_12_checkpointing, 75471, 0, 1561608000 }, // 2019-06-28 14:00AEDT
{ network_version_13_enforce_checkpoints, 127028, 0, 1568440800 }, // 2019-09-13 16:00AEDT
{ network_version_14_blink, 174630, 0, 1575075600 }, // 2019-11-30 07:00UTC
{ network_version_15_lns, 244777, 0, 1583940000 }, // 2020-03-11 15:20UTC
{ network_version_15_ons, 244777, 0, 1583940000 }, // 2020-03-11 15:20UTC
{ network_version_16_pulse, 382222, 0, 1600468200 }, // 2020-09-18 22:30UTC
{ network_version_17, 447275, 0, 1608276840 }, // 2020-12-18 05:34UTC
{ network_version_18, 501750, 0, 1616631051 }, // 2021-03-25 12:10UTC

View File

@ -3,21 +3,21 @@
namespace cryptonote {
tx_extra_oxen_name_system tx_extra_oxen_name_system::make_buy(
lns::generic_owner const& owner,
lns::generic_owner const* backup_owner,
lns::mapping_type type,
ons::generic_owner const& owner,
ons::generic_owner const* backup_owner,
ons::mapping_type type,
const crypto::hash& name_hash,
const std::string& encrypted_value,
const crypto::hash& prev_txid)
{
tx_extra_oxen_name_system result{};
result.fields = lns::extra_field::buy;
result.fields = ons::extra_field::buy;
result.owner = owner;
if (backup_owner)
result.backup_owner = *backup_owner;
else
result.fields = lns::extra_field::buy_no_backup;
result.fields = ons::extra_field::buy_no_backup;
result.type = type;
result.name_hash = name_hash;
@ -27,12 +27,12 @@ tx_extra_oxen_name_system tx_extra_oxen_name_system::make_buy(
}
tx_extra_oxen_name_system tx_extra_oxen_name_system::make_renew(
lns::mapping_type type, crypto::hash const &name_hash, crypto::hash const &prev_txid)
ons::mapping_type type, crypto::hash const &name_hash, crypto::hash const &prev_txid)
{
assert(is_lokinet_type(type) && prev_txid);
tx_extra_oxen_name_system result{};
result.fields = lns::extra_field::none;
result.fields = ons::extra_field::none;
result.type = type;
result.name_hash = name_hash;
result.prev_txid = prev_txid;
@ -40,35 +40,35 @@ tx_extra_oxen_name_system tx_extra_oxen_name_system::make_renew(
}
tx_extra_oxen_name_system tx_extra_oxen_name_system::make_update(
const lns::generic_signature& signature,
lns::mapping_type type,
const ons::generic_signature& signature,
ons::mapping_type type,
const crypto::hash& name_hash,
std::string_view encrypted_value,
const lns::generic_owner* owner,
const lns::generic_owner* backup_owner,
const ons::generic_owner* owner,
const ons::generic_owner* backup_owner,
const crypto::hash& prev_txid)
{
tx_extra_oxen_name_system result{};
result.signature = signature;
result.type = type;
result.name_hash = name_hash;
result.fields |= lns::extra_field::signature;
result.fields |= ons::extra_field::signature;
if (encrypted_value.size())
{
result.fields |= lns::extra_field::encrypted_value;
result.fields |= ons::extra_field::encrypted_value;
result.encrypted_value = std::string{encrypted_value};
}
if (owner)
{
result.fields |= lns::extra_field::owner;
result.fields |= ons::extra_field::owner;
result.owner = *owner;
}
if (backup_owner)
{
result.fields |= lns::extra_field::backup_owner;
result.fields |= ons::extra_field::backup_owner;
result.backup_owner = *backup_owner;
}

View File

@ -72,7 +72,7 @@ constexpr char
}
namespace lns
namespace ons
{
enum struct extra_field : uint8_t
{
@ -127,7 +127,7 @@ struct alignas(size_t) generic_owner
}
END_SERIALIZE()
};
static_assert(sizeof(generic_owner) == 80, "Unexpected padding, we store binary blobs into the LNS DB");
static_assert(sizeof(generic_owner) == 80, "Unexpected padding, we store binary blobs into the ONS DB");
struct generic_signature
{
@ -148,18 +148,18 @@ struct generic_signature
END_SERIALIZE()
};
static_assert(sizeof(crypto::ed25519_signature) == sizeof(crypto::signature), "LNS allows storing either ed25519 or monero style signatures, we store all signatures into crypto::signature in LNS");
static_assert(sizeof(crypto::ed25519_signature) == sizeof(crypto::signature), "ONS allows storing either ed25519 or monero style signatures, we store all signatures into crypto::signature in ONS");
inline std::ostream &operator<<(std::ostream &o, const generic_signature &v) {
return o << '<' << tools::type_to_hex(v.data) << '>';
}
} // namespace lns
} // namespace ons
namespace std {
static_assert(sizeof(lns::generic_owner) >= sizeof(std::size_t) && alignof(lns::generic_owner) >= alignof(std::size_t),
static_assert(sizeof(ons::generic_owner) >= sizeof(std::size_t) && alignof(ons::generic_owner) >= alignof(std::size_t),
"Size and alignment of hash must be at least that of size_t");
template <> struct hash<lns::generic_owner> {
std::size_t operator()(const lns::generic_owner &v) const { return reinterpret_cast<const std::size_t &>(v); }
template <> struct hash<ons::generic_owner> {
std::size_t operator()(const ons::generic_owner &v) const { return reinterpret_cast<const std::size_t &>(v); }
};
}
@ -534,55 +534,55 @@ namespace cryptonote
struct tx_extra_oxen_name_system
{
uint8_t version = 0;
lns::mapping_type type;
ons::mapping_type type;
crypto::hash name_hash;
crypto::hash prev_txid = crypto::null_hash; // previous txid that purchased the mapping
lns::extra_field fields;
lns::generic_owner owner = {};
lns::generic_owner backup_owner = {};
lns::generic_signature signature = {};
ons::extra_field fields;
ons::generic_owner owner = {};
ons::generic_owner backup_owner = {};
ons::generic_signature signature = {};
std::string encrypted_value; // binary format of the name->value mapping
bool field_is_set (lns::extra_field bit) const { return (fields & bit) == bit; }
bool field_any_set(lns::extra_field bit) const { return (fields & bit) != lns::extra_field::none; }
bool field_is_set (ons::extra_field bit) const { return (fields & bit) == bit; }
bool field_any_set(ons::extra_field bit) const { return (fields & bit) != ons::extra_field::none; }
// True if this is updating some LNS info: has a signature and 1 or more updating field
bool is_updating() const { return field_is_set(lns::extra_field::signature) && field_any_set(lns::extra_field::updatable_fields); }
// True if this is buying a new LNS record
bool is_buying() const { return (fields == lns::extra_field::buy || fields == lns::extra_field::buy_no_backup); }
// True if this is renewing an existing LNS: has no fields at all, is a renewal registration (i.e. lokinet),
// True if this is updating some ONS info: has a signature and 1 or more updating field
bool is_updating() const { return field_is_set(ons::extra_field::signature) && field_any_set(ons::extra_field::updatable_fields); }
// True if this is buying a new ONS record
bool is_buying() const { return (fields == ons::extra_field::buy || fields == ons::extra_field::buy_no_backup); }
// True if this is renewing an existing ONS: has no fields at all, is a renewal registration (i.e. lokinet),
// and has a non-null txid set (which should point to the most recent registration or update).
bool is_renewing() const { return fields == lns::extra_field::none && prev_txid && is_lokinet_type(type); }
bool is_renewing() const { return fields == ons::extra_field::none && prev_txid && is_lokinet_type(type); }
static tx_extra_oxen_name_system make_buy(
lns::generic_owner const& owner,
lns::generic_owner const* backup_owner,
lns::mapping_type type,
ons::generic_owner const& owner,
ons::generic_owner const* backup_owner,
ons::mapping_type type,
const crypto::hash& name_hash,
const std::string& encrypted_value,
const crypto::hash& prev_txid);
static tx_extra_oxen_name_system make_renew(lns::mapping_type type, const crypto::hash& name_hash, const crypto::hash& prev_txid);
static tx_extra_oxen_name_system make_renew(ons::mapping_type type, const crypto::hash& name_hash, const crypto::hash& prev_txid);
static tx_extra_oxen_name_system make_update(
const lns::generic_signature& signature,
lns::mapping_type type,
const ons::generic_signature& signature,
ons::mapping_type type,
const crypto::hash& name_hash,
std::string_view encrypted_value,
const lns::generic_owner* owner,
const lns::generic_owner* backup_owner,
const ons::generic_owner* owner,
const ons::generic_owner* backup_owner,
const crypto::hash& prev_txid);
BEGIN_SERIALIZE()
FIELD(version)
ENUM_FIELD(type, type < lns::mapping_type::_count)
ENUM_FIELD(type, type < ons::mapping_type::_count)
FIELD(name_hash)
FIELD(prev_txid)
ENUM_FIELD(fields, fields <= lns::extra_field::all)
if (field_is_set(lns::extra_field::owner)) FIELD(owner);
if (field_is_set(lns::extra_field::backup_owner)) FIELD(backup_owner);
if (field_is_set(lns::extra_field::signature)) FIELD(signature);
if (field_is_set(lns::extra_field::encrypted_value)) FIELD(encrypted_value);
ENUM_FIELD(fields, fields <= ons::extra_field::all)
if (field_is_set(ons::extra_field::owner)) FIELD(owner);
if (field_is_set(ons::extra_field::backup_owner)) FIELD(backup_owner);
if (field_is_set(ons::extra_field::signature)) FIELD(signature);
if (field_is_set(ons::extra_field::encrypted_value)) FIELD(encrypted_value);
END_SERIALIZE()
};

View File

@ -332,7 +332,7 @@ namespace cryptonote
network_version_12_checkpointing, // Checkpointing, Relaxed Deregistration, RandomXL, Oxen Storage Server
network_version_13_enforce_checkpoints,
network_version_14_blink,
network_version_15_lns,
network_version_15_ons,
network_version_16_pulse,
network_version_17, // future HF
network_version_18, // future HF

View File

@ -299,21 +299,21 @@ uint64_t Blockchain::get_current_blockchain_height(bool lock) const
bool Blockchain::load_missing_blocks_into_oxen_subsystems()
{
uint64_t const snl_height = std::max(m_hardfork->get_earliest_ideal_height_for_version(network_version_9_service_nodes), m_service_node_list.height() + 1);
uint64_t const lns_height = std::max(m_hardfork->get_earliest_ideal_height_for_version(network_version_15_lns), m_lns_db.height() + 1);
uint64_t const ons_height = std::max(m_hardfork->get_earliest_ideal_height_for_version(network_version_15_ons), m_ons_db.height() + 1);
uint64_t const end_height = m_db->height();
uint64_t const start_height = std::min(end_height, std::min(lns_height, snl_height));
uint64_t const start_height = std::min(end_height, std::min(ons_height, snl_height));
int64_t const total_blocks = static_cast<int64_t>(end_height) - static_cast<int64_t>(start_height);
if (total_blocks <= 0) return true;
if (total_blocks > 1)
MGINFO("Loading blocks into oxen subsystems, scanning blockchain from height: " << start_height << " to: " << end_height << " (snl: " << snl_height << ", lns: " << lns_height << ")");
MGINFO("Loading blocks into oxen subsystems, scanning blockchain from height: " << start_height << " to: " << end_height << " (snl: " << snl_height << ", ons: " << ons_height << ")");
using clock = std::chrono::steady_clock;
using work_time = std::chrono::duration<float>;
int64_t constexpr BLOCK_COUNT = 1000;
auto work_start = clock::now();
auto scan_start = work_start;
work_time lns_duration{}, snl_duration{}, lns_iteration_duration{}, snl_iteration_duration{};
work_time ons_duration{}, snl_duration{}, ons_iteration_duration{}, snl_iteration_duration{};
std::vector<cryptonote::block> blocks;
std::vector<cryptonote::transaction> txs;
@ -328,7 +328,7 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
{
m_service_node_list.store();
auto duration = work_time{clock::now() - work_start};
MGINFO("... scanning height " << start_height + (index * BLOCK_COUNT) << " (" << duration.count() << "s) (snl: " << snl_iteration_duration.count() << "s; lns: " << lns_iteration_duration.count() << "s)");
MGINFO("... scanning height " << start_height + (index * BLOCK_COUNT) << " (" << duration.count() << "s) (snl: " << snl_iteration_duration.count() << "s; ons: " << ons_iteration_duration.count() << "s)");
#ifdef ENABLE_SYSTEMD
// Tell systemd that we're doing something so that it should let us continue starting up
// (giving us 120s until we have to send the next notification):
@ -336,9 +336,9 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
#endif
work_start = clock::now();
lns_duration += lns_iteration_duration;
ons_duration += ons_iteration_duration;
snl_duration += snl_iteration_duration;
lns_iteration_duration = snl_iteration_duration = {};
ons_iteration_duration = snl_iteration_duration = {};
}
blocks.clear();
@ -357,7 +357,7 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
missed_txs.clear();
if (!get_transactions(blk.tx_hashes, txs, missed_txs))
{
MERROR("Unable to get transactions for block for updating LNS DB: " << cryptonote::get_block_hash(blk));
MERROR("Unable to get transactions for block for updating ONS DB: " << cryptonote::get_block_hash(blk));
return false;
}
@ -378,15 +378,15 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
snl_iteration_duration += clock::now() - snl_start;
}
if (m_lns_db.db && (block_height >= lns_height))
if (m_ons_db.db && (block_height >= ons_height))
{
auto lns_start = clock::now();
if (!m_lns_db.add_block(blk, txs))
auto ons_start = clock::now();
if (!m_ons_db.add_block(blk, txs))
{
MERROR("Unable to process block for updating LNS DB: " << cryptonote::get_block_hash(blk));
MERROR("Unable to process block for updating ONS DB: " << cryptonote::get_block_hash(blk));
return false;
}
lns_iteration_duration += clock::now() - lns_start;
ons_iteration_duration += clock::now() - ons_start;
}
}
}
@ -394,7 +394,7 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
if (total_blocks > 1)
{
auto duration = work_time{clock::now() - scan_start};
MGINFO("Done recalculating oxen subsystems (" << duration.count() << "s) (snl: " << snl_duration.count() << "s; lns: " << lns_duration.count() << "s)");
MGINFO("Done recalculating oxen subsystems (" << duration.count() << "s) (snl: " << snl_duration.count() << "s; ons: " << ons_duration.count() << "s)");
}
if (total_blocks > 0)
@ -405,7 +405,7 @@ bool Blockchain::load_missing_blocks_into_oxen_subsystems()
//------------------------------------------------------------------
//FIXME: possibly move this into the constructor, to avoid accidentally
// dereferencing a null BlockchainDB pointer
bool Blockchain::init(BlockchainDB* db, sqlite3 *lns_db, const network_type nettype, bool offline, const cryptonote::test_options *test_options, difficulty_type fixed_difficulty, const GetCheckpointsCallback& get_checkpoints/* = nullptr*/)
bool Blockchain::init(BlockchainDB* db, sqlite3 *ons_db, const network_type nettype, bool offline, const cryptonote::test_options *test_options, difficulty_type fixed_difficulty, const GetCheckpointsCallback& get_checkpoints/* = nullptr*/)
{
LOG_PRINT_L3("Blockchain::" << __func__);
@ -572,9 +572,9 @@ bool Blockchain::init(BlockchainDB* db, sqlite3 *lns_db, const network_type nett
return false;
}
if (lns_db && !m_lns_db.init(this, nettype, lns_db))
if (ons_db && !m_ons_db.init(this, nettype, ons_db))
{
MERROR("LNS failed to initialise");
MERROR("ONS failed to initialise");
return false;
}
@ -592,11 +592,11 @@ bool Blockchain::init(BlockchainDB* db, sqlite3 *lns_db, const network_type nett
return true;
}
//------------------------------------------------------------------
bool Blockchain::init(BlockchainDB* db, HardFork*& hf, sqlite3 *lns_db, const network_type nettype, bool offline)
bool Blockchain::init(BlockchainDB* db, HardFork*& hf, sqlite3 *ons_db, const network_type nettype, bool offline)
{
if (hf != nullptr)
m_hardfork = hf;
bool res = init(db, lns_db, nettype, offline, NULL);
bool res = init(db, ons_db, nettype, offline, NULL);
if (hf == nullptr)
hf = m_hardfork;
return res;
@ -751,7 +751,7 @@ block Blockchain::pop_block_from_blockchain()
// make sure the hard fork object updates its current version
m_hardfork->on_block_popped(1);
m_lns_db.block_detach(*this, m_db->height());
m_ons_db.block_detach(*this, m_db->height());
// return transactions from popped block to the tx_pool
size_t pruned = 0;
@ -3542,9 +3542,9 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
{
cryptonote::tx_extra_oxen_name_system data;
std::string fail_reason;
if (!m_lns_db.validate_lns_tx(hf_version, get_current_blockchain_height(), tx, data, &fail_reason))
if (!m_ons_db.validate_ons_tx(hf_version, get_current_blockchain_height(), tx, data, &fail_reason))
{
MERROR_VER("Failed to validate LNS TX reason: " << fail_reason);
MERROR_VER("Failed to validate ONS TX reason: " << fail_reason);
tvc.m_verbose_error = std::move(fail_reason);
return false;
}
@ -4448,9 +4448,9 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
return false;
}
if (!m_lns_db.add_block(bl, only_txs))
if (!m_ons_db.add_block(bl, only_txs))
{
MGINFO_RED("Failed to add block to LNS DB.");
MGINFO_RED("Failed to add block to ONS DB.");
bvc.m_verifivation_failed = true;
return false;
}
@ -4994,7 +4994,7 @@ bool Blockchain::calc_batched_governance_reward(uint64_t height, uint64_t &rewar
size_t num_blocks = cryptonote::get_config(nettype()).GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS;
// Fixed reward starting at HF15
if (hard_fork_version >= network_version_15_lns)
if (hard_fork_version >= network_version_15_ons)
{
reward = num_blocks * (
hard_fork_version >= network_version_17 ? FOUNDATION_REWARD_HF17 :

View File

@ -149,7 +149,7 @@ namespace cryptonote
*
* @return true on success, false if any initialization steps fail
*/
bool init(BlockchainDB* db, sqlite3 *lns_db, const network_type nettype = MAINNET, bool offline = false, const cryptonote::test_options *test_options = NULL, difficulty_type fixed_difficulty = 0, const GetCheckpointsCallback& get_checkpoints = nullptr);
bool init(BlockchainDB* db, sqlite3 *ons_db, const network_type nettype = MAINNET, bool offline = false, const cryptonote::test_options *test_options = NULL, difficulty_type fixed_difficulty = 0, const GetCheckpointsCallback& get_checkpoints = nullptr);
/**
* @brief Initialize the Blockchain state
@ -161,7 +161,7 @@ namespace cryptonote
*
* @return true on success, false if any initialization steps fail
*/
bool init(BlockchainDB* db, HardFork*& hf, sqlite3 *lns_db, const network_type nettype = MAINNET, bool offline = false);
bool init(BlockchainDB* db, HardFork*& hf, sqlite3 *ons_db, const network_type nettype = MAINNET, bool offline = false);
/**
* @brief Uninitializes the blockchain state
@ -1077,9 +1077,9 @@ namespace cryptonote
*/
bool blink_rollback(uint64_t rollback_height);
lns::name_system_db &name_system_db() { return m_lns_db; }
ons::name_system_db &name_system_db() { return m_ons_db; }
const lns::name_system_db &name_system_db() const { return m_lns_db; }
const ons::name_system_db &name_system_db() const { return m_ons_db; }
/**
* @brief flush the invalid blocks set
@ -1127,7 +1127,7 @@ namespace cryptonote
tx_memory_pool& m_tx_pool;
service_nodes::service_node_list& m_service_node_list;
lns::name_system_db m_lns_db;
ons::name_system_db m_ons_db;
mutable std::recursive_mutex m_blockchain_lock; // TODO: add here reader/writer lock

View File

@ -658,7 +658,7 @@ namespace cryptonote
return false;
}
auto lns_db_file_path = folder / "lns.db";
auto ons_db_file_path = folder / "ons.db";
folder /= db->get_db_name();
MGINFO("Loading blockchain from folder " << folder << " ...");
@ -677,7 +677,7 @@ namespace cryptonote
MERROR("Failed to remove data file in " << folder);
return false;
}
fs::remove(lns_db_file_path);
fs::remove(ons_db_file_path);
}
#endif
@ -828,13 +828,13 @@ namespace cryptonote
// Checkpoints
m_checkpoints_path = m_config_folder / fs::u8path(JSON_HASH_FILE_NAME);
sqlite3 *lns_db = lns::init_oxen_name_system(lns_db_file_path, db->is_read_only());
if (!lns_db) return false;
sqlite3 *ons_db = ons::init_oxen_name_system(ons_db_file_path, db->is_read_only());
if (!ons_db) return false;
init_oxenmq(vm);
const difficulty_type fixed_difficulty = command_line::get_arg(vm, arg_fixed_difficulty);
r = m_blockchain_storage.init(db.release(), lns_db, m_nettype, m_offline, regtest ? &regtest_test_options : test_options, fixed_difficulty, get_checkpoints);
r = m_blockchain_storage.init(db.release(), ons_db, m_nettype, m_offline, regtest ? &regtest_test_options : test_options, fixed_difficulty, get_checkpoints);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
r = m_mempool.init(max_txpool_weight);

View File

@ -134,7 +134,7 @@ namespace cryptonote
{
return hf_version >= network_version_17 ? FOUNDATION_REWARD_HF17 :
hf_version >= network_version_16_pulse ? FOUNDATION_REWARD_HF15 + CHAINFLIP_LIQUIDITY_HF16 :
hf_version >= network_version_15_lns ? FOUNDATION_REWARD_HF15 :
hf_version >= network_version_15_ons ? FOUNDATION_REWARD_HF15 :
base_reward / 20;
}
@ -197,7 +197,7 @@ namespace cryptonote
uint64_t service_node_reward_formula(uint64_t base_reward, uint8_t hard_fork_version)
{
return
hard_fork_version >= network_version_15_lns ? SN_REWARD_HF15 :
hard_fork_version >= network_version_15_ons ? SN_REWARD_HF15 :
hard_fork_version >= network_version_9_service_nodes ? base_reward / 2 : // 50% of base reward up until HF15's fixed payout
0;
}
@ -447,7 +447,7 @@ namespace cryptonote
}
uint64_t expected_amount = 0;
if (hard_fork_version <= cryptonote::network_version_15_lns)
if (hard_fork_version <= cryptonote::network_version_15_ons)
{
// NOTE: Use the amount actually paid out when we split the service node
// reward (across up to 4 recipients) which may actually pay out less than

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ struct tx_extra_oxen_name_system;
class Blockchain;
}; // namespace cryptonote
namespace lns
namespace ons
{
constexpr size_t WALLET_NAME_MAX = 64;
@ -60,7 +60,7 @@ struct mapping_value
bool operator==(mapping_value const &other) const { return encrypted == other.encrypted && other.to_view() == to_view(); }
bool operator==(std::string_view other) const { return other == to_view(); }
// Encrypts the mapping value in-place given the name, suitable for storing into the LNS DB. Only
// Encrypts the mapping value in-place given the name, suitable for storing into the ONS DB. Only
// basic overflow validation is attempted, values should be pre-validated in the validate*
// functions.
//
@ -131,7 +131,7 @@ constexpr bool mapping_type_allowed(uint8_t hf_version, mapping_type type) {
// Returns all mapping types supported for lookup as of the given hardfork. (Note that this does
// not return the dedicated length types such as mapping_type::lokinet_5years as those are only
// relevant within a LNS buy tx).
// relevant within a ONS buy tx).
std::vector<mapping_type> all_mapping_types(uint8_t hf_version);
sqlite3 *init_oxen_name_system(const fs::path& file_path, bool read_only);
@ -139,7 +139,7 @@ sqlite3 *init_oxen_name_system(const fs::path& file_path, bool read_only);
/// Returns the integer value used in the database and in RPC lookup calls for the given mapping
/// type. In particularly this maps all mapping_type::lokinet_Xyears values to the underlying value
/// of mapping_type::lokinet.
constexpr uint16_t db_mapping_type(lns::mapping_type type) {
constexpr uint16_t db_mapping_type(ons::mapping_type type) {
if (is_lokinet_type(type))
return static_cast<uint16_t>(mapping_type::lokinet);
return static_cast<uint16_t>(type);
@ -163,7 +163,7 @@ std::string name_hash_bytes_to_base64(std::string_view bytes);
// otherwise.
std::optional<std::string> name_hash_input_to_base64(std::string_view input);
bool validate_lns_name(mapping_type type, std::string name, std::string *reason = nullptr);
bool validate_ons_name(mapping_type type, std::string name, std::string *reason = nullptr);
generic_signature make_ed25519_signature(crypto::hash const &hash, crypto::ed25519_secret_key const &skey);
generic_owner make_monero_owner(cryptonote::account_public_address const &owner, bool is_subaddress);
@ -171,16 +171,16 @@ generic_owner make_ed25519_owner(crypto::ed25519_public_key const &pkey);
bool parse_owner_to_generic_owner(cryptonote::network_type nettype, std::string_view owner, generic_owner &key, std::string *reason);
std::string tx_extra_signature(std::string_view value, generic_owner const *owner, generic_owner const *backup_owner, crypto::hash const &prev_txid);
enum struct lns_tx_type { lookup, buy, update, renew };
// Converts a human readable case-insensitive string denoting the mapping type into a value suitable for storing into the LNS DB.
enum struct ons_tx_type { lookup, buy, update, renew };
// Converts a human readable case-insensitive string denoting the mapping type into a value suitable for storing into the ONS DB.
// Currently accepts "session" or "lokinet" for lookups, buys, updates, and renewals; for buys and renewals also accepts "lokinet_Ny[ear]" for N=2,5,10
// Lookups are implied by none of buy/update/renew.
// mapping_type: (optional) if function returns true, the uint16_t value of the 'type' will be set
bool validate_mapping_type(std::string_view type, uint8_t hf_version, lns_tx_type txtype, mapping_type *mapping_type, std::string *reason);
bool validate_mapping_type(std::string_view type, uint8_t hf_version, ons_tx_type txtype, mapping_type *mapping_type, std::string *reason);
// Hashes an LNS name. The name must already be lower-case (but this is only checked in debug builds).
// Hashes an ONS name. The name must already be lower-case (but this is only checked in debug builds).
crypto::hash name_to_hash(std::string_view name, const std::optional<crypto::hash>& key = std::nullopt); // Takes a human readable name and hashes it. Takes an optional value to use as a key to produce a keyed hash.
std::string name_to_base64_hash(std::string_view name); // Takes a human readable name, hashes it and returns a base64 representation of the hash, suitable for storage into the LNS DB.
std::string name_to_base64_hash(std::string_view name); // Takes a human readable name, hashes it and returns a base64 representation of the hash, suitable for storage into the ONS DB.
struct owner_record
{
@ -204,9 +204,9 @@ struct settings_record
struct mapping_record
{
// NOTE: We keep expired entries in the DB indefinitely because we need to
// keep all LNS entries indefinitely to support large blockchain detachments.
// keep all ONS entries indefinitely to support large blockchain detachments.
// A mapping_record forms a linked list of TXID's which allows us to revert
// the LNS DB to any arbitrary height at a small additional storage cost.
// the ONS DB to any arbitrary height at a small additional storage cost.
// return: if the record exists and hasn't expired.
bool active(uint64_t blockchain_height) const;
operator bool() const { return loaded; }
@ -298,9 +298,9 @@ struct name_system_db
// not found or expired, otherwise returns the encrypted value.
std::optional<mapping_value> resolve(mapping_type type, std::string_view name_hash_b64, uint64_t blockchain_height);
// Validates an LNS transaction. If the function returns true then entry will be populated with
// the LNS details. On a false return, `reason` is instead populated with the failure reason.
bool validate_lns_tx(uint8_t hf_version, uint64_t blockchain_height, cryptonote::transaction const &tx, cryptonote::tx_extra_oxen_name_system &entry, std::string *reason);
// Validates an ONS transaction. If the function returns true then entry will be populated with
// the ONS details. On a false return, `reason` is instead populated with the failure reason.
bool validate_ons_tx(uint8_t hf_version, uint64_t blockchain_height, cryptonote::transaction const &tx, cryptonote::tx_extra_oxen_name_system &entry, std::string *reason);
// Destructor; closes the sqlite3 database if one is open
~name_system_db();

View File

@ -224,7 +224,7 @@ namespace service_nodes {
constexpr proof_version MIN_UPTIME_PROOF_VERSIONS[] = {
{cryptonote::network_version_18, {9,0,0}},
{cryptonote::network_version_16_pulse, {8,1,0}},
{cryptonote::network_version_15_lns, {7,1,2}},
{cryptonote::network_version_15_ons, {7,1,2}},
{cryptonote::network_version_14_blink, {6,1,0}},
{cryptonote::network_version_13_enforce_checkpoints, {5,1,0}},
{cryptonote::network_version_12_checkpointing, {4,0,3}},

View File

@ -211,7 +211,7 @@ namespace cryptonote
if (data.type == pool_data.type && data.name_hash == pool_data.name_hash)
{
LOG_PRINT_L1("New TX: " << get_transaction_hash(tx) << ", has TX: " << get_transaction_hash(pool_tx) << " from the pool that is requesting the same LNS entry already.");
LOG_PRINT_L1("New TX: " << get_transaction_hash(tx) << ", has TX: " << get_transaction_hash(pool_tx) << " from the pool that is requesting the same ONS entry already.");
return true;
}
}

View File

@ -77,17 +77,17 @@ struct extra_printer {
void operator()(const tx_extra_tx_key_image_unlock& x) { std::cout << "TX key image unlock: " << x.key_image; }
void operator()(const tx_extra_burn& x) { std::cout << "Transaction burned fee/payment: " << print_money(x.amount); }
void operator()(const tx_extra_oxen_name_system& x) {
std::cout << "LNS " << (x.is_buying() ? "registration" : x.is_updating() ? "update" : "(unknown)");
std::cout << "ONS " << (x.is_buying() ? "registration" : x.is_updating() ? "update" : "(unknown)");
switch (x.type)
{
case lns::mapping_type::lokinet: std::cout << " - Lokinet (1y)"; break;
case lns::mapping_type::lokinet_2years: std::cout << " - Lokinet (2y)"; break;
case lns::mapping_type::lokinet_5years: std::cout << " - Lokinet (5y)"; break;
case lns::mapping_type::lokinet_10years: std::cout << " - Lokinet (10y)"; break;
case lns::mapping_type::session: std::cout << " - Session address"; break;
case lns::mapping_type::wallet: std::cout << " - Wallet address"; break;
case lns::mapping_type::update_record_internal:
case lns::mapping_type::_count:
case ons::mapping_type::lokinet: std::cout << " - Lokinet (1y)"; break;
case ons::mapping_type::lokinet_2years: std::cout << " - Lokinet (2y)"; break;
case ons::mapping_type::lokinet_5years: std::cout << " - Lokinet (5y)"; break;
case ons::mapping_type::lokinet_10years: std::cout << " - Lokinet (10y)"; break;
case ons::mapping_type::session: std::cout << " - Session address"; break;
case ons::mapping_type::wallet: std::cout << " - Wallet address"; break;
case ons::mapping_type::update_record_internal:
case ons::mapping_type::_count:
break;
}
}

View File

@ -182,7 +182,7 @@ namespace hw {
virtual bool generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image) = 0;
virtual bool generate_key_image_signature(const crypto::key_image& image, const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) = 0;
virtual bool generate_unlock_signature(const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) = 0;
virtual bool generate_lns_signature(std::string_view signature_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) = 0;
virtual bool generate_ons_signature(std::string_view signature_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) = 0;
// alternative prototypes available in libringct
rct::key scalarmultKey(const rct::key &P, const rct::key &a)

View File

@ -274,7 +274,7 @@ namespace hw {
return true;
}
bool device_default::generate_lns_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) {
bool device_default::generate_ons_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) {
crypto::hash hash;
crypto_generichash(reinterpret_cast<unsigned char*>(hash.data), sizeof(hash), reinterpret_cast<const unsigned char*>(sig_data.data()), sig_data.size(), nullptr, 0);

View File

@ -103,7 +103,7 @@ namespace hw {
bool generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image) override;
bool generate_key_image_signature(const crypto::key_image& image, const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) override;
bool generate_unlock_signature(const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) override;
bool generate_lns_signature(std::string_view signature_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) override;
bool generate_ons_signature(std::string_view signature_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) override;
/* ======================================================================= */

View File

@ -298,7 +298,7 @@ namespace hw {
LEDGER_INS(GET_TX_PROOF, 0xA0);
LEDGER_INS(GEN_UNLOCK_SIGNATURE, 0xA2);
LEDGER_INS(GEN_LNS_SIGNATURE, 0xA3);
LEDGER_INS(GEN_ONS_SIGNATURE, 0xA3);
LEDGER_INS(GEN_KEY_IMAGE_SIGNATURE, 0xA4);
LEDGER_INS(GET_RESPONSE, 0xc0);
@ -1316,16 +1316,16 @@ namespace hw {
return true;
}
bool device_ledger::generate_lns_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) {
bool device_ledger::generate_ons_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) {
// Initialize (prompts the user):
int offset = set_command_header_noopt(INS_GEN_LNS_SIGNATURE);
CHECK_AND_ASSERT_THROW_MES(finish_and_exchange(offset, true) == SW_OK, "LNS denied on device.");
int offset = set_command_header_noopt(INS_GEN_ONS_SIGNATURE);
CHECK_AND_ASSERT_THROW_MES(finish_and_exchange(offset, true) == SW_OK, "ONS denied on device.");
// Send lns signature data to be hashed:
exchange_multipart_data(INS_GEN_LNS_SIGNATURE, 1, sig_data, BLAKE2B_HASH_CHUNK_SIZE);
// Send ons signature data to be hashed:
exchange_multipart_data(INS_GEN_ONS_SIGNATURE, 1, sig_data, BLAKE2B_HASH_CHUNK_SIZE);
// Send the subaddr indices and get the signature:
offset = set_command_header_noopt(INS_GEN_LNS_SIGNATURE, 2);
offset = set_command_header_noopt(INS_GEN_ONS_SIGNATURE, 2);
send_bytes(&index, sizeof(index), offset);
finish_and_exchange(offset);
@ -1449,7 +1449,7 @@ namespace hw {
// As of protocol version 4, we send:
// - tx version
// - tx type (transfer, registration, stake, lns)
// - tx type (transfer, registration, stake, ons)
// - tx lock time (if the tx has multiple lock times this will be the largest one)
// We then wait for confirmation from the device, and if we get it we continue by sending the
// data in chunks. The last chunk will have a p2 subparameter of 0;

View File

@ -284,7 +284,7 @@ namespace hw {
bool generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image) override;
bool generate_key_image_signature(const crypto::key_image& image, const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) override;
bool generate_unlock_signature(const crypto::public_key& pub, const crypto::secret_key& sec, crypto::signature& sig) override;
bool generate_lns_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) override;
bool generate_ons_signature(std::string_view sig_data, const cryptonote::account_keys& keys, const cryptonote::subaddress_index& index, crypto::signature& sig) override;
/* ======================================================================= */
/* TRANSACTION */

View File

@ -54,10 +54,10 @@ static_assert(BLINK_BURN_TX_FEE_PERCENT >= 0, "blink burn tx percent cannot be n
// -------------------------------------------------------------------------------------------------
//
// LNS
// ONS
//
// -------------------------------------------------------------------------------------------------
namespace lns
namespace ons
{
enum struct mapping_type : uint16_t
{
@ -73,7 +73,7 @@ enum struct mapping_type : uint16_t
constexpr bool is_lokinet_type(mapping_type t) { return t >= mapping_type::lokinet && t <= mapping_type::lokinet_10years; }
// How many days we add per "year" of LNS lokinet registration. We slightly extend this to the 368
// How many days we add per "year" of ONS lokinet registration. We slightly extend this to the 368
// days per registration "year" to allow for some blockchain time drift + leap years.
constexpr uint64_t REGISTRATION_YEAR_DAYS = 368;
@ -84,7 +84,7 @@ constexpr uint64_t burn_needed(uint8_t hf_version, mapping_type type)
// The base amount for session/wallet/lokinet-1year:
const uint64_t basic_fee = (
hf_version >= 16 ? 15*COIN : // cryptonote::network_version_16_pulse -- but don't want to add cryptonote_config.h include
20*COIN // cryptonote::network_version_15_lns
20*COIN // cryptonote::network_version_15_ons
);
switch (type)
{
@ -105,5 +105,5 @@ constexpr uint64_t burn_needed(uint8_t hf_version, mapping_type type)
}
return result;
}
}; // namespace lns
}; // namespace ons

View File

@ -773,42 +773,42 @@ namespace cryptonote { namespace rpc {
for (auto& proof : x.proofs) entry.locked_key_images.emplace_back(tools::type_to_hex(proof.key_image));
}
void operator()(const tx_extra_tx_key_image_unlock& x) { entry.key_image_unlock = tools::type_to_hex(x.key_image); }
void _load_owner(std::optional<std::string>& entry, const lns::generic_owner& owner) {
void _load_owner(std::optional<std::string>& entry, const ons::generic_owner& owner) {
if (!owner)
return;
if (owner.type == lns::generic_owner_sig_type::monero)
if (owner.type == ons::generic_owner_sig_type::monero)
entry = get_account_address_as_str(nettype, owner.wallet.is_subaddress, owner.wallet.address);
else if (owner.type == lns::generic_owner_sig_type::ed25519)
else if (owner.type == ons::generic_owner_sig_type::ed25519)
entry = tools::type_to_hex(owner.ed25519);
}
void operator()(const tx_extra_oxen_name_system& x) {
auto& lns = entry.lns.emplace();
lns.blocks = lns::expiry_blocks(nettype, x.type);
auto& ons = entry.ons.emplace();
ons.blocks = ons::expiry_blocks(nettype, x.type);
switch (x.type)
{
case lns::mapping_type::lokinet: [[fallthrough]];
case lns::mapping_type::lokinet_2years: [[fallthrough]];
case lns::mapping_type::lokinet_5years: [[fallthrough]];
case lns::mapping_type::lokinet_10years: lns.type = "lokinet"; break;
case ons::mapping_type::lokinet: [[fallthrough]];
case ons::mapping_type::lokinet_2years: [[fallthrough]];
case ons::mapping_type::lokinet_5years: [[fallthrough]];
case ons::mapping_type::lokinet_10years: ons.type = "lokinet"; break;
case lns::mapping_type::session: lns.type = "session"; break;
case lns::mapping_type::wallet: lns.type = "wallet"; break;
case ons::mapping_type::session: ons.type = "session"; break;
case ons::mapping_type::wallet: ons.type = "wallet"; break;
case lns::mapping_type::update_record_internal: [[fallthrough]];
case lns::mapping_type::_count:
case ons::mapping_type::update_record_internal: [[fallthrough]];
case ons::mapping_type::_count:
break;
}
if (x.is_buying())
lns.buy = true;
ons.buy = true;
else if (x.is_updating())
lns.update = true;
ons.update = true;
else if (x.is_renewing())
lns.renew = true;
lns.name_hash = tools::type_to_hex(x.name_hash);
ons.renew = true;
ons.name_hash = tools::type_to_hex(x.name_hash);
if (!x.encrypted_value.empty())
lns.value = oxenmq::to_hex(x.encrypted_value);
_load_owner(lns.owner, x.owner);
_load_owner(lns.backup_owner, x.backup_owner);
ons.value = oxenmq::to_hex(x.encrypted_value);
_load_owner(ons.owner, x.owner);
_load_owner(ons.backup_owner, x.backup_owner);
}
// Ignore these fields:
@ -3531,43 +3531,43 @@ namespace cryptonote { namespace rpc {
return res;
}
//------------------------------------------------------------------------------------------------------------------------------
LNS_NAMES_TO_OWNERS::response core_rpc_server::invoke(LNS_NAMES_TO_OWNERS::request&& req, rpc_context context)
ONS_NAMES_TO_OWNERS::response core_rpc_server::invoke(ONS_NAMES_TO_OWNERS::request&& req, rpc_context context)
{
LNS_NAMES_TO_OWNERS::response res{};
ONS_NAMES_TO_OWNERS::response res{};
if (!context.admin)
check_quantity_limit(req.entries.size(), LNS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES);
check_quantity_limit(req.entries.size(), ONS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES);
std::optional<uint64_t> height = m_core.get_current_blockchain_height();
uint8_t hf_version = m_core.get_hard_fork_version(*height);
if (req.include_expired) height = std::nullopt;
std::vector<lns::mapping_type> types;
std::vector<ons::mapping_type> types;
lns::name_system_db &db = m_core.get_blockchain_storage().name_system_db();
ons::name_system_db &db = m_core.get_blockchain_storage().name_system_db();
for (size_t request_index = 0; request_index < req.entries.size(); request_index++)
{
LNS_NAMES_TO_OWNERS::request_entry const &request = req.entries[request_index];
ONS_NAMES_TO_OWNERS::request_entry const &request = req.entries[request_index];
if (!context.admin)
check_quantity_limit(request.types.size(), LNS_NAMES_TO_OWNERS::MAX_TYPE_REQUEST_ENTRIES, "types");
check_quantity_limit(request.types.size(), ONS_NAMES_TO_OWNERS::MAX_TYPE_REQUEST_ENTRIES, "types");
types.clear();
if (types.capacity() < request.types.size())
types.reserve(request.types.size());
for (auto type : request.types)
{
types.push_back(static_cast<lns::mapping_type>(type));
if (!lns::mapping_type_allowed(hf_version, types.back()))
types.push_back(static_cast<ons::mapping_type>(type));
if (!ons::mapping_type_allowed(hf_version, types.back()))
throw rpc_error{ERROR_WRONG_PARAM, "Invalid lokinet type '" + std::to_string(type) + "'"};
}
// This also takes 32 raw bytes, but that is undocumented (because it is painful to pass
// through json).
auto name_hash = lns::name_hash_input_to_base64(request.name_hash);
auto name_hash = ons::name_hash_input_to_base64(request.name_hash);
if (!name_hash)
throw rpc_error{ERROR_WRONG_PARAM, "Invalid name_hash: expected hash as 64 hex digits or 43/44 base64 characters"};
std::vector<lns::mapping_record> records = db.get_mappings(types, *name_hash, height);
std::vector<ons::mapping_record> records = db.get_mappings(types, *name_hash, height);
for (auto const &record : records)
{
auto& entry = res.entries.emplace_back();
@ -3587,38 +3587,38 @@ namespace cryptonote { namespace rpc {
return res;
}
//------------------------------------------------------------------------------------------------------------------------------
LNS_OWNERS_TO_NAMES::response core_rpc_server::invoke(LNS_OWNERS_TO_NAMES::request&& req, rpc_context context)
ONS_OWNERS_TO_NAMES::response core_rpc_server::invoke(ONS_OWNERS_TO_NAMES::request&& req, rpc_context context)
{
LNS_OWNERS_TO_NAMES::response res{};
ONS_OWNERS_TO_NAMES::response res{};
if (!context.admin)
check_quantity_limit(req.entries.size(), LNS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES);
check_quantity_limit(req.entries.size(), ONS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES);
std::unordered_map<lns::generic_owner, size_t> owner_to_request_index;
std::vector<lns::generic_owner> owners;
std::unordered_map<ons::generic_owner, size_t> owner_to_request_index;
std::vector<ons::generic_owner> owners;
owners.reserve(req.entries.size());
for (size_t request_index = 0; request_index < req.entries.size(); request_index++)
{
std::string const &owner = req.entries[request_index];
lns::generic_owner lns_owner = {};
ons::generic_owner ons_owner = {};
std::string errmsg;
if (!lns::parse_owner_to_generic_owner(m_core.get_nettype(), owner, lns_owner, &errmsg))
if (!ons::parse_owner_to_generic_owner(m_core.get_nettype(), owner, ons_owner, &errmsg))
throw rpc_error{ERROR_WRONG_PARAM, std::move(errmsg)};
// TODO(oxen): We now serialize both owner and backup_owner, since if
// we specify an owner that is backup owner, we don't show the (other)
// owner. For RPC compatibility we keep the request_index around until the
// next hard fork (16)
owners.push_back(lns_owner);
owner_to_request_index[lns_owner] = request_index;
owners.push_back(ons_owner);
owner_to_request_index[ons_owner] = request_index;
}
lns::name_system_db &db = m_core.get_blockchain_storage().name_system_db();
ons::name_system_db &db = m_core.get_blockchain_storage().name_system_db();
std::optional<uint64_t> height;
if (!req.include_expired) height = m_core.get_current_blockchain_height();
std::vector<lns::mapping_record> records = db.get_mappings_by_owners(owners, height);
std::vector<ons::mapping_record> records = db.get_mappings_by_owners(owners, height);
for (auto &record : records)
{
auto& entry = res.entries.emplace_back();
@ -3644,20 +3644,20 @@ namespace cryptonote { namespace rpc {
}
//------------------------------------------------------------------------------------------------------------------------------
LNS_RESOLVE::response core_rpc_server::invoke(LNS_RESOLVE::request&& req, rpc_context context)
ONS_RESOLVE::response core_rpc_server::invoke(ONS_RESOLVE::request&& req, rpc_context context)
{
LNS_RESOLVE::response res{};
ONS_RESOLVE::response res{};
if (req.type >= tools::enum_count<lns::mapping_type>)
throw rpc_error{ERROR_WRONG_PARAM, "Unable to resolve LNS address: 'type' parameter not specified"};
if (req.type >= tools::enum_count<ons::mapping_type>)
throw rpc_error{ERROR_WRONG_PARAM, "Unable to resolve ONS address: 'type' parameter not specified"};
auto name_hash = lns::name_hash_input_to_base64(req.name_hash);
auto name_hash = ons::name_hash_input_to_base64(req.name_hash);
if (!name_hash)
throw rpc_error{ERROR_WRONG_PARAM, "Unable to resolve LNS address: invalid 'name_hash' value '" + req.name_hash + "'"};
throw rpc_error{ERROR_WRONG_PARAM, "Unable to resolve ONS address: invalid 'name_hash' value '" + req.name_hash + "'"};
uint8_t hf_version = m_core.get_hard_fork_version(m_core.get_current_blockchain_height());
auto type = static_cast<lns::mapping_type>(req.type);
if (!lns::mapping_type_allowed(hf_version, type))
auto type = static_cast<ons::mapping_type>(req.type);
if (!ons::mapping_type_allowed(hf_version, type))
throw rpc_error{ERROR_WRONG_PARAM, "Invalid lokinet type '" + std::to_string(req.type) + "'"};
if (auto mapping = m_core.get_blockchain_storage().name_system_db().resolve(

View File

@ -268,9 +268,9 @@ namespace cryptonote::rpc {
REPORT_PEER_SS_STATUS::response invoke(REPORT_PEER_SS_STATUS::request&& req, rpc_context context);
TEST_TRIGGER_P2P_RESYNC::response invoke(TEST_TRIGGER_P2P_RESYNC::request&& req, rpc_context context);
TEST_TRIGGER_UPTIME_PROOF::response invoke(TEST_TRIGGER_UPTIME_PROOF::request&& req, rpc_context context);
LNS_NAMES_TO_OWNERS::response invoke(LNS_NAMES_TO_OWNERS::request&& req, rpc_context context);
LNS_OWNERS_TO_NAMES::response invoke(LNS_OWNERS_TO_NAMES::request&& req, rpc_context context);
LNS_RESOLVE::response invoke(LNS_RESOLVE::request&& req, rpc_context context);
ONS_NAMES_TO_OWNERS::response invoke(ONS_NAMES_TO_OWNERS::request&& req, rpc_context context);
ONS_OWNERS_TO_NAMES::response invoke(ONS_OWNERS_TO_NAMES::request&& req, rpc_context context);
ONS_RESOLVE::response invoke(ONS_RESOLVE::request&& req, rpc_context context);
ONS_RESOLVE_ADDRESS::response invoke(ONS_RESOLVE_ADDRESS::request&& req, rpc_context context);
FLUSH_CACHE::response invoke(FLUSH_CACHE::request&& req, rpc_context);

View File

@ -111,7 +111,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::extra_entry::state_change)
KV_SERIALIZE(reasons);
KV_SERIALIZE(reasons_maybe);
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::extra_entry::lns_details)
KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::extra_entry::ons_details)
KV_SERIALIZE(buy)
KV_SERIALIZE(update)
KV_SERIALIZE(renew)
@ -139,7 +139,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::extra_entry)
KV_SERIALIZE(tx_secret_key)
KV_SERIALIZE(locked_key_images)
KV_SERIALIZE(key_image_unlock)
KV_SERIALIZE(lns)
KV_SERIALIZE(ons)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::entry)
KV_SERIALIZE(tx_hash)
@ -1310,19 +1310,19 @@ KV_SERIALIZE_MAP_CODE_BEGIN(REPORT_PEER_SS_STATUS::request)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_NAMES_TO_OWNERS::request_entry)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_NAMES_TO_OWNERS::request_entry)
KV_SERIALIZE(name_hash)
KV_SERIALIZE(types)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_NAMES_TO_OWNERS::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_NAMES_TO_OWNERS::request)
KV_SERIALIZE(entries)
KV_SERIALIZE(include_expired)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_NAMES_TO_OWNERS::response_entry)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_NAMES_TO_OWNERS::response_entry)
KV_SERIALIZE(entry_index)
KV_SERIALIZE_ENUM(type)
KV_SERIALIZE(name_hash)
@ -1335,7 +1335,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_NAMES_TO_OWNERS::response_entry)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_NAMES_TO_OWNERS::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_NAMES_TO_OWNERS::response)
KV_SERIALIZE(entries)
KV_SERIALIZE(status)
KV_SERIALIZE_MAP_CODE_END()
@ -1350,13 +1350,13 @@ KV_SERIALIZE_MAP_CODE_BEGIN(ONS_RESOLVE_ADDRESS::response)
KV_SERIALIZE(status)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_OWNERS_TO_NAMES::request)
KV_SERIALIZE(entries)
KV_SERIALIZE(include_expired)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::response_entry)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_OWNERS_TO_NAMES::response_entry)
KV_SERIALIZE(request_index)
KV_SERIALIZE_ENUM(type)
KV_SERIALIZE(name_hash)
@ -1369,19 +1369,19 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::response_entry)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_OWNERS_TO_NAMES::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_OWNERS_TO_NAMES::response)
KV_SERIALIZE(entries)
KV_SERIALIZE(status)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_RESOLVE::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_RESOLVE::request)
KV_SERIALIZE(name_hash)
KV_SERIALIZE_OPT(type, static_cast<uint16_t>(-1))
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_RESOLVE::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_RESOLVE::response)
KV_SERIALIZE(encrypted_value)
KV_SERIALIZE(nonce)
KV_SERIALIZE_MAP_CODE_END()

View File

@ -300,15 +300,15 @@ namespace rpc {
std::optional<std::vector<std::string>> reasons_maybe; // If present, this contains any decomm/dereg reasons that were given by some but not all quorum voters
KV_MAP_SERIALIZABLE
};
struct lns_details
struct ons_details
{
std::optional<bool> buy; // Provided and true iff this is an LNS buy record
std::optional<bool> update; // Provided and true iff this is an LNS record update
std::optional<bool> renew; // Provided and true iff this is an LNS record renewal
std::string type; // The LNS request type. For registrations: "lokinet", "session", "wallet"; for a record update: "update"
std::optional<bool> buy; // Provided and true iff this is an ONS buy record
std::optional<bool> update; // Provided and true iff this is an ONS record update
std::optional<bool> renew; // Provided and true iff this is an ONS record renewal
std::string type; // The ONS request type. For registrations: "lokinet", "session", "wallet"; for a record update: "update"
std::optional<uint64_t> blocks; // The registration length in blocks (only applies to lokinet registrations; session/wallet registrations do not expire)
std::string name_hash; // The hashed name of the record being purchased/updated, in hex (the actual name is not provided on the blockchain).
std::optional<std::string> prev_txid; // For an update, this points at the txid of the previous lns update transaction.
std::optional<std::string> prev_txid; // For an update, this points at the txid of the previous ons update transaction.
std::optional<std::string> value; // The encrypted value of the record, in hex. Note that this is encrypted using the actual name itself (*not* the hashed name).
std::optional<std::string> owner; // The owner of this record; this can be a main wallet, wallet subaddress, or a plain public key.
std::optional<std::string> backup_owner; // Backup owner wallet/pubkey of the record, if provided.
@ -330,7 +330,7 @@ namespace rpc {
std::optional<std::string> tx_secret_key; // The transaction secret key, included in registrations/stakes to decrypt transaction amounts and recipients
std::vector<std::string> locked_key_images; // Key image(s) locked by the transaction (for registrations, stakes)
std::optional<std::string> key_image_unlock; // A key image being unlocked in a stake unlock request (an unlock will be started for *all* key images locked in the same SN contributions).
std::optional<lns_details> lns; // an LNS registration or update
std::optional<ons_details> ons; // an ONS registration or update
KV_MAP_SERIALIZABLE
};
@ -2435,7 +2435,7 @@ namespace rpc {
OXEN_RPC_DOC_INTROSPECT
// Get the name mapping for a Loki Name Service entry. Loki currently supports mappings
// for Session and Lokinet.
struct LNS_NAMES_TO_OWNERS : PUBLIC
struct ONS_NAMES_TO_OWNERS : PUBLIC
{
static constexpr auto names() { return NAMES("ons_names_to_owners", "lns_names_to_owners"); }
@ -2460,11 +2460,11 @@ namespace rpc {
struct response_entry
{
uint64_t entry_index; // The index in request_entry's `entries` array that was resolved via Loki Name Service.
lns::mapping_type type; // The type of Loki Name Service entry that the owner owns: currently supported values are 0 (session), 2 (lokinet)
ons::mapping_type type; // The type of Loki Name Service entry that the owner owns: currently supported values are 0 (session), 2 (lokinet)
std::string name_hash; // The hash of the name that was queried, in base64
std::string owner; // The public key that purchased the Loki Name Service entry.
std::optional<std::string> backup_owner; // The backup public key that the owner specified when purchasing the Loki Name Service entry. Omitted if no backup owner.
std::string encrypted_value; // The encrypted value that the name maps to. See the `LNS_RESOLVE` description for information on how this value can be decrypted.
std::string encrypted_value; // The encrypted value that the name maps to. See the `ONS_RESOLVE` description for information on how this value can be decrypted.
uint64_t update_height; // The last height that this Loki Name Service entry was updated on the Blockchain.
std::optional<uint64_t> expiration_height; // For records that expire, this will be set to the expiration block height.
std::string txid; // The txid of the mapping's most recent update or purchase.
@ -2506,7 +2506,7 @@ namespace rpc {
OXEN_RPC_DOC_INTROSPECT
// Get all the name mappings for the queried owner. The owner can be either a ed25519 public key or Monero style
// public key; by default purchases are owned by the spend public key of the purchasing wallet.
struct LNS_OWNERS_TO_NAMES : PUBLIC
struct ONS_OWNERS_TO_NAMES : PUBLIC
{
static constexpr auto names() { return NAMES("ons_owners_to_names", "lns_owners_to_names"); }
@ -2522,7 +2522,7 @@ namespace rpc {
struct response_entry
{
uint64_t request_index; // (Deprecated) The index in request's `entries` array that was resolved via Loki Name Service.
lns::mapping_type type; // The category the Loki Name Service entry belongs to; currently 0 for Session and 2 for Lokinet.
ons::mapping_type type; // The category the Loki Name Service entry belongs to; currently 0 for Session and 2 for Lokinet.
std::string name_hash; // The hash of the name that the owner purchased via Loki Name Service in base64
std::string owner; // The backup public key specified by the owner that purchased the Loki Name Service entry.
std::optional<std::string> backup_owner; // The backup public key specified by the owner that purchased the Loki Name Service entry. Omitted if no backup owner.
@ -2544,31 +2544,31 @@ namespace rpc {
};
OXEN_RPC_DOC_INTROSPECT
// Performs a simple LNS lookup of a BLAKE2b-hashed name. This RPC method is meant for simple,
// Performs a simple ONS lookup of a BLAKE2b-hashed name. This RPC method is meant for simple,
// single-value resolutions that do not care about registration details, etc.; if you need more
// information use LNS_NAMES_TO_OWNERS instead.
// information use ONS_NAMES_TO_OWNERS instead.
//
// Technical details: the returned value is encrypted using the name itself so that neither this
// oxend responding to the RPC request nor any other blockchain observers can (easily) obtain the
// name of registered addresses or the registration details. Thus, from a client's point of view,
// resolving an LNS record involves:
// resolving an ONS record involves:
//
// - Lower-case the name.
// - Calculate the name hash as a null-key, 32-byte BLAKE2b hash of the lower-case name.
// - Obtain the encrypted value and the nonce from this RPC call (or LNS_NAMES_TO_OWNERS); (encode
// - Obtain the encrypted value and the nonce from this RPC call (or ONS_NAMES_TO_OWNERS); (encode
// the name hash using either hex or base64.).
// - Calculate the decryption key as a 32-byte BLAKE2b keyed hash of the name using the
// (unkeyed) name hash calculated above as the hash key.
// - Decrypt (and verify) using XChaCha20-Poly1305 (for example libsodium's
// crypto_aead_xchacha20poly1305_ietf_decrypt) using the above decryption key and using the
// first 24 bytes of the name hash as the public nonce.
struct LNS_RESOLVE : PUBLIC
struct ONS_RESOLVE : PUBLIC
{
static constexpr auto names() { return NAMES("ons_resolve", "lns_resolve"); }
struct request
{
uint16_t type; // The LNS type (mandatory); currently supported values are: 0 = session, 2 = lokinet.
uint16_t type; // The ONS type (mandatory); currently supported values are: 0 = session, 2 = lokinet.
std::string name_hash; // The 32-byte BLAKE2b hash of the name to look up, encoded as 64 hex digits or 44/43 base64 characters (with/without padding).
KV_MAP_SERIALIZABLE
@ -2576,7 +2576,7 @@ namespace rpc {
struct response
{
std::optional<std::string> encrypted_value; // The encrypted LNS value, in hex. Will be omitted from the response if the given name_hash is not registered.
std::optional<std::string> encrypted_value; // The encrypted ONS value, in hex. Will be omitted from the response if the given name_hash is not registered.
std::optional<std::string> nonce; // The nonce value used for encryption, in hex.
KV_MAP_SERIALIZABLE

View File

@ -255,14 +255,14 @@ namespace
const char* USAGE_REQUEST_STAKE_UNLOCK("request_stake_unlock <service_node_pubkey>");
const char* USAGE_PRINT_LOCKED_STAKES("print_locked_stakes");
const char* USAGE_LNS_BUY_MAPPING("lns_buy_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=session|lokinet|lokinet_2y|lokinet_5y|lokinet_10y] [owner=<value>] [backup_owner=<value>] <name> <value>");
const char* USAGE_LNS_RENEW_MAPPING("lns_renew_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=lokinet|lokinet_2y|lokinet_5y|lokinet_10y] <name>");
const char* USAGE_LNS_UPDATE_MAPPING("lns_update_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=session|lokinet] [owner=<value>] [backup_owner=<value>] [value=<lns_value>] [signature=<hex_signature>] <name>");
const char* USAGE_ONS_BUY_MAPPING("ons_buy_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=session|lokinet|lokinet_2y|lokinet_5y|lokinet_10y] [owner=<value>] [backup_owner=<value>] <name> <value>");
const char* USAGE_ONS_RENEW_MAPPING("ons_renew_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=lokinet|lokinet_2y|lokinet_5y|lokinet_10y] <name>");
const char* USAGE_ONS_UPDATE_MAPPING("ons_update_mapping [index=<N1>[,<N2>,...]] [<priority>] [type=session|lokinet] [owner=<value>] [backup_owner=<value>] [value=<ons_value>] [signature=<hex_signature>] <name>");
const char* USAGE_LNS_ENCRYPT("lns_encrypt [type=session|lokinet] <name> <value>");
const char* USAGE_LNS_MAKE_UPDATE_MAPPING_SIGNATURE("lns_make_update_mapping_signature [type=session|lokinet] [owner=<value>] [backup_owner=<value>] [value=<encrypted_lns_value>] <name>");
const char* USAGE_LNS_PRINT_OWNERS_TO_NAMES("lns_print_owners_to_names [<owner> ...]");
const char* USAGE_LNS_PRINT_NAME_TO_OWNERS("lns_print_name_to_owners [type=session|lokinet] <name> [<name> ...]");
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> ...]");
#if defined (OXEN_ENABLE_INTEGRATION_TEST_HOOKS)
std::string input_line(const std::string &prompt, bool yesno = false)
@ -3149,40 +3149,40 @@ Pending or Failed: "failed"|"pending", "out", Lock, Checkpointed, Time, Amount*
tr(USAGE_PRINT_LOCKED_STAKES),
tr("Print stakes currently locked on the Service Node network"));
m_cmd_binder.set_handler("lns_buy_mapping",
[this](const auto& x) { return lns_buy_mapping(x); },
tr(USAGE_LNS_BUY_MAPPING),
tr(tools::wallet_rpc::LNS_BUY_MAPPING::description));
m_cmd_binder.set_handler("ons_buy_mapping",
[this](const auto& x) { return ons_buy_mapping(x); },
tr(USAGE_ONS_BUY_MAPPING),
tr(tools::wallet_rpc::ONS_BUY_MAPPING::description));
m_cmd_binder.set_handler("lns_renew_mapping",
[this](const auto& x) { return lns_renew_mapping(x); },
tr(USAGE_LNS_RENEW_MAPPING),
tr(tools::wallet_rpc::LNS_RENEW_MAPPING::description));
m_cmd_binder.set_handler("ons_renew_mapping",
[this](const auto& x) { return ons_renew_mapping(x); },
tr(USAGE_ONS_RENEW_MAPPING),
tr(tools::wallet_rpc::ONS_RENEW_MAPPING::description));
m_cmd_binder.set_handler("lns_update_mapping",
[this](const auto& x) { return lns_update_mapping(x); },
tr(USAGE_LNS_UPDATE_MAPPING),
tr(tools::wallet_rpc::LNS_UPDATE_MAPPING::description));
m_cmd_binder.set_handler("ons_update_mapping",
[this](const auto& x) { return ons_update_mapping(x); },
tr(USAGE_ONS_UPDATE_MAPPING),
tr(tools::wallet_rpc::ONS_UPDATE_MAPPING::description));
m_cmd_binder.set_handler("lns_encrypt",
[this](const auto& x) { return lns_encrypt(x); },
tr(USAGE_LNS_ENCRYPT),
tr("Encrypts a LNS mapping value with a given name; primarily intended for use with external mapping update signing"));
m_cmd_binder.set_handler("ons_encrypt",
[this](const auto& x) { return ons_encrypt(x); },
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("lns_print_owners_to_names",
[this](const auto& x) { return lns_print_owners_to_names(x); },
tr(USAGE_LNS_PRINT_OWNERS_TO_NAMES),
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),
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("lns_print_name_to_owners",
[this](const auto& x) { return lns_print_name_to_owners(x); },
tr(USAGE_LNS_PRINT_NAME_TO_OWNERS),
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),
tr("Query the ed25519 public keys that own the Oxen Name System names."));
m_cmd_binder.set_handler("lns_make_update_mapping_signature",
[this](const auto& x) { return lns_make_update_mapping_signature(x); },
tr(USAGE_LNS_MAKE_UPDATE_MAPPING_SIGNATURE),
tr(tools::wallet_rpc::LNS_MAKE_UPDATE_SIGNATURE::description));
m_cmd_binder.set_handler("ons_make_update_mapping_signature",
[this](const auto& x) { return ons_make_update_mapping_signature(x); },
tr(USAGE_ONS_MAKE_UPDATE_MAPPING_SIGNATURE),
tr(tools::wallet_rpc::ONS_MAKE_UPDATE_SIGNATURE::description));
}
simple_wallet::~simple_wallet()
@ -6438,16 +6438,16 @@ std::array<std::string, sizeof...(Prefixes)> eat_named_arguments(std::vector<std
}
// Parse a user-provided typestring value; if not provided, guess from the provided name and value.
static std::optional<lns::mapping_type> guess_lns_type(tools::wallet2& wallet, std::string_view typestr, std::string_view name, std::string_view value)
static std::optional<ons::mapping_type> guess_ons_type(tools::wallet2& wallet, std::string_view typestr, std::string_view name, std::string_view value)
{
if (typestr.empty())
{
if (tools::ends_with(name, ".loki") && (tools::ends_with(value, ".loki") || value.empty()))
return lns::mapping_type::lokinet;
if (!tools::ends_with(name, ".loki") && tools::starts_with(value, "05") && value.length() == 2*lns::SESSION_PUBLIC_KEY_BINARY_LENGTH)
return lns::mapping_type::session;
return ons::mapping_type::lokinet;
if (!tools::ends_with(name, ".loki") && tools::starts_with(value, "05") && value.length() == 2*ons::SESSION_PUBLIC_KEY_BINARY_LENGTH)
return ons::mapping_type::session;
fail_msg_writer() << tr("Could not infer LNS type from name/value; trying using the type= argument or see `help' for more details");
fail_msg_writer() << tr("Could not infer ONS type from name/value; trying using the type= argument or see `help' for more details");
return std::nullopt;
}
@ -6459,7 +6459,7 @@ static std::optional<lns::mapping_type> guess_lns_type(tools::wallet2& wallet, s
}
std::string reason;
if (lns::mapping_type type; lns::validate_mapping_type(typestr, *hf_version, lns::lns_tx_type::buy, &type, &reason))
if (ons::mapping_type type; ons::validate_mapping_type(typestr, *hf_version, ons::ons_tx_type::buy, &type, &reason))
return type;
fail_msg_writer() << reason;
@ -6467,32 +6467,32 @@ static std::optional<lns::mapping_type> guess_lns_type(tools::wallet2& wallet, s
}
//----------------------------------------------------------------------------------------------------
static constexpr auto LNS_OWNER_PREFIX = "owner="sv;
static constexpr auto LNS_BACKUP_OWNER_PREFIX = "backup_owner="sv;
static constexpr auto LNS_TYPE_PREFIX = "type="sv;
static constexpr auto LNS_VALUE_PREFIX = "value="sv;
static constexpr auto LNS_SIGNATURE_PREFIX = "signature="sv;
static constexpr auto ONS_OWNER_PREFIX = "owner="sv;
static constexpr auto ONS_BACKUP_OWNER_PREFIX = "backup_owner="sv;
static constexpr auto ONS_TYPE_PREFIX = "type="sv;
static constexpr auto ONS_VALUE_PREFIX = "value="sv;
static constexpr auto ONS_SIGNATURE_PREFIX = "signature="sv;
static char constexpr NULL_STR[] = "(none)";
bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
bool simple_wallet::ons_buy_mapping(std::vector<std::string> args)
{
uint32_t priority = 0;
std::set<uint32_t> subaddr_indices = {};
if (!parse_subaddr_indices_and_priority(*m_wallet, args, subaddr_indices, priority, m_current_subaddress_account)) return false;
auto [owner, backup_owner, typestr] = eat_named_arguments(args, LNS_OWNER_PREFIX, LNS_BACKUP_OWNER_PREFIX, LNS_TYPE_PREFIX);
auto [owner, backup_owner, typestr] = eat_named_arguments(args, ONS_OWNER_PREFIX, ONS_BACKUP_OWNER_PREFIX, ONS_TYPE_PREFIX);
if (args.size() != 2)
{
PRINT_USAGE(USAGE_LNS_BUY_MAPPING);
PRINT_USAGE(USAGE_ONS_BUY_MAPPING);
return true;
}
std::string const &name = args[0];
std::string const &value = args[1];
std::optional<lns::mapping_type> type = guess_lns_type(*m_wallet, typestr, name, value);
std::optional<ons::mapping_type> type = guess_ons_type(*m_wallet, typestr, name, value);
if (!type) return false;
SCOPED_WALLET_UNLOCK();
@ -6501,7 +6501,7 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
try
{
ptx_vector = m_wallet->lns_create_buy_mapping_tx(*type,
ptx_vector = m_wallet->ons_create_buy_mapping_tx(*type,
owner.size() ? &owner : nullptr,
backup_owner.size() ? &backup_owner : nullptr,
name,
@ -6524,7 +6524,7 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
dsts.push_back(info);
std::cout << std::endl << tr("Buying Oxen Name System Record") << std::endl << std::endl;
if (*type == lns::mapping_type::session)
if (*type == ons::mapping_type::session)
std::cout << boost::format(tr("Session Name: %s")) % name << std::endl;
else if (*type == ons::mapping_type::wallet)
std::cout << boost::format(tr("Wallet Name: %s")) % name << std::endl;
@ -6536,7 +6536,7 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
*type == ons::mapping_type::lokinet_5years ? 5 :
*type == ons::mapping_type::lokinet_2years ? 2 :
1;
int blocks = BLOCKS_EXPECTED_IN_DAYS(years * lns::REGISTRATION_YEAR_DAYS);
int blocks = BLOCKS_EXPECTED_IN_DAYS(years * ons::REGISTRATION_YEAR_DAYS);
std::cout << boost::format(tr("Registration: %d years (%d blocks)")) % years % blocks << "\n";
}
else
@ -6559,7 +6559,7 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
*type,
name,
name_hash_str};
m_wallet->set_lns_cache_record(detail);
m_wallet->set_ons_cache_record(detail);
}
catch (const std::exception &e)
{
@ -6576,32 +6576,32 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_renew_mapping(std::vector<std::string> args)
bool simple_wallet::ons_renew_mapping(std::vector<std::string> args)
{
uint32_t priority = 0;
std::set<uint32_t> subaddr_indices = {};
if (!parse_subaddr_indices_and_priority(*m_wallet, args, subaddr_indices, priority, m_current_subaddress_account)) return false;
std::string typestr = eat_named_argument(args, LNS_TYPE_PREFIX);
std::string typestr = eat_named_argument(args, ONS_TYPE_PREFIX);
if (args.empty())
{
PRINT_USAGE(USAGE_LNS_RENEW_MAPPING);
PRINT_USAGE(USAGE_ONS_RENEW_MAPPING);
return false;
}
std::string const &name = args[0];
lns::mapping_type type;
if (auto t = guess_lns_type(*m_wallet, typestr, name, ""))
ons::mapping_type type;
if (auto t = guess_ons_type(*m_wallet, typestr, name, ""))
type = *t;
else return false;
SCOPED_WALLET_UNLOCK();
std::string reason;
std::vector<tools::wallet2::pending_tx> ptx_vector;
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> response;
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> response;
try
{
ptx_vector = m_wallet->lns_create_renewal_tx(
ptx_vector = m_wallet->ons_create_renewal_tx(
type,
name,
&reason,
@ -6622,16 +6622,16 @@ bool simple_wallet::lns_renew_mapping(std::vector<std::string> args)
dsts.push_back(info);
std::cout << "\n" << tr("Renew Oxen Name System Record") << "\n\n";
if (lns::is_lokinet_type(type))
if (ons::is_lokinet_type(type))
std::cout << boost::format(tr("Lokinet Name: %s")) % name << "\n";
else
std::cout << boost::format(tr("Name: %s")) % name << "\n";
int years = 1;
if (type == lns::mapping_type::lokinet_2years) years = 2;
else if (type == lns::mapping_type::lokinet_5years) years = 5;
else if (type == lns::mapping_type::lokinet_10years) years = 10;
int blocks = BLOCKS_EXPECTED_IN_DAYS(years * lns::REGISTRATION_YEAR_DAYS);
if (type == ons::mapping_type::lokinet_2years) years = 2;
else if (type == ons::mapping_type::lokinet_5years) years = 5;
else if (type == ons::mapping_type::lokinet_10years) years = 10;
int blocks = BLOCKS_EXPECTED_IN_DAYS(years * ons::REGISTRATION_YEAR_DAYS);
std::cout << boost::format(tr("Renewal years: %d (%d blocks)")) % years % blocks << "\n";
std::cout << boost::format(tr("New expiry: Block %d")) % (*response[0].expiration_height + blocks) << "\n";
std::cout << std::flush;
@ -6655,7 +6655,7 @@ bool simple_wallet::lns_renew_mapping(std::vector<std::string> args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
bool simple_wallet::ons_update_mapping(std::vector<std::string> args)
{
uint32_t priority = 0;
std::set<uint32_t> subaddr_indices = {};
@ -6663,27 +6663,27 @@ bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
auto [owner, backup_owner, value, signature, typestr] =
eat_named_arguments(args, LNS_OWNER_PREFIX, LNS_BACKUP_OWNER_PREFIX, LNS_VALUE_PREFIX, LNS_SIGNATURE_PREFIX, LNS_TYPE_PREFIX);
eat_named_arguments(args, ONS_OWNER_PREFIX, ONS_BACKUP_OWNER_PREFIX, ONS_VALUE_PREFIX, ONS_SIGNATURE_PREFIX, ONS_TYPE_PREFIX);
if (args.empty())
{
PRINT_USAGE(USAGE_LNS_UPDATE_MAPPING);
PRINT_USAGE(USAGE_ONS_UPDATE_MAPPING);
return false;
}
std::string const &name = args[0];
lns::mapping_type type;
if (auto t = guess_lns_type(*m_wallet, typestr, name, value))
ons::mapping_type type;
if (auto t = guess_ons_type(*m_wallet, typestr, name, value))
type = *t;
else return false;
SCOPED_WALLET_UNLOCK();
std::string reason;
std::vector<tools::wallet2::pending_tx> ptx_vector;
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> response;
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> response;
try
{
ptx_vector = m_wallet->lns_create_update_mapping_tx(type,
ptx_vector = m_wallet->ons_create_update_mapping_tx(type,
name,
value.size() ? &value : nullptr,
owner.size() ? &owner : nullptr,
@ -6701,14 +6701,14 @@ bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
}
auto& enc_hex = response[0].encrypted_value;
if (!oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*lns::mapping_value::BUFFER_SIZE)
if (!oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE)
{
LOG_ERROR("invalid LNS data returned from oxend");
fail_msg_writer() << tr("invalid LNS data returned from oxend");
LOG_ERROR("invalid ONS data returned from oxend");
fail_msg_writer() << tr("invalid ONS data returned from oxend");
return true;
}
lns::mapping_value mval{};
ons::mapping_value mval{};
mval.len = enc_hex.size() / 2;
mval.encrypted = true;
oxenmq::from_hex(enc_hex.begin(), enc_hex.end(), mval.buffer.begin());
@ -6726,9 +6726,9 @@ bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
dsts.push_back(info);
std::cout << std::endl << tr("Updating Oxen Name System Record") << std::endl << std::endl;
if (type == lns::mapping_type::session)
if (type == ons::mapping_type::session)
std::cout << boost::format(tr("Session Name: %s")) % name << std::endl;
else if (lns::is_lokinet_type(type))
else if (ons::is_lokinet_type(type))
std::cout << boost::format(tr("Lokinet Name: %s")) % name << std::endl;
else if (type == ons::mapping_type::wallet)
std::cout << boost::format(tr("Wallet Name: %s")) % name << std::endl;
@ -6758,14 +6758,14 @@ bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
if (!confirm_and_send_tx(dsts, ptx_vector, false /*blink*/))
return false;
// Save the updated LNS record to the wallet cache
std::string name_hash_str = lns::name_to_base64_hash(name);
m_wallet->delete_lns_cache_record(name_hash_str);
tools::wallet2::lns_detail detail = {
// Save the updated ONS record to the wallet cache
std::string name_hash_str = ons::name_to_base64_hash(name);
m_wallet->delete_ons_cache_record(name_hash_str);
tools::wallet2::ons_detail detail = {
type,
name,
name_hash_str};
m_wallet->set_lns_cache_record(detail);
m_wallet->set_ons_cache_record(detail);
}
catch (const std::exception &e)
@ -6783,26 +6783,26 @@ bool simple_wallet::lns_update_mapping(std::vector<std::string> args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_encrypt(std::vector<std::string> args)
bool simple_wallet::ons_encrypt(std::vector<std::string> args)
{
std::string typestr = eat_named_argument(args, LNS_TYPE_PREFIX);
std::string typestr = eat_named_argument(args, ONS_TYPE_PREFIX);
if (args.size() != 2)
{
PRINT_USAGE(USAGE_LNS_ENCRYPT);
PRINT_USAGE(USAGE_ONS_ENCRYPT);
return false;
}
const auto& name = args[0];
const auto& value = args[1];
lns::mapping_type type;
if (auto t = guess_lns_type(*m_wallet, typestr, name, value))
ons::mapping_type type;
if (auto t = guess_ons_type(*m_wallet, typestr, name, value))
type = *t;
else return false;
if (value.size() > lns::mapping_value::BUFFER_SIZE)
if (value.size() > ons::mapping_value::BUFFER_SIZE)
{
fail_msg_writer() << "LNS value '" << value << "' is too long";
fail_msg_writer() << "ONS value '" << value << "' is too long";
return false;
}
@ -6814,20 +6814,20 @@ bool simple_wallet::lns_encrypt(std::vector<std::string> args)
return false;
}
if (!lns::validate_lns_name(type, name, &reason))
if (!ons::validate_ons_name(type, name, &reason))
{
tools::fail_msg_writer() << "Invalid LNS name '" << name << "': " << reason;
tools::fail_msg_writer() << "Invalid ONS name '" << name << "': " << reason;
return false;
}
lns::mapping_value mval;
if (!lns::mapping_value::validate(m_wallet->nettype(), type, value, &mval, &reason))
ons::mapping_value mval;
if (!ons::mapping_value::validate(m_wallet->nettype(), type, value, &mval, &reason))
{
tools::fail_msg_writer() << "Invalid LNS value '" << value << "': " << reason;
tools::fail_msg_writer() << "Invalid ONS value '" << value << "': " << reason;
return false;
}
bool old_argon2 = type == lns::mapping_type::session && *hf_version < cryptonote::network_version_16_pulse;
bool old_argon2 = type == ons::mapping_type::session && *hf_version < cryptonote::network_version_16_pulse;
if (!mval.encrypt(name, nullptr, old_argon2))
{
tools::fail_msg_writer() << "Value encryption failed";
@ -6838,25 +6838,25 @@ bool simple_wallet::lns_encrypt(std::vector<std::string> args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_make_update_mapping_signature(std::vector<std::string> args)
bool simple_wallet::ons_make_update_mapping_signature(std::vector<std::string> args)
{
if (!try_connect_to_daemon())
return true;
auto [owner, backup_owner, value, typestr] =
eat_named_arguments(args, LNS_OWNER_PREFIX, LNS_BACKUP_OWNER_PREFIX, LNS_VALUE_PREFIX, LNS_TYPE_PREFIX);
eat_named_arguments(args, ONS_OWNER_PREFIX, ONS_BACKUP_OWNER_PREFIX, ONS_VALUE_PREFIX, ONS_TYPE_PREFIX);
if (args.empty())
{
PRINT_USAGE(USAGE_LNS_MAKE_UPDATE_MAPPING_SIGNATURE);
PRINT_USAGE(USAGE_ONS_MAKE_UPDATE_MAPPING_SIGNATURE);
return false;
}
std::string const &name = args[0];
SCOPED_WALLET_UNLOCK();
lns::generic_signature signature_binary;
ons::generic_signature signature_binary;
std::string reason;
if (m_wallet->lns_make_update_mapping_signature(lns::mapping_type::session,
if (m_wallet->ons_make_update_mapping_signature(ons::mapping_type::session,
name,
value.size() ? &value : nullptr,
owner.size() ? &owner : nullptr,
@ -6871,21 +6871,21 @@ bool simple_wallet::lns_make_update_mapping_signature(std::vector<std::string> a
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
bool simple_wallet::ons_print_name_to_owners(std::vector<std::string> args)
{
if (!try_connect_to_daemon())
return false;
if (args.empty())
{
PRINT_USAGE(USAGE_LNS_PRINT_NAME_TO_OWNERS);
PRINT_USAGE(USAGE_ONS_PRINT_NAME_TO_OWNERS);
return true;
}
std::string typestr = eat_named_argument(args, LNS_TYPE_PREFIX);
std::string typestr = eat_named_argument(args, ONS_TYPE_PREFIX);
std::vector<uint16_t> requested_types;
// Parse LNS Types
// Parse ONS Types
if (!typestr.empty()) {
auto hf_version = m_wallet->get_hard_fork_version();
if (!hf_version)
@ -6896,14 +6896,14 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
for (auto type : tools::split(typestr, ","))
{
lns::mapping_type mapping_type;
ons::mapping_type mapping_type;
std::string reason;
if (!lns::validate_mapping_type(type, *hf_version, lns::lns_tx_type::lookup, &mapping_type, &reason))
if (!ons::validate_mapping_type(type, *hf_version, ons::ons_tx_type::lookup, &mapping_type, &reason))
{
fail_msg_writer() << reason;
return false;
}
requested_types.push_back(lns::db_mapping_type(mapping_type));
requested_types.push_back(ons::db_mapping_type(mapping_type));
}
}
@ -6915,27 +6915,27 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
fail_msg_writer() << tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED;
return false;
}
auto all_types = lns::all_mapping_types(*hf_version);
std::transform(all_types.begin(), all_types.end(), std::back_inserter(requested_types), lns::db_mapping_type);
auto all_types = ons::all_mapping_types(*hf_version);
std::transform(all_types.begin(), all_types.end(), std::back_inserter(requested_types), ons::db_mapping_type);
}
if (args.empty())
{
PRINT_USAGE(USAGE_LNS_PRINT_NAME_TO_OWNERS);
PRINT_USAGE(USAGE_ONS_PRINT_NAME_TO_OWNERS);
return true;
}
rpc::LNS_NAMES_TO_OWNERS::request request = {};
rpc::ONS_NAMES_TO_OWNERS::request request = {};
for (auto& name : args)
{
name = tools::lowercase_ascii_string(std::move(name));
request.entries.push_back({lns::name_to_base64_hash(name), requested_types});
request.entries.push_back({ons::name_to_base64_hash(name), requested_types});
}
auto [success, response] = m_wallet->lns_names_to_owners(request);
auto [success, response] = m_wallet->ons_names_to_owners(request);
if (!success)
{
fail_msg_writer() << "Connection to daemon failed when requesting LNS owners";
fail_msg_writer() << "Connection to daemon failed when requesting ONS owners";
return false;
}
@ -6943,9 +6943,9 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
for (auto const &mapping : response)
{
auto& enc_hex = mapping.encrypted_value;
if (mapping.entry_index >= args.size() || !oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*lns::mapping_value::BUFFER_SIZE)
if (mapping.entry_index >= args.size() || !oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE)
{
fail_msg_writer() << "Received invalid LNS mapping data from oxend";
fail_msg_writer() << "Received invalid ONS mapping data from oxend";
return false;
}
@ -6955,7 +6955,7 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
last_index = mapping.entry_index;
const auto& name = args[mapping.entry_index];
lns::mapping_value value{};
ons::mapping_value value{};
value.len = enc_hex.size() / 2;
value.encrypted = true;
oxenmq::from_hex(enc_hex.begin(), enc_hex.end(), value.buffer.begin());
@ -6969,7 +6969,7 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
auto writer = tools::msg_writer();
writer
<< "Name: " << name
<< "\n Type: " << static_cast<lns::mapping_type>(mapping.type)
<< "\n Type: " << static_cast<ons::mapping_type>(mapping.type)
<< "\n Value: " << value.to_readable_value(m_wallet->nettype(), mapping.type)
<< "\n Owner: " << mapping.owner;
if (mapping.backup_owner) writer
@ -6985,10 +6985,10 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
tools::wallet2::ons_detail detail =
{
static_cast<lns::mapping_type>(mapping.type),
static_cast<ons::mapping_type>(mapping.type),
name,
request.entries[0].name_hash};
m_wallet->set_lns_cache_record(detail);
m_wallet->set_ons_cache_record(detail);
}
for (size_t i = last_index + 1; i < args.size(); i++)
fail_msg_writer() << args[i] << " not found\n";
@ -6996,22 +6996,22 @@ bool simple_wallet::lns_print_name_to_owners(std::vector<std::string> args)
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::lns_print_owners_to_names(const std::vector<std::string>& args)
bool simple_wallet::ons_print_owners_to_names(const std::vector<std::string>& args)
{
if (!try_connect_to_daemon())
return false;
std::vector<std::vector<cryptonote::rpc::LNS_OWNERS_TO_NAMES::response_entry>> rpc_results;
std::vector<cryptonote::rpc::LNS_OWNERS_TO_NAMES::request> requests(1);
std::vector<std::vector<cryptonote::rpc::ONS_OWNERS_TO_NAMES::response_entry>> rpc_results;
std::vector<cryptonote::rpc::ONS_OWNERS_TO_NAMES::request> requests(1);
std::unordered_map<std::string, tools::wallet2::lns_detail> cache = m_wallet->get_lns_cache();
std::unordered_map<std::string, tools::wallet2::ons_detail> cache = m_wallet->get_ons_cache();
if (args.size() == 0)
{
for (uint32_t index = 0; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
{
if (requests.back().entries.size() >= cryptonote::rpc::LNS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES)
if (requests.back().entries.size() >= cryptonote::rpc::ONS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES)
requests.emplace_back();
requests.back().entries.push_back(m_wallet->get_subaddress_as_str({m_current_subaddress_account, index}));
}
@ -7032,7 +7032,7 @@ bool simple_wallet::lns_print_owners_to_names(const std::vector<std::string>& ar
//return false;
//}
if (requests.back().entries.size() >= cryptonote::rpc::LNS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES)
if (requests.back().entries.size() >= cryptonote::rpc::ONS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES)
requests.emplace_back();
requests.back().entries.push_back(arg);
}
@ -7041,10 +7041,10 @@ bool simple_wallet::lns_print_owners_to_names(const std::vector<std::string>& ar
rpc_results.reserve(requests.size());
for (auto const &request : requests)
{
auto [success, result] = m_wallet->lns_owners_to_names(request);
auto [success, result] = m_wallet->ons_owners_to_names(request);
if (!success)
{
fail_msg_writer() << "Connection to daemon failed when requesting LNS names";
fail_msg_writer() << "Connection to daemon failed when requesting ONS names";
return false;
}
rpc_results.emplace_back(std::move(result));
@ -7073,8 +7073,8 @@ bool simple_wallet::lns_print_owners_to_names(const std::vector<std::string>& ar
if (auto got = cache.find(entry.name_hash); got != cache.end())
{
name = got->second.name;
lns::mapping_value mv;
if (lns::mapping_value::validate_encrypted(entry.type, oxenmq::from_hex(entry.encrypted_value), &mv)
ons::mapping_value mv;
if (ons::mapping_value::validate_encrypted(entry.type, oxenmq::from_hex(entry.encrypted_value), &mv)
&& mv.decrypt(name, entry.type))
value = mv.to_readable_value(nettype, entry.type);
}

View File

@ -181,13 +181,13 @@ namespace cryptonote
bool request_stake_unlock(const std::vector<std::string> &args_);
bool print_locked_stakes(const std::vector<std::string>& /*args*/);
bool query_locked_stakes(bool print_result);
bool lns_buy_mapping(std::vector<std::string> args);
bool lns_renew_mapping(std::vector<std::string> args);
bool lns_update_mapping(std::vector<std::string> args);
bool lns_encrypt(std::vector<std::string> args);
bool lns_make_update_mapping_signature(std::vector<std::string> args);
bool lns_print_owners_to_names(const std::vector<std::string> &args);
bool lns_print_name_to_owners(std::vector<std::string> args);
bool ons_buy_mapping(std::vector<std::string> args);
bool ons_renew_mapping(std::vector<std::string> args);
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);
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);

View File

@ -335,14 +335,14 @@ std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODE_BLACKLISTED_KEY_IM
return result;
}
std::pair<bool, std::vector<cryptonote::rpc::LNS_OWNERS_TO_NAMES::response_entry>> NodeRPCProxy::lns_owners_to_names(cryptonote::rpc::LNS_OWNERS_TO_NAMES::request const &request) const
std::pair<bool, std::vector<cryptonote::rpc::ONS_OWNERS_TO_NAMES::response_entry>> NodeRPCProxy::ons_owners_to_names(cryptonote::rpc::ONS_OWNERS_TO_NAMES::request const &request) const
{
return get_result_pair<rpc::LNS_OWNERS_TO_NAMES>(request, [](auto&& res) { return std::move(res.entries); });
return get_result_pair<rpc::ONS_OWNERS_TO_NAMES>(request, [](auto&& res) { return std::move(res.entries); });
}
std::pair<bool, std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry>> NodeRPCProxy::lns_names_to_owners(cryptonote::rpc::LNS_NAMES_TO_OWNERS::request const &request) const
std::pair<bool, std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry>> NodeRPCProxy::ons_names_to_owners(cryptonote::rpc::ONS_NAMES_TO_OWNERS::request const &request) const
{
return get_result_pair<rpc::LNS_NAMES_TO_OWNERS>(request, [](auto&& res) { return std::move(res.entries); });
return get_result_pair<rpc::ONS_NAMES_TO_OWNERS>(request, [](auto&& res) { return std::move(res.entries); });
}
std::pair<bool, cryptonote::rpc::ONS_RESOLVE_ADDRESS::response> NodeRPCProxy::ons_resolve_address(cryptonote::rpc::ONS_RESOLVE_ADDRESS::request const &request) const

View File

@ -60,8 +60,8 @@ public:
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry>> get_all_service_nodes() const;
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry>> get_contributed_service_nodes(const std::string& contributor) const;
std::pair<bool, std::vector<cryptonote::rpc::GET_SERVICE_NODE_BLACKLISTED_KEY_IMAGES::entry>> get_service_node_blacklisted_key_images() const;
std::pair<bool, std::vector<cryptonote::rpc::LNS_OWNERS_TO_NAMES::response_entry>> lns_owners_to_names(cryptonote::rpc::LNS_OWNERS_TO_NAMES::request const &request) const;
std::pair<bool, std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry>> lns_names_to_owners(cryptonote::rpc::LNS_NAMES_TO_OWNERS::request const &request) const;
std::pair<bool, std::vector<cryptonote::rpc::ONS_OWNERS_TO_NAMES::response_entry>> ons_owners_to_names(cryptonote::rpc::ONS_OWNERS_TO_NAMES::request const &request) const;
std::pair<bool, std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry>> ons_names_to_owners(cryptonote::rpc::ONS_NAMES_TO_OWNERS::request const &request) const;
std::pair<bool, cryptonote::rpc::ONS_RESOLVE_ADDRESS::response> ons_resolve_address(cryptonote::rpc::ONS_RESOLVE_ADDRESS::request const &request) const;
private:

View File

@ -2546,7 +2546,7 @@ void wallet2::process_unconfirmed(const crypto::hash &txid, const cryptonote::tr
if(unconf_it != m_unconfirmed_txs.end()) {
if (store_tx_info()) {
try {
// TODO(doyle): LNS introduces tx type stake, we can use this to quickly determine if a transaction is staking
// TODO(doyle): ONS introduces tx type stake, we can use this to quickly determine if a transaction is staking
// transaction without having to parse tx_extra.
bool stake = service_nodes::tx_get_staking_components(tx, nullptr /*stake*/);
wallet::pay_type pay_type = stake ? wallet::pay_type::stake : wallet::pay_type::out;
@ -7748,7 +7748,7 @@ uint64_t wallet2::get_fee_percent(uint32_t priority, txtype type) const
THROW_WALLET_EXCEPTION(error::invalid_priority);
uint64_t burn_pct = 0;
if (use_fork_rules(network_version_15_lns, 0))
if (use_fork_rules(network_version_15_ons, 0))
burn_pct = BLINK_BURN_TX_FEE_PERCENT;
else if (use_fork_rules(network_version_14_blink, 0))
burn_pct = BLINK_BURN_TX_FEE_PERCENT_OLD;
@ -7799,7 +7799,7 @@ uint64_t wallet2::get_fee_quantization_mask() const
return 1;
}
oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx_type, uint32_t priority, lns::mapping_type type)
oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx_type, uint32_t priority, ons::mapping_type type)
{
oxen_construct_tx_params tx_params;
tx_params.hf_version = hf_version;
@ -7808,7 +7808,7 @@ oxen_construct_tx_params wallet2::construct_params(uint8_t hf_version, txtype tx
if (tx_type == txtype::oxen_name_system)
{
assert(priority != tools::tx_priority_blink);
tx_params.burn_fixed = lns::burn_needed(hf_version, type);
tx_params.burn_fixed = ons::burn_needed(hf_version, type);
}
else if (priority == tools::tx_priority_blink)
{
@ -8653,19 +8653,19 @@ wallet2::request_stake_unlock_result wallet2::can_request_stake_unlock(const cry
return result;
}
struct lns_prepared_args
struct ons_prepared_args
{
bool prepared;
operator bool() const { return prepared; }
lns::mapping_value encrypted_value;
ons::mapping_value encrypted_value;
crypto::hash name_hash;
lns::generic_owner owner;
lns::generic_owner backup_owner;
lns::generic_signature signature;
ons::generic_owner owner;
ons::generic_owner backup_owner;
ons::generic_signature signature;
crypto::hash prev_txid;
};
static bool try_generate_lns_signature(wallet2 const &wallet, std::string const &curr_owner, std::string const *new_owner, std::string const *new_backup_owner, lns_prepared_args &result)
static bool try_generate_ons_signature(wallet2 const &wallet, std::string const &curr_owner, std::string const *new_owner, std::string const *new_backup_owner, ons_prepared_args &result)
{
cryptonote::address_parse_info curr_owner_parsed = {};
if (!cryptonote::get_account_address_from_str(curr_owner_parsed, wallet.nettype(), curr_owner))
@ -8674,7 +8674,7 @@ static bool try_generate_lns_signature(wallet2 const &wallet, std::string const
std::optional<cryptonote::subaddress_index> index = wallet.get_subaddress_index(curr_owner_parsed.address);
if (!index) return false;
auto sig_data = lns::tx_extra_signature(
auto sig_data = ons::tx_extra_signature(
result.encrypted_value.to_view(),
new_owner ? &result.owner : nullptr,
new_backup_owner ? &result.backup_owner : nullptr,
@ -8684,26 +8684,26 @@ static bool try_generate_lns_signature(wallet2 const &wallet, std::string const
auto& account = wallet.get_account();
auto& hwdev = account.get_device();
hw::mode_resetter rst{hwdev};
hwdev.generate_lns_signature(sig_data, account.get_keys(), *index, result.signature.monero);
result.signature.type = lns::generic_owner_sig_type::monero;
hwdev.generate_ons_signature(sig_data, account.get_keys(), *index, result.signature.monero);
result.signature.type = ons::generic_owner_sig_type::monero;
return true;
}
static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const &wallet,
lns::mapping_type type,
static ons_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const &wallet,
ons::mapping_type type,
uint32_t priority,
std::string name,
std::string const *value,
std::string const *owner,
std::string const *backup_owner,
bool make_signature,
lns::lns_tx_type txtype,
ons::ons_tx_type txtype,
uint32_t account_index,
std::string *reason,
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> *response)
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> *response)
{
lns_prepared_args result = {};
ons_prepared_args result = {};
if (priority == tools::tx_priority_blink)
{
if (reason) *reason = "Can not request a blink TX for Oxen Name Service transactions";
@ -8711,13 +8711,13 @@ static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const
}
name = tools::lowercase_ascii_string(name);
if (!lns::validate_lns_name(type, name, reason))
if (!ons::validate_ons_name(type, name, reason))
return {};
result.name_hash = lns::name_to_hash(name);
result.name_hash = ons::name_to_hash(name);
if (value)
{
if (!lns::mapping_value::validate(wallet.nettype(), type, *value, &result.encrypted_value, reason))
if (!ons::mapping_value::validate(wallet.nettype(), type, *value, &result.encrypted_value, reason))
return {};
if (!result.encrypted_value.encrypt(name, &result.name_hash))
@ -8727,28 +8727,28 @@ static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const
}
}
if (owner && !lns::parse_owner_to_generic_owner(wallet.nettype(), *owner, result.owner, reason))
if (owner && !ons::parse_owner_to_generic_owner(wallet.nettype(), *owner, result.owner, reason))
return {};
if (backup_owner && !lns::parse_owner_to_generic_owner(wallet.nettype(), *backup_owner, result.backup_owner, reason))
if (backup_owner && !ons::parse_owner_to_generic_owner(wallet.nettype(), *backup_owner, result.backup_owner, reason))
return {};
{
cryptonote::rpc::LNS_NAMES_TO_OWNERS::request request = {};
cryptonote::rpc::ONS_NAMES_TO_OWNERS::request request = {};
{
auto &request_entry = request.entries.emplace_back();
request_entry.name_hash = oxenmq::to_base64(tools::view_guts(result.name_hash));
request_entry.types.push_back(lns::db_mapping_type(type));
request_entry.types.push_back(ons::db_mapping_type(type));
}
auto [success, response_] = wallet.lns_names_to_owners(request);
auto [success, response_] = wallet.ons_names_to_owners(request);
if (!response)
response = &response_;
else
*response = std::move(response_);
if (!success)
{
if (reason) *reason = "Failed to query previous owner for LNS entry: communication with daemon failed";
if (reason) *reason = "Failed to query previous owner for ONS entry: communication with daemon failed";
return result;
}
@ -8761,11 +8761,11 @@ static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const
}
}
if (txtype == lns::lns_tx_type::update && make_signature)
if (txtype == ons::ons_tx_type::update && make_signature)
{
if (response->empty())
{
if (reason) *reason = "Signature requested when preparing LNS TX but record to update does not exist";
if (reason) *reason = "Signature requested when preparing ONS TX but record to update does not exist";
return result;
}
@ -8775,20 +8775,20 @@ static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const
auto& rbackup_owner = response->front().backup_owner;
bool curr_owner = cryptonote::get_account_address_from_str(curr_owner_parsed, wallet.nettype(), rowner);
bool curr_backup_owner = rbackup_owner && cryptonote::get_account_address_from_str(curr_backup_owner_parsed, wallet.nettype(), *rbackup_owner);
if (!try_generate_lns_signature(wallet, rowner, owner, backup_owner, result))
if (!try_generate_ons_signature(wallet, rowner, owner, backup_owner, result))
{
if (!rbackup_owner || !try_generate_lns_signature(wallet, *rbackup_owner, owner, backup_owner, result))
if (!rbackup_owner || !try_generate_ons_signature(wallet, *rbackup_owner, owner, backup_owner, result))
{
if (reason)
{
*reason = "Signature requested when preparing LNS TX, but this wallet is not the owner of the record owner=" + rowner;
*reason = "Signature requested when preparing ONS TX, but this wallet is not the owner of the record owner=" + rowner;
if (rbackup_owner) *reason += ", backup_owner=" + *rbackup_owner;
}
return result;
}
}
}
else if (txtype == lns::lns_tx_type::renew)
else if (txtype == ons::ons_tx_type::renew)
{
if (response->empty())
{
@ -8802,7 +8802,7 @@ static lns_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const
return result;
}
std::vector<wallet2::pending_tx> wallet2::lns_create_buy_mapping_tx(lns::mapping_type type,
std::vector<wallet2::pending_tx> wallet2::ons_create_buy_mapping_tx(ons::mapping_type type,
std::string const *owner,
std::string const *backup_owner,
std::string name,
@ -8812,11 +8812,11 @@ std::vector<wallet2::pending_tx> wallet2::lns_create_buy_mapping_tx(lns::mapping
uint32_t account_index,
std::set<uint32_t> subaddr_indices)
{
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> response;
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> response;
constexpr bool make_signature = false;
lns_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, &value, owner, backup_owner, make_signature, lns::lns_tx_type::buy, account_index, reason, &response);
ons_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, &value, owner, backup_owner, make_signature, ons::ons_tx_type::buy, account_index, reason, &response);
if (!owner)
prepared_args.owner = lns::make_monero_owner(get_subaddress({account_index, 0}), account_index != 0);
prepared_args.owner = ons::make_monero_owner(get_subaddress({account_index, 0}), account_index != 0);
if (!prepared_args)
return {};
@ -8850,7 +8850,7 @@ std::vector<wallet2::pending_tx> wallet2::lns_create_buy_mapping_tx(lns::mapping
return result;
}
std::optional<lns::mapping_type> wallet2::lns_validate_type(std::string_view type, lns::lns_tx_type lns_action, std::string *reason)
std::optional<ons::mapping_type> wallet2::ons_validate_type(std::string_view type, ons::ons_tx_type ons_action, std::string *reason)
{
std::optional<uint8_t> hf_version = get_hard_fork_version();
if (!hf_version)
@ -8858,25 +8858,25 @@ std::optional<lns::mapping_type> wallet2::lns_validate_type(std::string_view typ
if (reason) *reason = ERR_MSG_NETWORK_VERSION_QUERY_FAILED;
return std::nullopt;
}
lns::mapping_type mapping_type;
if (!lns::validate_mapping_type(type, *hf_version, lns_action, &mapping_type, reason))
ons::mapping_type mapping_type;
if (!ons::validate_mapping_type(type, *hf_version, ons_action, &mapping_type, reason))
return std::nullopt;
return mapping_type;
}
std::vector<wallet2::pending_tx> wallet2::lns_create_renewal_tx(
lns::mapping_type type,
std::vector<wallet2::pending_tx> wallet2::ons_create_renewal_tx(
ons::mapping_type type,
std::string name,
std::string *reason,
uint32_t priority,
uint32_t account_index,
std::set<uint32_t> subaddr_indices,
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> *response
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> *response
)
{
constexpr bool make_signature = false;
lns_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, nullptr, nullptr, nullptr, make_signature, lns::lns_tx_type::renew, account_index, reason, response);
ons_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, nullptr, nullptr, nullptr, make_signature, ons::ons_tx_type::renew, account_index, reason, response);
if (!prepared_args)
return {};
@ -8908,7 +8908,7 @@ std::vector<wallet2::pending_tx> wallet2::lns_create_renewal_tx(
}
std::vector<wallet2::pending_tx> wallet2::lns_create_update_mapping_tx(lns::mapping_type type,
std::vector<wallet2::pending_tx> wallet2::ons_create_update_mapping_tx(ons::mapping_type type,
std::string name,
std::string const *value,
std::string const *owner,
@ -8918,16 +8918,16 @@ std::vector<wallet2::pending_tx> wallet2::lns_create_update_mapping_tx(lns::mapp
uint32_t priority,
uint32_t account_index,
std::set<uint32_t> subaddr_indices,
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> *response)
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> *response)
{
if (!value && !owner && !backup_owner)
{
if (reason) *reason = "Value, owner and backup owner are not specified. Atleast one field must be specified for updating the LNS record";
if (reason) *reason = "Value, owner and backup owner are not specified. Atleast one field must be specified for updating the ONS record";
return {};
}
bool make_signature = signature == nullptr;
lns_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, value, owner, backup_owner, make_signature, lns::lns_tx_type::update, account_index, reason, response);
ons_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, priority, name, value, owner, backup_owner, make_signature, ons::ons_tx_type::update, account_index, reason, response);
if (!prepared_args) return {};
if (!make_signature)
@ -8954,7 +8954,7 @@ std::vector<wallet2::pending_tx> wallet2::lns_create_update_mapping_tx(lns::mapp
if (reason) *reason = ERR_MSG_NETWORK_VERSION_QUERY_FAILED;
return {};
}
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, lns::mapping_type::update_record_internal);
oxen_construct_tx_params tx_params = wallet2::construct_params(*hf_version, txtype::oxen_name_system, priority, ons::mapping_type::update_record_internal);
auto result = create_transactions_2({} /*dests*/,
CRYPTONOTE_DEFAULT_TX_MIXIN,
@ -8993,23 +8993,23 @@ bool wallet2::unlock_keys_file()
return true;
}
bool wallet2::lns_make_update_mapping_signature(lns::mapping_type type,
bool wallet2::ons_make_update_mapping_signature(ons::mapping_type type,
std::string name,
std::string const *value,
std::string const *owner,
std::string const *backup_owner,
lns::generic_signature &signature,
ons::generic_signature &signature,
uint32_t account_index,
std::string *reason)
{
std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> response;
std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> response;
constexpr bool make_signature = true;
lns_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, tx_priority_unimportant, name, value, owner, backup_owner, make_signature, lns::lns_tx_type::update, account_index, reason, &response);
ons_prepared_args prepared_args = prepare_tx_extra_oxen_name_system_values(*this, type, tx_priority_unimportant, name, value, owner, backup_owner, make_signature, ons::ons_tx_type::update, account_index, reason, &response);
if (!prepared_args) return false;
if (prepared_args.prev_txid == crypto::null_hash)
{
if (reason) *reason = "name=\"" + name + std::string("\" does not have a corresponding LNS record, the mapping is available for purchase, update signature is not required.");
if (reason) *reason = "name=\"" + name + std::string("\" does not have a corresponding ONS record, the mapping is available for purchase, update signature is not required.");
return false;
}
@ -10038,7 +10038,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
if (update_splitted_dsts)
{
// NOTE: If LNS, there's already a dummy destination entry in there that
// NOTE: If ONS, there's already a dummy destination entry in there that
// we placed in (for fake calculating the TX fees and parts) that we
// repurpose for change after the fact.
if (tx_params.tx_type == txtype::oxen_name_system)
@ -10811,9 +10811,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
std::unique_lock hwdev_lock{hwdev};
hw::mode_resetter rst{hwdev};
bool const is_lns_tx = (tx_params.tx_type == txtype::oxen_name_system);
bool const is_ons_tx = (tx_params.tx_type == txtype::oxen_name_system);
auto original_dsts = dsts;
if (is_lns_tx)
if (is_ons_tx)
{
THROW_WALLET_EXCEPTION_IF(dsts.size() != 0, error::wallet_internal_error, "oxen name system txs must not have any destinations set, has: " + std::to_string(dsts.size()));
dsts.emplace_back(0, account_public_address{} /*address*/, false /*is_subaddress*/); // NOTE: Create a dummy dest that gets repurposed into the change output.
@ -10903,14 +10903,14 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
needed_money = 0;
for(auto& dt: dsts)
{
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && !is_lns_tx, error::zero_destination);
THROW_WALLET_EXCEPTION_IF(0 == dt.amount && !is_ons_tx, error::zero_destination);
needed_money += dt.amount;
LOG_PRINT_L2("transfer: adding " << print_money(dt.amount) << ", for a total of " << print_money (needed_money));
THROW_WALLET_EXCEPTION_IF(needed_money < dt.amount, error::tx_sum_overflow, dsts, 0, m_nettype);
}
// throw if attempting a transaction with no money
THROW_WALLET_EXCEPTION_IF(needed_money == 0 && !is_lns_tx, error::zero_destination);
THROW_WALLET_EXCEPTION_IF(needed_money == 0 && !is_ons_tx, error::zero_destination);
std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddr = unlocked_balance_per_subaddress(subaddr_account, false);
std::map<uint32_t, uint64_t> balance_per_subaddr = balance_per_subaddress(subaddr_account, false);
@ -10924,7 +10924,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
// early out if we know we can't make it anyway
// we could also check for being within FEE_PER_KB, but if the fee calculation
// ever changes, this might be missed, so let this go through
const uint64_t min_outputs = tx_params.tx_type == cryptonote::txtype::oxen_name_system ? 1 : 2; // if lns, only request the change output
const uint64_t min_outputs = tx_params.tx_type == cryptonote::txtype::oxen_name_system ? 1 : 2; // if ons, only request the change output
{
uint64_t min_fee = (
base_fee.first * estimate_rct_tx_size(1, fake_outs_count, min_outputs, extra.size(), clsag) +
@ -11101,11 +11101,11 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
idx = pop_back(preferred_inputs);
pop_if_present(*unused_transfers_indices, idx);
pop_if_present(*unused_dust_indices, idx);
} else if ((dsts.empty() || (dsts[0].amount == 0 && !is_lns_tx)) && !adding_fee) {
// NOTE: A LNS tx sets dsts[0].amount to 0, but this branch is for the
// 2 inputs/2 outputs. We only have 1 output as LNS transactions are
} else if ((dsts.empty() || (dsts[0].amount == 0 && !is_ons_tx)) && !adding_fee) {
// NOTE: A ONS tx sets dsts[0].amount to 0, but this branch is for the
// 2 inputs/2 outputs. We only have 1 output as ONS transactions are
// distinguishable, so we actually want the last branch which uses unused
// outputs in the wallet to pay off the LNS fee.
// outputs in the wallet to pay off the ONS fee.
// the "make rct txes 2/2" case - we pick a small value output to "clean up" the wallet too
std::vector<size_t> indices = get_only_rct(*unused_dust_indices, *unused_transfers_indices);
@ -13011,19 +13011,19 @@ std::vector<rpc::GET_SERVICE_NODES::response::entry> wallet2::list_current_stake
return service_node_states;
}
void wallet2::set_lns_cache_record(wallet2::lns_detail detail)
void wallet2::set_ons_cache_record(wallet2::ons_detail detail)
{
lns_records_cache[detail.hashed_name] = std::move(detail);
ons_records_cache[detail.hashed_name] = std::move(detail);
}
void wallet2::delete_lns_cache_record(const std::string& hashed_name)
void wallet2::delete_ons_cache_record(const std::string& hashed_name)
{
lns_records_cache.erase(hashed_name);
ons_records_cache.erase(hashed_name);
}
std::unordered_map<std::string, wallet2::lns_detail> wallet2::get_lns_cache()
std::unordered_map<std::string, wallet2::ons_detail> wallet2::get_ons_cache()
{
return lns_records_cache;
return ons_records_cache;
}
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)

View File

@ -815,23 +815,23 @@ private:
auto get_service_nodes(std::vector<std::string> const &pubkeys) const { return m_node_rpc_proxy.get_service_nodes(pubkeys); }
auto get_service_node_blacklisted_key_images() const { return m_node_rpc_proxy.get_service_node_blacklisted_key_images(); }
std::vector<cryptonote::rpc::GET_SERVICE_NODES::response::entry> list_current_stakes();
auto lns_owners_to_names(cryptonote::rpc::LNS_OWNERS_TO_NAMES::request const &request) const { return m_node_rpc_proxy.lns_owners_to_names(request); }
auto lns_names_to_owners(cryptonote::rpc::LNS_NAMES_TO_OWNERS::request const &request) const { return m_node_rpc_proxy.lns_names_to_owners(request); }
auto ons_owners_to_names(cryptonote::rpc::ONS_OWNERS_TO_NAMES::request const &request) const { return m_node_rpc_proxy.ons_owners_to_names(request); }
auto ons_names_to_owners(cryptonote::rpc::ONS_NAMES_TO_OWNERS::request const &request) const { return m_node_rpc_proxy.ons_names_to_owners(request); }
auto resolve_address(cryptonote::rpc::ONS_RESOLVE_ADDRESS::request const &request) const { return m_node_rpc_proxy.ons_resolve_address(request); }
struct lns_detail
struct ons_detail
{
lns::mapping_type type;
ons::mapping_type type;
std::string name;
std::string hashed_name;
};
std::unordered_map<std::string, lns_detail> lns_records_cache;
std::unordered_map<std::string, ons_detail> ons_records_cache;
void set_lns_cache_record(wallet2::lns_detail detail);
void set_ons_cache_record(wallet2::ons_detail detail);
void delete_lns_cache_record(const std::string& name);
void delete_ons_cache_record(const std::string& name);
std::unordered_map<std::string, lns_detail> get_lns_cache();
std::unordered_map<std::string, ons_detail> get_ons_cache();
uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); }
void rescan_spent();
@ -961,7 +961,7 @@ private:
a & m_immutable_height;
if(ver < 30)
return;
a & lns_records_cache;
a & ons_records_cache;
}
/*!
@ -1223,8 +1223,8 @@ private:
uint64_t get_fee_quantization_mask() const;
// params constructor, accumulates the burn amounts if the priority is
// a blink and, or a lns tx. If it is a blink TX, lns_burn_type is ignored.
static cryptonote::oxen_construct_tx_params construct_params(uint8_t hf_version, cryptonote::txtype tx_type, uint32_t priority, lns::mapping_type lns_burn_type = static_cast<lns::mapping_type>(0));
// a blink and, or a ons tx. If it is a blink TX, ons_burn_type is ignored.
static cryptonote::oxen_construct_tx_params construct_params(uint8_t hf_version, cryptonote::txtype tx_type, uint32_t priority, ons::mapping_type ons_burn_type = static_cast<ons::mapping_type>(0));
bool is_unattended() const { return m_unattended; }
@ -1391,22 +1391,22 @@ private:
};
request_stake_unlock_result can_request_stake_unlock(const crypto::public_key &sn_key);
// Attempts to convert the LNS type string to a mapping type (checking the current hard fork).
// Attempts to convert the ONS type string to a mapping type (checking the current hard fork).
// If type isn't valid then returns std::nullopt and sets the failure reason in `reason` (if not
// nullptr).
std::optional<lns::mapping_type> lns_validate_type(std::string_view type, lns::lns_tx_type lns_action, std::string *reason);
std::optional<ons::mapping_type> ons_validate_type(std::string_view type, ons::ons_tx_type ons_action, std::string *reason);
std::vector<pending_tx> lns_create_buy_mapping_tx(lns::mapping_type type, std::string const *owner, std::string const *backup_owner, std::string 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<pending_tx> ons_create_buy_mapping_tx(ons::mapping_type type, std::string const *owner, std::string const *backup_owner, std::string name, std::string const &value, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {});
// signature: (Optional) If set, use the signature given, otherwise by default derive the signature from the wallet spend key as an ed25519 key.
// The signature is derived from the hash of the previous txid blob and previous value blob of the mapping. By default this is signed using the wallet's spend key as an ed25519 keypair.
std::vector<pending_tx> lns_create_update_mapping_tx(lns::mapping_type type, std::string name, std::string const *value, std::string const *owner, std::string const *backup_owner, std::string const *signature, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {}, std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> *response = {});
std::vector<pending_tx> ons_create_update_mapping_tx(ons::mapping_type type, std::string name, std::string const *value, std::string const *owner, std::string const *backup_owner, std::string const *signature, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {}, std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> *response = {});
// LNS renewal (for lokinet registrations, not for session/wallet)
std::vector<pending_tx> lns_create_renewal_tx(lns::mapping_type type, std::string name, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {}, std::vector<cryptonote::rpc::LNS_NAMES_TO_OWNERS::response_entry> *response = {});
// ONS renewal (for lokinet registrations, not for session/wallet)
std::vector<pending_tx> ons_create_renewal_tx(ons::mapping_type type, std::string name, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set<uint32_t> subaddr_indices = {}, std::vector<cryptonote::rpc::ONS_NAMES_TO_OWNERS::response_entry> *response = {});
// Generate just the signature required for putting into lns_update_mapping command in the wallet
bool lns_make_update_mapping_signature(lns::mapping_type type, std::string name, std::string const *value, std::string const *owner, std::string const *backup_owner, lns::generic_signature &signature, uint32_t account_index = 0, std::string *reason = nullptr);
// Generate just the signature required for putting into ons_update_mapping command in the wallet
bool ons_make_update_mapping_signature(ons::mapping_type type, std::string name, std::string const *value, std::string const *owner, std::string const *backup_owner, ons::generic_signature &signature, uint32_t account_index = 0, std::string *reason = nullptr);
void freeze(size_t idx);
void thaw(size_t idx);
@ -1720,12 +1720,12 @@ BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 9)
BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 8)
BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 18)
BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
BOOST_CLASS_VERSION(tools::wallet2::lns_detail, 1)
BOOST_CLASS_VERSION(tools::wallet2::ons_detail, 1)
namespace boost::serialization
{
template <class Archive>
void serialize(Archive &a, tools::wallet2::lns_detail &x, const unsigned int ver)
void serialize(Archive &a, tools::wallet2::ons_detail &x, const unsigned int ver)
{
a & x.type;
a & x.name;

View File

@ -3063,17 +3063,17 @@ namespace {
return res;
}
LNS_BUY_MAPPING::response wallet_rpc_server::invoke(LNS_BUY_MAPPING::request&& req)
ONS_BUY_MAPPING::response wallet_rpc_server::invoke(ONS_BUY_MAPPING::request&& req)
{
require_open();
LNS_BUY_MAPPING::response res{};
ONS_BUY_MAPPING::response res{};
std::string reason;
auto type = m_wallet->lns_validate_type(req.type, lns::lns_tx_type::buy, &reason);
auto type = m_wallet->ons_validate_type(req.type, ons::ons_tx_type::buy, &reason);
if (!type)
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid LNS buy type: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid ONS buy type: " + reason};
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->lns_create_buy_mapping_tx(*type,
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->ons_create_buy_mapping_tx(*type,
req.owner.size() ? &req.owner : nullptr,
req.backup_owner.size() ? &req.backup_owner : nullptr,
req.name,
@ -3083,15 +3083,15 @@ namespace {
req.account_index,
req.subaddr_indices);
if (ptx_vector.empty())
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create LNS transaction: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create ONS transaction: " + reason};
//Save the LNS record to the wallet cache
std::string name_hash_str = lns::name_to_base64_hash(req.name);
tools::wallet2::lns_detail detail = {
//Save the ONS record to the wallet cache
std::string name_hash_str = ons::name_to_base64_hash(req.name);
tools::wallet2::ons_detail detail = {
*type,
req.name,
name_hash_str};
m_wallet->set_lns_cache_record(detail);
m_wallet->set_ons_cache_record(detail);
fill_response( ptx_vector,
req.get_tx_key,
@ -3111,21 +3111,21 @@ namespace {
return res;
}
LNS_RENEW_MAPPING::response wallet_rpc_server::invoke(LNS_RENEW_MAPPING::request&& req)
ONS_RENEW_MAPPING::response wallet_rpc_server::invoke(ONS_RENEW_MAPPING::request&& req)
{
require_open();
LNS_RENEW_MAPPING::response res{};
ONS_RENEW_MAPPING::response res{};
std::string reason;
auto type = m_wallet->lns_validate_type(req.type, lns::lns_tx_type::renew, &reason);
auto type = m_wallet->ons_validate_type(req.type, ons::ons_tx_type::renew, &reason);
if (!type)
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid LNS renewal type: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid ONS renewal type: " + reason};
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->lns_create_renewal_tx(
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->ons_create_renewal_tx(
*type, req.name, &reason, req.priority, req.account_index, req.subaddr_indices);
if (ptx_vector.empty())
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create LNS renewal transaction: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create ONS renewal transaction: " + reason};
fill_response( ptx_vector,
req.get_tx_key,
@ -3145,18 +3145,18 @@ namespace {
return res;
}
LNS_UPDATE_MAPPING::response wallet_rpc_server::invoke(LNS_UPDATE_MAPPING::request&& req)
ONS_UPDATE_MAPPING::response wallet_rpc_server::invoke(ONS_UPDATE_MAPPING::request&& req)
{
require_open();
LNS_UPDATE_MAPPING::response res{};
ONS_UPDATE_MAPPING::response res{};
std::string reason;
auto type = m_wallet->lns_validate_type(req.type, lns::lns_tx_type::update, &reason);
auto type = m_wallet->ons_validate_type(req.type, ons::ons_tx_type::update, &reason);
if (!type)
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid LNS update type: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid ONS update type: " + reason};
std::vector<wallet2::pending_tx> ptx_vector =
m_wallet->lns_create_update_mapping_tx(*type,
m_wallet->ons_create_update_mapping_tx(*type,
req.name,
req.value.empty() ? nullptr : &req.value,
req.owner.empty() ? nullptr : &req.owner,
@ -3168,16 +3168,16 @@ namespace {
req.subaddr_indices);
if (ptx_vector.empty())
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create LNS update transaction: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create ONS update transaction: " + reason};
// Save the updated LNS record to the wallet cache
std::string name_hash_str = lns::name_to_base64_hash(req.name);
m_wallet->delete_lns_cache_record(name_hash_str);
tools::wallet2::lns_detail detail = {
// Save the updated ONS record to the wallet cache
std::string name_hash_str = ons::name_to_base64_hash(req.name);
m_wallet->delete_ons_cache_record(name_hash_str);
tools::wallet2::ons_detail detail = {
*type,
req.name,
name_hash_str};
m_wallet->set_lns_cache_record(detail);
m_wallet->set_ons_cache_record(detail);
fill_response( ptx_vector,
req.get_tx_key,
@ -3197,20 +3197,20 @@ namespace {
return res;
}
LNS_MAKE_UPDATE_SIGNATURE::response wallet_rpc_server::invoke(LNS_MAKE_UPDATE_SIGNATURE::request&& req)
ONS_MAKE_UPDATE_SIGNATURE::response wallet_rpc_server::invoke(ONS_MAKE_UPDATE_SIGNATURE::request&& req)
{
require_open();
LNS_MAKE_UPDATE_SIGNATURE::response res{};
ONS_MAKE_UPDATE_SIGNATURE::response res{};
std::string reason;
lns::mapping_type type;
ons::mapping_type type;
std::optional<uint8_t> hf_version = m_wallet->get_hard_fork_version();
if (!hf_version) throw wallet_rpc_error{error_code::HF_QUERY_FAILED, tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED};
if (!lns::validate_mapping_type(req.type, *hf_version, lns::lns_tx_type::update, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_LNS_TYPE, "Wrong lns type given=" + reason};
if (!ons::validate_mapping_type(req.type, *hf_version, ons::ons_tx_type::update, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_ONS_TYPE, "Wrong ons type given=" + reason};
lns::generic_signature signature;
if (!m_wallet->lns_make_update_mapping_signature(type,
ons::generic_signature signature;
if (!m_wallet->ons_make_update_mapping_signature(type,
req.name,
req.encrypted_value.size() ? &req.encrypted_value : nullptr,
req.owner.size() ? &req.owner : nullptr,
@ -3218,53 +3218,53 @@ namespace {
signature,
req.account_index,
&reason))
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create signature for LNS update transaction: " + reason};
throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Failed to create signature for ONS update transaction: " + reason};
res.signature = tools::type_to_hex(signature.ed25519);
return res;
}
LNS_HASH_NAME::response wallet_rpc_server::invoke(LNS_HASH_NAME::request&& req)
ONS_HASH_NAME::response wallet_rpc_server::invoke(ONS_HASH_NAME::request&& req)
{
require_open();
LNS_HASH_NAME::response res{};
ONS_HASH_NAME::response res{};
std::string reason;
lns::mapping_type type;
ons::mapping_type type;
std::optional<uint8_t> hf_version = m_wallet->get_hard_fork_version();
if (!hf_version) throw wallet_rpc_error{error_code::HF_QUERY_FAILED, tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED};
if (!lns::validate_mapping_type(req.type, *hf_version, lns::lns_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_LNS_TYPE, "Wrong lns type given=" + reason};
if (!ons::validate_mapping_type(req.type, *hf_version, ons::ons_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_ONS_TYPE, "Wrong ons type given=" + reason};
if (!lns::validate_lns_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::LNS_BAD_NAME, "Bad lns name given=" + reason};
if (!ons::validate_ons_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::ONS_BAD_NAME, "Bad ons name given=" + reason};
res.name = lns::name_to_base64_hash(req.name);
res.name = ons::name_to_base64_hash(req.name);
return res;
}
LNS_KNOWN_NAMES::response wallet_rpc_server::invoke(LNS_KNOWN_NAMES::request&& req)
ONS_KNOWN_NAMES::response wallet_rpc_server::invoke(ONS_KNOWN_NAMES::request&& req)
{
require_open();
LNS_KNOWN_NAMES::response res{};
ONS_KNOWN_NAMES::response res{};
std::vector<lns::mapping_type> entry_types;
auto cache = m_wallet->get_lns_cache();
std::vector<ons::mapping_type> entry_types;
auto cache = m_wallet->get_ons_cache();
res.known_names.reserve(cache.size());
entry_types.reserve(cache.size());
for (auto& [name, details] : m_wallet->get_lns_cache())
for (auto& [name, details] : m_wallet->get_ons_cache())
{
auto& entry = res.known_names.emplace_back();
auto& type = entry_types.emplace_back(details.type);
if (type > lns::mapping_type::lokinet && type <= lns::mapping_type::lokinet_10years)
type = lns::mapping_type::lokinet;
entry.type = lns::mapping_type_str(type);
if (type > ons::mapping_type::lokinet && type <= ons::mapping_type::lokinet_10years)
type = ons::mapping_type::lokinet;
entry.type = ons::mapping_type_str(type);
entry.hashed = details.hashed_name;
entry.name = details.name;
}
auto nettype = m_wallet->nettype();
rpc::LNS_NAMES_TO_OWNERS::request lookup_req{};
rpc::ONS_NAMES_TO_OWNERS::request lookup_req{};
lookup_req.include_expired = req.include_expired;
uint64_t curr_height = req.include_expired ? m_wallet->get_blockchain_current_height() : 0;
@ -3273,9 +3273,9 @@ namespace {
for (auto it = res.known_names.begin(); it != res.known_names.end(); )
{
const size_t num_entries = std::distance(it, res.known_names.end());
const auto end = num_entries < rpc::LNS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES
const auto end = num_entries < rpc::ONS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES
? res.known_names.end()
: it + rpc::LNS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES;
: it + rpc::ONS_NAMES_TO_OWNERS::MAX_REQUEST_ENTRIES;
lookup_req.entries.clear();
lookup_req.entries.reserve(std::distance(it, end));
for (auto it2 = it; it2 != end; it2++)
@ -3285,7 +3285,7 @@ namespace {
e.types.push_back(static_cast<uint16_t>(entry_types[std::distance(res.known_names.begin(), it2)]));
}
if (auto [success, records] = m_wallet->lns_names_to_owners(lookup_req); success)
if (auto [success, records] = m_wallet->ons_names_to_owners(lookup_req); success)
{
size_t type_offset = std::distance(res.known_names.begin(), it);
for (auto& rec : records)
@ -3308,14 +3308,14 @@ namespace {
if (req.decrypt && !res_e.encrypted_value.empty() && oxenmq::is_hex(res_e.encrypted_value))
{
lns::mapping_value value;
ons::mapping_value value;
const auto type = entry_types[type_offset + rec.entry_index];
std::string errmsg;
if (lns::mapping_value::validate_encrypted(type, oxenmq::from_hex(res_e.encrypted_value), &value, &errmsg)
if (ons::mapping_value::validate_encrypted(type, oxenmq::from_hex(res_e.encrypted_value), &value, &errmsg)
&& value.decrypt(res_e.name, type))
res_e.value = value.to_readable_value(nettype, type);
else
MWARNING("Failed to decrypt LNS value for " << res_e.name << (errmsg.empty() ? ""s : ": " + errmsg));
MWARNING("Failed to decrypt ONS value for " << res_e.name << (errmsg.empty() ? ""s : ": " + errmsg));
}
}
}
@ -3335,7 +3335,7 @@ namespace {
return res;
}
LNS_ADD_KNOWN_NAMES::response wallet_rpc_server::invoke(LNS_ADD_KNOWN_NAMES::request&& req)
ONS_ADD_KNOWN_NAMES::response wallet_rpc_server::invoke(ONS_ADD_KNOWN_NAMES::request&& req)
{
require_open();
@ -3345,24 +3345,24 @@ namespace {
std::string reason;
for (auto& rec : req.names)
{
lns::mapping_type type;
if (!lns::validate_mapping_type(rec.type, *hf_version, lns::lns_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_LNS_TYPE, "Invalid LNS type: " + reason};
ons::mapping_type type;
if (!ons::validate_mapping_type(rec.type, *hf_version, ons::ons_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_ONS_TYPE, "Invalid ONS type: " + reason};
auto name = tools::lowercase_ascii_string(rec.name);
if (!lns::validate_lns_name(type, name, &reason))
throw wallet_rpc_error{error_code::LNS_BAD_NAME, "Invalid LNS name '" + name + "': " + reason};
if (!ons::validate_ons_name(type, name, &reason))
throw wallet_rpc_error{error_code::ONS_BAD_NAME, "Invalid ONS name '" + name + "': " + reason};
m_wallet->set_lns_cache_record({type, name, lns::name_to_base64_hash(name)});
m_wallet->set_ons_cache_record({type, name, ons::name_to_base64_hash(name)});
}
return {};
}
LNS_DECRYPT_VALUE::response wallet_rpc_server::invoke(LNS_DECRYPT_VALUE::request&& req)
ONS_DECRYPT_VALUE::response wallet_rpc_server::invoke(ONS_DECRYPT_VALUE::request&& req)
{
require_open();
LNS_DECRYPT_VALUE::response res{};
ONS_DECRYPT_VALUE::response res{};
// ---------------------------------------------------------------------------------------------
//
@ -3370,13 +3370,13 @@ namespace {
//
// ---------------------------------------------------------------------------------------------
if (req.encrypted_value.size() % 2 != 0)
throw wallet_rpc_error{error_code::LNS_VALUE_LENGTH_NOT_EVEN, "Value length not divisible by 2, length=" + std::to_string(req.encrypted_value.size())};
throw wallet_rpc_error{error_code::ONS_VALUE_LENGTH_NOT_EVEN, "Value length not divisible by 2, length=" + std::to_string(req.encrypted_value.size())};
if (req.encrypted_value.size() >= (lns::mapping_value::BUFFER_SIZE * 2))
throw wallet_rpc_error{error_code::LNS_VALUE_TOO_LONG, "Value too long to decrypt=" + req.encrypted_value};
if (req.encrypted_value.size() >= (ons::mapping_value::BUFFER_SIZE * 2))
throw wallet_rpc_error{error_code::ONS_VALUE_TOO_LONG, "Value too long to decrypt=" + req.encrypted_value};
if (!oxenmq::is_hex(req.encrypted_value))
throw wallet_rpc_error{error_code::LNS_VALUE_NOT_HEX, "Value is not hex=" + req.encrypted_value};
throw wallet_rpc_error{error_code::ONS_VALUE_NOT_HEX, "Value is not hex=" + req.encrypted_value};
// ---------------------------------------------------------------------------------------------
//
@ -3384,16 +3384,16 @@ namespace {
//
// ---------------------------------------------------------------------------------------------
std::string reason;
lns::mapping_type type = {};
ons::mapping_type type = {};
std::optional<uint8_t> hf_version = m_wallet->get_hard_fork_version();
if (!hf_version) throw wallet_rpc_error{error_code::HF_QUERY_FAILED, tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED};
{
if (!lns::validate_mapping_type(req.type, *hf_version, lns::lns_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_LNS_TYPE, "Invalid LNS type: " + reason};
if (!ons::validate_mapping_type(req.type, *hf_version, ons::ons_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_ONS_TYPE, "Invalid ONS type: " + reason};
if (!lns::validate_lns_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::LNS_BAD_NAME, "Invalid LNS name '" + req.name + "': " + reason};
if (!ons::validate_ons_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::ONS_BAD_NAME, "Invalid ONS name '" + req.name + "': " + reason};
}
// ---------------------------------------------------------------------------------------------
@ -3401,43 +3401,43 @@ namespace {
// Decrypt value
//
// ---------------------------------------------------------------------------------------------
lns::mapping_value value = {};
ons::mapping_value value = {};
value.len = req.encrypted_value.size() / 2;
value.encrypted = true;
oxenmq::from_hex(req.encrypted_value.begin(), req.encrypted_value.end(), value.buffer.begin());
if (!value.decrypt(req.name, type))
throw wallet_rpc_error{error_code::LNS_VALUE_NOT_HEX, "Value decryption failure"};
throw wallet_rpc_error{error_code::ONS_VALUE_NOT_HEX, "Value decryption failure"};
res.value = value.to_readable_value(m_wallet->nettype(), type);
return res;
}
LNS_ENCRYPT_VALUE::response wallet_rpc_server::invoke(LNS_ENCRYPT_VALUE::request&& req)
ONS_ENCRYPT_VALUE::response wallet_rpc_server::invoke(ONS_ENCRYPT_VALUE::request&& req)
{
require_open();
if (req.value.size() > lns::mapping_value::BUFFER_SIZE)
throw wallet_rpc_error{error_code::LNS_VALUE_TOO_LONG, "LNS value '" + req.value + "' is too long"};
if (req.value.size() > ons::mapping_value::BUFFER_SIZE)
throw wallet_rpc_error{error_code::ONS_VALUE_TOO_LONG, "ONS value '" + req.value + "' is too long"};
std::string reason;
std::optional<uint8_t> hf_version = m_wallet->get_hard_fork_version();
if (!hf_version) throw wallet_rpc_error{error_code::HF_QUERY_FAILED, tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED};
lns::mapping_type type;
if (!lns::validate_mapping_type(req.type, *hf_version, lns::lns_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_LNS_TYPE, "Wrong lns type given=" + reason};
ons::mapping_type type;
if (!ons::validate_mapping_type(req.type, *hf_version, ons::ons_tx_type::lookup, &type, &reason))
throw wallet_rpc_error{error_code::WRONG_ONS_TYPE, "Wrong ons type given=" + reason};
if (!lns::validate_lns_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::LNS_BAD_NAME, "Invalid LNS name '" + req.name + "': " + reason};
if (!ons::validate_ons_name(type, req.name, &reason))
throw wallet_rpc_error{error_code::ONS_BAD_NAME, "Invalid ONS name '" + req.name + "': " + reason};
lns::mapping_value value;
if (!lns::mapping_value::validate(m_wallet->nettype(), type, req.value, &value, &reason))
throw wallet_rpc_error{error_code::LNS_BAD_VALUE, "Invalid LNS value '" + req.value + "': " + reason};
ons::mapping_value value;
if (!ons::mapping_value::validate(m_wallet->nettype(), type, req.value, &value, &reason))
throw wallet_rpc_error{error_code::ONS_BAD_VALUE, "Invalid ONS value '" + req.value + "': " + reason};
bool old_argon2 = type == lns::mapping_type::session && *hf_version < cryptonote::network_version_16_pulse;
bool old_argon2 = type == ons::mapping_type::session && *hf_version < cryptonote::network_version_16_pulse;
if (!value.encrypt(req.name, nullptr, old_argon2))
throw wallet_rpc_error{error_code::LNS_VALUE_ENCRYPT_FAILED, "Value encryption failure"};
throw wallet_rpc_error{error_code::ONS_VALUE_ENCRYPT_FAILED, "Value encryption failure"};
return {oxenmq::to_hex(value.to_view())};
}

View File

@ -157,15 +157,15 @@ namespace tools
wallet_rpc::REGISTER_SERVICE_NODE::response invoke(wallet_rpc::REGISTER_SERVICE_NODE::request&& req);
wallet_rpc::CAN_REQUEST_STAKE_UNLOCK::response invoke(wallet_rpc::CAN_REQUEST_STAKE_UNLOCK::request&& req);
wallet_rpc::REQUEST_STAKE_UNLOCK::response invoke(wallet_rpc::REQUEST_STAKE_UNLOCK::request&& req);
wallet_rpc::LNS_BUY_MAPPING::response invoke(wallet_rpc::LNS_BUY_MAPPING::request&& req);
wallet_rpc::LNS_RENEW_MAPPING::response invoke(wallet_rpc::LNS_RENEW_MAPPING::request&& req);
wallet_rpc::LNS_UPDATE_MAPPING::response invoke(wallet_rpc::LNS_UPDATE_MAPPING::request&& req);
wallet_rpc::LNS_MAKE_UPDATE_SIGNATURE::response invoke(wallet_rpc::LNS_MAKE_UPDATE_SIGNATURE::request&& req);
wallet_rpc::LNS_HASH_NAME::response invoke(wallet_rpc::LNS_HASH_NAME::request&& req);
wallet_rpc::LNS_KNOWN_NAMES::response invoke(wallet_rpc::LNS_KNOWN_NAMES::request&& req);
wallet_rpc::LNS_ADD_KNOWN_NAMES::response invoke(wallet_rpc::LNS_ADD_KNOWN_NAMES::request&& req);
wallet_rpc::LNS_DECRYPT_VALUE::response invoke(wallet_rpc::LNS_DECRYPT_VALUE::request&& req);
wallet_rpc::LNS_ENCRYPT_VALUE::response invoke(wallet_rpc::LNS_ENCRYPT_VALUE::request&& req);
wallet_rpc::ONS_BUY_MAPPING::response invoke(wallet_rpc::ONS_BUY_MAPPING::request&& req);
wallet_rpc::ONS_RENEW_MAPPING::response invoke(wallet_rpc::ONS_RENEW_MAPPING::request&& req);
wallet_rpc::ONS_UPDATE_MAPPING::response invoke(wallet_rpc::ONS_UPDATE_MAPPING::request&& req);
wallet_rpc::ONS_MAKE_UPDATE_SIGNATURE::response invoke(wallet_rpc::ONS_MAKE_UPDATE_SIGNATURE::request&& req);
wallet_rpc::ONS_HASH_NAME::response invoke(wallet_rpc::ONS_HASH_NAME::request&& req);
wallet_rpc::ONS_KNOWN_NAMES::response invoke(wallet_rpc::ONS_KNOWN_NAMES::request&& req);
wallet_rpc::ONS_ADD_KNOWN_NAMES::response invoke(wallet_rpc::ONS_ADD_KNOWN_NAMES::request&& req);
wallet_rpc::ONS_DECRYPT_VALUE::response invoke(wallet_rpc::ONS_DECRYPT_VALUE::request&& req);
wallet_rpc::ONS_ENCRYPT_VALUE::response invoke(wallet_rpc::ONS_ENCRYPT_VALUE::request&& req);
wallet_rpc::QUERY_KEY::response invoke(wallet_rpc::QUERY_KEY::request&& req);
private:

View File

@ -1117,7 +1117,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(SET_LOG_CATEGORIES::response)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_BUY_MAPPING::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_BUY_MAPPING::request)
KV_SERIALIZE (type);
KV_SERIALIZE (owner);
KV_SERIALIZE (backup_owner);
@ -1133,7 +1133,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_BUY_MAPPING::request)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_BUY_MAPPING::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_BUY_MAPPING::response)
KV_SERIALIZE(tx_hash)
KV_SERIALIZE(tx_key)
KV_SERIALIZE(amount)
@ -1145,7 +1145,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_BUY_MAPPING::response)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_RENEW_MAPPING::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_RENEW_MAPPING::request)
KV_SERIALIZE (type);
KV_SERIALIZE (name);
KV_SERIALIZE_OPT(account_index, (uint32_t)0);
@ -1158,7 +1158,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_RENEW_MAPPING::request)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_UPDATE_MAPPING::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_UPDATE_MAPPING::request)
KV_SERIALIZE (type);
KV_SERIALIZE (name);
KV_SERIALIZE (value);
@ -1175,7 +1175,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_UPDATE_MAPPING::request)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_UPDATE_MAPPING::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_UPDATE_MAPPING::response)
KV_SERIALIZE(tx_hash)
KV_SERIALIZE(tx_key)
KV_SERIALIZE(amount)
@ -1187,7 +1187,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_UPDATE_MAPPING::response)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_MAKE_UPDATE_SIGNATURE::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_MAKE_UPDATE_SIGNATURE::request)
KV_SERIALIZE(type);
KV_SERIALIZE(name);
KV_SERIALIZE(encrypted_value);
@ -1196,29 +1196,29 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_MAKE_UPDATE_SIGNATURE::request)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_MAKE_UPDATE_SIGNATURE::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_MAKE_UPDATE_SIGNATURE::response)
KV_SERIALIZE(signature)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_HASH_NAME::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_HASH_NAME::request)
KV_SERIALIZE(type);
KV_SERIALIZE(name);
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_HASH_NAME::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_HASH_NAME::response)
KV_SERIALIZE(name)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_KNOWN_NAMES::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_KNOWN_NAMES::request)
KV_SERIALIZE(decrypt)
KV_SERIALIZE(include_expired)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_KNOWN_NAMES::known_record)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_KNOWN_NAMES::known_record)
KV_SERIALIZE(type)
KV_SERIALIZE(hashed)
KV_SERIALIZE(name)
@ -1233,41 +1233,41 @@ KV_SERIALIZE_MAP_CODE_BEGIN(LNS_KNOWN_NAMES::known_record)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_KNOWN_NAMES::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_KNOWN_NAMES::response)
KV_SERIALIZE(known_names)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_ADD_KNOWN_NAMES::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_ADD_KNOWN_NAMES::request)
KV_SERIALIZE(names)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_ADD_KNOWN_NAMES::record)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_ADD_KNOWN_NAMES::record)
KV_SERIALIZE(type)
KV_SERIALIZE(name)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_DECRYPT_VALUE::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_DECRYPT_VALUE::request)
KV_SERIALIZE(name);
KV_SERIALIZE(type);
KV_SERIALIZE(encrypted_value);
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_DECRYPT_VALUE::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_DECRYPT_VALUE::response)
KV_SERIALIZE(value)
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_ENCRYPT_VALUE::request)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_ENCRYPT_VALUE::request)
KV_SERIALIZE(name);
KV_SERIALIZE(type);
KV_SERIALIZE(value);
KV_SERIALIZE_MAP_CODE_END()
KV_SERIALIZE_MAP_CODE_BEGIN(LNS_ENCRYPT_VALUE::response)
KV_SERIALIZE_MAP_CODE_BEGIN(ONS_ENCRYPT_VALUE::response)
KV_SERIALIZE(encrypted_value)
KV_SERIALIZE_MAP_CODE_END()

View File

@ -2179,22 +2179,22 @@ namespace tools::wallet_rpc {
};
OXEN_RPC_DOC_INTROSPECT
struct LNS_BUY_MAPPING : RESTRICTED
struct ONS_BUY_MAPPING : RESTRICTED
{
static constexpr auto names() { return NAMES("lns_buy_mapping"); }
static constexpr auto names() { return NAMES("ons_buy_mapping"); }
static constexpr const char *description =
R"(Buy a Loki Name System (LNS) mapping that maps a unique name to a Session ID or Lokinet address.
R"(Buy a Loki Name System (ONS) mapping that maps a unique name to a Session ID or Lokinet address.
Currently supports Session, Lokinet and Wallet registrations. Lokinet registrations can be for 1, 2, 5, or 10 years by specifying a type value of "lokinet", "lokinet_2y", "lokinet_5y", "lokinet_10y". Session registrations do not expire.
The owner of the LNS entry (by default, the purchasing wallet) will be permitted to submit LNS update transactions to the Loki blockchain (for example to update a Session pubkey or the target Lokinet address). You may change the primary owner or add a backup owner in the registration and can change them later with update transactions. Owner addresses can be either Loki wallets, or generic ed25519 pubkeys (for advanced uses).
The owner of the ONS entry (by default, the purchasing wallet) will be permitted to submit ONS update transactions to the Loki blockchain (for example to update a Session pubkey or the target Lokinet address). You may change the primary owner or add a backup owner in the registration and can change them later with update transactions. Owner addresses can be either Loki wallets, or generic ed25519 pubkeys (for advanced uses).
For Session, the recommended owner or backup owner is the ed25519 public key of the user's Session ID.
When specifying owners, either a wallet (sub)address or standard ed25519 public key is supported per mapping. Updating the value that a name maps to requires one of the owners to sign the update transaction. For wallets, this is signed using the (sub)address's spend key.
For more information on updating and signing see the LNS_UPDATE_MAPPING documentation.)";
For more information on updating and signing see the ONS_UPDATE_MAPPING documentation.)";
struct request
{
@ -2231,10 +2231,10 @@ For more information on updating and signing see the LNS_UPDATE_MAPPING document
};
OXEN_RPC_DOC_INTROSPECT
// Renew an active lokinet LNS registration
struct LNS_RENEW_MAPPING : RESTRICTED
// Renew an active lokinet ONS registration
struct ONS_RENEW_MAPPING : RESTRICTED
{
static constexpr auto names() { return NAMES("lns_renew_mapping"); }
static constexpr auto names() { return NAMES("ons_renew_mapping"); }
static constexpr const char *description =
R"(Renews a Loki Name System lokinet mapping by adding to the existing expiry time.
@ -2257,14 +2257,14 @@ The renewal can be for 1, 2, 5, or 10 years by specifying a `type` value of "lok
KV_MAP_SERIALIZABLE
};
using response = LNS_BUY_MAPPING::response;
using response = ONS_BUY_MAPPING::response;
};
OXEN_RPC_DOC_INTROSPECT
// Update the underlying value in the name->value mapping via Loki Name Service.
struct LNS_UPDATE_MAPPING : RESTRICTED
struct ONS_UPDATE_MAPPING : RESTRICTED
{
static constexpr auto names() { return NAMES("lns_update_mapping"); }
static constexpr auto names() { return NAMES("ons_update_mapping"); }
static constexpr const char *description =
R"(Update a Loki Name System mapping to refer to a new address or owner.
@ -2273,7 +2273,7 @@ At least one field (value, owner, or backup owner) must be specified in the upda
The existing owner (wallet address or ed25519 public key) of the mapping must be used to sign the update. If no signature is provided then the wallet's active address (or subaddress) will be used to sign the update.
If signing is performed externally then you must first encrypt the `value` (if being updated), then sign a BLAKE2b hash of {encryptedvalue || owner || backup_owner || txid} (where txid is the most recent LNS update or registration transaction of this mapping; each of encrypted/owner/backup are empty strings if not being updated). For a wallet owner this is signed using the owning wallet's spend key; for a Ed25519 key this is a standard Ed25519 signature.)";
If signing is performed externally then you must first encrypt the `value` (if being updated), then sign a BLAKE2b hash of {encryptedvalue || owner || backup_owner || txid} (where txid is the most recent ONS update or registration transaction of this mapping; each of encrypted/owner/backup are empty strings if not being updated). For a wallet owner this is signed using the owning wallet's spend key; for a Ed25519 key this is a standard Ed25519 signature.)";
struct request
{
@ -2312,14 +2312,14 @@ If signing is performed externally then you must first encrypt the `value` (if b
};
OXEN_RPC_DOC_INTROSPECT
struct LNS_MAKE_UPDATE_SIGNATURE : RESTRICTED
struct ONS_MAKE_UPDATE_SIGNATURE : RESTRICTED
{
static constexpr auto names() { return NAMES("lns_make_update_mapping_signature"); }
static constexpr auto names() { return NAMES("ons_make_update_mapping_signature"); }
static constexpr const char *description =
R"(Generate the signature necessary for updating the requested record using the wallet's active [sub]address's spend key. The signature is only valid if the queried wallet is one of the owners of the LNS record.
R"(Generate the signature necessary for updating the requested record using the wallet's active [sub]address's spend key. The signature is only valid if the queried wallet is one of the owners of the ONS record.
This command is only required if the open wallet is one of the owners of a LNS record but wants the update transaction to occur via another non-owning wallet. By default, if no signature is specified to the update transaction, the open wallet is assumed the owner and it's active [sub]address's spend key will automatically be used.)";
This command is only required if the open wallet is one of the owners of a ONS record but wants the update transaction to occur via another non-owning wallet. By default, if no signature is specified to the update transaction, the open wallet is assumed the owner and it's active [sub]address's spend key will automatically be used.)";
struct request
{
@ -2335,17 +2335,17 @@ This command is only required if the open wallet is one of the owners of a LNS r
struct response
{
std::string signature; // A signature valid for using in LNS to update an underlying mapping.
std::string signature; // A signature valid for using in ONS to update an underlying mapping.
KV_MAP_SERIALIZABLE
};
};
OXEN_RPC_DOC_INTROSPECT
// Takes a LNS name, upon validating it, generates the hash and returns the base64 representation of the hash suitable for use in the daemon LNS name queries.
struct LNS_HASH_NAME : RPC_COMMAND
// Takes a ONS name, upon validating it, generates the hash and returns the base64 representation of the hash suitable for use in the daemon ONS name queries.
struct ONS_HASH_NAME : RPC_COMMAND
{
static constexpr auto names() { return NAMES("lns_hash_name"); }
static constexpr auto names() { return NAMES("ons_hash_name"); }
struct request
{
@ -2364,12 +2364,12 @@ This command is only required if the open wallet is one of the owners of a LNS r
};
OXEN_RPC_DOC_INTROSPECT
// Returns a list of known, plain-text LNS names along with record details for names that this
// wallet knows about. This can optionally decrypt the LNS value as well, or else just return the
// Returns a list of known, plain-text ONS names along with record details for names that this
// wallet knows about. This can optionally decrypt the ONS value as well, or else just return the
// encrypted value.
struct LNS_KNOWN_NAMES : RPC_COMMAND
struct ONS_KNOWN_NAMES : RPC_COMMAND
{
static constexpr auto names() { return NAMES("lns_known_names"); }
static constexpr auto names() { return NAMES("ons_known_names"); }
struct known_record
{
@ -2403,15 +2403,15 @@ This command is only required if the open wallet is one of the owners of a LNS r
};
OXEN_RPC_DOC_INTROSPECT
// Adds one or more names to the persistent LNS wallet cache of known names (i.e. for names that
// Adds one or more names to the persistent ONS wallet cache of known names (i.e. for names that
// are owned by this wallet that aren't currently in the cache).
struct LNS_ADD_KNOWN_NAMES : RPC_COMMAND
struct ONS_ADD_KNOWN_NAMES : RPC_COMMAND
{
static constexpr auto names() { return NAMES("lns_add_known_names"); }
static constexpr auto names() { return NAMES("ons_add_known_names"); }
struct record
{
std::string type; // The LNS type (mandatory); currently support values are: "session", "lokinet"
std::string type; // The ONS type (mandatory); currently support values are: "session", "lokinet"
std::string name; // The (unhashed) name of the record
KV_MAP_SERIALIZABLE
@ -2428,14 +2428,14 @@ This command is only required if the open wallet is one of the owners of a LNS r
};
OXEN_RPC_DOC_INTROSPECT
// Takes a LNS encrypted value and encrypts the mapping value using the LNS name.
struct LNS_ENCRYPT_VALUE : RPC_COMMAND
// Takes a ONS encrypted value and encrypts the mapping value using the ONS name.
struct ONS_ENCRYPT_VALUE : RPC_COMMAND
{
static constexpr auto names() { return NAMES("lns_encrypt_value"); }
static constexpr auto names() { return NAMES("ons_encrypt_value"); }
struct request
{
std::string name; // The LNS name with which to encrypt the value.
std::string name; // The ONS name with which to encrypt the value.
std::string type; // The mapping type: "session" or "lokinet".
std::string value; // The value to be encrypted.
@ -2451,14 +2451,14 @@ This command is only required if the open wallet is one of the owners of a LNS r
};
OXEN_RPC_DOC_INTROSPECT
// Takes a LNS encrypted value and decrypts the mapping value using the LNS name.
struct LNS_DECRYPT_VALUE : RPC_COMMAND
// Takes a ONS encrypted value and decrypts the mapping value using the ONS name.
struct ONS_DECRYPT_VALUE : RPC_COMMAND
{
static constexpr auto names() { return NAMES("lns_decrypt_value"); }
static constexpr auto names() { return NAMES("ons_decrypt_value"); }
struct request
{
std::string name; // The LNS name of the given encrypted value.
std::string name; // The ONS name of the given encrypted value.
std::string type; // The mapping type: "session" or "lokinet".
std::string encrypted_value; // The encrypted value represented in hex.
@ -2567,15 +2567,15 @@ This command is only required if the open wallet is one of the owners of a LNS r
SET_DAEMON,
SET_LOG_LEVEL,
SET_LOG_CATEGORIES,
LNS_BUY_MAPPING,
LNS_UPDATE_MAPPING,
LNS_RENEW_MAPPING,
LNS_MAKE_UPDATE_SIGNATURE,
LNS_HASH_NAME,
LNS_KNOWN_NAMES,
LNS_ADD_KNOWN_NAMES,
LNS_DECRYPT_VALUE,
LNS_ENCRYPT_VALUE
ONS_BUY_MAPPING,
ONS_UPDATE_MAPPING,
ONS_RENEW_MAPPING,
ONS_MAKE_UPDATE_SIGNATURE,
ONS_HASH_NAME,
ONS_KNOWN_NAMES,
ONS_ADD_KNOWN_NAMES,
ONS_DECRYPT_VALUE,
ONS_ENCRYPT_VALUE
>;
}

View File

@ -82,13 +82,13 @@ constexpr int16_t ATTRIBUTE_NOT_FOUND = -45;
// Loki:
constexpr int16_t BLINK_FAILED = -1000;
constexpr int16_t HF_QUERY_FAILED = -1001;
constexpr int16_t WRONG_LNS_TYPE = -1002;
constexpr int16_t LNS_BAD_NAME = -1003;
constexpr int16_t LNS_VALUE_TOO_LONG = -1004;
constexpr int16_t LNS_VALUE_NOT_HEX = -1005;
constexpr int16_t LNS_VALUE_LENGTH_NOT_EVEN = -1006;
constexpr int16_t LNS_VALUE_DECRYPT_FAILED = -1007;
constexpr int16_t LNS_VALUE_ENCRYPT_FAILED = -1008;
constexpr int16_t LNS_BAD_VALUE = -1009;
constexpr int16_t WRONG_ONS_TYPE = -1002;
constexpr int16_t ONS_BAD_NAME = -1003;
constexpr int16_t ONS_VALUE_TOO_LONG = -1004;
constexpr int16_t ONS_VALUE_NOT_HEX = -1005;
constexpr int16_t ONS_VALUE_LENGTH_NOT_EVEN = -1006;
constexpr int16_t ONS_VALUE_DECRYPT_FAILED = -1007;
constexpr int16_t ONS_VALUE_ENCRYPT_FAILED = -1008;
constexpr int16_t ONS_BAD_VALUE = -1009;
}

View File

@ -122,7 +122,7 @@ private:
get_test_options(): hard_forks{{std::make_pair(cryptonote::network_version_7, (uint64_t)0), std::make_pair((uint8_t)hf_version, (uint64_t)LONG_TERM_BLOCK_WEIGHT_WINDOW)}} {} \
} opts; \
cryptonote::Blockchain *bc = &bc_objects.m_blockchain; \
bool r = bc->init(new TestDB(), nullptr /*lns_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0); \
bool r = bc->init(new TestDB(), nullptr /*ons_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0); \
if (!r) \
{ \
fprintf(stderr, "Failed to init blockchain\n"); \

View File

@ -351,7 +351,7 @@ bool gen_bp_tx_valid_1_old::generate(std::vector<test_event_entry>& events) cons
bool gen_bp_tx_invalid_1_new::generate(std::vector<test_event_entry>& events) const
{
// After HF_VERSION_MIN_2_OUTPUTS we don't allow just one output (except in LNS transactions, but
// After HF_VERSION_MIN_2_OUTPUTS we don't allow just one output (except in ONS transactions, but
// that is tested elsewhere).
const uint64_t amounts_paid[] = {10000, (uint64_t)-1};
const size_t bp_sizes[] = {1, (size_t)-1};

View File

@ -167,7 +167,7 @@ oxen_chain_generator::oxen_chain_generator(std::vector<test_event_entry> &events
: events_(events)
, hard_forks_(hard_forks)
{
bool init = lns_db_->init(nullptr, cryptonote::FAKECHAIN, lns::init_oxen_name_system("", false /*read_only*/));
bool init = ons_db_->init(nullptr, cryptonote::FAKECHAIN, ons::init_oxen_name_system("", false /*read_only*/));
assert(init);
first_miner_.generate();
@ -235,9 +235,9 @@ oxen_blockchain_entry &oxen_chain_generator::add_block(oxen_blockchain_entry con
db_.tx_table[tx_hash] = tx;
}
if (can_be_added_to_blockchain && entry.block.major_version >= cryptonote::network_version_15_lns)
if (can_be_added_to_blockchain && entry.block.major_version >= cryptonote::network_version_15_ons)
{
lns_db_->add_block(entry.block, entry.txs);
ons_db_->add_block(entry.block, entry.txs);
}
// TODO(oxen): State history culling and alt states
@ -330,11 +330,11 @@ void oxen_chain_generator::add_tx(cryptonote::transaction const &tx, bool can_be
cryptonote::transaction
oxen_chain_generator::create_and_add_oxen_name_system_tx(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
lns::mapping_value const &value,
lns::generic_owner const *owner,
lns::generic_owner const *backup_owner,
ons::mapping_value const &value,
ons::generic_owner const *owner,
ons::generic_owner const *backup_owner,
bool kept_by_block)
{
cryptonote::transaction t = create_oxen_name_system_tx(src, hf_version, type, name, value, owner, backup_owner);
@ -345,12 +345,12 @@ oxen_chain_generator::create_and_add_oxen_name_system_tx(cryptonote::account_bas
cryptonote::transaction
oxen_chain_generator::create_and_add_oxen_name_system_tx_update(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
lns::mapping_value const *value,
lns::generic_owner const *owner,
lns::generic_owner const *backup_owner,
lns::generic_signature *signature,
ons::mapping_value const *value,
ons::generic_owner const *owner,
ons::generic_owner const *backup_owner,
ons::generic_signature *signature,
bool kept_by_block)
{
cryptonote::transaction t = create_oxen_name_system_tx_update(src, hf_version, type, name, value, owner, backup_owner, signature);
@ -361,7 +361,7 @@ oxen_chain_generator::create_and_add_oxen_name_system_tx_update(cryptonote::acco
cryptonote::transaction
oxen_chain_generator::create_and_add_oxen_name_system_tx_renew(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
bool kept_by_block)
{
@ -602,37 +602,37 @@ cryptonote::checkpoint_t oxen_chain_generator::create_service_node_checkpoint(ui
cryptonote::transaction oxen_chain_generator::create_oxen_name_system_tx(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
lns::mapping_value const &value,
lns::generic_owner const *owner,
lns::generic_owner const *backup_owner,
ons::mapping_value const &value,
ons::generic_owner const *owner,
ons::generic_owner const *backup_owner,
std::optional<uint64_t> burn_override) const
{
lns::generic_owner generic_owner = {};
ons::generic_owner generic_owner = {};
if (owner)
{
generic_owner = *owner;
}
else
{
generic_owner = lns::make_monero_owner(src.get_keys().m_account_address, false /*subaddress*/);
generic_owner = ons::make_monero_owner(src.get_keys().m_account_address, false /*subaddress*/);
}
cryptonote::block const &head = top().block;
uint64_t new_height = get_block_height(top().block) + 1;
uint8_t new_hf_version = get_hf_version_at(new_height);
uint64_t burn = burn_override.value_or(lns::burn_needed(new_hf_version, type));
uint64_t burn = burn_override.value_or(ons::burn_needed(new_hf_version, type));
auto lcname = tools::lowercase_ascii_string(name);
crypto::hash name_hash = lns::name_to_hash(lcname);
std::string name_base64_hash = lns::name_to_base64_hash(lcname);
crypto::hash name_hash = ons::name_to_hash(lcname);
std::string name_base64_hash = ons::name_to_base64_hash(lcname);
crypto::hash prev_txid = crypto::null_hash;
if (lns::mapping_record mapping = lns_db_->get_mapping(type, name_base64_hash, new_height))
if (ons::mapping_record mapping = ons_db_->get_mapping(type, name_base64_hash, new_height))
prev_txid = mapping.txid;
lns::mapping_value encrypted_value = value;
bool encrypted = encrypted_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_15_lns);
ons::mapping_value encrypted_value = value;
bool encrypted = encrypted_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_15_ons);
assert(encrypted);
std::vector<uint8_t> extra;
@ -651,46 +651,46 @@ cryptonote::transaction oxen_chain_generator::create_oxen_name_system_tx(crypton
cryptonote::transaction oxen_chain_generator::create_oxen_name_system_tx_update(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
lns::mapping_value const *value,
lns::generic_owner const *owner,
lns::generic_owner const *backup_owner,
lns::generic_signature *signature,
ons::mapping_value const *value,
ons::generic_owner const *owner,
ons::generic_owner const *backup_owner,
ons::generic_signature *signature,
bool use_asserts) const
{
auto lcname = tools::lowercase_ascii_string(name);
crypto::hash name_hash = lns::name_to_hash(lcname);
crypto::hash name_hash = ons::name_to_hash(lcname);
crypto::hash prev_txid = {};
{
std::string name_base64_hash = lns::name_to_base64_hash(lcname);
lns::mapping_record mapping = lns_db_->get_mapping(type, name_base64_hash);
std::string name_base64_hash = ons::name_to_base64_hash(lcname);
ons::mapping_record mapping = ons_db_->get_mapping(type, name_base64_hash);
if (use_asserts) assert(mapping);
prev_txid = mapping.txid;
}
lns::mapping_value encrypted_value = {};
ons::mapping_value encrypted_value = {};
if (value)
{
encrypted_value = *value;
if (!encrypted_value.encrypted)
{
assert(!signature); // Can't specify a signature with an unencrypted value because encrypting generates a new nonce and would invalidate it
bool encrypted = encrypted_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_15_lns);
bool encrypted = encrypted_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_15_ons);
if (use_asserts) assert(encrypted);
}
}
lns::generic_signature signature_ = {};
ons::generic_signature signature_ = {};
if (!signature)
{
signature = &signature_;
auto data = lns::tx_extra_signature(encrypted_value.to_view(), owner, backup_owner, prev_txid);
auto data = ons::tx_extra_signature(encrypted_value.to_view(), owner, backup_owner, prev_txid);
crypto::hash hash{};
if (!data.empty())
crypto_generichash(reinterpret_cast<unsigned char*>(hash.data), sizeof(hash), reinterpret_cast<const unsigned char*>(data.data()), data.size(), nullptr, 0);
generate_signature(hash, src.get_keys().m_account_address.m_spend_public_key, src.get_keys().m_spend_secret_key, signature->monero);
signature->type = lns::generic_owner_sig_type::monero;
signature->type = ons::generic_owner_sig_type::monero;
}
std::vector<uint8_t> extra;
@ -712,10 +712,10 @@ cryptonote::transaction oxen_chain_generator::create_oxen_name_system_tx_update(
}
cryptonote::transaction
oxen_chain_generator::create_oxen_name_system_tx_update_w_extra(cryptonote::account_base const &src, uint8_t hf_version, cryptonote::tx_extra_oxen_name_system const &lns_extra) const
oxen_chain_generator::create_oxen_name_system_tx_update_w_extra(cryptonote::account_base const &src, uint8_t hf_version, cryptonote::tx_extra_oxen_name_system const &ons_extra) const
{
std::vector<uint8_t> extra;
cryptonote::add_oxen_name_system_to_tx_extra(extra, lns_extra);
cryptonote::add_oxen_name_system_to_tx_extra(extra, ons_extra);
cryptonote::block const &head = top().block;
uint64_t new_height = get_block_height(top().block) + 1;
@ -732,21 +732,21 @@ oxen_chain_generator::create_oxen_name_system_tx_update_w_extra(cryptonote::acco
cryptonote::transaction oxen_chain_generator::create_oxen_name_system_tx_renew(cryptonote::account_base const &src,
uint8_t hf_version,
lns::mapping_type type,
ons::mapping_type type,
std::string const &name,
std::optional<uint64_t> burn_override) const
{
auto lcname = tools::lowercase_ascii_string(name);
crypto::hash name_hash = lns::name_to_hash(lcname);
crypto::hash name_hash = ons::name_to_hash(lcname);
crypto::hash prev_txid = {};
{
std::string name_base64_hash = lns::name_to_base64_hash(lcname);
lns::mapping_record mapping = lns_db_->get_mapping(type, name_base64_hash);
std::string name_base64_hash = ons::name_to_base64_hash(lcname);
ons::mapping_record mapping = ons_db_->get_mapping(type, name_base64_hash);
prev_txid = mapping.txid;
}
uint8_t new_hf_version = get_hf_version_at(get_block_height(top().block) + 1);
uint64_t burn = burn_override.value_or(lns::burn_needed(new_hf_version, type));
uint64_t burn = burn_override.value_or(ons::burn_needed(new_hf_version, type));
std::vector<uint8_t> extra;
cryptonote::tx_extra_oxen_name_system data = cryptonote::tx_extra_oxen_name_system::make_renew(type, name_hash, prev_txid);
@ -960,7 +960,7 @@ bool oxen_chain_generator::block_begin(oxen_blockchain_entry &entry, oxen_create
static_assert(cryptonote::network_version_count == cryptonote::network_version_18 + 1,
"The code below needs to be updated to support higher hard fork versions");
if (blk.major_version == cryptonote::network_version_15_lns)
if (blk.major_version == cryptonote::network_version_15_ons)
miner_tx_context.batched_governance = FOUNDATION_REWARD_HF15 * num_blocks;
else if (blk.major_version == cryptonote::network_version_16_pulse)
miner_tx_context.batched_governance = (FOUNDATION_REWARD_HF15 + CHAINFLIP_LIQUIDITY_HF16) * num_blocks;
@ -1226,7 +1226,7 @@ static void manual_calc_batched_governance(const test_generator &generator,
uint64_t num_blocks = cryptonote::get_config(cryptonote::FAKECHAIN).GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS;
uint64_t start_height = height - num_blocks;
if (hard_fork_version >= cryptonote::network_version_15_lns)
if (hard_fork_version >= cryptonote::network_version_15_ons)
{
miner_tx_context.batched_governance = num_blocks * cryptonote::governance_reward_formula(0, hard_fork_version);
return;
@ -1472,7 +1472,7 @@ cryptonote::transaction make_registration_tx(std::vector<test_event_entry>& even
add_service_node_contributor_to_tx_extra(extra, contributors.at(0));
cryptonote::txtype tx_type = cryptonote::txtype::standard;
if (hf_version >= cryptonote::network_version_15_lns) tx_type = cryptonote::txtype::stake; // NOTE: txtype stake was not introduced until HF14
if (hf_version >= cryptonote::network_version_15_ons) tx_type = cryptonote::txtype::stake; // NOTE: txtype stake was not introduced until HF14
oxen_tx_builder(events, tx, head, account, account.get_keys().m_account_address, amount, hf_version).with_tx_type(tx_type).with_extra(extra).with_unlock_time(unlock_time).build();
events.push_back(tx);
return tx;

View File

@ -1358,7 +1358,7 @@ public:
uint64_t change_amount;
constexpr size_t nmix = 9;
if (m_tx_params.tx_type == cryptonote::txtype::oxen_name_system) // LNS txes only have change
if (m_tx_params.tx_type == cryptonote::txtype::oxen_name_system) // ONS txes only have change
{
fill_tx_sources_and_multi_destinations(
m_events, m_head, m_from, m_to, nullptr /*amounts*/, 0 /*num_amounts*/, m_fee, nmix, sources, destinations, true /*add change*/, &change_amount);
@ -1456,7 +1456,7 @@ struct oxen_chain_generator
mutable std::unordered_map<crypto::public_key, crypto::secret_key> service_node_keys_;
service_nodes::service_node_list::state_set state_history_;
uint64_t last_cull_height_ = 0;
std::shared_ptr<lns::name_system_db> lns_db_ = std::make_shared<lns::name_system_db>();
std::shared_ptr<ons::name_system_db> ons_db_ = std::make_shared<ons::name_system_db>();
oxen_chain_generator_db db_;
uint8_t hf_version_ = cryptonote::network_version_7;
std::vector<test_event_entry>& events_;
@ -1494,9 +1494,9 @@ struct oxen_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_oxen_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, lns::mapping_value const &value, lns::generic_owner const *owner = nullptr, lns::generic_owner const *backup_owner = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_oxen_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, lns::mapping_value const *value, lns::generic_owner const *owner = nullptr, lns::generic_owner const *backup_owner = nullptr, lns::generic_signature *signature = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_oxen_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, bool kept_by_block = false);
cryptonote::transaction create_and_add_oxen_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, std::string const &name, ons::mapping_value const &value, ons::generic_owner const *owner = nullptr, ons::generic_owner const *backup_owner = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_oxen_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, std::string const &name, ons::mapping_value const *value, ons::generic_owner const *owner = nullptr, ons::generic_owner const *backup_owner = nullptr, ons::generic_signature *signature = nullptr, bool kept_by_block = false);
cryptonote::transaction create_and_add_oxen_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, 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, uint16_t reasons_all, uint16_t reasons_any, 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{hw::get_device("default")}, bool kept_by_block = false);
@ -1518,11 +1518,11 @@ struct oxen_chain_generator
cryptonote::checkpoint_t create_service_node_checkpoint(uint64_t block_height, size_t num_votes) const;
// 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_oxen_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, lns::mapping_value const &value, lns::generic_owner const *owner = nullptr, lns::generic_owner const *backup_owner = nullptr, std::optional<uint64_t> burn_override = std::nullopt) const;
cryptonote::transaction create_oxen_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, lns::mapping_value const *value, lns::generic_owner const *owner = nullptr, lns::generic_owner const *backup_owner = nullptr, lns::generic_signature *signature = nullptr, bool use_asserts = false) const;
cryptonote::transaction create_oxen_name_system_tx_update_w_extra(cryptonote::account_base const &src, uint8_t hf_version, cryptonote::tx_extra_oxen_name_system const &lns_extra) const;
cryptonote::transaction create_oxen_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, lns::mapping_type type, std::string const &name, std::optional<uint64_t> burn_override = std::nullopt) const;
static const uint64_t ONS_AUTO_BURN = static_cast<uint64_t>(-1);
cryptonote::transaction create_oxen_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, std::string const &name, ons::mapping_value const &value, ons::generic_owner const *owner = nullptr, ons::generic_owner const *backup_owner = nullptr, std::optional<uint64_t> burn_override = std::nullopt) const;
cryptonote::transaction create_oxen_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, std::string const &name, ons::mapping_value const *value, ons::generic_owner const *owner = nullptr, ons::generic_owner const *backup_owner = nullptr, ons::generic_signature *signature = nullptr, bool use_asserts = false) const;
cryptonote::transaction create_oxen_name_system_tx_update_w_extra(cryptonote::account_base const &src, uint8_t hf_version, cryptonote::tx_extra_oxen_name_system const &ons_extra) const;
cryptonote::transaction create_oxen_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, ons::mapping_type type, std::string const &name, std::optional<uint64_t> burn_override = std::nullopt) const;
oxen_blockchain_entry create_genesis_block(const cryptonote::account_base &miner, uint64_t timestamp);
oxen_blockchain_entry create_next_block(const std::vector<cryptonote::transaction>& txs = {}, cryptonote::checkpoint_t const *checkpoint = nullptr);

View File

@ -139,7 +139,7 @@ int main(int argc, char* argv[])
GENERATE_AND_PLAY(oxen_name_system_get_mappings_by_owner);
GENERATE_AND_PLAY(oxen_name_system_get_mappings_by_owners);
GENERATE_AND_PLAY(oxen_name_system_get_mappings);
GENERATE_AND_PLAY(oxen_name_system_handles_duplicate_in_lns_db);
GENERATE_AND_PLAY(oxen_name_system_handles_duplicate_in_ons_db);
GENERATE_AND_PLAY(oxen_name_system_handles_duplicate_in_tx_pool);
GENERATE_AND_PLAY(oxen_name_system_invalid_tx_extra_params);
GENERATE_AND_PLAY(oxen_name_system_large_reorg);

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ struct oxen_name_system_expiration
struct oxen_name_system_get_mappings_by_owner : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_get_mappings : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_get_mappings_by_owners : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_handles_duplicate_in_lns_db : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_handles_duplicate_in_ons_db : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_handles_duplicate_in_tx_pool : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_invalid_tx_extra_params : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };
struct oxen_name_system_large_reorg : public test_chain_unit_base { bool generate(std::vector<test_event_entry>& events); };

View File

@ -119,7 +119,7 @@ static uint32_t lcg()
get_test_options(): hard_forks{{std::make_pair(cryptonote::network_version_7, (uint64_t)0), std::make_pair((uint8_t)hf_version, (uint64_t)1)}} {} \
} opts; \
cryptonote::Blockchain *bc = &bc_objects.m_blockchain; \
bool r = bc->init(new ::TestDB(), nullptr /*lns_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0); \
bool r = bc->init(new ::TestDB(), nullptr /*ons_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0); \
ASSERT_TRUE(r)
#define PREFIX(hf_version) PREFIX_WINDOW(hf_version, TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW)

View File

@ -90,7 +90,7 @@ bool get_output_distribution(uint64_t amount, uint64_t from, uint64_t to, uint64
get_test_options():hard_forks{{std::make_pair((uint8_t)1, (uint64_t)0)}}{}
} opts;
cryptonote::Blockchain *blockchain = &bc.m_blockchain;
bool r = blockchain->init(new TestDB(test_distribution_size), nullptr /*lns_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0, NULL);
bool r = blockchain->init(new TestDB(test_distribution_size), nullptr /*ons_db*/, cryptonote::FAKECHAIN, true, &opts.test_options, 0, NULL);
return r && blockchain->get_output_distribution(amount, from, to, start_height, distribution, base);
}

View File

@ -68,31 +68,31 @@ TEST(oxen_name_system, name_tests)
{"\"hello", false},
};
for (uint16_t type16 = 0; type16 < static_cast<uint16_t>(lns::mapping_type::_count); type16++)
for (uint16_t type16 = 0; type16 < static_cast<uint16_t>(ons::mapping_type::_count); type16++)
{
auto type = static_cast<lns::mapping_type>(type16);
if (type == lns::mapping_type::wallet) continue; // Not yet supported
name_test const *names = lns::is_lokinet_type(type) ? lokinet_names : session_wallet_names;
size_t names_count = lns::is_lokinet_type(type) ? oxen::char_count(lokinet_names) : oxen::char_count(session_wallet_names);
auto type = static_cast<ons::mapping_type>(type16);
if (type == ons::mapping_type::wallet) continue; // Not yet supported
name_test const *names = ons::is_lokinet_type(type) ? lokinet_names : session_wallet_names;
size_t names_count = ons::is_lokinet_type(type) ? oxen::char_count(lokinet_names) : oxen::char_count(session_wallet_names);
for (size_t i = 0; i < names_count; i++)
{
name_test const &entry = names[i];
ASSERT_EQ(lns::validate_lns_name(type, entry.name), entry.allowed) << "Values were {type=" << type << ", name=\"" << entry.name << "\"}";
ASSERT_EQ(ons::validate_ons_name(type, entry.name), entry.allowed) << "Values were {type=" << type << ", name=\"" << entry.name << "\"}";
}
}
}
TEST(oxen_name_system, value_encrypt_and_decrypt)
{
std::string name = "my lns name";
lns::mapping_value value = {};
std::string name = "my ons name";
ons::mapping_value value = {};
value.len = 32;
memset(&value.buffer[0], 'a', value.len);
// The type here is not hugely important for decryption except that lokinet (as opposed to
// session) doesn't fall back to argon2 decryption if decryption fails.
constexpr auto type = lns::mapping_type::lokinet;
constexpr auto type = ons::mapping_type::lokinet;
// Encryption and Decryption success
{
@ -129,7 +129,7 @@ TEST(oxen_name_system, value_encrypt_and_decrypt)
TEST(oxen_name_system, value_encrypt_and_decrypt_heavy)
{
std::string name = "abcdefg";
lns::mapping_value value = {};
ons::mapping_value value = {};
value.len = 33;
memset(&value.buffer[0], 'a', value.len);
@ -140,8 +140,8 @@ TEST(oxen_name_system, value_encrypt_and_decrypt_heavy)
ASSERT_TRUE(mval.encrypt(name, nullptr, true));
ASSERT_TRUE(mval_new.encrypt(name, nullptr, false));
ASSERT_EQ(mval.len + 24, mval_new.len); // New value appends a 24-byte nonce
ASSERT_TRUE(mval.decrypt(name, lns::mapping_type::session));
ASSERT_TRUE(mval_new.decrypt(name, lns::mapping_type::session));
ASSERT_TRUE(mval.decrypt(name, ons::mapping_type::session));
ASSERT_TRUE(mval_new.decrypt(name, ons::mapping_type::session));
ASSERT_TRUE(mval == value);
ASSERT_TRUE(mval_new == value);
}

View File

@ -101,7 +101,7 @@ TEST(service_nodes, staking_requirement)
// Just before drop to 15k
{
uint64_t height = 641110;
uint64_t mainnet_requirement = service_nodes::get_staking_requirement(cryptonote::MAINNET, height, cryptonote::network_version_15_lns);
uint64_t mainnet_requirement = service_nodes::get_staking_requirement(cryptonote::MAINNET, height, cryptonote::network_version_15_ons);
uint64_t mainnet_expected = 16396'730529714;
ASSERT_EQ(mainnet_requirement, mainnet_expected);