-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxch_breaking.ps1
57 lines (46 loc) · 1.41 KB
/
xch_breaking.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
55
56
57
param (
# fingerprint of your wallet
[Parameter(mandatory)]
$Fingerprint,
[Parameter(mandatory)]
$Num,
[Parameter(mandatory)]
$Amount,
# fee 50_000_000 mojos is 0.00005 XCH
$Fee = 50000000
)
. ../chia_functions.ps1
$sw = new-object system.diagnostics.stopwatch
$sw.Start()
Wait-SyncedWallet $Fingerprint
$WALLET_ID = 1
$AMOUNT = $Amount
$txnFee = $Fee * $Num # fee for send_transaction_multi transaction
$total = ($AMOUNT * $Num) + $txnFee
Wait-EnoughSpendable -WalletId $WALLET_ID -Amount $total
$puzzleHashes = Get-DerivedPuzzleHashes -fingerprint $FINGERPRINT -num $Num
$additions = foreach($puzzleHash in $puzzleHashes) {
[PSCustomObject]@{
amount = $AMOUNT
puzzle_hash = $puzzleHash
}
}
$coins = Get-Coins -WalletId $WALLET_ID -Amount $total
Write-Host "XCH Breaking: $($coins.Length) coin(s) -> $($Num) coins"
$json = [PSCustomObject]@{
wallet_id = $WALLET_ID
additions = @($additions)
fee = $txnFee
coins = @($coins)
}
| ConvertTo-Json
| Edit-ChiaRpcJson
$json =
(chia rpc wallet create_signed_transaction $json | ConvertFrom-Json).signed_tx
| ConvertTo-Json -Depth 4
| Edit-ChiaRpcJson
$result = chia rpc wallet send_transaction_multi $json
$transaction_id = ($result | ConvertFrom-Json).transaction_id
Wait-Transaction $transaction_id
$sw.Stop()
Write-Host "XCH Breaking: $($sw.Elapsed.TotalMinutes) minutes"