Bitcoin Forum
May 08, 2024, 05:27:35 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: sx: bash script for creating, redeeming and sending multisignature transaction  (Read 6041 times)
genjix (OP)
Legendary
*
expert
Offline Offline

Activity: 1232
Merit: 1076


View Profile
August 08, 2013, 05:03:57 PM
Last edit: August 08, 2013, 05:52:56 PM by genjix
 #1

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://bitcointalk.org/index.php?topic=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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!