Bitcoin Forum
September 04, 2015, 09:01:43 PM *
News: New! Latest stable version of Bitcoin Core: 0.11.0 [Torrent]
 
   Home   Help Search Donate Login Register  
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 »  All
  Print  
Author Topic: sx command line utilities - Empower The Sysadmin With Bitcoin Tools  (Read 194544 times)
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 21, 2013, 03:54:21 PM
 #1

Website (tutorial): https://sx.dyne.org/

List of commands:

Code:
$ sx help
Usage: sx COMMAND [ARGS]...

  -c, --config               Specify a config file

The sx commands are:

CREATE TRANSACTIONS
   mktx                       Create an unsigned tx.
   rawscript                  Create the raw hex representation from a script.
   set-input                  Set a transaction input.
   sign-input                 Sign a transaction input.

DETERMINISTIC KEYS AND ADDRESSES
   genaddr                    Generate a Bitcoin address deterministically from a wallet
                              seed or master public key.
   genpriv                    Generate a private key deterministically from a seed.
   genpub                     Generate a public key deterministically from a wallet
                              seed or master public key.
   mpk                        Extract a master public key from a deterministic wallet seed.
   newseed                    Create a new deterministic wallet seed.

TRANSACTION PARSING
   showscript                 Show the details of a raw script.
   showtx                     Show the details of a transaction.

BLOCKCHAIN QUERIES (blockexplorer.com)
   blke-fetch-transaction     Fetches a transaction from blockexplorer.com

FORMAT
   base58-decode              Convert from base58 to hex
   base58-encode              Convert from hex to base58
   base58check-decode         Convert from base58check to hex
   base58check-encode         Convert from hex to base58check
   decode-addr                Decode an address to its internal RIPEMD representation.
   embed-addr                 Generate an address used for embedding record of data into the blockchain.
   encode-addr                Encode an address to base58check form.
   ripemd-hash                RIPEMD hash data from STDIN.
   unwrap                     Validates checksum and recovers version byte and original data from hexstring.
   validaddr                  Validate an address.
   wrap                       Adds version byte and checksum to hexstring.

BRAINWALLET
   brainwallet                Make a private key from a brainwallet
   mnemonic                   Work with Electrum compatible mnemonics (12 words wallet seed).

BLOCKCHAIN WATCHING
   monitor                    Monitor an address.
   watchtx                    Watch transactions from the network searching for a certain hash.

BLOCKCHAIN QUERIES (blockchain.info)
   bci-fetch-last-height      Fetch the last block height using blockchain.info.
   bci-history                Get list of output points, values, and their spends
                              from blockchain.info

MISC
   btc                        Convert Satoshis into Bitcoins.
   initchain                  Initialize a new blockchain.
   qrcode                     Generate Bitcoin QR codes offline.
   satoshi                    Convert Bitcoins into Satoshis.
   sha256                     Perform SHA256 hash of data.
   showblkhead                Show the details of a block header.
   wallet                     Experimental command line wallet.

MULTISIG ADDRESSES
   scripthash                 Create BIP 16 script hash address from raw script hex.

LOOSE KEYS AND ADDRESSES
   addr                       See Bitcoin address of a public or private key.
   get-pubkey                 Get the pubkey of an address if available
   newkey                     Create a new private key.
   pubkey                     See the public part of a private key.
   secret-to-wif              Convert a secret exponent value to Wallet. Import. Format.
   wif-to-secret              Convert a Wallet. Import. Format to secret exponent value.

STEALTH
   stealth-addr               See a stealth address from given input.
   stealth-initiate           Initiate a new stealth payment.
   stealth-newkey             Generate new stealth keys and an address.
   stealth-show-addr          Show details for a stealth address.
   stealth-uncover            Uncover a stealth address.
   stealth-uncover-secret     Uncover a stealth secret.

EC MATH
   ec-add-modp                Calculate the result of INTEGER + INTEGER.
   ec-multiply                Multiply an integer and a point together.
   ec-tweak-add               Calculate the result of POINT + INTEGER * G.

VALIDATE
   validsig                   Validate a transaction input's signature.

BLOCKCHAIN QUERIES
   balance                    Show balance of a Bitcoin address in satoshis.
   fetch-block-header         Fetch raw block header.
   fetch-last-height          Fetch the last block height.
   fetch-stealth              Fetch a stealth information using a network connection to
                              make requests against the obelisk load balancer backend.
   fetch-transaction          Fetch a raw transaction using a network connection to
                              make requests against the obelisk load balancer backend.
   fetch-transaction-index    Fetch block height and index in block of transaction.
   get-utxo                   Get enough unspent transaction outputs from a given set of
                              addresses to pay a given number of satoshis
   history                    Get list of output points, values, and their spends for an
                              address. grep can filter for just unspent outputs which can
                              be fed into mktx.
   validtx                    Validate a transaction.

BLOCKCHAIN UPDATES
   sendtx-bci                 Send tx to blockchain.info/pushtx.
   sendtx-node                Send transaction to a single node.
   sendtx-obelisk             Send tx to obelisk server.
   sendtx-p2p                 Send tx to bitcoin network.

HD KEYS
   hd-priv                    Create an private HD key from another HD private key.
   hd-pub                     Create an HD public key from another HD private or public key.
   hd-seed                    Create a random new HD key.
   hd-to-address              Convert an HD public or private key to a Bitcoin address.
   hd-to-wif                  Convert an HD private key to a WIF private key.

See 'sx help COMMAND' for more information on a specific command.

SpesmiloXchange home page: <http://sx.dyne.org/>

Install globally:

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

Install locally (non-root):

Code:
$ wget https://sx.dyne.org/install-sx.sh
$ bash install-sx.sh usr/

