mirror of
https://github.com/wownero/lwsf-wow.git
synced 2026-10-17 07:21:28 +02:00
Closer to cpp14 compliance for monero_c release branch
This commit is contained in:
+19
-19
@@ -243,7 +243,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
|
||||
if constexpr (!std::is_const<T>())
|
||||
{
|
||||
self.timestamp = std::nullopt;
|
||||
self.timestamp = boost::none;
|
||||
if (timestamp)
|
||||
self.timestamp = time_point{time_point::duration{boost::numeric_cast<time_point::rep>(*timestamp)}};
|
||||
}
|
||||
@@ -320,7 +320,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
default:
|
||||
throw std::runtime_error{"Unexpected ringct mask type"};
|
||||
case rpc::ringct::format::none:
|
||||
out.rct_mask = std::nullopt;
|
||||
out.rct_mask = boost::none;
|
||||
break;
|
||||
case rpc::ringct::format::encrypted:
|
||||
case rpc::ringct::format::recompute:
|
||||
@@ -356,7 +356,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
}
|
||||
}
|
||||
|
||||
crypto::secret_key get_spend_secret(const account& self, const std::optional<rpc::address_meta>& index)
|
||||
crypto::secret_key get_spend_secret(const account& self, const boost::optional<rpc::address_meta>& index)
|
||||
{
|
||||
if (!index || index->is_default())
|
||||
return self.spend.sec;
|
||||
@@ -378,7 +378,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
return self.subaccounts[sub.maj_i].last < sub.min_i; // last is inclusive
|
||||
}
|
||||
|
||||
std::optional<std::vector<rpc::address_meta>> update_tx(const account& self, transaction& out, const rpc::transaction& source)
|
||||
boost::optional<std::vector<rpc::address_meta>> update_tx(const account& self, transaction& out, const rpc::transaction& source)
|
||||
{
|
||||
/* Let `receives` re-populate in `merge_output`. This works because the
|
||||
server supplies all info - there is no local info to keep. */
|
||||
@@ -390,7 +390,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
if (source.timestamp)
|
||||
out.timestamp = std::chrono::system_clock::from_time_t(*source.timestamp);
|
||||
else
|
||||
out.timestamp = std::nullopt;
|
||||
out.timestamp = boost::none;
|
||||
out.fee = std::uint64_t(source.fee.value_or(rpc::uint64_string(0)));
|
||||
out.height = source.height;
|
||||
out.unlock_time = source.unlock_time;
|
||||
@@ -423,7 +423,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
}
|
||||
|
||||
if (!std::uint64_t(source.total_received) && !total_spent)
|
||||
return std::nullopt; // used as decoy
|
||||
return boost::none; // used as decoy
|
||||
|
||||
if (out.fee <= total_spent)
|
||||
total_spent -= out.fee;
|
||||
@@ -516,7 +516,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
|
||||
if (!rescanning)
|
||||
{
|
||||
iter->second->height = std::nullopt;
|
||||
iter->second->height = boost::none;
|
||||
iter->second->failed = false;
|
||||
}
|
||||
}
|
||||
@@ -1266,13 +1266,13 @@ namespace lwsf { namespace internal { namespace backend
|
||||
this->import_error = {};
|
||||
else
|
||||
this->import_error = value.error();
|
||||
return value
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
boost::unique_lock<boost::mutex> lock{sync};
|
||||
|
||||
if (primary.restore_height <= height)
|
||||
return update_import(import_response{});
|
||||
return update_import(rpc::import_response{});
|
||||
if (import_error && import_error == error::import_pending)
|
||||
return import_error;
|
||||
|
||||
@@ -1289,14 +1289,14 @@ namespace lwsf { namespace internal { namespace backend
|
||||
rpc::login login{primary.address, primary.view.sec};
|
||||
|
||||
lock.unlock();
|
||||
const auto import = rpc::invoke<rpc::import_response>(client, login);
|
||||
auto import = rpc::invoke<rpc::import_response>(client, login);
|
||||
lock.lock();
|
||||
|
||||
if (!import)
|
||||
return update_import(import.error());
|
||||
|
||||
if (import->request_fulfilled)
|
||||
return update_import(std::move(*import));
|
||||
return update_import(std::move(import));
|
||||
|
||||
const unsigned total =
|
||||
unsigned(bool(import->import_fee)) + bool(import->payment_address);
|
||||
@@ -1304,22 +1304,22 @@ namespace lwsf { namespace internal { namespace backend
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return update_import(error::import_pending);
|
||||
return update_import({error::import_pending});
|
||||
case 1:
|
||||
if (import->import_fee.value_or(rpc::uint64_string(0)) == rpc::uint64_string(0))
|
||||
return update_import(error::import_pending);
|
||||
return update_import(error::import_invalid);
|
||||
return update_import({error::import_pending});
|
||||
return update_import({error::import_invalid});
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
cryptonote::address_parse_info info{};
|
||||
if (!cryptonote::get_account_address_from_str(info, convert_net_type(primary.type), *import->payment_address))
|
||||
return update_import(error::import_invalid);
|
||||
return update_import({error::import_invalid});
|
||||
if (info.has_payment_id && import->payment_id)
|
||||
return update_import(error::import_invalid);
|
||||
return update_import({error::import_invalid});
|
||||
if (import->payment_id && (import->payment_id->empty() || (import->payment_id->size() != sizeof(crypto::hash8) && import->payment_id->size() != sizeof(crypto::hash))))
|
||||
return update_import(error::import_invalid);
|
||||
return update_import({error::import_invalid});
|
||||
|
||||
#ifdef LWSF_MASTER_ENABLE
|
||||
std::string payment_id;
|
||||
@@ -1342,7 +1342,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
else
|
||||
primary.addressbook[i] = address_book_entry{std::move(*import->payment_address), std::move(payment_id), std::move(description)};
|
||||
#endif
|
||||
return update_import(std::move(*import));
|
||||
return update_import(std::move(import));
|
||||
}
|
||||
|
||||
expect<std::vector<rpc::random_outputs>> wallet::get_decoys(const rpc::get_random_outs_request& req)
|
||||
|
||||
+4
-4
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
@@ -37,7 +38,6 @@
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
@@ -130,7 +130,7 @@ namespace lwsf { namespace internal { namespace backend
|
||||
std::uint64_t amount;
|
||||
rpc::address_meta recipient;
|
||||
std::uint16_t index;
|
||||
std::optional<rct::key> rct_mask;
|
||||
boost::optional<rct::key> rct_mask;
|
||||
crypto::public_key tx_pub;
|
||||
|
||||
transfer_in() noexcept
|
||||
@@ -178,8 +178,8 @@ namespace lwsf { namespace internal { namespace backend
|
||||
boost::container::flat_map<crypto::public_key, transfer_in, memory> receives; //!< Key is output pub
|
||||
std::vector<transfer_out> transfers;
|
||||
std::string description;
|
||||
std::optional<std::chrono::system_clock::time_point> timestamp; //!< guaranteed to be unix epoch in C++20
|
||||
std::optional<std::uint64_t> height;
|
||||
boost::optional<std::chrono::system_clock::time_point> timestamp; //!< guaranteed to be unix epoch in C++20
|
||||
boost::optional<std::uint64_t> height;
|
||||
std::uint64_t amount;
|
||||
std::uint64_t fee;
|
||||
std::uint64_t unlock_time;
|
||||
|
||||
+2
-2
@@ -184,8 +184,8 @@ namespace lwsf { namespace internal { namespace rpc
|
||||
{
|
||||
using min_spent = wire::min_element_sizeof<crypto::key_image>;
|
||||
|
||||
std::optional<std::string> timestamp;
|
||||
std::optional<epee::byte_slice> payment_id;
|
||||
boost::optional<std::string> timestamp;
|
||||
boost::optional<epee::byte_slice> payment_id;
|
||||
wire::object(source,
|
||||
WIRE_FIELD_ARRAY(spent_outputs, min_spent),
|
||||
wire::optional_field("payment_id", std::ref(payment_id)),
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
#include <ctime>
|
||||
#include <optional>
|
||||
#include <system_error>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
@@ -120,7 +120,7 @@ namespace lwsf { namespace internal { namespace rpc
|
||||
login_response() = delete;
|
||||
static constexpr const char* endpoint() noexcept { return "/login"; }
|
||||
|
||||
std::optional<std::uint64_t> start_height;
|
||||
boost::optional<std::uint64_t> start_height;
|
||||
};
|
||||
void read_bytes(wire::json_reader&, login_response&);
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace lwsf { namespace internal { namespace rpc
|
||||
struct transaction_spend
|
||||
{
|
||||
uint64_string amount;
|
||||
std::optional<address_meta> sender;
|
||||
boost::optional<address_meta> sender;
|
||||
std::uint16_t out_index;
|
||||
crypto::key_image key_image;
|
||||
crypto::public_key tx_pub_key;
|
||||
@@ -190,11 +190,11 @@ namespace lwsf { namespace internal { namespace rpc
|
||||
{
|
||||
std::vector<transaction_spend> spent_outputs;
|
||||
std::variant<empty, crypto::hash8, crypto::hash> payment_id;
|
||||
std::optional<std::time_t> timestamp;
|
||||
std::optional<uint64_string> fee;
|
||||
boost::optional<std::time_t> timestamp;
|
||||
boost::optional<uint64_string> fee;
|
||||
uint64_string total_received;
|
||||
std::uint64_t unlock_time;
|
||||
std::optional<std::uint64_t> height;
|
||||
boost::optional<std::uint64_t> height;
|
||||
crypto::hash hash;
|
||||
bool coinbase;
|
||||
bool mempool;
|
||||
@@ -380,11 +380,13 @@ namespace lwsf { namespace internal { namespace rpc
|
||||
struct import_response
|
||||
{
|
||||
import_response() = delete;
|
||||
import_response(import_response&&) = default;
|
||||
import_response(const import_response&) = delete;
|
||||
static constexpr const char* endpoint() noexcept { return "/import_wallet_request"; }
|
||||
|
||||
std::optional<std::string> payment_address;
|
||||
std::optional<epee::byte_slice> payment_id;
|
||||
std::optional<uint64_string> import_fee;
|
||||
boost::optional<std::string> payment_address;
|
||||
boost::optional<epee::byte_slice> payment_id;
|
||||
boost::optional<uint64_string> import_fee;
|
||||
std::string status;
|
||||
bool new_request;
|
||||
bool request_fulfilled;
|
||||
|
||||
+1
-1
@@ -1921,6 +1921,6 @@ namespace lwsf { namespace internal
|
||||
payment_address = import->payment_address.value_or({});
|
||||
status = std::move(import->status);
|
||||
}
|
||||
#endif LWSF_MASTER_ENABLE
|
||||
#endif // LWSF_MASTER_ENABLE
|
||||
|
||||
}} // lwsf // internal
|
||||
|
||||
+3
-3
@@ -270,7 +270,7 @@ namespace internal
|
||||
* @brief watchOnly - checks if wallet is watch only
|
||||
* @return - true if watch only
|
||||
*/
|
||||
virtual bool watchOnly() const override { /* TODO */ return false; }
|
||||
virtual bool watchOnly() const override { return false; }
|
||||
|
||||
/**
|
||||
* @brief isDeterministic - checks if wallet keys are deterministic
|
||||
@@ -428,7 +428,7 @@ namespace internal
|
||||
* @return new info string if more rounds required or exception if no more rounds (i.e. no rounds to boost)
|
||||
*/
|
||||
virtual std::string getMultisigKeyExchangeBooster(const std::vector<std::string> &info, const uint32_t threshold, const uint32_t num_signers) override { /* TODO */ return {}; }
|
||||
#endif
|
||||
#endif // LWSF_MASTER_ENABLE
|
||||
|
||||
/**
|
||||
* @brief exportMultisigImages - exports transfers' key images
|
||||
@@ -737,7 +737,7 @@ namespace internal
|
||||
|
||||
//! Initiates a light wallet import wallet request
|
||||
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override;
|
||||
#endif LWSF_MASTER_ENABLE
|
||||
#endif // LWSF_MASTER_ENABLE
|
||||
|
||||
//! locks/unlocks the keys file; returns true on success
|
||||
virtual bool lockKeysFile() override { return false; }
|
||||
|
||||
@@ -291,6 +291,7 @@ namespace lwsf
|
||||
bool queryWalletDevice(Monero::Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds) const override
|
||||
{
|
||||
//! \TODO Complete
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user