Merge xmrig v6.15.0 into master
This commit is contained in:
commit
29fa5c61e0
258 changed files with 13719 additions and 8163 deletions
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/stratum/AutoClient.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
@ -32,7 +31,7 @@ xmrig::AutoClient::AutoClient(int id, const char *agent, IClientListener *listen
|
|||
bool xmrig::AutoClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||
{
|
||||
if (m_mode == DEFAULT_MODE) {
|
||||
return Client::handleResponse(id, result, error);
|
||||
return Client::handleResponse(id, result, error); // NOLINT(bugprone-parent-virtual-call)
|
||||
}
|
||||
|
||||
return EthStratumClient::handleResponse(id, result, error);
|
||||
|
@ -74,7 +73,7 @@ bool xmrig::AutoClient::parseLogin(const rapidjson::Value &result, int *code)
|
|||
int64_t xmrig::AutoClient::submit(const JobResult &result)
|
||||
{
|
||||
if (result.algorithm.family() != Algorithm::KAWPOW) {
|
||||
return Client::submit(result);
|
||||
return Client::submit(result); // NOLINT(bugprone-parent-virtual-call)
|
||||
}
|
||||
|
||||
return EthStratumClient::submit(result);
|
||||
|
@ -85,7 +84,7 @@ void xmrig::AutoClient::parseNotification(const char *method, const rapidjson::V
|
|||
{
|
||||
if (strcmp(method, "job") == 0) {
|
||||
m_mode = DEFAULT_MODE;
|
||||
return Client::parseNotification(method, params, error);
|
||||
return Client::parseNotification(method, params, error); // NOLINT(bugprone-parent-virtual-call)
|
||||
}
|
||||
|
||||
m_mode = ETH_MODE;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/stratum/BaseClient.h"
|
||||
#include "3rdparty/fmt/core.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/Env.h"
|
||||
#include "base/io/log/Log.h"
|
||||
|
@ -58,7 +52,7 @@ void xmrig::BaseClient::setPool(const Pool &pool)
|
|||
m_user = Env::expand(pool.user());
|
||||
m_password = Env::expand(pool.password());
|
||||
m_rigId = Env::expand(pool.rigId());
|
||||
m_tag = std::string(Tags::network()) + " " CYAN_BOLD_S + m_pool.url().data() + CLEAR;
|
||||
m_tag = fmt::format("{} " CYAN_BOLD("{}"), Tags::network(), m_pool.url().data());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -351,32 +351,6 @@ bool xmrig::Client::close()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Client::isCriticalError(const char *message)
|
||||
{
|
||||
if (!message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Unauthenticated", 15) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "your IP is banned", 17) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "IP Address currently banned", 27) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Invalid job id", 14) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
{
|
||||
if (!params.IsObject()) {
|
||||
|
@ -467,7 +441,7 @@ bool xmrig::Client::send(BIO *bio)
|
|||
{
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
uv_buf_t buf;
|
||||
buf.len = BIO_get_mem_data(bio, &buf.base);
|
||||
buf.len = BIO_get_mem_data(bio, &buf.base); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
|
||||
if (buf.len == 0) {
|
||||
return true;
|
||||
|
@ -961,6 +935,32 @@ void xmrig::Client::startTimeout()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Client::isCriticalError(const char *message)
|
||||
{
|
||||
if (!message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Unauthenticated", 15) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "your IP is banned", 17) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "IP Address currently banned", 27) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Invalid job id", 14) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::onClose(uv_handle_t *handle)
|
||||
{
|
||||
auto client = getClient(handle->data);
|
||||
|
|
|
@ -96,7 +96,6 @@ private:
|
|||
class Socks5;
|
||||
class Tls;
|
||||
|
||||
bool isCriticalError(const char *message);
|
||||
bool parseJob(const rapidjson::Value ¶ms, int *code);
|
||||
bool send(BIO *bio);
|
||||
bool verifyAlgorithm(const Algorithm &algorithm, const char *algo) const;
|
||||
|
@ -119,6 +118,7 @@ private:
|
|||
inline void setExtension(Extension ext, bool enable) noexcept { m_extensions.set(ext, enable); }
|
||||
template<Extension ext> inline bool has() const noexcept { return m_extensions.test(ext); }
|
||||
|
||||
static bool isCriticalError(const char *message);
|
||||
static void onClose(uv_handle_t *handle);
|
||||
static void onConnect(uv_connect_t *req, int status);
|
||||
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/net/stratum/DaemonClient.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "3rdparty/rapidjson/error/en.h"
|
||||
|
@ -42,7 +45,6 @@
|
|||
#include "base/tools/Cvt.h"
|
||||
#include "base/tools/Timer.h"
|
||||
#include "base/tools/cryptonote/Signatures.h"
|
||||
#include "base/tools/cryptonote/WalletAddress.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
||||
|
@ -71,7 +73,7 @@ static constexpr size_t kZMQGreetingSize1 = 11;
|
|||
static const char kZMQHandshake[] = "\4\x19\5READY\xbSocket-Type\0\0\0\3SUB";
|
||||
static const char kZMQSubscribe[] = "\0\x18\1json-minimal-chain_main";
|
||||
|
||||
}
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::DaemonClient::DaemonClient(int id, IClientListener *listener) :
|
||||
|
@ -135,21 +137,21 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
|
|||
|
||||
memcpy(data + m_job.nonceOffset() * 2, result.nonce, 8);
|
||||
|
||||
if (m_blocktemplate.has_miner_signature && result.sig) {
|
||||
if (m_blocktemplate.hasMinerSignature() && result.sig) {
|
||||
memcpy(data + sig_offset * 2, result.sig, 64 * 2);
|
||||
memcpy(data + m_blocktemplate.tx_pubkey_index * 2, result.sig_data, 32 * 2);
|
||||
memcpy(data + m_blocktemplate.eph_public_key_index * 2, result.sig_data + 32 * 2, 32 * 2);
|
||||
memcpy(data + m_blocktemplate.offset(BlockTemplate::TX_PUBKEY_OFFSET) * 2, result.sig_data, 32 * 2);
|
||||
memcpy(data + m_blocktemplate.offset(BlockTemplate::EPH_PUBLIC_KEY_OFFSET) * 2, result.sig_data + 32 * 2, 32 * 2);
|
||||
}
|
||||
|
||||
if (result.extra_nonce >= 0) {
|
||||
Cvt::toHex(data + m_blocktemplate.tx_extra_nonce_index * 2, 8, reinterpret_cast<const uint8_t*>(&result.extra_nonce), 4);
|
||||
Cvt::toHex(data + m_blocktemplate.offset(BlockTemplate::TX_EXTRA_NONCE_OFFSET) * 2, 8, reinterpret_cast<const uint8_t*>(&result.extra_nonce), 4);
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
Cvt::toHex(data + m_job.nonceOffset() * 2, 8, reinterpret_cast<const uint8_t*>(&result.nonce), 4);
|
||||
|
||||
if (m_blocktemplate.has_miner_signature) {
|
||||
if (m_blocktemplate.hasMinerSignature()) {
|
||||
Cvt::toHex(data + sig_offset * 2, 128, result.minerSignature(), 64);
|
||||
}
|
||||
|
||||
|
@ -181,12 +183,28 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
|
|||
|
||||
void xmrig::DaemonClient::connect()
|
||||
{
|
||||
if ((m_pool.algorithm() == Algorithm::ASTROBWT_DERO) || (m_pool.coin() == Coin::DERO)) {
|
||||
m_apiVersion = API_DERO;
|
||||
}
|
||||
auto connectError = [this](const char *message) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("connect error: ") RED_BOLD("\"%s\""), tag(), message);
|
||||
}
|
||||
|
||||
retry();
|
||||
};
|
||||
|
||||
setState(ConnectingState);
|
||||
|
||||
if (!m_walletAddress.isValid()) {
|
||||
return connectError("Invalid wallet address.");
|
||||
}
|
||||
|
||||
if (!m_coin.isValid() && !m_pool.algorithm().isValid()) {
|
||||
return connectError("Invalid algorithm.");
|
||||
}
|
||||
|
||||
if ((m_pool.algorithm() == Algorithm::ASTROBWT_DERO) || (m_coin == Coin::DERO)) {
|
||||
m_apiVersion = API_DERO;
|
||||
}
|
||||
|
||||
if (m_pool.zmq_port() >= 0) {
|
||||
m_dns = Dns::resolve(m_pool.host(), this);
|
||||
}
|
||||
|
@ -203,6 +221,20 @@ void xmrig::DaemonClient::connect(const Pool &pool)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::DaemonClient::setPool(const Pool &pool)
|
||||
{
|
||||
BaseClient::setPool(pool);
|
||||
|
||||
m_walletAddress.decode(m_user);
|
||||
|
||||
m_coin = pool.coin().isValid() ? pool.coin() : m_walletAddress.coin();
|
||||
|
||||
if (!m_coin.isValid() && pool.algorithm() == Algorithm::RX_WOW) {
|
||||
m_coin = Coin::WOWNERO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DaemonClient::onHttpData(const HttpData &data)
|
||||
{
|
||||
if (data.status != 200) {
|
||||
|
@ -219,7 +251,7 @@ void xmrig::DaemonClient::onHttpData(const HttpData &data)
|
|||
rapidjson::Document doc;
|
||||
if (doc.Parse(data.body.c_str()).HasParseError()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s:%d] JSON decode failed: \"%s\"", m_pool.host().data(), m_pool.port(), rapidjson::GetParseError_En(doc.GetParseError()));
|
||||
LOG_ERR("%s " RED("JSON decode failed: ") RED_BOLD("\"%s\""), tag(), rapidjson::GetParseError_En(doc.GetParseError()));
|
||||
}
|
||||
|
||||
return retry();
|
||||
|
@ -284,7 +316,7 @@ void xmrig::DaemonClient::onTimer(const Timer *)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::DaemonClient::onResolved(const DnsRecords& records, int status, const char* error)
|
||||
void xmrig::DaemonClient::onResolved(const DnsRecords &records, int status, const char* error)
|
||||
{
|
||||
m_dns.reset();
|
||||
|
||||
|
@ -297,14 +329,14 @@ void xmrig::DaemonClient::onResolved(const DnsRecords& records, int status, cons
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_ZMQSocket) {
|
||||
delete m_ZMQSocket;
|
||||
}
|
||||
|
||||
const auto& record = records.get();
|
||||
delete m_ZMQSocket;
|
||||
|
||||
|
||||
const auto &record = records.get();
|
||||
m_ip = record.ip();
|
||||
|
||||
uv_connect_t* req = new uv_connect_t;
|
||||
auto req = new uv_connect_t;
|
||||
req->data = m_storage.ptr(m_key);
|
||||
|
||||
m_ZMQSocket = new uv_tcp_t;
|
||||
|
@ -329,68 +361,60 @@ bool xmrig::DaemonClient::isOutdated(uint64_t height, const char *hash) const
|
|||
|
||||
bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
{
|
||||
auto jobError = [this, code](const char *message) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("job error: ") RED_BOLD("\"%s\""), tag(), message);
|
||||
}
|
||||
|
||||
*code = 1;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
Job job(false, m_pool.algorithm(), String());
|
||||
|
||||
String blocktemplate = Json::getString(params, kBlocktemplateBlob);
|
||||
|
||||
if (blocktemplate.isNull()) {
|
||||
LOG_ERR("Empty block template received from daemon");
|
||||
*code = 1;
|
||||
return false;
|
||||
return jobError("Empty block template received from daemon."); // FIXME
|
||||
}
|
||||
|
||||
Coin pool_coin = m_pool.coin();
|
||||
|
||||
if (!pool_coin.isValid() && (m_pool.algorithm() == Algorithm::RX_WOW)) {
|
||||
pool_coin = Coin::WOWNERO;
|
||||
}
|
||||
|
||||
if (!m_blocktemplate.Init(blocktemplate, pool_coin)) {
|
||||
LOG_ERR("Invalid block template received from daemon");
|
||||
*code = 2;
|
||||
return false;
|
||||
if (!m_blocktemplate.parse(blocktemplate, m_coin)) {
|
||||
return jobError("Invalid block template received from daemon.");
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
const size_t k = m_blocktemplate.miner_tx_prefix_begin_index;
|
||||
const size_t k = m_blocktemplate.offset(BlockTemplate::MINER_TX_PREFIX_OFFSET);
|
||||
job.setMinerTx(
|
||||
m_blocktemplate.raw_blob.data() + k,
|
||||
m_blocktemplate.raw_blob.data() + m_blocktemplate.miner_tx_prefix_end_index,
|
||||
m_blocktemplate.eph_public_key_index - k,
|
||||
m_blocktemplate.tx_pubkey_index - k,
|
||||
m_blocktemplate.tx_extra_nonce_index - k,
|
||||
m_blocktemplate.tx_extra_nonce_size,
|
||||
m_blocktemplate.miner_tx_merkle_tree_branch
|
||||
m_blocktemplate.blob() + k,
|
||||
m_blocktemplate.blob() + m_blocktemplate.offset(BlockTemplate::MINER_TX_PREFIX_END_OFFSET),
|
||||
m_blocktemplate.offset(BlockTemplate::EPH_PUBLIC_KEY_OFFSET) - k,
|
||||
m_blocktemplate.offset(BlockTemplate::TX_PUBKEY_OFFSET) - k,
|
||||
m_blocktemplate.offset(BlockTemplate::TX_EXTRA_NONCE_OFFSET) - k,
|
||||
m_blocktemplate.txExtraNonce().size(),
|
||||
m_blocktemplate.minerTxMerkleTreeBranch()
|
||||
);
|
||||
# endif
|
||||
|
||||
m_blockhashingblob = Json::getString(params, "blockhashing_blob");
|
||||
|
||||
if (m_blocktemplate.has_miner_signature) {
|
||||
if (m_blocktemplate.hasMinerSignature()) {
|
||||
if (m_pool.spendSecretKey().isEmpty()) {
|
||||
LOG_ERR("Secret spend key is not set");
|
||||
*code = 4;
|
||||
return false;
|
||||
return jobError("Secret spend key is not set.");
|
||||
}
|
||||
|
||||
if (m_pool.spendSecretKey().size() != 64) {
|
||||
LOG_ERR("Secret spend key has invalid length. It must be 64 hex characters.");
|
||||
*code = 5;
|
||||
return false;
|
||||
return jobError("Secret spend key has invalid length. It must be 64 hex characters.");
|
||||
}
|
||||
|
||||
uint8_t secret_spendkey[32];
|
||||
if (!Cvt::fromHex(secret_spendkey, 32, m_pool.spendSecretKey(), 64)) {
|
||||
LOG_ERR("Secret spend key is not a valid hex data.");
|
||||
*code = 6;
|
||||
return false;
|
||||
return jobError("Secret spend key is not a valid hex data.");
|
||||
}
|
||||
|
||||
uint8_t public_spendkey[32];
|
||||
if (!secret_key_to_public_key(secret_spendkey, public_spendkey)) {
|
||||
LOG_ERR("Secret spend key is invalid.");
|
||||
*code = 7;
|
||||
return false;
|
||||
return jobError("Secret spend key is invalid.");
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
|
@ -401,41 +425,30 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
|
||||
uint8_t public_viewkey[32];
|
||||
if (!secret_key_to_public_key(secret_viewkey, public_viewkey)) {
|
||||
LOG_ERR("Secret view key is invalid.");
|
||||
*code = 8;
|
||||
return false;
|
||||
return jobError("Secret view key is invalid.");
|
||||
}
|
||||
|
||||
uint8_t derivation[32];
|
||||
if (!generate_key_derivation(m_blocktemplate.raw_blob.data() + m_blocktemplate.tx_pubkey_index, secret_viewkey, derivation)) {
|
||||
LOG_ERR("Failed to generate key derivation for miner signature.");
|
||||
*code = 9;
|
||||
return false;
|
||||
if (!generate_key_derivation(m_blocktemplate.blob(BlockTemplate::TX_PUBKEY_OFFSET), secret_viewkey, derivation)) {
|
||||
return jobError("Failed to generate key derivation for miner signature.");
|
||||
}
|
||||
|
||||
WalletAddress user_address;
|
||||
if (!user_address.Decode(m_pool.user())) {
|
||||
LOG_ERR("Invalid wallet address.");
|
||||
*code = 10;
|
||||
return false;
|
||||
if (!m_walletAddress.decode(m_pool.user())) {
|
||||
return jobError("Invalid wallet address.");
|
||||
}
|
||||
|
||||
if (memcmp(user_address.public_spend_key, public_spendkey, sizeof(public_spendkey)) != 0) {
|
||||
LOG_ERR("Wallet address and spend key don't match.");
|
||||
*code = 11;
|
||||
return false;
|
||||
if (memcmp(m_walletAddress.spendKey(), public_spendkey, sizeof(public_spendkey)) != 0) {
|
||||
return jobError("Wallet address and spend key don't match.");
|
||||
}
|
||||
|
||||
if (memcmp(user_address.public_view_key, public_viewkey, sizeof(public_viewkey)) != 0) {
|
||||
LOG_ERR("Wallet address and view key don't match.");
|
||||
*code = 12;
|
||||
return false;
|
||||
if (memcmp(m_walletAddress.viewKey(), public_viewkey, sizeof(public_viewkey)) != 0) {
|
||||
return jobError("Wallet address and view key don't match.");
|
||||
}
|
||||
|
||||
uint8_t eph_secret_key[32];
|
||||
derive_secret_key(derivation, 0, secret_spendkey, eph_secret_key);
|
||||
|
||||
job.setEphemeralKeys(m_blocktemplate.raw_blob.data() + m_blocktemplate.eph_public_key_index, eph_secret_key);
|
||||
job.setEphemeralKeys(m_blocktemplate.blob(BlockTemplate::EPH_PUBLIC_KEY_OFFSET), eph_secret_key);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -444,8 +457,8 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize);
|
||||
}
|
||||
|
||||
if (pool_coin.isValid()) {
|
||||
job.setAlgorithm(pool_coin.algorithm(m_blocktemplate.major_version));
|
||||
if (m_coin.isValid()) {
|
||||
job.setAlgorithm(m_coin.algorithm(m_blocktemplate.majorVersion()));
|
||||
}
|
||||
|
||||
if (!job.setBlob(m_blockhashingblob)) {
|
||||
|
@ -594,7 +607,6 @@ void xmrig::DaemonClient::send(const char *path)
|
|||
|
||||
void xmrig::DaemonClient::setState(SocketState state)
|
||||
{
|
||||
assert(m_state != state);
|
||||
if (m_state == state) {
|
||||
return;
|
||||
}
|
||||
|
@ -735,10 +747,9 @@ void xmrig::DaemonClient::ZMQRead(ssize_t nread, const uv_buf_t* buf)
|
|||
m_ZMQConnectionState = ZMQ_GREETING_2;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
LOG_ERR("%s " RED("ZMQ handshake failed: invalid greeting format"), tag());
|
||||
ZMQClose();
|
||||
}
|
||||
|
||||
LOG_ERR("%s " RED("ZMQ handshake failed: invalid greeting format"), tag());
|
||||
ZMQClose();
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -751,10 +762,10 @@ void xmrig::DaemonClient::ZMQRead(ssize_t nread, const uv_buf_t* buf)
|
|||
ZMQWrite(kZMQHandshake, sizeof(kZMQHandshake) - 1);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
LOG_ERR("%s " RED("ZMQ handshake failed: invalid greeting format 2"), tag());
|
||||
ZMQClose();
|
||||
}
|
||||
|
||||
LOG_ERR("%s " RED("ZMQ handshake failed: invalid greeting format 2"), tag());
|
||||
ZMQClose();
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -812,9 +823,9 @@ void xmrig::DaemonClient::ZMQParse()
|
|||
|
||||
size_t msg_size = 0;
|
||||
|
||||
char* data = m_ZMQRecvBuf.data();
|
||||
char *data = m_ZMQRecvBuf.data();
|
||||
size_t avail = m_ZMQRecvBuf.size();
|
||||
bool more;
|
||||
bool more = false;
|
||||
|
||||
do {
|
||||
if (avail < 1) {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,21 +21,25 @@
|
|||
#define XMRIG_DAEMONCLIENT_H
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IDnsListener.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
#include "base/net/stratum/BaseClient.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/tools/cryptonote/BlockTemplate.h"
|
||||
#include "base/net/tools/Storage.h"
|
||||
#include "base/tools/cryptonote/BlockTemplate.h"
|
||||
#include "base/tools/cryptonote/WalletAddress.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
using uv_buf_t = struct uv_buf_t;
|
||||
using uv_connect_t = struct uv_connect_s;
|
||||
using uv_handle_t = struct uv_handle_s;
|
||||
using uv_stream_t = struct uv_stream_s;
|
||||
using uv_tcp_t = struct uv_tcp_s;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -62,10 +60,11 @@ protected:
|
|||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void connect(const Pool &pool) override;
|
||||
void setPool(const Pool &pool) override;
|
||||
|
||||
void onHttpData(const HttpData &data) override;
|
||||
void onTimer(const Timer *timer) override;
|
||||
void onResolved(const DnsRecords& records, int status, const char* error) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char* error) override;
|
||||
|
||||
inline bool hasExtension(Extension) const noexcept override { return false; }
|
||||
inline const char *mode() const override { return "daemon"; }
|
||||
|
@ -92,18 +91,19 @@ private:
|
|||
API_DERO,
|
||||
} m_apiVersion = API_MONERO;
|
||||
|
||||
BlockTemplate m_blocktemplate;
|
||||
Coin m_coin;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
String m_currentJobId;
|
||||
String m_blocktemplateStr;
|
||||
String m_blockhashingblob;
|
||||
String m_blocktemplateRequestHash;
|
||||
String m_blocktemplateStr;
|
||||
String m_currentJobId;
|
||||
String m_prevHash;
|
||||
String m_tlsFingerprint;
|
||||
String m_tlsVersion;
|
||||
Timer *m_timer;
|
||||
uint64_t m_blocktemplateRequestHeight = 0;
|
||||
String m_blocktemplateRequestHash;
|
||||
|
||||
BlockTemplate m_blocktemplate;
|
||||
WalletAddress m_walletAddress;
|
||||
|
||||
private:
|
||||
static inline DaemonClient* getClient(void* data) { return m_storage.get(data); }
|
||||
|
|
|
@ -272,7 +272,7 @@ void xmrig::EthStratumClient::setExtraNonce(const rapidjson::Value &nonce)
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::EthStratumClient::errorMessage(const rapidjson::Value &error) const
|
||||
const char *xmrig::EthStratumClient::errorMessage(const rapidjson::Value &error)
|
||||
{
|
||||
if (error.IsArray() && error.GetArray().Size() > 1) {
|
||||
auto &value = error.GetArray()[1];
|
||||
|
|
|
@ -48,7 +48,8 @@ protected:
|
|||
void setExtraNonce(const rapidjson::Value &nonce);
|
||||
|
||||
private:
|
||||
const char *errorMessage(const rapidjson::Value &error) const;
|
||||
static const char *errorMessage(const rapidjson::Value &error);
|
||||
|
||||
void authorize();
|
||||
void onAuthorizeResponse(const rapidjson::Value &result, bool success, uint64_t elapsed);
|
||||
void onSubscribeResponse(const rapidjson::Value &result, bool success, uint64_t elapsed);
|
||||
|
|
|
@ -352,16 +352,16 @@ void xmrig::Job::generateHashingBlob(String &blob) const
|
|||
{
|
||||
uint8_t root_hash[32];
|
||||
const uint8_t* p = m_minerTxPrefix.data();
|
||||
BlockTemplate::CalculateRootHash(p, p + m_minerTxPrefix.size(), m_minerTxMerkleTreeBranch, root_hash);
|
||||
BlockTemplate::calculateRootHash(p, p + m_minerTxPrefix.size(), m_minerTxMerkleTreeBranch, root_hash);
|
||||
|
||||
uint64_t root_hash_offset = nonceOffset() + nonceSize();
|
||||
|
||||
if (m_hasMinerSignature) {
|
||||
root_hash_offset += BlockTemplate::SIGNATURE_SIZE + 2 /* vote */;
|
||||
root_hash_offset += BlockTemplate::kSignatureSize + 2 /* vote */;
|
||||
}
|
||||
|
||||
blob = rawBlob();
|
||||
Cvt::toHex(blob.data() + root_hash_offset * 2, 64, root_hash, BlockTemplate::HASH_SIZE);
|
||||
Cvt::toHex(blob.data() + root_hash_offset * 2, 64, root_hash, BlockTemplate::kHashSize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -374,7 +374,7 @@ void xmrig::Job::generateMinerSignature(const uint8_t* blob, size_t size, uint8_
|
|||
memcpy(tmp, blob, size);
|
||||
|
||||
// Fill signature with zeros
|
||||
memset(tmp + nonceOffset() + nonceSize(), 0, BlockTemplate::SIGNATURE_SIZE);
|
||||
memset(tmp + nonceOffset() + nonceSize(), 0, BlockTemplate::kSignatureSize);
|
||||
|
||||
uint8_t prefix_hash[32];
|
||||
xmrig::keccak(tmp, static_cast<int>(size), prefix_hash, sizeof(prefix_hash));
|
||||
|
|
|
@ -82,7 +82,7 @@ const char *Pool::kSpendSecretKey = "spend-secret-key";
|
|||
const char *Pool::kNicehashHost = "nicehash.com";
|
||||
|
||||
|
||||
}
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Pool::Pool(const char *url) :
|
||||
|
@ -190,10 +190,6 @@ bool xmrig::Pool::isEnabled() const
|
|||
}
|
||||
# endif
|
||||
|
||||
if (m_mode == MODE_DAEMON && (!algorithm().isValid() && !coin().isValid())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_flags.test(FLAG_ENABLED) && isValid();
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,9 @@ void xmrig::Pools::setProxyDonate(int value)
|
|||
case PROXY_DONATE_AUTO:
|
||||
case PROXY_DONATE_ALWAYS:
|
||||
m_proxyDonate = static_cast<ProxyDonate>(value);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ void xmrig::Client::Socks5::handshake()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr) const
|
||||
bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr)
|
||||
{
|
||||
return uv_ip4_addr(host.data(), 0, reinterpret_cast<sockaddr_in *>(addr)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr) const
|
||||
bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr)
|
||||
{
|
||||
return uv_ip6_addr(host.data(), 0, reinterpret_cast<sockaddr_in6 *>(addr)) == 0;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,9 @@ private:
|
|||
Ready
|
||||
};
|
||||
|
||||
bool isIPv4(const String &host, sockaddr_storage *addr) const;
|
||||
bool isIPv6(const String &host, sockaddr_storage *addr) const;
|
||||
static bool isIPv4(const String &host, sockaddr_storage *addr);
|
||||
static bool isIPv6(const String &host, sockaddr_storage *addr);
|
||||
|
||||
void connect();
|
||||
|
||||
Client *m_client;
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,7 +17,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/stratum/Tls.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
|
@ -177,7 +170,7 @@ bool xmrig::Client::Tls::verifyFingerprint(X509 *cert)
|
|||
}
|
||||
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
unsigned int dlen;
|
||||
unsigned int dlen = 0;
|
||||
|
||||
if (X509_digest(cert, digest, md, &dlen) != 1) {
|
||||
return false;
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,7 +16,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/stratum/Url.h"
|
||||
|
||||
|
||||
|
@ -49,7 +41,7 @@ static const char kDaemonHttp[] = "daemon+http://";
|
|||
static const char kDaemonHttps[] = "daemon+https://";
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Url::Url(const char *url)
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -249,7 +249,7 @@ uint64_t xmrig::BenchClient::referenceHash() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::printExit()
|
||||
void xmrig::BenchClient::printExit() const
|
||||
{
|
||||
LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), tag());
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
|
||||
bool setSeed(const char *seed);
|
||||
uint64_t referenceHash() const;
|
||||
void printExit();
|
||||
void printExit() const;
|
||||
void start();
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue