Commit c5909cd63bb6eddf0b0c95cea461d28a846d7620

Authored by Marius Hanne
1 parent d01c14e56f
Exists in wallet

document bitcoin_wallet usage in README

Showing 1 changed file with 62 additions and 16 deletions Side-by-side Diff

... ... @@ -20,45 +20,91 @@
20 20  
21 21 == Demos
22 22  
23   -There are a few demo scripts you can run to try things out:
  23 +There are a few demo scripts in bin/ you can run to try things out:
24 24  
25   -=== bin/bitcoin_connect
  25 +=== bitcoin_connect
26 26  
27 27 Connect to a network node and chat a little.
28 28  
29   -=== bin/bitcoin_blockchain
  29 +=== bitcoin_blockchain
30 30  
31 31 Connect to a node and download the whole blockchain into storage.
32 32  
33   - ./bin/bitcoin_blockchain # connects to testnet using dummy store
34   - ./bin/bitcoin_blockchain -n bitcoin -s sequel::postgres///bitcoin
35   - ./bin/bitcoin_blockchain -h
  33 + bitcoin_blockchain # connects to testnet using dummy store
  34 + bitcoin_blockchain -n bitcoin -s sequel::postgres///bitcoin
  35 + bitcoin_blockchain -h
36 36  
37   -=== bin/bitcoin_verify_tx
  37 +=== bitcoin_verify_tx
38 38  
39 39 Fetch a transaction and all its prev_outs from local storage
40 40 and verify the signatures.
41 41  
42   - ./bin/bitcoin_verify_tx [options] <tx_hash>
43   - ./bin/bitcoin_verify_tx -s sequel::postgres:///bitcoin 0f6741210a02e196ca5f5ad17f684968623546c1accdbcb701a668a51a7ba9fd
  42 + bitcoin_verify_tx [options] <tx_hash>
  43 + bitcoin_verify_tx -s sequel::postgres:/bitcoin 0f6741210a02e196ca5f5ad17f684968623546c1accdbcb701a668a51a7ba9fd
44 44  
45 45 Note: For this to work, you obviously need to have the transactions in your storage.
46 46  
47   -=== bin/bbe_verify_tx
  47 +=== bbe_verify_tx
48 48  
49 49 In case you don't have a local storage, this script fetches a transaction and
50 50 all its prev_outs from blockexplorer.com and verifies the signatures.
51 51  
52   - ./bin/bbe_verify_tx <tx_hash> [testnet]
  52 + bbe_verify_tx <tx_hash> [testnet]
53 53  
54   -=== bin/bitcoin_balance
  54 +=== bitcoin_balance
55 55  
56 56 Collect transactions and display balance for an address.
57 57  
58   - ./bin/bitcoin_balance -s sequel::postgres:///bitcoin -l moz14kFmgHPszRvS6rvhfEVYmx4RbcNMfH
  58 + bitcoin_balance -s sequel::postgres:/bitcoin -l moz14kFmgHPszRvS6rvhfEVYmx4RbcNMfH
59 59  
60   -=== bin/bitcoin_shell
  60 +=== bitcoin_wallet
61 61  
  62 +To use the wallet you should create a configfile. It's not required but more convenient.
  63 +Default paths are `./bitcoin-ruby.yml`, `~/.bitcoin-ruby.yml` and `/etc/bitcoin-ruby.yml`.
  64 +
  65 + network: bitcoin
  66 + keystore: "simple::file=keys.json"
  67 + # keystore: "deterministic::seed=foo,nonce=2116,keys=7"
  68 + storage: "sequel::postgres:/bitcoin"
  69 + node: "127.0.01:9999" # command socket of a node to relay the transaction
  70 +
  71 +The `simple` keystore will create one key and put it into the given file.
  72 +You can later ask it to generate more keys.
  73 +
  74 +The `deterministic` keystore uses the seed (which should be a large, unique, random string!)
  75 +and generates the given number of keys. The nonce is optional, it just speeds up finding the first key.
  76 +See Bitcoin::Wallet::KeyGenerator for details.
  77 +
  78 +Then you can list all addresses in the wallet:
  79 +
  80 + bitcoin_wallet list
  81 +
  82 +Display transaction history for a specific address:
  83 +
  84 + bitcoin_wallet list <address>
  85 +
  86 +Create new keys/addresses (only with `simple` keystore; with `deterministic` you have to edit your config):
  87 +
  88 + bitcoin_wallet new
  89 +
  90 +Import keys from base58 format:
  91 +
  92 + bitcoin_wallet import <base58>
  93 +
  94 +Export keys to base58 format:
  95 +
  96 + bitcoin_wallet export <address>
  97 +
  98 +And finally send bitcoins to an address:
  99 +
  100 + bitcoin_wallet send <address>:<amount> [<fee>]
  101 + bitcoin_wallet send 1GQkkFvAFW2ts3YLnEvMnu76WyCB6yDb4d:0.1 0.005
  102 +
  103 +This will create a transaction and display it, asking for confirmation.
  104 +If you accept, it will be sent to your node and relayed to the rest of the network.
  105 +
  106 +=== bitcoin_shell
  107 +
62 108 Launches an irb session with bitcoin loaded where you can try stuff out.
63 109  
64 110  
... ... @@ -70,7 +116,7 @@
70 116  
71 117 dummy
72 118 sequel::sqlite:///tmp/bitcoin.db
73   - sequel::postgres:///bitcoin
  119 + sequel::postgres:/bitcoin
74 120 sequel::postgres://user:pass@host/database
75 121  
76 122  
... ... @@ -158,7 +204,7 @@
158 204 and activerecord/postgres backend.
159 205  
160 206 store = Bitcoin::Storage.dummy # or:
161   - store = Bitcoin::Storage.sequel(:db => "postgres:///bitcoin")
  207 + store = Bitcoin::Storage.sequel(:db => "postgres:/bitcoin")
162 208 store.store_block(Bitcoin.network[:genesis_block])
163 209 store.get_block(Bitcoin.network[:genesis_hash])
164 210 store.get_head #=> Bitcoin.network[:genesis_hash]