aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/CMakeLists.txt1
-rw-r--r--src/wallet/node_rpc_proxy.cpp96
-rw-r--r--src/wallet/node_rpc_proxy.h28
-rw-r--r--src/wallet/wallet2.cpp148
-rw-r--r--src/wallet/wallet2.h41
-rw-r--r--src/wallet/wallet_args.cpp4
-rw-r--r--src/wallet/wallet_args.h1
-rw-r--r--src/wallet/wallet_errors.h9
-rw-r--r--src/wallet/wallet_rpc_helpers.h95
-rw-r--r--src/wallet/wallet_rpc_payments.cpp212
-rw-r--r--src/wallet/wallet_rpc_server.cpp14
11 files changed, 24 insertions, 625 deletions
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index e72f3eb20..48c7f1c5b 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -37,7 +37,6 @@ set(wallet_sources
node_rpc_proxy.cpp
message_store.cpp
message_transporter.cpp
- wallet_rpc_payments.cpp
)
monero_find_all_headers(wallet_private_headers "${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp
index 62a525a4b..dd0f6eb0c 100644
--- a/src/wallet/node_rpc_proxy.cpp
+++ b/src/wallet/node_rpc_proxy.cpp
@@ -28,8 +28,6 @@
#include "node_rpc_proxy.h"
#include "rpc/core_rpc_server_commands_defs.h"
-#include "rpc/rpc_payment_signature.h"
-#include "rpc/rpc_payment_costs.h"
#include "storages/http_abstract_invoke.h"
#include <boost/thread.hpp>
@@ -37,7 +35,6 @@
#define RETURN_ON_RPC_RESPONSE_ERROR(r, error, res, method) \
do { \
CHECK_AND_ASSERT_MES(error.code == 0, error.message, error.message); \
- handle_payment_changes(res, std::integral_constant<bool, HasCredits<decltype(res)>::Has>()); \
CHECK_AND_ASSERT_MES(r, std::string("Failed to connect to daemon"), "Failed to connect to daemon"); \
/* empty string -> not connection */ \
CHECK_AND_ASSERT_MES(!res.status.empty(), res.status, "No connection to daemon"); \
@@ -53,9 +50,8 @@ namespace tools
static const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
-NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::abstract_http_client &http_client, rpc_payment_state_t &rpc_payment_state, boost::recursive_mutex &mutex)
+NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::abstract_http_client &http_client, boost::recursive_mutex &mutex)
: m_http_client(http_client)
- , m_rpc_payment_state(rpc_payment_state)
, m_daemon_rpc_mutex(mutex)
, m_offline(false)
{
@@ -77,16 +73,8 @@ void NodeRPCProxy::invalidate()
m_block_weight_limit = 0;
m_adjusted_time = 0;
m_get_info_time = 0;
- m_rpc_payment_info_time = 0;
- m_rpc_payment_seed_height = 0;
- m_rpc_payment_seed_hash = crypto::null_hash;
- m_rpc_payment_next_seed_hash = crypto::null_hash;
m_height_time = 0;
m_target_height_time = 0;
- m_rpc_payment_diff = 0;
- m_rpc_payment_credits_per_hash_found = 0;
- m_rpc_payment_height = 0;
- m_rpc_payment_cookie = 0;
m_daemon_hard_forks.clear();
}
@@ -147,11 +135,8 @@ boost::optional<std::string> NodeRPCProxy::get_info()
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_info", req_t, resp_t, m_http_client, rpc_timeout);
RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "get_info");
- check_rpc_cost(m_rpc_payment_state, "get_info", resp_t.credits, pre_call_credits, COST_PER_GET_INFO);
}
m_height = resp_t.height;
@@ -227,11 +212,8 @@ boost::optional<std::string> NodeRPCProxy::get_earliest_height(uint8_t version,
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "hard_fork_info", req_t, resp_t, m_http_client, rpc_timeout);
RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "hard_fork_info");
- check_rpc_cost(m_rpc_payment_state, "hard_fork_info", resp_t.credits, pre_call_credits, COST_PER_HARD_FORK_INFO);
}
m_earliest_height[version] = resp_t.earliest_height;
@@ -259,11 +241,8 @@ boost::optional<std::string> NodeRPCProxy::get_dynamic_base_fee_estimate_2021_sc
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_fee_estimate", req_t, resp_t, m_http_client, rpc_timeout);
RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "get_fee_estimate");
- check_rpc_cost(m_rpc_payment_state, "get_fee_estimate", resp_t.credits, pre_call_credits, COST_PER_FEE_ESTIMATE);
}
m_dynamic_base_fee_estimate = resp_t.fee;
@@ -305,11 +284,8 @@ boost::optional<std::string> NodeRPCProxy::get_fee_quantization_mask(uint64_t &f
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_fee_estimate", req_t, resp_t, m_http_client, rpc_timeout);
RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "get_fee_estimate");
- check_rpc_cost(m_rpc_payment_state, "get_fee_estimate", resp_t.credits, pre_call_credits, COST_PER_FEE_ESTIMATE);
}
m_dynamic_base_fee_estimate = resp_t.fee;
@@ -326,72 +302,6 @@ boost::optional<std::string> NodeRPCProxy::get_fee_quantization_mask(uint64_t &f
return boost::optional<std::string>();
}
-boost::optional<std::string> NodeRPCProxy::get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie)
-{
- const time_t now = time(NULL);
- if (m_rpc_payment_state.stale || now >= m_rpc_payment_info_time + 5*60 || (mining && now >= m_rpc_payment_info_time + 10)) // re-cache every 10 seconds if mining, 5 minutes otherwise
- {
- cryptonote::COMMAND_RPC_ACCESS_INFO::request req_t = AUTO_VAL_INIT(req_t);
- cryptonote::COMMAND_RPC_ACCESS_INFO::response resp_t = AUTO_VAL_INIT(resp_t);
-
- {
- const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
- bool r = net_utils::invoke_http_json_rpc("/json_rpc", "rpc_access_info", req_t, resp_t, m_http_client, rpc_timeout);
- RETURN_ON_RPC_RESPONSE_ERROR(r, epee::json_rpc::error{}, resp_t, "rpc_access_info");
- m_rpc_payment_state.stale = false;
- }
-
- m_rpc_payment_diff = resp_t.diff;
- m_rpc_payment_credits_per_hash_found = resp_t.credits_per_hash_found;
- m_rpc_payment_height = resp_t.height;
- m_rpc_payment_seed_height = resp_t.seed_height;
- m_rpc_payment_cookie = resp_t.cookie;
-
- if (m_rpc_payment_diff == 0)
- {
- // If no payment required daemon doesn't give us back a hashing blob
- m_rpc_payment_blob.clear();
- }
- else if (!epee::string_tools::parse_hexstr_to_binbuff(resp_t.hashing_blob, m_rpc_payment_blob) || m_rpc_payment_blob.size() < 43)
- {
- MERROR("Invalid hashing blob: " << resp_t.hashing_blob);
- return std::string("Invalid hashing blob");
- }
- if (resp_t.seed_hash.empty())
- {
- m_rpc_payment_seed_hash = crypto::null_hash;
- }
- else if (!epee::string_tools::hex_to_pod(resp_t.seed_hash, m_rpc_payment_seed_hash))
- {
- MERROR("Invalid seed_hash: " << resp_t.seed_hash);
- return std::string("Invalid seed hash");
- }
- if (resp_t.next_seed_hash.empty())
- {
- m_rpc_payment_next_seed_hash = crypto::null_hash;
- }
- else if (!epee::string_tools::hex_to_pod(resp_t.next_seed_hash, m_rpc_payment_next_seed_hash))
- {
- MERROR("Invalid next_seed_hash: " << resp_t.next_seed_hash);
- return std::string("Invalid next seed hash");
- }
- m_rpc_payment_info_time = now;
- }
-
- payment_required = m_rpc_payment_diff > 0;
- credits = m_rpc_payment_state.credits;
- diff = m_rpc_payment_diff;
- credits_per_hash_found = m_rpc_payment_credits_per_hash_found;
- blob = m_rpc_payment_blob;
- height = m_rpc_payment_height;
- seed_height = m_rpc_payment_seed_height;
- seed_hash = m_rpc_payment_seed_hash;
- next_seed_hash = m_rpc_payment_next_seed_hash;
- cookie = m_rpc_payment_cookie;
- return boost::none;
-}
-
boost::optional<std::string> NodeRPCProxy::get_transactions(const std::vector<crypto::hash> &txids, const std::function<void(const cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request&, const cryptonote::COMMAND_RPC_GET_TRANSACTIONS::response&, bool)> &f)
{
const size_t SLICE_SIZE = 100; // RESTRICTED_TRANSACTIONS_COUNT as defined in rpc/core_rpc_server.cpp
@@ -410,11 +320,7 @@ boost::optional<std::string> NodeRPCProxy::get_transactions(const std::vector<cr
bool r = false;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = cryptonote::make_rpc_payment_signature(m_client_id_secret_key);
r = net_utils::invoke_http_json("/gettransactions", req_t, resp_t, m_http_client, rpc_timeout);
- if (r && resp_t.status == CORE_RPC_STATUS_OK)
- check_rpc_cost(m_rpc_payment_state, "/gettransactions", resp_t.credits, pre_call_credits, resp_t.txs.size() * COST_PER_TX);
}
f(req_t, resp_t, r);
diff --git a/src/wallet/node_rpc_proxy.h b/src/wallet/node_rpc_proxy.h
index eb947d2b2..3ec96baaa 100644
--- a/src/wallet/node_rpc_proxy.h
+++ b/src/wallet/node_rpc_proxy.h
@@ -34,7 +34,6 @@
#include "include_base_utils.h"
#include "net/abstract_http_client.h"
#include "rpc/core_rpc_server_commands_defs.h"
-#include "wallet_rpc_helpers.h"
namespace tools
{
@@ -42,9 +41,8 @@ namespace tools
class NodeRPCProxy
{
public:
- NodeRPCProxy(epee::net_utils::http::abstract_http_client &http_client, rpc_payment_state_t &rpc_payment_state, boost::recursive_mutex &mutex);
+ NodeRPCProxy(epee::net_utils::http::abstract_http_client &http_client, boost::recursive_mutex &mutex);
- void set_client_secret_key(const crypto::secret_key &skey) { m_client_id_secret_key = skey; }
void invalidate();
void set_offline(bool offline) { m_offline = offline; }
@@ -58,28 +56,13 @@ public:
boost::optional<std::string> get_dynamic_base_fee_estimate(uint64_t grace_blocks, uint64_t &fee);
boost::optional<std::string> get_dynamic_base_fee_estimate_2021_scaling(uint64_t grace_blocks, std::vector<uint64_t> &fees);
boost::optional<std::string> get_fee_quantization_mask(uint64_t &fee_quantization_mask);
- boost::optional<std::string> get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie);
boost::optional<std::string> get_transactions(const std::vector<crypto::hash> &txids, const std::function<void(const cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request&, const cryptonote::COMMAND_RPC_GET_TRANSACTIONS::response&, bool)> &f);
private:
- template<typename T> void handle_payment_changes(const T &res, std::true_type) {
- if (res.status == CORE_RPC_STATUS_OK || res.status == CORE_RPC_STATUS_PAYMENT_REQUIRED)
- m_rpc_payment_state.credits = res.credits;
- if (res.top_hash != m_rpc_payment_state.top_hash)
- {
- m_rpc_payment_state.top_hash = res.top_hash;
- m_rpc_payment_state.stale = true;
- }
- }
- template<typename T> void handle_payment_changes(const T &res, std::false_type) {}
-
-private:
boost::optional<std::string> get_info();
epee::net_utils::http::abstract_http_client &m_http_client;
- rpc_payment_state_t &m_rpc_payment_state;
boost::recursive_mutex &m_daemon_rpc_mutex;
- crypto::secret_key m_client_id_secret_key;
bool m_offline;
uint64_t m_height;
@@ -94,15 +77,6 @@ private:
uint64_t m_target_height;
uint64_t m_block_weight_limit;
time_t m_get_info_time;
- time_t m_rpc_payment_info_time;
- uint64_t m_rpc_payment_diff;
- uint64_t m_rpc_payment_credits_per_hash_found;
- cryptonote::blobdata m_rpc_payment_blob;
- uint64_t m_rpc_payment_height;
- uint64_t m_rpc_payment_seed_height;
- crypto::hash m_rpc_payment_seed_hash;
- crypto::hash m_rpc_payment_next_seed_hash;
- uint32_t m_rpc_payment_cookie;
time_t m_height_time;
time_t m_target_height_time;
std::vector<std::pair<uint8_t, uint64_t>> m_daemon_hard_forks;
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index a8c1ffd38..41dbf70e8 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -51,15 +51,12 @@ using namespace epee;
#include "cryptonote_config.h"
#include "hardforks/hardforks.h"
#include "cryptonote_core/tx_sanity_check.h"
-#include "wallet_rpc_helpers.h"
#include "wallet2.h"
#include "wallet_args.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "net/parse.h"
#include "rpc/core_rpc_server_commands_defs.h"
#include "rpc/core_rpc_server_error_codes.h"
-#include "rpc/rpc_payment_signature.h"
-#include "rpc/rpc_payment_costs.h"
#include "misc_language.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "multisig/multisig.h"
@@ -1191,15 +1188,13 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std
m_show_wallet_name_when_locked(false),
m_inactivity_lock_timeout(DEFAULT_INACTIVITY_LOCK_TIMEOUT),
m_setup_background_mining(BackgroundMiningMaybe),
- m_persistent_rpc_client_id(false),
- m_auto_mine_for_rpc_payment_threshold(-1.0f),
m_is_initialized(false),
m_kdf_rounds(kdf_rounds),
is_old_file_format(false),
m_watch_only(false),
m_multisig(false),
m_multisig_threshold(0),
- m_node_rpc_proxy(*m_http_client, m_rpc_payment_state, m_daemon_rpc_mutex),
+ m_node_rpc_proxy(*m_http_client, m_daemon_rpc_mutex),
m_account_public_address{crypto::null_pkey, crypto::null_pkey},
m_subaddress_lookahead_major(SUBADDRESS_LOOKAHEAD_MAJOR),
m_subaddress_lookahead_minor(SUBADDRESS_LOOKAHEAD_MINOR),
@@ -1223,13 +1218,11 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std
m_rpc_version(0),
m_export_format(ExportFormat::Binary),
m_load_deprecated_formats(false),
- m_credits_target(0),
m_enable_multisig(false),
m_pool_info_query_time(0),
m_has_ever_refreshed_from_node(false),
m_allow_mismatched_daemon_version(false)
{
- set_rpc_client_secret_key(rct::rct2sk(rct::skGen()));
}
wallet2::~wallet2()
@@ -1343,11 +1336,6 @@ bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_u
m_trusted_daemon = trusted_daemon;
if (changed)
{
- if (!m_persistent_rpc_client_id) {
- set_rpc_client_secret_key(rct::rct2sk(rct::skGen()));
- }
- m_rpc_payment_state.expected_spent = 0;
- m_rpc_payment_state.discrepancy = 0;
m_rpc_version = 0;
m_node_rpc_proxy.invalidate();
m_pool_info_query_time = 0;
@@ -1647,7 +1635,6 @@ void wallet2::scan_tx(const std::vector<crypto::hash> &txids)
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to get transaction from daemon");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != req.txs_hashes.size(), error::wallet_internal_error, "Failed to get transaction from daemon");
@@ -2760,15 +2747,11 @@ void wallet2::pull_blocks(bool first, bool try_incremental, uint64_t start_heigh
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = net_utils::invoke_http_bin("/getblocks.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "getblocks.bin", error::get_blocks_error, get_rpc_status(res.status));
THROW_WALLET_EXCEPTION_IF(res.blocks.size() != res.output_indices.size(), error::wallet_internal_error,
"mismatched blocks (" + boost::lexical_cast<std::string>(res.blocks.size()) + ") and output_indices (" +
boost::lexical_cast<std::string>(res.output_indices.size()) + ") sizes from daemon");
- uint64_t pool_info_cost = res.added_pool_txs.size() * COST_PER_TX + (res.remaining_added_pool_txids.size() + res.removed_pool_txids.size()) * COST_PER_POOL_HASH;
- check_rpc_cost("/getblocks.bin", res.credits, pre_call_credits, 1 + res.blocks.size() * COST_PER_BLOCK + pool_info_cost);
}
blocks_start_height = res.start_height;
@@ -2809,11 +2792,8 @@ void wallet2::pull_hashes(uint64_t start_height, uint64_t &blocks_start_height,
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- req.client = get_client_signature();
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
bool r = net_utils::invoke_http_bin("/gethashes.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "gethashes.bin", error::get_hashes_error, get_rpc_status(res.status));
- check_rpc_cost("/gethashes.bin", res.credits, pre_call_credits, 1 + res.m_block_ids.size() * COST_PER_BLOCK_HASH);
}
blocks_start_height = res.start_height;
@@ -3313,12 +3293,8 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction,
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = net_utils::invoke_http_bin("/getblocks.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "getblocks.bin", error::get_blocks_error, get_rpc_status(res.status));
- uint64_t pool_info_cost = res.added_pool_txs.size() * COST_PER_TX + (res.remaining_added_pool_txids.size() + res.removed_pool_txids.size()) * COST_PER_POOL_HASH;
- check_rpc_cost("/getblocks.bin", res.credits, pre_call_credits, pool_info_cost);
}
m_pool_info_query_time = res.daemon_time;
@@ -3354,11 +3330,8 @@ void wallet2::update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote:
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/get_transaction_pool_hashes.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "get_transaction_pool_hashes.bin", error::get_tx_pool_error);
- check_rpc_cost("/get_transaction_pool_hashes.bin", res.credits, pre_call_credits, 1 + res.tx_hashes.size() * COST_PER_POOL_HASH);
}
MTRACE("update_pool_state_by_pool_query got pool");
@@ -3818,9 +3791,8 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo
THROW_WALLET_EXCEPTION_IF(!waiter.wait(), error::wallet_internal_error, "Exception in thread pool");
throw;
}
- catch (const error::payment_required&)
+ catch (const error::deprecated_rpc_access&)
{
- // no point in trying again, it'd just eat up credits
THROW_WALLET_EXCEPTION_IF(!waiter.wait(), error::wallet_internal_error, "Exception in thread pool");
throw;
}
@@ -3905,11 +3877,8 @@ bool wallet2::get_rct_distribution(uint64_t &start_height, std::vector<uint64_t>
try
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = net_utils::invoke_http_bin("/get_output_distribution.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/get_output_distribution.bin");
- check_rpc_cost("/get_output_distribution.bin", res.credits, pre_call_credits, COST_PER_OUTPUT_DISTRIBUTION_0);
}
catch(...)
{
@@ -4288,13 +4257,16 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
json.AddMember("original_view_secret_key", value, json.GetAllocator());
}
- value2.SetInt(m_persistent_rpc_client_id ? 1 : 0);
+ // This value is serialized for compatibility with wallets which support the pay-to-use RPC system
+ value2.SetInt(0);
json.AddMember("persistent_rpc_client_id", value2, json.GetAllocator());
- value2.SetFloat(m_auto_mine_for_rpc_payment_threshold);
+ // This value is serialized for compatibility with wallets which support the pay-to-use RPC system
+ value2.SetFloat(0.0f);
json.AddMember("auto_mine_for_rpc_payment", value2, json.GetAllocator());
- value2.SetUint64(m_credits_target);
+ // This value is serialized for compatibility with wallets which support the pay-to-use RPC system
+ value2.SetUint64(0);
json.AddMember("credits_target", value2, json.GetAllocator());
value2.SetInt(m_enable_multisig ? 1 : 0);
@@ -4445,9 +4417,6 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st
m_device_derivation_path = "";
m_key_device_type = hw::device::device_type::SOFTWARE;
encrypted_secret_keys = false;
- m_persistent_rpc_client_id = false;
- m_auto_mine_for_rpc_payment_threshold = -1.0f;
- m_credits_target = 0;
m_enable_multisig = false;
m_allow_mismatched_daemon_version = false;
}
@@ -4675,13 +4644,6 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st
m_original_keys_available = false;
}
- GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, persistent_rpc_client_id, int, Int, false, false);
- m_persistent_rpc_client_id = field_persistent_rpc_client_id;
- // save as float, load as double, because it can happen you can't load back as float...
- GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, auto_mine_for_rpc_payment, float, Double, false, FLT_MAX);
- m_auto_mine_for_rpc_payment_threshold = field_auto_mine_for_rpc_payment;
- GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, credits_target, uint64_t, Uint64, false, 0);
- m_credits_target = field_credits_target;
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, enable_multisig, int, Int, false, false);
m_enable_multisig = field_enable_multisig;
}
@@ -5910,9 +5872,6 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
}
- if (!m_persistent_rpc_client_id)
- set_rpc_client_secret_key(rct::rct2sk(rct::skGen()));
-
cryptonote::block genesis;
generate_genesis(genesis);
crypto::hash genesis_hash = get_block_hash(genesis);
@@ -5970,11 +5929,7 @@ void wallet2::trim_hashchain()
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
req.height = m_blockchain.size() - 1;
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = net_utils::invoke_http_json_rpc("/json_rpc", "getblockheaderbyheight", req, res, *m_http_client, rpc_timeout);
- if (r && res.status == CORE_RPC_STATUS_OK)
- check_rpc_cost("getblockheaderbyheight", res.credits, pre_call_credits, COST_PER_BLOCK_HEADER);
}
if (r && res.status == CORE_RPC_STATUS_OK)
@@ -6386,14 +6341,11 @@ void wallet2::rescan_spent()
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/is_key_image_spent", req, daemon_resp, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, daemon_resp, "is_key_image_spent", error::is_key_image_spent_error, get_rpc_status(daemon_resp.status));
THROW_WALLET_EXCEPTION_IF(daemon_resp.spent_status.size() != n_outputs, error::wallet_internal_error,
"daemon returned wrong response for is_key_image_spent, wrong amounts count = " +
std::to_string(daemon_resp.spent_status.size()) + ", expected " + std::to_string(n_outputs));
- check_rpc_cost("/is_key_image_spent", daemon_resp.credits, pre_call_credits, n_outputs * COST_PER_KEY_IMAGE);
}
std::copy(daemon_resp.spent_status.begin(), daemon_resp.spent_status.end(), std::back_inserter(spent_status));
@@ -6736,11 +6688,8 @@ void wallet2::commit_tx(pending_tx& ptx)
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/sendrawtransaction", req, daemon_send_resp, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, daemon_send_resp, "sendrawtransaction", error::tx_rejected, ptx.tx, get_rpc_status(daemon_send_resp.status), get_text_reason(daemon_send_resp));
- check_rpc_cost("/sendrawtransaction", daemon_send_resp.credits, pre_call_credits, COST_PER_TX_RELAY);
}
// sanity checks
@@ -7882,11 +7831,8 @@ uint32_t wallet2::adjust_priority(uint32_t priority)
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- getbh_req.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "getblockheadersrange", getbh_req, getbh_res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, getbh_res, "getblockheadersrange", error::get_blocks_error, get_rpc_status(getbh_res.status));
- check_rpc_cost("/getblockheadersrange", getbh_res.credits, pre_call_credits, N * COST_PER_BLOCK_HEADER);
}
if (getbh_res.headers.size() != N)
@@ -8125,14 +8071,11 @@ bool wallet2::find_and_save_rings(bool force)
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/gettransactions");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != req.txs_hashes.size(), error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong txs count = " +
std::to_string(res.txs.size()) + ", expected " + std::to_string(req.txs_hashes.size()));
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, res.txs.size() * COST_PER_TX);
}
MDEBUG("Scanning " << res.txs.size() << " transactions");
@@ -8470,11 +8413,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_output_histogram", req_t, resp_t, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, resp_t, "get_output_histogram", error::get_histogram_error, get_rpc_status(resp_t.status));
- check_rpc_cost("get_output_histogram", resp_t.credits, pre_call_credits, COST_PER_OUTPUT_HISTOGRAM * req_t.amounts.size());
}
}
@@ -8497,13 +8437,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_output_distribution", req_t, resp_t, *m_http_client, rpc_timeout * 1000);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, resp_t, "get_output_distribution", error::get_output_distribution, get_rpc_status(resp_t.status));
- uint64_t expected_cost = 0;
- for (uint64_t amount: req_t.amounts) expected_cost += (amount ? COST_PER_OUTPUT_DISTRIBUTION : COST_PER_OUTPUT_DISTRIBUTION_0);
- check_rpc_cost("get_output_distribution", resp_t.credits, pre_call_credits, expected_cost);
}
// check we got all data
@@ -8885,14 +8820,11 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
chunk_req.outputs.push_back(req.outputs[offset + i]);
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- chunk_req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_bin("/get_outs.bin", chunk_req, chunk_daemon_resp, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, chunk_daemon_resp, "get_outs.bin", error::get_outs_error, get_rpc_status(chunk_daemon_resp.status));
THROW_WALLET_EXCEPTION_IF(chunk_daemon_resp.outs.size() != chunk_req.outputs.size(), error::wallet_internal_error,
"daemon returned wrong response for get_outs.bin, wrong amounts count = " +
std::to_string(chunk_daemon_resp.outs.size()) + ", expected " + std::to_string(chunk_req.outputs.size()));
- check_rpc_cost("/get_outs.bin", chunk_daemon_resp.credits, pre_call_credits, chunk_daemon_resp.outs.size() * COST_PER_OUT);
offset += chunk_size;
for (size_t i = 0; i < chunk_daemon_resp.outs.size(); ++i)
@@ -11325,12 +11257,8 @@ std::vector<size_t> wallet2::select_available_outputs_from_histogram(uint64_t co
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_output_histogram", req_t, resp_t, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, resp_t, "get_output_histogram", error::get_histogram_error, resp_t.status);
- uint64_t cost = req_t.amounts.empty() ? COST_PER_FULL_OUTPUT_HISTOGRAM : (COST_PER_OUTPUT_HISTOGRAM * req_t.amounts.size());
- check_rpc_cost("get_output_histogram", resp_t.credits, pre_call_credits, cost);
}
std::set<uint64_t> mixable;
@@ -11367,13 +11295,10 @@ uint64_t wallet2::get_num_rct_outputs()
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req_t.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_output_histogram", req_t, resp_t, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, resp_t, "get_output_histogram", error::get_histogram_error, resp_t.status);
THROW_WALLET_EXCEPTION_IF(resp_t.histogram.size() != 1, error::get_histogram_error, "Expected exactly one response");
THROW_WALLET_EXCEPTION_IF(resp_t.histogram[0].amount != 0, error::get_histogram_error, "Expected 0 amount");
- check_rpc_cost("get_output_histogram", resp_t.credits, pre_call_credits, COST_PER_OUTPUT_HISTOGRAM);
}
return resp_t.histogram[0].total_instances;
@@ -11498,12 +11423,9 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- req.client = get_client_signature();
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
bool ok = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client);
THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
error::wallet_internal_error, "Failed to get transaction from daemon");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, res.txs.size() * COST_PER_TX);
}
cryptonote::transaction tx;
@@ -11548,17 +11470,13 @@ void wallet2::set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_
req.prune = true;
COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
bool r;
- uint64_t pre_call_credits;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/gettransactions");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1, error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong txs count = " +
std::to_string(res.txs.size()) + ", expected 1");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -11611,17 +11529,13 @@ std::string wallet2::get_spend_proof(const crypto::hash &txid, const std::string
req.prune = true;
COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
bool r;
- uint64_t pre_call_credits;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "gettransactions");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1, error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong txs count = " +
std::to_string(res.txs.size()) + ", expected 1");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -11674,17 +11588,13 @@ std::string wallet2::get_spend_proof(const crypto::hash &txid, const std::string
}
COMMAND_RPC_GET_OUTPUTS_BIN::response res = AUTO_VAL_INIT(res);
bool r;
- uint64_t pre_call_credits;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = epee::net_utils::invoke_http_bin("/get_outs.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "get_outs.bin", error::get_outs_error, res.status);
THROW_WALLET_EXCEPTION_IF(res.outs.size() != ring_size, error::wallet_internal_error,
"daemon returned wrong response for get_outs.bin, wrong amounts count = " +
std::to_string(res.outs.size()) + ", expected " + std::to_string(ring_size));
- check_rpc_cost("/get_outs.bin", res.credits, pre_call_credits, ring_size * COST_PER_OUT);
}
// copy pubkey pointers
@@ -11732,17 +11642,13 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
req.prune = true;
COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
bool r;
- uint64_t pre_call_credits;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "gettransactions");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1, error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong txs count = " +
std::to_string(res.txs.size()) + ", expected 1");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -11807,17 +11713,13 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
}
COMMAND_RPC_GET_OUTPUTS_BIN::response res = AUTO_VAL_INIT(res);
bool r;
- uint64_t pre_call_credits;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = epee::net_utils::invoke_http_bin("/get_outs.bin", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "get_outs.bin", error::get_outs_error, res.status);
THROW_WALLET_EXCEPTION_IF(res.outs.size() != req.outputs.size(), error::wallet_internal_error,
"daemon returned wrong response for get_outs.bin, wrong amounts count = " +
std::to_string(res.outs.size()) + ", expected " + std::to_string(req.outputs.size()));
- check_rpc_cost("/get_outs.bin", res.credits, pre_call_credits, req.outputs.size() * COST_PER_OUT);
}
// copy pointers
@@ -11903,12 +11805,9 @@ void wallet2::check_tx_key_helper(const crypto::hash &txid, const crypto::key_de
bool ok;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
ok = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client);
THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
error::wallet_internal_error, "Failed to get transaction from daemon");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -12001,12 +11900,9 @@ std::string wallet2::get_tx_proof(const crypto::hash &txid, const cryptonote::ac
bool ok;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
ok = net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client);
THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
error::wallet_internal_error, "Failed to get transaction from daemon");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -12162,12 +12058,9 @@ bool wallet2::check_tx_proof(const crypto::hash &txid, const cryptonote::account
bool ok;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
ok = net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client);
THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
error::wallet_internal_error, "Failed to get transaction from daemon");
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, COST_PER_TX);
}
cryptonote::transaction tx;
@@ -12485,12 +12378,9 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- gettx_req.client = get_client_signature();
bool ok = net_utils::invoke_http_json("/gettransactions", gettx_req, gettx_res, *m_http_client);
THROW_WALLET_EXCEPTION_IF(!ok || gettx_res.txs.size() != proofs.size(),
error::wallet_internal_error, "Failed to get transaction from daemon");
- check_rpc_cost("/gettransactions", gettx_res.credits, pre_call_credits, gettx_res.txs.size() * COST_PER_TX);
}
// check spent status
@@ -12502,12 +12392,9 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
bool ok;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- kispent_req.client = get_client_signature();
ok = epee::net_utils::invoke_http_json("/is_key_image_spent", kispent_req, kispent_res, *m_http_client, rpc_timeout);
THROW_WALLET_EXCEPTION_IF(!ok || kispent_res.spent_status.size() != proofs.size(),
error::wallet_internal_error, "Failed to get key image spent status from daemon");
- check_rpc_cost("/is_key_image_spent", kispent_res.credits, pre_call_credits, kispent_res.spent_status.size() * COST_PER_KEY_IMAGE);
}
total = spent = 0;
@@ -13157,14 +13044,11 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
PERF_TIMER(import_key_images_RPC);
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = epee::net_utils::invoke_http_json("/is_key_image_spent", req, daemon_resp, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, daemon_resp, "is_key_image_spent");
THROW_WALLET_EXCEPTION_IF(daemon_resp.spent_status.size() != signed_key_images.size(), error::wallet_internal_error,
"daemon returned wrong response for is_key_image_spent, wrong amounts count = " +
std::to_string(daemon_resp.spent_status.size()) + ", expected " + std::to_string(signed_key_images.size()));
- check_rpc_cost("/is_key_image_spent", daemon_resp.credits, pre_call_credits, daemon_resp.spent_status.size() * COST_PER_KEY_IMAGE);
}
for (size_t n = 0; n < daemon_resp.spent_status.size(); ++n)
@@ -13246,13 +13130,10 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
PERF_TIMER_START(import_key_images_E);
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- gettxs_req.client = get_client_signature();
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
bool r = epee::net_utils::invoke_http_json("/gettransactions", gettxs_req, gettxs_res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, gettxs_res, "gettransactions");
THROW_WALLET_EXCEPTION_IF(gettxs_res.txs.size() != spent_txids.size(), error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong count = " + std::to_string(gettxs_res.txs.size()) + ", expected " + std::to_string(spent_txids.size()));
- check_rpc_cost("/gettransactions", gettxs_res.credits, pre_call_credits, spent_txids.size() * COST_PER_TX);
}
PERF_TIMER_STOP(import_key_images_E);
@@ -14402,11 +14283,7 @@ uint64_t wallet2::get_blockchain_height_by_date(uint16_t year, uint8_t month, ui
bool r;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
r = net_utils::invoke_http_bin("/getblocks_by_height.bin", req, res, *m_http_client, rpc_timeout);
- if (r && res.status == CORE_RPC_STATUS_OK)
- check_rpc_cost("/getblocks_by_height.bin", res.credits, pre_call_credits, 3 * COST_PER_BLOCK);
}
if (!r || res.status != CORE_RPC_STATUS_OK)
@@ -14480,11 +14357,8 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(const std::
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_txpool_backlog", req, res, *m_http_client, rpc_timeout);
THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "get_txpool_backlog", error::get_tx_pool_error);
- check_rpc_cost("get_txpool_backlog", res.credits, pre_call_credits, COST_PER_TX_POOL_STATS * res.backlog.size());
}
uint64_t block_weight_limit = 0;
@@ -14635,13 +14509,17 @@ std::string wallet2::get_rpc_status(const std::string &s) const
//----------------------------------------------------------------------------------------------------
void wallet2::throw_on_rpc_response_error(bool r, const epee::json_rpc::error &error, const std::string &status, const char *method) const
{
+ // Treat all RPC payment access errors the same, whether payment is actually required or not
+ THROW_WALLET_EXCEPTION_IF(error.code == CORE_RPC_ERROR_CODE_INVALID_CLIENT, tools::error::deprecated_rpc_access, method);
THROW_WALLET_EXCEPTION_IF(error.code, tools::error::wallet_coded_rpc_error, method, error.code, get_rpc_server_error_message(error.code));
THROW_WALLET_EXCEPTION_IF(!r, tools::error::no_connection_to_daemon, method);
// empty string -> not connection
THROW_WALLET_EXCEPTION_IF(status.empty(), tools::error::no_connection_to_daemon, method);
THROW_WALLET_EXCEPTION_IF(status == CORE_RPC_STATUS_BUSY, tools::error::daemon_busy, method);
- THROW_WALLET_EXCEPTION_IF(status == CORE_RPC_STATUS_PAYMENT_REQUIRED, tools::error::payment_required, method);
+ THROW_WALLET_EXCEPTION_IF(status == CORE_RPC_STATUS_PAYMENT_REQUIRED, tools::error::deprecated_rpc_access, method);
+ // Deprecated RPC payment access endpoints would set status to "Client signature does not verify for <method>"
+ THROW_WALLET_EXCEPTION_IF(status.compare(0, 16, "Client signature") == 0, tools::error::deprecated_rpc_access, method);
}
//----------------------------------------------------------------------------------------------------
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index d3f3287c5..d5737a5bd 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -71,14 +71,12 @@
#include "node_rpc_proxy.h"
#include "message_store.h"
#include "wallet_light_rpc.h"
-#include "wallet_rpc_helpers.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
#define THROW_ON_RPC_RESPONSE_ERROR(r, error, res, method, ...) \
do { \
- handle_payment_changes(res, std::integral_constant<bool, HasCredits<decltype(res)>::Has>()); \
throw_on_rpc_response_error(r, error, res.status, method); \
THROW_WALLET_EXCEPTION_IF(res.status != CORE_RPC_STATUS_OK, ## __VA_ARGS__); \
} while(0)
@@ -1234,7 +1232,8 @@ private:
a & m_cold_key_images.parent();
if(ver < 29)
return;
- a & m_rpc_client_secret_key;
+ crypto::secret_key dummy_rpc_client_secret_key; // Compatibility for old RPC payment system
+ a & dummy_rpc_client_secret_key;
if(ver < 30)
{
m_has_ever_refreshed_from_node = false;
@@ -1270,7 +1269,8 @@ private:
FIELD(m_tx_device)
FIELD(m_device_last_key_image_sync)
FIELD(m_cold_key_images)
- FIELD(m_rpc_client_secret_key)
+ crypto::secret_key dummy_rpc_client_secret_key; // Compatibility for old RPC payment system
+ FIELD_N("m_rpc_client_secret_key", dummy_rpc_client_secret_key)
if (version < 1)
{
m_has_ever_refreshed_from_node = false;
@@ -1354,14 +1354,6 @@ private:
inline void set_export_format(const ExportFormat& export_format) { m_export_format = export_format; }
bool load_deprecated_formats() const { return m_load_deprecated_formats; }
void load_deprecated_formats(bool load) { m_load_deprecated_formats = load; }
- bool persistent_rpc_client_id() const { return m_persistent_rpc_client_id; }
- void persistent_rpc_client_id(bool persistent) { m_persistent_rpc_client_id = persistent; }
- void auto_mine_for_rpc_payment_threshold(float threshold) { m_auto_mine_for_rpc_payment_threshold = threshold; }
- float auto_mine_for_rpc_payment_threshold() const { return m_auto_mine_for_rpc_payment_threshold; }
- crypto::secret_key get_rpc_client_secret_key() const { return m_rpc_client_secret_key; }
- void set_rpc_client_secret_key(const crypto::secret_key &key) { m_rpc_client_secret_key = key; m_node_rpc_proxy.set_client_secret_key(key); }
- uint64_t credits_target() const { return m_credits_target; }
- void credits_target(uint64_t threshold) { m_credits_target = threshold; }
bool is_multisig_enabled() const { return m_enable_multisig; }
void enable_multisig(bool enable) { m_enable_multisig = enable; }
bool is_mismatched_daemon_version_allowed() const { return m_allow_mismatched_daemon_version; }
@@ -1545,21 +1537,6 @@ private:
std::pair<size_t, uint64_t> estimate_tx_size_and_weight(bool use_rct, int n_inputs, int ring_size, int n_outputs, size_t extra_size);
- bool get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &hashing_blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie);
- bool daemon_requires_payment();
- bool make_rpc_payment(uint32_t nonce, uint32_t cookie, uint64_t &credits, uint64_t &balance);
- bool search_for_rpc_payment(uint64_t credits_target, uint32_t n_threads, const std::function<bool(uint64_t, uint64_t)> &startfunc, const std::function<bool(unsigned)> &contfunc, const std::function<bool(uint64_t)> &foundfunc = NULL, const std::function<void(const std::string&)> &errorfunc = NULL);
- template<typename T> void handle_payment_changes(const T &res, std::true_type) {
- if (res.status == CORE_RPC_STATUS_OK || res.status == CORE_RPC_STATUS_PAYMENT_REQUIRED)
- m_rpc_payment_state.credits = res.credits;
- if (res.top_hash != m_rpc_payment_state.top_hash)
- {
- m_rpc_payment_state.top_hash = res.top_hash;
- m_rpc_payment_state.stale = true;
- }
- }
- template<typename T> void handle_payment_changes(const T &res, std::false_type) {}
-
// Light wallet specific functions
// fetch unspent outs from lw node and store in m_transfers
void light_wallet_get_unspent_outs();
@@ -1674,9 +1651,6 @@ private:
void set_offline(bool offline = true);
bool is_offline() const { return m_offline; }
- uint64_t credits() const { return m_rpc_payment_state.credits; }
- void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const { expected_spent = m_rpc_payment_state.expected_spent; discrepancy = m_rpc_payment_state.discrepancy; }
-
static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; }
private:
@@ -1785,9 +1759,6 @@ private:
std::string get_rpc_status(const std::string &s) const;
void throw_on_rpc_response_error(bool r, const epee::json_rpc::error &error, const std::string &status, const char *method) const;
- std::string get_client_signature() const;
- void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost);
-
bool should_expand(const cryptonote::subaddress_index &index) const;
bool spends_one_of_ours(const cryptonote::transaction &tx) const;
@@ -1873,7 +1844,6 @@ private:
bool m_show_wallet_name_when_locked;
uint32_t m_inactivity_lock_timeout;
BackgroundMiningSetupType m_setup_background_mining;
- bool m_persistent_rpc_client_id;
float m_auto_mine_for_rpc_payment_threshold;
bool m_is_initialized;
NodeRPCProxy m_node_rpc_proxy;
@@ -1885,9 +1855,6 @@ private:
bool m_use_dns;
bool m_offline;
uint32_t m_rpc_version;
- crypto::secret_key m_rpc_client_secret_key;
- rpc_payment_state_t m_rpc_payment_state;
- uint64_t m_credits_target;
bool m_enable_multisig;
bool m_allow_mismatched_daemon_version;
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index c1f47d6a9..9710f134c 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -76,10 +76,6 @@ namespace wallet_args
{
return {"wallet-file", wallet_args::tr("Use wallet <arg>"), ""};
}
- command_line::arg_descriptor<std::string> arg_rpc_client_secret_key()
- {
- return {"rpc-client-secret-key", wallet_args::tr("Set RPC client secret key for RPC payments"), ""};
- }
command_line::arg_descriptor<std::string> arg_password_file()
{
return {"password-file", wallet_args::tr("Wallet password file"), ""};
diff --git a/src/wallet/wallet_args.h b/src/wallet/wallet_args.h
index 2e687521f..e5b440fc3 100644
--- a/src/wallet/wallet_args.h
+++ b/src/wallet/wallet_args.h
@@ -36,7 +36,6 @@ namespace wallet_args
{
command_line::arg_descriptor<std::string> arg_generate_from_json();
command_line::arg_descriptor<std::string> arg_wallet_file();
- command_line::arg_descriptor<std::string> arg_rpc_client_secret_key();
command_line::arg_descriptor<std::string> arg_password_file();
const char* tr(const char* str);
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index fb43d16b4..a2b248434 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -91,7 +91,7 @@ namespace tools
// is_key_image_spent_error
// get_histogram_error
// get_output_distribution
- // payment_required
+ // deprecated_rpc_access
// wallet_files_doesnt_correspond
//
// * - class with protected ctor
@@ -865,10 +865,11 @@ namespace tools
}
};
//----------------------------------------------------------------------------------------------------
- struct payment_required: public wallet_rpc_error
+ struct deprecated_rpc_access: public wallet_rpc_error
{
- explicit payment_required(std::string&& loc, const std::string& request)
- : wallet_rpc_error(std::move(loc), "payment required", request)
+ // The daemon we connected to has enabled the old pay-to-access RPC feature
+ explicit deprecated_rpc_access(std::string&& loc, const std::string& request)
+ : wallet_rpc_error(std::move(loc), "daemon requires deprecated RPC payment", request)
{
}
};
diff --git a/src/wallet/wallet_rpc_helpers.h b/src/wallet/wallet_rpc_helpers.h
deleted file mode 100644
index e974e0a9e..000000000
--- a/src/wallet/wallet_rpc_helpers.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2018-2023, The Monero Project
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are
-// permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice, this list
-// of conditions and the following disclaimer in the documentation and/or other
-// materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its contributors may be
-// used to endorse or promote products derived from this software without specific
-// prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// 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.
-
-#pragma once
-
-#include <limits>
-#include <type_traits>
-
-namespace
-{
- // credits to yrp (https://stackoverflow.com/questions/87372/check-if-a-class-has-a-member-function-of-a-given-signature
- template <typename T>
- struct HasCredits
- {
- template<typename U, uint64_t (U::*)> struct SFINAE {};
- template<typename U> static char Test(SFINAE<U, &U::credits>*);
- template<typename U> static int Test(...);
- static const bool Has = sizeof(Test<T>(0)) == sizeof(char);
- };
-}
-
-namespace tools
-{
- struct rpc_payment_state_t
- {
- uint64_t credits;
- uint64_t expected_spent;
- uint64_t discrepancy;
- std::string top_hash;
- bool stale;
-
- rpc_payment_state_t(): credits(0), expected_spent(0), discrepancy(0), stale(true) {}
- };
-
- static inline void check_rpc_cost(rpc_payment_state_t &rpc_payment_state, const char *call, uint64_t post_call_credits, uint64_t pre_call_credits, double expected_cost)
- {
- uint64_t expected_credits = (uint64_t)expected_cost;
- if (expected_credits == 0)
- expected_credits = 1;
-
- rpc_payment_state.credits = post_call_credits;
- rpc_payment_state.expected_spent += expected_credits;
-
- if (pre_call_credits <= post_call_credits)
- return;
-
- uint64_t cost = pre_call_credits - post_call_credits;
-
- if (cost == expected_credits)
- {
- MDEBUG("Call " << call << " cost " << cost << " credits");
- return;
- }
- MWARNING("Call " << call << " cost " << cost << " credits, expected " << expected_credits);
-
- if (cost > expected_credits)
- {
- uint64_t d = cost - expected_credits;
- if (rpc_payment_state.discrepancy > std::numeric_limits<uint64_t>::max() - d)
- {
- MERROR("Integer overflow in credit discrepancy calculation, setting to max");
- rpc_payment_state.discrepancy = std::numeric_limits<uint64_t>::max();
- }
- else
- {
- rpc_payment_state.discrepancy += d;
- }
- }
- }
-}
diff --git a/src/wallet/wallet_rpc_payments.cpp b/src/wallet/wallet_rpc_payments.cpp
deleted file mode 100644
index 3242d88b8..000000000
--- a/src/wallet/wallet_rpc_payments.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright (c) 2018-2023, The Monero Project
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are
-// permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice, this list
-// of conditions and the following disclaimer in the documentation and/or other
-// materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its contributors may be
-// used to endorse or promote products derived from this software without specific
-// prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// 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 <boost/utility/value_init.hpp>
-#include "include_base_utils.h"
-#include "cryptonote_config.h"
-#include "wallet_rpc_helpers.h"
-#include "wallet2.h"
-#include "cryptonote_basic/cryptonote_format_utils.h"
-#include "rpc/core_rpc_server_commands_defs.h"
-#include "rpc/rpc_payment_signature.h"
-#include "misc_language.h"
-#include "cryptonote_basic/cryptonote_basic_impl.h"
-#include "int-util.h"
-#include "crypto/crypto.h"
-#include "cryptonote_basic/blobdatatype.h"
-#include "common/i18n.h"
-#include "common/util.h"
-#include "common/threadpool.h"
-
-#undef MONERO_DEFAULT_LOG_CATEGORY
-#define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2.rpc_payments"
-
-#define RPC_PAYMENT_POLL_PERIOD 10 /* seconds*/
-
-namespace tools
-{
-//----------------------------------------------------------------------------------------------------
-std::string wallet2::get_client_signature() const
-{
- return cryptonote::make_rpc_payment_signature(m_rpc_client_secret_key);
-}
-//----------------------------------------------------------------------------------------------------
-bool wallet2::get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &hashing_blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie)
-{
- boost::optional<std::string> result = m_node_rpc_proxy.get_rpc_payment_info(mining, payment_required, credits, diff, credits_per_hash_found, hashing_blob, height, seed_height, seed_hash, next_seed_hash, cookie);
- credits = m_rpc_payment_state.credits;
- if (result && *result != CORE_RPC_STATUS_OK)
- return false;
- return true;
-}
-//----------------------------------------------------------------------------------------------------
-bool wallet2::daemon_requires_payment()
-{
- bool payment_required = false;
- uint64_t credits, diff, credits_per_hash_found, height, seed_height;
- uint32_t cookie;
- cryptonote::blobdata blob;
- crypto::hash seed_hash, next_seed_hash;
- return get_rpc_payment_info(false, payment_required, credits, diff, credits_per_hash_found, blob, height, seed_height, seed_hash, next_seed_hash, cookie) && payment_required;
-}
-//----------------------------------------------------------------------------------------------------
-bool wallet2::make_rpc_payment(uint32_t nonce, uint32_t cookie, uint64_t &credits, uint64_t &balance)
-{
- cryptonote::COMMAND_RPC_ACCESS_SUBMIT_NONCE::request req = AUTO_VAL_INIT(req);
- cryptonote::COMMAND_RPC_ACCESS_SUBMIT_NONCE::response res = AUTO_VAL_INIT(res);
- req.nonce = nonce;
- req.cookie = cookie;
- m_daemon_rpc_mutex.lock();
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
- req.client = get_client_signature();
- epee::json_rpc::error error;
- bool r = epee::net_utils::invoke_http_json_rpc("/json_rpc", "rpc_access_submit_nonce", req, res, error, *m_http_client, rpc_timeout);
- m_daemon_rpc_mutex.unlock();
- THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, error, res, "rpc_access_submit_nonce");
- THROW_WALLET_EXCEPTION_IF(res.credits < pre_call_credits, error::wallet_internal_error, "RPC payment did not increase balance");
- if (m_rpc_payment_state.top_hash != res.top_hash)
- {
- m_rpc_payment_state.top_hash = res.top_hash;
- m_rpc_payment_state.stale = true;
- }
-
- m_rpc_payment_state.credits = res.credits;
- balance = res.credits;
- credits = balance - pre_call_credits;
- return true;
-}
-//----------------------------------------------------------------------------------------------------
-bool wallet2::search_for_rpc_payment(uint64_t credits_target, uint32_t n_threads, const std::function<bool(uint64_t, uint64_t)> &startfunc, const std::function<bool(unsigned)> &contfunc, const std::function<bool(uint64_t)> &foundfunc, const std::function<void(const std::string&)> &errorfunc)
-{
- bool need_payment = false;
- bool payment_required;
- uint64_t credits, diff, credits_per_hash_found, height, seed_height;
- uint32_t cookie;
- unsigned int n_hashes = 0;
- cryptonote::blobdata hashing_blob;
- crypto::hash seed_hash, next_seed_hash;
- try
- {
- need_payment = get_rpc_payment_info(false, payment_required, credits, diff, credits_per_hash_found, hashing_blob, height, seed_height, seed_hash, next_seed_hash, cookie) && payment_required && credits < credits_target;
- if (!need_payment)
- return true;
- if (!startfunc(diff, credits_per_hash_found))
- return true;
- }
- catch (const std::exception &e) { return false; }
-
- static std::atomic<uint32_t> nonce(0);
- while (contfunc(n_hashes))
- {
- try
- {
- need_payment = get_rpc_payment_info(true, payment_required, credits, diff, credits_per_hash_found, hashing_blob, height, seed_height, seed_hash, next_seed_hash, cookie) && payment_required && credits < credits_target;
- if (!need_payment)
- return true;
- }
- catch (const std::exception &e) { return false; }
- if (hashing_blob.empty())
- {
- MERROR("Bad hashing blob from daemon");
- if (errorfunc)
- errorfunc("Bad hashing blob from daemon, trying again");
- epee::misc_utils::sleep_no_w(1000);
- continue;
- }
-
- if(n_threads == 0)
- n_threads = boost::thread::hardware_concurrency();
-
- std::vector<crypto::hash> hash(n_threads);
- tools::threadpool& tpool = tools::threadpool::getInstanceForCompute();
- tools::threadpool::waiter waiter(tpool);
-
- const uint32_t local_nonce = nonce += n_threads; // wrapping's OK
- for (size_t i = 0; i < n_threads; i++)
- {
- tpool.submit(&waiter, [&, i] {
- *(uint32_t*)(hashing_blob.data() + 39) = SWAP32LE(local_nonce-i);
- const uint8_t major_version = hashing_blob[0];
- if (major_version >= RX_BLOCK_VERSION)
- {
- crypto::rx_slow_hash(seed_hash.data, hashing_blob.data(), hashing_blob.size(), hash[i].data);
- }
- else
- {
- int cn_variant = hashing_blob[0] >= 7 ? hashing_blob[0] - 6 : 0;
- crypto::cn_slow_hash(hashing_blob.data(), hashing_blob.size(), hash[i], cn_variant, height);
- }
- });
- }
- waiter.wait();
- n_hashes += n_threads;
-
- for(size_t i=0; i < n_threads; i++)
- {
- if (cryptonote::check_hash(hash[i], diff))
- {
- uint64_t credits, balance;
- try
- {
- make_rpc_payment(local_nonce-i, cookie, credits, balance);
- if (credits != credits_per_hash_found)
- {
- MERROR("Found nonce, but daemon did not credit us with the expected amount");
- if (errorfunc)
- errorfunc("Found nonce, but daemon did not credit us with the expected amount");
- return false;
- }
- MDEBUG("Found nonce " << local_nonce-i << " at diff " << diff << ", gets us " << credits_per_hash_found << ", now " << balance << " credits");
- if (!foundfunc(credits))
- break;
- }
- catch (const tools::error::wallet_coded_rpc_error &e)
- {
- MWARNING("Found a local_nonce at diff " << diff << ", but failed to send it to the daemon");
- if (errorfunc)
- errorfunc("Found nonce, but daemon errored out with error " + std::to_string(e.code()) + ": " + e.status() + ", continuing");
- }
- catch (const std::exception &e)
- {
- MWARNING("Found a local_nonce at diff " << diff << ", but failed to send it to the daemon");
- if (errorfunc)
- errorfunc("Found nonce, but daemon errored out with: '" + std::string(e.what()) + "', continuing");
- }
- }
- }
- }
- return true;
-}
-//----------------------------------------------------------------------------------------------------
-void wallet2::check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_call_credits, double expected_cost)
-{
- return tools::check_rpc_cost(m_rpc_payment_state, call, post_call_credits, pre_call_credits, expected_cost);
-}
-//----------------------------------------------------------------------------------------------------
-}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index d11e9bc1a..81e26c120 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -4517,7 +4517,6 @@ public:
const auto arg_wallet_file = wallet_args::arg_wallet_file();
const auto arg_from_json = wallet_args::arg_generate_from_json();
- const auto arg_rpc_client_secret_key = wallet_args::arg_rpc_client_secret_key();
const auto arg_password_file = wallet_args::arg_password_file();
const auto wallet_file = command_line::get_arg(vm, arg_wallet_file);
@@ -4575,17 +4574,6 @@ public:
return false;
}
- if (!command_line::is_arg_defaulted(vm, arg_rpc_client_secret_key))
- {
- crypto::secret_key client_secret_key;
- if (!epee::string_tools::hex_to_pod(command_line::get_arg(vm, arg_rpc_client_secret_key), client_secret_key))
- {
- MERROR(arg_rpc_client_secret_key.name << ": RPC client secret key should be 32 byte in hex format");
- return false;
- }
- wal->set_rpc_client_secret_key(client_secret_key);
- }
-
bool quit = false;
tools::signal_handler::install([&wal, &quit](int) {
assert(wal);
@@ -4692,7 +4680,6 @@ int main(int argc, char** argv) {
const auto arg_wallet_file = wallet_args::arg_wallet_file();
const auto arg_from_json = wallet_args::arg_generate_from_json();
- const auto arg_rpc_client_secret_key = wallet_args::arg_rpc_client_secret_key();
po::options_description hidden_options("Hidden");
@@ -4706,7 +4693,6 @@ int main(int argc, char** argv) {
command_line::add_arg(desc_params, arg_from_json);
command_line::add_arg(desc_params, arg_wallet_dir);
command_line::add_arg(desc_params, arg_prompt_for_password);
- command_line::add_arg(desc_params, arg_rpc_client_secret_key);
command_line::add_arg(desc_params, arg_no_initial_sync);
daemonizer::init_options(hidden_options, desc_params);