genjix





Offline



Activity: 1232

Merit: 1000







LegendaryActivity: 1232Merit: 1000 sx command line utilities - Empower The Sysadmin With Bitcoin Tools July 21, 2013, 03:54:21 PM

Last edit: May 29, 2014, 08:20:00 PM by genjix #1



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/

Website (tutorial): https://sx.dyne.org/ List of commands:Install globally:Install locally (non-root):

stevenh512



Offline



Activity: 137

Merit: 100









Full MemberActivity: 137Merit: 100 Re: sx command line utilities - Empower The Sysadmin With Bitcoin Tools July 22, 2013, 01:55:24 PM #4



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. Electrum compatible is probably good enough for now.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.

genjix





Offline



Activity: 1232

Merit: 1000







LegendaryActivity: 1232Merit: 1000 Re: sx command line utilities - Empower The Sysadmin With Bitcoin Tools July 24, 2013, 01:39:30 AM

Last edit: July 26, 2013, 10:02:21 PM by genjix #12



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. Not yet. Will do.New easy install/update script:START HERE: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.

genjix





Offline



Activity: 1232

Merit: 1000







LegendaryActivity: 1232Merit: 1000 Re: sx command line utilities - Empower The Sysadmin With Bitcoin Tools August 02, 2013, 09:41:27 PM

Last edit: August 03, 2013, 08:47:36 AM by genjix #13 Quote from: hahahafr on July 24, 2013, 12:17:31 AM 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.

multisignature now works: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.