Skip to content

Commit

Permalink
v6.3.8
Browse files Browse the repository at this point in the history
Fixes:
- BalancesTracker: NiceHash balances not working
- Core / Includes.psm1: Function 'Get-AllDAGdata' querying API's too often
- Core / Includes.psm1: Function 'Get-Stat' not returning all stats if called without parameter
- Core / Includes.psm1: Function 'Update-PoolWatchdog' Pool watchdog marking pools unavailable with two reasons simultaneously (Regression from 6.3.3)
- Miner API 'EthMiner': Error when miner crashed
- Web GUI: Miners & Pools tables: Reasons filter not working

Improvements:
- Core & Miner APIs: Remove obsolete code & minor code optimizations
- LegacyGUI.ps1: Remove obsolete code & minor code optimizations

Miner updates:
- BzMiner-v21.5.1
  • Loading branch information
UselessGuru committed Oct 12, 2024
1 parent ff5cf30 commit fc31687
Show file tree
Hide file tree
Showing 133 changed files with 2,644 additions and 1,167 deletions.
4 changes: 2 additions & 2 deletions Balances/HashCryptos.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\HashCryptos.ps1
Version: 6.3.7
Version date: 2024/10/05
Version: 6.3.8
Version date: 2024/10/12
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/HiveON.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\Hiveon.ps1
Version: 6.3.7
Version date: 2024/10/05
Version: 6.3.8
Version date: 2024/10/12
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
4 changes: 2 additions & 2 deletions Balances/MiningDutch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\MiningDutch.ps1
Version: 6.3.7
Version date: 2024/10/05
Version: 6.3.8
Version date: 2024/10/12
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
Expand Down
142 changes: 142 additions & 0 deletions Balances/MiningPoolHub.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<#
Copyright (c) 2018-2024 UselessGuru
UG-Miner is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
UG-Miner is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#>

<#
Product: UG-Miner
File: \Balances\MiningPoolHub.ps1
Version: 6.3.8
Version date: 2024/10/12
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName

$RetryInterval = $Config.PoolsConfig.$Name.PoolAPIretryInterval
$PoolAPItimeout = $Config.PoolsConfig.$Name.PoolAPItimeout
$RetryCount = $Config.PoolsConfig.$Name.PoolAPIretryInterval

$Headers = @{ "Cache-Control" = "no-cache" }
$Useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"

