Last active
March 15, 2020 19:10
-
-
Save buzzkillb/f897b1304db5d87f8d5d3ec7c0c0d0af to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
#Collateral Staker | |
#copy alias to alias.txt | |
awk '{if(NR==1) print $1}' fortunastake.conf > alias.txt | |
#copy first line, columns 1, 2, 3 of fortunastake.conf to temporary file | |
awk '{if(NR==1) print $1, $2, $3 }' fortunastake.conf > staking1.txt | |
#remove first line from fortunastake.conf | |
sed -i.bak -e '1d' fortunastake.conf | |
#stop denarius daemon | |
denarius.daemon stop | |
sleep 60 | |
#start denarius daemon | |
denarius.daemon | |
#sleep 120 seconds to get sync | |
sleep 120 | |
#unlock wallet for staking (45min) wait for collateral stake | |
denarius.daemon walletpassphrase "password" 2700 | |
#sleep 30min waiting for stake | |
sleep 1800 | |
#get new address to send to | |
echo "getnewaddress and put into address.txt" | |
denarius.daemon getnewaddress FS > address.txt | |
sleep 2 | |
#put address into variable | |
address=$(head -1 address.txt) | |
sleep 3 | |
echo "Send 5k to $address" | |
denarius.daemon sendtoaddress $address 5000 > sendcol.txt | |
#wait 6 min for send to for sure go through | |
sleep 360 | |
txid=$(head -1 sendcol.txt) | |
sleep 2 | |
denarius.daemon gettransaction $txid > txdetails.json | |
sleep 5 | |
txid=$(head -1 sendcol.txt) | |
echo "txid=$txid" | |
jq --arg ADDRESS "$address" '.vout[] | select(.scriptPubKey.addresses[]==$ADDRESS) | .n' txdetails.json > txindex.txt | |
txindex=$(head -1 txindex.txt) | |
echo "index=$txindex" | |
#put txid at end of temporary file | |
awk -v a=$txid '{print $0 " " a}' staking1.txt > staking2.txt | |
#put index at end of temporary file | |
awk -v b=$txindex '{print $0 " " b}' staking2.txt > staking3.txt | |
fortunaline=$(head -1 staking3.txt) | |
echo "$fortunaline" | |
echo "$fortunaline" >> fortunastake.conf | |
#restart wallet | |
denarius.daemon stop | |
sleep 120 | |
denarius.daemon | |
#wait 500 confirms (approx 4.6 hours or 276 min) | |
sleep 16560 | |
#unlock wallet for staking (20min) to fortunastake start-alias | |
denarius.daemon walletpassphrase "password" 1200 | |
sleep 2 | |
fsalias=$(head -1 alias.txt) | |
sleep 2 | |
#start-alias | |
denarius.daemon fortunastake start-alias $fsalias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of searching for the 5000 send which if 2 users send on the same block is gonna be an issue.
jq '.vout[] | select(.value==5000) | .n' txdetails.json
Changed to searching out the address from address.txt $address variable we are using when getnewaddress is summoned.
jq --arg ADDRESS "$address" '.vout[] | select(.scriptPubKey.addresses[]==$ADDRESS) | .n' txdetails.json > txindex.txt