From 6fcfd0b8babd47c04cbf284f6a4289d619496547 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 10 Feb 2022 14:25:55 -0400 Subject: [PATCH] Update oxenmq to latest oxen-mq+oxen-encoding All the encoding parts move to oxen-encoding recently; this updates to the latest version of oxen-mq, adds oxen-encoding, and converts everything to use oxenc headers rather than the oxenmq compatibility shims. --- .gitmodules | 3 ++ external/CMakeLists.txt | 11 +++++ external/loki-mq | 2 +- external/oxen-encoding | 1 + src/blockchain_utilities/sn_key_tool.cpp | 48 +++++++++---------- src/common/hex.h | 8 ++-- .../cryptonote_format_utils.cpp | 8 ++-- src/cryptonote_basic/miner.cpp | 6 +-- src/cryptonote_core/cryptonote_core.cpp | 4 +- src/cryptonote_core/cryptonote_tx_utils.cpp | 4 +- src/cryptonote_core/oxen_name_system.cpp | 44 ++++++++--------- src/cryptonote_core/oxen_name_system.h | 4 +- src/cryptonote_core/pulse.cpp | 4 +- src/cryptonote_core/service_node_list.cpp | 6 +-- src/cryptonote_core/uptime_proof.cpp | 12 ++--- src/cryptonote_core/uptime_proof.h | 5 +- .../cryptonote_protocol_handler.inl | 8 ++-- src/cryptonote_protocol/quorumnet.cpp | 23 +++++---- src/daemon/rpc_command_executor.cpp | 10 ++-- src/debug_utilities/cn_deserialize.cpp | 10 ++-- src/device/device_ledger.cpp | 6 +-- src/device/io_hid.cpp | 2 +- src/device/log.cpp | 6 +-- src/device_trezor/trezor/transport.cpp | 4 +- src/rpc/core_rpc_server.cpp | 32 ++++++------- src/rpc/http_server.cpp | 1 - src/rpc/http_server_base.cpp | 10 ++-- src/rpc/lmq_server.cpp | 4 +- src/serialization/json_archive.h | 4 +- src/simplewallet/simplewallet.cpp | 20 ++++---- src/wallet/api/pending_transaction.cpp | 2 +- src/wallet/api/wallet.cpp | 6 +-- src/wallet/message_store.cpp | 2 +- src/wallet/wallet2.cpp | 38 +++++++-------- src/wallet/wallet_rpc_server.cpp | 28 +++++------ tests/core_proxy/core_proxy.cpp | 2 +- ...ransactions_generation_from_blockchain.cpp | 2 +- tests/io.h | 6 +-- tests/unit_tests/serialization.cpp | 22 ++++----- 39 files changed, 219 insertions(+), 199 deletions(-) create mode 160000 external/oxen-encoding diff --git a/.gitmodules b/.gitmodules index 7b68e772d..4188e9528 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "external/SQLiteCpp"] path = external/SQLiteCpp url = https://github.com/SRombauts/SQLiteCpp +[submodule "external/oxen-encoding"] + path = external/oxen-encoding + url = https://github.com/oxen-io/oxen-encoding.git diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index b05f46f26..8f6653366 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -45,6 +45,7 @@ if(NOT STATIC AND NOT BUILD_STATIC_DEPS) if(WITH_MINIUPNPC) pkg_check_modules(MINIUPNPC miniupnpc>=2.1 IMPORTED_TARGET) endif() + pkg_check_modules(OXENC liboxenc>=1.0.1 IMPORTED_TARGET) pkg_check_modules(OXENMQ liboxenmq>=1.2.3 IMPORTED_TARGET) endif() @@ -70,6 +71,16 @@ else() endif() +if(NOT OXENC_FOUND) + message(STATUS "Using in-tree oxen-encoding") + add_subdirectory(oxen-encoding) +else() + add_library(oxenc INTERFACE) + target_link_libraries(oxenc INTERFACE PkgConfig::OXENC) + add_library(oxenc::oxenc ALIAS oxenc) + message(STATUS "Found liboxenc ${OXENC_VERSION}") +endif() + if(NOT OXENMQ_FOUND) message(STATUS "Using in-tree oxenmq") add_subdirectory(loki-mq) diff --git a/external/loki-mq b/external/loki-mq index 51754037e..5c72a57ec 160000 --- a/external/loki-mq +++ b/external/loki-mq @@ -1 +1 @@ -Subproject commit 51754037ea19204610751c2ea8ae72b7ed6c1818 +Subproject commit 5c72a57eca120750ecf557ce5a668fb38242956b diff --git a/external/oxen-encoding b/external/oxen-encoding new file mode 160000 index 000000000..a0912ab4b --- /dev/null +++ b/external/oxen-encoding @@ -0,0 +1 @@ +Subproject commit a0912ab4bf3b5e83b42715eff6f632c8912b21e4 diff --git a/src/blockchain_utilities/sn_key_tool.cpp b/src/blockchain_utilities/sn_key_tool.cpp index a54983cf3..f24951bfd 100644 --- a/src/blockchain_utilities/sn_key_tool.cpp +++ b/src/blockchain_utilities/sn_key_tool.cpp @@ -4,8 +4,8 @@ extern "C" { } #include #include -#include -#include +#include +#include #include #include #include @@ -137,7 +137,7 @@ int generate(bool ed25519, std::list args) { return error(11, "Internal error: pubkey check failed"); if (pubkey_pos != std::string::npos) - filename.replace(pubkey_pos, 6, oxenmq::to_hex(pubkey.begin(), pubkey.end())); + filename.replace(pubkey_pos, 6, oxenc::to_hex(pubkey.begin(), pubkey.end())); fs::ofstream out{fs::u8path(filename), std::ios::trunc | std::ios::binary}; if (!out.good()) return error(2, "Failed to open output file '" + filename + "': " + std::strerror(errno)); @@ -156,11 +156,11 @@ int generate(bool ed25519, std::list args) { if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pubkey.data(), pubkey.data())) return error(14, "Internal error: unable to convert Ed25519 pubkey to X25519 pubkey"); std::cout << - "Public key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << - "\nX25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) << - "\nLokinet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".snode\n"; + "Public key: " << oxenc::to_hex(pubkey.begin(), pubkey.end()) << + "\nX25519 pubkey: " << oxenc::to_hex(x_pubkey.begin(), x_pubkey.end()) << + "\nLokinet address: " << oxenc::to_base32z(pubkey.begin(), pubkey.end()) << ".snode\n"; } else { - std::cout << "Public key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << "\n"; + std::cout << "Public key: " << oxenc::to_hex(pubkey.begin(), pubkey.end()) << "\n"; } return 0; @@ -220,8 +220,8 @@ int show(std::list args) { pubkey = pubkey_from_privkey(seckey); std::cout << filename.u8string() << " (legacy SN keypair)" << "\n==========" << - "\nPrivate key: " << oxenmq::to_hex(seckey.begin(), seckey.begin() + 32) << - "\nPublic key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << "\n\n"; + "\nPrivate key: " << oxenc::to_hex(seckey.begin(), seckey.begin() + 32) << + "\nPublic key: " << oxenc::to_hex(pubkey.begin(), pubkey.end()) << "\n\n"; return 0; } @@ -234,16 +234,16 @@ int show(std::list args) { ustring_view privkey{privkey_signhash.data(), 32}; pubkey = pubkey_from_privkey(privkey); if (size >= 64 && ustring_view{pubkey.data(), pubkey.size()} != ustring_view{seckey.data() + 32, 32}) - return error(13, "Error: derived pubkey (" + oxenmq::to_hex(pubkey.begin(), pubkey.end()) + ")" - " != embedded pubkey (" + oxenmq::to_hex(seckey.begin() + 32, seckey.end()) + ")"); + return error(13, "Error: derived pubkey (" + oxenc::to_hex(pubkey.begin(), pubkey.end()) + ")" + " != embedded pubkey (" + oxenc::to_hex(seckey.begin() + 32, seckey.end()) + ")"); if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pubkey.data(), pubkey.data())) return error(14, "Unable to convert Ed25519 pubkey to X25519 pubkey; is this a really valid secret key?"); std::cout << filename << " (Ed25519 SN keypair)" << "\n==========" << - "\nSecret key: " << oxenmq::to_hex(seckey.begin(), seckey.begin() + 32) << - "\nPublic key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << - "\nX25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) << - "\nLokinet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".snode\n\n"; + "\nSecret key: " << oxenc::to_hex(seckey.begin(), seckey.begin() + 32) << + "\nPublic key: " << oxenc::to_hex(pubkey.begin(), pubkey.end()) << + "\nX25519 pubkey: " << oxenc::to_hex(x_pubkey.begin(), x_pubkey.end()) << + "\nLokinet address: " << oxenc::to_base32z(pubkey.begin(), pubkey.end()) << ".snode\n\n"; return 0; } @@ -278,15 +278,15 @@ int restore(bool ed25519, std::list args) { // Advanced feature: if you provide the concatenated privkey and pubkey in hex, we won't prompt // for verification (as long as the pubkey matches what we derive from the privkey). - if (!(skey_hex.size() == 64 || skey_hex.size() == 128) || !oxenmq::is_hex(skey_hex)) + if (!(skey_hex.size() == 64 || skey_hex.size() == 128) || !oxenc::is_hex(skey_hex)) return error(7, "Invalid input: provide the secret key as 64 hex characters"); std::array skey; std::array pubkey; std::array seed; std::optional> pubkey_expected; - oxenmq::from_hex(skey_hex.begin(), skey_hex.begin() + 64, seed.begin()); + oxenc::from_hex(skey_hex.begin(), skey_hex.begin() + 64, seed.begin()); if (skey_hex.size() == 128) - oxenmq::from_hex(skey_hex.begin() + 64, skey_hex.end(), pubkey_expected.emplace().begin()); + oxenc::from_hex(skey_hex.begin() + 64, skey_hex.end(), pubkey_expected.emplace().begin()); if (ed25519) { crypto_sign_seed_keypair(pubkey.data(), skey.data(), seed.data()); @@ -294,19 +294,19 @@ int restore(bool ed25519, std::list args) { pubkey = pubkey_from_privkey(seed); } - std::cout << "\nPublic key: " << oxenmq::to_hex(pubkey.begin(), pubkey.end()) << "\n"; + std::cout << "\nPublic key: " << oxenc::to_hex(pubkey.begin(), pubkey.end()) << "\n"; if (ed25519) { std::array x_pubkey; if (0 != crypto_sign_ed25519_pk_to_curve25519(x_pubkey.data(), pubkey.data())) return error(14, "Unable to convert Ed25519 pubkey to X25519 pubkey; is this a really valid secret key?"); - std::cout << "X25519 pubkey: " << oxenmq::to_hex(x_pubkey.begin(), x_pubkey.end()) << - "\nLokinet address: " << oxenmq::to_base32z(pubkey.begin(), pubkey.end()) << ".snode"; + std::cout << "X25519 pubkey: " << oxenc::to_hex(x_pubkey.begin(), x_pubkey.end()) << + "\nLokinet address: " << oxenc::to_base32z(pubkey.begin(), pubkey.end()) << ".snode"; } if (pubkey_expected) { if (*pubkey_expected != pubkey) - return error(2, "Derived pubkey (" + oxenmq::to_hex(pubkey.begin(), pubkey.end()) + ") doesn't match " - "provided pubkey (" + oxenmq::to_hex(pubkey_expected->begin(), pubkey_expected->end()) + ")"); + return error(2, "Derived pubkey (" + oxenc::to_hex(pubkey.begin(), pubkey.end()) + ") doesn't match " + "provided pubkey (" + oxenc::to_hex(pubkey_expected->begin(), pubkey_expected->end()) + ")"); } else { if (ed25519 && filename.size() >= 4 && filename.substr(filename.size() - 4) == "/key") { @@ -324,7 +324,7 @@ int restore(bool ed25519, std::list args) { } if (pubkey_pos != std::string::npos) - filename.replace(pubkey_pos, 6, oxenmq::to_hex(pubkey.begin(), pubkey.end())); + filename.replace(pubkey_pos, 6, oxenc::to_hex(pubkey.begin(), pubkey.end())); auto filepath = fs::u8path(filename); if (!overwrite && fs::exists(filepath)) diff --git a/src/common/hex.h b/src/common/hex.h index 52254293f..2e7cc36fb 100644 --- a/src/common/hex.h +++ b/src/common/hex.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include "epee/span.h" // epee @@ -11,9 +11,9 @@ namespace tools { !std::is_const_v && (std::is_trivially_copyable_v || epee::is_byte_spannable) >> bool hex_to_type(std::string_view hex, T& x) { - if (!oxenmq::is_hex(hex) || hex.size() != 2*sizeof(T)) + if (!oxenc::is_hex(hex) || hex.size() != 2*sizeof(T)) return false; - oxenmq::from_hex(hex.begin(), hex.end(), reinterpret_cast(&x)); + oxenc::from_hex(hex.begin(), hex.end(), reinterpret_cast(&x)); return true; } @@ -23,6 +23,6 @@ namespace tools { || epee::is_byte_spannable >> std::string type_to_hex(const T& val) { - return oxenmq::to_hex(std::string_view{reinterpret_cast(&val), sizeof(val)}); + return oxenc::to_hex(std::string_view{reinterpret_cast(&val), sizeof(val)}); } } diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index a2e9c7527..a560af7a9 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "common/hex.h" #include "epee/wipeable_string.h" @@ -541,7 +541,7 @@ namespace cryptonote try { serialization::deserialize_all(ar, tx_extra_fields); } catch (const std::exception& e) { - MWARNING(__func__ << ": failed to deserialize extra field: " << e.what() << "; extra = " << oxenmq::to_hex(tx_extra.begin(), tx_extra.end())); + MWARNING(__func__ << ": failed to deserialize extra field: " << e.what() << "; extra = " << oxenc::to_hex(tx_extra.begin(), tx_extra.end())); return false; } @@ -807,7 +807,7 @@ namespace cryptonote value(newar, field); } while (ar.remaining_bytes() > 0); } catch (const std::exception& e) { - LOG_PRINT_L1(__func__ << ": failed to deserialize extra field: " << e.what() << "; extra = " << oxenmq::to_hex(tx_extra.begin(), tx_extra.end())); + LOG_PRINT_L1(__func__ << ": failed to deserialize extra field: " << e.what() << "; extra = " << oxenc::to_hex(tx_extra.begin(), tx_extra.end())); return false; } @@ -969,7 +969,7 @@ namespace cryptonote //--------------------------------------------------------------- std::string short_hash_str(const crypto::hash& h) { - return oxenmq::to_hex(tools::view_guts(h).substr(0, 4)) + "...."; + return oxenc::to_hex(tools::view_guts(h).substr(0, 4)) + "...."; } //--------------------------------------------------------------- bool is_out_to_acc(const account_keys& acc, const txout_to_key& out_key, const crypto::public_key& tx_pub_key, const std::vector& additional_tx_pub_keys, size_t output_index) diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 6c6059e3b..0c38d04ae 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -31,7 +31,7 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include -#include +#include #include "epee/misc_language.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "epee/misc_os_dependent.h" @@ -254,13 +254,13 @@ namespace cryptonote tools::trim(extra_vec[i]); if(!extra_vec[i].size()) continue; - if (!oxenmq::is_base64(extra_vec[i])) + if (!oxenc::is_base64(extra_vec[i])) { MWARNING("Invalid (non-base64) extra message `" << extra_vec[i] << "'"); continue; } - std::string buff = oxenmq::from_base64(extra_vec[i]); + std::string buff = oxenc::from_base64(extra_vec[i]); if(buff != "0") m_extra_messages[i] = buff; } diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index ebd798272..450df6ad8 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include extern "C" { #include @@ -937,7 +937,7 @@ namespace cryptonote MGINFO_YELLOW("- primary: " << tools::type_to_hex(keys.pub)); MGINFO_YELLOW("- ed25519: " << tools::type_to_hex(keys.pub_ed25519)); // .snode address is the ed25519 pubkey, encoded with base32z and with .snode appended: - MGINFO_YELLOW("- lokinet: " << oxenmq::to_base32z(tools::view_guts(keys.pub_ed25519)) << ".snode"); + MGINFO_YELLOW("- lokinet: " << oxenc::to_base32z(tools::view_guts(keys.pub_ed25519)) << ".snode"); MGINFO_YELLOW("- x25519: " << tools::type_to_hex(keys.pub_x25519)); } else { // Only print the x25519 version because it's the only thing useful for a non-SN (for diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index a41baa5f1..4af9ae1af 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -1040,8 +1040,8 @@ namespace cryptonote //genesis block bl = {}; - CHECK_AND_ASSERT_MES(oxenmq::is_hex(conf.GENESIS_TX), false, "failed to parse coinbase tx from hard coded blob"); - std::string tx_bl = oxenmq::from_hex(conf.GENESIS_TX); + CHECK_AND_ASSERT_MES(oxenc::is_hex(conf.GENESIS_TX), false, "failed to parse coinbase tx from hard coded blob"); + std::string tx_bl = oxenc::from_hex(conf.GENESIS_TX); bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx); CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob"); bl.major_version = 7; diff --git a/src/cryptonote_core/oxen_name_system.cpp b/src/cryptonote_core/oxen_name_system.cpp index 9b9f60613..32e4a142b 100644 --- a/src/cryptonote_core/oxen_name_system.cpp +++ b/src/cryptonote_core/oxen_name_system.cpp @@ -16,9 +16,9 @@ #include "cryptonote_core/blockchain.h" #include "oxen_economy.h" -#include -#include -#include +#include +#include +#include #include @@ -109,17 +109,17 @@ std::string ons::mapping_value::to_readable_value(cryptonote::network_type netty std::string result; if (is_lokinet_type(type)) { - result = oxenmq::to_base32z(to_view()) + ".loki"; + result = oxenc::to_base32z(to_view()) + ".loki"; } else if (type == ons::mapping_type::wallet) { std::optional addr = get_wallet_address_info(); if(addr) { result = cryptonote::get_account_address_as_str(nettype, (*addr).is_subaddress, (*addr).address); } else { - result = oxenmq::to_hex(to_view()); + result = oxenc::to_hex(to_view()); } } else { - result = oxenmq::to_hex(to_view()); + result = oxenc::to_hex(to_view()); } return result; @@ -707,9 +707,9 @@ bool parse_owner_to_generic_owner(cryptonote::network_type nettype, std::string_ { result = ons::make_monero_owner(parsed_addr.address, parsed_addr.is_subaddress); } - else if (owner.size() == 2*sizeof(ed_owner.data) && oxenmq::is_hex(owner)) + else if (owner.size() == 2*sizeof(ed_owner.data) && oxenc::is_hex(owner)) { - oxenmq::from_hex(owner.begin(), owner.end(), ed_owner.data); + oxenc::from_hex(owner.begin(), owner.end(), ed_owner.data); result = ons::make_ed25519_owner(ed_owner); } else @@ -864,7 +864,7 @@ bool validate_ons_name(mapping_type type, std::string name, std::string *reason) std::optional encrypted_wallet_value_to_info(std::string name, std::string encrypted_value, std::string nonce) { std::string lower_name = tools::lowercase_ascii_string(std::move(name)); - mapping_value record(oxenmq::from_hex(encrypted_value), oxenmq::from_hex(nonce)); + mapping_value record(oxenc::from_hex(encrypted_value), oxenc::from_hex(nonce)); record.decrypt(lower_name, mapping_type::wallet); return record.get_wallet_address_info(); } @@ -884,7 +884,7 @@ static bool check_lengths(mapping_type type, std::string_view value, size_t max, { std::stringstream err_stream; err_stream << "ONS type=" << type << ", specifies mapping from name_hash->encrypted_value where the value's length=" << value.size() << ", does not equal the required length=" << max << ", given value="; - if (binary_val) err_stream << oxenmq::to_hex(value); + if (binary_val) err_stream << oxenc::to_hex(value); else err_stream << value; *reason = err_stream.str(); } @@ -950,14 +950,14 @@ bool mapping_value::validate(cryptonote::network_type nettype, mapping_type type // We need a 52 char base32z string that decodes to a 32-byte value, which really means we need // 51 base32z chars (=255 bits) followed by a 1-bit value ('y'=0, or 'o'=0b10000); anything else // in the last spot isn't a valid lokinet address. - if (check_condition(value.size() != 57 || !tools::ends_with(value, ".loki") || !oxenmq::is_base32z(value.substr(0, 52)) || !(value[51] == 'y' || value[51] == 'o'), + if (check_condition(value.size() != 57 || !tools::ends_with(value, ".loki") || !oxenc::is_base32z(value.substr(0, 52)) || !(value[51] == 'y' || value[51] == 'o'), reason, "'", value, "' is not a valid lokinet address")) return false; if (blob) { blob->len = sizeof(crypto::ed25519_public_key); - oxenmq::from_base32z(value.begin(), value.begin() + 52, blob->buffer.begin()); + oxenc::from_base32z(value.begin(), value.begin() + 52, blob->buffer.begin()); } } else @@ -967,7 +967,7 @@ bool mapping_value::validate(cryptonote::network_type nettype, mapping_type type if (check_condition(value.size() != 2*SESSION_PUBLIC_KEY_BINARY_LENGTH, reason, "The value=", value, " is not the required ", 2*SESSION_PUBLIC_KEY_BINARY_LENGTH, "-character hex string session public key, length=", value.size())) return false; - if (check_condition(!oxenmq::is_hex(value), reason, ", specifies name -> value mapping where the value is not a hex string given value=")) + if (check_condition(!oxenc::is_hex(value), reason, ", specifies name -> value mapping where the value is not a hex string given value=")) return false; // NOTE: Session public keys are 33 bytes, with the first byte being 0x05 and the remaining 32 being the public key. @@ -978,7 +978,7 @@ bool mapping_value::validate(cryptonote::network_type nettype, mapping_type type { blob->len = value.size() / 2; assert(blob->len <= blob->buffer.size()); - oxenmq::from_hex(value.begin(), value.end(), blob->buffer.begin()); + oxenc::from_hex(value.begin(), value.end(), blob->buffer.begin()); } } @@ -1048,17 +1048,17 @@ std::string name_hash_bytes_to_base64(std::string_view bytes) { if (bytes.size() != NAME_HASH_SIZE) throw std::runtime_error{"Invalid name hash: expected exactly 32 bytes"}; - return oxenmq::to_base64(bytes); + return oxenc::to_base64(bytes); } std::optional name_hash_input_to_base64(std::string_view input) { if (input.size() == NAME_HASH_SIZE) return name_hash_bytes_to_base64(input); - if (input.size() == 2*NAME_HASH_SIZE && oxenmq::is_hex(input)) - return name_hash_bytes_to_base64(oxenmq::from_hex(input)); - if (input.size() >= NAME_HASH_SIZE_B64_MIN && input.size() <= NAME_HASH_SIZE_B64_MAX && oxenmq::is_base64(input)) { - std::string tmp = oxenmq::from_base64(input); + if (input.size() == 2*NAME_HASH_SIZE && oxenc::is_hex(input)) + return name_hash_bytes_to_base64(oxenc::from_hex(input)); + if (input.size() >= NAME_HASH_SIZE_B64_MIN && input.size() <= NAME_HASH_SIZE_B64_MAX && oxenc::is_base64(input)) { + std::string tmp = oxenc::from_base64(input); if (tmp.size() == NAME_HASH_SIZE) // Could still be off from too much/too little padding return name_hash_bytes_to_base64(tmp); } @@ -2267,7 +2267,7 @@ bool name_system_db::get_wallet_mapping(std::string str, uint64_t blockchain_hei mapping_record name_system_db::get_mapping(mapping_type type, std::string_view name_base64_hash, std::optional blockchain_height) { - assert(name_base64_hash.size() == 44 && name_base64_hash.back() == '=' && oxenmq::is_base64(name_base64_hash)); + assert(name_base64_hash.size() == 44 && name_base64_hash.back() == '=' && oxenc::is_base64(name_base64_hash)); mapping_record result = {}; result.loaded = bind_and_run(ons_sql_type::get_mapping, get_mapping_sql, &result, db_mapping_type(type), name_base64_hash); @@ -2278,7 +2278,7 @@ mapping_record name_system_db::get_mapping(mapping_type type, std::string_view n std::optional name_system_db::resolve(mapping_type type, std::string_view name_hash_b64, uint64_t blockchain_height) { - assert(name_hash_b64.size() == 44 && name_hash_b64.back() == '=' && oxenmq::is_base64(name_hash_b64)); + assert(name_hash_b64.size() == 44 && name_hash_b64.back() == '=' && oxenc::is_base64(name_hash_b64)); std::optional result; bind_all(resolve_sql, db_mapping_type(type), name_hash_b64, blockchain_height); if (step(resolve_sql) == SQLITE_ROW) @@ -2299,7 +2299,7 @@ std::optional name_system_db::resolve(mapping_type type, std::str std::vector name_system_db::get_mappings(std::vector const &types, std::string_view name_base64_hash, std::optional blockchain_height) { - assert(name_base64_hash.size() == 44 && name_base64_hash.back() == '=' && oxenmq::is_base64(name_base64_hash)); + assert(name_base64_hash.size() == 44 && name_base64_hash.back() == '=' && oxenc::is_base64(name_base64_hash)); std::vector result; if (types.empty()) return result; diff --git a/src/cryptonote_core/oxen_name_system.h b/src/cryptonote_core/oxen_name_system.h index 28e5eb641..36317e36e 100644 --- a/src/cryptonote_core/oxen_name_system.h +++ b/src/cryptonote_core/oxen_name_system.h @@ -6,7 +6,7 @@ #include "epee/span.h" #include "cryptonote_basic/tx_extra.h" #include "common/fs.h" -#include +#include #include #include @@ -115,7 +115,7 @@ struct mapping_value mapping_value(); mapping_value(std::string encrypted_value, std::string nonce); }; -inline std::ostream &operator<<(std::ostream &os, mapping_value const &v) { return os << oxenmq::to_hex(v.to_view()); } +inline std::ostream &operator<<(std::ostream &os, mapping_value const &v) { return os << oxenc::to_hex(v.to_view()); } inline std::string_view mapping_type_str(mapping_type type) { diff --git a/src/cryptonote_core/pulse.cpp b/src/cryptonote_core/pulse.cpp index b8d8e162b..c0964d04f 100644 --- a/src/cryptonote_core/pulse.cpp +++ b/src/cryptonote_core/pulse.cpp @@ -1565,7 +1565,7 @@ round_state send_and_wait_for_random_value(round_context &context, service_nodes { if (auto &random_value = quorum[index]; random_value) { - epee::wipeable_string string = oxenmq::to_hex(tools::view_guts(random_value->data)); + epee::wipeable_string string = oxenc::to_hex(tools::view_guts(random_value->data)); #if defined(NDEBUG) // Mask the random value generated incase someone is snooping logs @@ -1596,7 +1596,7 @@ round_state send_and_wait_for_random_value(round_context &context, service_nodes crypto::hash const &final_block_hash = cryptonote::get_block_hash(final_block); crypto::generate_signature(final_block_hash, key.pub, key.key, context.transient.signed_block.send.data); - MINFO(log_prefix(context) << "Block final random value " << oxenmq::to_hex(tools::view_guts(final_block.pulse.random_value.data)) << " generated from validators " << bitset_view16(stage.bitset)); + MINFO(log_prefix(context) << "Block final random value " << oxenc::to_hex(tools::view_guts(final_block.pulse.random_value.data)) << " generated from validators " << bitset_view16(stage.bitset)); return round_state::send_and_wait_for_signed_blocks; } diff --git a/src/cryptonote_core/service_node_list.cpp b/src/cryptonote_core/service_node_list.cpp index 7a3dc68aa..09b97884d 100644 --- a/src/cryptonote_core/service_node_list.cpp +++ b/src/cryptonote_core/service_node_list.cpp @@ -1246,7 +1246,7 @@ namespace service_nodes std::bitset<8 * sizeof(block.pulse.validator_bitset)> const validator_bitset = block.pulse.validator_bitset; stream << "Block(" << cryptonote::get_block_height(block) << "): " << cryptonote::get_block_hash(block) << "\n"; stream << "Leader: "; - if (quorum) stream << (quorum->workers.empty() ? "(invalid leader)" : oxenmq::to_hex(tools::view_guts(quorum->workers[0]))) << "\n"; + if (quorum) stream << (quorum->workers.empty() ? "(invalid leader)" : oxenc::to_hex(tools::view_guts(quorum->workers[0]))) << "\n"; else stream << "(invalid quorum)\n"; stream << "Round: " << +block.pulse.round << "\n"; stream << "Validator Bitset: " << validator_bitset << "\n"; @@ -1260,8 +1260,8 @@ namespace service_nodes stream << " [" << +entry.voter_index << "] validator: "; if (quorum) { - stream << ((entry.voter_index >= quorum->validators.size()) ? "(invalid quorum index)" : oxenmq::to_hex(tools::view_guts(quorum->validators[entry.voter_index]))); - stream << ", signature: " << oxenmq::to_hex(tools::view_guts(entry.signature)); + stream << ((entry.voter_index >= quorum->validators.size()) ? "(invalid quorum index)" : oxenc::to_hex(tools::view_guts(quorum->validators[entry.voter_index]))); + stream << ", signature: " << oxenc::to_hex(tools::view_guts(entry.signature)); } else stream << "(invalid quorum)"; } diff --git a/src/cryptonote_core/uptime_proof.cpp b/src/cryptonote_core/uptime_proof.cpp index 0a84ea506..0377ae06b 100644 --- a/src/cryptonote_core/uptime_proof.cpp +++ b/src/cryptonote_core/uptime_proof.cpp @@ -44,7 +44,7 @@ Proof::Proof( Proof::Proof(const std::string& serialized_proof) { try { - using namespace oxenmq; + using namespace oxenc; const bt_dict bt_proof = bt_deserialize(serialized_proof); //snode_version @@ -99,11 +99,11 @@ crypto::hash Proof::hash_uptime_proof() const return result; } -oxenmq::bt_dict Proof::bt_encode_uptime_proof() const +oxenc::bt_dict Proof::bt_encode_uptime_proof() const { - oxenmq::bt_dict encoded_proof{ + oxenc::bt_dict encoded_proof{ //version - {"v", oxenmq::bt_list{{version[0], version[1], version[2]}}}, + {"v", oxenc::bt_list{{version[0], version[1], version[2]}}}, //timestamp {"t", timestamp}, //public_ip @@ -117,9 +117,9 @@ oxenmq::bt_dict Proof::bt_encode_uptime_proof() const //storage_omq_port {"sop", storage_omq_port}, //storage_version - {"sv", oxenmq::bt_list{{storage_server_version[0], storage_server_version[1], storage_server_version[2]}}}, + {"sv", oxenc::bt_list{{storage_server_version[0], storage_server_version[1], storage_server_version[2]}}}, //lokinet_version - {"lv", oxenmq::bt_list{{lokinet_version[0], lokinet_version[1], lokinet_version[2]}}}, + {"lv", oxenc::bt_list{{lokinet_version[0], lokinet_version[1], lokinet_version[2]}}}, }; if (tools::view_guts(pubkey) != tools::view_guts(pubkey_ed25519)) { diff --git a/src/cryptonote_core/uptime_proof.h b/src/cryptonote_core/uptime_proof.h index a1c42144a..ffdc99801 100644 --- a/src/cryptonote_core/uptime_proof.h +++ b/src/cryptonote_core/uptime_proof.h @@ -1,7 +1,8 @@ #pragma once #include "cryptonote_protocol/cryptonote_protocol_defs.h" -#include +#include +#include namespace service_nodes { @@ -34,7 +35,7 @@ public: Proof(uint32_t sn_public_ip, uint16_t sn_storage_https_port, uint16_t sn_storage_omq_port, std::array ss_version, uint16_t quorumnet_port, std::array lokinet_version, const service_nodes::service_node_keys& keys); Proof(const std::string& serialized_proof); - oxenmq::bt_dict bt_encode_uptime_proof() const; + oxenc::bt_dict bt_encode_uptime_proof() const; crypto::hash hash_uptime_proof() const; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 1ca364238..59e3b374e 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -692,7 +692,7 @@ namespace cryptonote LOG_ERROR_CCONTEXT ( "sent wrong tx: failed to parse and validate transaction: " - << oxenmq::to_hex(tx_blob) + << oxenc::to_hex(tx_blob) << ", dropping connection" ); @@ -834,7 +834,7 @@ namespace cryptonote LOG_ERROR_CCONTEXT ( "sent wrong block: failed to parse and validate block: " - << oxenmq::to_hex(arg.b.block) + << oxenc::to_hex(arg.b.block) << ", dropping connection" ); @@ -1255,7 +1255,7 @@ namespace cryptonote if(!parse_and_validate_block_from_blob(block_entry.block, b, block_hash)) { LOG_ERROR_CCONTEXT("sent wrong block: failed to parse and validate block: " - << oxenmq::to_hex(block_entry.block) << ", dropping connection"); + << oxenc::to_hex(block_entry.block) << ", dropping connection"); drop_connection(context, false, false); ++m_sync_bad_spans_downloaded; return 1; @@ -1263,7 +1263,7 @@ namespace cryptonote if (b.miner_tx.vin.size() != 1 || !std::holds_alternative(b.miner_tx.vin.front())) { LOG_ERROR_CCONTEXT("sent wrong block: block: miner tx does not have exactly one txin_gen input" - << oxenmq::to_hex(block_entry.block) << ", dropping connection"); + << oxenc::to_hex(block_entry.block) << ", dropping connection"); drop_connection(context, false, false); ++m_sync_bad_spans_downloaded; return 1; diff --git a/src/cryptonote_protocol/quorumnet.cpp b/src/cryptonote_protocol/quorumnet.cpp index 2d6ac3f2a..7868d0fe3 100644 --- a/src/cryptonote_protocol/quorumnet.cpp +++ b/src/cryptonote_protocol/quorumnet.cpp @@ -40,7 +40,7 @@ #include "common/random.h" #include -#include +#include #include #include #include @@ -53,9 +53,12 @@ namespace quorumnet { namespace { using namespace service_nodes; -using namespace oxenmq; +using namespace oxenc; -using blink_tx = cryptonote::blink_tx; +namespace send_option = oxenmq::send_option; +using oxenmq::Message; + +using cryptonote::blink_tx; constexpr auto NUM_BLINK_QUORUMS = tools::enum_count; static_assert(std::is_same(), "unexpected underlying blink quorum count type"); @@ -72,7 +75,7 @@ using pending_signature_set = std::unordered_set btxptr; pending_signature_set pending_sigs; - ConnectionID reply_conn; + oxenmq::ConnectionID reply_conn; uint64_t reply_tag = 0; }; // { height => { txhash => {blink_tx,conn,reply}, ... }, ... } @@ -320,7 +323,7 @@ public: } private: - OxenMQ &omq; + oxenmq::OxenMQ &omq; /// Looks up a pubkey in known remotes and adds it to `peers`. If strong, it is added with an /// address, otherwise it is added with an empty address. If the element already exists, it @@ -650,7 +653,7 @@ std::string debug_known_signatures(blink_tx &btx, quorum_array &blink_quorums) { /// tx; otherwise signatures are stored until we learn about the tx and then processed. void process_blink_signatures(QnetState &qnet, const std::shared_ptr &btxptr, quorum_array &blink_quorums, uint64_t quorum_checksum, std::list &&signatures, uint64_t reply_tag, // > 0 if we are expected to send a status update if it becomes accepted/rejected - ConnectionID reply_conn, // who we are supposed to send the status update to + oxenmq::ConnectionID reply_conn, // who we are supposed to send the status update to const std::string &received_from = ""s /* x25519 of the peer that sent this, if available (to avoid trying to pointlessly relay back to them) */) { auto &btx = *btxptr; @@ -828,7 +831,7 @@ void process_blink_signatures(QnetState &qnet, const std::shared_ptr & /// "#" - precomputed tx hash. This much match the actual hash of the transaction (the blink /// submission will fail immediately if it does not). /// -void handle_blink(oxenmq::Message& m, QnetState& qnet) { +void handle_blink(Message& m, QnetState& qnet) { // TODO: if someone sends an invalid tx (i.e. one that doesn't get to the distribution stage) // then put a timeout on that IP during which new submissions from them are dropped for a short // time. @@ -1193,7 +1196,7 @@ void handle_blink_signature(Message& m, QnetState& qnet) { auto blink_quorums = get_blink_quorums(blink_height, qnet.core.get_service_node_list(), &checksum); // throws if bad quorum or checksum mismatch uint64_t reply_tag = 0; - ConnectionID reply_conn; + oxenmq::ConnectionID reply_conn; std::shared_ptr btxptr; auto find_blink = [&]() { auto height_it = qnet.blinks.find(blink_height); @@ -1703,6 +1706,8 @@ void init_core_callbacks() { namespace { void setup_endpoints(cryptonote::core& core, void* obj) { + using namespace oxenmq; + auto& omq = core.get_omq(); if (core.service_node()) { diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index c0db57f86..634a1b823 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -41,7 +41,7 @@ #include "cryptonote_basic/hardfork.h" #include "checkpoints/checkpoints.h" #include -#include +#include #include #include @@ -842,11 +842,11 @@ bool rpc_command_executor::print_transaction(const crypto::hash& transaction_has std::optional t; if (include_metadata || include_json) { - if (oxenmq::is_hex(pruned_as_hex) && (!tx.prunable_as_hex || oxenmq::is_hex(*tx.prunable_as_hex))) + if (oxenc::is_hex(pruned_as_hex) && (!tx.prunable_as_hex || oxenc::is_hex(*tx.prunable_as_hex))) { - std::string blob = oxenmq::from_hex(pruned_as_hex); + std::string blob = oxenc::from_hex(pruned_as_hex); if (tx.prunable_as_hex) - blob += oxenmq::from_hex(*tx.prunable_as_hex); + blob += oxenc::from_hex(*tx.prunable_as_hex); bool parsed = pruned ? cryptonote::parse_and_validate_tx_base_from_blob(blob, t.emplace()) @@ -1626,7 +1626,7 @@ static void append_printable_service_node_list_entry(cryptonote::network_type ne if (detailed_view) stream << indent2 << "Auxiliary Public Keys:\n" << indent3 << (entry.pubkey_ed25519.empty() ? "(not yet received)" : entry.pubkey_ed25519) << " (Ed25519)\n" - << indent3 << (entry.pubkey_ed25519.empty() ? "(not yet received)" : oxenmq::to_base32z(oxenmq::from_hex(entry.pubkey_ed25519)) + ".snode") << " (Lokinet)\n" + << indent3 << (entry.pubkey_ed25519.empty() ? "(not yet received)" : oxenc::to_base32z(oxenc::from_hex(entry.pubkey_ed25519)) + ".snode") << " (Lokinet)\n" << indent3 << (entry.pubkey_x25519.empty() ? "(not yet received)" : entry.pubkey_x25519) << " (X25519)\n"; // diff --git a/src/debug_utilities/cn_deserialize.cpp b/src/debug_utilities/cn_deserialize.cpp index 2de1f078f..d780d54c0 100644 --- a/src/debug_utilities/cn_deserialize.cpp +++ b/src/debug_utilities/cn_deserialize.cpp @@ -34,7 +34,7 @@ #include "oxen_economy.h" #include "common/hex.h" #include "version.h" -#include +#include #undef OXEN_DEFAULT_LOG_CATEGORY #define OXEN_DEFAULT_LOG_CATEGORY "debugtools.deserialize" @@ -46,10 +46,10 @@ using namespace cryptonote; static std::string extra_nonce_to_string(const cryptonote::tx_extra_nonce &extra_nonce) { if (extra_nonce.nonce.size() == 9 && extra_nonce.nonce[0] == TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID) - return "encrypted payment ID: " + oxenmq::to_hex(extra_nonce.nonce.begin() + 1, extra_nonce.nonce.end()); + return "encrypted payment ID: " + oxenc::to_hex(extra_nonce.nonce.begin() + 1, extra_nonce.nonce.end()); if (extra_nonce.nonce.size() == 33 && extra_nonce.nonce[0] == TX_EXTRA_NONCE_PAYMENT_ID) - return "plaintext payment ID: " + oxenmq::to_hex(extra_nonce.nonce.begin() + 1, extra_nonce.nonce.end()); - return oxenmq::to_hex(extra_nonce.nonce); + return "plaintext payment ID: " + oxenc::to_hex(extra_nonce.nonce.begin() + 1, extra_nonce.nonce.end()); + return oxenc::to_hex(extra_nonce.nonce); } struct extra_printer { @@ -66,7 +66,7 @@ struct extra_printer { std::cout << pk; } } - void operator()(const tx_extra_mysterious_minergate& x) { std::cout << "minergate custom: " << oxenmq::to_hex(x.data); } + void operator()(const tx_extra_mysterious_minergate& x) { std::cout << "minergate custom: " << oxenc::to_hex(x.data); } void operator()(const tx_extra_service_node_winner& x) { std::cout << "SN reward winner: " << x.m_service_node_key; } void operator()(const tx_extra_service_node_register& x) { std::cout << "SN registration data"; } // TODO: could parse this further void operator()(const tx_extra_service_node_pubkey& x) { std::cout << "SN pubkey: " << x.m_service_node_key; } diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index 6360f784a..6071cd0bf 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -381,7 +381,7 @@ namespace hw::ledger { #endif cmd << " p=(0x" << std::setw(2) << +buffer_send[2] << ",0x" << std::setw(2) << +buffer_send[3] << ')'; cmd << " sz=0x" << std::setw(2) << +buffer_send[4] << '[' << std::to_string(buffer_send[4]) << "] "; - MDEBUG("CMD: " << cmd.str() << oxenmq::to_hex(buffer_send + 5, buffer_send + length_send)); + MDEBUG("CMD: " << cmd.str() << oxenc::to_hex(buffer_send + 5, buffer_send + length_send)); last_cmd = std::chrono::steady_clock::now(); } } @@ -389,8 +389,8 @@ namespace hw::ledger { void device_ledger::logRESP() { if (apdu_verbose) MDEBUG("RESP (+" << tools::short_duration(std::chrono::steady_clock::now() - last_cmd) << "): " - << oxenmq::to_hex(std::string_view{reinterpret_cast(&sw), sizeof(sw)}) - << ' ' << oxenmq::to_hex(buffer_recv, buffer_recv + length_recv)); + << oxenc::to_hex(std::string_view{reinterpret_cast(&sw), sizeof(sw)}) + << ' ' << oxenc::to_hex(buffer_recv, buffer_recv + length_recv)); } int device_ledger::set_command_header(unsigned char ins, unsigned char p1, unsigned char p2) { diff --git a/src/device/io_hid.cpp b/src/device/io_hid.cpp index e64912a64..3e0010782 100644 --- a/src/device/io_hid.cpp +++ b/src/device/io_hid.cpp @@ -72,7 +72,7 @@ namespace hw::io { void hid::io_hid_log(int read, unsigned char* buffer, int block_len) { if (hid_verbose) - MDEBUG("HID " << (read ? '<' : '>') << " : " << oxenmq::to_hex(buffer, buffer + block_len)); + MDEBUG("HID " << (read ? '<' : '>') << " : " << oxenc::to_hex(buffer, buffer + block_len)); } void hid::init() { diff --git a/src/device/log.cpp b/src/device/log.cpp index 4d9f90c22..a6daae639 100644 --- a/src/device/log.cpp +++ b/src/device/log.cpp @@ -28,7 +28,7 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#include +#include #include "epee/misc_log_ex.h" #include "log.hpp" @@ -38,7 +38,7 @@ namespace hw { #define OXEN_DEFAULT_LOG_CATEGORY "device" void log_hexbuffer(std::string_view msg, const void* buff, size_t len) { - MDEBUG(msg << ": " << oxenmq::to_hex(std::string_view{reinterpret_cast(buff), len})); + MDEBUG(msg << ": " << oxenc::to_hex(std::string_view{reinterpret_cast(buff), len})); } void log_message(std::string_view msg, std::string_view info) { @@ -119,7 +119,7 @@ namespace hw { log_hexbuffer(" host ", h, len); log_hexbuffer(" device", d, len); } else { - log_message("ASSERT EQ OK", msg + ": " + info + ": " + oxenmq::to_hex(d, d+len)); + log_message("ASSERT EQ OK", msg + ": " + info + ": " + oxenc::to_hex(d, d+len)); } } diff --git a/src/device_trezor/trezor/transport.cpp b/src/device_trezor/trezor/transport.cpp index 1de7c72e9..3ee80cfd2 100644 --- a/src/device_trezor/trezor/transport.cpp +++ b/src/device_trezor/trezor/transport.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "common/apply_permutation.h" #include "common/string_util.h" #include "transport.hpp" @@ -458,7 +458,7 @@ namespace trezor{ epee::wipeable_string res_hex; epee::wipeable_string req_hex; req_hex.reserve(buff_size * 2); - oxenmq::to_hex(req_buff_raw, req_buff_raw + buff_size, std::back_inserter(req_hex)); + oxenc::to_hex(req_buff_raw, req_buff_raw + buff_size, std::back_inserter(req_hex)); bool req_status = invoke_bridge_http(uri, req_hex, res_hex); if (!req_status){ diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 50f801176..1d405428e 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "crypto/crypto.h" #include "cryptonote_basic/hardfork.h" #include "cryptonote_basic/tx_extra.h" @@ -721,9 +721,9 @@ namespace cryptonote { namespace rpc { void operator()(const tx_extra_nonce& x) { if ((x.nonce.size() == sizeof(crypto::hash) + 1 && x.nonce[0] == TX_EXTRA_NONCE_PAYMENT_ID) || (x.nonce.size() == sizeof(crypto::hash8) + 1 && x.nonce[0] == TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID)) - entry.payment_id = oxenmq::to_hex(x.nonce.begin() + 1, x.nonce.end()); + entry.payment_id = oxenc::to_hex(x.nonce.begin() + 1, x.nonce.end()); else - entry.extra_nonce = oxenmq::to_hex(x.nonce); + entry.extra_nonce = oxenc::to_hex(x.nonce); } void operator()(const tx_extra_merge_mining_tag& x) { entry.mm_depth = x.depth; entry.mm_root = tools::type_to_hex(x.merkle_root); } void operator()(const tx_extra_additional_pub_keys& x) { entry.additional_pubkeys = hexify(x.data); } @@ -814,7 +814,7 @@ namespace cryptonote { namespace rpc { ons.renew = true; ons.name_hash = tools::type_to_hex(x.name_hash); if (!x.encrypted_value.empty()) - ons.value = oxenmq::to_hex(x.encrypted_value); + ons.value = oxenc::to_hex(x.encrypted_value); _load_owner(ons.owner, x.owner); _load_owner(ons.backup_owner, x.backup_owner); } @@ -962,9 +962,9 @@ namespace cryptonote { namespace rpc { } else { - e.pruned_as_hex = oxenmq::to_hex(unprunable_data); + e.pruned_as_hex = oxenc::to_hex(unprunable_data); if (!req.prune && prunable && !pruned) - e.prunable_as_hex = oxenmq::to_hex(prunable_data); + e.prunable_as_hex = oxenc::to_hex(prunable_data); } } else @@ -973,7 +973,7 @@ namespace cryptonote { namespace rpc { tx_data = unprunable_data; tx_data += prunable_data; if (!req.decode_as_json) - e.as_hex = oxenmq::to_hex(tx_data); + e.as_hex = oxenc::to_hex(tx_data); } cryptonote::transaction t; @@ -1482,7 +1482,7 @@ namespace cryptonote { namespace rpc { m_core.get_pool().get_transactions_and_spent_keys_info(res.transactions, res.spent_key_images, load_extra, context.admin); for (tx_info& txi : res.transactions) - txi.tx_blob = oxenmq::to_hex(txi.tx_blob); + txi.tx_blob = oxenc::to_hex(txi.tx_blob); res.status = STATUS_OK; return res; } @@ -1712,8 +1712,8 @@ namespace cryptonote { namespace rpc { } blobdata hashing_blob = get_block_hashing_blob(b); res.prev_hash = tools::type_to_hex(b.prev_id); - res.blocktemplate_blob = oxenmq::to_hex(block_blob); - res.blockhashing_blob = oxenmq::to_hex(hashing_blob); + res.blocktemplate_blob = oxenc::to_hex(block_blob); + res.blockhashing_blob = oxenc::to_hex(hashing_blob); res.status = STATUS_OK; return res; } @@ -1795,7 +1795,7 @@ namespace cryptonote { namespace rpc { return true; }, b, template_res.difficulty, template_res.height); - submit_req.blob[0] = oxenmq::to_hex(block_to_blob(b)); + submit_req.blob[0] = oxenc::to_hex(block_to_blob(b)); auto submit_res = invoke(std::move(submit_req), context); res.status = submit_res.status; @@ -2077,7 +2077,7 @@ namespace cryptonote { namespace rpc { res.tx_hashes.reserve(blk.tx_hashes.size()); for (const auto& tx_hash : blk.tx_hashes) res.tx_hashes.push_back(tools::type_to_hex(tx_hash)); - res.blob = oxenmq::to_hex(t_serializable_object_to_blob(blk)); + res.blob = oxenc::to_hex(t_serializable_object_to_blob(blk)); res.json = obj_to_json_str(blk); res.status = STATUS_OK; return res; @@ -3528,7 +3528,7 @@ namespace cryptonote { namespace rpc { entry.name_hash = record.name_hash; entry.owner = record.owner.to_string(nettype()); if (record.backup_owner) entry.backup_owner = record.backup_owner.to_string(nettype()); - entry.encrypted_value = oxenmq::to_hex(record.encrypted_value.to_view()); + entry.encrypted_value = oxenc::to_hex(record.encrypted_value.to_view()); entry.expiration_height = record.expiration_height; entry.update_height = record.update_height; entry.txid = tools::type_to_hex(record.txid); @@ -3590,7 +3590,7 @@ namespace cryptonote { namespace rpc { entry.name_hash = std::move(record.name_hash); if (record.owner) entry.owner = record.owner.to_string(nettype()); if (record.backup_owner) entry.backup_owner = record.backup_owner.to_string(nettype()); - entry.encrypted_value = oxenmq::to_hex(record.encrypted_value.to_view()); + entry.encrypted_value = oxenc::to_hex(record.encrypted_value.to_view()); entry.update_height = record.update_height; entry.expiration_height = record.expiration_height; entry.txid = tools::type_to_hex(record.txid); @@ -3622,9 +3622,9 @@ namespace cryptonote { namespace rpc { type, *name_hash, m_core.get_current_blockchain_height())) { auto [val, nonce] = mapping->value_nonce(type); - res.encrypted_value = oxenmq::to_hex(val); + res.encrypted_value = oxenc::to_hex(val); if (val.size() < mapping->to_view().size()) - res.nonce = oxenmq::to_hex(nonce); + res.nonce = oxenc::to_hex(nonce); } return res; } diff --git a/src/rpc/http_server.cpp b/src/rpc/http_server.cpp index e2d482236..5c0ffdd2a 100644 --- a/src/rpc/http_server.cpp +++ b/src/rpc/http_server.cpp @@ -2,7 +2,6 @@ #include "http_server.h" #include #include -#include #include #include #include "common/command_line.h" diff --git a/src/rpc/http_server_base.cpp b/src/rpc/http_server_base.cpp index 3acd1154e..73c0413d7 100644 --- a/src/rpc/http_server_base.cpp +++ b/src/rpc/http_server_base.cpp @@ -1,7 +1,7 @@ #include "http_server_base.h" -#include -#include +#include +#include #include "common/string_util.h" // epee: @@ -25,9 +25,9 @@ namespace cryptonote::rpc { std::optional check_authorization(std::string_view auth_header, std::string_view realm, Callback check_login) { std::string fail = "Basic realm=\"" + std::string{realm} + "\", charset=\"UTF-8\""; auto parts = tools::split_any(auth_header, " \t\r\n", true); - if (parts.size() < 2 || parts[0] != "Basic"sv || !oxenmq::is_base64(parts[1])) + if (parts.size() < 2 || parts[0] != "Basic"sv || !oxenc::is_base64(parts[1])) return fail; - auto login = oxenmq::from_base64(parts[1]); + auto login = oxenc::from_base64(parts[1]); auto colon = login.find(':'); if (colon == std::string_view::npos) return fail; @@ -144,7 +144,7 @@ namespace cryptonote::rpc { result << ']'; } else - result << "{unknown:" << oxenmq::to_hex(addr) << "}"; + result << "{unknown:" << oxenc::to_hex(addr) << "}"; return result.str(); } diff --git a/src/rpc/lmq_server.cpp b/src/rpc/lmq_server.cpp index 7e21fdfb2..0ea7e13ae 100644 --- a/src/rpc/lmq_server.cpp +++ b/src/rpc/lmq_server.cpp @@ -64,10 +64,10 @@ auto as_x_pubkeys(const std::vector& pk_strings) { std::vector pks; pks.reserve(pk_strings.size()); for (const auto& pkstr : pk_strings) { - if (pkstr.size() != 64 || !oxenmq::is_hex(pkstr)) + if (pkstr.size() != 64 || !oxenc::is_hex(pkstr)) throw std::runtime_error("Invalid LMQ login pubkey: '" + pkstr + "'; expected 64-char hex pubkey"); pks.emplace_back(); - oxenmq::to_hex(pkstr.begin(), pkstr.end(), reinterpret_cast(&pks.back())); + oxenc::to_hex(pkstr.begin(), pkstr.end(), reinterpret_cast(&pks.back())); } return pks; } diff --git a/src/serialization/json_archive.h b/src/serialization/json_archive.h index 00fca2597..c2a28b3a5 100644 --- a/src/serialization/json_archive.h +++ b/src/serialization/json_archive.h @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace serialization { @@ -115,7 +115,7 @@ struct json_archiver : public serializer void serialize_blob(void *buf, size_t len, std::string_view delimiter="\""sv) { stream_ << delimiter; auto* begin = static_cast(buf); - oxenmq::to_hex(begin, begin + len, std::ostreambuf_iterator{stream_}); + oxenc::to_hex(begin, begin + len, std::ostreambuf_iterator{stream_}); stream_ << delimiter; } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 9d6d354f2..4d88f32b8 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include "epee/console_handler.h" #include "common/i18n.h" #include "common/command_line.h" @@ -603,7 +603,7 @@ namespace { std::string_view data{k.data, sizeof(k.data)}; std::ostream_iterator osi{std::cout}; - oxenmq::to_hex(data.begin(), data.end(), osi); + oxenc::to_hex(data.begin(), data.end(), osi); } bool long_payment_id_failure(bool ret) @@ -6714,7 +6714,7 @@ bool simple_wallet::ons_update_mapping(std::vector args) } auto& enc_hex = response[0].encrypted_value; - if (!oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE) + if (!oxenc::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE) { LOG_ERROR("invalid ONS data returned from oxend"); fail_msg_writer() << tr("invalid ONS data returned from oxend"); @@ -6724,7 +6724,7 @@ bool simple_wallet::ons_update_mapping(std::vector args) ons::mapping_value mval{}; mval.len = enc_hex.size() / 2; mval.encrypted = true; - oxenmq::from_hex(enc_hex.begin(), enc_hex.end(), mval.buffer.begin()); + oxenc::from_hex(enc_hex.begin(), enc_hex.end(), mval.buffer.begin()); if (!mval.decrypt(tools::lowercase_ascii_string(name), type)) { @@ -6847,7 +6847,7 @@ bool simple_wallet::ons_encrypt(std::vector args) return false; } - tools::success_msg_writer() << "encrypted value=" << oxenmq::to_hex(mval.to_view()); + tools::success_msg_writer() << "encrypted value=" << oxenc::to_hex(mval.to_view()); return true; } //---------------------------------------------------------------------------------------------------- @@ -6956,7 +6956,7 @@ bool simple_wallet::ons_lookup(std::vector args) for (auto const &mapping : response) { auto& enc_hex = mapping.encrypted_value; - if (mapping.entry_index >= args.size() || !oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE) + if (mapping.entry_index >= args.size() || !oxenc::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*ons::mapping_value::BUFFER_SIZE) { fail_msg_writer() << "Received invalid ONS mapping data from oxend"; return false; @@ -6971,7 +6971,7 @@ bool simple_wallet::ons_lookup(std::vector args) ons::mapping_value value{}; value.len = enc_hex.size() / 2; value.encrypted = true; - oxenmq::from_hex(enc_hex.begin(), enc_hex.end(), value.buffer.begin()); + oxenc::from_hex(enc_hex.begin(), enc_hex.end(), value.buffer.begin()); if (!value.decrypt(name, mapping.type)) { @@ -7040,7 +7040,7 @@ bool simple_wallet::ons_by_owner(const std::vector& args) return false; } - if (!(oxenmq::is_hex(arg) && arg.size() == 64) && (!cryptonote::is_valid_address(arg, m_wallet->nettype()))) + if (!(oxenc::is_hex(arg) && arg.size() == 64) && (!cryptonote::is_valid_address(arg, m_wallet->nettype()))) { fail_msg_writer() << "arg contains non valid characters: " << arg; return false; @@ -7077,7 +7077,7 @@ bool simple_wallet::ons_by_owner(const std::vector& args) { name = got->second.name; ons::mapping_value mv; - if (ons::mapping_value::validate_encrypted(entry.type, oxenmq::from_hex(entry.encrypted_value), &mv) + if (ons::mapping_value::validate_encrypted(entry.type, oxenc::from_hex(entry.encrypted_value), &mv) && mv.decrypt(name, entry.type)) value = mv.to_readable_value(nettype, entry.type); } @@ -10150,7 +10150,7 @@ void simple_wallet::commit_or_save(std::vector& ptx_ { cryptonote::blobdata blob; tx_to_blob(ptx.tx, blob); - const std::string blob_hex = oxenmq::to_hex(blob); + const std::string blob_hex = oxenc::to_hex(blob); fs::path filename = fs::u8path("raw_oxen_tx"); if (ptx_vector.size() > 1) filename += "_" + std::to_string(i++); bool success = m_wallet->save_to_file(filename, blob_hex, true); diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp index bd456f282..f21a7265b 100644 --- a/src/wallet/api/pending_transaction.cpp +++ b/src/wallet/api/pending_transaction.cpp @@ -231,7 +231,7 @@ std::string PendingTransactionImpl::multisigSignData() { txSet.m_signers = m_signers; auto cipher = m_wallet.wallet()->save_multisig_tx(txSet); - return oxenmq::to_hex(cipher); + return oxenc::to_hex(cipher); } catch (const std::exception& e) { m_status = {Status_Error, std::string(tr("Couldn't multisig sign data: ")) + e.what()}; } diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 57156e602..24c4132bd 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -339,14 +339,14 @@ std::string Wallet::genPaymentId() EXPORT bool Wallet::paymentIdValid(const std::string &payment_id) { - return payment_id.size() == 16 && oxenmq::is_hex(payment_id); + return payment_id.size() == 16 && oxenc::is_hex(payment_id); } EXPORT bool Wallet::serviceNodePubkeyValid(const std::string &str) { crypto::public_key sn_key; - return str.size() == 64 && oxenmq::is_hex(str); + return str.size() == 64 && oxenc::is_hex(str); } EXPORT @@ -1470,7 +1470,7 @@ bool WalletImpl::exportMultisigImages(std::string& images) { checkMultisigWalletReady(w); auto blob = w->export_multisig(); - images = oxenmq::to_hex(blob); + images = oxenc::to_hex(blob); return true; } catch (const std::exception& e) { LOG_ERROR("Error on exporting multisig images: " << e.what()); diff --git a/src/wallet/message_store.cpp b/src/wallet/message_store.cpp index 1b96e13b0..c618d5f87 100644 --- a/src/wallet/message_store.cpp +++ b/src/wallet/message_store.cpp @@ -336,7 +336,7 @@ std::string message_store::create_auto_config_token() const crypto::hash &hash = crypto::cn_fast_hash(token_bytes.data(), token_bytes.size()); token_bytes += hash.data[0]; std::string prefix(AUTO_CONFIG_TOKEN_PREFIX); - return prefix + oxenmq::to_hex(token_bytes); + return prefix + oxenc::to_hex(token_bytes); } // Add a message for sending "me" address data to the auto-config transport address diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index ab0c87aad..d7253e453 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include "common/password.h" #include "common/string_util.h" #include "cryptonote_basic/tx_extra.h" @@ -6948,7 +6948,7 @@ void wallet2::commit_tx(pending_tx& ptx, bool blink) light_rpc::SUBMIT_RAW_TX::response ores{}; oreq.address = get_account().get_public_address_str(m_nettype); oreq.view_key = tools::type_to_hex(get_account().get_keys().m_view_secret_key); - oreq.tx = oxenmq::to_hex(tx_to_blob(ptx.tx)); + oreq.tx = oxenc::to_hex(tx_to_blob(ptx.tx)); oreq.blink = blink; bool r = invoke_http(oreq, ores); THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "submit_raw_tx"); @@ -6962,7 +6962,7 @@ void wallet2::commit_tx(pending_tx& ptx, bool blink) { // Normal submit rpc::SEND_RAW_TX::request req{}; - req.tx_as_hex = oxenmq::to_hex(tx_to_blob(ptx.tx)); + req.tx_as_hex = oxenc::to_hex(tx_to_blob(ptx.tx)); req.do_not_relay = false; req.do_sanity_checks = true; req.blink = blink; @@ -7309,7 +7309,7 @@ bool wallet2::sign_tx(unsigned_tx_set& exported_txs, const fs::path& signed_file { for (size_t i = 0; i < signed_txes.ptx.size(); ++i) { - std::string tx_as_hex = oxenmq::to_hex(tx_to_blob(signed_txes.ptx[i].tx)); + std::string tx_as_hex = oxenc::to_hex(tx_to_blob(signed_txes.ptx[i].tx)); fs::path raw_filename = signed_filename; raw_filename += "_raw"; if (signed_txes.ptx.size() > 1) raw_filename += "_" + std::to_string(i); @@ -8767,7 +8767,7 @@ static ons_prepared_args prepare_tx_extra_oxen_name_system_values(wallet2 const cryptonote::rpc::ONS_NAMES_TO_OWNERS::request request = {}; { auto &request_entry = request.entries.emplace_back(); - request_entry.name_hash = oxenmq::to_base64(tools::view_guts(result.name_hash)); + request_entry.name_hash = oxenc::to_base64(tools::view_guts(result.name_hash)); request_entry.types.push_back(ons::db_mapping_type(type)); } @@ -10323,7 +10323,7 @@ void wallet2::light_wallet_get_outs(std::vector= 3 && oxenmq::is_hex(it + 1, it + 3)) + if (*it == '%' && encoded.end() - it >= 3 && oxenc::is_hex(it + 1, it + 3)) { - decoded += oxenmq::from_hex(it + 1, it + 3); + decoded += oxenc::from_hex(it + 1, it + 3); it += 3; } else diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 18d1653a1..22db0ae94 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -954,7 +954,7 @@ namespace tools { return ""; } - return oxenmq::to_hex(oss.str()); + return oxenc::to_hex(oss.str()); } //------------------------------------------------------------------------------------------------------------------------------ template static bool is_error_value(const T &val) { return false; } @@ -1004,14 +1004,14 @@ namespace tools if (m_wallet->multisig()) { - multisig_txset = oxenmq::to_hex(m_wallet->save_multisig_tx(ptx_vector)); + multisig_txset = oxenc::to_hex(m_wallet->save_multisig_tx(ptx_vector)); if (multisig_txset.empty()) throw wallet_rpc_error{error_code::UNKNOWN_ERROR, "Failed to save multisig tx set after creation"}; } else { if (m_wallet->watch_only()){ - unsigned_txset = oxenmq::to_hex(m_wallet->dump_tx_to_str(ptx_vector)); + unsigned_txset = oxenc::to_hex(m_wallet->dump_tx_to_str(ptx_vector)); if (unsigned_txset.empty()) throw wallet_rpc_error{error_code::UNKNOWN_ERROR, "Failed to save unsigned tx set after creation"}; } @@ -1022,7 +1022,7 @@ namespace tools for (auto & ptx : ptx_vector) { bool r = fill(tx_hash, tools::type_to_hex(cryptonote::get_transaction_hash(ptx.tx))); - r = r && (!get_tx_hex || fill(tx_blob, oxenmq::to_hex(tx_to_blob(ptx.tx)))); + r = r && (!get_tx_hex || fill(tx_blob, oxenc::to_hex(tx_to_blob(ptx.tx)))); r = r && (!get_tx_metadata || fill(tx_metadata, ptx_to_string(ptx))); if (!r) throw wallet_rpc_error{error_code::UNKNOWN_ERROR, "Failed to save tx info"}; @@ -1122,7 +1122,7 @@ namespace tools if (ciphertext.empty()) throw wallet_rpc_error{error_code::SIGN_UNSIGNED, "Failed to sign unsigned tx"}; - res.signed_txset = oxenmq::to_hex(ciphertext); + res.signed_txset = oxenc::to_hex(ciphertext); } for (auto &ptx: ptxs) @@ -1140,7 +1140,7 @@ namespace tools { for (auto &ptx: ptxs) { - res.tx_raw_list.push_back(oxenmq::to_hex(cryptonote::tx_to_blob(ptx.tx))); + res.tx_raw_list.push_back(oxenc::to_hex(cryptonote::tx_to_blob(ptx.tx))); } } @@ -2139,7 +2139,7 @@ namespace tools if (m_wallet->key_on_device()) throw wallet_rpc_error{error_code::UNKNOWN_ERROR, "command not supported by HW wallet"}; - res.outputs_data_hex = oxenmq::to_hex(m_wallet->export_outputs_to_str(req.all)); + res.outputs_data_hex = oxenc::to_hex(m_wallet->export_outputs_to_str(req.all)); return res; } @@ -2742,7 +2742,7 @@ namespace { cryptonote::blobdata info; info = m_wallet->export_multisig(); - res.info = oxenmq::to_hex(info); + res.info = oxenc::to_hex(info); return res; } @@ -2861,7 +2861,7 @@ namespace { throw wallet_rpc_error{error_code::MULTISIG_SIGNATURE, "Failed to sign multisig tx: "s + e.what()}; } - res.tx_data_hex = oxenmq::to_hex(m_wallet->save_multisig_tx(txs)); + res.tx_data_hex = oxenc::to_hex(m_wallet->save_multisig_tx(txs)); if (!txids.empty()) { for (const crypto::hash &txid: txids) @@ -3334,12 +3334,12 @@ namespace { res_e.expired = *res_e.expiration_height < curr_height; res_e.txid = std::move(rec.txid); - if (req.decrypt && !res_e.encrypted_value.empty() && oxenmq::is_hex(res_e.encrypted_value)) + if (req.decrypt && !res_e.encrypted_value.empty() && oxenc::is_hex(res_e.encrypted_value)) { ons::mapping_value value; const auto type = entry_types[type_offset + rec.entry_index]; std::string errmsg; - if (ons::mapping_value::validate_encrypted(type, oxenmq::from_hex(res_e.encrypted_value), &value, &errmsg) + if (ons::mapping_value::validate_encrypted(type, oxenc::from_hex(res_e.encrypted_value), &value, &errmsg) && value.decrypt(res_e.name, type)) res_e.value = value.to_readable_value(nettype, type); else @@ -3403,7 +3403,7 @@ namespace { if (req.encrypted_value.size() >= (ons::mapping_value::BUFFER_SIZE * 2)) throw wallet_rpc_error{error_code::ONS_VALUE_TOO_LONG, "Value too long to decrypt=" + req.encrypted_value}; - if (!oxenmq::is_hex(req.encrypted_value)) + if (!oxenc::is_hex(req.encrypted_value)) throw wallet_rpc_error{error_code::ONS_VALUE_NOT_HEX, "Value is not hex=" + req.encrypted_value}; // --------------------------------------------------------------------------------------------- @@ -3432,7 +3432,7 @@ namespace { ons::mapping_value value = {}; value.len = req.encrypted_value.size() / 2; value.encrypted = true; - oxenmq::from_hex(req.encrypted_value.begin(), req.encrypted_value.end(), value.buffer.begin()); + oxenc::from_hex(req.encrypted_value.begin(), req.encrypted_value.end(), value.buffer.begin()); if (!value.decrypt(req.name, type)) throw wallet_rpc_error{error_code::ONS_VALUE_NOT_HEX, "Value decryption failure"}; @@ -3467,7 +3467,7 @@ namespace { if (!value.encrypt(req.name, nullptr, old_argon2)) throw wallet_rpc_error{error_code::ONS_VALUE_ENCRYPT_FAILED, "Value encryption failure"}; - return {oxenmq::to_hex(value.to_view())}; + return {oxenc::to_hex(value.to_view())}; } std::unique_ptr wallet_rpc_server::load_wallet() diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp index c1ed48b34..5486071e4 100644 --- a/tests/core_proxy/core_proxy.cpp +++ b/tests/core_proxy/core_proxy.cpp @@ -171,7 +171,7 @@ std::vector tests::proxy_core::par std::cout << txi.tx_hash << "\n"; std::cout << tx_prefix_hash << "\n"; std::cout << tx_blobs[i].size() << "\n"; - //std::cout << oxenmq::to_hex(tx_blob) << "\n\n"; + //std::cout << oxenc::to_hex(tx_blob) << "\n\n"; std::cout << obj_to_json_str(txi.tx) << "\n"; std::cout << "\nENDTX\n"; txi.result = txi.parsed = true; diff --git a/tests/functional_tests/transactions_generation_from_blockchain.cpp b/tests/functional_tests/transactions_generation_from_blockchain.cpp index e58558a7d..1ed1e20b0 100644 --- a/tests/functional_tests/transactions_generation_from_blockchain.cpp +++ b/tests/functional_tests/transactions_generation_from_blockchain.cpp @@ -134,7 +134,7 @@ bool make_tx(blockchain_storage& bch) } rpc::SEND_RAW_TX::request req; - req.tx_as_hex = oxenmq::to_hex(tx_to_blob(tx)); + req.tx_as_hex = oxenc::to_hex(tx_to_blob(tx)); rpc::SEND_RAW_TX::response daemon_send_resp; r = net_utils::http::invoke_http_json_remote_command(m_daemon_address + "/sendrawtransaction", req, daemon_send_resp, m_http_client); CHECK_AND_ASSERT_MES(r, false, "failed to send transaction"); diff --git a/tests/io.h b/tests/io.h index 7367d3189..8020c2432 100644 --- a/tests/io.h +++ b/tests/io.h @@ -33,13 +33,13 @@ #include #include #include -#include +#include inline bool hexdecode(const char *from, std::size_t length, void *to) { const char* end = from + 2*length; - if (!oxenmq::is_hex(from, end)) + if (!oxenc::is_hex(from, end)) return false; - oxenmq::from_hex(from, end, reinterpret_cast(to)); + oxenc::from_hex(from, end, reinterpret_cast(to)); return true; } diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 170d5665d..ac0743d57 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -160,7 +160,7 @@ TEST(serialization, custom_type_serialization) { std::string blob; ASSERT_NO_THROW(blob = serialization::dump_binary(s1)); - ASSERT_EQ(oxenmq::to_hex(blob), "03e100000000e005000000030001003132333435363738e101000000020a001600"); + ASSERT_EQ(oxenc::to_hex(blob), "03e100000000e005000000030001003132333435363738e101000000020a001600"); ASSERT_NO_THROW(try_parse(blob)); blob[6] = '\xE1'; @@ -191,53 +191,53 @@ TEST(serialization, serializes_vector_uint64_as_varint) std::string blob; ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "00"); + ASSERT_EQ(oxenc::to_hex(blob), "00"); // +1 byte v.push_back(0); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0100"); + ASSERT_EQ(oxenc::to_hex(blob), "0100"); // ^^ // +1 byte v.push_back(1); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "020001"); + ASSERT_EQ(oxenc::to_hex(blob), "020001"); // ^^ // +2 bytes v.push_back(0x80); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0300018001"); + ASSERT_EQ(oxenc::to_hex(blob), "0300018001"); // ^^^^ // +2 bytes v.push_back(0xFF); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0400018001ff01"); + ASSERT_EQ(oxenc::to_hex(blob), "0400018001ff01"); // ^^^^ // +2 bytes v.push_back(0x3FFF); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0500018001ff01ff7f"); + ASSERT_EQ(oxenc::to_hex(blob), "0500018001ff01ff7f"); // ^^^^ // +3 bytes v.push_back(0x40FF); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0600018001ff01ff7fff8101"); + ASSERT_EQ(oxenc::to_hex(blob), "0600018001ff01ff7fff8101"); // ^^^^^^ // +10 bytes v.push_back(0xFFFF'FFFF'FFFF'FFFF); ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0700018001ff01ff7fff8101ffffffffffffffffff01"); + ASSERT_EQ(oxenc::to_hex(blob), "0700018001ff01ff7fff8101ffffffffffffffffff01"); // ^^^^^^^^^^^^^^^^^^^^ v = {0x64, 0xcc, 0xbf04}; ASSERT_NO_THROW(blob = serialization::dump_binary(v)); - ASSERT_EQ(oxenmq::to_hex(blob), "0364cc0184fe02"); + ASSERT_EQ(oxenc::to_hex(blob), "0364cc0184fe02"); } TEST(serialization, serializes_vector_int64_as_fixed_int) @@ -445,7 +445,7 @@ TEST(serialization, serializes_transaction_signatures_correctly) tx.signatures[i][j].c.data[2*i + j] = ((i+1) << 4) + 2*i + j + 1; tx.invalidate_hashes(); ASSERT_NO_THROW(blob = serialization::dump_binary(tx)); - ASSERT_EQ(oxenmq::to_hex(blob), + ASSERT_EQ(oxenc::to_hex(blob), "0100020201020cfd1a42424242424242424242424242424242424242424242424242424242424242420201020cfd1a42424242424242424242424242424242424242424242424242424242424242420000" "11000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "00120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"