-
Notifications
You must be signed in to change notification settings - Fork 1
/
sweep-all.ps1
54 lines (35 loc) · 1.32 KB
/
sweep-all.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
### Setup
$Password = ""
$WalletName = ""
$ColdWalletAddress = ""
$apiUrl = "http://127.0.0.1:12973/"
$apiKey = ''
###
$headers = @{'X-API-KEY' = $apiKey}
### UNLOCK
$unlockUrl = $apiUrl + "wallets/" + $WalletName +"/" + "unlock"
$Form =
@{
password = $Password
}
Invoke-WebRequest -Uri $unlockUrl -Headers $headers -Method Post -Body ($Form|ConvertTo-Json) -ContentType "application/json" -UseBasicParsing
#######
### Get addresses
$balencesUrl = $apiUrl + "wallets/" + $WalletName +"/" + "balances"
Write-Output $balencesUrl
$result = Invoke-WebRequest -Uri $balencesUrl -Headers $headers -ContentType "application/json" -UseBasicParsing | ConvertFrom-Json
########
### Change active address and sweep.
foreach ($i in $result.balances)
{
$changeActiveAddressUrl = $apiUrl + "wallets/" + $WalletName +"/" + "change-active-address"
$Form = @{
address = $i.address
}
Invoke-WebRequest -Uri $changeActiveAddressUrl -Headers $headers -Method Post -Body ($Form|ConvertTo-Json) -ContentType "application/json" -UseBasicParsing
$sweepAllUrl = $apiUrl + "wallets/" + $WalletName +"/sweep-all"
$Form = @{
toAddress = $ColdWalletAddress
}
Invoke-WebRequest -Uri $sweepAllUrl -Headers $headers -Method Post -Body ($Form|ConvertTo-Json) -ContentType "application/json" -UseBasicParsing
}