Skip to content

Commit

Permalink
v6.0.0
Browse files Browse the repository at this point in the history
Initial release
  • Loading branch information
UselessGuru committed Jan 2, 2024
1 parent 91e2dfc commit 44e7811
Show file tree
Hide file tree
Showing 223 changed files with 38,135 additions and 7 deletions.
67 changes: 67 additions & 0 deletions Balances/HashCryptos.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
Copyright (c) 2018-2023 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\HashCryptos.ps1
Version: 6.0.0
Version date: 2024/01/01
#>

$Name = (Get-Item $MyInvocation.MyCommand.Path).BaseName
$PayoutCurrency = $Config.PoolsConfig.$Name.PayoutCurrency
$Wallet = $Config.PoolsConfig.$Name.Wallets.$PayoutCurrency
$RetryCount = $Config.PoolsConfig.$Name.PoolAPIAllowedFailureCount
$RetryInterval = $Config.PoolsConfig.$Name.PoolAPIRetryInterval

$Request = "https://www.hashcryptos.com/api/wallet/?address=$Wallet"

$Headers = @{"Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}
$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 $APIResponse -and $RetryCount -gt 0 -and $Wallet) {

Try {
$APIResponse = Invoke-RestMethod $Request -TimeoutSec $Config.PoolAPITimeout -ErrorAction Ignore -Headers $Headers -UserAgent $UserAgent -SkipCertificateCheck

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 ($APIResponse.symbol) {
Return [PSCustomObject]@{
DateTime = ([DateTime]::Now).ToUniversalTime()
Pool = $Name
Currency = $APIResponse.symbol
Wallet = $Wallet
Pending = [Double]$APIResponse.unsold # Pending
Balance = [Double]$APIResponse.balance
Unpaid = [Double]$APIResponse.unpaid # Balance + unsold (pending)
# Paid = [Double]$APIResponse.total # Reset after payout
# Total = [Double]$APIResponse.unpaid + [Double]$APIResponse.total # Reset after payout
Url = "https://www.hashcryptos.com/?address=$Wallet"
}
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}

$RetryCount--
}
71 changes: 71 additions & 0 deletions Balances/HiveON.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<#
Copyright (c) 2018-2023 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\Hiveon.ps1
Version: 6.0.0
Version date: 2024/01/01
#>

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

$PoolConfig = $Config.PoolsConfig.$Name
$PoolConfig.Wallets.psBase.Keys.Where({ $_ -in @("BTC", "ETC", "RVN") }).ForEach(
{
$APIResponse = $null
$Currency = $_.ToUpper()
$Wallet = ($PoolConfig.Wallets.$_ -replace '^0x').ToLower()
$RetryCount = $PoolConfig.PoolAPIAllowedFailureCount
$RetryInterval = $PoolConfig.PoolAPIRetryInterval

$Request = "https://Hiveon.net/api/v1/stats/miner/$Wallet/$Currency/billing-acc"

While (-not $APIResponse -and $RetryCount -gt 0 -and $Wallet) {

Try {
$APIResponse = Invoke-RestMethod $Request -TimeoutSec $PoolConfig.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 ($APIResponse.earningStats) {
[PSCustomObject]@{
DateTime = ([DateTime]::Now).ToUniversalTime()
Pool = $Name
Currency = $_
Wallet = $Wallet
Pending = [Double]0
Balance = [Double]$APIResponse.totalUnpaid
Unpaid = [Double]$APIResponse.totalUnpaid
# Paid = [Double]$APIResponse.stats.totalPaid
# Total = [Double]$APIResponse.stats.balance + [Decimal]$APIResponse.stats.penddingBalance
Url = "https://Hiveon.net/$($Currency.ToLower())?miner=$Wallet"
}
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}

$RetryCount--
}
}
)
81 changes: 81 additions & 0 deletions Balances/MiningDutch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<#
Copyright (c) 2018-2023 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\MiningDutch.ps1
Version: 6.0.0
Version date: 2024/01/01
#>

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

$RetryInterval = $Config.PoolsConfig.$Name.PoolAPIRetryInterval
$PoolAPITimeout = $Config.PoolsConfig.$Name.PoolAPITimeout
$RetryCount = $Config.PoolsConfig.$Name.PoolAPIAllowedFailureCount

$Headers = @{"Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}
$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 $APIResponse -and $RetryCount -gt 0 -and $Config.MiningDutchAPIKey) {

Try {
(Invoke-RestMethod "https://www.mining-dutch.nl/api/v1/public/pooldata/?method=poolstats&algorithm=all&id=$($Config.MiningDutchUserName)" -UserAgent $Useragent -Headers $Headers -TimeoutSec $PoolAPITimeout -ErrorAction Ignore).result.Where({ $_.tag -notlike "*_*" }).ForEach(
{
$RetryCount = $Config.PoolsConfig.$Name.PoolAPIAllowedFailureCount
$Currency = $_.tag
$CoinName = $_.currency

$APIResponse = $null
While (-not $APIResponse -and $RetryCount -gt 0) {
Try {
If ($APIResponse = ((Invoke-RestMethod "https://www.mining-dutch.nl/pools/$($CoinName.ToLower()).php?page=api&action=getuserbalance&api_key=$($Config.MiningDutchAPIKey)" -UserAgent $Useragent -Headers $Headers -TimeoutSec $PoolAPITimeout -ErrorAction Ignore).getuserbalance).data) {
$RetryCount = $Config.PoolsConfig.$Name.PoolAPIAllowedFailureCount

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
}

[PSCustomObject]@{
DateTime = ([DateTime]::Now).ToUniversalTime()
Pool = $Name
Currency = $Currency
Wallet = $Config.MiningDutchUserName
Pending = [Double]$APIResponse.unconfirmed
Balance = [Double]$APIResponse.confirmed
Unpaid = [Double]$APIResponse.confirmed + [Double]$APIResponse.unconfirmed
Url = "https://www.mining-dutch.nl//index.php?page=earnings"
}
}
}
Catch {
$RetryCount--
Start-Sleep -Seconds $Config.PoolsConfig.$Name.PoolAPIRetryInterval # Pool might not like immediate requests
}
}
}
)
}
Catch {
$RetryCount--
Start-Sleep -Seconds $Config.PoolsConfig.$Name.PoolAPIRetryInterval # Pool might not like immediate requests
}

$RetryCount--
}
139 changes: 139 additions & 0 deletions Balances/MiningPoolHub.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<#
Copyright (c) 2018-2023 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.0.0
Version date: 2024/01/01
#>

$Name = (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-Object { $_.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-Object { $_.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 (-not $Currency) {
Write-Message -Level Warn "$($Name): Cannot determine balance for currency '$(If ($_) { $_ } Else { "unknown" } )' - cannot convert some balances to BTC or other currencies."
}
Else {
# 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"
}
}
}
}
)
}
}
Catch {
Start-Sleep -Seconds $RetryInterval # Pool might not like immediate requests
}

$RetryCount--
}
Loading

0 comments on commit 44e7811

Please sign in to comment.