bitcoin-ruby 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +2 -7
  4. data/COPYING +1 -1
  5. data/Gemfile +2 -6
  6. data/Gemfile.lock +34 -0
  7. data/README.rdoc +16 -68
  8. data/Rakefile +3 -6
  9. data/bin/bitcoin_shell +0 -1
  10. data/{concept-examples/blockchain-pow.rb → examples/concept-blockchain-pow.rb} +0 -0
  11. data/lib/bitcoin.rb +350 -296
  12. data/lib/bitcoin/builder.rb +3 -1
  13. data/lib/bitcoin/connection.rb +2 -1
  14. data/lib/bitcoin/contracthash.rb +76 -0
  15. data/lib/bitcoin/dogecoin.rb +97 -0
  16. data/lib/bitcoin/ffi/bitcoinconsensus.rb +74 -0
  17. data/lib/bitcoin/ffi/openssl.rb +98 -2
  18. data/lib/bitcoin/ffi/secp256k1.rb +144 -0
  19. data/lib/bitcoin/key.rb +12 -2
  20. data/lib/bitcoin/logger.rb +3 -12
  21. data/lib/bitcoin/protocol/block.rb +3 -9
  22. data/lib/bitcoin/protocol/parser.rb +6 -2
  23. data/lib/bitcoin/protocol/tx.rb +44 -13
  24. data/lib/bitcoin/protocol/txin.rb +4 -2
  25. data/lib/bitcoin/protocol/txout.rb +2 -2
  26. data/lib/bitcoin/script.rb +212 -37
  27. data/lib/bitcoin/trezor/mnemonic.rb +130 -0
  28. data/lib/bitcoin/version.rb +1 -1
  29. data/spec/bitcoin/bitcoin_spec.rb +32 -3
  30. data/spec/bitcoin/builder_spec.rb +18 -0
  31. data/spec/bitcoin/contracthash_spec.rb +45 -0
  32. data/spec/bitcoin/dogecoin_spec.rb +176 -0
  33. data/spec/bitcoin/ffi_openssl.rb +45 -0
  34. data/spec/bitcoin/fixtures/156e6e1b84c5c3bd3a0927b25e4119fadce6e6d5186f363317511d1d680fae9a.json +24 -0
  35. data/spec/bitcoin/fixtures/8d0b238a06b5a70be75d543902d02d7a514d68d3252a949a513865ac3538874c.json +24 -0
  36. data/spec/bitcoin/fixtures/coinbase-toshi.json +33 -0
  37. data/spec/bitcoin/fixtures/coinbase.json +24 -0
  38. data/spec/bitcoin/fixtures/dogecoin-block-60323982f9c5ff1b5a954eac9dc1269352835f47c2c5222691d80f0d50dcf053.bin +0 -0
  39. data/spec/bitcoin/fixtures/rawtx-01-toshi.json +46 -0
  40. data/spec/bitcoin/fixtures/rawtx-02-toshi.json +46 -0
  41. data/spec/bitcoin/fixtures/rawtx-03-toshi.json +73 -0
  42. data/spec/bitcoin/fixtures/rawtx-testnet-04fdc38d6722ab4b12d79113fc4b2896bdcc5169710690ee4e78541b98e467b4.bin +0 -0
  43. data/spec/bitcoin/fixtures/rawtx-testnet-0b294c7d11dd21bcccb8393e6744fed7d4d1981a08c00e3e88838cc421f33c9f.bin +0 -0
  44. data/spec/bitcoin/fixtures/rawtx-testnet-3bc52ac063291ad92d95ddda5fd776a342083b95607ad32ed8bc6f8f7d30449e.bin +0 -0
  45. data/spec/bitcoin/fixtures/rawtx-testnet-6f0bbdd4e71a8af4305018d738184df32dbb6f27284fdebd5b56d16947f7c181.bin +0 -0
  46. data/spec/bitcoin/fixtures/rawtx-testnet-a7c9b06e275e8674cc19a5f7d3e557c72c6d93576e635b33212dbe08ab7cdb60.bin +0 -0
  47. data/spec/bitcoin/fixtures/rawtx-testnet-f80acbd2f594d04ddb0e1cacba662132104909157dff526935a3c88abe9201a5.bin +0 -0
  48. data/spec/bitcoin/protocol/block_spec.rb +0 -22
  49. data/spec/bitcoin/protocol/tx_spec.rb +145 -2
  50. data/spec/bitcoin/script/script_spec.rb +282 -0
  51. data/spec/bitcoin/secp256k1_spec.rb +48 -0
  52. data/spec/bitcoin/spec_helper.rb +0 -51
  53. data/spec/bitcoin/trezor/mnemonic_spec.rb +161 -0
  54. metadata +48 -98
  55. data/bin/bitcoin_dns_seed +0 -130
  56. data/bin/bitcoin_gui +0 -80
  57. data/bin/bitcoin_node +0 -153
  58. data/bin/bitcoin_node_cli +0 -81
  59. data/bin/bitcoin_wallet +0 -402
  60. data/doc/CONFIG.rdoc +0 -66
  61. data/doc/EXAMPLES.rdoc +0 -13
  62. data/doc/NAMECOIN.rdoc +0 -34
  63. data/doc/NODE.rdoc +0 -225
  64. data/doc/STORAGE.rdoc +0 -33
  65. data/doc/WALLET.rdoc +0 -102
  66. data/examples/balance.rb +0 -66
  67. data/examples/forwarder.rb +0 -73
  68. data/examples/index_nhash.rb +0 -24
  69. data/examples/reindex_p2sh_addrs.rb +0 -44
  70. data/examples/relay_tx.rb +0 -22
  71. data/examples/verify_tx.rb +0 -57
  72. data/lib/bitcoin/config.rb +0 -58
  73. data/lib/bitcoin/gui/addr_view.rb +0 -44
  74. data/lib/bitcoin/gui/bitcoin-ruby.png +0 -0
  75. data/lib/bitcoin/gui/bitcoin-ruby.svg +0 -80
  76. data/lib/bitcoin/gui/conn_view.rb +0 -38
  77. data/lib/bitcoin/gui/connection.rb +0 -70
  78. data/lib/bitcoin/gui/em_gtk.rb +0 -30
  79. data/lib/bitcoin/gui/gui.builder +0 -1643
  80. data/lib/bitcoin/gui/gui.rb +0 -292
  81. data/lib/bitcoin/gui/helpers.rb +0 -115
  82. data/lib/bitcoin/gui/tree_view.rb +0 -84
  83. data/lib/bitcoin/gui/tx_view.rb +0 -69
  84. data/lib/bitcoin/namecoin.rb +0 -280
  85. data/lib/bitcoin/network/command_client.rb +0 -104
  86. data/lib/bitcoin/network/command_handler.rb +0 -570
  87. data/lib/bitcoin/network/connection_handler.rb +0 -387
  88. data/lib/bitcoin/network/node.rb +0 -565
  89. data/lib/bitcoin/storage/dummy/dummy_store.rb +0 -179
  90. data/lib/bitcoin/storage/models.rb +0 -171
  91. data/lib/bitcoin/storage/sequel/migrations.rb +0 -99
  92. data/lib/bitcoin/storage/sequel/migrations/001_base_schema.rb +0 -52
  93. data/lib/bitcoin/storage/sequel/migrations/002_tx.rb +0 -45
  94. data/lib/bitcoin/storage/sequel/migrations/003_change_txin_script_sig_to_blob.rb +0 -18
  95. data/lib/bitcoin/storage/sequel/migrations/004_change_txin_prev_out_to_blob.rb +0 -18
  96. data/lib/bitcoin/storage/sequel/migrations/005_change_tx_hash_to_bytea.rb +0 -14
  97. data/lib/bitcoin/storage/sequel/migrations/006_add_tx_nhash.rb +0 -31
  98. data/lib/bitcoin/storage/sequel/migrations/007_add_prev_out_index_index.rb +0 -16
  99. data/lib/bitcoin/storage/sequel/migrations/008_add_txin_p2sh_type.rb +0 -31
  100. data/lib/bitcoin/storage/sequel/migrations/009_add_addrs_type.rb +0 -56
  101. data/lib/bitcoin/storage/sequel/sequel_store.rb +0 -551
  102. data/lib/bitcoin/storage/storage.rb +0 -517
  103. data/lib/bitcoin/storage/utxo/migrations/001_base_schema.rb +0 -52
  104. data/lib/bitcoin/storage/utxo/migrations/002_utxo.rb +0 -18
  105. data/lib/bitcoin/storage/utxo/migrations/003_update_indices.rb +0 -14
  106. data/lib/bitcoin/storage/utxo/migrations/004_add_addrs_type.rb +0 -14
  107. data/lib/bitcoin/storage/utxo/utxo_store.rb +0 -374
  108. data/lib/bitcoin/validation.rb +0 -400
  109. data/lib/bitcoin/wallet/coinselector.rb +0 -33
  110. data/lib/bitcoin/wallet/keygenerator.rb +0 -77
  111. data/lib/bitcoin/wallet/keystore.rb +0 -207
  112. data/lib/bitcoin/wallet/txdp.rb +0 -118
  113. data/lib/bitcoin/wallet/wallet.rb +0 -281
  114. data/spec/bitcoin/fixtures/freicoin-block-000000005d231b285e63af83edae2d8f5e50e70d396468643092b9239fd3be3c.bin +0 -0
  115. data/spec/bitcoin/fixtures/freicoin-block-000000005d231b285e63af83edae2d8f5e50e70d396468643092b9239fd3be3c.json +0 -43
  116. data/spec/bitcoin/fixtures/freicoin-genesis-block-000000005b1e3d23ecfd2dd4a6e1a35238aa0392c0a8528c40df52376d7efe2c.bin +0 -0
  117. data/spec/bitcoin/fixtures/freicoin-genesis-block-000000005b1e3d23ecfd2dd4a6e1a35238aa0392c0a8528c40df52376d7efe2c.json +0 -67
  118. data/spec/bitcoin/namecoin_spec.rb +0 -182
  119. data/spec/bitcoin/node/command_api_spec.rb +0 -663
  120. data/spec/bitcoin/storage/models_spec.rb +0 -104
  121. data/spec/bitcoin/storage/reorg_spec.rb +0 -236
  122. data/spec/bitcoin/storage/storage_spec.rb +0 -387
  123. data/spec/bitcoin/storage/validation_spec.rb +0 -300
  124. data/spec/bitcoin/wallet/coinselector_spec.rb +0 -38
  125. data/spec/bitcoin/wallet/keygenerator_spec.rb +0 -69
  126. data/spec/bitcoin/wallet/keystore_spec.rb +0 -190
  127. data/spec/bitcoin/wallet/txdp_spec.rb +0 -76
  128. data/spec/bitcoin/wallet/wallet_spec.rb +0 -238
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Collect all unspent outputs for given address and display balance.
4
- # Optionally display list of transactions.
5
- #
6
- # examples/balance.rb <address> [--list]
7
- # examples/balance.rb 1Q2TWHE3GMdB6BZKafqwxXtWAWgFt5Jvm3
8
-
9
- $:.unshift( File.expand_path("../../lib", __FILE__) )
10
- require 'bitcoin'
11
-
12
- Bitcoin.network = :bitcoin
13
- store = Bitcoin::Storage.sequel(:db => "sqlite://bitcoin.db")
14
-
15
- address = ARGV.shift
16
-
17
- unless Bitcoin.valid_address?(address)
18
- puts "Address #{address} is invalid for #{Bitcoin.network_name} network."
19
- exit 1
20
- end
21
-
22
-
23
- # format value to be displayed
24
- def str_val(val, pre = "")
25
- ("#{pre}#{"%.8f" % (val / 1e8)}").rjust(20)
26
- end
27
-
28
- if ARGV[0] == "--list"
29
- txouts = store.get_txouts_for_address(address)
30
- unless txouts.any?
31
- puts "Address not seen."
32
- exit
33
- end
34
-
35
- total = 0
36
- txouts.each do |txout|
37
- tx = txout.get_tx
38
- total += txout.value
39
- puts "#{tx.hash} |#{str_val(txout.value, '+ ')} |=> #{str_val(total)}"
40
-
41
- tx = txout.get_tx
42
- if tx.is_coinbase?
43
- puts " "*12 + "generated (#{tx.get_block.hash})"
44
- else
45
- tx.in.each do |txin|
46
- addresses = txin.get_prev_out.get_addresses.join(", ")
47
- puts " #{str_val(txin.get_prev_out.value)} from #{addresses}"
48
- end
49
- end
50
- puts
51
-
52
- if txin = txout.get_next_in
53
- tx = txin.get_tx
54
- total -= txout.value
55
- puts "#{tx.hash} |#{str_val(txout.value, '- ')} |=> #{str_val(total)}"
56
- txin.get_tx.out.each do |out|
57
- puts " #{str_val(out.value)} to #{out.get_addresses.join(", ")}"
58
- end
59
- puts
60
- end
61
- end
62
- end
63
-
64
- hash160 = Bitcoin.hash160_from_address(address)
65
- balance = store.get_balance(hash160)
66
- puts "Balance: %.8f" % (balance / 1e8)
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Connect to a node's command socket, monitor incoming payments to one address
4
- # and forward everything to another address.
5
- # Needs the private key of the receiving address (to sign new tx) and the forwarding
6
- # address where payments are sent to.
7
- # Note how the private key does NOT have to be passed to the node, we just sign the
8
- # sig_hash ourselves.
9
- #
10
- # examples/forwarder.rb <base58_privkey> <forwarding_address>
11
- # examples/forwarder.rb KyZsiZiFyewBswJpdYywz4b5sif252iN5zZQjGzPVVgAsGYyMk8a 12bL22Pynmp7pDtDqD2w9iP7dRzdM1gNUd
12
-
13
- $:.unshift( File.expand_path("../../lib", __FILE__) )
14
- require 'eventmachine'
15
- require 'bitcoin'
16
-
17
- Bitcoin.network = :testnet3
18
-
19
- EM.run do
20
-
21
- # key/address where people can send money
22
- KEY = Bitcoin::Key.from_base58(ARGV[0])
23
-
24
- # address where received money is forwarded to
25
- FORWARD = ARGV[1]
26
-
27
- # number of confirmations tx need before being forwarded
28
- CONFIRMATIONS = 1
29
-
30
- # list of already forwarded txs, to prevent duplicates
31
- FORWARDED_TXS = []
32
-
33
- Bitcoin::Network::CommandClient.connect("127.0.0.1", 9999) do
34
-
35
- on_connected do
36
- request("monitor", "output", "output_#{CONFIRMATIONS}")
37
-
38
- puts "Running bitcoin forwarder on address #{KEY.addr}."
39
- puts "Forwarding every incoming payment to #{FORWARD}."
40
- end
41
-
42
- on_output do |tx_hash, recipient_addr, value, confirmations|
43
- if recipient_addr == KEY.addr
44
- if confirmations >= CONFIRMATIONS
45
- next if FORWARDED_TXS.include?(tx_hash)
46
- FORWARDED_TXS << tx_hash
47
- puts "Payment of #{value.to_f/1e8} BTC confirmed. Forwarding..."
48
-
49
- # Note: We could also pass KEY.priv instead of KEY.addr here.
50
- # Then we would get the complete tx in one step without calling "assemble_tx".
51
- request("create_tx", [KEY.addr], [[FORWARD, value]])
52
- else
53
- puts "Received unconfirmed payment of #{value.to_f/1e8} BTC."
54
- end
55
- end
56
- end
57
-
58
- on_create_tx do |unsigned_tx, sig_hashes|
59
- sig_pubkeys = sig_hashes.map do |sig_hash, address|
60
- [KEY.sign(sig_hash.htb).hth, KEY.pub]
61
- end
62
- request("assemble_tx", unsigned_tx, sig_pubkeys)
63
- end
64
-
65
- on_assemble_tx do |tx_in_hex|
66
- tx = Bitcoin::P::Tx.new(tx_in_hex.htb)
67
- puts "Relaying tx #{tx.hash}..."
68
- request("relay_tx", tx_in_hex)
69
- end
70
-
71
- end
72
-
73
- end
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift( File.expand_path("../../lib", __FILE__) )
4
- require 'bitcoin'
5
-
6
- Bitcoin.network = :testnet3
7
- @store = Bitcoin::Storage.sequel(:db => "postgres://mhanne:password@localhost:5434/testnet3_full")
8
-
9
- #@store.db.execute "DROP INDEX tx_nhash_index"
10
-
11
- def process_block blk
12
- print "\r#{blk.hash} - #{blk.depth}"
13
- blk.tx.each do |tx|
14
- @store.db[:tx].where(hash: tx.hash.htb.blob).update(nhash: tx.nhash.htb.blob)
15
- end
16
- end
17
-
18
- blk = @store.get_block_by_depth(0)
19
- process_block(blk)
20
- while blk = blk.get_next_block
21
- process_block(blk)
22
- end
23
-
24
- @store.db.execute "CREATE INDEX tx_nhash_index ON tx (nhash)"
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift( File.expand_path("../../lib", __FILE__) )
4
- require 'bitcoin'
5
-
6
- Bitcoin.network = :testnet3
7
- @store = Bitcoin::Storage.sequel(:db => "postgres://mhanne:password@localhost:5434/testnet3_full")
8
- # @store = Bitcoin::Storage.sequel(:db => "postgres:/testnet3")
9
-
10
- puts "move namecoin types up by one to make room for op_return"
11
- if Bitcoin.network_name == :namecoin
12
- @store.db.run "UPDATE txout SET type = 8 WHERE type = 7"
13
- @store.db.run "UPDATE txout SET type = 7 WHERE type = 6"
14
- @store.db.run "UPDATE txout SET type = 6 WHERE type = 5"
15
- end
16
-
17
- puts "create missing p2sh output <-> address mappings"
18
- @store.db[:txout].where(type: 4).each do |txout|
19
- script = Bitcoin::Script.new(txout[:pk_script])
20
- if addr = @store.db[:addr][hash160: script.get_hash160]
21
- addr_id = addr[:id]
22
- else
23
- addr_id = @store.db[:addr].insert(hash160: script.get_hash160)
24
- end
25
-
26
- if addr_txout = @store.db[:addr_txout][addr_id: addr_id, txout_id: txout[:id]]
27
- # mapping already exists
28
- print "e"
29
- else
30
- print "C"
31
- @store.db[:addr_txout].insert(addr_id: addr_id, txout_id: txout[:id])
32
- end
33
- end
34
-
35
- puts
36
- puts "scan all txouts of unknown type and check if they are op_returns"
37
- @store.db[:txout].where(type: 0).each do |txout|
38
- if Bitcoin::Script.new(txout[:pk_script]).is_op_return?
39
- print "C"
40
- @store.db[:txout].where(id: txout[:id]).update(type: 5)
41
- else
42
- print "s"
43
- end
44
- end
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Relay transaction to the network.
4
- # TODO
5
-
6
- require 'socket'
7
- require 'json'
8
-
9
- # TODO: use CommandClient
10
-
11
- host, port = "127.0.0.1", 9999
12
- if ARGV[0] == "-s"
13
- host, port = ARGV[1].split(":")
14
- ARGV.shift; ARGV.shift
15
- end
16
-
17
- s = TCPSocket.new("127.0.0.1", 9999)
18
- s.puts ("relay_tx " + ARGF.read.unpack("H*")[0])
19
-
20
- res = s.readline
21
- puts JSON::pretty_generate(JSON::parse(res))
22
- s.close
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Fetch a transaction and all its previous outputs from local storage and verify signatures.
4
- #
5
- # examples/verify_tx.rb <tx_hash>
6
- # examples/verify_tx.rb f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16
7
- #
8
- # see Bitcoin::Protocol::Tx and Bitcoin::Script.
9
- # Note: For this to work, you need to have the transactions in your storage. see NODE.
10
- # Note: There is also Bitcoin::Validation::Tx which validates a lot more than signatures.
11
-
12
- $:.unshift( File.expand_path("../../lib", __FILE__) )
13
- require 'bitcoin'
14
-
15
- Bitcoin.network = :bitcoin
16
- store = Bitcoin::Storage.sequel(:db => "sqlite://bitcoin.db")
17
-
18
- tx_hash = ARGV.shift
19
-
20
- tx1 = store.get_tx(tx_hash)
21
-
22
- unless tx1
23
- puts "Tx #{tx_hash} not found."
24
- exit
25
- end
26
-
27
- if tx1.in.all?{|txin| txin.coinbase? }
28
- puts "Tx #{tx_hash} is a coinbase transaction. Check the block instead."
29
- exit
30
- end
31
-
32
- tx1.in.each_with_index do |txin, idx|
33
- if txin.coinbase?
34
- puts "skipping coinbase transaction input.."; next
35
- end
36
-
37
- prev_tx = txin.get_prev_out.get_tx
38
- if prev_tx
39
- puts "Found prev tx #{prev_tx.hash}"
40
- txout = prev_tx.out[txin.prev_out_index]
41
- script = Bitcoin::Script.new(txout.pk_script)
42
- puts "Output Script: #{script.to_string}"
43
- else
44
- puts "Missing prev tx for input #{idx}!"
45
- exit
46
- end
47
-
48
- result = tx1.verify_input_signature(idx, prev_tx)
49
- if result
50
- puts "Valid signature for input #{idx}."
51
- else
52
- puts "Signature for input #{idx} is invalid!"
53
- exit
54
- end
55
- end
56
-
57
- puts "Tx #{tx_hash} is valid."
@@ -1,58 +0,0 @@
1
- # encoding: ascii-8bit
2
-
3
- require 'yaml'
4
- module Bitcoin
5
-
6
- # Load config files, merge options, etc.
7
- #
8
- # Multiple config files are loaded in order, and their settings merged into an
9
- # existing +options+ hash.
10
- #
11
- # Each config file defines one or more +categories+ which hold the actual settings.
12
- # Which categories are loaded, and in what order, is specified when you load
13
- # the config (ie. the order in the file doesn't matter).
14
- # The default category "all" is always used, and is always the first
15
- # (gets overridden by all others)
16
- module Config
17
-
18
- CONFIG_PATHS = "./bitcoin-ruby.yml:~/.bitcoin-ruby.yml:/etc/bitcoin-ruby.yml"
19
-
20
- # Load +categories+ from all files at +paths+ into given +options+ hash.
21
- def self.load(options, categories = [], paths = CONFIG_PATHS)
22
- paths.split(":").reverse.each do |path|
23
- path.sub!("~", ENV["HOME"])
24
- next unless File.exist?(path)
25
- options = load_file(options, path, categories)
26
- end
27
- options
28
- end
29
-
30
- # Load categories +c+ of a single config +file+ into given +options+ hash.
31
- def self.load_file(options, file, c = [])
32
- categories = YAML::load_file(file)
33
- [:all, *(c.is_a?(Array) ? c : [c])].each do |category|
34
- options = merge(options, categories[category.to_s]) if categories[category.to_s]
35
- end
36
- options
37
- end
38
-
39
- # Deep-merge hash +b+ into +a+.
40
- def self.merge(a, b)
41
- return a unless b
42
- symbolize(a).merge(symbolize(b)) do |k, o, n|
43
- if o.is_a?(Hash) && n.is_a?(Hash)
44
- merge(symbolize(o), symbolize(n))
45
- else
46
- n
47
- end
48
- end
49
- end
50
-
51
- # Turn all keys in +hash+ into symbols.
52
- def self.symbolize(hash)
53
- Hash[hash.map{|k,v|[k.to_sym,v]}]
54
- end
55
-
56
- end
57
-
58
- end
@@ -1,44 +0,0 @@
1
- # encoding: ascii-8bit
2
-
3
- module Bitcoin::Gui
4
- class AddrView < TreeView
5
-
6
- def initialize gui
7
- super(gui, :addr_view, [
8
- [GObject::TYPE_STRING, "Address", :format_address_col],
9
- [GObject::TYPE_STRING],
10
- [GObject::TYPE_STRING, "Balance", :format_value_col],
11
- [GObject::TYPE_BOOLEAN, "Mine?"]])
12
- end
13
-
14
- def update addrs
15
- EM.defer do
16
- @model.clear
17
- addrs.each do |addr|
18
- row = @model.append(nil)
19
- @model.set_value(row, 0, addr[:addr])
20
- @model.set_value(row, 1, addr[:label] || "")
21
- @model.set_value(row, 3, !!addr[:mine])
22
- balance = 0
23
- unconfirmed = @gui.check_unconfirmed.active
24
- @gui.storage.get_txouts_for_address(addr[:addr]).each do |txout|
25
- next if !unconfirmed && !txout.get_tx.get_block
26
- tx_row = @model.append(row)
27
- @model.set_value(tx_row, 0, txout.get_tx.hash)
28
- @model.set_value(tx_row, 2, txout.value.to_s)
29
- balance += txout.value
30
- if txin = txout.get_next_in
31
- tx_row = @model.append(row)
32
- @model.set_value(tx_row, 0, txin.get_tx.hash)
33
- @model.set_value(tx_row, 2, (0 - txout.value).to_s)
34
- balance -= txout.value
35
- end
36
- end
37
- @model.set_value(row, 2, balance.to_s)
38
- end
39
- @view.set_model @model
40
- end
41
- end
42
-
43
- end
44
- end
@@ -1,80 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
-
4
- <svg
5
- xmlns:dc="http://purl.org/dc/elements/1.1/"
6
- xmlns:cc="http://creativecommons.org/ns#"
7
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
- xmlns:svg="http://www.w3.org/2000/svg"
9
- xmlns="http://www.w3.org/2000/svg"
10
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
- width="744.09448819"
13
- height="1052.3622047"
14
- id="svg2"
15
- version="1.1"
16
- inkscape:version="0.48.3.1 r9886"
17
- sodipodi:docname="bitcoin-ruby.svg">
18
- <defs
19
- id="defs4" />
20
- <sodipodi:namedview
21
- id="base"
22
- pagecolor="#ffffff"
23
- bordercolor="#666666"
24
- borderopacity="1.0"
25
- inkscape:pageopacity="0.0"
26
- inkscape:pageshadow="2"
27
- inkscape:zoom="0.35"
28
- inkscape:cx="-129.28571"
29
- inkscape:cy="520"
30
- inkscape:document-units="px"
31
- inkscape:current-layer="layer1"
32
- showgrid="false"
33
- inkscape:window-width="1596"
34
- inkscape:window-height="1180"
35
- inkscape:window-x="2"
36
- inkscape:window-y="18"
37
- inkscape:window-maximized="0" />
38
- <metadata
39
- id="metadata7">
40
- <rdf:RDF>
41
- <cc:Work
42
- rdf:about="">
43
- <dc:format>image/svg+xml</dc:format>
44
- <dc:type
45
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
46
- <dc:title></dc:title>
47
- </cc:Work>
48
- </rdf:RDF>
49
- </metadata>
50
- <g
51
- inkscape:label="Layer 1"
52
- inkscape:groupmode="layer"
53
- id="layer1">
54
- <rect
55
- style="fill:#8c0000;fill-opacity:1;stroke:#ffffff;stroke-width:0.75155282;stroke-opacity:1"
56
- id="rect2987"
57
- width="120.24844"
58
- height="120.24844"
59
- x="268.4472"
60
- y="200.80939"
61
- inkscape:export-filename="/home/mhanne/work/bitcoin-ruby/lib/bitcoin/gui/bitcoin-ruby.png"
62
- inkscape:export-xdpi="74.380165"
63
- inkscape:export-ydpi="74.380165" />
64
- <text
65
- xml:space="preserve"
66
- style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
67
- x="285.71429"
68
- y="303.79077"
69
- id="text2989"
70
- sodipodi:linespacing="125%"
71
- inkscape:export-filename="/home/mhanne/work/bitcoin-ruby/lib/bitcoin/gui/bitcoin-ruby.png"
72
- inkscape:export-xdpi="74.380165"
73
- inkscape:export-ydpi="74.380165"><tspan
74
- sodipodi:role="line"
75
- id="tspan2991"
76
- x="285.71429"
77
- y="303.79077"
78
- style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;font-family:FreeMono;-inkscape-font-specification:FreeMono Bold">B</tspan></text>
79
- </g>
80
- </svg>