Several related mining-tab pool improvements:
- Report the default pool fee correctly: pool.dragonx.is is 1%, not 0%.
The registry constant was hardcoded to 0. It now also fetches the live
poolFee from the pool's /api/stats alongside hashrate (no extra
request), so the displayed fee self-corrects and falls back to the
compile-time value only when the fetch hasn't landed.
- Show fractional fees: new FormatFeePercent trims trailing zeros so
whole fees read "1%" and fractional ones keep their decimals ("1.5%").
- Surface saved + custom pools in the pool list card: the list is now
the union of the official pools, the user's saved favorites, and the
currently-mined pool (effectivePools), each a selectable, endpoint-
deduped row. Previously the card only showed the hardcoded knownPools().
- Fix the xmrig "user" field: the "Payout Address" field now drives the
pool login rewards are credited to (resolveMiningUserAddress), instead
of being written only to "pass" while "user" was auto-derived from the
wallet's own first z-address -- which silently ignored a configured
payout address and could route rewards to the wrong address.
Unit tests cover parsePoolFee, FormatFeePercent, effectivePools, and
resolveMiningUserAddress; full app + ObsidianDragonTests build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "mining_pool_panel.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace dragonx {
|
|
namespace ui {
|
|
|
|
bool shouldDefaultPoolWorker(const std::string& currentWorker, bool alreadyDefaulted)
|
|
{
|
|
return !alreadyDefaulted && (currentWorker.empty() || currentWorker == "x");
|
|
}
|
|
|
|
std::string defaultPoolWorkerAddress(const std::vector<AddressInfo>& addresses)
|
|
{
|
|
for (const auto& addr : addresses) {
|
|
if (addr.type == "shielded" && !addr.address.empty()) {
|
|
return addr.address;
|
|
}
|
|
}
|
|
return {};
|
|
}
|
|
|
|
std::string resolveMiningUserAddress(const std::string& payoutAddress,
|
|
const std::string& firstShieldedAddress,
|
|
const std::string& firstTransparentAddress)
|
|
{
|
|
// The configured payout address is the pool login rewards go to, so it wins over
|
|
// the wallet's own addresses. "x" is the placeholder for an unset field.
|
|
if (!payoutAddress.empty() && payoutAddress != "x") return payoutAddress;
|
|
if (!firstShieldedAddress.empty()) return firstShieldedAddress;
|
|
return firstTransparentAddress; // may be empty -> caller reports "no address"
|
|
}
|
|
|
|
bool miningValueAlreadySaved(const std::vector<std::string>& savedValues,
|
|
const std::string& value)
|
|
{
|
|
if (value.empty()) return false;
|
|
return std::find(savedValues.begin(), savedValues.end(), value) != savedValues.end();
|
|
}
|
|
|
|
const char* defaultPoolUrl()
|
|
{
|
|
return "pool.dragonx.is:3433";
|
|
}
|
|
|
|
} // namespace ui
|
|
} // namespace dragonx
|