fix build after merge

still need to make tests build and fix up some behavior
correctness around RPC (and maybe other areas)
This commit is contained in:
Thomas Winget 2022-07-25 22:22:49 -04:00
parent b3a3461f92
commit 0b17bb9adb
28 changed files with 90 additions and 98 deletions

View File

@ -35,7 +35,6 @@
#include "levin_base.h"
#include "buffer.h"
#include "../misc_language.h"
#include "../scope_leaver.h"
#include "../int-util.h"

View File

@ -158,7 +158,7 @@ namespace epee
case SERIALIZE_TYPE_TAG<std::string>: return read_ae<std::string>();
case SERIALIZE_TYPE_TAG<section>: return read_ae<section>();
//case SERIALIZE_TYPE_ARRAY: return read_ae<array_entry>(); // nested arrays not supported
default: CHECK_AND_ASSERT_THROW_MES(false, "unknown entry_type code = " << (int)type);
default: { CHECK_AND_ASSERT_THROW_MES(false, "unknown entry_type code = " << (int)type); return {}; }
}
}
@ -211,7 +211,7 @@ namespace epee
case SERIALIZE_TYPE_TAG<std::string>: return read_se<std::string>();
case SERIALIZE_TYPE_TAG<section>: return read_se<section>();
//case SERIALIZE_TYPE_ARRAY: return read_se<array_entry>(); // nested arrays not supported
default: CHECK_AND_ASSERT_THROW_MES(false, "unknown entry_type code = " << (int)ent_type);
default: { CHECK_AND_ASSERT_THROW_MES(false, "unknown entry_type code = " << (int)ent_type); return {}; }
}
}
inline

View File

@ -36,6 +36,7 @@ add_library(blockchain_db
target_link_libraries(blockchain_db
PUBLIC
sqlitedb
nlohmann_json::nlohmann_json
PRIVATE
common
ringct

View File

@ -56,6 +56,7 @@ namespace cryptonote
namespace
{
const command_line::arg_descriptor<std::string> arg_extra_messages = {"extra-messages-file", "Specify file for extra messages to include into coinbase transactions", "", true};
const command_line::arg_descriptor<std::string> arg_start_mining = {"start-mining", "Specify wallet address to mining for", "", true};
const command_line::arg_descriptor<uint32_t> arg_mining_threads = {"mining-threads", "Specify mining threads count", 0, true};
}
@ -122,26 +123,12 @@ namespace cryptonote
return true;
});
m_update_hashrate_interval.do_call([&](){
update_hashrate();
return true;
});
return true;
}
//-----------------------------------------------------------------------------------------------------
void miner::update_hashrate()
{
std::unique_lock lock{m_hashrate_mutex};
auto hashes = m_hashes.exchange(0);
using dseconds = std::chrono::duration<double>;
if (m_last_hr_update && is_mining())
m_current_hash_rate = hashes / dseconds{std::chrono::steady_clock::now() - *m_last_hr_update}.count();
m_last_hr_update = std::chrono::steady_clock::now();
}
//-----------------------------------------------------------------------------------------------------
void miner::init_options(boost::program_options::options_description& desc)
{
command_line::add_arg(desc, arg_extra_messages);
command_line::add_arg(desc, arg_start_mining);
command_line::add_arg(desc, arg_mining_threads);
}
@ -253,7 +240,6 @@ namespace cryptonote
double miner::get_speed() const
{
if (is_mining()) {
std::unique_lock lock{m_hashrate_mutex};
return m_current_hash_rate;
}
return 0.0;

View File

@ -86,7 +86,6 @@ namespace cryptonote
private:
bool worker_thread(uint32_t index, bool slow_mining = false);
bool request_block_template();
void update_hashrate();
struct miner_config
{

View File

@ -37,11 +37,8 @@
#include "common/rules.h"
#include "common/hex.h"
<<<<<<< HEAD
#include "common/string_util.h"
=======
#include "common/median.h"
>>>>>>> upstream/dev
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/hardfork.h"

View File

@ -494,7 +494,7 @@ namespace cryptonote
*
* @note see Blockchain::get_blocks(const t_ids_container&, t_blocks_container&, t_missed_container&) const
*/
bool get_blocks(const std::vector<crypto::hash>& block_ids, std::vector<std::pair<cryptonote::blobdata, block>> blocks, std::unordered_set<crypto::hash>* missed_bs = nullptr) const;
bool get_blocks(const std::vector<crypto::hash>& block_ids, std::vector<std::pair<std::string, block>> blocks, std::unordered_set<crypto::hash>* missed_bs = nullptr) const;
/**
* @copydoc Blockchain::get_block_id_by_height

View File

@ -3914,17 +3914,6 @@ namespace service_nodes
tools::type_to_hex(reg.service_node_pubkey),
tools::type_to_hex(reg.signature));
if (make_friendly && reg.uses_portions)
{
std::tm tm;
epee::misc_utils::get_gmt_time(reg.hf, tm);
cmd += "\n\n";
cmd += fmt::format(tr("This registration expires at {:%Y-%m-%d %I:%M:%S %p} UTC.\n"), tm);
cmd += tr("This should be about 2 weeks from now; if it isn't, check this computer's clock.\n");
cmd += tr("Please submit your registration into the blockchain before this time or it will be invalid.");
}
return true;
}

View File

@ -365,8 +365,8 @@ bool rpc_command_executor::print_peer_list_stats() {
}
tools::msg_writer()
<< "White list size: " << wls->get<int>() << "/" << cryptonote::p2p::P2P_LOCAL_WHITE_PEERLIST_LIMIT << " (" << wls->get<int>() * 100.0 / cryptonote::p2p::P2P_LOCAL_WHITE_PEERLIST_LIMIT << "%)\n"
<< "Gray list size: " << gls->get<int>() << "/" << cryptonote::p2p::P2P_LOCAL_GRAY_PEERLIST_LIMIT << " (" << gls->get<int>() * 100.0 / cryptonote::p2p::P2P_LOCAL_GRAY_PEERLIST_LIMIT << "%)";
<< "White list size: " << wls->get<int>() << "/" << cryptonote::p2p::LOCAL_WHITE_PEERLIST_LIMIT << " (" << wls->get<int>() * 100.0 / cryptonote::p2p::LOCAL_WHITE_PEERLIST_LIMIT << "%)\n"
<< "Gray list size: " << gls->get<int>() << "/" << cryptonote::p2p::LOCAL_GRAY_PEERLIST_LIMIT << " (" << gls->get<int>() * 100.0 / cryptonote::p2p::LOCAL_GRAY_PEERLIST_LIMIT << "%)";
return true;
}
@ -509,7 +509,7 @@ bool rpc_command_executor::show_status() {
if (height < net_height)
str << ", syncing";
auto hf_version = hfinfo["version"].get<uint8_t>();
auto hf_version = hfinfo["version"].get<cryptonote::hf>();
if (hf_version < cryptonote::feature::PULSE && !has_mining_info)
str << ", mining info unavailable";
if (has_mining_info && !mining_busy && mining_active)
@ -601,6 +601,19 @@ bool rpc_command_executor::mining_status() {
return true;
}
static const char *get_address_type_name(epee::net_utils::address_type address_type)
{
switch (address_type)
{
default:
case epee::net_utils::address_type::invalid: return "invalid";
case epee::net_utils::address_type::ipv4: return "IPv4";
case epee::net_utils::address_type::ipv6: return "IPv6";
case epee::net_utils::address_type::i2p: return "I2P";
case epee::net_utils::address_type::tor: return "Tor";
}
}
bool rpc_command_executor::print_connections() {
auto maybe_conns = try_running([this] { return invoke<GET_CONNECTIONS>(); }, "Failed to retrieve connection info");
if (!maybe_conns)
@ -621,7 +634,7 @@ bool rpc_command_executor::print_connections() {
address += tools::int_to_string(info["port"].get<uint16_t>());
tools::msg_writer() << fmt::format(row_fmt,
address,
info["address_type"].get<epee::net_utils::address_type>(),
get_address_type_name(info["address_type"].get<epee::net_utils::address_type>()),
info["peer_id"].get<std::string_view>(),
fmt::format("{}({}/{})", info["recv_count"].get<uint64_t>(),
tools::friendly_duration(1ms * info["recv_idle_ms"].get<int64_t>()),
@ -1901,11 +1914,6 @@ bool rpc_command_executor::print_sn_key()
namespace {
uint64_t get_actual_amount(uint64_t amount, uint64_t portions)
{
return mul128_div64(amount, portions, cryptonote::old::STAKING_PORTIONS);
}
// Returns an error message on invalid, nullopt if good
std::optional<std::string_view> is_invalid_staking_address(
std::string_view addr,
@ -1984,7 +1992,7 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
}
uint64_t block_height = std::max(info["height"].get<uint64_t>(), info["target_height"].get<uint64_t>());
uint8_t hf_version = hfinfo["version"].get<uint8_t>();
auto hf_version = hfinfo["version"].get<cryptonote::hf>();
cryptonote::network_type const nettype =
info.value("mainnet", false) ? cryptonote::network_type::MAINNET :
info.value("devnet", false) ? cryptonote::network_type::DEVNET :
@ -2003,7 +2011,7 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
auto const& header = *maybe_header;
const auto now = std::chrono::system_clock::now();
const auto block_ts = std::chrono::system_clock::from_time_t(header.value<time_t>("timestamp", 0));
const auto block_ts = std::chrono::system_clock::from_time_t(header.timestamp);
if (now - block_ts >= 10min)
{
@ -2012,7 +2020,7 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
<< "\n\nRegistering this node may result in a deregistration due to being out of date with the network\n";
}
if (auto synced_height = header.value<uint64_t>("height", 0); block_height >= synced_height)
if (auto synced_height = header.height; block_height >= synced_height)
{
uint64_t delta = block_height - header.height;
if (delta > 5)
@ -2030,7 +2038,7 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
"------------------------------\n"
"Service Node Pubkey: \x1b[32;1m{}\x1b[33;1m\n"
"Staking requirement: {} from up to {} contributors\n\n",
snode_keys.value<std::string>(service_node_pubkey, ""),
snode_keys.value<std::string>("service_node_pubkey", ""),
highlight_money(staking_requirement),
oxen::MAX_CONTRIBUTORS_HF19);
@ -2268,7 +2276,7 @@ The Service Node will not activate until the entire stake has been contributed.
std::cout << "\nRegistration Summary:\n\n";
std::cout << "Service Node Pubkey: \x1b[32;1m" << kres.service_node_pubkey << "\x1b[0m\n" << std::endl;
std::cout << "Service Node Pubkey: \x1b[32;1m" << snode_keys["service_node_pubkey"] << "\x1b[0m\n" << std::endl;
if (amount_left > 0 || state.contributions.size() > 1)
fmt::print("Operator fee (as % of Service Node rewards): \x1b[33;1m{}%\x1b[0m\n\n",

View File

@ -692,7 +692,7 @@ namespace nodetool
{
zone.second.m_net_server.get_config_object().set_handler(this);
zone.second.m_net_server.get_config_object().m_invoke_timeout
= std::chrono::milliseconds{cryptonote::p2p::DEFAULT_INVOKE_TIMEOUT}.count();
= std::chrono::milliseconds{cryptonote::p2p::DEFAULT_INVOKE_TIMEOUT};
if (!zone.second.m_bind_ip.empty())
{
@ -925,7 +925,7 @@ namespace nodetool
LOG_DEBUG_CC(context, " COMMAND_HANDSHAKE(AND CLOSE) INVOKED OK");
}
context_ = context;
}, std::chrono::milliseconds{cryptonote::p2p::DEFAULT_HANDSHAKE_INVOKE_TIMEOUT}.count());
}, std::chrono::milliseconds{cryptonote::p2p::DEFAULT_HANDSHAKE_INVOKE_TIMEOUT});
if(r)
{

View File

@ -1,5 +1,4 @@
#include "p2p_protocol_defs.h"
#include "epee/misc_language.h"
#include "epee/string_tools.h"
#include "epee/time_helper.h"
#include "net/tor_address.h" // needed for serialization

View File

@ -205,7 +205,7 @@ namespace cryptonote::rpc {
info.response_hex["top_block_hash"] = top_hash;
info.response["target_height"] = m_core.get_target_blockchain_height();
res.hard_fork = m_core.get_blockchain_storage().get_network_version();
info.response["hard_fork"] = m_core.get_blockchain_storage().get_network_version();
bool next_block_is_pulse = false;
if (pulse::timings t;
@ -600,19 +600,20 @@ namespace cryptonote::rpc {
new_reg["expiry"] = x.hf_or_expiration;
new_reg["fee"] = microportion(x.fee);
}
hf reg_hf = new_reg["hardfork"];
new_reg["contributors"] = json::array();
for (size_t i = 0; i < x.amounts.size(); i++) {
auto wallet = get_account_address_as_str(nettype, false, {x.public_spend_keys[i], x.public_view_keys[i]});
uint64_t amount;
uint32_t portion;
if (reg.hardfork >= hf::hf19_reward_batching) {
if (reg_hf >= hf::hf19_reward_batching) {
amount = x.amounts[i];
// We aren't given info on whether this is testnet/mainnet, but we can guess by looking
// at the operator amount, which has to be <= 100 on testnet, but >= 3750 on mainnet.
auto nettype = x.amounts[0] > oxen::STAKING_REQUIREMENT_TESTNET
? network_type::MAINNET : network_type::TESTNET;
portion = std::lround(amount / (double) service_nodes::get_staking_requirement(nettype, reg.hardfork) * 1'000'000.0);
portion = std::lround(amount / (double) service_nodes::get_staking_requirement(nettype, reg_hf) * 1'000'000.0);
} else {
amount = 0;
portion = microportion(x.amounts[i]);
@ -743,7 +744,7 @@ namespace cryptonote::rpc {
bc.for_all_txpool_txes(
[&tx_infos, &pool]
(const crypto::hash& txid, const txpool_tx_meta_t& meta, const cryptonote::blobdata* bd) {
(const crypto::hash& txid, const txpool_tx_meta_t& meta, const std::string* bd) {
transaction tx;
if (!parse_and_validate_tx_from_blob(*bd, tx))
{
@ -943,7 +944,7 @@ namespace cryptonote::rpc {
auto height = std::numeric_limits<uint64_t>::max();
auto hf_version = get_network_version(nettype(), in_pool ? m_core.get_current_blockchain_height() : height);
if (uint64_t fee, burned; get_tx_miner_fee(tx, fee, hf_version >= HF_VERSION_FEE_BURNING, &burned)) {
if (uint64_t fee, burned; get_tx_miner_fee(tx, fee, hf_version >= feature::FEE_BURNING, &burned)) {
e["fee"] = fee;
e["burned"] = burned;
}
@ -1038,7 +1039,6 @@ namespace cryptonote::rpc {
tx.response["status"] = STATUS_BUSY;
return;
}
auto tx_blob = oxenc::from_hex(req.tx_as_hex);
if (tx.request.blink)
{
@ -1606,9 +1606,9 @@ namespace cryptonote::rpc {
PERF_TIMER(on_hard_fork_info);
const auto& blockchain = m_core.get_blockchain_storage();
uint8_t version =
hfinfo.request.version > 0 ? hfinfo.request.version :
hfinfo.request.height > 0 ? static_cast<uint8_t>(blockchain.get_network_version(hfinfo.request.height)) :
auto version =
hfinfo.request.version > 0 ? static_cast<hf>(hfinfo.request.version) :
hfinfo.request.height > 0 ? blockchain.get_network_version(hfinfo.request.height) :
blockchain.get_network_version();
hfinfo.response["version"] = version;
hfinfo.response["enabled"] = blockchain.get_network_version() >= version;
@ -2747,14 +2747,14 @@ namespace cryptonote::rpc {
std::string_view name,
std::atomic<std::time_t>& update,
std::chrono::seconds lifetime,
SuccessCallback success)
Success success)
{
std::string status{};
std::string our_ed25519_pubkey = tools::type_to_hex(core.get_service_keys().pub_ed25519);
if (cur_version < required) {
std::ostringstream os;
os << "Outdated " << name << ". Current: " << version_printer{cur_version} << " Required: " << version_printer{required};
status = os.str();
status = fmt::format("Outdated {}. Current: {}.{}.{} Required: {}.{}.{}", name,
cur_version[0], cur_version[1], cur_version[2],
required[0], required[1], required[2]);
MERROR(status);
} else if (!ed25519_pubkey.empty() // TODO: once lokinet & ss are always sending this we can remove this empty bypass
&& ed25519_pubkey != our_ed25519_pubkey) {
@ -2780,9 +2780,9 @@ namespace cryptonote::rpc {
void core_rpc_server::invoke(STORAGE_SERVER_PING& storage_server_ping, rpc_context context)
{
m_core.ss_version = storage_server_ping.request.version;
storage_server_ping.response["status"] = handle_ping(
storage_server_ping.response["status"] = handle_ping(m_core,
storage_server_ping.request.version, service_nodes::MIN_STORAGE_SERVER_VERSION,
req.ed25519_pubkey,
storage_server_ping.request.ed25519_pubkey,
"Storage Server", m_core.m_last_storage_server_ping, m_core.get_net_config().UPTIME_PROOF_FREQUENCY,
[this, &storage_server_ping](bool significant) {
m_core.m_storage_https_port = storage_server_ping.request.https_port;
@ -2795,9 +2795,9 @@ namespace cryptonote::rpc {
void core_rpc_server::invoke(LOKINET_PING& lokinet_ping, rpc_context context)
{
m_core.lokinet_version = lokinet_ping.request.version;
lokinet_ping.response["status"] = handle_ping(
lokinet_ping.response["status"] = handle_ping(m_core,
lokinet_ping.request.version, service_nodes::MIN_LOKINET_VERSION,
req.ed25519_pubkey,
lokinet_ping.request.ed25519_pubkey,
"Lokinet", m_core.m_last_lokinet_ping, m_core.get_net_config().UPTIME_PROOF_FREQUENCY,
[this](bool significant) { if (significant) m_core.reset_proof_interval(); });
}

View File

@ -240,12 +240,14 @@ namespace cryptonote::rpc {
void parse_request(LOKINET_PING& lokinet_ping, rpc_input in){
get_values(in, "version", lokinet_ping.request.version);
get_values(in, "ed25519_pubkey", lokinet_ping.request.ed25519_pubkey);
}
void parse_request(STORAGE_SERVER_PING& storage_server_ping, rpc_input in){
get_values(in, "version", storage_server_ping.request.version);
get_values(in, "https_port", storage_server_ping.request.https_port);
get_values(in, "omq_port", storage_server_ping.request.omq_port);
get_values(in, "ed25519_pubkey", storage_server_ping.request.ed25519_pubkey);
}
void parse_request(PRUNE_BLOCKCHAIN& prune_blockchain, rpc_input in){

View File

@ -77,7 +77,7 @@ void to_json(nlohmann::json& j, const block_header_response& h)
{"difficulty", h.difficulty},
{"cumulative_difficulty", h.cumulative_difficulty},
{"reward", h.reward},
{"miner_reward", h.miner_reward},
{"miner_reward", h.reward},
{"block_size", h.block_size},
{"block_weight", h.block_weight},
{"num_txes", h.num_txes},
@ -104,7 +104,7 @@ void from_json(const nlohmann::json& j, block_header_response& h)
j.at("difficulty").get_to(h.difficulty);
j.at("cumulative_difficulty").get_to(h.cumulative_difficulty);
j.at("reward").get_to(h.reward);
j.at("miner_reward").get_to(h.miner_reward);
j.at("miner_reward").get_to(h.reward);
j.at("block_size").get_to(h.block_size);
j.at("block_weight").get_to(h.block_weight);
j.at("num_txes").get_to(h.num_txes);

View File

@ -1873,6 +1873,7 @@ namespace cryptonote::rpc {
std::array<uint16_t, 3> version; // Storage server version
uint16_t https_port; // Storage server https port to include in uptime proofs
uint16_t omq_port; // Storage Server oxenmq port to include in uptime proofs
std::string ed25519_pubkey; // Service node Ed25519 pubkey for verifying that storage server is using the right one
} request;
};
@ -1895,6 +1896,7 @@ namespace cryptonote::rpc {
struct request_parameters
{
std::array<uint16_t, 3> version; // Lokinet version
std::string ed25519_pubkey; // Service node Ed25519 pubkey for verifying that lokinet is using the right one
} request;
};

View File

@ -420,7 +420,7 @@ void omq_rpc::on_get_blocks(oxenmq::Message& m)
block_bt["height"] = i;
block_bt["timestamp"] = b.timestamp;
std::vector<cryptonote::blobdata> txs;
std::vector<std::string> txs;
core_.get_transactions(b.tx_hashes, txs);
if (txs.size() != b.tx_hashes.size())
{

View File

@ -51,7 +51,7 @@ target_link_libraries(wallet
PUBLIC
multisig
rpc_commands
rpc_server_base
rpc_common
cryptonote_core
mnemonics
net
@ -74,7 +74,7 @@ oxen_add_executable(wallet_rpc_server "oxen-wallet-rpc"
target_link_libraries(wallet_rpc_server
PRIVATE
rpc_server_base
rpc_common
wallet
daemonizer
Boost::program_options

View File

@ -183,7 +183,7 @@ std::optional<cryptonote::hf> NodeRPCProxy::get_hardfork_version() const
try {
auto res = m_http_client.json_rpc("hard_fork_info", {});
return res["version"].get<uint8_t>();
return res["version"].get<cryptonote::hf>();
} catch (...) {}
return std::nullopt;

View File

@ -881,7 +881,14 @@ bool get_pruned_tx(const nlohmann::json& entry, cryptonote::transaction &tx, cry
// easy case if we have the whole tx
if (entry["as_hex"] || (entry["prunable"] && entry["pruned"]))
{
CHECK_AND_ASSERT_MES(oxenc::from_hex(entry["as_hex"] ? entry["as_hex"].get<std::string>() : entry["pruned"].get<std::string>() + entry["prunable"].get<std::string>(), bd), false, "Failed to parse tx data");
std::string hex_blob;
if (entry["as_hex"])
hex_blob = entry["as_hex"].get<std::string>();
else
hex_blob = entry["pruned"].get<std::string>() + entry["prunable"].get<std::string>();
CHECK_AND_ASSERT_MES(oxenc::is_hex(hex_blob), false, "Invalid tx data");
bd = oxenc::from_hex(hex_blob);
CHECK_AND_ASSERT_MES(cryptonote::parse_and_validate_tx_from_blob(bd, tx), false, "Invalid tx data");
tx_hash = cryptonote::get_transaction_hash(tx);
// if the hash was given, check it matches
@ -894,7 +901,8 @@ bool get_pruned_tx(const nlohmann::json& entry, cryptonote::transaction &tx, cry
{
crypto::hash ph;
CHECK_AND_ASSERT_MES(tools::hex_to_type(entry["prunable_hash"].get<std::string>(), ph), false, "Failed to parse prunable hash");
CHECK_AND_ASSERT_MES(oxenc::from_hex(entry["pruned"].get<std::string>(), bd), false, "Failed to parse pruned data");
CHECK_AND_ASSERT_MES(oxenc::is_hex(entry["pruned"].get<std::string>()), false, "Invalid pruned tx entry");
bd = oxenc::from_hex(entry["pruned"].get<std::string>());
CHECK_AND_ASSERT_MES(parse_and_validate_tx_base_from_blob(bd, tx), false, "Invalid base tx data");
// only v2 txes can calculate their txid after pruned
if (bd[0] > 1)
@ -8554,6 +8562,7 @@ wallet2::request_stake_unlock_result wallet2::can_request_stake_unlock(const cry
found = true;
contributions = contributor["locked_contributions"];
break;
}
if (!found)
@ -8595,15 +8604,15 @@ wallet2::request_stake_unlock_result wallet2::can_request_stake_unlock(const cry
return result;
}
if (contribution.amount < service_nodes::SMALL_CONTRIBUTOR_THRESHOLD && (curr_height - node_info.registration_height) < service_nodes::SMALL_CONTRIBUTOR_UNLOCK_TIMER)
if (contribution["amount"] < service_nodes::SMALL_CONTRIBUTOR_THRESHOLD && (curr_height - node_info["registration_height"].get<uint64_t>()) < service_nodes::SMALL_CONTRIBUTOR_UNLOCK_TIMER)
{
result.msg.append("You are requesting to unlock a stake of: ");
result.msg.append(cryptonote::print_money(contribution.amount));
result.msg.append(cryptonote::print_money(contribution["amount"]));
result.msg.append(" Oxen which is a small contributor stake.\nSmall contributors need to wait ");
result.msg.append(std::to_string(service_nodes::SMALL_CONTRIBUTOR_UNLOCK_TIMER));
result.msg.append(" blocks before being allowed to unlock.");
result.msg.append("You will need to wait: ");
result.msg.append(std::to_string(service_nodes::SMALL_CONTRIBUTOR_UNLOCK_TIMER - (curr_height - node_info.registration_height)));
result.msg.append(std::to_string(service_nodes::SMALL_CONTRIBUTOR_UNLOCK_TIMER - (curr_height - node_info["registration_height"].get<uint64_t>())));
result.msg.append(" more blocks.");
return result;
}
@ -12045,8 +12054,9 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
std::string tx_data;
crypto::hash tx_prefix_hash{};
const auto& res_tx = res["txs"].front();
bool valid_hex = oxenc::from_hex(res_tx["pruned"].get<std::string>() + (res_tx["prunable"] ? res_tx["prunable"].get<std::string>() : ""s), tx_data);
THROW_WALLET_EXCEPTION_IF(!valid_hex, error::wallet_internal_error, "Failed to parse transaction from daemon");
std::string tx_blob_hex = res_tx["pruned"].get<std::string>() + (res_tx["prunable"] ? res_tx["prunable"].get<std::string>() : ""s);
THROW_WALLET_EXCEPTION_IF(not oxenc::is_hex(tx_blob_hex), error::wallet_internal_error, "Failed to parse transaction from daemon");
tx_data = oxenc::from_hex(tx_blob_hex);
THROW_WALLET_EXCEPTION_IF(!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash),
error::wallet_internal_error, "Failed to validate transaction from daemon");
THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error,

View File

@ -1,12 +1,12 @@
#include "decoy_selection.hpp"
#include <cryptonote_config.h> // for ring size (CRYPTONOTE_DEFAULT_TX_MIXIN)
#include <cryptonote_config.h> // for ring size (cryptonote::TX_OUTPUT_DECOYS)
namespace wallet
{
std::vector<int64_t>
DecoySelector::operator()(const Output& selected_output)
{
const size_t n_decoys = CRYPTONOTE_DEFAULT_TX_MIXIN;
const size_t n_decoys = cryptonote::TX_OUTPUT_DECOYS;
// Select some random outputs according to gamma distribution
std::random_device rd;

View File

@ -84,8 +84,8 @@ namespace wallet
bool syncing = false;
int64_t max_sync_blocks = DEFAULT_MAX_SYNC_BLOCKS;
int64_t fee_per_byte = FEE_PER_BYTE_V13;
int64_t fee_per_output = FEE_PER_OUTPUT_V18;
int64_t fee_per_byte = cryptonote::FEE_PER_BYTE_V13;
int64_t fee_per_output = cryptonote::FEE_PER_OUTPUT_V18;
};
} // namespace wallet

View File

@ -14,7 +14,7 @@
namespace wallet
{
crypto::secret_key
Keyring::generate_tx_key(uint8_t hf_version)
Keyring::generate_tx_key(cryptonote::hf hf_version)
{
// TODO sean make sure this is zero
crypto::secret_key tx_key{};
@ -207,7 +207,7 @@ namespace wallet
void
Keyring::sign_transaction(PendingTransaction& ptx)
{
uint8_t hf_version = cryptonote::network_version_19;
auto hf_version = cryptonote::hf::hf19_reward_batching;
auto tx_key = generate_tx_key(hf_version);
rct::ctkeyV inSk;

View File

@ -29,7 +29,7 @@ namespace wallet
Keyring() {}
virtual crypto::secret_key
generate_tx_key(uint8_t hf_version);
generate_tx_key(cryptonote::hf hf_version);
// Derivation = a*R where
// `a` is the private view key of the recipient

View File

@ -59,9 +59,9 @@ namespace wallet
int64_t fixed_fee = 0;
// TODO sean add this
int64_t burn_pct = 0;
int64_t fee_percent = BLINK_BURN_TX_FEE_PERCENT_V18; // 100%
int64_t fee_percent = oxen::BLINK_BURN_TX_FEE_PERCENT_V18; // 100%
if (blink)
fee_percent = BLINK_MINER_TX_FEE_PERCENT + BLINK_BURN_TX_FEE_PERCENT_V18 + burn_pct; // Blink ends up being 300%
fee_percent = oxen::BLINK_MINER_TX_FEE_PERCENT + oxen::BLINK_BURN_TX_FEE_PERCENT_V18 + burn_pct; // Blink ends up being 300%
int64_t fee = (get_tx_weight(n_inputs) * fee_per_byte + (recipients.size() + 1) * fee_per_output) * fee_percent / 100;
// Add fixed amount to the fee for items such as burning. This is defined in the pending transactions

View File

@ -32,9 +32,9 @@ namespace wallet
uint64_t change_unlock_time = 0;
int64_t fee = 0;
uint64_t fee_per_byte = FEE_PER_BYTE_V13;
uint64_t fee_per_output = FEE_PER_OUTPUT_V18;
size_t mixin_count = CRYPTONOTE_DEFAULT_TX_MIXIN;
uint64_t fee_per_byte = cryptonote::FEE_PER_BYTE_V13;
uint64_t fee_per_output = cryptonote::FEE_PER_OUTPUT_V18;
size_t mixin_count = cryptonote::TX_OUTPUT_DECOYS;
size_t extra_size() const {return 0;};
PendingTransaction() = default;

View File

@ -1501,7 +1501,7 @@ namespace wallet::rpc {
bool coinbase = false;
bool filter_by_height = false;
uint64_t min_height = 0;
uint64_t max_height = CRYPTONOTE_MAX_BLOCK_NUMBER;
uint64_t max_height = cryptonote::MAX_BLOCK_NUMBER;
std::set<uint32_t> subaddr_indices;
uint32_t account_index;
bool all_accounts;

View File

@ -34,8 +34,8 @@ namespace wallet
PendingTransaction
create_transaction(const std::vector<cryptonote::tx_destination_entry>& recipients);
uint64_t fee_per_byte = FEE_PER_BYTE_V13;
uint64_t fee_per_output = FEE_PER_OUTPUT_V18;
uint64_t fee_per_byte = cryptonote::FEE_PER_BYTE_V13;
uint64_t fee_per_output = cryptonote::FEE_PER_OUTPUT_V18;
std::unique_ptr<DecoySelector> decoy_selector;

View File

@ -105,7 +105,7 @@ namespace wallet
wallet::rpc::OmqServer omq_server;
bool running = true;
cryptonote::network_type nettype = cryptonote::TESTNET;
cryptonote::network_type nettype = cryptonote::network_type::TESTNET;
};
} // namespace wallet