While (-not $UserAllBalances -and $RetryCount -gt 0 -and $Config.MiningPoolHubAPIKey) {
Try {
$Url = "https://miningpoolhub.com/"
$WebResponse = Invoke-WebRequest -Uri $Url -TimeoutSec $PoolAPItimeout -ErrorAction Ignore

# PWSH 6+ no longer supports basic parsing -> parse text
$CoinList = [System.Collections.Generic.List[PSCustomObject]]@()
$InCoinList = $false

If ($WebResponse.statuscode -eq 200) {
($WebResponse.Content -split "\n" -replace ' \s+' -replace ' $').ForEach(
{
If ($_ -like '<table id="coinList"*>') {
$InCoinList = $true
}
If ($InCoinList) {
If ($_ -like '</table>') { Return }
If ($_ -like '<td align="left"><a href="*') {
$CoinList.Add($_ -replace '<td align="left"><a href="' -replace '" target="_blank">.+' -replace '^//' -replace '.miningpoolhub.com')
}
}
}
)
}
$CoinList = $CoinList | Sort-Object

$UserAllBalances = (((Invoke-RestMethod "http://miningpoolhub.com/index.php?page=api&action=getuserallbalances&api_key=$($Config.MiningPoolHubAPIKey)" -Headers $Headers -TimeoutSec $PoolAPItimeout -ErrorAction Ignore).getuserallbalances).data).Where({ $_.confirmed -gt 0 -or $_.unconfirmed -gt 0 })

If ($Config.LogBalanceAPIResponse) {
"$([DateTime]::Now.ToUniversalTime())" | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$Request | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$UserAllBalances | ConvertTo-Json -Depth 10 >> ".\Logs\BalanceAPIResponse_$Name.json"
}

If ($CoinList -and $UserAllBalances) {
$CoinList.ForEach(
{
$CoinBalance = $null
$RetryCount2 = $Config.PoolsConfig.$Name.PoolAPIretryInterval

While (-not ($CoinBalance) -and $RetryCount2 -gt 0) {
$RetryCount2--
Try {
$CoinBalance = ((Invoke-RestMethod "http://$($_).miningpoolhub.com/index.php?page=api&action=getuserbalance&api_key=$($Config.MiningPoolHubAPIKey)" -Headers $Headers -UserAgent $UserAgent -TimeoutSec $PoolAPItimeout -ErrorAction Ignore).getuserbalance).data
If ($Config.LogBalanceAPIResponse) {
$APIResponse | ConvertTo-Json -Depth 10 | Out-File -LiteralPath ".\Logs\CoinBalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}
}

If ($Balance = $UserAllBalances.Where({ $_.confirmed -eq $CoinBalance.confirmed -and $_.unconfirmed -eq $CoinBalance.unconfirmed })) {
$Currency = ""
$RetryCount2 = $Config.PoolsConfig.$Name.PoolAPIretryInterval
$PoolInfo = $null

While (-not ($PoolInfo) -and $RetryCount2 -gt 0) {
$RetryCount2--
Try {
$PoolInfo = ((Invoke-RestMethod "http://$($_).miningpoolhub.com/index.php?page=api&action=getpoolinfo&api_key=$($Config.MiningPoolHubAPIKey)" -Headers $Headers -UserAgent $UserAgent -TimeoutSec $PoolAPItimeout -ErrorAction Ignore).getpoolinfo).data
If ($Config.LogBalanceAPIResponse) {
$APIResponse | ConvertTo-Json -Depth 10 | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
}
$Currency = $PoolInfo.currency
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}
}

If ($Currency) {
# Prefer custom payout threshold
$PayoutThreshold = $Config.PoolsConfig.$Name.PayoutThreshold.$Currency

If ((-not $PayoutThreshold) -and $Currency -eq "BTC" -and $Config.PoolsConfig.$Name.PayoutThreshold.mBTC) { $PayoutThreshold = $Config.PoolsConfig.$Name.PayoutThreshold.mBTC / 1000 }
If (-not $PayoutThreshold) { $PayoutThreshold = $PoolInfo.min_ap_threshold }

[PSCustomObject]@{
DateTime = [DateTime]::Now.ToUniversalTime()
Pool = $Name
Currency = $Currency
Wallet = $Config.MiningPoolHubUserName
Pending = [Double]$CoinBalance.unconfirmed
Balance = [Double]$CoinBalance.confirmed
Unpaid = [Double]($CoinBalance.confirmed + $CoinBalance.unconfirmed)
# Total = [Double]($CoinBalance.confirmed + $CoinBalance.unconfirmed + $CoinBalance.ae_confirmed + $CoinBalance.ae_unconfirmed + $CoinBalance.exchange)
PayoutThreshold = [Double]$PayoutThreshold
Url = "https://$($_).miningpoolhub.com/index.php?page=account&action=pooledit"
}
}
Else {
Write-Message -Level Warn "$($Name): Cannot determine balance for currency '$(If ($_) { $_ } Else { "unknown" })' - cannot convert some balances to BTC or other currencies."
}
}
}
)
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}

$RetryCount--
}

$Error.Clear()
[System.GC]::Collect()
81 changes: 42 additions & 39 deletions Balances/NiceHash External.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<#
Product: UG-Miner
File: \Balances\NiceHash Internal.ps1
Version: 6.3.7
Version date: 2024/10/05
Version: 6.3.8
Version date: 2024/10/12
#>

$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
$PoolConfig = $Config.PoolsConfig.NiceHash
$PayoutCurrency = $PoolConfig.Variant.$Name.PayoutCurrency
$Wallet = $Config.PoolsConfig.NiceHash.Variant.$Name.Wallets.$PayoutCurrency
$RetryCount = $PoolConfig.PoolAPIAllowedFailureCount
$RetryInterval = $PoolConfig.PoolAPIretryInterval
If (-not $Config.NiceHashWalletIsInternal) {

$Request = "https://api2.nicehash.com/main/api/v2/mining/external/$Wallet/rigs2"
$Name = [String](Get-Item $MyInvocation.MyCommand.Path).BaseName
$PoolConfig = $Config.PoolsConfig.NiceHash
$PayoutCurrency = $PoolConfig.PayoutCurrency
$Wallet = $PoolConfig.Wallets.$PayoutCurrency
$RetryCount = $PoolConfig.PoolAPIAllowedFailureCount
$RetryInterval = $PoolConfig.PoolAPIretryInterval

While (-not $APIResponse -and $RetryCount -gt 0 -and $Wallet) {
$Request = "https://api2.nicehash.com/main/api/v2/mining/external/$Wallet/rigs2"

Try {
$APIResponse = Invoke-RestMethod $Request -TimeoutSec $Config.PoolAPItimeout -ErrorAction Ignore
While (-not $APIResponse -and $RetryCount -gt 0 -and $Wallet) {

If ($Config.LogBalanceAPIResponse) {
"$([DateTime]::Now.ToUniversalTime())" | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$Request | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$APIResponse | ConvertTo-Json -Depth 10 | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
}
Try {
$APIResponse = Invoke-RestMethod $Request -TimeoutSec $Config.PoolAPItimeout -ErrorAction Ignore

If ($Config.LogBalanceAPIResponse) {
"$([DateTime]::Now.ToUniversalTime())" | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$Request | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
$APIResponse | ConvertTo-Json -Depth 10 | Out-File -LiteralPath ".\Logs\BalanceAPIResponse_$Name.json" -Append -Force -ErrorAction Ignore
}

If ($Sum = [Double]$APIResponse.unpaidAmount + [Double]$APIResponse.externalBalance) {
Return [PSCustomObject]@{
DateTime = [DateTime]::Now.ToUniversalTime()
Pool = $Name
Currency = $PayoutCurrency
Wallet = $Wallet
Pending = [Double]$APIResponse.unpaidAmount
Balance = [Double]$APIResponse.externalBalance
Unpaid = $Sum
#Total = $Sum
Url = "https://www.nicehash.com/my/miner/$Wallet"
NextPayout = $APIResponse.NextPayoutTimeStamp
If ($Sum = [Double]$APIResponse.unpaidAmount + [Double]$APIResponse.externalBalance) {
Return [PSCustomObject]@{
DateTime = [DateTime]::Now.ToUniversalTime()
Pool = $Name
Currency = $PayoutCurrency
Wallet = $Wallet
Pending = [Double]$APIResponse.unpaidAmount
Balance = [Double]$APIResponse.externalBalance
Unpaid = $Sum
#Total = $Sum
Url = "https://www.nicehash.com/my/miner/$Wallet"
NextPayout = $APIResponse.NextPayoutTimeStamp
}
}
Else {
Return
}
}
Else {
Return
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}

$RetryCount--
}
$RetryCount--
}

$Error.Clear()
[System.GC]::Collect()
$Error.Clear()
[System.GC]::Collect()
}
Loading

0 comments on commit fc31687

Please sign in to comment.