/checkWalletWithApiKey.ps Secret
Created
December 13, 2021 11:25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#credit to @diomark | |
#credit to @mwferris | |
# Put your details here: | |
$walletName = "WALLET_NAME" | |
$unlockWallet = 0 # swap to 1 if you want to auto unlock wallet | |
$walletPassword = "WALLET_PASSWORD" # only needed if unlocking wallet in script | |
$apiKey = "0000000000000000000000000000000000000000000000000000000000000000" | |
$headers = @{ | |
'accept'='*/*' | |
'X-API-KEY'=$($apiKey) | |
} | |
# unlock wallet | |
if($unlockWallet -eq 1){ | |
$body = @{ password=$walletPassword } | ConvertTo-Json | |
Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:12973/wallets/$($walletName)/unlock " ` | |
-ContentType "application/json" -Headers $headers -Body $body | |
} | |
#check wallet | |
$oldBalance = Invoke-RestMethod -Method Get -Uri "http://127.0.0.1:12973/wallets/$($walletName)/balances" ` | |
-ContentType "application/json" -Headers $headers | Select-Object -ExpandProperty TotalBalanceHint | |
Write-Output "Current balance: $($oldBalance)" | |
$oldDate=Get-Date | |
while($true) { | |
Write-Host "." -NoNewLine | |
$newBalance=Invoke-RestMethod -Method Get -Uri "http://127.0.0.1:12973/wallets/$($walletName)/balances" ` | |
-ContentType "application/json" -Headers $headers | Select-Object -ExpandProperty TotalBalanceHint | |
if($oldBalance -ne $newBalance) { | |
$newDate=Get-Date | |
$msg="`nWon a block after $($(($newDate - $oldDate).TotalMinutes).tostring("#")) minutes!" | |
" $($msg) Current balance: $($newBalance) " | Write-Output | |
$oldDate=$newDate | |
$oldBalance = $newBalance | |
} | |
Start-Sleep 30 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment