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.
This commit is contained in:
Jason Rhinelander 2022-02-10 14:25:55 -04:00
parent 83ac88e8ab
commit 6fcfd0b8ba
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262
39 changed files with 219 additions and 199 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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)

2
external/loki-mq vendored

@ -1 +1 @@
Subproject commit 51754037ea19204610751c2ea8ae72b7ed6c1818
Subproject commit 5c72a57eca120750ecf557ce5a668fb38242956b

1
external/oxen-encoding vendored Submodule

@ -0,0 +1 @@
Subproject commit a0912ab4bf3b5e83b42715eff6f632c8912b21e4

View File

@ -4,8 +4,8 @@ extern "C" {
}
#include <iostream>
#include <fstream>
#include <oxenmq/hex.h>
#include <oxenmq/base32z.h>
#include <oxenc/hex.h>
#include <oxenc/base32z.h>
#include <string_view>
#include <string>
#include <list>
@ -137,7 +137,7 @@ int generate(bool ed25519, std::list<std::string_view> 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<std::string_view> 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<std::string_view> 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<std::string_view> 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<std::string_view> 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<unsigned char, crypto_sign_SECRETKEYBYTES> skey;
std::array<unsigned char, crypto_sign_PUBLICKEYBYTES> pubkey;
std::array<unsigned char, crypto_sign_SEEDBYTES> seed;
std::optional<std::array<unsigned char, crypto_sign_PUBLICKEYBYTES>> 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<std::string_view> 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<unsigned char, crypto_scalarmult_curve25519_BYTES> 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<std::string_view> 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))

View File

@ -1,5 +1,5 @@
#pragma once
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#include <type_traits>
#include "epee/span.h" // epee
@ -11,9 +11,9 @@ namespace tools {
!std::is_const_v<T> && (std::is_trivially_copyable_v<T> || epee::is_byte_spannable<T>)
>>
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<char*>(&x));
oxenc::from_hex(hex.begin(), hex.end(), reinterpret_cast<char*>(&x));
return true;
}
@ -23,6 +23,6 @@ namespace tools {
|| epee::is_byte_spannable<T>
>>
std::string type_to_hex(const T& val) {
return oxenmq::to_hex(std::string_view{reinterpret_cast<const char*>(&val), sizeof(val)});
return oxenc::to_hex(std::string_view{reinterpret_cast<const char*>(&val), sizeof(val)});
}
}

View File

@ -32,7 +32,7 @@
#include <atomic>
#include <boost/algorithm/string.hpp>
#include <limits>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#include <variant>
#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<crypto::public_key>& additional_tx_pub_keys, size_t output_index)

View File

@ -31,7 +31,7 @@
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <numeric>
#include <oxenmq/base64.h>
#include <oxenc/base64.h>
#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;
}

View File

@ -37,7 +37,7 @@
#include <unordered_set>
#include <sstream>
#include <iomanip>
#include <oxenmq/base32z.h>
#include <oxenc/base32z.h>
extern "C" {
#include <sodium.h>
@ -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

View File

@ -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;

View File

@ -16,9 +16,9 @@
#include "cryptonote_core/blockchain.h"
#include "oxen_economy.h"
#include <oxenmq/hex.h>
#include <oxenmq/base32z.h>
#include <oxenmq/base64.h>
#include <oxenc/hex.h>
#include <oxenc/base32z.h>
#include <oxenc/base64.h>
#include <sqlite3.h>
@ -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<cryptonote::address_parse_info> 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<cryptonote::address_parse_info> 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<std::string> 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<uint64_t> 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<mapping_value> 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<mapping_value> 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<mapping_value> name_system_db::resolve(mapping_type type, std::str
std::vector<mapping_record> name_system_db::get_mappings(std::vector<mapping_type> const &types, std::string_view name_base64_hash, std::optional<uint64_t> 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<mapping_record> result;
if (types.empty())
return result;

View File

@ -6,7 +6,7 @@
#include "epee/span.h"
#include "cryptonote_basic/tx_extra.h"
#include "common/fs.h"
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#include <cassert>
#include <string>
@ -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)
{

View File

@ -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;
}

View File

@ -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)";
}

View File

