Author

Topic: sx: bash script for creating, redeeming and sending multisignature transaction (Read 6041 times)

legendary
Activity: 1232
Merit: 1076
This script will automate creating, redeeming and sending an MN multisignature transaction for you:

http://sx.dyne.org/automsig.sh

Read the first line and uncomment it to generate a new set of keys for the first time.

sx main thread: https://bitcointalksearch.org/topic/sx-command-line-utilities-empower-the-sysadmin-with-bitcoin-tools-259999

Code:
#!/bin/bash
# Uncomment this line to generate new keys.
#for x in `seq 1 3`; do sx newkey > pk$x; done
for x in `seq 1 3`; do cat pk$x | sx pubkey > pub$x; done
for x in `seq 1 3`; do cat pk$x | sx addr > addr$x; done

sx rawscript 2 [ `cat pub1` ] [ `cat pub2` ] [ `cat pub3` ] 3 checkmultisig > msig.script
cat msig.script | sx scripthash > 3addr
echo "Send 0.001 BTC to $(cat 3addr)"

echo "Enter Y to continue."
select yn in "Y"; do
    break;
done

echo "Pausing a few seconds before polling history"
sleep 10

sx history `cat 3addr` | grep Unspent -B 2 | grep output | awk '{print $2}' > unspent
cat unspent

if [ `cat unspent | wc -l` -eq 0 ]; then
    echo "No funds sent to address."
    exit
fi

INPUT=$(cat unspent | head -n 1)

sx mktx txfile.tx -i $INPUT -o 1Fufjpf9RM2aQsGedhSpbSCGRHrmLMJ7yY:90000
cat pk1 | sx sign-input txfile.tx 0 `cat msig.script` > sig1
cat pk3 | sx sign-input txfile.tx 0 `cat msig.script` > sig3
sx rawscript zero [ `cat sig1` ] [ `cat sig3` ] [ `cat msig.script` ] > input.script
cat input.script | sx set-input txfile.tx 0

sx broadcast-tx txfile.tx
Jump to: