:: [unSYSTEM] sx - Empower The Sysadmi…
Góra strony
Delete this message
Reply to this message
Autor: Amir Taaki
Data:  
Dla: unsystem
Temat: [unSYSTEM] sx - Empower The Sysadmin With Bitcoin Tools
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.

Enjoy!

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

- ---------------

Build:

$ autoreconf -i
$ ./configure
$ make

Try this to make a mini-wallet.

$ cd src/
$ ./newpriv > private.key
$ ./addr < private.key
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/YuQuLW4.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:

$ ./mktx 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.

  $ ./showtx 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.

  $ ./sign-input tx 0 < private.key
  $ ./showtx 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.

$ ./broadcast-tx tx

- --------------------
Deterministic Wallet
- --------------------

$ ./newseed > wallet.seed
$ ./mpk < wallet.seed > master_public_key
$ ./genpriv 0 < wallet.seed > key0
$ ./genpub 0 < master_public_key

- --------------------------
balance/history (Advanced)
- --------------------------

To use these 2 tools, you will need Obelisk:

$ cd ~
$ git clone https://github.com/genjix/obelisk
$ cd obelisk
$ ./build.sh

Make sure you have an up to date version of the blockchain available:

$ cd worker
$ ./download-blockchain.sh

You can edit worker.cfg to configure the backend Bitcoin node(s).

$ cd ~/obelisk/
$ ./queue/ppqueue &
$ ./worker/obworker

It's possible to run as many backend workers as you like. The
load balancer (ppqueue) 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.

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

$ cd ~/subx/src/
$ cd balance
$ make
$ cd ../history
$ make
$ cd ..

  $ ./balance/balance 134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz
  100000
  $ ./history/history 134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz
  Output Hash:Index                           Output Height   Value
(Satoshis) Spend Hash:Index                Spend Height
  97e06e49dfdd26c5a904670971ccf4c7fe7d9da53cb379bf9b442fc9427080b3:1
247683 100000      Unspent                                 230529504