@ -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<bt_dict>(serialized_proof);
//snode_version <X,X,X>
@ -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)) {

View File

@ -1,7 +1,8 @@
#pragma once
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
#include <oxenmq/bt_serialize.h>
#include <oxenc/bt_serialize.h>
#include <oxenc/bt_value.h>
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<uint16_t, 3> ss_version, uint16_t quorumnet_port, std::array<uint16_t, 3> 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;

View File

@ -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<txin_gen>(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;

View File

@ -40,7 +40,7 @@
#include "common/random.h"
#include <oxenmq/oxenmq.h>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#include <shared_mutex>
#include <iterator>
#include <time.h>
@ -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<blink_tx::subquorum>;
static_assert(std::is_same<const uint8_t, decltype(NUM_BLINK_QUORUMS)>(), "unexpected underlying blink quorum count type");
@ -72,7 +75,7 @@ using pending_signature_set = std::unordered_set<pending_signature, pending_sign
struct QnetState {
cryptonote::core &core;
OxenMQ &omq{core.get_omq()};
oxenmq::OxenMQ &omq{core.get_omq()};
// Track submitted blink txes here; unlike the blinks stored in the mempool we store these ones
// more liberally to track submitted blinks, even if unsigned/unacceptable, while the mempool
@ -82,7 +85,7 @@ struct QnetState {
struct blink_metadata {
std::shared_ptr<blink_tx> 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<blink_tx> &btxptr, quorum_array &blink_quorums, uint64_t quorum_checksum, std::list<pending_signature> &&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<blink_tx> &
/// "#" - 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<blink_tx> 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()) {

View File

@ -41,7 +41,7 @@
#include "cryptonote_basic/hardfork.h"
#include "checkpoints/checkpoints.h"
#include <exception>
#include <oxenmq/base32z.h>
#include <oxenc/base32z.h>
#include <fmt/core.h>
#include <fstream>
@ -842,11 +842,11 @@ bool rpc_command_executor::print_transaction(const crypto::hash& transaction_has
std::optional<cryptonote::transaction> 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";
//

View File

@ -34,7 +34,7 @@
#include "oxen_economy.h"
#include "common/hex.h"
#include "version.h"
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#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; }

View File

@ -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<const char*>(&sw), sizeof(sw)})
<< ' ' << oxenmq::to_hex(buffer_recv, buffer_recv + length_recv));
<< oxenc::to_hex(std::string_view{reinterpret_cast<const char*>(&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) {

View File

@ -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() {

View File

@ -28,7 +28,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#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<const char*>(buff), len}));
MDEBUG(msg << ": " << oxenc::to_hex(std::string_view{reinterpret_cast<const char*>(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));
}
}

View File

@ -38,7 +38,7 @@
#include <boost/endian/conversion.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/udp.hpp>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#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){

View File

@ -38,7 +38,7 @@
#include <iterator>
#include <type_traits>
#include <variant>
#include <oxenmq/base64.h>
#include <oxenc/base64.h>
#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;
}

View File

@ -2,7 +2,6 @@
#include "http_server.h"
#include <chrono>
#include <exception>
#include <oxenmq/base64.h>
#include <boost/endian/conversion.hpp>
#include <oxenmq/variant.h>
#include "common/command_line.h"

View File

@ -1,7 +1,7 @@
#include "http_server_base.h"
#include <oxenmq/base64.h>
#include <oxenmq/hex.h>
#include <oxenc/base64.h>
#include <oxenc/hex.h>
#include "common/string_util.h"
// epee:
@ -25,9 +25,9 @@ namespace cryptonote::rpc {
std::optional<std::string> 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();
}

View File

@ -64,10 +64,10 @@ auto as_x_pubkeys(const std::vector<std::string>& pk_strings) {
std::vector<crypto::x25519_public_key> 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<char *>(&pks.back()));
oxenc::to_hex(pkstr.begin(), pkstr.end(), reinterpret_cast<char *>(&pks.back()));
}
return pks;
}

View File

@ -42,7 +42,7 @@
#include <iostream>
#include <iomanip>
#include <exception>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
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<unsigned char*>(buf);
oxenmq::to_hex(begin, begin + len, std::ostreambuf_iterator{stream_});
oxenc::to_hex(begin, begin + len, std::ostreambuf_iterator{stream_});
stream_ << delimiter;
}

View File

@ -53,7 +53,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
#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<char> 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<std::string> args)
}
auto& enc_hex = response[0].encrypted_value;
if (!oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*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<std::string> 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<std::string> 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<std::string> args)
for (auto const &mapping : response)
{
auto& enc_hex = mapping.encrypted_value;
if (mapping.entry_index >= args.size() || !oxenmq::is_hex(enc_hex) || enc_hex.size() % 2 != 0 || enc_hex.size() > 2*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<std::string> 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<std::string>& 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<std::string>& 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<tools::wallet2::pending_tx>& 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);

View File

@ -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()};
}

View File

@ -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());

