What changed, and why it matters
This is a large but straightforward code cleanup that swaps the old Boost optional type for the modern C++ standard library equivalent (std::optional). It touches many files but does not change program logic, security checks, or behavior. There is no indication this fixes a security bug.
No security action required. Treat as routine maintenance/refactoring. Reviewers may verify the build compiles and tests pass after the type swap.
Security signals we found
No security-relevant behavioral changes observed
No new input parsing or boundary logic
No changes to authentication, cryptography, or network protocol handling
No vendor security disclosure or advisory referenced
Evidence from the diff
The commit replaces boost::optional and boost::none with std::optional and std::nullopt across the Monero codebase, including epee networking, HTTP authentication, wallet RPC, and tests. It also adds a couple of missing standard headers (cstddef, cstdint) and keeps boost::optional only where still needed (crypto.cpp, device.hpp). A few call sites are updated to match changed function signatures (e.g., core_rpc_server init in tests). The diff is purely a modernization refactor with no semantic changes to security-critical logic.
Changed components
contrib/epee networking and HTTP librarieswallet2, wallet RPC server, simplewalletdaemon RPC command executorTrezor transportunit and functional testsInspect captured patch +121 / −121
### contrib/epee/include/console_handler.h
@@ -32,6 +32,7 @@
#include <condition_variable>
#include <functional>
#include <mutex>
+#include <optional>
#include <thread>
#include <iostream>
#ifdef __OpenBSD__
@@ -327,7 +328,7 @@ namespace epee
template<class chain_handler>
bool run(chain_handler ch_handler, std::function<std::string(void)> prompt, const std::string& usage = "", std::function<void(void)> exit_handler = NULL)
{
- return run(prompt, usage, [&](const boost::optional<std::string>& cmd) { return ch_handler(cmd); }, exit_handler);
+ return run(prompt, usage, [&](const std::optional<std::string>& cmd) { return ch_handler(cmd); }, exit_handler);
}
void stop()
@@ -392,7 +393,7 @@ namespace epee
if (m_cancel)
{
MDEBUG("Input cancelled");
- cmd_handler(boost::none);
+ cmd_handler(std::nullopt);
m_cancel = false;
continue;
}
@@ -610,7 +611,7 @@ namespace epee
return it->second.first(cmd_local);
}
- bool process_command_str(const boost::optional<std::string>& cmd)
+ bool process_command_str(const std::optional<std::string>& cmd)
{
if (!cmd)
return m_cancel_handler();
### contrib/epee/include/fnv1.h
@@ -29,6 +29,9 @@
#pragma once
+#include <cstddef>
+#include <cstdint>
+
namespace epee
{
### contrib/epee/include/net/abstract_http_client.h
@@ -25,8 +25,8 @@
#pragma once
+#include <optional>
#include <string>
-#include <boost/optional/optional.hpp>
#include "http_auth.h"
#include "net/net_ssl.h"
@@ -62,9 +62,9 @@ namespace http
public:
abstract_http_client() {}
virtual ~abstract_http_client() {}
- bool set_server(const std::string& address, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect);
+ bool set_server(const std::string& address, std::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect);
virtual bool set_proxy(const std::string& address);
- virtual void set_server(std::string host, std::string port, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) = 0;
+ virtual void set_server(std::string host, std::string port, std::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) = 0;
virtual void set_auto_connect(bool auto_connect) = 0;
virtual bool connect(std::chrono::milliseconds timeout) = 0;
virtual bool disconnect() = 0;
### contrib/epee/include/net/abstract_tcp_server2.h
@@ -44,6 +44,7 @@
#include <cassert>
#include <map>
#include <memory>
+#include <optional>
#include <condition_variable>
#include <boost/asio/post.hpp>
@@ -53,7 +54,6 @@
#include <boost/array.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/thread/thread.hpp>
-#include <boost/optional.hpp>
#include "byte_slice.h"
#include "net_utils_base.h"
#include "scope_guard.h"
@@ -154,7 +154,7 @@ namespace net_utils
bool start_internal(
bool is_income,
bool is_multithreaded,
- boost::optional<network_address> real_remote,
+ std::optional<network_address> real_remote,
std::string initial_data = {},
t_connection_context* context_out = nullptr
);
### contrib/epee/include/net/abstract_tcp_server2.inl
@@ -935,7 +935,7 @@ namespace net_utils
bool connection<T>::start_internal(
bool is_income,
bool is_multithreaded,
- boost::optional<network_address> real_remote,
+ std::optional<network_address> real_remote,
std::string initial_data,
t_connection_context* context_out
)
### contrib/epee/include/net/http_auth.h
@@ -27,10 +27,10 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
-#include <boost/optional/optional.hpp>
#include <boost/utility/string_ref.hpp>
#include <cstdint>
#include <functional>
+#include <optional>
#include <string>
#include <utility>
#include "wipeable_string.h"
@@ -74,18 +74,18 @@ namespace net_utils
http_server_auth() : user(), rng(), disable_md5(false) {}
http_server_auth(login credentials, std::function<void(size_t, uint8_t*)> r, bool disable_md5 = false);
- //! \return Auth response, or `boost::none` iff `request` had valid auth.
- boost::optional<http_response_info> get_response(const http_request_info& request)
+ //! \return Auth response, or `std::nullopt` iff `request` had valid auth.
+ std::optional<http_response_info> get_response(const http_request_info& request)
{
if (user)
return do_get_response(request);
- return boost::none;
+ return std::nullopt;
}
private:
- boost::optional<http_response_info> do_get_response(const http_request_info& request);
+ std::optional<http_response_info> do_get_response(const http_request_info& request);
- boost::optional<session> user;
+ std::optional<session> user;
std::function<void(size_t, uint8_t*)> rng;
bool disable_md5;
@@ -155,19 +155,19 @@ namespace net_utils
\return A HTTP "Authorization" field if `handle_401(...)` previously
returned `kSuccess`.
*/
- boost::optional<std::pair<std::string, std::string>> get_auth_field(
+ std::optional<std::pair<std::string, std::string>> get_auth_field(
const boost::string_ref method, const boost::string_ref uri)
{
if (user)
return do_get_auth_field(method, uri);
- return boost::none;
+ return std::nullopt;
}
private:
status do_handle_401(const http_response_info&);
- boost::optional<std::pair<std::string, std::string>> do_get_auth_field(boost::string_ref, boost::string_ref);
+ std::optional<std::pair<std::string, std::string>> do_get_auth_field(boost::string_ref, boost::string_ref);
- boost::optional<session> user;
+ std::optional<session> user;
};
}
}
### contrib/epee/include/net/http_client.h
@@ -30,7 +30,6 @@
#include <ctype.h>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
-#include <boost/optional/optional.hpp>
#include <boost/utility/string_ref.hpp>
#include <algorithm>
#include <cctype>
@@ -127,7 +126,7 @@ namespace net_utils
using abstract_http_client::set_server;
- void set_server(std::string host, std::string port, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) override
+ void set_server(std::string host, std::string port, std::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) override
{
CRITICAL_REGION_LOCAL(m_lock);
disconnect();
### contrib/epee/include/net/http_protocol_handler.h
@@ -30,7 +30,7 @@
#ifndef _HTTP_SERVER_H_
#define _HTTP_SERVER_H_
-#include <boost/optional/optional.hpp>
+#include <optional>
#include <string>
#include <unordered_map>
#include "net_utils_base.h"
@@ -57,7 +57,7 @@ namespace net_utils
std::string m_folder;
std::vector<std::string> m_access_control_origins;
std::unordered_map<std::string, std::size_t> m_connections;
- boost::optional<login> m_user;
+ std::optional<login> m_user;
size_t m_max_content_length{std::numeric_limits<size_t>::max()};
std::size_t m_connection_count{0};
std::size_t m_max_public_ip_connections{3};
### contrib/epee/include/net/http_server_impl_base.h
@@ -61,7 +61,7 @@ namespace epee
bool init(std::function<void(size_t, uint8_t*)> rng, const std::string& bind_port = "0", const std::string& bind_ip = "0.0.0.0",
const std::string& bind_ipv6_address = "::", bool use_ipv6 = false, bool require_ipv4 = true,
std::vector<std::string> access_control_origins = std::vector<std::string>(),
- boost::optional<net_utils::http::login> user = boost::none,
+ std::optional<net_utils::http::login> user = std::nullopt,
net_utils::ssl_options_t ssl_options = net_utils::ssl_support_t::e_ssl_support_autodetect,
const std::size_t max_public_ip_connections = DEFAULT_RPC_MAX_CONNECTIONS_PER_PUBLIC_IP,
const std::size_t max_private_ip_connections = DEFAULT_RPC_MAX_CONNECTIONS_PER_PRIVATE_IP,
### contrib/epee/include/net/net_utils_base.h
@@ -32,10 +32,9 @@
#include <boost/uuid/uuid.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/address_v6.hpp>
-#include <boost/optional/optional.hpp>
#include <cstddef>
#include <memory>
-#include <stdexcept>
+#include <optional>
#include <typeinfo>
#include <type_traits>
#include "byte_slice.h"
@@ -276,7 +275,7 @@ namespace net_utils
inline bool operator>=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
{ return !lhs.less(rhs); }
- boost::optional<ipv4_network_address> get_ipv4_mapped_address(const ipv6_network_address& address);
+ std::optional<ipv4_network_address> get_ipv4_mapped_address(const ipv6_network_address& address);
class network_address
{
@@ -404,7 +403,7 @@ namespace net_utils
END_KV_SERIALIZE_MAP()
};
- boost::optional<ipv4_network_address> get_ipv4_mapped_address(const network_address& address);
+ std::optional<ipv4_network_address> get_ipv4_mapped_address(const network_address& address);
inline bool operator==(const network_address& lhs, const network_address& rhs)
{ return lhs.equal(rhs); }
### contrib/epee/include/wipeable_string.h
@@ -28,7 +28,7 @@
#pragma once
-#include <boost/optional/optional.hpp>
+#include <optional>
#include <stddef.h>
#include <vector>
#include <string>
@@ -65,7 +65,7 @@ namespace epee
bool empty() const noexcept { return buffer.empty(); }
void trim();
void split(std::vector<wipeable_string> &fields) const;
- boost::optional<wipeable_string> parse_hexstr() const;
+ std::optional<wipeable_string> parse_hexstr() const;
template<typename T> inline bool hex_to_pod(T &pod) const;
template<typename T> inline bool hex_to_pod(tools::scrubbed<T> &pod) const { return hex_to_pod(unwrap(pod)); }
void resize(size_t sz);
@@ -90,7 +90,7 @@ namespace epee
static_assert(std::is_pod<T>::value, "expected pod type");
if (size() != sizeof(T) * 2)
return false;
- boost::optional<epee::wipeable_string> blob = parse_hexstr();
+ std::optional<epee::wipeable_string> blob = parse_hexstr();
if (!blob)
return false;
if (blob->size() != sizeof(T))
### contrib/epee/src/abstract_http_client.cpp
@@ -121,7 +121,7 @@ namespace net_utils
namespace http
{
//----------------------------------------------------------------------------------------------------
- bool epee::net_utils::http::abstract_http_client::set_server(const std::string& address, boost::optional<login> user, ssl_options_t ssl_options)
+ bool epee::net_utils::http::abstract_http_client::set_server(const std::string& address, std::optional<login> user, ssl_options_t ssl_options)
{
http::url_content parsed{};
const bool r = parse_url(address, parsed);
### contrib/epee/src/http_auth.cpp
@@ -42,7 +42,6 @@
#include <boost/range/algorithm/find_if.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/join.hpp>
-#include <boost/optional/optional.hpp>
#include <boost/spirit/include/karma_generate.hpp>
#include <boost/spirit/include/karma_uint.hpp>
#include <boost/spirit/include/qi_alternative.hpp>
@@ -138,26 +137,26 @@ namespace
};
template<typename... T>
- boost::optional<std::array<char, DigestSize * 2>> operator()(const T&... args) const
+ std::optional<std::array<char, DigestSize * 2>> operator()(const T&... args) const
{
std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)> ctx(EVP_MD_CTX_new(), &EVP_MD_CTX_free);
if (!ctx)
- return boost::none;
+ return std::nullopt;
if (EVP_DigestInit_ex(ctx.get(), DigestFunc(), nullptr) != 1)
- return boost::none;
+ return std::nullopt;
bool ok = true;
boost::fusion::for_each(std::tie(args...), [&] (const auto& arg) {
ok = ok && update{ctx.get()}(arg);
});
if (!ok)
- return boost::none;
+ return std::nullopt;
std::array<std::uint8_t, DigestSize> digest{{}};
if (EVP_DigestFinal_ex(ctx.get(), digest.data(), nullptr) != 1)
- return boost::none;
+ return std::nullopt;
return epee::to_hex::array(digest);
}
};
@@ -442,7 +441,7 @@ namespace
, username() {
}
- static boost::optional<auth_message> parse(const boost::string_ref request)
+ static std::optional<auth_message> parse(const boost::string_ref request)
{
struct parser
{
@@ -519,7 +518,7 @@ namespace
fields = field_table >> skip_whitespace >> equal_sign >> skip_whitespace;
}
- boost::optional<auth_message> operator()(const boost::string_ref request) const
+ std::optional<auth_message> operator()(const boost::string_ref request) const
{
namespace qi = boost::spirit::qi;
@@ -528,7 +527,7 @@ namespace
if (!qi::parse(current, end, header))
{
- return boost::none;
+ return std::nullopt;
}
auth_message info{};
@@ -539,11 +538,11 @@ namespace
{
if (!qi::parse(current, end, fields, field) || !field(*this, current, end, info))
{
- return boost::none;
+ return std::nullopt;
}
qi::parse(current, end, skip_whitespace);
} while (qi::parse(current, end, qi::char_(comma) >> skip_whitespace));
- return boost::make_optional(current == end, info);
+ return (current == end) ? std::optional(info) : std::optional<auth_message>();
}
private:
@@ -564,13 +563,13 @@ namespace
struct has_valid_response
{
template<typename Digest, typename Result>
- boost::optional<Result> generate_old_response(Digest digest, const Result& key, const Result& auth) const
+ std::optional<Result> generate_old_response(Digest digest, const Result& key, const Result& auth) const
{
return digest(key, u8":", request.nonce, u8":", auth);
}
template<typename Digest, typename Result>
- boost::optional<Result> generate_new_response(Digest digest, const Result& key, const Result& auth) const
+ std::optional<Result> generate_new_response(Digest digest, const Result& key, const Result& auth) const
{
return digest(
key, u8":", request.nonce, u8":", request.nc, u8":", request.cnonce, u8":", request.qop, u8":", auth
@@ -624,13 +623,13 @@ namespace
const bool disable_md5;
};
- boost::optional<std::uint32_t> counter() const
+ std::optional<std::uint32_t> counter() const
{
namespace qi = boost::spirit::qi;
using hex = qi::uint_parser<std::uint32_t, 16>;
std::uint32_t value = 0;
const bool converted = qi::parse(nc.begin(), nc.end(), hex{}, value);
- return boost::make_optional(converted, value);
+ return converted ? std::optional(value) : std::optional<std::uint32_t>();
}
struct server_parameters
@@ -778,7 +777,7 @@ namespace epee
: user(session{std::move(credentials)}), rng(std::move(r)), disable_md5(disable_md5_) {
}
- boost::optional<http_response_info> http_server_auth::do_get_response(const http_request_info& request)
+ std::optional<http_response_info> http_server_auth::do_get_response(const http_request_info& request)
{
assert(user);
using field = std::pair<std::string, std::string>;
@@ -795,7 +794,7 @@ namespace epee
switch (auth_message::verify(request.m_http_method_str, request.m_URI, auth->second, *user, disable_md5))
{
case auth_message::kPass:
- return boost::none;
+ return std::nullopt;
case auth_message::kStale:
is_stale = true;
@@ -832,7 +831,7 @@ namespace epee
return first_auth ? kParseFailure : kBadPassword;
}
- boost::optional<std::pair<std::string, std::string>> http_client_auth::do_get_auth_field(
+ std::optional<std::pair<std::string, std::string>> http_client_auth::do_get_auth_field(
const boost::string_ref method, const boost::string_ref uri)
{
assert(user);
@@ -841,11 +840,11 @@ namespace epee
++(user->counter);
std::string auth = user->server.generator(*user, method, uri);
if (auth.empty())
- return boost::none;
+ return std::nullopt;
return std::make_pair(std::string(client_auth_field), std::move(auth));
}
- return boost::none;
+ return std::nullopt;
}
}
}
### contrib/epee/src/net_utils_base.cpp
@@ -44,11 +44,11 @@ namespace epee { namespace net_utils
bool ipv6_network_address::is_loopback() const { return m_address.is_loopback(); }
bool ipv6_network_address::is_local() const { return m_address.is_link_local(); }
- boost::optional<ipv4_network_address> get_ipv4_mapped_address(const ipv6_network_address& address)
+ std::optional<ipv4_network_address> get_ipv4_mapped_address(const ipv6_network_address& address)
{
const boost::asio::ip::address_v6 ip = address.ip();
if (!ip.is_v4_mapped())
- return boost::none;
+ return std::nullopt;
const boost::asio::ip::address_v4 ipv4 =
boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, ip);
@@ -164,25 +164,25 @@ namespace epee { namespace net_utils
const auto this_id = get_type_id();
if (this_id == ipv4_network_address::get_type_id() && other.get_type_id() == ipv6_network_address::get_type_id())
{
- const boost::optional<ipv4_network_address> mapped =
+ const std::optional<ipv4_network_address> mapped =
get_ipv4_mapped_address(other.as<const ipv6_network_address>());
if (mapped)
return is_same_host(*mapped);
}
else if (this_id == ipv6_network_address::get_type_id() && other.get_type_id() == ipv4_network_address::get_type_id())
{
- const boost::optional<ipv4_network_address> mapped =
+ const std::optional<ipv4_network_address> mapped =
get_ipv4_mapped_address(this->as<const ipv6_network_address>());
if (mapped)
return other.is_same_host(*mapped);
}
return false;
}
- boost::optional<ipv4_network_address> get_ipv4_mapped_address(const network_address& address)
+ std::optional<ipv4_network_address> get_ipv4_mapped_address(const network_address& address)
{
if (address.get_type_id() != ipv6_network_address::get_type_id())
- return boost::none;
+ return std::nullopt;
return get_ipv4_mapped_address(address.as<const ipv6_network_address>());
}
### contrib/epee/src/wipeable_string.cpp
@@ -26,7 +26,6 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <boost/optional/optional.hpp>
#include <limits>
#include <string.h>
#include "memwipe.h"
@@ -200,11 +199,11 @@ void wipeable_string::split(std::vector<wipeable_string> &fields) const
}
}
-boost::optional<epee::wipeable_string> wipeable_string::parse_hexstr() const
+std::optional<epee::wipeable_string> wipeable_string::parse_hexstr() const
{
if (size() % 2 != 0)
- return boost::none;
- boost::optional<epee::wipeable_string> res = epee::wipeable_string("");
+ return std::nullopt;
+ std::optional<epee::wipeable_string> res = epee::wipeable_string("");
const size_t len = size();
const char *d = data();
res->grow(0, len / 2);
@@ -213,11 +212,11 @@ boost::optional<epee::wipeable_string> wipeable_string::parse_hexstr() const
char c = atolower(d[i]);
const char *ptr0 = (const char*)memchr(hex, c, sizeof(hex) - 1);
if (!ptr0)
- return boost::none;
+ return std::nullopt;
c = atolower(d[i+1]);
const char *ptr1 = (const char*)memchr(hex, c, sizeof(hex) - 1);
if (!ptr1)
- return boost::none;
+ return std::nullopt;
res->push_back(((ptr0-hex)<<4) | (ptr1-hex));
}
return res;
### src/common/download.cpp
@@ -188,7 +188,7 @@ namespace tools
epee::net_utils::ssl_support_t ssl = u_c.schema == "https" ? epee::net_utils::ssl_support_t::e_ssl_support_enabled : epee::net_utils::ssl_support_t::e_ssl_support_disabled;
uint16_t port = u_c.port ? u_c.port : ssl == epee::net_utils::ssl_support_t::e_ssl_support_enabled ? 443 : 80;
MDEBUG("Connecting to " << u_c.host << ":" << port);
- client.set_server(u_c.host, std::to_string(port), boost::none, ssl);
+ client.set_server(u_c.host, std::to_string(port), std::nullopt, ssl);
if (!client.connect(std::chrono::seconds(30)))
{
boost::lock_guard<boost::mutex> lock(control->mutex);
### src/common/rpc_client.h
@@ -28,8 +28,6 @@
#pragma once
-#include <boost/optional/optional.hpp>
-
#include "common/http_connection.h"
#include "common/scoped_message_writer.h"
#include "rpc/core_rpc_server_commands_defs.h"
@@ -49,7 +47,7 @@ namespace tools
t_rpc_client(
uint32_t ip
, uint16_t port
- , boost::optional<epee::net_utils::http::login> user
+ , std::optional<epee::net_utils::http::login> user
, epee::net_utils::ssl_options_t ssl_options
)
: m_http_client{}
### src/crypto/crypto.cpp
@@ -35,6 +35,7 @@
#include <cstdlib>
#include <cstring>
#include <random>
+#include <boost/optional.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/shared_ptr.hpp>
### src/daemon/rpc_command_executor.cpp
@@ -161,7 +161,7 @@ t_rpc_command_executor::t_rpc_command_executor(
{
if (is_rpc)
{
- boost::optional<epee::net_utils::http::login> http_login{};
+ std::optional<epee::net_utils::http::login> http_login{};
if (login)
http_login.emplace(login->username, login->password.password());
m_rpc_client = new tools::t_rpc_client(ip, port, std::move(http_login), ssl_options);
### src/device/device.hpp
@@ -29,6 +29,8 @@
#pragma once
+#include <boost/optional.hpp>
+
#include "crypto/crypto.h"
#include "crypto/chacha.h"
#include "ringct/rctTypes.h"
### src/device_trezor/trezor/transport.cpp
@@ -365,7 +365,7 @@ namespace trezor{
MDEBUG("Bridge host: " << m_bridge_host);
}
- m_http_client.set_server(m_bridge_host, boost::none, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ m_http_client.set_server(m_bridge_host, std::nullopt, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
}
std::string BridgeTransport::get_path() const {
@@ -484,7 +484,7 @@ namespace trezor{
throw exc::CommunicationException("Could not read, no response stored");
}
- boost::optional<epee::wipeable_string> bin_data = m_response->parse_hexstr();
+ std::optional<epee::wipeable_string> bin_data = m_response->parse_hexstr();
if (!bin_data || bin_data->size() < PROTO_HEADER_SIZE){
throw exc::CommunicationException("Response is not well hexcoded");
}
### src/net/parse.cpp
@@ -189,7 +189,7 @@ namespace net
if (ipv6)
{
const epee::net_utils::ipv6_network_address address{v6, port};
- const boost::optional<epee::net_utils::ipv4_network_address> mapped =
+ const std::optional<epee::net_utils::ipv4_network_address> mapped =
epee::net_utils::get_ipv4_mapped_address(address);
if (mapped)
return {std::move(*mapped)};
### src/p2p/net_node.inl
@@ -1832,7 +1832,7 @@ namespace nodetool
// Local helper method to get the host string, i.e. the pure IP address without port
const auto get_host_string = [](const epee::net_utils::network_address &address) {
- const boost::optional<epee::net_utils::ipv4_network_address> mapped = epee::net_utils::get_ipv4_mapped_address(address);
+ const std::optional<epee::net_utils::ipv4_network_address> mapped = epee::net_utils::get_ipv4_mapped_address(address);
if (mapped)
return epee::net_utils::ipv4_network_address(mapped->ip(), 0).host_str();
return address.host_str();
### src/rpc/core_rpc_server.cpp
@@ -165,7 +165,7 @@ namespace cryptonote
disable_rpc_ban = rpc_config->disable_rpc_ban;
const std::string data_dir{command_line::get_arg(vm, cryptonote::arg_data_dir)};
- boost::optional<epee::net_utils::http::login> http_login{};
+ std::optional<epee::net_utils::http::login> http_login{};
if (rpc_config->login)
http_login.emplace(std::move(rpc_config->login->username), std::move(rpc_config->login->password).password());
### src/simplewallet/simplewallet.cpp
@@ -4133,7 +4133,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
if (m_restore_multisig_wallet)
{
- const boost::optional<epee::wipeable_string> parsed = m_electrum_seed.parse_hexstr();
+ const std::optional<epee::wipeable_string> parsed = m_electrum_seed.parse_hexstr();
if (!parsed)
{
fail_msg_writer() << tr("Multisig seed failed verification");
@@ -5637,7 +5637,7 @@ bool simple_wallet::set_daemon(const std::vector<std::string>& args)
std::string trusted;
- boost::optional<epee::net_utils::http::login> daemon_login = boost::none;
+ std::optional<epee::net_utils::http::login> daemon_login = std::nullopt;
std::string proxy_address;
bool proxy_explicitly_set = false;
for (size_t i = 1; i < args.size(); ++i)
### src/wallet/api/wallet.cpp
@@ -1073,7 +1073,7 @@ bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transact
if(daemon_username != "")
m_daemon_login.emplace(daemon_username, daemon_password);
else
- m_daemon_login = boost::none;
+ m_daemon_login = std::nullopt;
return doInit(daemon_address, proxy_address, upper_transaction_size_limit, use_ssl);
}
### src/wallet/api/wallet.h
@@ -303,7 +303,7 @@ class WalletImpl : public Wallet
std::atomic<bool> m_rebuildWalletCache;
// cache connection status to avoid unnecessary RPC calls
mutable std::atomic<bool> m_is_connected;
- boost::optional<epee::net_utils::http::login> m_daemon_login{};
+ std::optional<epee::net_utils::http::login> m_daemon_login{};
};
### src/wallet/api/wallet_manager.cpp
@@ -244,7 +244,7 @@ std::string WalletManagerImpl::errorString() const
void WalletManagerImpl::setDaemonAddress(const std::string &address)
{
- m_http_client.set_server(address, boost::none);
+ m_http_client.set_server(address, std::nullopt);
}
bool WalletManagerImpl::connected(uint32_t *version)
### src/wallet/message_transporter.cpp
@@ -96,7 +96,7 @@ void message_transporter::set_options(const std::string &bitmessage_address, con
}
m_bitmessage_login = bitmessage_login;
- m_http_client->set_server(address_parts.host, std::to_string(address_parts.port), boost::none);
+ m_http_client->set_server(address_parts.host, std::to_string(address_parts.port), std::nullopt);
}
bool message_transporter::receive_messages(const std::vector<std::string> &destination_transport_addresses,
### src/wallet/wallet2.cpp
@@ -405,7 +405,7 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
THROW_WALLET_EXCEPTION_IF(!daemon_address.empty() && !daemon_host.empty() && 0 != daemon_port,
tools::error::wallet_internal_error, tools::wallet2::tr("can't specify daemon host or port more than once"));
- boost::optional<epee::net_utils::http::login> login{};
+ std::optional<epee::net_utils::http::login> login{};
if (command_line::has_arg(vm, opts.daemon_login))
{
auto parsed = tools::login::parse(
@@ -489,7 +489,7 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
if (daemon_override)
{
daemon_address = daemon_override->address;
- login = boost::none;
+ login = std::nullopt;
if (!daemon_override->username.empty() || !daemon_override->password.empty())
login.emplace(daemon_override->username, daemon_override->password);
proxy = daemon_override->proxy;
@@ -1448,7 +1448,7 @@ std::unique_ptr<wallet2> wallet2::make_dummy(const boost::program_options::varia
}
//----------------------------------------------------------------------------------------------------
-bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options, const std::string& proxy)
+bool wallet2::set_daemon(std::string daemon_address, std::optional<epee::net_utils::http::login> daemon_login, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options, const std::string& proxy)
{
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
@@ -1505,7 +1505,7 @@ std::string wallet2::get_proxy() const
return m_proxy;
}
//----------------------------------------------------------------------------------------------------
-bool wallet2::init(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, const std::string &proxy_address, uint64_t upper_transaction_weight_limit, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
+bool wallet2::init(std::string daemon_address, std::optional<epee::net_utils::http::login> daemon_login, const std::string &proxy_address, uint64_t upper_transaction_weight_limit, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
{
m_checkpoints.init_default_checkpoints(m_nettype);
m_is_initialized = true;
### src/wallet/wallet2.h
@@ -841,13 +841,13 @@ namespace tools
bool deinit();
bool init(std::string daemon_address,
- boost::optional<epee::net_utils::http::login> daemon_login = boost::none,
+ std::optional<epee::net_utils::http::login> daemon_login = std::nullopt,
const std::string &proxy = "",
uint64_t upper_transaction_weight_limit = 0,
bool trusted_daemon = true,
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect);
bool set_daemon(std::string daemon_address,
- boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true,
+ std::optional<epee::net_utils::http::login> daemon_login = std::nullopt, bool trusted_daemon = true,
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect,
const std::string &proxy = "");
bool set_proxy(const std::string &address);
@@ -1340,7 +1340,7 @@ namespace tools
std::string get_wallet_file() const;
std::string get_keys_file() const;
std::string get_daemon_address() const;
- const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
+ const std::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
std::string get_daemon_proxy() const { return m_proxy; }
uint64_t get_daemon_blockchain_height(std::string& err);
uint64_t get_daemon_blockchain_target_height(std::string& err);
@@ -1721,7 +1721,7 @@ namespace tools
bool spends_one_of_ours(const cryptonote::transaction &tx) const;
cryptonote::account_base m_account;
- boost::optional<epee::net_utils::http::login> m_daemon_login;
+ std::optional<epee::net_utils::http::login> m_daemon_login;
std::string m_daemon_address;
std::string m_proxy;
std::string m_wallet_file;
### src/wallet/wallet_rpc_server.cpp
@@ -350,8 +350,8 @@ namespace tools
m_vm = vm;
- boost::optional<epee::net_utils::http::login> http_login{};
- boost::optional<epee::wipeable_string> generated_password{};
+ std::optional<epee::net_utils::http::login> http_login{};
+ std::optional<epee::wipeable_string> generated_password{};
std::string bind_port = command_line::get_arg(*m_vm, arg_rpc_bind_port);
const bool disable_auth = command_line::get_arg(*m_vm, arg_disable_rpc_login);
m_restricted = command_line::get_arg(*m_vm, arg_restricted);
@@ -5164,7 +5164,7 @@ namespace tools
// apply to the open wallet now; the config also seeds wallets opened/created later
if (m_wallet)
{
- boost::optional<epee::net_utils::http::login> daemon_login{};
+ std::optional<epee::net_utils::http::login> daemon_login{};
if (!req.username.empty() || !req.password.empty())
daemon_login.emplace(req.username, req.password);
### tests/functional_tests/transactions_flow_test.cpp
@@ -159,7 +159,7 @@ bool transactions_flow_test(std::string& working_folder,
epee::net_utils::http::http_simple_client http_client;
COMMAND_RPC_STOP_MINING::request daemon1_req = AUTO_VAL_INIT(daemon1_req);
COMMAND_RPC_STOP_MINING::response daemon1_rsp = AUTO_VAL_INIT(daemon1_rsp);
- bool r = http_client.set_server(daemon_addr_a, boost::none) && net_utils::invoke_http_json("/stop_mine", daemon1_req, daemon1_rsp, http_client, std::chrono::seconds(10));
+ bool r = http_client.set_server(daemon_addr_a, std::nullopt) && net_utils::invoke_http_json("/stop_mine", daemon1_req, daemon1_rsp, http_client, std::chrono::seconds(10));
CHECK_AND_ASSERT_MES(r, false, "failed to stop mining");
COMMAND_RPC_START_MINING::request daemon_req = AUTO_VAL_INIT(daemon_req);
### tests/fuzz/cold-outputs.cpp
@@ -46,7 +46,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
- wallet->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet->set_subaddress_lookahead(1, 1);
wallet->generate("", "", spendkey, true, false);
END_INIT_SIMPLE_FUZZER()
### tests/fuzz/cold-transaction.cpp
@@ -45,7 +45,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
- wallet->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet->set_subaddress_lookahead(1, 1);
wallet->generate("", "", spendkey, true, false);
END_INIT_SIMPLE_FUZZER()
### tests/fuzz/multisig_init.h
@@ -45,7 +45,7 @@ static void multisig_init_make_wallet(tools::wallet2 &wallet, const char *spendk
crypto::secret_key spendkey;
CHECK_AND_ASSERT_THROW_MES(epee::string_tools::hex_to_pod(spendkey_hex, spendkey), "Bad spend key");
- wallet.init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet.init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet.set_subaddress_lookahead(1, 1);
wallet.generate("", "", spendkey, true, false);
}
### tests/fuzz/signature.cpp
@@ -45,7 +45,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
- wallet->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet->set_subaddress_lookahead(1, 1);
wallet->generate("", "", spendkey, true, false);
### tests/fuzz/wallet-cache.cpp
@@ -69,7 +69,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
- wallet->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet->set_subaddress_lookahead(1, 1);
wallet->generate("", "", spendkey, true, false);
### tests/fuzz/wallet-proof-uri.cpp
@@ -323,7 +323,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
{
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(w.second, spendkey);
- w.first->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ w.first->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
w.first->set_subaddress_lookahead(2, 3);
w.first->generate("", "", spendkey, true, false);
}
### tests/fuzz/wallet-scan.cpp
@@ -281,7 +281,7 @@ BEGIN_INIT_SIMPLE_FUZZER()
crypto::secret_key spendkey;
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
- wallet->init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet->init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet->set_subaddress_lookahead(2, 3);
wallet->generate("", "", spendkey, true, false);
### tests/trezor/daemon.cpp
@@ -128,15 +128,15 @@ void mock_daemon::init()
m_rpc_server.nettype(m_network_type);
CHECK_AND_ASSERT_THROW_MES(m_protocol.init(m_vm), "Failed to initialize cryptonote protocol.");
- CHECK_AND_ASSERT_THROW_MES(m_rpc_server.init(m_vm, false, main_rpc_port, false), "Failed to initialize RPC server.");
+ CHECK_AND_ASSERT_THROW_MES(m_rpc_server.init(m_vm, false, main_rpc_port), "Failed to initialize RPC server.");
if (m_start_p2p)
CHECK_AND_ASSERT_THROW_MES(m_server.init(m_vm), "Failed to initialize p2p server.");
if(m_http_client.is_connected())
m_http_client.disconnect();
- CHECK_AND_ASSERT_THROW_MES(m_http_client.set_server(rpc_addr(), boost::none, epee::net_utils::ssl_support_t::e_ssl_support_disabled), "RPC client init fail");
+ CHECK_AND_ASSERT_THROW_MES(m_http_client.set_server(rpc_addr(), std::nullopt, epee::net_utils::ssl_support_t::e_ssl_support_disabled), "RPC client init fail");
}
void mock_daemon::deinit()
### tests/trezor/trezor_tests.cpp
@@ -275,7 +275,7 @@ static void rollback_chain(cryptonote::core * core, const cryptonote::block & he
return;
CHECK_AND_ASSERT_THROW_MES(cur_height > height, "Height differs");
- core->get_blockchain_storage().get_db().pop_block(popped_block, popped_txs);
+ core->get_blockchain_storage().get_db().pop_block(popped_block, &popped_txs);
} while(true);
}
### tests/unit_tests/http.cpp
@@ -2019,7 +2019,7 @@ TEST(HTTP, Client_Drops_Chunked_Trailing_Bytes)
ASSERT_TRUE(client.test(header + "1\r\na\r\n0\r\n\r\n1\r\nx\r\n0\r\n\r\n", std::chrono::milliseconds(1000)));
EXPECT_EQ("a", client.body_seen);
- client.set_server("daemon-b", "18081", boost::none);
+ client.set_server("daemon-b", "18081", std::nullopt);
ASSERT_TRUE(client.test(header + "1\r\nb\r\n0\r\n\r\n", std::chrono::milliseconds(1000)));
EXPECT_EQ("b", client.body_seen);
}
### tests/unit_tests/multisig.cpp
@@ -81,7 +81,7 @@ static void make_wallet(unsigned int idx, tools::wallet2 &wallet)
try
{
- wallet.init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallet.init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallet.set_subaddress_lookahead(1, 1);
wallet.generate("", "", spendkey, true, false);
ASSERT_TRUE(test_addresses[idx].address == wallet.get_account().get_public_address_str(cryptonote::TESTNET));
@@ -523,7 +523,7 @@ TEST(multisig, reload_after_intermediate_exchange)
crypto::secret_key spendkey;
ASSERT_TRUE(epee::string_tools::hex_to_pod(test_addresses[0].spendkey, spendkey));
- wallets[0].init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ wallets[0].init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
wallets[0].set_subaddress_lookahead(1, 1);
wallets[0].generate(wallet_path.string(), password, spendkey, true, false);
for (size_t i = 1; i < wallets.size(); ++i)
@@ -551,7 +551,7 @@ TEST(multisig, reload_after_intermediate_exchange)
wallets[0].deinit();
tools::wallet2 reopened;
- reopened.init("", boost::none, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ reopened.init("", std::nullopt, "", 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
ASSERT_NO_THROW(reopened.load(wallet_path.string(), password));
EXPECT_TRUE(reopened.get_multisig_status().multisig_is_active);
EXPECT_FALSE(reopened.get_multisig_status().is_ready);
### tests/unit_tests/node_server.cpp
@@ -422,7 +422,7 @@ TEST(node_server, ipv4_mapped_ipv6_address)
const epee::net_utils::network_address mapped{
epee::net_utils::ipv6_network_address{boost::asio::ip::address_v6{bytes}, 18080}
};
- const boost::optional<epee::net_utils::ipv4_network_address> ipv4 = epee::net_utils::get_ipv4_mapped_address(mapped);
+ const std::optional<epee::net_utils::ipv4_network_address> ipv4 = epee::net_utils::get_ipv4_mapped_address(mapped);
ASSERT_TRUE(bool(ipv4));
EXPECT_EQ("45.155.69.10", ipv4->host_str());
EXPECT_EQ(18080, ipv4->port());
### tests/unit_tests/wipeable_string.cpp
@@ -27,7 +27,6 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <boost/optional/optional.hpp>
#include <string.h>
#include "gtest/gtest.h"
@@ -188,24 +187,24 @@ TEST(wipeable_string, split)
TEST(wipeable_string, parse_hexstr)
{
- boost::optional<epee::wipeable_string> s;
+ std::optional<epee::wipeable_string> s;
- ASSERT_TRUE(boost::none == epee::wipeable_string("x").parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("x0000000000000000").parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("0000000000000000x").parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("0").parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("000").parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("\0\0", 2).parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("0\0", 2).parse_hexstr());
- ASSERT_TRUE(boost::none == epee::wipeable_string("\0" "0", 2).parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("x").parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("x0000000000000000").parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("0000000000000000x").parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("0").parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("000").parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("\0\0", 2).parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("0\0", 2).parse_hexstr());
+ ASSERT_TRUE(std::nullopt == epee::wipeable_string("\0" "0", 2).parse_hexstr());
- ASSERT_TRUE((s = epee::wipeable_string("").parse_hexstr()) != boost::none);
+ ASSERT_TRUE((s = epee::wipeable_string("").parse_hexstr()) != std::nullopt);
ASSERT_TRUE(*s == "");
- ASSERT_TRUE((s = epee::wipeable_string("00").parse_hexstr()) != boost::none);
+ ASSERT_TRUE((s = epee::wipeable_string("00").parse_hexstr()) != std::nullopt);
ASSERT_TRUE(*s == epee::wipeable_string("", 1));
- ASSERT_TRUE((s = epee::wipeable_string("41").parse_hexstr()) != boost::none);
+ ASSERT_TRUE((s = epee::wipeable_string("41").parse_hexstr()) != std::nullopt);
ASSERT_TRUE(*s == epee::wipeable_string("A"));
- ASSERT_TRUE((s = epee::wipeable_string("414243").parse_hexstr()) != boost::none);
+ ASSERT_TRUE((s = epee::wipeable_string("414243").parse_hexstr()) != std::nullopt);
ASSERT_TRUE(*s == epee::wipeable_string("ABC"));
}
Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.