Last active
March 18, 2020 15:37
-
-
Save buzzkillb/538c791fe72308a513bcad92a97c0cda 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 | |
#debug.log location | |
debuglog=~/snap/denarius/common/.denarius/debug.log | |
#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 | |
#wait 6 minutes to stake | |
sleep 360 | |
#then wait 40 extra confirms confirms so stake is fully confirmed and no reorgs | |
#someone make me smarter | |
#get blockheight | |
stakeheight=($(denarius.daemon getblockcount)) | |
echo -e "$stakeheight" > stakeheight.txt | |
stakeconfirms=40 | |
heighttoconfirm=$((stakeheight+stakeconfirms)) | |
echo "fully confirmed at $heighttoconfirm" | |
tail -f $debuglog | egrep -m 1 "$heighttoconfirm trust=" | |
echo "found height $heighttoconfirm. time to send collateral" | |
#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 | |
#get blockheight | |
blockheight=($(denarius.daemon getblockcount)) | |
echo -e "$blockheight" > blockheight.txt | |
#store txid | |
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 120 seconds for wallet to sync | |
sleep 120 | |
#wait 510 confirms to send | |
sleep 2 | |
fsalias=$(head -1 alias.txt) | |
sleep 240 | |
fsconfirms=510 | |
heighttosend=$((blockheight+fsconfirms)) | |
echo "start-alias $fsalias at height $heighttosend" | |
tail -f $debuglog | egrep -m 1 "$heighttosend trust=" | |
echo "found height $heighttosend. time to fortunastake start-alias" | |
#unlock wallet for staking (20min) to fortunastake start-alias | |
denarius.daemon walletpassphrase "password" 1200 | |
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