Added support for mining to a subaddress
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
### P2Pool command line options
|
||||
|
||||
```
|
||||
--wallet Wallet address to mine to. Subaddresses and integrated addresses are not supported!
|
||||
--wallet Main wallet address (the one that starts with 4...). To mine to a subaddress of this wallet, use it together with --subaddress
|
||||
--subaddress Subaddress to mine to. It must belong to the same wallet that was specified with --wallet parameter
|
||||
--host IP address of your Monero node, default is 127.0.0.1
|
||||
--rpc-port monerod RPC API port number, default is 18081
|
||||
--zmq-port monerod ZMQ pub port number, default is 18083 (same port as in monerod's "--zmq-pub" command line parameter)
|
||||
|
||||
@@ -60,7 +60,8 @@ void p2pool_usage()
|
||||
{
|
||||
printf("P2Pool %s\n"
|
||||
"\nUsage:\n\n" \
|
||||
"--wallet Wallet address to mine to. Subaddresses and integrated addresses are not supported!\n"
|
||||
"--wallet Main wallet address (the one that starts with 4...). To mine to a subaddress of this wallet, use it together with --subaddress\n"
|
||||
"--subaddress Subaddress to mine to. It must belong to the same wallet that was specified with --wallet parameter\n"
|
||||
"--host IP address of your Monero node, default is 127.0.0.1\n"
|
||||
"--rpc-port monerod RPC API port number, default is 18081\n"
|
||||
"--zmq-port monerod ZMQ pub port number, default is 18083 (same port as in monerod's \"--zmq-pub\" command line parameter)\n"
|
||||
|
||||
@@ -121,7 +121,7 @@ void Miner::on_block(const BlockTemplate& block)
|
||||
m_totalHashes += hash_count;
|
||||
|
||||
if (m_pool->api() && m_pool->params().m_localStats && !m_pool->stopped()) {
|
||||
const double block_reward_share_percent = m_pool->side_chain().get_reward_share(m_pool->params().m_wallet) * 100.0;
|
||||
const double block_reward_share_percent = m_pool->side_chain().get_reward_share(m_pool->params().m_miningWallet) * 100.0;
|
||||
|
||||
m_pool->api()->set(p2pool_api::Category::LOCAL, "miner",
|
||||
[cur_ts, hash_count, dt, block_reward_share_percent, this](log::Stream& s)
|
||||
|
||||
@@ -109,12 +109,12 @@ p2pool::p2pool(int argc, char* argv[])
|
||||
generate_keys(pub, sec);
|
||||
|
||||
uint8_t view_tag;
|
||||
if (!p->m_wallet.get_eph_public_key(sec, 0, eph_public_key, view_tag)) {
|
||||
if (!p->m_miningWallet.get_eph_public_key(sec, 0, eph_public_key, view_tag)) {
|
||||
LOGERR(1, "Invalid wallet address: get_eph_public_key failed");
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
const NetworkType type = p->m_wallet.type();
|
||||
const NetworkType type = p->m_miningWallet.type();
|
||||
|
||||
if (type == NetworkType::Testnet) {
|
||||
LOGWARN(1, "Mining to a testnet wallet address");
|
||||
@@ -625,7 +625,7 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
||||
if (!merkle_root.empty()) {
|
||||
const PoolBlock* block = side_chain().find_block_by_merkle_root(merkle_root);
|
||||
if (block) {
|
||||
const Wallet& w = params().m_wallet;
|
||||
const Wallet& w = params().m_miningWallet;
|
||||
|
||||
const char* who = (block->m_minerWallet == w) ? "you" : "someone else in this p2pool";
|
||||
LOGINFO(0, log::LightGreen() << "BLOCK FOUND: main chain block at height " << data.height << " was mined by " << who << BLOCK_FOUND);
|
||||
@@ -1240,7 +1240,7 @@ void p2pool::update_block_template()
|
||||
if (m_updateSeed.exchange(false)) {
|
||||
m_hasher->set_seed_async(data.seed_hash);
|
||||
}
|
||||
m_blockTemplate->update(data, *m_mempool, &m_params->m_wallet);
|
||||
m_blockTemplate->update(data, *m_mempool, &m_params->m_miningWallet);
|
||||
stratum_on_block();
|
||||
api_update_pool_stats();
|
||||
|
||||
|
||||
@@ -73,7 +73,12 @@ Params::Params(int argc, char* const argv[])
|
||||
}
|
||||
|
||||
if ((strcmp(argv[i], "--wallet") == 0) && (i + 1 < argc)) {
|
||||
m_wallet.decode(argv[++i]);
|
||||
m_mainWallet.decode(argv[++i]);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((strcmp(argv[i], "--subaddress") == 0) && (i + 1 < argc)) {
|
||||
m_subaddress.decode(argv[++i]);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
@@ -305,20 +310,44 @@ Params::Params(int argc, char* const argv[])
|
||||
LOGWARN(1, "Value for --stratum-ban-time is too high, adjusting to " << MAX_STRATUM_BAN_TIME);
|
||||
m_stratumBanTime = MAX_STRATUM_BAN_TIME;
|
||||
}
|
||||
|
||||
char display_wallet_buf[Wallet::ADDRESS_LENGTH] = {};
|
||||
|
||||
if (m_mainWallet.valid() && m_subaddress.valid()) {
|
||||
m_miningWallet.assign(m_subaddress.spend_public_key(), m_mainWallet.view_public_key(), m_mainWallet.type(), false);
|
||||
m_subaddress.encode(display_wallet_buf);
|
||||
}
|
||||
else if (m_mainWallet.valid()) {
|
||||
m_miningWallet = m_mainWallet;
|
||||
m_mainWallet.encode(display_wallet_buf);
|
||||
}
|
||||
|
||||
m_displayWallet.assign(display_wallet_buf, Wallet::ADDRESS_LENGTH);
|
||||
}
|
||||
|
||||
bool Params::valid() const
|
||||
{
|
||||
if (!m_wallet.valid()) {
|
||||
if (!m_mainWallet.valid() || !m_miningWallet.valid()) {
|
||||
LOGERR(1, "Invalid wallet address. Try \"p2pool --help\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_wallet.is_subaddress()) {
|
||||
if (m_mainWallet.is_subaddress()) {
|
||||
LOGERR(1, "Wallet address must be a main address (starting with 4...). Try \"p2pool --help\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_subaddress.valid()) {
|
||||
if (!m_subaddress.is_subaddress()) {
|
||||
LOGERR(1, "Subaddress must start with 8... Try \"p2pool --help\".");
|
||||
return false;
|
||||
}
|
||||
if (m_subaddress.type() != m_mainWallet.type()) {
|
||||
LOGERR(1, "Subaddress must belong to the same network type as the main wallet address. Try \"p2pool --help\".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mergeMiningHosts.size() > 10) {
|
||||
LOGERR(1, "Too many merge mining blockchains.");
|
||||
return false;
|
||||
|
||||
@@ -70,7 +70,14 @@ struct Params
|
||||
std::vector<MergeMiningHost> m_mergeMiningHosts;
|
||||
|
||||
bool m_lightMode = false;
|
||||
Wallet m_wallet{ nullptr };
|
||||
|
||||
Wallet m_mainWallet{ nullptr };
|
||||
Wallet m_subaddress{ nullptr };
|
||||
|
||||
Wallet m_miningWallet{ nullptr };
|
||||
|
||||
std::string m_displayWallet;
|
||||
|
||||
std::string m_stratumAddresses;
|
||||
std::string m_p2pAddresses;
|
||||
std::string m_p2pPeerList;
|
||||
|
||||
@@ -662,7 +662,7 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
|
||||
WriteLock lock(m_watchBlockLock);
|
||||
|
||||
if (block.m_merkleRoot == m_watchBlockMerkleRoot) {
|
||||
const Wallet& w = m_pool->params().m_wallet;
|
||||
const Wallet& w = m_pool->params().m_miningWallet;
|
||||
|
||||
const char* who = (block.m_minerWallet == w) ? "you" : "someone else in this p2pool";
|
||||
LOGINFO(0, log::LightGreen() << "BLOCK FOUND: main chain block at height " << m_watchBlock.height << " was mined by " << who << BLOCK_FOUND);
|
||||
@@ -971,7 +971,7 @@ void SideChain::print_status(bool obtain_sidechain_lock) const
|
||||
std::array<uint64_t, N> our_blocks_in_window{};
|
||||
std::array<uint64_t, N> our_uncles_in_window{};
|
||||
|
||||
const Wallet& w = m_pool->params().m_wallet;
|
||||
const Wallet& w = m_pool->params().m_miningWallet;
|
||||
|
||||
while (cur) {
|
||||
blocks_in_window.emplace(cur->m_sidechainId);
|
||||
@@ -1079,7 +1079,7 @@ void SideChain::print_status(bool obtain_sidechain_lock) const
|
||||
(hashrate_est ? "\nYour hashrate (pool-side) = " : "") << (hashrate_est ? log::Hashrate(hashrate_est) : log::Hashrate()) <<
|
||||
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)" <<
|
||||
"\nPPLNS window duration = " << log::Duration((pplns_weight / pool_hashrate).lo) <<
|
||||
"\nYour wallet address = " << w <<
|
||||
"\nYour wallet address = " << m_pool->params().m_displayWallet <<
|
||||
"\nYour shares = " << our_blocks_in_window_total << " blocks (+" << our_uncles_in_window_total << " uncles, " << our_orphans << " orphans)"
|
||||
<< our_blocks_in_window_chart << our_uncles_in_window_chart <<
|
||||
"\nBlock reward share = " << block_share << "% (" << log::XMRAmount(your_reward) << ')'
|
||||
@@ -1425,7 +1425,7 @@ void SideChain::verify_loop(PoolBlock* block)
|
||||
if (block->m_wantBroadcast && !block->m_broadcasted) {
|
||||
block->m_broadcasted = true;
|
||||
if (server && (block->m_depth < UNCLE_BLOCK_DEPTH)) {
|
||||
if (m_pool && (block->m_minerWallet == m_pool->params().m_wallet)) {
|
||||
if (m_pool && (block->m_minerWallet == m_pool->params().m_miningWallet)) {
|
||||
LOGINFO(0, log::Green() << "SHARE ADDED: height = " << block->m_sidechainHeight << ", id = " << block->m_sidechainId << ", mainchain height = " << block->m_txinGenHeight);
|
||||
}
|
||||
server->broadcast(*block, get_parent(block));
|
||||
|
||||
@@ -1555,7 +1555,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
||||
uint32_t connections = m_numConnections;
|
||||
uint32_t incoming_connections = m_numIncomingConnections;
|
||||
|
||||
const double block_reward_share_percent = m_pool->side_chain().get_reward_share(m_pool->params().m_wallet) * 100.0;
|
||||
const double block_reward_share_percent = m_pool->side_chain().get_reward_share(m_pool->params().m_miningWallet) * 100.0;
|
||||
|
||||
CallOnLoop(&m_loop, [=]() {
|
||||
m_pool->api()->set(p2pool_api::Category::LOCAL, "stratum", [=](log::Stream& s) {
|
||||
@@ -1572,7 +1572,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
||||
<< ",\"connections\":" << connections
|
||||
<< ",\"incoming_connections\":" << incoming_connections
|
||||
<< ",\"block_reward_share_percent\":" << block_reward_share_percent
|
||||
<< ",\"wallet\":\"" << m_pool->params().m_wallet << '"'
|
||||
<< ",\"wallet\":\"" << m_pool->params().m_displayWallet << '"'
|
||||
<< ",\"workers\":[";
|
||||
|
||||
const difficulty_type pool_diff = m_pool->side_chain().difficulty();
|
||||
|
||||
Reference in New Issue
Block a user