forked from RainbowMiner/RainbowMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrinmint.ps1
38 lines (34 loc) · 1.19 KB
/
Grinmint.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param(
$Config
)
$Name = Get-Item $MyInvocation.MyCommand.Path | Select-Object -ExpandProperty BaseName
$PoolConfig = $Config.Pools.$Name
if (!$PoolConfig.GRIN) {
Write-Log -Level Verbose "Pool Balance API ($Name) has failed - no wallet address specified."
return
}
$Request = [PSCustomObject]@{}
try {
if ($Request = Invoke-RestMethodAsync "https://api.grinmint.com/v1/user/$($PoolConfig.GRIN)/userStats" -cycletime ($Config.BalanceUpdateMinutes*60)) {
if ($Request.status) {
$Divisor = [Decimal]1e9
$Unpaid = [Decimal]$Request.unpaid_balance / $Divisor
$Immature = [Decimal]$Request.immature_balance / $Divisor
[PSCustomObject]@{
Caption = "$($Name) (GRIN)"
BaseName = $Name
Currency = "GRIN"
Balance = $Unpaid
Pending = $Immature
Total = $Unpaid + $Immature
Paid = 0
Earned = 0
Payouts = @()
LastUpdated = (Get-Date).ToUniversalTime()
}
}
}
}
catch {
if ($Error.Count){$Error.RemoveAt(0)}
}