Pages:
Author

Topic: sx command line utilities - Empower The Sysadmin With Bitcoin Tools - page 10. (Read 240157 times)

legendary
Activity: 3710
Merit: 1586
Is there any documentation for how to use the network parts of this tool? Like how to setup obelisk with the blockchain data so that I can do sx history and so on?
legendary
Activity: 1232
Merit: 1076
Github is spitting a 404 at

https://github.com/genjix/sx/



https://github.com/spesmilo/sx/

sx now supports embedding files in the blockchain.

$ echo foo | sx embed-addr
$ 1N9v8AKBqst9MNceV3gLmFKsgkKv1bZcBU

send some bitcoin to that address, and it will be a record in the blockchain of some data.

But I recommend to use the install script instead. You can even specify a local path and you don't need to be root. It will build the dependencies needed and stuff.
member
Activity: 203
Merit: 10
The World’s First Blockchain Core
legendary
Activity: 1372
Merit: 1008
1davout
g++ 4.7 or higher as always. This is the version of g++ that properly implements the C++ standard. g++ 4.7 is in pretty much every Linux distro now. Older g++ do not fully implement the new C++ standard.

I personally use Ubuntu LTS or Debian stable for servers I manage, and as far as I know they don't have g++ 4.7.
If you're targeting sysadmins (which I think is great) it would be good to have it build easily on these versions.

I really like the idea of having ligthweight tools that I can use on my servers instead of running a resource-hungry client, but if I need to fiddle around to get g++ 4.7 or run cutting edge versions that's kind of a turn off.

Then again I don't know shit about C++ so I have no idea about the difficulty of working around the limitations of g++ 4.6.3 which is present on Ubuntu LTS for example.
legendary
Activity: 1232
Merit: 1076
Have you lowered the g++ dependency?

g++ 4.7 or higher as always. This is the version of g++ that properly implements the C++ standard. g++ 4.7 is in pretty much every Linux distro now. Older g++ do not fully implement the new C++ standard.
legendary
Activity: 1372
Merit: 1008
1davout
Have you lowered the g++ dependency?
member
Activity: 73
Merit: 10
****
The author of the article answered my question, change that line to:

for x in `seq 0 2`; do sx rawscript [ `cat sig$x` ] [ `cat pub1 | sx pubkey` ] | sx set-input txfile.tx $x > txfile2.tx; mv txfile2.tx txfile.tx; done
****

Hello,

I've been following the steps in this article (http://bitcoinmagazine.com/what-libbitcoin-and-sx-are-and-why-they-matter/), but can't seem to make a valid raw transaction from an address with multiple unspent inputs.

It misses the scriptSig data from each prev_out. If I copy the raw transaction that

for x in `seq 0 2`; do sx rawscript [ `cat sig$x` ] [ `cat pub1` ] | sx set-input txfile.tx $x; done

returns it shows that only the first prev_out has the scriptSig data.

When using an address with only one unspent transaction it works as expected.

These are the steps I follow:

sx history `cat addr1` | grep Unspent -B 2 | grep output | awk '{print $2}' > input
sx mktx txfile.tx `cat input` -o 18qk7SqRHuS4Kf3f6dmsvqqv7iw1xy77Z6:90000
sx rawscript dup hash160 [ `cat addr1 | sx decode-addr` ] equalverify checksig > raw.script
cat pk1 | sx sign-input txfile.tx 0 `cat raw.script` > sig
sx rawscript [ `cat sig` ] [ `cat pub1` ] | sx set-input txfile.tx 0
sx broadcast-tx txfile.tx

Any ideas?

Thanks
legendary
Activity: 1232
Merit: 1076
Code:
$ sx help validtx
Usage: sx validtx FILENAME
Validate a transaction.
$ sx validtx footx
Status: Success
$ sx validtx txfile.tx
Status: Matching previous object found
$ sx validtx badsignature.tx
Status: Validation of inputs failed
$
legendary
Activity: 1232
Merit: 1076
Thanks all. I've added lots more commands for fetching raw transactions and working with block headers. The help should display all.
legendary
Activity: 3710
Merit: 1586
Interesting. I especially like the electrum compatible wallet creation. But will wait for experts to go through the code.

BTW the OP has his own wikipedia page:

http://en.wikipedia.org/wiki/Amir_Taaki
full member
Activity: 154
Merit: 100
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.
legendary
Activity: 1232
Merit: 1076
Run 'g++ --version'

Your compiler should be 4.7 or higher. I think you might have an older version.


I'm sorry but I always get:

In file included from ./../include/bitcoin/utility/big_number.hpp:6:0,
                 from ./../include/bitcoin/constants.hpp:6,
                 from ./../include/bitcoin/satoshi_serialize.hpp:4,
                 from satoshi_serialize.cpp:1:
./../include/bitcoin/types.hpp:24:9: error: 'atomic' in namespace 'std' does not name a type
./../include/bitcoin/types.hpp:25:25: error: 'atomic_counter' was not declared in this scope
./../include/bitcoin/types.hpp:25:39: error: template argument 1 is invalid
./../include/bitcoin/types.hpp:25:59: error: invalid type in declaration before ';' token
make[1]: *** [satoshi_serialize.lo] Error 1
make[1]: Leaving directory `/usr/local/src/libbitcoin-git/src'
make: *** [all-recursive] Error 1

on the "libtool: compile" line.

I tried to re-run the install.sh lines one by one, and libbitcoin-git seems to make it into /usr/local/src/ but then later on terminal seems to say that libbitcoin is not available. It suggested setting a directory but I could not figure it out."

This is just like Gavin's multisig example, which I couldn't figure out either! DARN.

Help would be appreciated.
member
Activity: 115
Merit: 10
I'm sorry but I always get:

In file included from ./../include/bitcoin/utility/big_number.hpp:6:0,
                 from ./../include/bitcoin/constants.hpp:6,
                 from ./../include/bitcoin/satoshi_serialize.hpp:4,
                 from satoshi_serialize.cpp:1:
./../include/bitcoin/types.hpp:24:9: error: 'atomic' in namespace 'std' does not name a type
./../include/bitcoin/types.hpp:25:25: error: 'atomic_counter' was not declared in this scope
./../include/bitcoin/types.hpp:25:39: error: template argument 1 is invalid
./../include/bitcoin/types.hpp:25:59: error: invalid type in declaration before ';' token
make[1]: *** [satoshi_serialize.lo] Error 1
make[1]: Leaving directory `/usr/local/src/libbitcoin-git/src'
make: *** [all-recursive] Error 1

on the "libtool: compile" line.

I tried to re-run the install.sh lines one by one, and libbitcoin-git seems to make it into /usr/local/src/ but then later on terminal seems to say that libbitcoin is not available. It suggested setting a directory but I could not figure it out."

This is just like Gavin's multisig example, which I couldn't figure out either! DARN.

Help would be appreciated.
legendary
Activity: 1232
Merit: 1076
Question: Does sx support multi-sig transactions?

multisignature now works:

Code:
===============================
Multisignature N-M Transactions
===============================

This example will create a 2-3 multisignature transaction but these
instructions can be easily generalised for other types.

Firstly we will create 3 keypairs.

  $ sx newkey > key1
  $ cat key1 | sx addr
  15xG6FE45vjuEdQQamvvgRPzrdzvZAxAyJ
  $ sx newkey > key2
  $ cat key2 | sx addr
  12GhrHLu4K5LL8hNkyMZZXz3u7QJc5Qjsc
  $ sx newkey > key3
  $ cat key3 | sx addr
  1KWv6rPrXzggQNkQrz8Leq1DhDm1b3y23r

For multisignature stuff we will need to use the public keys of the keypairs.
We use bash substitution below for convenience.

  $ sx rawscript 2 [ $(cat key1 | sx pubkey) ] [ $(cat key2 | sx pubkey) ] [
$(cat key3 | sx pubkey) ] 3 checkmultisig > msig.script

The file 'msig.script' now stores the hex representation of that script.
We can display it at anytime using:

  $ cat msig.script | sx showscript
  2 [ 04cb9c3c222c5f7a7d3b9bd152f363a0b6d54c9eb312c4d4f9af1e8551b6c421a6a4ab0e29105f24de20ff463c1c91fcf3bf662cdde4783d4799f787cb7c08869b ] [ 04ccc588420deeebea22a7e900cc8b68620d2212c374604e3487ca08f1ff3ae12bdc639514d0ec8612a2d3c519f084d9a00cbbe3b53d071e9b09e71e610b036aa2 ] [ 04ab47ad1939edcb3db65f7fedea62bbf781c5410d3f22a7a3a56ffefb2238af8627363bdf2ed97c1f89784a1aecdb43384f11d2acc64443c7fc299cef0400421a ] 3 checkmultisig

Now we generate the multisignature Bitcoin address (which always begins
with the number 3):

  $ cat msig.script | sx scripthash
  34CRZpt8j81rgh9QhzuBepqPi4cBQSjhjr

Send some bitcoin to that address!

This is my transaction:

https://blockchain.info/tx/e2124d25a7f6fe0d5dd5dd78ba7d98f60f8c47be9c91699e649e04118d531f52

---------------------------------
Spending the multisignature coins
---------------------------------

We create the basic transaction.

  $ sx mktx txfile.tx -i e2124d25a7f6fe0d5dd5dd78ba7d98f60f8c47be9c91699e649e04118d531f52:0 -o 1Fufjpf9RM2aQsGedhSpbSCGRHrmLMJ7yY:9900000
  Added input e2124d25a7f6fe0d5dd5dd78ba7d98f60f8c47be9c91699e649e04118d531f52:0
  Added output sending 9900000 Satoshis to 1Fufjpf9RM2aQsGedhSpbSCGRHrmLMJ7yY.

The transaction has a fee of 0.001 BTC and is saved in the file named
'txfile.tx'.

It has a single input which we will generate the signatures for, create the
script and then set the input.

Use the sx command 'showtx' to show a transaction.

In our example we will emit the first signature and only use key2 and key3.

We use the opcode 'zero' to represent the emitted signature of key1.

Sign an input using:

  $ cat key2 | sx sign-input txfile.tx 0  $(cat msig.script)
  3046022100a147c529f7dfa291ceb2c2f21094ca101a1cfe7036cda18935d6899111cad76b022100c0d6392bdd9b31e0e3fe13dce3d928cf6857b411b6e05f35f12403b877c26bad01
  $ cat key3 | sx sign-input txfile.tx 0  $(cat msig.script)
  3046022100957f0bfdd476f2d8985268d7964168f6b7e43f54089f8fbff35a4f62e7a221f9022100be8f565e30781d353d71f54202009fe14b8203151d235ba6bf3db2b531680bca01

Our example will use bash substitution again.

  $ sx rawscript zero [ $(cat key2 | sx sign-input txfile.tx 0 $(cat msig.script)) ] [ $(cat key3 | sx sign-input txfile.tx 0 $(cat msig.script)) ] [ $(cat msig.script) ] | sx set-input txfile.tx 0

The transaction is finalised! Broadcast it:

  $ sx broadcast-tx txfile.tx

https://blockchain.info/tx/d646f82bd5fbdb94a36872ce460f97662b80c3050ad3209bef9d1e398ea277ab

offline multisignature tx = micropayment channels (exchange raw tx, sign your input, exchange signatures)

or you can do offline tx + MPK with multisig for doubly secure offline wallet.
legendary
Activity: 1232
Merit: 1076
Not yet. Will do.

New easy install/update script:

START HERE:

Code:
  $ wget http://sx.dyne.org/install-sx.sh
  $ sudo bash ./install-sx.sh

sx should now be installed.

Enjoy!

Special thanks to Andrew Day and Vitalik Buterin. Big thanks to Santiago Mendez who put in the time to help me improve the tools offering valuable feedback.
hero member
Activity: 938
Merit: 501
Question: Does sx support multi-sig transactions?
legendary
Activity: 1792
Merit: 1008
/dev/null
thanks genjix, this will save alot time in the future Smiley
hero member
Activity: 742
Merit: 500
 Maybe I missed it. Why the name "sx"?

Very cool.
Pages:
Jump to: