bitcoin 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.rvmrc +1 -1
  2. data/Gemfile.lock +56 -4
  3. data/Guardfile +38 -0
  4. data/README.markdown +21 -2
  5. data/bin/rbcoin +8 -1
  6. data/bitcoin.gemspec +17 -5
  7. data/config/cucumber.yml +3 -3
  8. data/config/darcs.boring +121 -0
  9. data/doc/DEFINITION_OF_DONE.markdown +12 -0
  10. data/doc/HISTORY.markdown +19 -0
  11. data/{LICENCE.markdown → doc/LICENCE.markdown} +1 -1
  12. data/doc/TODO.markdown +31 -0
  13. data/doc/UBIQUITOUS_LANGUAGE.markdown +15 -0
  14. data/features/descriptions/command_help.feature +31 -0
  15. data/features/descriptions/satoshi_wallet/add_address.feature +49 -0
  16. data/features/descriptions/satoshi_wallet/show_addresses.feature +18 -0
  17. data/features/descriptions/satoshi_wallet/show_version.feature +17 -0
  18. data/features/descriptions/satoshi_wallet/subcommand_help.feature +20 -0
  19. data/features/fixtures/ABOUT_FIXTURES.markdown +6 -0
  20. data/features/fixtures/addressbook_wallet.dat +0 -0
  21. data/features/fixtures/new_wallet.dat +0 -0
  22. data/features/step_definitions/command_steps.rb +3 -0
  23. data/features/step_definitions/wallet_steps.rb +11 -0
  24. data/features/support/env.rb +8 -1
  25. data/lib/bitcoin/cli.rb +35 -0
  26. data/lib/bitcoin/commands.rb +3 -0
  27. data/lib/bitcoin/commands/help_command.rb +32 -0
  28. data/lib/bitcoin/commands/satoshi_wallet.rb +11 -0
  29. data/lib/bitcoin/commands/satoshi_wallet/add_address_command.rb +61 -0
  30. data/lib/bitcoin/commands/satoshi_wallet/show_addresses_command.rb +16 -0
  31. data/lib/bitcoin/commands/satoshi_wallet/show_version_command.rb +15 -0
  32. data/lib/bitcoin/commands/satoshi_wallet_command.rb +37 -0
  33. data/lib/bitcoin/commands/satoshi_wallet_command_environment.rb +28 -0
  34. data/lib/bitcoin/console/capturing_stream_bundle.rb +42 -0
  35. data/lib/bitcoin/console/stream_bundle.rb +21 -0
  36. data/lib/bitcoin/data_access/satoshi/bdb_satoshi_wallet_repository.rb +155 -0
  37. data/lib/bitcoin/data_access/satoshi/satoshi_version.rb +58 -0
  38. data/lib/bitcoin/data_access/satoshi/satoshi_wallet.rb +39 -0
  39. data/lib/bitcoin/domain/address_book.rb +19 -0
  40. data/lib/bitcoin/domain/bitcoin_address.rb +33 -0
  41. data/lib/bitcoin/filesystem/empty_temp_dir.rb +74 -0
  42. data/lib/bitcoin/rspec/argument_matchers.rb +1 -0
  43. data/lib/bitcoin/rspec/argument_matchers/block_evaluating_to_matcher.rb +23 -0
  44. data/lib/bitcoin/rspec/directory_helpers.rb +22 -0
  45. data/lib/bitcoin/version.rb +1 -1
  46. data/spec/bitcoin/cli_spec.rb +128 -0
  47. data/spec/bitcoin/commands/help_command_spec.rb +53 -0
  48. data/spec/bitcoin/commands/satoshi_wallet/add_address_command_spec.rb +149 -0
  49. data/spec/bitcoin/commands/satoshi_wallet/show_addresses_command_spec.rb +26 -0
  50. data/spec/bitcoin/commands/satoshi_wallet/show_version_command_spec.rb +26 -0
  51. data/spec/bitcoin/commands/satoshi_wallet_command_environment_spec.rb +76 -0
  52. data/spec/bitcoin/commands/satoshi_wallet_command_spec.rb +73 -0
  53. data/spec/bitcoin/console/_contracts/stream_bundle_contract.rb +29 -0
  54. data/spec/bitcoin/console/capturing_stream_bundle_spec.rb +74 -0
  55. data/spec/bitcoin/console/stream_bundle_spec.rb +13 -0
  56. data/spec/bitcoin/data_access/satoshi/bdb_satoshi_wallet_repository_spec.rb +78 -0
  57. data/spec/bitcoin/data_access/satoshi/satoshi_version_spec.rb +112 -0
  58. data/spec/bitcoin/data_access/satoshi/satoshi_wallet_spec.rb +102 -0
  59. data/spec/bitcoin/domain/address_book_spec.rb +63 -0
  60. data/spec/bitcoin/domain/bitcoin_address_spec.rb +52 -0
  61. data/spec/bitcoin/filesystem/empty_temp_dir_spec.rb +170 -0
  62. data/spec/bitcoin/rspec/argument_matchers/block_evaluating_to_matcher_spec.rb +36 -0
  63. data/spec/spec_helper.rb +29 -1
  64. metadata +221 -18
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.2@bitcoin
1
+ rvm use 1.9.2@bitcoin --create
@@ -1,12 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitcoin (0.0.1)
4
+ bitcoin (0.1.1)
5
+ lstrip-on-steroids (>= 1.0.0)
6
+ sbdb (>= 0.0.12.2)
5
7
 
6
8
  GEM
7
9
  remote: http://rubygems.org/
8
10
  specs:
11
+ aruba (0.4.6)
12
+ bcat (>= 0.6.1)
13
+ childprocess (>= 0.2.0)
14
+ cucumber (>= 1.0.2)
15
+ rdiscount (>= 1.6.8)
16
+ rspec (>= 2.6.0)
17
+ awesome_print (0.4.0)
18
+ bcat (0.6.1)
19
+ rack (~> 1.0)
20
+ bdb (0.2.6.5)
21
+ tuple (>= 0.1.2)
9
22
  builder (3.0.0)
23
+ childprocess (0.2.1)
24
+ ffi (~> 1.0.6)
10
25
  cucumber (1.0.2)
11
26
  builder (>= 2.1.2)
12
27
  diff-lcs (>= 1.1.2)
@@ -14,14 +29,36 @@ GEM
14
29
  json (>= 1.4.6)
15
30
  term-ansicolor (>= 1.0.5)
16
31
  diff-lcs (1.1.2)
17
- gherkin (2.4.5)
32
+ fakefs (0.3.2)
33
+ ffi (1.0.9)
34
+ fuubar (0.0.6)
35
+ rspec (~> 2.0)
36
+ rspec-instafail (~> 0.1.8)
37
+ ruby-progressbar (~> 0.0.10)
38
+ gherkin (2.4.14)
18
39
  json (>= 1.4.6)
19
40
  growl (1.0.3)
20
- guard (0.5.1)
41
+ growl_notify (0.0.1)
42
+ rb-appscript
43
+ guard (0.6.2)
21
44
  thor (~> 0.14.6)
45
+ guard-bundler (0.1.3)
46
+ bundler (>= 1.0.0)
47
+ guard (>= 0.2.2)
48
+ guard-cucumber (0.6.1)
49
+ cucumber (>= 0.10)
50
+ guard (>= 0.4.0)
51
+ guard-rspec (0.4.2)
52
+ guard (>= 0.4.0)
22
53
  json (1.5.3)
54
+ looksee (1.0.2)
55
+ lstrip-on-steroids (1.0.0)
56
+ rack (1.3.2)
23
57
  rake (0.9.2)
24
- rb-fsevent (0.4.1)
58
+ rb-appscript (0.6.1)
59
+ rb-fsevent (0.4.3.1)
60
+ rdiscount (1.6.8)
61
+ ref (1.0.0)
25
62
  rspec (2.6.0)
26
63
  rspec-core (~> 2.6.0)
27
64
  rspec-expectations (~> 2.6.0)
@@ -29,18 +66,33 @@ GEM
29
66
  rspec-core (2.6.4)
30
67
  rspec-expectations (2.6.0)
31
68
  diff-lcs (~> 1.1.2)
69
+ rspec-instafail (0.1.8)
32
70
  rspec-mocks (2.6.0)
71
+ ruby-progressbar (0.0.10)
72
+ sbdb (0.0.12.2)
73
+ bdb (>= 0.2.6.5)
74
+ ref
33
75
  term-ansicolor (1.0.6)
34
76
  thor (0.14.6)
77
+ tuple (0.1.2)
35
78
 
36
79
  PLATFORMS
37
80
  ruby
38
81
 
39
82
  DEPENDENCIES
83
+ aruba
84
+ awesome_print
40
85
  bitcoin!
41
86
  cucumber
87
+ fakefs
88
+ fuubar
42
89
  growl
90
+ growl_notify
43
91
  guard
92
+ guard-bundler
93
+ guard-cucumber
94
+ guard-rspec
95
+ looksee
44
96
  rake
45
97
  rb-fsevent
46
98
  rspec
@@ -0,0 +1,38 @@
1
+ # Signal to interested subprocesses that they are being run from Guard
2
+ ENV["GUARD"] = "fast"
3
+
4
+ guard 'bundler' do
5
+ watch('Gemfile')
6
+ # Uncomment next line if Gemfile contain `gemspec' command
7
+ watch(/^.+\.gemspec/)
8
+ end
9
+
10
+ guard 'rspec', version: 2, cli: "--color --format Fuubar" do
11
+ watch(%r{^spec/.+_spec\.rb})
12
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+ end
15
+
16
+ # Only run this once to stop Guardfile re-evaluation making a hash of things
17
+ unless ::Guard::RSpec.instance_methods.include?(:run_on_change_orig)
18
+ # There's a "hook" branch of Guard that will make this class patch
19
+ # unnecessary: https://github.com/guard/guard/tree/hook
20
+ class ::Guard::RSpec
21
+ # Monkey-patch to indicate to RSpec that it can run slow tests if
22
+ # only one file was changed
23
+ alias_method :run_on_change_orig, :run_on_change
24
+ def run_on_change(paths)
25
+ if paths.length == 1 && File.read(paths.first).include?("adapter: :slow")
26
+ ENV["GUARD"] = "all"
27
+ end
28
+ run_on_change_orig(paths)
29
+ ensure
30
+ ENV["GUARD"] = "fast"
31
+ end
32
+ end
33
+ end
34
+
35
+ guard 'cucumber' do
36
+ watch(%r{^features/.+\.feature$})
37
+ watch(%r{^features/support/.+$}) { 'features' }
38
+ end
@@ -1,5 +1,24 @@
1
1
  # Bitcoin
2
2
 
3
- A Bitcoin client written in Ruby
3
+ A [Bitcoin][bitcoin] client written in Ruby
4
4
 
5
- This is currently just a stub project
5
+ This is very early stages - I haven't yet spent much time on it, but I
6
+ have explored the Bitcoin Berkeley DB database format to some extent,
7
+ and the first phase is to be able to read (and write) enough from standard
8
+ wallets to be a useful management tool.
9
+
10
+ For licence and other documentation, see the "doc" folder
11
+
12
+ ## Installation
13
+
14
+ You need Berkeley DB 4.7 installed. To get this through MacPorts:
15
+
16
+ sudo port install db47
17
+
18
+ The BDB gem dependency should then compile.
19
+
20
+ ## Contact
21
+
22
+ I can be reached by email at <ash.moran@patchspace.co.uk>
23
+
24
+ [bitcoin]: http://www.bitcoin.org/
data/bin/rbcoin CHANGED
@@ -1 +1,8 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'bitcoin/cli'
6
+ require 'bitcoin/console/stream_bundle'
7
+
8
+ exit Bitcoin::CLI.new(Bitcoin::Console::StreamBundle.new(STDIN, STDOUT, STDERR)).run(ARGV.dup)
@@ -5,22 +5,34 @@ require "bitcoin/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "bitcoin"
7
7
  s.version = Bitcoin::VERSION
8
- s.authors = ["Ash Moran"]
9
- s.email = ["ash.moran@patchspace.co.uk"]
10
- s.homepage = "http://bitcoinrb.info/"
11
- s.summary = "kwoon-#{Bitcoin::VERSION}"
8
+ s.authors = [ "Ash Moran", "Andy Shipman" ]
9
+ s.email = %w[ ash.moran@patchspace.co.uk andy@cllearview.com ]
10
+ s.homepage = "http://rbcoin.org/"
11
+ s.summary = "bitcoin-#{Bitcoin::VERSION}"
12
12
  s.description = "Bitcoin client"
13
13
 
14
14
  # s.rubyforge_project = "bitcoin"
15
15
 
16
+ s.add_dependency("sbdb", ">= 0.0.12.2")
17
+ s.add_dependency("lstrip-on-steroids", ">= 1.0.0")
18
+
16
19
  s.add_development_dependency("rake")
17
20
  s.add_development_dependency("cucumber")
21
+ s.add_development_dependency("aruba")
18
22
  s.add_development_dependency("rspec")
23
+ s.add_development_dependency("fuubar")
19
24
  s.add_development_dependency("guard")
25
+ s.add_development_dependency("guard-rspec")
26
+ s.add_development_dependency("guard-cucumber")
27
+ s.add_development_dependency("guard-bundler")
20
28
  s.add_development_dependency("rb-fsevent")
21
29
  s.add_development_dependency("growl")
30
+ s.add_development_dependency("fakefs")
31
+ s.add_development_dependency("awesome_print")
32
+ s.add_development_dependency("looksee")
33
+ s.add_development_dependency("growl_notify")
22
34
 
23
- # `darcs show files` lists directories unlike `git ls-files`, so we exclude them here
35
+ # `darcs show files` lists directories unlike `git ls-files`, so we exclude them here
24
36
  s.files = `darcs show files`.split("\n").select { |file| File.file?(file) }
25
37
  s.test_files = `darcs show files {features,spec}/*`.split("\n").select { |file| File.file?(file) }
26
38
  s.executables = `darcs show files bin/*`.split("\n").select { |file| File.file?(file) }.map { |file| File.basename(file) }
@@ -1,5 +1,5 @@
1
1
  <%
2
- std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
2
+ std_opts = "--require features/support/env.rb --require features/step_definitions --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
3
3
  %>
4
- default: <%= std_opts %> features
5
- wip: --tags @wip:3 --wip features
4
+ default: <%= std_opts %> --tags ~@wip --strict
5
+ wip: <%= std_opts %> --tags @wip:3 --wip
@@ -0,0 +1,121 @@
1
+ # Boring file regexps:
2
+
3
+ ### compiler and interpreter intermediate files
4
+ # haskell (ghc) interfaces
5
+ \.hi$
6
+ \.hi-boot$
7
+ \.o-boot$
8
+ # object files
9
+ \.o$
10
+ \.o\.cmd$
11
+ # profiling haskell
12
+ \.p_hi$
13
+ \.p_o$
14
+ # haskell program coverage resp. profiling info
15
+ \.tix$
16
+ \.prof$
17
+ # fortran module files
18
+ \.mod$
19
+ # linux kernel
20
+ \.ko\.cmd$
21
+ \.mod\.c$
22
+ (^|/)\.tmp_versions($|/)
23
+ # *.ko files aren't boring by default because they might
24
+ # be Korean translations rather than kernel modules
25
+ # \.ko$
26
+ # python, emacs, java byte code
27
+ \.py[co]$
28
+ \.elc$
29
+ \.class$
30
+ # objects and libraries; lo and la are libtool things
31
+ \.(obj|a|exe|so|lo|la)$
32
+ # compiled zsh configuration files
33
+ \.zwc$
34
+ # Common LISP output files for CLISP and CMUCL
35
+ \.(fas|fasl|sparcf|x86f)$
36
+
37
+ ### build and packaging systems
38
+ # cabal intermediates
39
+ \.installed-pkg-config
40
+ \.setup-config
41
+ # standard cabal build dir, might not be boring for everybody
42
+ # ^dist(/|$)
43
+ # autotools
44
+ (^|/)autom4te\.cache($|/)
45
+ (^|/)config\.(log|status)$
46
+ # microsoft web expression, visual studio metadata directories
47
+ \_vti_cnf$
48
+ \_vti_pvt$
49
+ # gentoo tools
50
+ \.revdep-rebuild.*
51
+ # generated dependencies
52
+ ^\.depend$
53
+
54
+ ### version control systems
55
+ # cvs
56
+ (^|/)CVS($|/)
57
+ \.cvsignore$
58
+ # cvs, emacs locks
59
+ ^\.#
60
+ # rcs
61
+ (^|/)RCS($|/)
62
+ ,v$
63
+ # subversion
64
+ (^|/)\.svn($|/)
65
+ # mercurial
66
+ (^|/)\.hg($|/)
67
+ # git
68
+ (^|/)\.git($|/)
69
+ # bzr
70
+ \.bzr$
71
+ # sccs
72
+ (^|/)SCCS($|/)
73
+ # darcs
74
+ (^|/)_darcs($|/)
75
+ (^|/)\.darcsrepo($|/)
76
+ ^\.darcs-temp-mail$
77
+ -darcs-backup[[:digit:]]+$
78
+ # gnu arch
79
+ (^|/)(\+|,)
80
+ (^|/)vssver\.scc$
81
+ \.swp$
82
+ (^|/)MT($|/)
83
+ (^|/)\{arch\}($|/)
84
+ (^|/).arch-ids($|/)
85
+ # bitkeeper
86
+ (^|/)BitKeeper($|/)
87
+ (^|/)ChangeSet($|/)
88
+
89
+ ### miscellaneous
90
+ # backup files
91
+ ~$
92
+ \.bak$
93
+ \.BAK$
94
+ # patch originals and rejects
95
+ \.orig$
96
+ \.rej$
97
+ # X server
98
+ \..serverauth.*
99
+ # image spam
100
+ \#
101
+ (^|/)Thumbs\.db$
102
+ # vi, emacs tags
103
+ (^|/)(tags|TAGS)$
104
+ #(^|/)\.[^/]
105
+ # core dumps
106
+ (^|/|\.)core$
107
+ # partial broken files (KIO copy operations)
108
+ \.part$
109
+ # waf files, see http://code.google.com/p/waf/
110
+ (^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/)
111
+ (^|/)\.lock-wscript$
112
+ # mac os finder
113
+ (^|/)\.DS_Store$
114
+
115
+ ### Bitcoin gem additions
116
+ pkg$
117
+ ^tmp/.*
118
+ ^bitcoinrb_db_tmp$
119
+ ^scratch\.rb$
120
+ ^features/fixtures/real_wallet.dat$
121
+ ^.*\.gem$
@@ -0,0 +1,12 @@
1
+ # Bitcoin Definition of Done
2
+
3
+ A feature in the Bitcoin client will be considered done under normal
4
+ circumstances if it meets the following criteria:
5
+
6
+ * There is a Cucumber feature describing it
7
+ * The feature covers the command line interface
8
+ * There is a command-line interface for it
9
+ * The command-line interface is documented in the internal help
10
+ * All realistic input-related error conditions are handled
11
+ * All realistic runtime errors are handled
12
+ * The feature behaves in a suitably similar way to the Satoshi client
@@ -0,0 +1,19 @@
1
+ # Bitcoin gem history
2
+
3
+ ## 0.1.2 (2011-08-29)
4
+
5
+ ### New features
6
+
7
+ * `rbcoin satoshi-wallet add-address` command
8
+ * `rbcoin satoshi-wallet show-addresses` command
9
+
10
+ ## 0.1.1 (2011-08-22)
11
+
12
+ ### New features
13
+
14
+ * `rbcoin satoshi-wallet show-version` command
15
+ * `rbcoin help` command shows WIP help, not everything described is implemented
16
+
17
+ ## 0.1.0 (2011-07-21)
18
+
19
+ Initial "release". Doesn't actually do anything yet :-)
@@ -1,4 +1,4 @@
1
- Copyright 2011 Ash Moran ("the copyright holder"). All rights reserved.
1
+ Copyright 2011 Ash Moran <ash.moran@patchspace.co.uk>. All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification, are
4
4
  permitted provided that the following conditions are met:
@@ -0,0 +1,31 @@
1
+ # TODO
2
+
3
+ ## Satoshi code
4
+
5
+ * Investigate `read_compact_size`
6
+
7
+ ## Features
8
+
9
+ * Flags to `rbcoin satoshi-wallet show-addresses`: --all, --sending --receiving
10
+
11
+ ## Usability
12
+
13
+ * Berkeley DB error handling
14
+ * Character encoding (assuming UTF8 everywhere)
15
+ * Zsh command completion
16
+ * Handle mismatched wallet versions
17
+ * Offer a read-only mode for satoshi-wallet commands
18
+ * Subcommand help for `rbcoin satoshi-wallet`
19
+
20
+ ## Design
21
+
22
+ * OCP-compliant command system
23
+
24
+ ## Specs
25
+
26
+ * A contract that commands return 0/1 on success/failure
27
+ * A contract that commands terminate with a newline
28
+
29
+ ## Security
30
+
31
+ * Prevent data being written to swap
@@ -0,0 +1,15 @@
1
+ # RbCoin Ubiquitous Language
2
+
3
+ ## Bitcoin
4
+
5
+ Terms defined here should be used consistently throughout the application user
6
+ interface, documentation and code
7
+
8
+ * Satoshi Client: The original Bitcoin client, referred to as the "Satoshi client" for clarity
9
+ * Satoshi Wallet: The wallet.dat file used by the Satoshi Client (a Berkeley DB file)
10
+ * Address: A Bitcoin address
11
+ * Tip Jar: A Bitcoin address published onymously, usually to collect anonymous tips
12
+
13
+ ## Technical
14
+
15
+ * Value Object: an immutable object (Domain Driven Design sense)
@@ -0,0 +1,31 @@
1
+ Feature: Command help
2
+ In order to avoid being frustrated by being unable to interact with the application
3
+ As a user
4
+ I want to be told when I make a mistake
5
+
6
+ Scenario: `rbcoin`
7
+ When I successfully run `rbcoin`
8
+ Then the output should contain:
9
+ """
10
+ Usage: rbcoin COMMAND ...
11
+
12
+ Commands:
13
+ help Display help about rbcoin and rbcoin commands
14
+ satoshi-wallet Manipulate the wallet.dat file of the original client
15
+
16
+ Use "rbcoin COMMAND --help" or "rbcoin help COMMAND" for help on a single command
17
+ Use "rbcoin --version" to see the rbcoin version number
18
+ Use "rbcoin --exact-version" to see the all version details (with dependencies)
19
+ """
20
+
21
+ Scenario: `rbcoin help`
22
+ When I successfully run `rbcoin help`
23
+ Then the output should contain "Usage: rbcoin COMMAND ..."
24
+
25
+ Scenario: Invalid command
26
+ When I run `rbcoin thiscommanddoesnotexist`
27
+ Then it should fail with:
28
+ """
29
+ rbcoin failed: No such command "thiscommanddoesnotexist"
30
+ Try: `rbcoin help`
31
+ """