Donate to DarkWallet
1441400503
Hero Member
*
Offline Offline

Posts: 1441400503

View Profile Personal Message (Offline)

Ignore
1441400503
Reply with quote  #2

1441400503
Report to moderator
1441400503
Hero Member
*
Offline Offline

Posts: 1441400503

View Profile Personal Message (Offline)

Ignore
1441400503
Reply with quote  #2

1441400503
Report to moderator
1441400503
Hero Member
*
Offline Offline

Posts: 1441400503

View Profile Personal Message (Offline)

Ignore
1441400503
Reply with quote  #2

1441400503
Report to moderator
PACMiC V3 Now 33% less per TH/s. Available only on HashNest
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1441400503
Hero Member
*
Offline Offline

Posts: 1441400503

View Profile Personal Message (Offline)

Ignore
1441400503
Reply with quote  #2

1441400503
Report to moderator
stevenh512
Full Member
***
Offline Offline

Activity: 134



View Profile

Ignore
July 22, 2013, 12:22:40 PM
 #2

Interesting, I can see how these tools could be extremely useful for sysadmins and power users.

You mentioned deterministic wallets, are these BIP-32 compatible?

This signature intentionally left blank.
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 22, 2013, 12:42:23 PM
 #3

Interesting, I can see how these tools could be extremely useful for sysadmins and power users.

You mentioned deterministic wallets, are these BIP-32 compatible?

No, they are Electrum compatible. BIP-32 wallets will happen once Electrum and other clients start using them, and I have an implementation to follow and understand how to design a nice API for libbitcoin.

Donate to DarkWallet
stevenh512
Full Member
***
Offline Offline

Activity: 134



View Profile

Ignore
July 22, 2013, 01:55:24 PM
 #4

Electrum compatible is probably good enough for now. Smiley

The latest Electrum from GitHub does have an up-to-date BIP-32 implementation, but I don't think there's any way to actually use it in Electrum yet. There are also a couple other Python and Java implementations on GitHub but I don't know how up to date those are.

This signature intentionally left blank.
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


View Profile

Ignore
July 22, 2013, 02:53:35 PM
 #5

Very cool.   It is much like my recently introduced txtool utility.

I tend to prefer the git-like sub-command model, rather than putting all the utilities in PATH.


Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 22, 2013, 06:03:03 PM
 #6

Very cool.   It is much like my recently introduced txtool utility.

I tend to prefer the git-like sub-command model, rather than putting all the utilities in PATH.



Yeah the point is that the installer should put them in a non-default location with a prefix like sx.newkey and then a bash script provides the wrapper on top together with the help and everything.

Donate to DarkWallet
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 23, 2013, 02:04:01 AM
 #7

Created a nice cheatsheet.


Donate to DarkWallet
Red Emerald
Hero Member
*****
Offline Offline

Activity: 728



View Profile WWW

Ignore
July 23, 2013, 02:36:13 AM
 #8

 Maybe I missed it. Why the name "sx"?

Very cool.

genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 23, 2013, 09:47:21 AM
 #9

The original: https://bitcointalk.org/index.php?topic=50721.0

Donate to DarkWallet
K1773R
Legendary
*
Offline Offline

Activity: 1260


/dev/null


View Profile

Ignore
July 23, 2013, 10:46:08 AM
 #10

thanks genjix, this will save alot time in the future Smiley

[GPG Public Key]  [Devcoin Builds]  [BBQCoin Builds]  [Multichain Blockexplorer]  [Multichain Blockexplorer - PoS Coins]  [Ufasoft Miner Linux Builds]
BTC/DVC/TRC/FRC: 1K1773RbXRZVRQSSXe9N6N2MUFERvrdu6y ANC/XPM AK1773RTmRKtvbKBCrUu95UQg5iegrqyeA NMC: NK1773Rzv8b4ugmCgX789PbjewA9fL9Dy1 LTC: LKi773RBuPepQH8E6Zb1ponoCvgbU7hHmd EMC: EK1773RxUes1HX1YAGMZ1xVYBBRUCqfDoF BQC: bK1773R1APJz4yTgRkmdKQhjhiMyQpJgfN
hahahafr
Full Member
***
Offline Offline

Activity: 232



View Profile

Ignore
July 24, 2013, 12:17:31 AM
 #11

Question: Does sx support multi-sig transactions?

genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
July 24, 2013, 01:39:30 AM
 #12

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.

Donate to DarkWallet
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
August 02, 2013, 09:41:27 PM
 #13

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.

Donate to DarkWallet
AsymmetricInformation
Member
**
Offline Offline

Activity: 115


View Profile WWW

Ignore
August 04, 2013, 05:32:14 PM
 #14

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.

Support Decentralized Bitcoin Prediction Markets: 1M5tVTtynuqiS7Goq8hbh5UBcxLaa5XQb8
https://github.com/psztorc/Truthcoin
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
August 05, 2013, 03:09:00 PM
 #15

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.

Donate to DarkWallet
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
August 08, 2013, 05:00:01 PM
 #16

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.

Donate to DarkWallet
juca
Full Member
***
Offline Offline

Activity: 154



View Profile

Ignore
August 10, 2013, 08:58:54 PM
 #17

thanks for all!
Abdussamad
Legendary
*
Offline Offline

Activity: 840



View Profile WWW

Ignore
August 13, 2013, 06:58:09 AM
 #18

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

genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
August 16, 2013, 11:42:46 AM
 #19

Thanks all. I've added lots more commands for fetching raw transactions and working with block headers. The help should display all.

Donate to DarkWallet
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


View Profile

Ignore
August 18, 2013, 02:58:52 AM
 #20

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
$

Donate to DarkWallet
Pages: [1] 2 3 4 5 6 7 8 9 10 11 12 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!