Skip to content

Instantly share code, notes, and snippets.

@wozz
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save wozz/9300799 to your computer and use it in GitHub Desktop.

Select an option

Save wozz/9300799 to your computer and use it in GitHub Desktop.
sx-create-transaction script
#!/bin/bash
# inputs:
#addr1.txt = send from address
#output.txt = send to address + amount
#pk1 = private key to addr1
#pub1 = public key to addr1
sx history `cat addr1.txt` | grep Unspent -B 3 | grep output: | awk '{print $2}' > inputs.txt
cat inputs.txt | sed 's/^/-i /' | tr '\n' ' ' > input-line.txt
sx mktx txfile.tx `cat input-line.txt` -o `cat output.txt`
sx rawscript dup hash160 [ `cat addr1.txt | sx decode-addr` ] equalverify checksig > raw.script.txt
for x in `seq 0 1`; do cat pk1 | sx sign-input txfile.tx $x `cat raw.script.txt` | tail -n 1 > sig$x; done
for x in `seq 0 1`; do sx set-input txfile.tx $x `sx rawscript [ $(cat sig$x) ] [ $(cat pub1) ]` > txfile2.tx; mv txfile2.tx txfile.tx; done
#Result:
#sx validtx txfile.tx
#> Status: Success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment