Skip to content

Commit

Permalink
nicehash get wallets
Browse files Browse the repository at this point in the history
-No longer can do request for
  nicehash wallets.
-API for external wallets added.
  • Loading branch information
MaynardMiner committed Nov 8, 2019
1 parent a49a357 commit d077124
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
9 changes: 2 additions & 7 deletions build/powershell/build/wallets.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,8 @@ function Global:Get-Wallets {
$AltWallet_Config = Global:Get-AltWallets

##Remove NiceHash From Regular Wallet
if ($(arg).Nicehash_Wallet1) { $(arg).PoolName | % { if ($_ -ne "nicehash") { $NewWallet1 += $_ } } }
else { $(arg).PoolName | % { $NewWallet1 += $_ } }
if ($(arg).Nicehash_Wallet2) { $(arg).PoolName | % { if ($_ -ne "nicehash") { $NewWallet2 += $_ } } }
else { $(arg).PoolName | % { $NewWallet1 += $_ } }
if ($(arg).Nicehash_Wallet3) { $(arg).PoolName | % { if ($_ -ne "nicehash") { $NewWallet3 += $_ } } }
else { $(arg).PoolName | % { $NewWallet3 += $_ } }

$(arg).PoolName | % { $NewWallet1 += $_; $NewWallet2 += $_; $NewWallet3 += $_ }

$C = $true
if ($(arg).Coin) { $C = $false }
if ($C -eq $false) { log "Coin Parameter Specified, disabling All alternative wallets." -ForegroundColor Yellow }
Expand Down
41 changes: 22 additions & 19 deletions wallet/pools/nicehash.ps1
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
$Name = Get-Item $MyInvocation.MyCommand.Path | Select-Object -ExpandProperty BaseName
$PoolQuery = "https://api.nicehash.com/api?method=stats.provider&addr="
$PoolQuery = "https://api2.nicehash.com/main/api/v2/mining/external/"

$Query = @()
if ($Global:WalletKeys.Nicehash_Wallet1.BTC.Pools -contains $Name) {
$Global:WalletKeys.Nicehash_Wallet1.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Nicehash_Wallet1.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Nicehash_Wallet1.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Nicehash_Wallet1.BTC.address; Response = ""}
if ($Global:WalletKeys.Wallet1.BTC.Pools -contains $Name) {
$Global:WalletKeys.Wallet1.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Wallet1.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Wallet1.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Wallet1.BTC.address; Response = "" }
}
}
}

if ($Global:WalletKeys.Nicehash_Wallet2.BTC.Pools -contains $Name) {
$Global:WalletKeys.Nicehash_Wallet2.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Nicehash_Wallet2.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Nicehash_Wallet2.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Nicehash_Wallet2.BTC.address; Response = ""}
if ($Global:WalletKeys.Wallet2.BTC.Pools -contains $Name) {
$Global:WalletKeys.Wallet2.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Wallet2.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Wallet2.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Wallet2.BTC.address; Response = "" }
}
}
}

if ($Global:WalletKeys.Nicehash_Wallet3.BTC.Pools -contains $Name) {
$Global:WalletKeys.Nicehash_Wallet3.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Nicehash_Wallet3.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Nicehash_Wallet3.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Nicehash_Wallet3.BTC.address; Response = ""}
if ($Global:WalletKeys.Wallet3.BTC.Pools -contains $Name) {
$Global:WalletKeys.Wallet3.BTC.pools | % {
if ($Query.Name -notcontains "$($Name)_$($Global:WalletKeys.Wallet3.BTC.address)") {
$Query += [PSCustomObject]@{Name = "$($Name)_$($Global:WalletKeys.Wallet3.BTC.address)"; Symbol = "BTC"; Address = $Global:WalletKeys.Wallet3.BTC.address; Response = "" }
}
}
}

$Query | % {
try {$Response = Invoke-RestMethod "$PoolQuery$($_.address)" -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop}
Catch {Write-Warning "failed to contact $Name For $($_.Address) Info"; $Response = $Null}
$_.Response = $Response
if ([string]$_.address -ne "") {
try { $Response = Invoke-RestMethod "$PoolQuery$($_.address)/rigs" -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop }
Catch { Write-Warning "failed to contact $Name For $($_.Address) wallet Info"; $Response = $Null }
$_.Response = $Response
}
}

$Query| % {
if ($_.Response.result) {
$Query | % {
if ($_.Response) {
$unpaid = 0
$nhbalance = 0
$_.Response.result.Stats | % {$nhbalance += $_.balance}
if ($_.Response.externalBalance -gt 0) { $nhbalance += $_.Response.externalBalance }
if ($_.Response.unpaidAmount -gt 0) { $unpaid += $_.Response.unpaidAmount }
Set-WStat -Name "$($Name)_$($_.Address)" -Symbol $_.symbol -address $_.address -balance $nhbalance -unpaid $unpaid
}
}
Expand Down

0 comments on commit d077124

Please sign in to comment.