Added support for solo mining with miner signatures (Wownero)
This commit is contained in:
parent
29f2dd4b9e
commit
a136790bee
20 changed files with 200 additions and 41 deletions
|
@ -28,7 +28,7 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
bool CBlockTemplate::Init(const String& blockTemplate)
|
||||
bool BlockTemplate::Init(const String& blockTemplate, Coin coin)
|
||||
{
|
||||
raw_blob = Cvt::fromHex(blockTemplate);
|
||||
|
||||
|
@ -41,6 +41,12 @@ bool CBlockTemplate::Init(const String& blockTemplate)
|
|||
ar(prev_id);
|
||||
ar(nonce);
|
||||
|
||||
// Wownero block template has miner signature starting from version 19
|
||||
has_miner_signature = (coin == Coin::WOWNERO) && (major_version >= 19);
|
||||
if (has_miner_signature) {
|
||||
ar(miner_signature);
|
||||
}
|
||||
|
||||
// Miner transaction begin
|
||||
// Prefix begin
|
||||
miner_tx_prefix_begin_index = ar.index();
|
||||
|
@ -108,7 +114,7 @@ bool CBlockTemplate::Init(const String& blockTemplate)
|
|||
ar(num_hashes);
|
||||
|
||||
hashes.resize((num_hashes + 1) * HASH_SIZE);
|
||||
CalculateMinerTxHash(hashes.data());
|
||||
//CalculateMinerTxHash(hashes.data());
|
||||
|
||||
for (uint64_t i = 1; i <= num_hashes; ++i) {
|
||||
uint8_t h[HASH_SIZE];
|
||||
|
@ -116,14 +122,14 @@ bool CBlockTemplate::Init(const String& blockTemplate)
|
|||
memcpy(hashes.data() + i * HASH_SIZE, h, HASH_SIZE);
|
||||
}
|
||||
|
||||
CalculateMerkleTreeHash(hashes.data(), num_hashes + 1, root_hash);
|
||||
CalculateHashingBlob();
|
||||
//CalculateMerkleTreeHash(hashes.data(), num_hashes + 1, root_hash);
|
||||
//CalculateHashingBlob();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CBlockTemplate::CalculateMinerTxHash(uint8_t* hash)
|
||||
void BlockTemplate::CalculateMinerTxHash(uint8_t* hash)
|
||||
{
|
||||
uint8_t hashes[HASH_SIZE * 3];
|
||||
|
||||
|
@ -147,7 +153,7 @@ void CBlockTemplate::CalculateMinerTxHash(uint8_t* hash)
|
|||
|
||||
|
||||
|
||||
void CBlockTemplate::CalculateMerkleTreeHash(const uint8_t* hashes, size_t count, uint8_t* root_hash)
|
||||
void BlockTemplate::CalculateMerkleTreeHash(const uint8_t* hashes, size_t count, uint8_t* root_hash)
|
||||
{
|
||||
if (count == 1) {
|
||||
memcpy(root_hash, hashes, HASH_SIZE);
|
||||
|
@ -180,7 +186,7 @@ void CBlockTemplate::CalculateMerkleTreeHash(const uint8_t* hashes, size_t count
|
|||
}
|
||||
|
||||
|
||||
void CBlockTemplate::CalculateHashingBlob()
|
||||
void BlockTemplate::CalculateHashingBlob()
|
||||
{
|
||||
hashingBlob.clear();
|
||||
hashingBlob.reserve(miner_tx_prefix_begin_index + HASH_SIZE + 3);
|
||||
|
@ -194,9 +200,6 @@ void CBlockTemplate::CalculateHashingBlob()
|
|||
k >>= 7;
|
||||
}
|
||||
hashingBlob.emplace_back(static_cast<uint8_t>(k));
|
||||
|
||||
for (int i = 0; i < hashingBlob.size(); ++i)
|
||||
printf("%02x", hashingBlob[i]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define XMRIG_BLOCKTEMPLATE_H
|
||||
|
||||
|
||||
#include "base/crypto/Coin.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
@ -29,11 +30,12 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
struct CBlockTemplate
|
||||
struct BlockTemplate
|
||||
{
|
||||
enum {
|
||||
HASH_SIZE = 32,
|
||||
KEY_SIZE = 32,
|
||||
SIGNATURE_SIZE = 64,
|
||||
NONCE_SIZE = 4,
|
||||
};
|
||||
|
||||
|
@ -50,6 +52,9 @@ struct CBlockTemplate
|
|||
uint8_t prev_id[HASH_SIZE];
|
||||
uint8_t nonce[NONCE_SIZE];
|
||||
|
||||
bool has_miner_signature;
|
||||
uint8_t miner_signature[SIGNATURE_SIZE];
|
||||
|
||||
// Miner tx
|
||||
uint64_t tx_version;
|
||||
uint64_t unlock_time;
|
||||
|
@ -72,7 +77,7 @@ struct CBlockTemplate
|
|||
|
||||
Buffer hashingBlob;
|
||||
|
||||
bool Init(const String& blockTemplate);
|
||||
bool Init(const String& blockTemplate, Coin coin);
|
||||
|
||||
private:
|
||||
void CalculateMinerTxHash(uint8_t* hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue