diff --git a/CMakeLists.txt b/CMakeLists.txt index ad3405e262f..1ca507de6fb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,9 +51,9 @@ message(STATUS "CMake version ${CMAKE_VERSION}") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)") project(beldex - VERSION 5.0.2 + VERSION 6.0.0 LANGUAGES CXX C) -set(BELDEX_RELEASE_CODENAME "Bern") +set(BELDEX_RELEASE_CODENAME "Hermes") # String value to append to the full version string; this is intended to easily identify whether a # binary was build from the release or development branches. This should be permanently set to an @@ -427,7 +427,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) if (APPLE AND NOT IOS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -fvisibility=default") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -fvisibility=default") endif() add_definition_if_library_exists(c memset_s "string.h" HAVE_MEMSET_S) diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 244b4c7a906..395ea4194db 100755 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -5,12 +5,12 @@ set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads") -set(BOOST_VERSION 1.76.0 CACHE STRING "boost version") +set(BOOST_VERSION 1.83.0 CACHE STRING "boost version") set(BOOST_MIRROR ${LOCAL_MIRROR} https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source CACHE STRING "boost download mirror(s)") string(REPLACE "." "_" BOOST_VERSION_ ${BOOST_VERSION}) set(BOOST_SOURCE boost_${BOOST_VERSION_}.tar.bz2) -set(BOOST_HASH SHA256=f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41 +set(BOOST_HASH SHA256=6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e CACHE STRING "boost source hash") set(NCURSES_VERSION 6.2 CACHE STRING "ncurses version") diff --git a/contrib/epee/include/epee/storages/portable_storage_to_bin.h b/contrib/epee/include/epee/storages/portable_storage_to_bin.h index ff3af308d80..c37317f8aa0 100755 --- a/contrib/epee/include/epee/storages/portable_storage_to_bin.h +++ b/contrib/epee/include/epee/storages/portable_storage_to_bin.h @@ -31,7 +31,7 @@ #include "../pragma_comp_defs.h" #include "portable_storage_base.h" #include -#include +#include namespace epee { diff --git a/contrib/epee/src/portable_storage.cpp b/contrib/epee/src/portable_storage.cpp index 12b40aa7005..202c4562d2f 100755 --- a/contrib/epee/src/portable_storage.cpp +++ b/contrib/epee/src/portable_storage.cpp @@ -1,6 +1,6 @@ #include "epee/storages/portable_storage_to_json.h" #include "epee/storages/portable_storage.h" -#include +#include namespace epee { namespace serialization { diff --git a/external/loki-mq b/external/loki-mq index 5c72a57eca1..b8bb10eac5b 160000 --- a/external/loki-mq +++ b/external/loki-mq @@ -1 +1 @@ -Subproject commit 5c72a57eca120750ecf557ce5a668fb38242956b +Subproject commit b8bb10eac5b45846f25f30fe6f26fd2bc671f9c2 diff --git a/external/oxen-encoding b/external/oxen-encoding index a0912ab4bf3..085bbff7741 160000 --- a/external/oxen-encoding +++ b/external/oxen-encoding @@ -1 +1 @@ -Subproject commit a0912ab4bf3b5e83b42715eff6f632c8912b21e4 +Subproject commit 085bbff774106dfd41c4848ef03e4de259accf4d diff --git a/src/beldex_economy.h b/src/beldex_economy.h index 20aed059d33..526a1bd9c26 100755 --- a/src/beldex_economy.h +++ b/src/beldex_economy.h @@ -62,6 +62,7 @@ enum struct mapping_type : uint16_t belnet_2years, belnet_5years, belnet_10years, + eth_addr, _count, update_record_internal, }; diff --git a/src/common/meta.h b/src/common/meta.h index 4ca051a5f4c..da72975d8fb 100755 --- a/src/common/meta.h +++ b/src/common/meta.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include #ifdef __GNUG__ diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp index ed886e78f77..3818139a1a8 100755 --- a/src/cryptonote_basic/hardfork.cpp +++ b/src/cryptonote_basic/hardfork.cpp @@ -44,6 +44,7 @@ static constexpr std::array mainnet_hard_forks = hard_fork{15, 0, 742420, 1636320320 }, //Friday, December 10, 2021 6:00:00 PM (GMT) hard_fork{17, 0, 742421, 1636320540 }, hard_fork{18, 0, 2986890, 1706506200 }, // Monday, January 29, 2024 5:30:00 AM (UTC) + hard_fork{19, 0, 3546545, 1725514200 }, // Thursday, September 5, 2024 5:30:00 AM (UTC) }; static constexpr std::array testnet_hard_forks = @@ -56,6 +57,7 @@ static constexpr std::array testnet_hard_forks = hard_fork{15, 0, 169950, 1636391396 }, // Monday, November 8, 2021 5:09:56 PM hard_fork{17, 0, 169960, 1636391696 }, // Monday, November 8, 2021 5:14:56 PM hard_fork{18, 0, 1251330, 1701063000 }, // Monday, November 27, 2023 5:30:00 AM + hard_fork{19, 0, 1997558, 1723447800 }, // Monday, Aug 12, 2024 7:30:00 AM }; static constexpr std::array devnet_hard_forks = diff --git a/src/cryptonote_basic/tx_extra.cpp b/src/cryptonote_basic/tx_extra.cpp index 6a96c952e5f..a12fd0b74d7 100644 --- a/src/cryptonote_basic/tx_extra.cpp +++ b/src/cryptonote_basic/tx_extra.cpp @@ -10,6 +10,7 @@ tx_extra_beldex_name_system tx_extra_beldex_name_system::make_buy( const std::string& encrypted_bchat_value, const std::string& encrypted_wallet_value, const std::string& encrypted_belnet_value, + const std::string& encrypted_eth_addr_value, const crypto::hash& prev_txid) { tx_extra_beldex_name_system result{}; @@ -43,6 +44,12 @@ tx_extra_beldex_name_system tx_extra_beldex_name_system::make_buy( result.encrypted_belnet_value = encrypted_belnet_value; } + if (encrypted_eth_addr_value.size()) + { + result.fields |= bns::extra_field::encrypted_eth_addr_value; + result.encrypted_eth_addr_value = encrypted_eth_addr_value; + } + result.prev_txid = prev_txid; return result; } @@ -71,6 +78,7 @@ tx_extra_beldex_name_system tx_extra_beldex_name_system::make_update( std::string_view encrypted_bchat_value, std::string_view encrypted_wallet_value, std::string_view encrypted_belnet_value, + std::string_view encrypted_eth_addr_value, const bns::generic_owner* owner, const bns::generic_owner* backup_owner, const crypto::hash& prev_txid) @@ -98,6 +106,12 @@ tx_extra_beldex_name_system tx_extra_beldex_name_system::make_update( result.fields |= bns::extra_field::encrypted_belnet_value; result.encrypted_belnet_value = std::string{encrypted_belnet_value}; } + + if (encrypted_eth_addr_value.size()) + { + result.fields |= bns::extra_field::encrypted_eth_addr_value; + result.encrypted_eth_addr_value = std::string{encrypted_eth_addr_value}; + } if (owner) { @@ -124,6 +138,7 @@ std::vector readable_reasons(uint16_t decomm_reason) { if (decomm_reason & timestamp_response_unreachable) results.push_back("Unreachable for Timestamp Check"); if (decomm_reason & timesync_status_out_of_sync) results.push_back("Time out of sync"); if (decomm_reason & belnet_unreachable) results.push_back("Belnet Unreachable"); + if (decomm_reason & multi_mn_accept_range_not_met) results.push_back("Multi MN accept Range Not Met"); return results; } @@ -136,6 +151,7 @@ std::vector coded_reasons(uint16_t decomm_reason) { if (decomm_reason & timestamp_response_unreachable) results.push_back("timecheck"); if (decomm_reason & timesync_status_out_of_sync) results.push_back("timesync"); if (decomm_reason & belnet_unreachable) results.push_back("belnet"); + if (decomm_reason & multi_mn_accept_range_not_met) results.push_back("multi_mn_range"); return results; } diff --git a/src/cryptonote_basic/tx_extra.h b/src/cryptonote_basic/tx_extra.h index 3c7b02d0916..ac3089e2e5e 100755 --- a/src/cryptonote_basic/tx_extra.h +++ b/src/cryptonote_basic/tx_extra.h @@ -83,11 +83,12 @@ enum struct extra_field : uint8_t encrypted_bchat_value = 1 << 3, encrypted_wallet_value = 1 << 4, encrypted_belnet_value = 1 << 5, + encrypted_eth_addr_value = 1 << 6, // Bit Masks - updatable_fields = (extra_field::owner | extra_field::backup_owner | extra_field::encrypted_bchat_value | extra_field::encrypted_wallet_value | extra_field::encrypted_belnet_value), + updatable_fields = (extra_field::owner | extra_field::backup_owner | extra_field::encrypted_bchat_value | extra_field::encrypted_wallet_value | extra_field::encrypted_belnet_value | extra_field::encrypted_eth_addr_value), buy_no_backup = (extra_field::owner), - buy_any_value = (extra_field::encrypted_bchat_value | extra_field::encrypted_wallet_value | extra_field::encrypted_belnet_value), + buy_any_value = (extra_field::encrypted_bchat_value | extra_field::encrypted_wallet_value | extra_field::encrypted_belnet_value | extra_field::encrypted_eth_addr_value), buy = (extra_field::buy_no_backup | extra_field::backup_owner), all = (extra_field::updatable_fields | extra_field::signature), }; @@ -435,6 +436,7 @@ namespace cryptonote timestamp_response_unreachable = 1 << 4, timesync_status_out_of_sync = 1 << 5, belnet_unreachable = 1 << 6, + multi_mn_accept_range_not_met = 1 << 7, }; // Returns human-readable reason strings (e.g. "Missed Uptime Proofs") for the given reason bits @@ -557,6 +559,7 @@ namespace cryptonote std::string encrypted_bchat_value; // binary format of the name->bchat_value mapping std::string encrypted_wallet_value; // binary format of the name->wallet_value mapping std::string encrypted_belnet_value; // binary format of the name->belnet_value mapping + std::string encrypted_eth_addr_value; // binary format of the name->eth_addr_value mapping bool field_is_set (bns::extra_field bit) const { return (fields & bit) == bit; } bool field_any_set(bns::extra_field bit) const { return (fields & bit) != bns::extra_field::none; } @@ -577,6 +580,7 @@ namespace cryptonote const std::string& encrypted_bchat_value, const std::string& encrypted_wallet_value, const std::string& encrypted_belnet_value, + const std::string& encrypted_eth_addr_value, const crypto::hash& prev_txid); static tx_extra_beldex_name_system make_renew( @@ -591,6 +595,7 @@ namespace cryptonote std::string_view encrypted_bchat_value, std::string_view encrypted_wallet_value, std::string_view encrypted_belnet_value, + std::string_view encrypted_eth_addr_value, const bns::generic_owner* owner, const bns::generic_owner* backup_owner, const crypto::hash& prev_txid); @@ -610,6 +615,7 @@ namespace cryptonote if (field_is_set(bns::extra_field::encrypted_bchat_value)) FIELD(encrypted_bchat_value); if (field_is_set(bns::extra_field::encrypted_wallet_value)) FIELD(encrypted_wallet_value); if (field_is_set(bns::extra_field::encrypted_belnet_value)) FIELD(encrypted_belnet_value); + if (field_is_set(bns::extra_field::encrypted_eth_addr_value)) FIELD(encrypted_eth_addr_value); END_SERIALIZE() }; diff --git a/src/cryptonote_core/beldex_name_system.cpp b/src/cryptonote_core/beldex_name_system.cpp index 350e932b35e..60caac947e8 100755 --- a/src/cryptonote_core/beldex_name_system.cpp +++ b/src/cryptonote_core/beldex_name_system.cpp @@ -80,6 +80,7 @@ enum struct mapping_record_column encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, + encrypted_eth_addr_value, txid, owner_id, backup_owner_id, @@ -119,7 +120,12 @@ std::string bns::mapping_value::to_readable_value(cryptonote::network_type netty } else { result = oxenc::to_hex(to_view()); } - } else { + } + else if (type == bns::mapping_type::eth_addr) + { + result = "0x" + oxenc::to_hex(to_view()); + } + else { result = oxenc::to_hex(to_view()); } @@ -378,7 +384,21 @@ mapping_record sql_get_mapping_from_statement(sql_compiled_statement& statement) get(statement, mapping_record_column::owner_id, result.owner_id); get(statement, mapping_record_column::backup_owner_id, result.backup_owner_id); - // Copy encrypted_bchat_value + // Copy encrypted_eth_addr_value + { + auto value = get(statement, mapping_record_column::encrypted_eth_addr_value); + if(!value.empty()){ + if (value.size() > result.encrypted_eth_addr_value.buffer.size()) + { + MERROR("Unexpected encrypted Ethereum address value with size=" << value.size() << ", in BNS db larger than the available size=" << result.encrypted_eth_addr_value.buffer.size()); + return result; + } + result.encrypted_eth_addr_value.len = value.size(); + result.encrypted_eth_addr_value.encrypted = true; + std::memcpy(&result.encrypted_eth_addr_value.buffer[0], value.data(), value.size()); + } + } + // Copy encrypted_bchat_value { auto value = get(statement, mapping_record_column::encrypted_bchat_value); if(!value.empty()){ @@ -675,7 +695,7 @@ static void append_owner(std::string& buffer, const bns::generic_owner* owner) } } -std::string tx_extra_signature(std::string_view value_bchat,std::string_view value_wallet,std::string_view value_belnet, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, crypto::hash const &prev_txid) +std::string tx_extra_signature(std::string_view value_bchat,std::string_view value_wallet,std::string_view value_belnet, std::string_view value_eth_addr, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, crypto::hash const &prev_txid) { static_assert(sizeof(crypto::hash) == crypto_generichash_BYTES, "Using libsodium generichash for signature hash, require we fit into crypto::hash"); if (value_bchat.size() > mapping_value::BUFFER_SIZE) @@ -693,12 +713,18 @@ std::string tx_extra_signature(std::string_view value_bchat,std::string_view val MERROR("Unexpected value len=" << value_belnet.size() << " greater than the expected capacity=" << mapping_value::BUFFER_SIZE); return ""s; } + else if (value_eth_addr.size() > mapping_value::BUFFER_SIZE) + { + MERROR("Unexpected value len=" << value_eth_addr.size() << " greater than the expected capacity=" << mapping_value::BUFFER_SIZE); + return ""s; + } std::string result; - result.reserve(3 * mapping_value::BUFFER_SIZE + sizeof(*owner) + sizeof(*backup_owner) + sizeof(prev_txid)); + result.reserve(4 * mapping_value::BUFFER_SIZE + sizeof(*owner) + sizeof(*backup_owner) + sizeof(prev_txid)); result += value_bchat; result += value_wallet; result += value_belnet; + result += value_eth_addr; append_owner(result, owner); append_owner(result, backup_owner); @@ -945,6 +971,25 @@ bool mapping_value::validate(cryptonote::network_type nettype, mapping_type type oxenc::from_base32z(value.begin(), value.begin() + 52, blob->buffer.begin()); } } + else if(type == mapping_type::eth_addr) + { + std::string_view value_eth = value.substr(2); + if(check_condition(value_eth.size() != 2*ETH_ADDR_BINARY_LENGTH, reason, "The value=", value, " is not the required ", 2*ETH_ADDR_BINARY_LENGTH, "-character hex string eth address, length=", value.size())) + return false; + + if (check_condition(!oxenc::is_hex(value_eth), reason, ", specifies name -> value mapping where the value is not a hex string given value=")) + return false; + + if (check_condition(!tools::starts_with(value, "0x"), reason, "BNS type=eth_addr, specifies mapping from name -> ed25519 key where the key is not prefixed with 0x, given ed25519=", value)) + return false; + + if (blob) // NOTE: Given blob, write the binary output + { + blob->len = value_eth.size() / 2; + assert(blob->len <= blob->buffer.size()); + oxenc::from_hex(value_eth.begin(), value_eth.end(), blob->buffer.begin()); + } + } else { assert(type == mapping_type::bchat); @@ -995,6 +1040,10 @@ bool mapping_value::validate_encrypted(mapping_type type, std::string_view value if (value.size() == value_len - crypto_aead_xchacha20poly1305_ietf_NPUBBYTES) value_len -= crypto_aead_xchacha20poly1305_ietf_NPUBBYTES; } + else if (type == mapping_type::eth_addr) + { + value_len += ETH_ADDR_BINARY_LENGTH; + } else { if (reason) @@ -1099,6 +1148,9 @@ static bool validate_against_previous_mapping(bns::name_system_db &bns_db, uint6 if (check_condition(bns_extra.field_is_set(bns::extra_field::encrypted_belnet_value) && bns_extra.encrypted_belnet_value == mapping.encrypted_belnet_value.to_view(), reason, tx, ", ", bns_extra_string(bns_db.network_type(), bns_extra), SPECIFYING_SAME_VALUE_ERR, "value")) return false; + if (check_condition(bns_extra.field_is_set(bns::extra_field::encrypted_eth_addr_value) && bns_extra.encrypted_eth_addr_value == mapping.encrypted_eth_addr_value.to_view(), reason, tx, ", ", bns_extra_string(bns_db.network_type(), bns_extra), SPECIFYING_SAME_VALUE_ERR, "value")) + return false; + if (check_condition(bns_extra.field_is_set(bns::extra_field::owner) && bns_extra.owner == mapping.owner, reason, tx, ", ", bns_extra_string(bns_db.network_type(), bns_extra), SPECIFYING_SAME_VALUE_ERR, "owner")) return false; @@ -1110,6 +1162,7 @@ static bool validate_against_previous_mapping(bns::name_system_db &bns_db, uint6 bns_extra.encrypted_bchat_value, bns_extra.encrypted_wallet_value, bns_extra.encrypted_belnet_value, + bns_extra.encrypted_eth_addr_value, bns_extra.field_is_set(bns::extra_field::owner) ? &bns_extra.owner : nullptr, bns_extra.field_is_set(bns::extra_field::backup_owner) ? &bns_extra.backup_owner : nullptr, expected_prev_txid); @@ -1146,6 +1199,7 @@ static bool validate_against_previous_mapping(bns::name_system_db &bns_db, uint6 bns_extra.encrypted_bchat_value, bns_extra.encrypted_wallet_value, bns_extra.encrypted_belnet_value, + bns_extra.encrypted_eth_addr_value, bns_extra.field_is_set(bns::extra_field::owner) ? &bns_extra.owner : nullptr, bns_extra.field_is_set(bns::extra_field::backup_owner) ? &bns_extra.backup_owner : nullptr, expected_prev_txid); @@ -1203,6 +1257,9 @@ bool name_system_db::validate_bns_tx(uint8_t hf_version, uint64_t blockchain_hei if (check_condition(!bns_extra.field_is_set(bns::extra_field::encrypted_belnet_value) && bns_extra.encrypted_belnet_value.size(), reason, tx, ", ", bns_extra_string(nettype, bns_extra), VALUE_SPECIFIED_BUT_NOT_REQUESTED, "encrypted_belnet_value")) return false; + if (check_condition(!bns_extra.field_is_set(bns::extra_field::encrypted_eth_addr_value) && bns_extra.encrypted_eth_addr_value.size(), reason, tx, ", ", bns_extra_string(nettype, bns_extra), VALUE_SPECIFIED_BUT_NOT_REQUESTED, "encrypted_eth_addr_value")) + return false; + if (check_condition(!bns_extra.field_is_set(bns::extra_field::owner) && bns_extra.owner, reason, tx, ", ", bns_extra_string(nettype, bns_extra), VALUE_SPECIFIED_BUT_NOT_REQUESTED, "owner")) return false; @@ -1260,6 +1317,16 @@ bool name_system_db::validate_bns_tx(uint8_t hf_version, uint64_t blockchain_hei return false; } + if (bns_extra.field_is_set(bns::extra_field::encrypted_eth_addr_value)) + { + // BNS Allowed type Validation + if (check_condition(hf_version < cryptonote::network_version_19, reason, tx, ", ", bns_extra_string(nettype, bns_extra)," specifying eth_addr is disallowed in HF", +static_cast(hf_version))) + return false; + + if (!mapping_value::validate_encrypted(mapping_type::eth_addr, bns_extra.encrypted_eth_addr_value, nullptr, reason)) + return false; + } + if (!validate_against_previous_mapping(*this, blockchain_height, tx, bns_extra, reason)) return false; @@ -1299,9 +1366,11 @@ bool validate_mapping_type(std::string_view mapping_type_str, uint8_t hf_version mapping_type_ = bns::mapping_type::belnet; else if (tools::string_iequal(mapping, "wallet")) mapping_type_ = bns::mapping_type::wallet; + else if (tools::string_iequal(mapping, "eth_addr")) + mapping_type_ = bns::mapping_type::eth_addr; else { - if (reason) *reason = "Unsupported BNS type \"" + std::string{mapping_type_str} + "\"; supported types are: bchat, belnet, wallet"; + if (reason) *reason = "Unsupported BNS type \"" + std::string{mapping_type_str} + "\"; supported types are: bchat, belnet, wallet and eth_addr"; return false; } @@ -1457,6 +1526,7 @@ bool mapping_value::decrypt(std::string_view name, mapping_type type, const cryp { switch(type) { case mapping_type::bchat: dec_length = BCHAT_PUBLIC_KEY_BINARY_LENGTH; break; + case mapping_type::eth_addr: dec_length = ETH_ADDR_BINARY_LENGTH; break; case mapping_type::belnet: dec_length = BELNET_ADDRESS_BINARY_LENGTH; break; case mapping_type::wallet: //Wallet type has variable type, check performed in check_length if (auto plain_len = len - crypto_aead_xchacha20poly1305_ietf_ABYTES - crypto_aead_xchacha20poly1305_ietf_NPUBBYTES; @@ -1546,6 +1616,7 @@ bool build_default_tables(name_system_db& bns_db) encrypted_bchat_value BLOB, encrypted_wallet_value BLOB, encrypted_belnet_value BLOB, + encrypted_eth_addr_value BLOB, txid BLOB NOT NULL, owner_id INTEGER NOT NULL REFERENCES owner(id), backup_owner_id INTEGER REFERENCES owner(id), @@ -1587,16 +1658,16 @@ CREATE INDEX IF NOT EXISTS mapping_type_name_exp ON mappings (name_hash, expirat // In Beldex v5.0.0 we dropped some columns that are no longer needed, but SQLite can't do this easily: // instead we have to manually recreate the table, so check it and see if the type or // encrypted_value columns still exist: if so, we need to recreate. - bool need_mappings_migration = false; + bool need_mappings_migration = true; { sql_compiled_statement mappings_info{bns_db}; mappings_info.compile("PRAGMA table_info(mappings)", false); while (step(mappings_info) == SQLITE_ROW) { auto name = get(mappings_info, 1); - if (name == "type" || name == "encrypted_value") + if (name == "encrypted_eth_addr_value") { - need_mappings_migration = true; + need_mappings_migration = false; break; } } @@ -1607,14 +1678,24 @@ CREATE INDEX IF NOT EXISTS mapping_type_name_exp ON mappings (name_hash, expirat LOG_PRINT_L1("Migrating BNS mappings database to new format"); const std::string migrate = R"( BEGIN TRANSACTION; -ALTER TABLE mappings RENAME TO mappings_old; -CREATE TABLE mappings ()" + mappings_columns + R"(); -DROP TABLE mappings_old; -DELETE FROM owner; -CREATE UNIQUE INDEX name_type_update ON mappings(name_hash, update_height DESC); -CREATE INDEX owner_id_index ON mappings(owner_id); -CREATE INDEX backup_owner_index ON mappings(backup_owner_id); -CREATE INDEX mapping_type_name_exp ON mappings(name_hash, expiration_height DESC); +CREATE TABLE mappings_new ( + id INTEGER PRIMARY KEY NOT NULL, + name_hash VARCHAR NOT NULL, + encrypted_bchat_value BLOB, + encrypted_wallet_value BLOB, + encrypted_belnet_value BLOB, + encrypted_eth_addr_value BLOB, + txid BLOB NOT NULL, + owner_id INTEGER NOT NULL REFERENCES owner(id), + backup_owner_id INTEGER REFERENCES owner(id), + update_height INTEGER NOT NULL, + expiration_height INTEGER NOT NULL +); +INSERT INTO mappings_new (id, name_hash, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, encrypted_eth_addr_value,txid, owner_id, backup_owner_id, update_height, expiration_height) +SELECT id, name_hash, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, NULL AS encrypted_eth_addr_value, txid, owner_id, backup_owner_id, update_height, expiration_height +FROM mappings; +DROP TABLE mappings; +ALTER TABLE mappings_new RENAME TO mappings; COMMIT TRANSACTION; )"; @@ -1748,7 +1829,7 @@ DELETE FROM owner WHERE NOT EXISTS (SELECT * FROM mappings WHERE owner.id = mappings.owner_id) AND NOT EXISTS (SELECT * FROM mappings WHERE owner.id = mappings.backup_owner_id))"sv; - constexpr auto SAVE_MAPPING_STR = "INSERT INTO mappings (name_hash, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, txid, owner_id, backup_owner_id, update_height, expiration_height) VALUES (?,?,?,?,?,?,?,?,?)"sv; + constexpr auto SAVE_MAPPING_STR = "INSERT INTO mappings (name_hash, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, encrypted_eth_addr_value, txid, owner_id, backup_owner_id, update_height, expiration_height) VALUES (?,?,?,?,?,?,?,?,?,?)"sv; constexpr auto SAVE_OWNER_STR = "INSERT INTO owner (address) VALUES (?)"sv; constexpr auto SAVE_SETTINGS_STR = "INSERT OR REPLACE INTO settings (id, top_height, top_hash, version) VALUES (1,?,?,?)"sv; @@ -1951,7 +2032,7 @@ std::pair> update_record_query(name_sys sql.reserve(500); sql += R"( -INSERT INTO mappings (name_hash, txid, update_height, expiration_height, owner_id, backup_owner_id, encrypted_bchat_value,encrypted_wallet_value,encrypted_belnet_value) +INSERT INTO mappings (name_hash, txid, update_height, expiration_height, owner_id, backup_owner_id, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, encrypted_eth_addr_value) SELECT name_hash, ?, ?)"; bind.emplace_back(blob_view{tx_hash.data, sizeof(tx_hash)}); @@ -1961,7 +2042,7 @@ SELECT name_hash, ?, ?)"; if (entry.is_renewing()) { - sql += ", expiration_height + ?, owner_id, backup_owner_id, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value"; + sql += ", expiration_height + ?, owner_id, backup_owner_id, encrypted_bchat_value, encrypted_wallet_value, encrypted_belnet_value, encrypted_eth_addr_value"; bind.emplace_back(expiry_blocks(bns_db.network_type(), entry.mapping_years).value_or(0)); } else @@ -2023,6 +2104,14 @@ SELECT name_hash, ?, ?)"; } else sql += ", encrypted_belnet_value"; + + if (entry.field_is_set(bns::extra_field::encrypted_eth_addr_value)) + { + sql += ", ?"; + bind.emplace_back(blob_view{entry.encrypted_eth_addr_value}); + } + else + sql += ", encrypted_eth_addr_value"; } sql += suffix; @@ -2152,7 +2241,7 @@ struct bns_update_history void bns_update_history::update(uint64_t height, cryptonote::tx_extra_beldex_name_system const &bns_extra) { - if (bns_extra.field_is_set(bns::extra_field::encrypted_bchat_value) || bns_extra.field_is_set(bns::extra_field::encrypted_wallet_value) || bns_extra.field_is_set(bns::extra_field::encrypted_belnet_value)) + if (bns_extra.field_is_set(bns::extra_field::encrypted_bchat_value) || bns_extra.field_is_set(bns::extra_field::encrypted_wallet_value) || bns_extra.field_is_set(bns::extra_field::encrypted_belnet_value) || bns_extra.field_is_set(bns::extra_field::encrypted_eth_addr_value)) value_last_update_height = height; if (bns_extra.field_is_set(bns::extra_field::owner)) @@ -2213,7 +2302,12 @@ bool name_system_db::save_mapping(crypto::hash const &tx_hash, cryptonote::tx_ex bind(statement, mapping_record_column::encrypted_belnet_value,blob_view{}); else bind(statement, mapping_record_column::encrypted_belnet_value, blob_view{src.encrypted_belnet_value}); - + + if(src.encrypted_eth_addr_value.empty()) + bind(statement, mapping_record_column::encrypted_eth_addr_value,blob_view{}); + else + bind(statement, mapping_record_column::encrypted_eth_addr_value, blob_view{src.encrypted_eth_addr_value}); + bind(statement, mapping_record_column::txid, blob_view{tx_hash.data, sizeof(tx_hash)}); bind(statement, mapping_record_column::update_height, height); bind(statement, mapping_record_column::expiration_height, expiration); diff --git a/src/cryptonote_core/beldex_name_system.h b/src/cryptonote_core/beldex_name_system.h index c4b414ccb05..4bcb91bdad3 100755 --- a/src/cryptonote_core/beldex_name_system.h +++ b/src/cryptonote_core/beldex_name_system.h @@ -35,6 +35,7 @@ constexpr size_t DOMAIN_NAME_MAX_NOHYPHEN = 32 + 4; // If the name does not cont constexpr size_t BELNET_ADDRESS_BINARY_LENGTH = sizeof(crypto::ed25519_public_key); constexpr size_t BCHAT_DISPLAY_NAME_MAX = 64; constexpr size_t BCHAT_PUBLIC_KEY_BINARY_LENGTH = 1 + sizeof(crypto::ed25519_public_key); // Bchat keys at prefixed with 0xbd + ed25519 key +constexpr size_t ETH_ADDR_BINARY_LENGTH = 20; // Ethereum address bytes constexpr size_t NAME_HASH_SIZE = sizeof(crypto::hash); constexpr size_t NAME_HASH_SIZE_B64_MIN = (4*NAME_HASH_SIZE + 2) / 3; // No padding @@ -48,8 +49,7 @@ constexpr char BNS_WALLET_TYPE_INTEGRATED = 0x02; struct mapping_value { - static size_t constexpr BUFFER_SIZE = std::max({WALLET_ACCOUNT_BINARY_LENGTH_INC_PAYMENT_ID, BELNET_ADDRESS_BINARY_LENGTH, BCHAT_PUBLIC_KEY_BINARY_LENGTH}) + SODIUM_ENCRYPTION_EXTRA_BYTES; - // static size_t constexpr BUFFER_SIZE_TOTAL = (WALLET_ACCOUNT_BINARY_LENGTH_INC_PAYMENT_ID + BELNET_ADDRESS_BINARY_LENGTH + BCHAT_PUBLIC_KEY_BINARY_LENGTH) + 3*SODIUM_ENCRYPTION_EXTRA_BYTES; + static size_t constexpr BUFFER_SIZE = std::max({WALLET_ACCOUNT_BINARY_LENGTH_INC_PAYMENT_ID, BELNET_ADDRESS_BINARY_LENGTH, BCHAT_PUBLIC_KEY_BINARY_LENGTH, ETH_ADDR_BINARY_LENGTH}) + SODIUM_ENCRYPTION_EXTRA_BYTES; std::array buffer; bool encrypted; @@ -123,10 +123,11 @@ inline std::string_view mapping_type_str(mapping_type type) { switch(type) { - case mapping_type::belnet: return "belnet"sv; // general type stored in the database; 1 year when in a purchase tx + case mapping_type::belnet: return "belnet"sv; // general type stored in the database; 1 year when in a purchase tx case mapping_type::bchat: return "bchat"sv; - case mapping_type::wallet: return "wallet"sv; - default: assert(false); return "xx_unhandled_type"sv; + case mapping_type::wallet: return "wallet"sv; + case mapping_type::eth_addr: return "eth_addr"sv; + default: assert(false); return "xx_unhandled_type"sv; } } inline std::ostream &operator<<(std::ostream &os, mapping_type type) { return os << mapping_type_str(type); } @@ -153,6 +154,7 @@ constexpr std::string_view db_mapping_value(bns::mapping_type type) { case mapping_type::bchat: return "encrypted_bchat_value"sv; case mapping_type::wallet: return "encrypted_wallet_value"sv; case mapping_type::belnet: return "encrypted_belnet_value"sv; + case mapping_type::eth_addr: return "encrypted_eth_addr_value"sv; default: assert(false); return "xx_unhandled_type"sv; } } @@ -182,7 +184,7 @@ generic_signature make_ed25519_signature(crypto::hash const &hash, crypto::ed25 generic_owner make_monero_owner(cryptonote::account_public_address const &owner, bool is_subaddress); 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_bchat, std::string_view value_wallet, std::string_view value_belnet, generic_owner const *owner, generic_owner const *backup_owner, crypto::hash const &prev_txid); +std::string tx_extra_signature(std::string_view value_bchat, std::string_view value_wallet, std::string_view value_belnet, std::string_view value_eth_addr, generic_owner const *owner, generic_owner const *backup_owner, crypto::hash const &prev_txid); enum struct bns_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 BNS DB. @@ -230,6 +232,7 @@ struct mapping_record mapping_value encrypted_bchat_value; mapping_value encrypted_wallet_value; mapping_value encrypted_belnet_value; + mapping_value encrypted_eth_addr_value; uint64_t register_height; std::optional expiration_height; uint64_t update_height; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 03769b69239..0ff4213f17b 100755 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1767,7 +1767,7 @@ namespace cryptonote emission_amount = m_coinbase_cache.emissions; total_fee_amount = m_coinbase_cache.fees; burnt_beldex = m_coinbase_cache.burnt; - start_offset = m_coinbase_cache.height; + start_offset = m_coinbase_cache.height + 1; count -= m_coinbase_cache.height; } // else don't change anything; we need a subset of blocks that ends before the cache. @@ -1798,7 +1798,7 @@ namespace cryptonote total_fee_amount = m_coinbase_cache.fees; burnt_beldex = m_coinbase_cache.burnt; count -= m_coinbase_cache.height - start_offset; - start_offset = m_coinbase_cache.height; + start_offset = m_coinbase_cache.height + 1; } } if (cache_to > 0 && count > CACHE_EXCLUSIVE) { @@ -1809,7 +1809,7 @@ namespace cryptonote } } - const uint64_t end = start_offset + count - 1; + const uint64_t end = start_offset + count - 2; m_blockchain_storage.for_blocks_range(start_offset, end, [this, &cache_to, &result, &cache_build_started](uint64_t height, const crypto::hash& hash, const block& b){ auto& [emission_amount, total_fee_amount, burnt_beldex] = *result; diff --git a/src/cryptonote_core/master_node_quorum_cop.cpp b/src/cryptonote_core/master_node_quorum_cop.cpp index 9ab7da6cd2d..d5fcf9a9340 100755 --- a/src/cryptonote_core/master_node_quorum_cop.cpp +++ b/src/cryptonote_core/master_node_quorum_cop.cpp @@ -60,6 +60,7 @@ namespace master_nodes if (!timesync_status) results.push_back("Too many missed timesync replies."sv); if (!storage_server_reachable) results.push_back("Storage server is not reachable."sv); if (!belnet_reachable) results.push_back("Belnet router is not reachable."sv); + if (!multi_mn_accept_range) results.push_back("This Master Node IP Reached Maximum acceptable Range."sv); return results; } @@ -76,7 +77,7 @@ namespace master_nodes // Perform master node tests -- this returns true if the server node is in a good state, that is, // has submitted uptime proofs, participated in required quorums, etc. - master_node_test_results quorum_cop::check_master_node(uint8_t hf_version, const crypto::public_key &pubkey, const master_node_info &info) const + master_node_test_results quorum_cop::check_master_node(std::map>> multi_mns_list, uint8_t hf_version, const crypto::public_key &pubkey, const master_node_info &info) const { const auto& netconf = m_core.get_net_config(); @@ -106,6 +107,33 @@ namespace master_nodes timesync_status = proof.timesync_status; }); + + if (hf_version >= cryptonote::network_version_19) { + + std::vector> multi_mns = multi_mns_list[ips[0].first]; + + // Sort the list + std::sort(multi_mns.begin(), multi_mns.end(), [](const auto &a, const auto &b){ + return a.second < b.second; + }); + + // Find the position of pubkey in the vector + auto position = std::find_if(multi_mns.begin(), multi_mns.end(), [&](const auto &pair){ + return pair.first == pubkey; + }); + + // Check if "pubkey" is found in the multi_mns list + if (position != multi_mns.end()) { + auto index_in_multi_mns = std::distance(multi_mns.begin(), position); + + // Ensure the index is within allowed limits + if (index_in_multi_mns >= MAX_ALLOWED_MASTERNODES_PER_IP) { + LOG_PRINT_L1("This Master Node reached the maximum multinode: " << pubkey); + result.multi_mn_accept_range = false; + } + } + } + std::chrono::seconds time_since_last_uptime_proof{std::time(nullptr) - timestamp}; bool check_uptime_obligation = true; @@ -230,7 +258,7 @@ namespace master_nodes return result; } - void quorum_cop::handling_master_nodes_states(uint8_t const obligations_height_hf_version_,uint8_t const hf_version,std::shared_ptr quorum,int index_in_group,uint64_t const latest_height) + void quorum_cop::handling_master_nodes_states(std::map>> multi_mns_list, uint8_t const obligations_height_hf_version_,uint8_t const hf_version,std::shared_ptr quorum,int index_in_group,uint64_t const latest_height) { // // NOTE: I am in the quorum @@ -259,7 +287,7 @@ namespace master_nodes continue; } - auto test_results = check_master_node(obligations_height_hf_version_, node_key, info); //MN proof Testing + auto test_results = check_master_node(multi_mns_list, obligations_height_hf_version_, node_key, info); //MN proof Testing bool passed = test_results.passed(); LOG_PRINT_L3("process_quorums: check_master_node passed:");//TODO:VOTE LOG_PRINT_L3("NODE KEY:" << quorum->workers[node_index]); @@ -294,6 +322,7 @@ namespace master_nodes if (!test_results.POS_participation) reason |= cryptonote::Decommission_Reason::missed_POS_participations; if (!test_results.storage_server_reachable) reason |= cryptonote::Decommission_Reason::storage_server_unreachable; if (!test_results.belnet_reachable) reason |= cryptonote::Decommission_Reason::belnet_unreachable; + if (!test_results.multi_mn_accept_range) reason |= cryptonote::Decommission_Reason::multi_mn_accept_range_not_met; if (!test_results.timestamp_participation) reason |= cryptonote::Decommission_Reason::timestamp_response_unreachable; if (!test_results.timesync_status) reason |= cryptonote::Decommission_Reason::timesync_status_out_of_sync; @@ -330,11 +359,12 @@ namespace master_nodes if (!handle_vote(vote, vvc,hf_version)) LOG_ERROR("Failed to add state change vote; reason: " << print_vote_verification_context(vvc, &vote)); } + if (good > 0) LOG_PRINT_L3(good << " of " << total << " master nodes are active and passing checks; no state change votes required"); } - void quorum_cop::handling_my_master_node_states(uint8_t const obligations_height_hf_version,uint8_t const hf_version,bool &tested_myself_once_per_block,std::chrono::seconds live_time) + void quorum_cop::handling_my_master_node_states(std::map>> multi_mns_list, uint8_t const obligations_height_hf_version,uint8_t const hf_version,bool &tested_myself_once_per_block,std::chrono::seconds live_time) { const auto& my_keys = m_core.get_master_keys(); const auto states_array = m_core.get_master_node_list_state({my_keys.pub}); @@ -344,7 +374,7 @@ namespace master_nodes if (info.can_be_voted_on(m_obligations_height)) { tested_myself_once_per_block = true; - auto my_test_results = check_master_node(obligations_height_hf_version, my_keys.pub, info); + auto my_test_results = check_master_node(multi_mns_list, obligations_height_hf_version, my_keys.pub, info); const bool print_failings = info.is_decommissioned() || (info.is_active() && !my_test_results.passed() && // Don't warn uptime proofs if the daemon is just recently started and is candidate for testing (i.e. restarting the daemon) @@ -361,7 +391,7 @@ namespace master_nodes LOG_PRINT_L0(tools::join("\n", *why)); else LOG_PRINT_L0("Master Node is passing all local tests"); - LOG_PRINT_L0("(Note that some tests, such as storage server and belnet reachability, can only assessed by remote master nodes)"); + LOG_PRINT_L0("(Note that some tests, such as storage server, belnet reachability and multi_mn_accept_range, can only assessed by remote master nodes)"); } }else{ LOG_PRINT_L0("process_quorums: Cant be voted on my Master Node"); @@ -420,6 +450,16 @@ namespace master_nodes if (hf_version < cryptonote::network_version_9_master_nodes) return; + auto mn_infos = m_core.get_master_node_list_state(); + std::map>> multi_mns_list; + // Find the MultiMaster nodes + for (auto &mn_info : mn_infos) + { + m_core.get_master_node_list().access_proof(mn_info.pubkey, [&](const proof_info &proof) { + auto& entry = multi_mns_list[proof.proof->public_ip]; + entry.push_back({mn_info.pubkey, mn_info.info->registration_height}); + }); + } const auto& netconf = m_core.get_net_config(); uint64_t const REORG_SAFETY_BUFFER_BLOCKS = (hf_version >= cryptonote::network_version_13_checkpointing) @@ -519,7 +559,7 @@ namespace master_nodes int index_in_group = voting_enabled ? find_index_in_quorum_group(quorum->validators, my_keys.pub) : -1; if (index_in_group >= 0) { - handling_master_nodes_states(obligations_height_hf_version,hf_version,quorum,index_in_group,latest_height); + handling_master_nodes_states(multi_mns_list,obligations_height_hf_version,hf_version,quorum,index_in_group,latest_height); } else if (!tested_myself_once_per_block && (find_index_in_quorum_group(quorum->workers, my_keys.pub) >= 0)) { @@ -527,7 +567,7 @@ namespace master_nodes // being tested. If so, check if we would be decommissioned // based on _our_ data and if so, report it to the user so they // know about it. - handling_my_master_node_states(obligations_height_hf_version,hf_version,tested_myself_once_per_block,live_time); + handling_my_master_node_states(multi_mns_list,obligations_height_hf_version,hf_version,tested_myself_once_per_block,live_time); } } } diff --git a/src/cryptonote_core/master_node_quorum_cop.h b/src/cryptonote_core/master_node_quorum_cop.h index c5fe1c8e45e..623fd1e8092 100755 --- a/src/cryptonote_core/master_node_quorum_cop.h +++ b/src/cryptonote_core/master_node_quorum_cop.h @@ -94,6 +94,7 @@ namespace master_nodes bool timesync_status = true; bool storage_server_reachable = true; bool belnet_reachable = true; + bool multi_mn_accept_range = true; // Returns a vector of reasons why this node is failing (nullopt if not failing). std::optional> why() const; @@ -106,7 +107,8 @@ namespace master_nodes timestamp_participation && timesync_status && storage_server_reachable && - belnet_reachable; + belnet_reachable && + multi_mn_accept_range; } }; @@ -128,9 +130,9 @@ namespace master_nodes private: void process_quorums(cryptonote::block const &block); void quorum_checkpoint_handle(uint64_t const start_voting_from_height_,uint64_t const height,uint8_t const hf_version); - void handling_master_nodes_states(uint8_t const obligations_height_hf_version_,uint8_t const hf_version,std::shared_ptr quorum,int index_in_group,uint64_t const latest_height); - void handling_my_master_node_states(uint8_t const obligations_height_hf_version,uint8_t const hf_version,bool &tested_myself_once_per_block,std::chrono::seconds live_time); - master_node_test_results check_master_node(uint8_t hf_version, const crypto::public_key &pubkey, const master_node_info &info) const; + void handling_master_nodes_states(std::map>> multi_mns_list, uint8_t const obligations_height_hf_version_,uint8_t const hf_version,std::shared_ptr quorum,int index_in_group,uint64_t const latest_height); + void handling_my_master_node_states(std::map>> multi_mns_list, uint8_t const obligations_height_hf_version,uint8_t const hf_version,bool &tested_myself_once_per_block,std::chrono::seconds live_time); + master_node_test_results check_master_node(std::map>> multi_mns_list, uint8_t hf_version, const crypto::public_key &pubkey, const master_node_info &info) const; cryptonote::core& m_core; voting_pool m_vote_pool; diff --git a/src/cryptonote_core/master_node_rules.h b/src/cryptonote_core/master_node_rules.h index bd5a09f9a1c..2cabac14103 100755 --- a/src/cryptonote_core/master_node_rules.h +++ b/src/cryptonote_core/master_node_rules.h @@ -191,6 +191,8 @@ namespace master_nodes { constexpr uint64_t REORG_SAFETY_BUFFER_BLOCKS_POST_HF12 = (CHECKPOINT_INTERVAL * CHECKPOINT_NUM_CHECKPOINTS_FOR_CHAIN_FINALITY) + (CHECKPOINT_INTERVAL - 1); constexpr uint64_t REORG_SAFETY_BUFFER_BLOCKS_PRE_HF12 = 20; + // A single public IP address is restricted from hosting more than 3 masternodes. + constexpr int16_t MAX_ALLOWED_MASTERNODES_PER_IP = 3; constexpr auto IP_CHANGE_WINDOW = 24h; // How far back an obligations quorum looks for multiple IPs (unless the following buffer is more recent) constexpr auto IP_CHANGE_BUFFER = 2h; // After we bump a MN for an IP change we don't bump again for changes within this time period @@ -234,6 +236,7 @@ namespace master_nodes { }; constexpr proof_version MIN_UPTIME_PROOF_VERSIONS[] = { + proof_version{{cryptonote::network_version_19, 0}, {6,0,0}, {0,9,7}, {2,3,0}}, proof_version{{cryptonote::network_version_18_bns, 0}, {5,0,0}, {0,9,7}, {2,3,0}}, proof_version{{cryptonote::network_version_17_POS, 0}, {4,0,0}, {0,9,5}, {2,2,0}}, proof_version{{cryptonote::network_version_16, 0}, {4,0,0}, {0,9,5}, {2,2,0}}, diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 75aa3d52679..b599768f3ac 100755 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -2748,9 +2748,10 @@ skip: uint64_t target = 0; m_p2p->for_each_connection([&](const connection_context& cntxt, nodetool::peerid_type peer_id, uint32_t support_flags) { MINFO("DEBUGconnection state:" << cntxt.m_state << " cntxtId:" << cntxt.m_connection_id << " context:"<= cryptonote_connection_context::state_synchronizing && cntxt.m_connection_id != context.m_connection_id) + if (cntxt.m_state >= cryptonote_connection_context::state_synchronizing && cntxt.m_connection_id != context.m_connection_id){ target = std::max(target, cntxt.m_remote_blockchain_height); - MINFO("Target found:" << target); + } + MINFO("Target found:" << target); return true; }); const uint64_t previous_target = m_core.get_target_blockchain_height(); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index f469f172973..10ceec0474b 100755 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -56,7 +56,6 @@ #include "cryptonote_basic/cryptonote_format_utils.h" #include "cryptonote_basic/account.h" #include "cryptonote_basic/cryptonote_basic_impl.h" -#include "cryptonote_core/tx_sanity_check.h" #include "cryptonote_core/uptime_proof.h" #include "net/parse.h" #include "crypto/hash.h" @@ -810,6 +809,7 @@ namespace cryptonote { namespace rpc { case bns::mapping_type::bchat: bns.type = "bchat"; break; case bns::mapping_type::wallet: bns.type = "wallet"; break; + case bns::mapping_type::eth_addr: bns.type = "eth_addr"; break; case bns::mapping_type::update_record_internal: [[fallthrough]]; case bns::mapping_type::_count: @@ -828,6 +828,8 @@ namespace cryptonote { namespace rpc { bns.value_wallet = oxenc::to_hex(x.encrypted_wallet_value); if (!x.encrypted_belnet_value.empty()) bns.value_belnet = oxenc::to_hex(x.encrypted_belnet_value); + if (!x.encrypted_eth_addr_value.empty()) + bns.value_eth_addr = oxenc::to_hex(x.encrypted_eth_addr_value); _load_owner(bns.owner, x.owner); _load_owner(bns.backup_owner, x.backup_owner); } @@ -1151,15 +1153,6 @@ namespace cryptonote { namespace rpc { } auto tx_blob = oxenc::from_hex(req.tx_as_hex); - if (req.do_sanity_checks && !cryptonote::tx_sanity_check(tx_blob, m_core.get_blockchain_storage().get_num_mature_outputs(0))) - { - res.status = "Failed"; - res.reason = "Sanity check failed"; - res.sanity_check_failed = true; - return res; - } - res.sanity_check_failed = false; - if (req.flash) { auto future = m_core.handle_flash_tx(tx_blob); @@ -3537,6 +3530,7 @@ namespace cryptonote { namespace rpc { entry.encrypted_bchat_value = oxenc::to_hex(record.encrypted_bchat_value.to_view()); entry.encrypted_wallet_value = oxenc::to_hex(record.encrypted_wallet_value.to_view()); entry.encrypted_belnet_value = oxenc::to_hex(record.encrypted_belnet_value.to_view()); + entry.encrypted_eth_addr_value = oxenc::to_hex(record.encrypted_eth_addr_value.to_view()); entry.expiration_height = record.expiration_height; entry.update_height = record.update_height; entry.txid = tools::type_to_hex(record.txid); @@ -3586,6 +3580,11 @@ namespace cryptonote { namespace rpc { auto bns_value_decrypt_res = invoke(std::move(bns_value_decrypt_req), context); res.wallet_value = bns_value_decrypt_res.value; } + if(!entries.encrypted_eth_addr_value.empty()){ + BNS_VALUE_DECRYPT::request bns_value_decrypt_req{name, "eth_addr", entries.encrypted_eth_addr_value}; + auto bns_value_decrypt_res = invoke(std::move(bns_value_decrypt_req), context); + res.eth_addr_value = bns_value_decrypt_res.value; + } } res.status = STATUS_OK; @@ -3646,6 +3645,7 @@ namespace cryptonote { namespace rpc { entry.encrypted_bchat_value = oxenc::to_hex(record.encrypted_bchat_value.to_view()); entry.encrypted_wallet_value = oxenc::to_hex(record.encrypted_wallet_value.to_view()); entry.encrypted_belnet_value = oxenc::to_hex(record.encrypted_belnet_value.to_view()); + entry.encrypted_eth_addr_value = oxenc::to_hex(record.encrypted_eth_addr_value.to_view()); entry.update_height = record.update_height; entry.expiration_height = record.expiration_height; entry.txid = tools::type_to_hex(record.txid); diff --git a/src/rpc/core_rpc_server_commands_defs.cpp b/src/rpc/core_rpc_server_commands_defs.cpp index eb8d9ad7e63..d71a335e500 100755 --- a/src/rpc/core_rpc_server_commands_defs.cpp +++ b/src/rpc/core_rpc_server_commands_defs.cpp @@ -123,6 +123,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_TRANSACTIONS::extra_entry::bns_details) KV_SERIALIZE(value_bchat) KV_SERIALIZE(value_wallet) KV_SERIALIZE(value_belnet) + KV_SERIALIZE(value_eth_addr) KV_SERIALIZE(owner) KV_SERIALIZE(backup_owner) KV_SERIALIZE_MAP_CODE_END() @@ -256,7 +257,6 @@ KV_SERIALIZE_MAP_CODE_END() KV_SERIALIZE_MAP_CODE_BEGIN(SEND_RAW_TX::request) KV_SERIALIZE(tx_as_hex) KV_SERIALIZE_OPT(do_not_relay, false) - KV_SERIALIZE_OPT(do_sanity_checks, true) KV_SERIALIZE_OPT(flash, false) KV_SERIALIZE_MAP_CODE_END() @@ -1338,6 +1338,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_NAMES_TO_OWNERS::response_entry) KV_SERIALIZE(encrypted_bchat_value) KV_SERIALIZE(encrypted_wallet_value) KV_SERIALIZE(encrypted_belnet_value) + KV_SERIALIZE(encrypted_eth_addr_value) KV_SERIALIZE(update_height) KV_SERIALIZE(expiration_height) KV_SERIALIZE(txid) @@ -1360,6 +1361,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_LOOKUP::response) KV_SERIALIZE(bchat_value) KV_SERIALIZE(wallet_value) KV_SERIALIZE(belnet_value) + KV_SERIALIZE(eth_addr_value) KV_SERIALIZE(update_height) KV_SERIALIZE(expiration_height) KV_SERIALIZE(txid) @@ -1383,6 +1385,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_OWNERS_TO_NAMES::response_entry) KV_SERIALIZE(update_height) KV_SERIALIZE(expiration_height) KV_SERIALIZE(txid) + KV_SERIALIZE(encrypted_eth_addr_value) KV_SERIALIZE_MAP_CODE_END() diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 0b9e38f094a..e6475a12adb 100755 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -313,6 +313,7 @@ namespace rpc { std::optional value_bchat; // The encrypted value of the record, in hex for the bchat. Note that this is encrypted using the actual name itself (*not* the hashed name). std::optional value_wallet; // The encrypted value of the record, in hex for the wallet. Note that this is encrypted using the actual name itself (*not* the hashed name). std::optional value_belnet; // The encrypted value of the record, in hex for the belnet. Note that this is encrypted using the actual name itself (*not* the hashed name). + std::optional value_eth_addr;// The encrypted value of the record, in hex for the belnet. Note that this is encrypted using the actual name itself (*not* the hashed name). std::optional owner; // The owner of this record; this can be a main wallet, wallet subaddress, or a plain public key. std::optional backup_owner; // Backup owner wallet/pubkey of the record, if provided. KV_MAP_SERIALIZABLE @@ -535,7 +536,6 @@ namespace rpc { { std::string tx_as_hex; // Full transaction information as hexidecimal string. bool do_not_relay; // (Optional: Default false) Stop relaying transaction to other nodes. Ignored if `flash` is true. - bool do_sanity_checks; // (Optional: Default true) Verify TX params have sane values. bool flash; // (Optional: Default false) Submit this as a flash tx rather than into the mempool. KV_MAP_SERIALIZABLE @@ -2457,10 +2457,10 @@ namespace rpc { std::string encrypted_bchat_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. std::string encrypted_wallet_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. std::string encrypted_belnet_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. + std::string encrypted_eth_addr_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. uint64_t update_height; // The last height that this Beldex Name Service entry was updated on the Blockchain. std::optional 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. - KV_MAP_SERIALIZABLE }; @@ -2495,6 +2495,7 @@ namespace rpc { std::optional bchat_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. std::optional wallet_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. std::optional belnet_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. + std::optional eth_addr_value; // The encrypted value that the name maps to. See the `BNS_RESOLVE` description for information on how this value can be decrypted. uint64_t update_height; // The last height that this Beldex Name Service entry was updated on the Blockchain. std::optional 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. @@ -2530,10 +2531,10 @@ namespace rpc { std::string encrypted_bchat_value; // The bchat encrypted value that the name maps to, in hex. This value of bchat is encrypted using the name (not the hash) as the secret. std::string encrypted_wallet_value; // The wallet encrypted value that the name maps to, in hex. This value of wallet is encrypted using the name (not the hash) as the secret. std::string encrypted_belnet_value; // The belnet encrypted value that the name maps to, in hex. This value of belnet is encrypted using the name (not the hash) as the secret. + std::string encrypted_eth_addr_value; // The eth_address encrypted value that the name maps to, in hex. This value of eth_address is encrypted using the name (not the hash) as the secret. uint64_t update_height; // The last height that this Beldex Name Service entry was updated on the Blockchain. std::optional 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. - KV_MAP_SERIALIZABLE }; @@ -2571,7 +2572,7 @@ namespace rpc { struct request { - uint16_t type; // The BNS type (mandatory); currently supported values are: 0 = bchat, 1 = wallet, 2 = belnet. + uint16_t type; // The BNS type (mandatory); currently supported values are: 0 = bchat, 1 = wallet, 2 = belnet. 6=eth_addr 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 diff --git a/src/rpc/http_server.cpp b/src/rpc/http_server.cpp index 1378396cd14..4ad5d6d67c1 100755 --- a/src/rpc/http_server.cpp +++ b/src/rpc/http_server.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "common/command_line.h" #include "common/string_util.h" #include "cryptonote_config.h" diff --git a/src/serialization/boost_std_variant.h b/src/serialization/boost_std_variant.h index dd150d24b28..13b95fbddd5 100755 --- a/src/serialization/boost_std_variant.h +++ b/src/serialization/boost_std_variant.h @@ -5,7 +5,7 @@ // interchangeable). // -#include +#include #include diff --git a/src/serialization/variant.h b/src/serialization/variant.h index 1dcf6b29451..d43460299a8 100755 --- a/src/serialization/variant.h +++ b/src/serialization/variant.h @@ -36,7 +36,7 @@ */ #pragma once -#include +#include #include "serialization.h" #include "common/meta.h" diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 1c7fb0db9cc..6e3ae925061 100755 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -255,11 +255,11 @@ namespace const char* USAGE_REQUEST_STAKE_UNLOCK("request_stake_unlock "); const char* USAGE_PRINT_LOCKED_STAKES("print_locked_stakes [key_images]"); - const char* USAGE_BNS_BUY_MAPPING("bns_buy_mapping [index=[,,...]] [] [years=1y|2y|5y|10y] [owner=] [backup_owner=] [bchat_id=] [belnet_id=] [address=] "); + const char* USAGE_BNS_BUY_MAPPING("bns_buy_mapping [index=[,,...]] [] [years=1y|2y|5y|10y] [owner=] [backup_owner=] [bchat_id=] [belnet_id=] [address=] [eth=] "); const char* USAGE_BNS_RENEW_MAPPING("bns_renew_mapping [index=[,,...]] [] [years=1y|2y|5y|10y] "); - const char* USAGE_BNS_UPDATE_MAPPING("bns_update_mapping [index=[,,...]] [] [owner=] [backup_owner=] [bchat_id=] [belnet_id=] [address=] [signature=] "); + const char* USAGE_BNS_UPDATE_MAPPING("bns_update_mapping [index=[,,...]] [] [owner=] [backup_owner=] [bchat_id=] [belnet_id=] [address=] [eth=] [signature=] "); - const char* USAGE_BNS_ENCRYPT("bns_encrypt [type=bchat|wallet|belnet] ||||"); + const char* USAGE_BNS_ENCRYPT("bns_encrypt [type=bchat|wallet|belnet|eth_addr] ||||||"); const char* USAGE_BNS_MAKE_UPDATE_MAPPING_SIGNATURE("bns_make_update_mapping_signature [owner=] [backup_owner=] "); const char* USAGE_BNS_BY_OWNER("bns_by_owner [ ...]"); const char* USAGE_BNS_LOOKUP("bns_lookup [ ...]"); @@ -6329,11 +6329,6 @@ bool simple_wallet::query_locked_stakes(bool print_result, bool print_key_images crypto::key_image key_image; for (const auto& entry : response) { - if (first) - first = false; - else - msg_buf += "\n"; - if (!tools::hex_to_type(entry.key_image, key_image)) { fail_msg_writer() << tr("Failed to parse hex representation of key image: ") << entry.key_image; @@ -6343,6 +6338,11 @@ bool simple_wallet::query_locked_stakes(bool print_result, bool print_key_images if (!m_wallet->contains_key_image(key_image)) continue; + if (first) + first = false; + else + msg_buf += "\n"; + has_locked_stakes = true; if (!print_result) continue; @@ -6400,6 +6400,8 @@ static std::optional guess_bns_type(tools::wallet2& wallet, s return bns::mapping_type::belnet; if (tools::ends_with(name, ".bdx") && tools::starts_with(value, "bd") && value.length() == 2*bns::BCHAT_PUBLIC_KEY_BINARY_LENGTH) return bns::mapping_type::bchat; + if (tools::ends_with(name, ".bdx") && tools::starts_with(value, "0x") && value.substr(2).size() == 2*bns::ETH_ADDR_BINARY_LENGTH) + return bns::mapping_type::eth_addr; if (cryptonote::is_valid_address(std::string{value}, wallet.nettype())) return bns::mapping_type::wallet; @@ -6463,6 +6465,7 @@ static constexpr auto BNS_VALUE_PREFIX = "value="sv; static constexpr auto BNS_VALUE_BCHAT_PREFIX = "bchat_id="sv; static constexpr auto BNS_VALUE_WALLET_PREFIX = "address="sv; static constexpr auto BNS_VALUE_BELNET_PREFIX = "belnet_id="sv; +static constexpr auto BNS_VALUE_ETH_ADDR_PREFIX = "eth="sv; static constexpr auto BNS_SIGNATURE_PREFIX = "signature="sv; static char constexpr NULL_STR[] = "(none)"; @@ -6473,9 +6476,9 @@ bool simple_wallet::bns_buy_mapping(std::vector args) std::set subaddr_indices = {}; if (!parse_subaddr_indices_and_priority(*m_wallet, args, subaddr_indices, priority, m_current_subaddress_account)) return false; - auto [owner, backup_owner,value_bchat,value_wallet,value_belnet,map_years] = eat_named_arguments(args, BNS_OWNER_PREFIX, BNS_BACKUP_OWNER_PREFIX,BNS_VALUE_BCHAT_PREFIX,BNS_VALUE_WALLET_PREFIX,BNS_VALUE_BELNET_PREFIX, BNS_YEAR_PREFIX); + auto [owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, map_years] = eat_named_arguments(args, BNS_OWNER_PREFIX, BNS_BACKUP_OWNER_PREFIX, BNS_VALUE_BCHAT_PREFIX, BNS_VALUE_WALLET_PREFIX, BNS_VALUE_BELNET_PREFIX, BNS_VALUE_ETH_ADDR_PREFIX, BNS_YEAR_PREFIX); - if (args.size() != 1 || (value_bchat.empty() && value_wallet.empty() && value_belnet.empty())) + if (args.size() != 1 || (value_bchat.empty() && value_wallet.empty() && value_belnet.empty() && value_eth_addr.empty())) { PRINT_USAGE(USAGE_BNS_BUY_MAPPING); return true; @@ -6507,6 +6510,9 @@ bool simple_wallet::bns_buy_mapping(std::vector args) } } } + + std::transform(value_eth_addr.begin(), value_eth_addr.end(), value_eth_addr.begin(), + [](unsigned char c){ return std::tolower(c); }); try { @@ -6517,6 +6523,7 @@ bool simple_wallet::bns_buy_mapping(std::vector args) value_bchat.size() ? &value_bchat : nullptr, value_wallet.size() ? &value_wallet : nullptr, value_belnet.size() ? &value_belnet : nullptr, + value_eth_addr.size() ? &value_eth_addr : nullptr, &reason, priority, m_current_subaddress_account, @@ -6545,6 +6552,7 @@ bool simple_wallet::bns_buy_mapping(std::vector args) fmt::print(fmt::format(tr("Value bchat : {}\n"), value_bchat.empty() ? "(none)" : value_bchat)); fmt::print(fmt::format(tr("Value wallet : {}\n"), value_wallet.empty() ? "(none)" : value_wallet)); fmt::print(fmt::format(tr("Value belnet : {}\n"), value_belnet.empty() ? "(none)" : value_belnet)); + fmt::print(fmt::format(tr("Value ethAddr: {}\n"), value_eth_addr.empty() ? "(none)" : value_eth_addr)); fmt::print(fmt::format(tr("Owner : {}\n"), owner.empty() ? m_wallet->get_subaddress_as_str({m_current_subaddress_account, 0}) + " (this wallet) " : owner)); if(backup_owner.size()) { @@ -6664,7 +6672,7 @@ bool simple_wallet::bns_update_mapping(std::vector args) if (!parse_subaddr_indices_and_priority(*m_wallet, args, subaddr_indices, priority, m_current_subaddress_account)) return false; - auto [owner, backup_owner, value_bchat, value_wallet, value_belnet, signature] = eat_named_arguments(args, BNS_OWNER_PREFIX, BNS_BACKUP_OWNER_PREFIX, BNS_VALUE_BCHAT_PREFIX, BNS_VALUE_WALLET_PREFIX, BNS_VALUE_BELNET_PREFIX, BNS_SIGNATURE_PREFIX); + auto [owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, signature] = eat_named_arguments(args, BNS_OWNER_PREFIX, BNS_BACKUP_OWNER_PREFIX, BNS_VALUE_BCHAT_PREFIX, BNS_VALUE_WALLET_PREFIX, BNS_VALUE_BELNET_PREFIX, BNS_VALUE_ETH_ADDR_PREFIX, BNS_SIGNATURE_PREFIX); if (args.size() != 1) { PRINT_USAGE(USAGE_BNS_UPDATE_MAPPING); @@ -6694,12 +6702,16 @@ bool simple_wallet::bns_update_mapping(std::vector args) } } + std::transform(value_eth_addr.begin(), value_eth_addr.end(), value_eth_addr.begin(), + [](unsigned char c){ return std::tolower(c); }); + try { ptx_vector = m_wallet->bns_create_update_mapping_tx(name, value_bchat.size() ? &value_bchat : nullptr, value_wallet.size() ? &value_wallet : nullptr, value_belnet.size() ? &value_belnet : nullptr, + value_eth_addr.size() ? &value_eth_addr : nullptr, owner.size() ? &owner : nullptr, backup_owner.size() ? &backup_owner : nullptr, signature.size() ? &signature : nullptr, @@ -6737,6 +6749,14 @@ bool simple_wallet::bns_update_mapping(std::vector args) fail_msg_writer() << tr("invalid BNS data returned from beldexd"); return true; } + + auto &enc_eth_hex = response[0].encrypted_eth_addr_value; + if (!oxenc::is_hex(enc_eth_hex) || enc_eth_hex.size() > 2 * bns::mapping_value::BUFFER_SIZE) + { + LOG_ERROR("invalid BNS data returned from beldexd"); + fail_msg_writer() << tr("invalid BNS data returned from beldexd"); + return true; + } //BCHAT bns::mapping_value bchat{}; @@ -6786,6 +6806,22 @@ bool simple_wallet::bns_update_mapping(std::vector args) } } + //ETH_ADDRESS + bns::mapping_value eth_addr{}; + { + if (!enc_eth_hex.empty()) + { + eth_addr.len = enc_eth_hex.size() / 2; + eth_addr.encrypted = true; + oxenc::from_hex(enc_eth_hex.begin(), enc_eth_hex.end(), eth_addr.buffer.begin()); + if (!eth_addr.decrypt(tools::lowercase_ascii_string(name), bns::mapping_type::eth_addr)) + { + fail_msg_writer() << "Failed to decrypt the mapping value=" << enc_eth_hex; + return false; + } + } + } + std::vector dsts; cryptonote::address_parse_info info = {}; info.address = m_wallet->get_subaddress({m_current_subaddress_account, 0}); @@ -6796,56 +6832,66 @@ bool simple_wallet::bns_update_mapping(std::vector args) << tr("Updating Beldex Name System Record") << std::endl << std::endl; - fmt::print(fmt::format(tr("Name : {}\n"), name)); + fmt::print(fmt::format(tr("Name : {}\n"), name)); if (value_bchat.size()) { - fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value bchat : {}\n"), !enc_bchat_hex.empty() ? bchat.to_readable_value(m_wallet->nettype(), bns::mapping_type::bchat) : "(none)")); - fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value bchat : {}\n"), value_bchat)); + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value bchat : {}\n"), !enc_bchat_hex.empty() ? bchat.to_readable_value(m_wallet->nettype(), bns::mapping_type::bchat) : "(none)")); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value bchat : {}\n"), value_bchat)); } else { - fmt::print(fmt::format(tr("Value bchat : {} (unchanged)\n"), !enc_bchat_hex.empty() ? bchat.to_readable_value(m_wallet->nettype(), bns::mapping_type::bchat) : "(none)")); + fmt::print(fmt::format(tr("Value bchat : {} (unchanged)\n"), !enc_bchat_hex.empty() ? bchat.to_readable_value(m_wallet->nettype(), bns::mapping_type::bchat) : "(none)")); } if (value_wallet.size()) { - fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value wallet : {}\n"), !enc_wallet_hex.empty() ? wallet.to_readable_value(m_wallet->nettype(), bns::mapping_type::wallet) : "(none)")); - fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value wallet : {}\n"), value_wallet)); + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value wallet : {}\n"), !enc_wallet_hex.empty() ? wallet.to_readable_value(m_wallet->nettype(), bns::mapping_type::wallet) : "(none)")); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value wallet : {}\n"), value_wallet)); } else { - fmt::print(fmt::format(tr("Value wallet : {} (unchanged)\n"), !enc_wallet_hex.empty() ? wallet.to_readable_value(m_wallet->nettype(), bns::mapping_type::wallet) : "(none)")); + fmt::print(fmt::format(tr("Value wallet : {} (unchanged)\n"), !enc_wallet_hex.empty() ? wallet.to_readable_value(m_wallet->nettype(), bns::mapping_type::wallet) : "(none)")); } if (value_belnet.size()) { - fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value belnet : {}\n"), !enc_belnet_hex.empty() ? belnet.to_readable_value(m_wallet->nettype(), bns::mapping_type::belnet) : "(none)")); - fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value belnet : {}\n"), value_belnet)); + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value belnet : {}\n"), !enc_belnet_hex.empty() ? belnet.to_readable_value(m_wallet->nettype(), bns::mapping_type::belnet) : "(none)")); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value belnet : {}\n"), value_belnet)); } else { - fmt::print(fmt::format(tr("Value belnet : {} (unchanged)\n"), !enc_belnet_hex.empty() ? belnet.to_readable_value(m_wallet->nettype(), bns::mapping_type::belnet) : "(none)")); + fmt::print(fmt::format(tr("Value belnet : {} (unchanged)\n"), !enc_belnet_hex.empty() ? belnet.to_readable_value(m_wallet->nettype(), bns::mapping_type::belnet) : "(none)")); + } + + if (value_eth_addr.size()) + { + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Value ethAddr : {}\n"), !enc_eth_hex.empty() ? eth_addr.to_readable_value(m_wallet->nettype(), bns::mapping_type::eth_addr) : "(none)")); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Value ethAddr : {}\n"), value_eth_addr)); + } + else + { + fmt::print(fmt::format(tr("Value ethAddr : {} (unchanged)\n"), !enc_eth_hex.empty() ? eth_addr.to_readable_value(m_wallet->nettype(), bns::mapping_type::eth_addr) : "(none)")); } if (owner.size()) { - fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Owner : {}\n"), response[0].owner)); - fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Owner : {}\n"), owner)); + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Owner : {}\n"), response[0].owner)); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Owner : {}\n"), owner)); } else { - fmt::print(fmt::format(tr("Owner : {} (unchanged)\n"), response[0].owner)); + fmt::print(fmt::format(tr("Owner : {} (unchanged)\n"), response[0].owner)); } if (backup_owner.size()) { - fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Backup Owner : {}\n"), response[0].backup_owner.value_or(NULL_STR))); - fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Backup Owner : {}\n"), backup_owner)); + fmt::print(fmt::fg(fmt::color::red),fmt::format(tr("Old Backup Owner : {}\n"), response[0].backup_owner.value_or(NULL_STR))); + fmt::print(fmt::fg(fmt::color::light_green),fmt::format(tr("New Backup Owner : {}\n"), backup_owner)); } else { - fmt::print(fmt::format(tr("Backup Owner : {} (unchanged)\n"), response[0].backup_owner.value_or(NULL_STR))); + fmt::print(fmt::format(tr("Backup Owner : {} (unchanged)\n"), response[0].backup_owner.value_or(NULL_STR))); } if (value_bchat.size() && (value_bchat == bchat.to_readable_value(m_wallet->nettype(), bns::mapping_type::bchat))) @@ -6860,6 +6906,10 @@ bool simple_wallet::bns_update_mapping(std::vector args) if (!confirmAction()) return false; + if (value_eth_addr.size() && (value_eth_addr == eth_addr.to_readable_value(m_wallet->nettype(), bns::mapping_type::eth_addr))) + if (!confirmAction()) + return false; + if (!confirm_and_send_tx(dsts, ptx_vector, false /*flash*/)) return false; @@ -6982,6 +7032,7 @@ bool simple_wallet::bns_make_update_mapping_signature(std::vector a nullptr, nullptr, nullptr, + nullptr, owner.size() ? &owner : nullptr, backup_owner.size() ? &backup_owner : nullptr, signature_binary, @@ -7043,6 +7094,13 @@ bool simple_wallet::bns_lookup(std::vector args) return false; } + auto& enc_eth_hex = mapping.encrypted_eth_addr_value; + if (mapping.entry_index >= args.size() || !oxenc::is_hex(enc_eth_hex) || enc_eth_hex.size() > 2*bns::mapping_value::BUFFER_SIZE) + { + fail_msg_writer() << "Received invalid BNS mapping data from beldexd"; + return false; + } + // Print any skipped (i.e. not registered) results: for (size_t i = last_index + 1; i < mapping.entry_index; i++) fail_msg_writer() << args[i] << " not found\n"; @@ -7101,6 +7159,23 @@ bool simple_wallet::bns_lookup(std::vector args) } } + //ETH_ADDRESS + bns::mapping_value value_eth{}; + { + if (!enc_eth_hex.empty()) + { + value_eth.len = enc_eth_hex.size() / 2; + value_eth.encrypted = true; + oxenc::from_hex(enc_eth_hex.begin(), enc_eth_hex.end(), value_eth.buffer.begin()); + + if (!value_eth.decrypt(name, bns::mapping_type::eth_addr)) + { + fail_msg_writer() << "Failed to decrypt the mapping eth_value=" << enc_eth_hex; + return false; + } + } + } + auto writer = tools::msg_writer(); writer << fmt::format(fg(fmt::color::sky_blue), " Name : {}", name); @@ -7110,6 +7185,8 @@ bool simple_wallet::bns_lookup(std::vector args) << "\n Value wallet : " << value_wallet.to_readable_value(m_wallet->nettype(), bns::mapping_type::wallet); if(!enc_belnet_hex.empty()) writer << "\n Value belnet : " << value_belnet.to_readable_value(m_wallet->nettype(), bns::mapping_type::belnet); + if(!enc_eth_hex.empty()) writer + << "\n Value ethAddress : " << value_eth.to_readable_value(m_wallet->nettype(), bns::mapping_type::eth_addr); writer << "\n Owner : " << mapping.owner; if (mapping.backup_owner) writer @@ -7124,6 +7201,8 @@ bool simple_wallet::bns_lookup(std::vector args) << "\n Encrypted wallet value : " << (enc_wallet_hex.empty() ? "(none)" :enc_wallet_hex); writer << "\n Encrypted belnet value : " << (enc_belnet_hex.empty() ? "(none)" :enc_belnet_hex); + writer + << "\n Encrypted Eth value : " << (enc_eth_hex.empty() ? "(none)" :enc_eth_hex); writer << "\n"; @@ -7202,7 +7281,7 @@ bool simple_wallet::bns_by_owner(const std::vector& args) for (auto const &entry : rpc) { std::string_view name; - std::string value_bchat, value_wallet, value_belnet; + std::string value_bchat, value_wallet, value_belnet, value_eth; if (auto got = cache.find(entry.name_hash); got != cache.end()) { name = got->second.name; @@ -7230,6 +7309,15 @@ bool simple_wallet::bns_by_owner(const std::vector& args) && mv.decrypt(name, type)) value_belnet = mv.to_readable_value(nettype, type); } + + //ETH_ADDRESS + { + bns::mapping_value mv; + const auto type = bns::mapping_type::eth_addr; + if (bns::mapping_value::validate_encrypted(type, oxenc::from_hex(entry.encrypted_eth_addr_value), &mv) + && mv.decrypt(name, type)) + value_eth = mv.to_readable_value(nettype, type); + } } auto writer = tools::msg_writer(); @@ -7243,6 +7331,8 @@ bool simple_wallet::bns_by_owner(const std::vector& args) << "\n Value wallet : " << value_wallet; if (!value_belnet.empty()) writer << "\n Value belnet : " << value_belnet; + if (!value_eth.empty()) writer + << "\n Value ethAddress : " << value_eth; writer << "\n Owner : " << entry.owner; if (entry.backup_owner) writer @@ -7257,6 +7347,8 @@ bool simple_wallet::bns_by_owner(const std::vector& args) << "\n Encrypted wallet value : " << (entry.encrypted_wallet_value.empty() ? "(none)" : entry.encrypted_wallet_value); writer << "\n Encrypted belnet value : " << (entry.encrypted_belnet_value.empty() ? "(none)" : entry.encrypted_belnet_value); + writer + << "\n Encrypted Eth value : " << (entry.encrypted_eth_addr_value.empty() ? "(none)" : entry.encrypted_eth_addr_value); writer << "\n"; } diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index e720e4f040f..1789589d8da 100755 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -1887,7 +1887,7 @@ bool WalletImpl::bns_validate_years(std::string_view map_years, bns::mapping_yea } EXPORT -PendingTransaction *WalletImpl::createBnsTransaction(std::string& owner, std::string& backup_owner,std::string& mapping_years,std::string &value_bchat,std::string &value_wallet,std::string &value_belnet,std::string &name, +PendingTransaction *WalletImpl::createBnsTransaction(std::string& owner, std::string& backup_owner,std::string& mapping_years,std::string &value_bchat,std::string &value_wallet,std::string &value_belnet, std::string &value_eth_addr, std::string &name, uint32_t priority, uint32_t subaddr_account, std::set subaddr_indices) { @@ -1899,7 +1899,7 @@ PendingTransaction *WalletImpl::createBnsTransaction(std::string& owner, std::st do { auto w = wallet(); - if(value_bchat.empty() && value_wallet.empty() && value_belnet.empty()){ + if(value_bchat.empty() && value_wallet.empty() && value_belnet.empty() && value_eth_addr.empty()){ setStatusError(tr("Value must be atleast one")); break; } @@ -1923,6 +1923,7 @@ PendingTransaction *WalletImpl::createBnsTransaction(std::string& owner, std::st value_bchat.size() ? &value_bchat : nullptr, value_wallet.size() ? &value_wallet : nullptr, value_belnet.size() ? &value_belnet : nullptr, + value_eth_addr.size() ? &value_eth_addr : nullptr, &reason, priority, subaddr_account, @@ -2013,7 +2014,7 @@ PendingTransaction *WalletImpl::createBnsTransaction(std::string& owner, std::st } EXPORT -PendingTransaction *WalletImpl::bnsUpdateTransaction(std::string& owner, std::string& backup_owner,std::string &value_bchat,std::string &value_wallet,std::string &value_belnet,std::string &name, +PendingTransaction *WalletImpl::bnsUpdateTransaction(std::string& owner, std::string& backup_owner,std::string &value_bchat,std::string &value_wallet,std::string &value_belnet, std::string &value_eth_addr, std::string &name, uint32_t priority, uint32_t subaddr_account, std::set subaddr_indices) { @@ -2039,6 +2040,7 @@ PendingTransaction *WalletImpl::bnsUpdateTransaction(std::string& owner, std::st value_bchat.size() ? &value_bchat : nullptr, value_wallet.size() ? &value_wallet : nullptr, value_belnet.size() ? &value_belnet : nullptr, + value_eth_addr.size() ? &value_eth_addr : nullptr, owner.size() ? &owner : nullptr, backup_owner.size() ? &backup_owner : nullptr, nullptr, @@ -2313,7 +2315,7 @@ std::vector* WalletImpl::MyBns() const for (auto const &entry : rpc) { std::string_view name; - std::string value_bchat, value_wallet, value_belnet; + std::string value_bchat, value_wallet, value_belnet, value_eth_addr; if (auto got = cache.find(entry.name_hash); got != cache.end()) { name = got->second.name; @@ -2325,6 +2327,14 @@ std::vector* WalletImpl::MyBns() const && mv.decrypt(name, type)) value_bchat = mv.to_readable_value(nettype, type); } + //ETH_ADDRESS + { + bns::mapping_value mv; + const auto type = bns::mapping_type::eth_addr; + if (bns::mapping_value::validate_encrypted(type, oxenc::from_hex(entry.encrypted_eth_addr_value), &mv) + && mv.decrypt(name, type)) + value_eth_addr = mv.to_readable_value(nettype, type); + } //WALLET { bns::mapping_value mv; @@ -2348,6 +2358,7 @@ std::vector* WalletImpl::MyBns() const info.value_bchat = value_bchat.empty() ? "(none)" : value_bchat; info.value_wallet = value_wallet.empty() ? "(none)" : value_wallet; info.value_belnet = value_belnet.empty() ? "(none)" : value_belnet; + info.value_eth_addr = value_eth_addr.empty() ? "(none)" : value_eth_addr; info.owner = entry.owner; info.backup_owner = entry.backup_owner? *entry.backup_owner : "(none)"; info.update_height = entry.update_height; @@ -2355,6 +2366,7 @@ std::vector* WalletImpl::MyBns() const info.encrypted_bchat_value = entry.encrypted_bchat_value.empty() ? "(none)" : entry.encrypted_bchat_value; info.encrypted_wallet_value = entry.encrypted_wallet_value.empty() ? "(none)" : entry.encrypted_wallet_value; info.encrypted_belnet_value = entry.encrypted_belnet_value.empty() ? "(none)" : entry.encrypted_belnet_value; + info.encrypted_eth_addr_value = entry.encrypted_eth_addr_value.empty() ? "(none)" : entry.encrypted_eth_addr_value; } } return my_bns; diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index c965f076539..941ef6822d0 100755 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -190,6 +190,7 @@ class WalletImpl : public Wallet std::string &value_bchat, std::string &value_wallet, std::string &value_belnet, + std::string &value_eth_addr, std::string &name, uint32_t priority = 0, uint32_t subaddr_account = 0, @@ -199,6 +200,7 @@ class WalletImpl : public Wallet std::string &value_bchat, std::string &value_wallet, std::string &value_belnet, + std::string &value_eth_addr, std::string &name, uint32_t priority = 0, uint32_t subaddr_account = 0, diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index 14183550ce8..af95cc32369 100755 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -430,9 +430,11 @@ struct bnsInfo{ std::string value_bchat; std::string value_wallet; std::string value_belnet; + std::string value_eth_addr; std::string encrypted_bchat_value; std::string encrypted_wallet_value; std::string encrypted_belnet_value; + std::string encrypted_eth_addr_value; }; /** @@ -899,6 +901,7 @@ struct Wallet * \param value_bchat bchat_id * \param value_wallet wallet address * \param value_belnet belnet_id + * \param value_eth_addr ethereum address * \param name bns name * \param subaddr_account subaddress account from which the input funds are taken * \param subaddr_indices set of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices @@ -911,6 +914,7 @@ struct Wallet std::string &value_bchat, std::string &value_wallet, std::string &value_belnet, + std::string &value_eth_addr, std::string &name, uint32_t priority = 0, uint32_t subaddr_account = 0, @@ -922,6 +926,7 @@ struct Wallet * \param value_bchat bchat_id * \param value_wallet wallet address * \param value_belnet belnet_id + * \param value_eth_addr ethereum address * \param name bns name * \param subaddr_account subaddress account from which the input funds are taken * \param subaddr_indices set of subaddress indices to use for transfer or sweeping. if set empty, all are chosen when sweeping, and one or more are automatically chosen when transferring. after execution, returns the set of actually used indices @@ -933,6 +938,7 @@ struct Wallet std::string& value_bchat, std::string& value_wallet, std::string& value_belnet, + std::string &value_eth_addr, std::string& name, uint32_t priority = 0, uint32_t subaddr_account = 0, diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5e87838fc30..5d4e912513d 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -6930,7 +6930,6 @@ void wallet2::commit_tx(pending_tx& ptx, bool flash) rpc::SEND_RAW_TX::request req{}; req.tx_as_hex = oxenc::to_hex(tx_to_blob(ptx.tx)); req.do_not_relay = false; - req.do_sanity_checks = true; req.flash = flash; rpc::SEND_RAW_TX::response daemon_send_resp{}; bool r = invoke_http(req, daemon_send_resp); @@ -8665,6 +8664,7 @@ struct bns_prepared_args bns::mapping_value encrypted_bchat_value; bns::mapping_value encrypted_wallet_value; bns::mapping_value encrypted_belnet_value; + bns::mapping_value encrypted_eth_addr_value; crypto::hash name_hash; bns::generic_owner owner; bns::generic_owner backup_owner; @@ -8685,6 +8685,7 @@ static bool try_generate_bns_signature(wallet2 const &wallet, std::string const result.encrypted_bchat_value.to_view(), result.encrypted_wallet_value.to_view(), result.encrypted_belnet_value.to_view(), + result.encrypted_eth_addr_value.to_view(), new_owner ? &result.owner : nullptr, new_backup_owner ? &result.backup_owner : nullptr, result.prev_txid); @@ -8705,6 +8706,7 @@ static bns_prepared_args prepare_tx_extra_beldex_name_system_values(wallet2 cons std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, + std::string const *value_eth_addr, std::string const *owner, std::string const *backup_owner, bool make_signature, @@ -8737,6 +8739,18 @@ static bns_prepared_args prepare_tx_extra_beldex_name_system_values(wallet2 cons } } + if (value_eth_addr) + { + if (!bns::mapping_value::validate(wallet.nettype(), bns::mapping_type::eth_addr, *value_eth_addr, &result.encrypted_eth_addr_value, reason)) + return {}; + + if (!result.encrypted_eth_addr_value.encrypt(name, &result.name_hash)) + { + if (reason) *reason = "Fail to encrypt mapping value=" + *value_eth_addr; + return {}; + } + } + if (value_wallet) { if (!bns::mapping_value::validate(wallet.nettype(), bns::mapping_type::wallet, *value_wallet, &result.encrypted_wallet_value, reason)) @@ -8833,6 +8847,7 @@ std::vector wallet2::bns_create_buy_mapping_tx(bns::mapping std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, + std::string const *value_eth_addr, std::string *reason, uint32_t priority, uint32_t account_index, @@ -8840,7 +8855,7 @@ std::vector wallet2::bns_create_buy_mapping_tx(bns::mapping { std::vector response; constexpr bool make_signature = false; - bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, value_bchat, value_wallet, value_belnet, owner, backup_owner, make_signature, bns::bns_tx_type::buy, account_index, reason, &response); + bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, value_bchat, value_wallet, value_belnet,value_eth_addr, owner, backup_owner, make_signature, bns::bns_tx_type::buy, account_index, reason, &response); if (!owner) prepared_args.owner = bns::make_monero_owner(get_subaddress({account_index, 0}), account_index != 0); @@ -8856,6 +8871,7 @@ std::vector wallet2::bns_create_buy_mapping_tx(bns::mapping prepared_args.encrypted_bchat_value.to_string(), prepared_args.encrypted_wallet_value.to_string(), prepared_args.encrypted_belnet_value.to_string(), + prepared_args.encrypted_eth_addr_value.to_string(), prepared_args.prev_txid); add_beldex_name_system_to_tx_extra(extra, entry); @@ -8915,7 +8931,7 @@ std::vector wallet2::bns_create_renewal_tx( ) { constexpr bool make_signature = false; - bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, nullptr, nullptr, nullptr, nullptr, nullptr, make_signature, bns::bns_tx_type::renew, account_index, reason, response); + bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, make_signature, bns::bns_tx_type::renew, account_index, reason, response); if (!prepared_args) return {}; @@ -8952,6 +8968,7 @@ std::vector wallet2::bns_create_update_mapping_tx(std::stri std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, + std::string const *value_eth_addr, std::string const *owner, std::string const *backup_owner, std::string const *signature, @@ -8961,14 +8978,14 @@ std::vector wallet2::bns_create_update_mapping_tx(std::stri std::set subaddr_indices, std::vector *response) { - if (!value_bchat && !value_wallet && !value_belnet && !owner && !backup_owner) + if (!value_bchat && !value_wallet && !value_belnet && !value_eth_addr && !owner && !backup_owner) { - if (reason) *reason = "Value_bchat, Value_wallet, Value_belnet, owner and backup owner are not specified. Atleast one field must be specified for updating the BNS record"; + if (reason) *reason = "Value_bchat, Value_wallet, Value_belnet, value_eth_addr, owner and backup owner are not specified. Atleast one field must be specified for updating the BNS record"; return {}; } bool make_signature = signature == nullptr; - bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, value_bchat, value_wallet, value_belnet, owner, backup_owner, make_signature, bns::bns_tx_type::update, account_index, reason, response); + bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, priority, name, value_bchat, value_wallet, value_belnet, value_eth_addr, owner, backup_owner, make_signature, bns::bns_tx_type::update, account_index, reason, response); if (!prepared_args) return {}; if (!make_signature) @@ -8986,6 +9003,7 @@ std::vector wallet2::bns_create_update_mapping_tx(std::stri prepared_args.encrypted_bchat_value.to_view(), prepared_args.encrypted_wallet_value.to_view(), prepared_args.encrypted_belnet_value.to_view(), + prepared_args.encrypted_eth_addr_value.to_view(), owner ? &prepared_args.owner : nullptr, backup_owner ? &prepared_args.backup_owner : nullptr, prepared_args.prev_txid); @@ -9038,6 +9056,7 @@ bool wallet2::bns_make_update_mapping_signature(std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, + std::string const *value_eth_addr, std::string const *owner, std::string const *backup_owner, bns::generic_signature &signature, @@ -9046,7 +9065,7 @@ bool wallet2::bns_make_update_mapping_signature(std::string name, { std::vector response; constexpr bool make_signature = true; - bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, tx_priority_unimportant, name, value_bchat, value_wallet, value_belnet, owner, backup_owner, make_signature, bns::bns_tx_type::update, account_index, reason, &response); + bns_prepared_args prepared_args = prepare_tx_extra_beldex_name_system_values(*this, tx_priority_unimportant, name, value_bchat, value_wallet, value_belnet, value_eth_addr, owner, backup_owner, make_signature, bns::bns_tx_type::update, account_index, reason, &response); if (!prepared_args) return false; if (prepared_args.prev_txid == crypto::null_hash) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 749ffa128b9..2b4ea021116 100755 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1399,17 +1399,17 @@ namespace tools // nullptr). std::optional bns_validate_years(std::string_view map_years, std::string *reason); - std::vector bns_create_buy_mapping_tx(bns::mapping_years mapping_years, std::string const *owner, std::string const *backup_owner, std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set subaddr_indices = {}); + std::vector bns_create_buy_mapping_tx(bns::mapping_years mapping_years, std::string const *owner, std::string const *backup_owner, std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, std::string const *value_eth_addr, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set 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 bns_create_update_mapping_tx(std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, 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 subaddr_indices = {}, std::vector *response = {}); + std::vector bns_create_update_mapping_tx(std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, std::string const *value_eth_addr, 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 subaddr_indices = {}, std::vector *response = {}); // BNS renewal (for belnet registrations, not for bchat/wallet) std::vector bns_create_renewal_tx(bns::mapping_years map_years, std::string name, std::string *reason, uint32_t priority = 0, uint32_t account_index = 0, std::set subaddr_indices = {}, std::vector *response = {}); // Generate just the signature required for putting into bns_update_mapping command in the wallet - bool bns_make_update_mapping_signature(std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, std::string const *owner, std::string const *backup_owner, bns::generic_signature &signature, uint32_t account_index = 0, std::string *reason = nullptr); + bool bns_make_update_mapping_signature(std::string name, std::string const *value_bchat, std::string const *value_wallet, std::string const *value_belnet, std::string const *value_eth_addr, std::string const *owner, std::string const *backup_owner, bns::generic_signature &signature, uint32_t account_index = 0, std::string *reason = nullptr); void freeze(size_t idx); void thaw(size_t idx); diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index aeeddd1e909..02bd6d9d8f9 100755 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -3117,10 +3117,8 @@ namespace { BNS_BUY_MAPPING::response res{}; std::string reason; - - if(req.value_bchat.empty() && req.value_wallet.empty() && req.value_belnet.empty()) - throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid Values : required atleast one of the {value_bchat, value_wallet, value_belnet}"}; - + if(req.value_bchat.empty() && req.value_wallet.empty() && req.value_belnet.empty() && req.value_eth_addr.empty()) + throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid Values : required atleast one of the {value_bchat, value_wallet, value_belnet, value_eth_addr}"}; auto map_years = m_wallet->bns_validate_years(req.years, &reason); if (!map_years) throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Invalid BNS buy years: " + reason}; @@ -3132,6 +3130,7 @@ namespace { req.value_bchat.size() ? &req.value_bchat : nullptr, req.value_wallet.size() ? &req.value_wallet : nullptr, req.value_belnet.size() ? &req.value_belnet : nullptr, + req.value_eth_addr.size() ? &req.value_eth_addr : nullptr, &reason, req.priority, req.account_index, @@ -3209,6 +3208,7 @@ namespace { req.value_bchat.empty() ? nullptr : &req.value_bchat, req.value_wallet.empty() ? nullptr : &req.value_wallet, req.value_belnet.empty() ? nullptr : &req.value_belnet, + req.value_eth_addr.empty() ? nullptr : &req.value_eth_addr, req.owner.empty() ? nullptr : &req.owner, req.backup_owner.empty() ? nullptr : &req.backup_owner, req.signature.empty() ? nullptr : &req.signature, @@ -3258,6 +3258,7 @@ namespace { nullptr, nullptr, nullptr, + nullptr, req.owner.size() ? &req.owner : nullptr, req.backup_owner.size() ? &req.backup_owner : nullptr, signature, @@ -3335,6 +3336,7 @@ namespace { res_e.encrypted_bchat_value = std::move(rec.encrypted_bchat_value); res_e.encrypted_wallet_value = std::move(rec.encrypted_wallet_value); res_e.encrypted_belnet_value = std::move(rec.encrypted_belnet_value); + res_e.encrypted_eth_addr_value = std::move(rec.encrypted_eth_addr_value); res_e.update_height = rec.update_height; res_e.expiration_height = rec.expiration_height; if (req.include_expired && res_e.expiration_height) @@ -3354,6 +3356,19 @@ namespace { MWARNING("Failed to decrypt BNS value for " << res_e.name << (errmsg.empty() ? ""s : ": " + errmsg)); } + //ETH_ADDR + if (req.decrypt && !res_e.encrypted_eth_addr_value.empty() && oxenc::is_hex(res_e.encrypted_eth_addr_value)) + { + bns::mapping_value value; + const auto type = bns::mapping_type::eth_addr; + std::string errmsg; + if (bns::mapping_value::validate_encrypted(type, oxenc::from_hex(res_e.encrypted_eth_addr_value), &value, &errmsg) + && value.decrypt(res_e.name, type)) + res_e.value_eth_addr = value.to_readable_value(nettype, type); + else + MWARNING("Failed to decrypt BNS value for " << res_e.name << (errmsg.empty() ? ""s : ": " + errmsg)); + } + //WALLET if (req.decrypt && !res_e.encrypted_wallet_value.empty() && oxenc::is_hex(res_e.encrypted_wallet_value)) { diff --git a/src/wallet/wallet_rpc_server_commands_defs.cpp b/src/wallet/wallet_rpc_server_commands_defs.cpp index 017b463c8b5..e843c123085 100755 --- a/src/wallet/wallet_rpc_server_commands_defs.cpp +++ b/src/wallet/wallet_rpc_server_commands_defs.cpp @@ -1146,6 +1146,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_BUY_MAPPING::request) KV_SERIALIZE (value_bchat); KV_SERIALIZE (value_wallet); KV_SERIALIZE (value_belnet); + KV_SERIALIZE (value_eth_addr); KV_SERIALIZE_OPT(account_index, (uint32_t)0); KV_SERIALIZE (subaddr_indices); KV_SERIALIZE_OPT(priority, (uint32_t)0); @@ -1186,6 +1187,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_UPDATE_MAPPING::request) KV_SERIALIZE (value_bchat); KV_SERIALIZE (value_wallet); KV_SERIALIZE (value_belnet); + KV_SERIALIZE (value_eth_addr); KV_SERIALIZE (owner); KV_SERIALIZE (backup_owner); KV_SERIALIZE (signature); @@ -1247,9 +1249,11 @@ KV_SERIALIZE_MAP_CODE_BEGIN(BNS_KNOWN_NAMES::known_record) KV_SERIALIZE(encrypted_bchat_value) KV_SERIALIZE(encrypted_wallet_value) KV_SERIALIZE(encrypted_belnet_value) + KV_SERIALIZE(encrypted_eth_addr_value) KV_SERIALIZE(value_bchat) KV_SERIALIZE(value_wallet) KV_SERIALIZE(value_belnet) + KV_SERIALIZE(value_eth_addr) KV_SERIALIZE(update_height) KV_SERIALIZE(expiration_height) KV_SERIALIZE(expired) diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index d18c6f51789..d1a8dae8848 100755 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -2237,7 +2237,8 @@ For more information on updating and signing see the BNS_UPDATE_MAPPING document std::string name; // The name to purchase via Beldex Name Service std::string value_bchat; // The value of bchat that the name maps to via Beldex Name Service, (i.e. For Bchat: [display name->bchat public key]). std::string value_wallet; // The value of wallet that the name maps to via Beldex Name Service, (i.e, For wallets: [name->wallet address]). - std::string value_belnet; // The value of wallet that the name maps to via Beldex Name Service, (i.e, For Belnet: [name->domain name]). + std::string value_belnet; // The value of belnet that the name maps to via Beldex Name Service, (i.e, For Belnet: [name->domain name]). + std::string value_eth_addr; // The value of Ethereum Address that the name maps to via Beldex Name Service, (i.e, For etha_address: [name->eth_address]). uint32_t account_index; // (Optional) Transfer from this account index. (Defaults to 0) std::set subaddr_indices; // (Optional) Transfer from this set of subaddresses. (Defaults to 0) @@ -2316,6 +2317,7 @@ If signing is performed externally then you must first encrypt the `value` (if b std::string value_bchat; // (Optional): The new value of bchat that the name maps to via Beldex Name Service. If not specified or given the empty string "", then the mapping's value remains unchanged. If using a `signature` then this value bchat (if non-empty) must be already encrypted. std::string value_wallet; // (Optional): The new value of wallet that the name maps to via Beldex Name Service. If not specified or given the empty string "", then the mapping's value remains unchanged. If using a `signature` then this value wallet(if non-empty) must be already encrypted. std::string value_belnet; // (Optional): The new value of belnet that the name maps to via Beldex Name Service. If not specified or given the empty string "", then the mapping's value remains unchanged. If using a `signature` then this value belnet (if non-empty) must be already encrypted. + std::string value_eth_addr;// (Optional): The new value of Ethereum Address that the name maps to via Beldex Name Service. If not specified or given the empty string "", then the mapping's value remains unchanged.If using a `signature` then this value belnet (if non-empty) must be already encrypted. std::string owner; // (Optional): The new owner of the mapping. If not specified or given the empty string "", then the mapping's owner remains unchanged. std::string backup_owner; // (Optional): The new backup owner of the mapping. If not specified or given the empty string "", then the mapping's backup owner remains unchanged. std::string signature; // (Optional): Signature derived using libsodium generichash on {current txid blob, new value blob} of the mapping to update. By default the hash is signed using the wallet's spend key as an ed25519 keypair, if signature is specified. @@ -2414,9 +2416,11 @@ This command is only required if the open wallet is one of the owners of a BNS r std::string encrypted_bchat_value; // The encrypted value of bchat that the name maps to, in hex. std::string encrypted_wallet_value; // The encrypted value of wallet that the name maps to, in hex. std::string encrypted_belnet_value; // The encrypted value of belnet that the name maps to, in hex. + std::string encrypted_eth_addr_value; std::optional value_bchat; // Decrypted value that that name maps to. Only provided if `decrypt: true` was specified in the request. std::optional value_wallet; // Decrypted value that that name maps to. Only provided if `decrypt: true` was specified in the request. std::optional value_belnet; // Decrypted value that that name maps to. Only provided if `decrypt: true` was specified in the request. + std::optional value_eth_addr; uint64_t update_height; // The last height that this Beldex Name Service entry was updated on the Blockchain. std::optional expiration_height; // For records that expire, this will be set to the expiration block height. std::optional expired; // Indicates whether the record has expired. Only included in the response if "include_expired" is specified in the request. diff --git a/tests/core_tests/beldex_tests.cpp b/tests/core_tests/beldex_tests.cpp index 77c6ac99ddf..83c6a6ffa0b 100755 --- a/tests/core_tests/beldex_tests.cpp +++ b/tests/core_tests/beldex_tests.cpp @@ -1075,10 +1075,13 @@ bool beldex_name_system_disallow_reserved_type::generate(std::vector(-1); bns::mapping_years mapping_years; assert(!bns::mapping_type_allowed(gen.hardfork(), unusable_type)); - cryptonote::transaction tx1 = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, "FriendlyName", mapping_value_bchat, mapping_value_wallet, mapping_value_belnet); + cryptonote::transaction tx1 = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, "FriendlyName", mapping_value_bchat, mapping_value_wallet, mapping_value_belnet, mapping_value_eth_addr); gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can't create a BNS TX that requests a BNS type that is unused but reserved by the protocol"); return true; } @@ -1089,6 +1092,7 @@ struct bns_keys_t bns::mapping_value wallet_value; // NOTE: this field is the binary (value) part of the name -> (value) mapping bns::mapping_value belnet_value; bns::mapping_value bchat_value; + bns::mapping_value eth_addr_value; }; static bns_keys_t make_bns_keys(cryptonote::account_base const &src) @@ -1098,7 +1102,7 @@ static bns_keys_t make_bns_keys(cryptonote::account_base const &src) result.bchat_value.len = bns::BCHAT_PUBLIC_KEY_BINARY_LENGTH; result.wallet_value.len = sizeof(src.get_keys().m_account_address); result.belnet_value.len = sizeof(result.owner.wallet.address.m_spend_public_key); - + result.eth_addr_value.len = bns::ETH_ADDR_BINARY_LENGTH; memcpy(&result.bchat_value.buffer[0] + 1, &result.owner.wallet.address.m_spend_public_key, result.belnet_value.len); memcpy(&result.wallet_value.buffer[0], (char *)&src.get_keys().m_account_address, result.wallet_value.len); @@ -1134,7 +1138,7 @@ bool beldex_name_system_expiration::generate(std::vector &even std::string const name = "mydomain.bdx"; if (bns::mapping_type_allowed(gen.hardfork(), mapping_type)) { - cryptonote::transaction tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); gen.create_and_add_next_block({tx}); crypto::hash tx_hash = cryptonote::get_transaction_hash(tx); @@ -1182,7 +1186,7 @@ bool beldex_name_system_expiration::generate(std::vector &even } else { - cryptonote::transaction tx = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction tx = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); gen.add_tx(tx, false /*can_be_added_to_blockchain*/, "Can not add BNS TX that uses disallowed type"); } } @@ -1220,8 +1224,8 @@ bool beldex_name_system_get_mappings_by_owner::generate(std::vector &ev std::string bchat_name1 = "MyName"; crypto::hash bchat_tx_hash; { - cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bchat_name1, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value); + cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bchat_name1, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value, bob_key.eth_addr_value); bchat_tx_hash = cryptonote::get_transaction_hash(tx1); gen.create_and_add_next_block({tx1}); } @@ -1445,7 +1449,7 @@ bool beldex_name_system_handles_duplicate_in_bns_db::generate(std::vector txs; @@ -1453,7 +1457,7 @@ bool beldex_name_system_handles_duplicate_in_bns_db::generate(std::vector(3928); { // NOTE: Allow duplicates with the same name but different type - cryptonote::transaction bar = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value); + cryptonote::transaction bar = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value, bob_key.eth_addr_value); if (bns::mapping_type_allowed(gen.hardfork(), custom_type)) - cryptonote::transaction bar2 = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value); + cryptonote::transaction bar2 = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value, bob_key.eth_addr_value); // NOTE: Make duplicate in the TX pool, this should be rejected - cryptonote::transaction bar4 = gen.create_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value); + cryptonote::transaction bar4 = gen.create_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bchat_name, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value, bob_key.eth_addr_value); gen.add_tx(bar4, false /*can_be_added_to_blockchain*/, "Duplicate name requested by new owner: original already exists in tx pool"); } return true; @@ -1689,20 +1693,20 @@ bool beldex_name_system_large_reorg::generate(std::vector &eve // NOTE: Generate and add the (transactions + block) to the blockchain { std::vector txs; - cryptonote::transaction bchat_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction bchat_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); bchat_tx_hash1 = get_transaction_hash(bchat_tx); txs.push_back(bchat_tx); if (bns::mapping_type_allowed(gen.hardfork(), bns::mapping_type::wallet)) { - cryptonote::transaction wallet_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, wallet_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction wallet_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, wallet_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); txs.push_back(wallet_tx); wallet_tx_hash1 = get_transaction_hash(wallet_tx); } if (bns::mapping_type_allowed(gen.hardfork(), bns::mapping_type::belnet)) { - cryptonote::transaction belnet_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, belnet_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction belnet_tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, belnet_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); txs.push_back(belnet_tx); belnet_tx_hash1 = get_transaction_hash(belnet_tx); } @@ -1747,7 +1751,7 @@ bool beldex_name_system_large_reorg::generate(std::vector &eve crypto::hash bchat_tx_hash2 = {}, belnet_tx_hash2 = {}, bchat_tx_hash3; { std::vector txs; - txs.push_back(gen.create_and_add_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bob_bchat_name1, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value)); + txs.push_back(gen.create_and_add_beldex_name_system_tx(bob, gen.hardfork(), mapping_years, bob_bchat_name1, bob_key.bchat_value, bob_key.wallet_value, bob_key.belnet_value, bob_key.eth_addr_value)); bchat_tx_hash2 = cryptonote::get_transaction_hash(txs[0]); if (bns::mapping_type_allowed(gen.hardfork(), bns::mapping_type::belnet)) @@ -1756,7 +1760,7 @@ bool beldex_name_system_large_reorg::generate(std::vector &eve belnet_tx_hash2 = cryptonote::get_transaction_hash(txs.back()); } - txs.push_back(gen.create_and_add_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &other_key.bchat_value, &other_key.wallet_value, &other_key.belnet_value)); + txs.push_back(gen.create_and_add_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &other_key.bchat_value, &other_key.wallet_value, &other_key.belnet_value, &other_key.eth_addr_value)); bchat_tx_hash3 = cryptonote::get_transaction_hash(txs.back()); gen.create_and_add_next_block(txs); @@ -1884,7 +1888,7 @@ bool beldex_name_system_name_renewal::generate(std::vector &ev bns::mapping_years mapping_years; bns_keys_t miner_key = make_bns_keys(miner); std::string const name = "mydomain.bdx"; - cryptonote::transaction tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction tx = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); gen.create_and_add_next_block({tx}); crypto::hash prev_txid = get_transaction_hash(tx); @@ -2002,6 +2006,14 @@ bool beldex_name_system_name_value_max_lengths::generate(std::vector & crypto::hash bchat_tx_hash1; std::string bchat_name1 = "myname"; { - cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value); + cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, bchat_name1, miner_key.bchat_value, miner_key.wallet_value, miner_key.belnet_value, miner_key.eth_addr_value); bchat_tx_hash1 = cryptonote::get_transaction_hash(tx1); gen.create_and_add_next_block({tx1}); } @@ -2097,13 +2109,13 @@ bool beldex_name_system_update_mapping::generate(std::vector & // Test update mapping with same name fails if (hf() == cryptonote::network_version_16) { - cryptonote::transaction tx1 = gen.create_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &miner_key.bchat_value, &miner_key.wallet_value, &miner_key.belnet_value); + cryptonote::transaction tx1 = gen.create_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &miner_key.bchat_value, &miner_key.wallet_value, &miner_key.belnet_value, &miner_key.eth_addr_value); gen.add_tx(tx1, false /*can_be_added_to_blockchain*/, "Can not add a BNS TX that re-updates the underlying value to same value"); } crypto::hash bchat_tx_hash2; { - cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &bob_key.bchat_value, &bob_key.wallet_value, &bob_key.belnet_value); + cryptonote::transaction tx1 = gen.create_and_add_beldex_name_system_tx_update(miner, gen.hardfork(), bns::mapping_type::bchat, bchat_name1, &bob_key.bchat_value, &bob_key.wallet_value, &bob_key.belnet_value, &bob_key.eth_addr_value); bchat_tx_hash2 = cryptonote::get_transaction_hash(tx1); gen.create_and_add_next_block({tx1}); } @@ -2166,7 +2178,7 @@ bool beldex_name_system_update_mapping_multiple_owners::generate(std::vector &even } bns_keys_t ons_keys = make_bns_keys(miner); - bns::mapping_type const types[] = {bns::mapping_type::bchat, bns::mapping_type::wallet, bns::mapping_type::belnet}; + bns::mapping_type const types[] = {bns::mapping_type::bchat, bns::mapping_type::wallet, bns::mapping_type::belnet, bns::mapping_type::eth_addr}; for (int i = 0; i < 2; i++) { bool under_burn = (i == 0); @@ -2521,6 +2533,7 @@ bool beldex_name_system_wrong_burn::generate(std::vector &even bns::mapping_value value_bchat = {}; bns::mapping_value value_wallet = {}; bns::mapping_value value_belnet = {}; + bns::mapping_value value_eth_addr = {}; std::string name; if (type == bns::mapping_type::bchat) @@ -2538,6 +2551,11 @@ bool beldex_name_system_wrong_burn::generate(std::vector &even value_belnet = ons_keys.belnet_value; name = "myfriendlybelnetname.bdx"; } + else if (type == bns::mapping_type::eth_addr) + { + value_eth_addr = ons_keys.eth_addr_value; + name = "myfriendlybelnetname.bdx"; + } else assert("Unhandled type enum" == nullptr); @@ -2547,7 +2565,7 @@ bool beldex_name_system_wrong_burn::generate(std::vector &even if (under_burn) burn -= 1; else burn += 1; - cryptonote::transaction tx = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, value_bchat, value_wallet, value_belnet, nullptr /*owner*/, nullptr /*backup_owner*/, burn); + cryptonote::transaction tx = gen.create_beldex_name_system_tx(miner, gen.hardfork(), mapping_years, name, value_bchat, value_wallet, value_belnet, value_eth_addr,nullptr /*owner*/, nullptr /*backup_owner*/, burn); gen.add_tx(tx, false /*can_be_added_to_blockchain*/, "Wrong burn for a BNS tx", false /*kept_by_block*/); } } diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 808446aa05c..87e559c8973 100755 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -336,11 +336,12 @@ beldex_chain_generator::create_and_add_beldex_name_system_tx(cryptonote::account bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, + bns::mapping_value const &value_eth_addr, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, bool kept_by_block) { - cryptonote::transaction t = create_beldex_name_system_tx(src, hf_version, mapping_years, name, value_bchat, value_wallet, value_belnet, owner, backup_owner); + cryptonote::transaction t = create_beldex_name_system_tx(src, hf_version, mapping_years, name, value_bchat, value_wallet, value_belnet, value_eth_addr, owner, backup_owner); add_tx(t, true /*can_be_added_to_blockchain*/, ""/*fail_msg*/, kept_by_block); return t; } @@ -353,12 +354,13 @@ beldex_chain_generator::create_and_add_beldex_name_system_tx_update(cryptonote:: bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, + bns::mapping_value const *value_eth_addr, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, bns::generic_signature *signature, bool kept_by_block) { - cryptonote::transaction t = create_beldex_name_system_tx_update(src, hf_version, type, name, value_bchat, value_wallet, value_belnet, owner, backup_owner, signature); + cryptonote::transaction t = create_beldex_name_system_tx_update(src, hf_version, type, name, value_bchat, value_wallet, value_belnet, value_eth_addr, owner, backup_owner, signature); add_tx(t, true /*can_be_added_to_blockchain*/, ""/*fail_msg*/, kept_by_block); return t; } @@ -613,6 +615,7 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx(cry bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, + bns::mapping_value const &value_eth_addr, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, std::optional burn_override) const @@ -651,8 +654,12 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx(cry bool encrypted_belnet = encrypted_belnet_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_16); assert(encrypted_belnet); + bns::mapping_value encrypted_eth_addr_value = value_eth_addr; + bool encrypted_eth_addr = encrypted_eth_addr_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_16); + assert(encrypted_eth_addr); + std::vector extra; - cryptonote::tx_extra_beldex_name_system data = cryptonote::tx_extra_beldex_name_system::make_buy(generic_owner, backup_owner, mapping_years, name_hash, encrypted_bchat_value.to_string(), encrypted_wallet_value.to_string(), encrypted_belnet_value.to_string(), prev_txid); + cryptonote::tx_extra_beldex_name_system data = cryptonote::tx_extra_beldex_name_system::make_buy(generic_owner, backup_owner, mapping_years, name_hash, encrypted_bchat_value.to_string(), encrypted_wallet_value.to_string(), encrypted_belnet_value.to_string(), encrypted_eth_addr_value.to_string(), prev_txid); cryptonote::add_beldex_name_system_to_tx_extra(extra, data); cryptonote::add_burned_amount_to_tx_extra(extra, burn); cryptonote::transaction result = {}; @@ -672,6 +679,7 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx_upd bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, + bns::mapping_value const *value_eth_addr, bns::generic_owner const *owner, bns::generic_owner const *backup_owner, bns::generic_signature *signature, @@ -723,11 +731,23 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx_upd } } + bns::mapping_value encrypted_eth_addr_value = {}; + if (value_eth_addr) + { + encrypted_eth_addr_value = *value_eth_addr; + if (!encrypted_eth_addr_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_eth_addr = encrypted_eth_addr_value.encrypt(lcname, &name_hash, hf_version <= cryptonote::network_version_16); + if (use_asserts) assert(encrypted_eth_addr); + } + } + bns::generic_signature signature_ = {}; if (!signature) { signature = &signature_; - auto data = bns::tx_extra_signature(encrypted_bchat_value.to_view(), encrypted_wallet_value.to_view(), encrypted_belnet_value.to_view(), owner, backup_owner, prev_txid); + auto data = bns::tx_extra_signature(encrypted_bchat_value.to_view(), encrypted_wallet_value.to_view(), encrypted_belnet_value.to_view(), encrypted_eth_addr_value.to_view(), owner, backup_owner, prev_txid); crypto::hash hash{}; if (!data.empty()) crypto_generichash(reinterpret_cast(hash.data), sizeof(hash), reinterpret_cast(data.data()), data.size(), nullptr, 0); @@ -736,7 +756,7 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx_upd } std::vector extra; - cryptonote::tx_extra_beldex_name_system data = cryptonote::tx_extra_beldex_name_system::make_update(*signature, name_hash, encrypted_bchat_value.to_view(), encrypted_wallet_value.to_view(), encrypted_belnet_value.to_view(), owner, backup_owner, prev_txid); + cryptonote::tx_extra_beldex_name_system data = cryptonote::tx_extra_beldex_name_system::make_update(*signature, name_hash, encrypted_bchat_value.to_view(), encrypted_wallet_value.to_view(), encrypted_belnet_value.to_view(), encrypted_eth_addr_value.to_view(), owner, backup_owner, prev_txid); cryptonote::add_beldex_name_system_to_tx_extra(extra, data); cryptonote::block const &head = top().block; @@ -795,7 +815,7 @@ cryptonote::transaction beldex_chain_generator::create_beldex_name_system_tx_ren if (!signature) { signature = &signature_; - auto data = bns::tx_extra_signature(nullptr, nullptr, nullptr, nullptr, nullptr, prev_txid); + auto data = bns::tx_extra_signature(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,prev_txid); crypto::hash hash{}; if (!data.empty()) crypto_generichash(reinterpret_cast(hash.data), sizeof(hash), reinterpret_cast(data.data()), data.size(), nullptr, 0); diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index d27f805001d..d3638c1cb8c 100755 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -1468,8 +1468,8 @@ struct beldex_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_beldex_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bool kept_by_block = false); - cryptonote::transaction create_and_add_beldex_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_type type, std::string const &name, bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bns::generic_signature *signature = nullptr, bool kept_by_block = false); + cryptonote::transaction create_and_add_beldex_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, bns::mapping_value const &value_eth_addr, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bool kept_by_block = false); + cryptonote::transaction create_and_add_beldex_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_type type, std::string const &name, bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, bns::mapping_value const *value_eth_addr, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bns::generic_signature *signature = nullptr, bool kept_by_block = false); cryptonote::transaction create_and_add_beldex_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::generic_signature *signature = nullptr, 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(master_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& voters = {}, uint64_t fee = 0, bool kept_by_block = false); @@ -1493,8 +1493,8 @@ struct beldex_chain_generator // value: Takes the binary value NOT the human readable version, of the name->value mapping static const uint64_t ONS_AUTO_BURN = static_cast(-1); - cryptonote::transaction create_beldex_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, std::optional burn_override = std::nullopt) const; - cryptonote::transaction create_beldex_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_type type, std::string const &name, bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bns::generic_signature *signature = nullptr, bool use_asserts = false) const; + cryptonote::transaction create_beldex_name_system_tx(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::mapping_value const &value_bchat, bns::mapping_value const &value_wallet, bns::mapping_value const &value_belnet, bns::mapping_value const &value_eth_addr, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, std::optional burn_override = std::nullopt) const; + cryptonote::transaction create_beldex_name_system_tx_update(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_type type, std::string const &name, bns::mapping_value const *value_bchat, bns::mapping_value const *value_wallet, bns::mapping_value const *value_belnet, bns::mapping_value const *value_eth_addr, bns::generic_owner const *owner = nullptr, bns::generic_owner const *backup_owner = nullptr, bns::generic_signature *signature = nullptr, bool use_asserts = false) const; cryptonote::transaction create_beldex_name_system_tx_update_w_extra(cryptonote::account_base const &src, uint8_t hf_version, cryptonote::tx_extra_beldex_name_system const &ons_extra) const; cryptonote::transaction create_beldex_name_system_tx_renew(cryptonote::account_base const &src, uint8_t hf_version, bns::mapping_years mapping_years, std::string const &name, bns::generic_signature *signature = nullptr, std::optional burn_override = std::nullopt) const; diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 6d6f420edb9..ecd0447f141 100755 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -615,6 +615,7 @@ TEST_F(WalletTest1, BnsBuyTransaction) std::string value_bchat = ""; std::string value_wallet = ""; std::string value_belnet = "a6iiyy3c4qsp8kdt49ao79dqxskd81eejidhq9j36d8oodznibqy.bdx"; + std::string value_eth_addr = ""; std::string name ="blackpearl.bdx"; Wallet::PendingTransaction * transaction = wallet1->createBnsTransaction(owner, backup_owner, @@ -622,6 +623,49 @@ TEST_F(WalletTest1, BnsBuyTransaction) value_bchat, value_wallet, value_belnet, + value_eth_addr, + name); + ASSERT_TRUE(transaction->good()); + std::cout <<"refresh_started...\n"; + wallet1->refresh(); + std::cout <<"refresh_end...\n"; + ASSERT_TRUE(wallet1->balance(0) == balance); + + ASSERT_TRUE(transaction->commit()); + ASSERT_FALSE(wallet1->balance(0) == balance); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} + +TEST_F(WalletTest1, BnsBuyEthTransaction) +{ + //TODO=Beldex_bns have to check more conditions also the wallet_listener check + + Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET); + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + std::cout <<"Refresh_started...\n"; + ASSERT_TRUE(wallet1->refresh()); + std::cout <<"Refresh_end...\n"; + uint64_t balance = wallet1->balance(0); + std::cout <<"**balance: " << balance << std::endl; + ASSERT_TRUE(wallet1->good()); + + // Change the value based on your datas + std::string owner = Utils::get_wallet_address(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS); + std::string backup_owner = ""; + std::string mapping_years = "1y"; + std::string value_bchat = ""; + std::string value_wallet = ""; + std::string value_belnet = "a6iiyy3c4qsp8kdt49ao79dqxskd81eejidhq9j36d8oodznibqy.bdx"; + std::string value_eth_addr = "0xbBdA8c587De8dC04Abb35de738C04E4413355007"; + std::string name ="toretto.bdx"; + Wallet::PendingTransaction * transaction = wallet1->createBnsTransaction(owner, + backup_owner, + mapping_years, + value_bchat, + value_wallet, + value_belnet, + value_eth_addr, name); ASSERT_TRUE(transaction->good()); std::cout <<"refresh_started...\n"; @@ -654,6 +698,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithNoValues) std::string value_bchat = ""; std::string value_wallet = ""; std::string value_belnet = ""; + std::string value_eth_addr = ""; std::string name ="black.bdx"; Wallet::PendingTransaction * transaction = wallet1->createBnsTransaction(owner, backup_owner, @@ -661,6 +706,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithNoValues) value_bchat, value_wallet, value_belnet, + value_eth_addr, name); Utils::print_status(transaction->status()); ASSERT_FALSE(transaction->good()); @@ -687,6 +733,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithWrongYears) std::string value_bchat = ""; std::string value_wallet = ""; std::string value_belnet = "t9e3s4k9rw4e6fxexycb74wo1guriebnsepfkkfr6s3rpxauncmy.bdx"; + std::string value_eth_addr = ""; std::string name ="black.bdx"; Wallet::PendingTransaction * transaction = wallet1->createBnsTransaction(owner, backup_owner, @@ -694,6 +741,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithWrongYears) value_bchat, value_wallet, value_belnet, + value_eth_addr, name); Utils::print_status(transaction->status()); ASSERT_FALSE(transaction->good()); @@ -720,6 +768,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithOldValue) std::string value_bchat = ""; std::string value_wallet = ""; std::string value_belnet = "a6iiyy3c4qsp8kdt49ao79dqxskd81eejidhq9j36d8oodznibqy.bdx"; + std::string value_eth_addr = ""; std::string name ="blackpearl.bdx"; Wallet::PendingTransaction * transaction = wallet1->createBnsTransaction(owner, backup_owner, @@ -727,6 +776,7 @@ TEST_F(WalletTest1, BnsBuyTransactionWithOldValue) value_bchat, value_wallet, value_belnet, + value_eth_addr, name); ASSERT_TRUE(transaction->good()); std::cout <<"refresh_started...\n"; @@ -759,8 +809,9 @@ TEST_F(WalletTest1, BnsUpdateTransaction) std::string value_bchat = "bd08c9d0c3077a509f159a2d91aa251b69480a3572f2ce60f01f01067b06de9c21"; std::string value_wallet = ""; std::string value_belnet = ""; + std::string value_eth_addr = ""; std::string name ="blackpearl.bdx"; - Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, name); + Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, name); ASSERT_TRUE(transaction->good()); std::cout <<"refresh_started...\n"; wallet1->refresh(); @@ -771,6 +822,38 @@ TEST_F(WalletTest1, BnsUpdateTransaction) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } +TEST_F(WalletTest1, BnsEthUpdateTransaction) + +{ + //TODO=Beldex_bns have to check more conditions also the wallet_listener check + Wallet::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Wallet::NetworkType::TESTNET); + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + std::cout <<"Refresh_started...\n"; + ASSERT_TRUE(wallet1->refresh()); + std::cout <<"Refresh_end...\n"; + uint64_t balance = wallet1->balance(0); + std::cout <<"**balance: " << balance << std::endl; + ASSERT_TRUE(wallet1->good()); + + // Change the value based on your datas + std::string owner = ""; + std::string backup_owner = ""; + std::string value_bchat = "bd08c9d0c3077a509f159a2d91aa251b69480a3572f2ce60f01f01067b06de9c21"; + std::string value_wallet = ""; + std::string value_belnet = ""; + std::string value_eth_addr = "0xa83114A443dA1CecEFC50368531cACE9F37fCCcb"; + std::string name ="toretto.bdx"; + Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, name); + ASSERT_TRUE(transaction->good()); + std::cout <<"refresh_started...\n"; + wallet1->refresh(); + std::cout <<"refresh_end...\n"; + ASSERT_TRUE(wallet1->balance(0) == balance); + ASSERT_TRUE(transaction->commit()); + ASSERT_FALSE(wallet1->balance(0) == balance); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} TEST_F(WalletTest1, BnsUpdateWithSameValue) { @@ -791,8 +874,9 @@ TEST_F(WalletTest1, BnsUpdateWithSameValue) std::string value_bchat = "bd08c9d0c3077a509f159a2d91aa251b69480a3572f2ce60f01f01067b06de9c21"; std::string value_wallet = ""; std::string value_belnet = "fcbzchy4kknz1tq8eb5aiakibyfo7nqg6qxpons46h1qytexfc4y.bdx"; + std::string value_eth_addr = ""; std::string name ="blackpearl.bdx"; - Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, name); + Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, name); ASSERT_TRUE(transaction->good()); std::cout <<"refresh_started...\n"; wallet1->refresh(); @@ -823,8 +907,9 @@ TEST_F(WalletTest1, BnsUpdateWrongValues) std::string value_bchat =""; std::string value_wallet =""; std::string value_belnet ="bd08c9d0c3077a509f159a2d91aa251b69480a3572f2ce60f01f01067b06de9c21"; + std::string value_eth_addr = ""; std::string name ="blackpearl.bdx"; - Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, name); + Wallet::PendingTransaction *transaction = wallet1->bnsUpdateTransaction(owner, backup_owner, value_bchat, value_wallet, value_belnet, value_eth_addr, name); ASSERT_FALSE(transaction->good()); Utils::print_status(transaction->status()); ASSERT_TRUE(wmgr->closeWallet(wallet1)); diff --git a/tests/unit_tests/output_selection.cpp b/tests/unit_tests/output_selection.cpp index 4a5e727c350..89a96d2f9e5 100755 --- a/tests/unit_tests/output_selection.cpp +++ b/tests/unit_tests/output_selection.cpp @@ -115,7 +115,7 @@ TEST(select_outputs, gamma) std::vector offsets; MKOFFSETS(300000, 1); - tools::gamma_picker picker(offsets, cryptonote::network_version_17_POS); + tools::gamma_picker picker(offsets); std::vector ages(100000); double age_scale = 120. * (offsets.size() / (double)n_outs); for (size_t i = 0; i < ages.size(); ) @@ -140,7 +140,7 @@ TEST(select_outputs, density) std::vector offsets; MKOFFSETS(300000, 1 + (crypto::rand() & 0x1f)); - tools::gamma_picker picker(offsets,cryptonote::network_version_17_POS); + tools::gamma_picker picker(offsets); std::vector picks(/*n_outs*/offsets.size(), 0); for (int i = 0; i < NPICKS; ) @@ -183,7 +183,7 @@ TEST(select_outputs, same_distribution) std::vector offsets; MKOFFSETS(300000, 1 + (crypto::rand() & 0x1f)); - tools::gamma_picker picker(offsets, cryptonote::network_version_17_POS); + tools::gamma_picker picker(offsets); std::vector chain_picks(offsets.size(), 0); std::vector output_picks(n_outs, 0); diff --git a/utils/build_scripts/drone-ios-static-upload.sh b/utils/build_scripts/drone-ios-static-upload.sh index 87b965674ef..f52b2a0b83e 100755 --- a/utils/build_scripts/drone-ios-static-upload.sh +++ b/utils/build_scripts/drone-ios-static-upload.sh @@ -1,28 +1,3 @@ -#!/usr/bin/env bash - -# Script used with Drone CI to upload build artifacts (because specifying all this in -# .drone.jsonnet is too painful). - - - -set -o errexit - -if [ -z "$SSH_KEY" ]; then - echo -e "\n\n\n\e[31;1mUnable to upload artifact: SSH_KEY not set\e[0m" - # Just warn but don't fail, so that this doesn't trigger a build failure for untrusted builds - exit 0 -fi - -echo "$SSH_KEY" >ssh_key - -set -o xtrace # Don't start tracing until *after* we write the ssh key - -chmod 600 ssh_key - -branch_or_tag=${DRONE_BRANCH:-${DRONE_TAG:-unknown}} - -upload_to="beldex.rocks/${DRONE_REPO// /_}/${branch_or_tag// /_}" - tmpdir=ios-deps-${DRONE_COMMIT} mkdir -p $tmpdir/lib mkdir -p $tmpdir/include @@ -45,14 +20,4 @@ for p in "${upload_dirs[@]}"; do dir_tmp="$dir_tmp$p/" mkdirs="$mkdirs -mkdir $dir_tmp" -done - -sftp -i ssh_key -b - -o StrictHostKeyChecking=off drone@beldex.rocks <