View File

@ -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

View File

@ -39,7 +39,7 @@
#include <openssl/pem.h>
#include <type_traits>
#include <cpr/parameters.h>
#include <oxenmq/base64.h>
#include <oxenc/base64.h>
#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<light_rpc::SUBMIT_RAW_TX>(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<std::vector<tools::wallet2::get_
rct::key mask{}; // decrypted mask - not used here
rct::key rct_commit{};
const auto& pkey = ores.amount_outs[amount_key].outputs[i].public_key;
THROW_WALLET_EXCEPTION_IF(pkey.size() != 64 || !oxenmq::is_hex(pkey), error::wallet_internal_error, "Invalid public_key");
THROW_WALLET_EXCEPTION_IF(pkey.size() != 64 || !oxenc::is_hex(pkey), error::wallet_internal_error, "Invalid public_key");
tools::hex_to_type(ores.amount_outs[amount_key].outputs[i].public_key, tx_public_key);
const uint64_t global_index = ores.amount_outs[amount_key].outputs[i].global_index;
if(!light_wallet_parse_rct_str(ores.amount_outs[amount_key].outputs[i].rct, tx_public_key, 0, mask, rct_commit, false))
@ -10429,14 +10429,14 @@ void wallet2::light_wallet_get_unspent_outs()
bool add_transfer = true;
crypto::key_image unspent_key_image;
crypto::public_key tx_public_key{};
THROW_WALLET_EXCEPTION_IF(o.tx_pub_key.size() != 64 || !oxenmq::is_hex(o.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
THROW_WALLET_EXCEPTION_IF(o.tx_pub_key.size() != 64 || !oxenc::is_hex(o.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
tools::hex_to_type(o.tx_pub_key, tx_public_key);
for (const std::string &ski: o.spend_key_images) {
spent = false;
// Check if key image is ours
THROW_WALLET_EXCEPTION_IF(ski.size() != 64 || !oxenmq::is_hex(ski), error::wallet_internal_error, "Invalid key image");
THROW_WALLET_EXCEPTION_IF(ski.size() != 64 || !oxenc::is_hex(ski), error::wallet_internal_error, "Invalid key image");
tools::hex_to_type(ski, unspent_key_image);
if(light_wallet_key_image_is_ours(unspent_key_image, tx_public_key, o.index)){
MTRACE("Output " << o.public_key << " is spent. Key image: " << ski);
@ -10451,9 +10451,9 @@ void wallet2::light_wallet_get_unspent_outs()
crypto::hash txid;
crypto::public_key tx_pub_key;
crypto::public_key public_key;
THROW_WALLET_EXCEPTION_IF(o.tx_hash.size() != 64 || !oxenmq::is_hex(o.tx_hash), error::wallet_internal_error, "Invalid tx_hash field");
THROW_WALLET_EXCEPTION_IF(o.public_key.size() != 64 || !oxenmq::is_hex(o.public_key), error::wallet_internal_error, "Invalid public_key field");
THROW_WALLET_EXCEPTION_IF(o.tx_pub_key.size() != 64 || !oxenmq::is_hex(o.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
THROW_WALLET_EXCEPTION_IF(o.tx_hash.size() != 64 || !oxenc::is_hex(o.tx_hash), error::wallet_internal_error, "Invalid tx_hash field");
THROW_WALLET_EXCEPTION_IF(o.public_key.size() != 64 || !oxenc::is_hex(o.public_key), error::wallet_internal_error, "Invalid public_key field");
THROW_WALLET_EXCEPTION_IF(o.tx_pub_key.size() != 64 || !oxenc::is_hex(o.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
tools::hex_to_type(o.tx_hash, txid);
tools::hex_to_type(o.public_key, public_key);
tools::hex_to_type(o.tx_pub_key, tx_pub_key);
@ -10597,8 +10597,8 @@ void wallet2::light_wallet_get_address_txs()
{
crypto::public_key tx_public_key;
crypto::key_image key_image;
THROW_WALLET_EXCEPTION_IF(so.tx_pub_key.size() != 64 || !oxenmq::is_hex(so.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
THROW_WALLET_EXCEPTION_IF(so.key_image.size() != 64 || !oxenmq::is_hex(so.key_image), error::wallet_internal_error, "Invalid key_image field");
THROW_WALLET_EXCEPTION_IF(so.tx_pub_key.size() != 64 || !oxenc::is_hex(so.tx_pub_key), error::wallet_internal_error, "Invalid tx_pub_key field");
THROW_WALLET_EXCEPTION_IF(so.key_image.size() != 64 || !oxenc::is_hex(so.key_image), error::wallet_internal_error, "Invalid key_image field");
tools::hex_to_type(so.tx_pub_key, tx_public_key);
tools::hex_to_type(so.key_image, key_image);
@ -10615,8 +10615,8 @@ void wallet2::light_wallet_get_address_txs()
crypto::hash payment_id = null_hash;
crypto::hash tx_hash;
THROW_WALLET_EXCEPTION_IF(t.payment_id.size() != 64 || !oxenmq::is_hex(t.payment_id), error::wallet_internal_error, "Invalid payment_id field");
THROW_WALLET_EXCEPTION_IF(t.hash.size() != 64 || !oxenmq::is_hex(t.hash), error::wallet_internal_error, "Invalid hash field");
THROW_WALLET_EXCEPTION_IF(t.payment_id.size() != 64 || !oxenc::is_hex(t.payment_id), error::wallet_internal_error, "Invalid payment_id field");
THROW_WALLET_EXCEPTION_IF(t.hash.size() != 64 || !oxenc::is_hex(t.hash), error::wallet_internal_error, "Invalid hash field");
tools::hex_to_type(t.payment_id, payment_id);
tools::hex_to_type(t.hash, tx_hash);
@ -10755,8 +10755,8 @@ bool wallet2::light_wallet_parse_rct_str(const std::string& rct_string, const cr
rct::key encrypted_mask;
std::string rct_commit_str = rct_string.substr(0,64);
std::string encrypted_mask_str = rct_string.substr(64,64);
THROW_WALLET_EXCEPTION_IF(rct_commit_str.size() != 64 || !oxenmq::is_hex(rct_commit_str), error::wallet_internal_error, "Invalid rct commit hash: " + rct_commit_str);
THROW_WALLET_EXCEPTION_IF(encrypted_mask_str.size() != 64 || !oxenmq::is_hex(encrypted_mask_str), error::wallet_internal_error, "Invalid rct mask: " + encrypted_mask_str);
THROW_WALLET_EXCEPTION_IF(rct_commit_str.size() != 64 || !oxenc::is_hex(rct_commit_str), error::wallet_internal_error, "Invalid rct commit hash: " + rct_commit_str);
THROW_WALLET_EXCEPTION_IF(encrypted_mask_str.size() != 64 || !oxenc::is_hex(encrypted_mask_str), error::wallet_internal_error, "Invalid rct mask: " + encrypted_mask_str);
tools::hex_to_type(rct_commit_str, rct_commit);
tools::hex_to_type(encrypted_mask_str, encrypted_mask);
if (decrypt) {
@ -14399,9 +14399,9 @@ static std::string uri_decode(std::string_view encoded)
std::string decoded;
for (auto it = encoded.begin(); it != encoded.end(); )
{
if (*it == '%' && encoded.end() - it >= 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

View File

@ -954,7 +954,7 @@ namespace tools
{
return "";
}
return oxenmq::to_hex(oss.str());
return oxenc::to_hex(oss.str());
}
//------------------------------------------------------------------------------------------------------------------------------
template<typename T> 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<tools::wallet2> wallet_rpc_server::load_wallet()

View File

@ -171,7 +171,7 @@ std::vector<cryptonote::core::tx_verification_batch_info> 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;

View File

@ -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");

View File

@ -33,13 +33,13 @@
#include <iostream>
#include <type_traits>
#include <vector>
#include <oxenmq/hex.h>
#include <oxenc/hex.h>
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<char*>(to));
oxenc::from_hex(from, end, reinterpret_cast<char*>(to));
return true;
}

View File

@ -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"