:: [unSYSTEM] sx Bitcoin utilities (ne…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Amir Taaki
日付:  
To: unsystem
題目: [unSYSTEM] sx Bitcoin utilities (new installation instructions and information inside)
Hi!

My aim with this project is to provide a set of modular Bitcoin
commandline utilities, that admin types can engage with Bitcoin
functionality without having to write code.

By chaining all these commands together in different ways, you can do
offline transactions, maintain a wallet, work with deterministic keys, ...

It would be cool to see Bitcoin wallets written in bash script using
these tools to handle the core functionality. I believe the more we
give good tools to the community, the more we can decentralise
development and increase access to the core technology for all types.

Use this bash shell script to install sx:
http://libbitcoin.dyne.org/install-sx.sh

ArchLinux users: https://aur.archlinux.org/packages/sx-git/

==========================
Debian/Ubuntu Instructions
==========================

VVVVVVVVVVV
> Start Here! <

^^^^^^^^^^^

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


sx should now be installed.

Enjoy!

    Installation commencing NOW.
    ...


============
Instructions
============

Development repository:

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

My Bitcoin address (from http://libbitcoin.dyne.org/):

1Fufjpf9RM2aQsGedhSpbSCGRHrmLMJ7yY

I want your feedback and suggestions! amir@???

http://i.imgur.com/8R0cfuw.png

Type sx-TAB to see a list of all the sx commands.

-------------------|-------------------------------------------
| sx-addr           | See Bitcoin address of a private key.     |

|-------------------|-------------------------------------------|
| sx-broadcast-tx   | Broadcast tx to network.                  |

|-------------------|-------------------------------------------|
| sx-mktx           | Create an unsigned tx.                    |

|-------------------|-------------------------------------------|
| sx-newkey         | Create a new private key.                 |

|-------------------|-------------------------------------------|
| sx-newseed        | Create a new deterministic wallet seed.   |

|-------------------|-------------------------------------------|
| sx-mpk            | Extract a master public key from a        |
|                   | deterministic wallet seed.                |

|-------------------|-------------------------------------------|
| sx-genpriv        | Generate a private key deterministically  |
|                   | from a seed.                              |

|-------------------|-------------------------------------------|
| sx-genpub         | Generate a Bitcoin address                |
|                   | deterministically from a                  |
|                   | master public key.                        |

|-------------------|-------------------------------------------|
| sx-mnemonic       | Work with Electrum compatible mnemonics   |
|                   | (12 words wallet seed).                   |

|-------------------|-------------------------------------------|
| sx-sendtx         | Send transaction to a single node.        |

|-------------------|-------------------------------------------|
| sx-showtx         | Show the details of a transaction.        |

|-------------------|-------------------------------------------|
| sx-sign-input     | Sign a transaction input.                 |

|-------------------|-------------------------------------------|
| sx-genqr          | Generate Bitcoin QR codes offline.        |

|-------------------|-------------------------------------------|
| sx-balance        | Show balance of an address.               |

|-------------------|-------------------------------------------|
| sx-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.                         |

|-------------------|-------------------------------------------|
| sx-watchtx        | Watch transactions from the network       |
|                   | searching for a certain hash.             |

-------------------|-------------------------------------------

=====================
Simple Bitcoin Client
=====================

Try this to make a mini-wallet.

$ cd src/
$ sx-newkey
5KPFsatiYrJcvCSRrDbtx61822vZjeGGGx3wu38pQDHRF8eVJ8H
$ sx-newkey > private.key
$ cat private.key | sx-addr
134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz

Now send some funds to your address (0.01 BTC).

In this example we will send the funds to 13Ft7SkreJY9D823NPm4t6D1cBqLYTJtAe.

100000 Satoshis (0.001 BTC) in total.
90000 Satoshis (0.0009 BTC) to send.
10000 Satoshis (0.0001 BTC) for the fee.

Use blockchain.info (or the history tool provided here) to lookup the
output for this address. Note down the transaction hash and transaction
index.

Here is a screenshot of blockchain.info: http://i.imgur.com/dZvqJIV.png

We can see the tx hash is:
97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3
And there is a single output at index 1 that we want to spend.

Construct the transaction:

$ sx-mktx txfile.tx -i
97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3:1 -o
13Ft7SkreJY9D823NPm4t6D1cBqLYTJtAe:90000

Because there is 100000 Satoshis going in, but only 9000 Satoshis out,
the remaining 10000 Satoshis (0.0001 BTC) will be taken by the Bitcoin
network as a fee. This is how fees work internally in Bitcoin.

'showtx' allows inspecting of tx files.

  $ sx-showtx txfile.tx
  hash: 4d25b18ed094ad68f75f21692d8540f45ceb90b240a521b8f191e95d8b6b8bb0
  version: 1  locktime: 0
  Input:
    previous output:
  97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3:0
    script:   sequence: 4294967295
  Output:
    value: 90000
    script: dup hash160 [ 18c0bd8d1818f1bf99cb1df2269c645318ef7b73 ]
equalverify
  checksig
    address: 13Ft7SkreJY9D823NPm4t6D1cBqLYTJtAe


Note that the input script is empty.

We will now sign the first input using our private key.

  $ cat private.key | sx-sign-input txfile.tx 0
  $ sx-showtx txfile.tx
  hash: 4a8be467fb75f0f757649348dbb05762142236ec236ac9e55e4683d7083ffca2
  version: 1  locktime: 0
  Input:
    previous output:
  97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3:0
    script: [
  304602210083f8b5131f6399cdc01ed8368f6137f288f771e40834a94d65cee6b380fec873022100da5ed6d1d283f228752a88c2d6f629587b2a6fbc102202ae7c20f48af7c0533c01
  ] [
  04e3af7cdfaab6ba2f14001a7ea0a490f40c6ba43607be92a05111d2e8fc1eecf6fa2c248b3e25ddf7db081684f6f49dc83fd7b9b5a3a88a2e6b83b918f8972351
  ]  sequence: 4294967295
    address: 134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz
  Output:
    value: 90000
    script: dup hash160 [ 18c0bd8d1818f1bf99cb1df2269c645318ef7b73 ]
equalverify
  checksig
    address: 13Ft7SkreJY9D823NPm4t6D1cBqLYTJtAe


Now the input script is prepared, and the tx is signed.

Broadcast the final tx to the Bitcoin network.

$ sx-broadcast-tx txfile.tx

Or to send it to one Bitcoin node (like a localhost one), then use:

$ sx-sendtx txfile.tx localhost 4009

=================
QR Code Generator
=================

$ sudo apt-get install qrencode
$ sx-genqr 13Ft7SkreJY9D823NPm4t6D1cBqLYTJtAe qrcode.png

====================
Deterministic Wallet
====================

$ sx-newseed > wallet.seed
$ cat wallet.seed
b220b5bd2909df1d74b71c9e664233bf
$ cat wallet.seed | sx-mpk > master_public.key

Now you can generate your private keys for whatever number:

$ cat wallet.seed | sx-genpriv 0
5Jmb4EYzEqj63rkPwADFY7WyGV2kga3YB1HfDAzg9dHNG57NMPu
$ cat wallet.seed | sx-genpriv 1
5KjCYpPyxU2e88S57b1naKUsJ1JNjCudkFSQPxqcYyBYgzzahNe

You can use either the master_public.key or the wallet.seed for generating
Bitcoin receive addresses. But you cannot use the master_public.key for
generating the private keys for spending those Bitcoins.

$ cat master_public.key | sx-genpub 0
1a4b47AC4ydSnAAcTNH1qozHq2pwJb644
$ cat wallet.seed | sx-genpub 0
1a4b47AC4ydSnAAcTNH1qozHq2pwJb644

For Electrum compatible 12 word seeds, use the mnemonic tool.

$ echo 148f0a1d77e20dbaee3ff920ca40240d | sx-mnemonic
people blonde admit dart couple different truth common alas stumble time
cookie
$ echo "people blonde admit dart couple different truth common alas
stumble time cookie" | sx-mnemonic
148f0a1d77e20dbaee3ff920ca40240d

==========================
balance/history (Advanced)
==========================

The balance/history tools use a network connection to make requests
against the load balancer backend.

  $ echo 134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz | sx-balance
  100000
  $ echo 134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz | sx-history
  Output Hash:Index                           Output Height   Value
(Satoshis) Spend Hash:Index                Spend Height
  97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3:1 
247683 100000      Unspent                                 230529504


It's possible to run as many backend workers as you like. The
load balancer (obbalancer) will distribute requests evenly among the
backends.
Use worker-output.sh to view debug info from the worker. Each worker must
have their own unique copy of the blockchain database.

See the Obelisk config files in /usr/local/etc/obelisk/. The sx config file
is stored at /usr/local/etc/sx.cfg. You can change this configuration
parameter using './configure --sysconfigdir=/etc/'. By configuring different
workers and load balancers, you can run multiple setups on the same host.
By default it is no pointing at my development server, but I will change this
soon and migrate to a new host. Also I make no guarantees about stability or
compatibility.