Last active
November 3, 2017 19:31
-
-
Save devzer01/f7092b8d9a4fd27e6132db7862e5b68a 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 | |
# i wrote this in 10-15 minutes, it works feel free to improve it and do whatever u want with it :) | |
# you can use any api to publish the transaction. | |
# the idea is you traverse back to the the input that is confirmed and boradcast the transaction to the network. | |
# if you are luckly you can broadcast about 25-30 per block, if you are running multiple wallets then you can increase this | |
# limit (but i haven't verified this | |
# call the script with your transaction waiting to confirm | |
# hash-push.sh acaf309bdded0746253fadbde42ded0a06f73c57059a1690cbc259b5469086d3 | |
# THIS SCRIPT IS PROVIDED AS IS I WILL HOLD NO RESPONSIBILITY, HOWEVER IF YOU HAVE QUESTIONS | |
# ABOUT IT YOU CAN ASK IN reddit.com/r/hashflair | |
# donations: 18vgdFLPG2QhLFYFX97nNzmavEk9f1Ntm8 (BTC) | |
PREFIX="jshon -F tx.txt -e data" | |
txid=$1 | |
echo "got transaction $txid" | |
confirm="0" #change this to 1 if you want to force part 2 | |
while [ $confirm == "0" ] | |
do | |
tmd5=$(echo $txid | md5sum | cut -d- -f1 | tr -d ' ') | |
trans=$tmd5.trans | |
status=`wget https://chain.so/api/v2/tx/BTC/$txid -O $tmd5.txt 2>&1 | grep HTTP | grep -o "\.\.\. ..." | sed -e "s/\.//g" | tr -d ' '` | |
if [ "$status" == "200" ] | |
then | |
cp $tmd5.txt tx.txt | |
txid=`$PREFIX -e inputs -e 0 -e received_from -e txid | sed -e "s/\"//g"` | |
confirm=`$PREFIX -e confirmations` | |
current=`$PREFIX -e txid` | |
xtime=`$PREFIX -e time` | |
txhex=`$PREFIX -e tx_hex` | |
echo "INPUT: $current FROM $txid Time $xtime Confirmations $confirm" | |
echo $txhex > $trans | |
echo $current >> proc.log | |
sleep 2 | |
else | |
echo "throttle ....... sleeping 10" | |
sleep 10 | |
fi | |
done | |
PREFIX="jshon -e data" | |
CURRENTHASH=`wget -q -O- https://blockchain.info/q/latesthash` | |
for txid in `tac proc.log | sed -e "s/\"//g"` #notice tac here (not cat) we need to replay backwards | |
do | |
fname="$(echo $txid | md5sum | cut -d- -f1 | tr -d ' ').txt" #i have placed the raw transaction in .trans and full json in txt you can use which ever | |
txhex=`cat $fname | $PREFIX -e tx_hex | tr -d '"' ` | |
echo -ne "submitting $txid => " | |
statusf=$fname.xstat | |
electrum broadcast $txhex | tee $statusf | |
xstatus=`jshon -F $statusf -e 0` | |
xtxn=`jshon -F $statusf -e 1 | sed -e "s/\"//g"` | |
if [ $xstatus == "true" ]; then | |
if [ $xtxn == $txid ]; then | |
echo "Success" | |
else | |
echo "txid didn't match" | |
fi | |
else | |
echo "error $xtxn " | cut -c1-45 | |
NOWHASH=`wget -q -O- https://blockchain.info/q/latesthash` | |
if [ $CURRENTHASH == $NOWHASH ]; then | |
echo "still same block" | |
while [ $CURRENTHASH == $NOWHASH ]; do | |
NOWHASH=`wget -q -O- https://blockchain.info/q/latesthash` | |
sleep 10; | |
done | |
echo "new block found" | |
echo "trying resend " | |
electrum broadcast $txhex | |
fi | |
echo "resend using $txhex" | |
fi | |
sleep 1 | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
starting
when the confirmed input is found it goes forward
Submitting Transactions Looks like this
When mempool limit is reached it waits for the next block
if things got half way done or if you get a message saying transaction already in chain, then you will have to manually seek forward and adjust the inputfile
other