Last active
June 10, 2022 01:16
-
-
Save kimsk/c78cab395fe0a5369f380ed97194dcc8 to your computer and use it in GitHub Desktop.
Breaking large XCH coins for fees
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
$sw = new-object system.diagnostics.stopwatch | |
$sw.Start() | |
$FINGERPRINT = 219821919 # fingerprint of your wallet | |
$FEE = 50000000 # 50_000_000 mojos is 0.00005 XCH | |
$WALLET_ID = 1 | |
$NUM = 100 | |
$AMOUNT = $FEE | |
# set synced wallet | |
chia wallet show -f $FINGERPRINT | Out-Null | |
Start-Sleep -s 5 | |
$addresses = | |
chia keys derive -f $FINGERPRINT wallet-address -n $NUM | |
| % { $_ -replace '(^Wallet address )(.*)(: )', "" } | |
$additions = @() | |
foreach($addr in $addresses) { | |
$puzzle_hash = cdv decode $addr | |
Write-Host $addr $puzzle_hash | |
$addition = @{ | |
amount = $AMOUNT | |
puzzle_hash = $puzzle_hash | |
} | |
$additions += $addition | |
} | |
$txn_fee = $FEE * $NUM # fee for send_transaction_multi transaction | |
$select_coins_json = | |
@{ | |
wallet_id = $WALLET_ID | |
amount = ($AMOUNT * $NUM) + $txn_fee | |
} | ConvertTo-Json | |
$_select_coins_json = $select_coins_json -replace '"', '\""' | |
$coins = (chia rpc wallet select_coins $_select_coins_json | ConvertFrom-Json).coins | |
$json = @{ | |
wallet_id = 1 | |
additions = $additions | |
fee = $txn_fee | |
coins = $coins | |
} | ConvertTo-Json | |
$_json = $json -replace '"', '\""' | |
$signed_tx = (chia rpc wallet create_signed_transaction $_json | ConvertFrom-Json).signed_tx | |
$signed_tx_json = $signed_tx | ConvertTo-Json -Depth 4 | |
$_signed_tx_json = $signed_tx_json -replace '"', '\""' | |
chia rpc wallet send_transaction_multi $_signed_tx_json | |
$sw.Stop() | |
Write-Host $sw.Elapsed.TotalMinutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment