bit_wallet 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/bit_wallet.gemspec +3 -1
  2. data/lib/bit_wallet/account.rb +3 -1
  3. data/lib/bit_wallet/version.rb +1 -1
  4. data/spec/bit_wallet/account_spec.rb +15 -12
  5. data/spec/bit_wallet/accounts_spec.rb +1 -1
  6. data/spec/bit_wallet/address_spec.rb +1 -1
  7. data/spec/bit_wallet/addresses_spec.rb +1 -1
  8. data/spec/bit_wallet/transaction_spec.rb +1 -1
  9. data/spec/bit_wallet/wallet_spec.rb +12 -11
  10. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_be_able_to_override_the_min_conf.yml +114 -0
  11. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_default_to_the_config_min_conf.yml +114 -0
  12. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_return_the_balance_of_the_account.yml +188 -0
  13. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_recent_transactions/should_default_to_list_10_transactions.yml +558 -0
  14. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_amount/_to_is_a_BitWallet_Address/should_send_it_to_the_address_of_the_given_BitWallet_Address.yml +225 -0
  15. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_amount/account_does_not_have_enough_money/should_fail_with_the_InsufficientFunds_error.yml +189 -0
  16. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_amount/should_send_money_to_the_given_address.yml +225 -0
  17. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_total_received/should_return_the_total_amount_received_by_the_address.yml +40 -0
  18. data/spec/fixtures/vcr_cassettes/BitWallet_Account/addresses/.yml +40 -0
  19. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/should_be_assigned_that_name.yml +114 -0
  20. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/should_have_a_default_name.yml +40 -0
  21. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/when_the_account_name_already_exists/should_return_that_same_address.yml +114 -0
  22. data/spec/fixtures/vcr_cassettes/BitWallet_Account/wallet/.yml +40 -0
  23. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_includes_account_name_account_/should_return_true_if_the_array_includes_the_account.yml +114 -0
  24. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_new/should_create_a_new_BitWallet_Account_with_a_default_address.yml +114 -0
  25. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_with_balance/should_return_accounts_with_a_balance_0.yml +484 -0
  26. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/wallet/.yml +77 -0
  27. data/spec/fixtures/vcr_cassettes/BitWallet_Address/_total_received/should_return_the_total_amount_received_by_the_address.yml +77 -0
  28. data/spec/fixtures/vcr_cassettes/BitWallet_Address/account/.yml +77 -0
  29. data/spec/fixtures/vcr_cassettes/BitWallet_Address/on_initialization/address_given_already_exists/should_not_create_an_address.yml +40 -0
  30. data/spec/fixtures/vcr_cassettes/BitWallet_Address/on_initialization/no_address_is_given/should_create_an_address.yml +77 -0
  31. data/spec/fixtures/vcr_cassettes/BitWallet_Addresses/_new/with_address_string_given/should_return_an_Address_with_the_given_address_string.yml +40 -0
  32. data/spec/fixtures/vcr_cassettes/BitWallet_Addresses/_new/without_any_address_string_given/should_return_an_Address_that_points_to_the_same_account.yml +77 -0
  33. data/spec/fixtures/vcr_cassettes/BitWallet_Addresses/account/.yml +40 -0
  34. data/spec/fixtures/vcr_cassettes/BitWallet_Addresses/new/.yml +77 -0
  35. data/spec/fixtures/vcr_cassettes/BitWallet_Transaction/on_initialization/should_be_able_to_take_a_bitcoind_hash.yml +114 -0
  36. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_accounts/should_return_array_of_BitWallet_Accounts.yml +77 -0
  37. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_return_the_most_recent_transactions_of_all_accounts_defaulting_to_10_transactions.yml +558 -0
  38. data/spec/spec_helper.rb +9 -1
  39. metadata +94 -5
data/bit_wallet.gemspec CHANGED
@@ -22,5 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'rspec', '2.12.0'
23
23
  gem.add_development_dependency 'pry'
24
24
  gem.add_development_dependency 'factory_girl', '4.2.0'
25
- gem.add_development_dependency 'bitcoin_testnet', '0.0.1'
25
+ gem.add_development_dependency 'bitcoin_testnet', '0.3.1'
26
+ gem.add_development_dependency 'vcr', '2.4.0'
27
+ gem.add_development_dependency 'webmock', '1.9.0'
26
28
  end
@@ -43,7 +43,9 @@ module BitWallet
43
43
 
44
44
  def recent_transactions(options={})
45
45
  count = options.delete(:limit) || 10
46
- client.listtransactions self.name, count
46
+ client.listtransactions(self.name, count).map do |hash|
47
+ Transaction.new self.wallet, hash
48
+ end
47
49
  end
48
50
 
49
51
  private
@@ -1,3 +1,3 @@
1
1
  module BitWallet
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Account do
3
+ describe BitWallet::Account, vcr: true do
4
4
 
5
5
  let(:wallet) { build(:wallet) }
6
6
  subject { described_class.new(wallet, 'name') }
@@ -115,17 +115,20 @@ describe BitWallet::Account do
115
115
  end
116
116
 
117
117
  context 'when transaction limit is 5' do
118
- it 'should list the 5 most recent transactions' do
119
- wallet = build(:wallet)
120
- default_account = wallet.accounts.new('')
121
- account_1 = wallet.accounts.new('1')
122
-
123
- 1.upto(6).each do |n|
124
- default_account.send_amount n, to: account_1.addresses.first
125
- end
126
-
127
- account_1.recent_transactions(limit: 5).size.should == 5
128
- end
118
+ # FIXME when bitcoin-client this is resolved: https://github.com/sinisterchipmunk/bitcoin-client/issues/4
119
+ it 'should list the 5 most recent transactions'
120
+ # it 'should list the 5 most recent transactions' do
121
+ # pending "Fix this when when..."
122
+ # wallet = build(:wallet)
123
+ # default_account = wallet.accounts.new('')
124
+ # account_1 = wallet.accounts.new('1')
125
+
126
+ # 1.upto(6).each do |n|
127
+ # default_account.send_amount n, to: account_1.addresses.first
128
+ # end
129
+
130
+ # account_1.recent_transactions(limit: 5).size.should == 5
131
+ # end
129
132
  end
130
133
  end
131
134
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Accounts do
3
+ describe BitWallet::Accounts, vcr: true do
4
4
 
5
5
  let(:wallet) do
6
6
  build(:wallet)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Address do
3
+ describe BitWallet::Address, vcr: true do
4
4
 
5
5
  let(:account) { build(:account) }
6
6
  subject { build(:address, account: account) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Addresses do
3
+ describe BitWallet::Addresses, vcr: true do
4
4
 
5
5
  let(:account) { build(:account) }
6
6
  subject { BitWallet::Addresses.new(account) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Transaction do
3
+ describe BitWallet::Transaction, vcr: true do
4
4
 
5
5
  describe 'on initialization' do
6
6
  it 'should be able to take a bitcoind hash' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BitWallet::Wallet do
3
+ describe BitWallet::Wallet, vcr: true do
4
4
 
5
5
  describe '#accounts' do
6
6
  it 'should return array of BitWallet::Accounts' do
@@ -22,18 +22,19 @@ describe BitWallet::Wallet do
22
22
  wallet.recent_transactions.size.should == 10
23
23
  end
24
24
 
25
- it 'should allow overriding of the transaction limit' do
26
- pending "Fix when bitcoin-client this is resolved: https://github.com/sinisterchipmunk/bitcoin-client/issues/4"
27
- wallet = build(:wallet)
28
- default_account = wallet.accounts.new('')
29
- account_1 = wallet.accounts.new('1')
25
+ # FIXME when bitcoin-client this is resolved: https://github.com/sinisterchipmunk/bitcoin-client/issues/4
26
+ it 'should allow overriding of the transaction limit'
27
+ # it 'should allow overriding of the transaction limit' do
28
+ # wallet = build(:wallet)
29
+ # default_account = wallet.accounts.new('')
30
+ # account_1 = wallet.accounts.new('1')
30
31
 
31
- 1.upto(11).each do |n|
32
- default_account.send_amount n, to: account_1.addresses.first
33
- end
32
+ # 1.upto(11).each do |n|
33
+ # default_account.send_amount n, to: account_1.addresses.first
34
+ # end
34
35
 
35
- wallet.recent_transactions(limit: 5).size.should == 5
36
- end
36
+ # wallet.recent_transactions(limit: 5).size.should == 5
37
+ # end
37
38
  end
38
39
 
39
40
  end
@@ -0,0 +1,114 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://admin1:123@localhost:19001/
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"method":"listaccounts","params":[1],"id":"jsonrpc"}'
9
+ headers:
10
+ Accept:
11
+ - ! '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '53'
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 07 Mar 2013 10:20:27 +0000
25
+ Connection:
26
+ - keep-alive
27
+ Content-Length:
28
+ - '58'
29
+ Content-Type:
30
+ - application/json
31
+ Server:
32
+ - bitcoin-json-rpc/v0.7.2-beta
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ! '{"result":{"":8800.00000000},"error":null,"id":"jsonrpc"}
36
+
37
+ '
38
+ http_version:
39
+ recorded_at: Thu, 07 Mar 2013 10:20:27 GMT
40
+ - request:
41
+ method: post
42
+ uri: http://admin1:123@localhost:19001/
43
+ body:
44
+ encoding: UTF-8
45
+ string: ! '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
46
+ headers:
47
+ Accept:
48
+ - ! '*/*; q=0.5, application/xml'
49
+ Accept-Encoding:
50
+ - gzip, deflate
51
+ Content-Length:
52
+ - '55'
53
+ User-Agent:
54
+ - Ruby
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Date:
61
+ - Thu, 07 Mar 2013 10:20:27 +0000
62
+ Connection:
63
+ - keep-alive
64
+ Content-Length:
65
+ - '76'
66
+ Content-Type:
67
+ - application/json
68
+ Server:
69
+ - bitcoin-json-rpc/v0.7.2-beta
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ! '{"result":"mi487X6jj8ggY6FAoG8ibv7qomcq9TXL1U","error":null,"id":"jsonrpc"}
73
+
74
+ '
75
+ http_version:
76
+ recorded_at: Thu, 07 Mar 2013 10:20:27 GMT
77
+ - request:
78
+ method: post
79
+ uri: http://admin1:123@localhost:19001/
80
+ body:
81
+ encoding: UTF-8
82
+ string: ! '{"method":"getnewaddress","params":["nona"],"id":"jsonrpc"}'
83
+ headers:
84
+ Accept:
85
+ - ! '*/*; q=0.5, application/xml'
86
+ Accept-Encoding:
87
+ - gzip, deflate
88
+ Content-Length:
89
+ - '59'
90
+ User-Agent:
91
+ - Ruby
92
+ response:
93
+ status:
94
+ code: 200
95
+ message: OK
96
+ headers:
97
+ Date:
98
+ - Thu, 07 Mar 2013 10:20:27 +0000
99
+ Connection:
100
+ - keep-alive
101
+ Content-Length:
102
+ - '76'
103
+ Content-Type:
104
+ - application/json
105
+ Server:
106
+ - bitcoin-json-rpc/v0.7.2-beta
107
+ body:
108
+ encoding: US-ASCII
109
+ string: ! '{"result":"mkwWW2pnqFkDfH5esHxXBNARTN7GnUDpsv","error":null,"id":"jsonrpc"}
110
+
111
+ '
112
+ http_version:
113
+ recorded_at: Thu, 07 Mar 2013 10:20:27 GMT
114
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,114 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://admin1:123@localhost:19001/
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"method":"listaccounts","params":[1],"id":"jsonrpc"}'
9
+ headers:
10
+ Accept:
11
+ - ! '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '53'
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 07 Mar 2013 10:20:24 +0000
25
+ Connection:
26
+ - keep-alive
27
+ Content-Length:
28
+ - '58'
29
+ Content-Type:
30
+ - application/json
31
+ Server:
32
+ - bitcoin-json-rpc/v0.7.2-beta
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ! '{"result":{"":8800.00000000},"error":null,"id":"jsonrpc"}
36
+
37
+ '
38
+ http_version:
39
+ recorded_at: Thu, 07 Mar 2013 10:20:24 GMT
40
+ - request:
41
+ method: post
42
+ uri: http://admin1:123@localhost:19001/
43
+ body:
44
+ encoding: UTF-8
45
+ string: ! '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
46
+ headers:
47
+ Accept:
48
+ - ! '*/*; q=0.5, application/xml'
49
+ Accept-Encoding:
50
+ - gzip, deflate
51
+ Content-Length:
52
+ - '55'
53
+ User-Agent:
54
+ - Ruby
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Date:
61
+ - Thu, 07 Mar 2013 10:20:24 +0000
62
+ Connection:
63
+ - keep-alive
64
+ Content-Length:
65
+ - '76'
66
+ Content-Type:
67
+ - application/json
68
+ Server:
69
+ - bitcoin-json-rpc/v0.7.2-beta
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ! '{"result":"mi487X6jj8ggY6FAoG8ibv7qomcq9TXL1U","error":null,"id":"jsonrpc"}
73
+
74
+ '
75
+ http_version:
76
+ recorded_at: Thu, 07 Mar 2013 10:20:24 GMT
77
+ - request:
78
+ method: post
79
+ uri: http://admin1:123@localhost:19001/
80
+ body:
81
+ encoding: UTF-8
82
+ string: ! '{"method":"getnewaddress","params":["nona"],"id":"jsonrpc"}'
83
+ headers:
84
+ Accept:
85
+ - ! '*/*; q=0.5, application/xml'
86
+ Accept-Encoding:
87
+ - gzip, deflate
88
+ Content-Length:
89
+ - '59'
90
+ User-Agent:
91
+ - Ruby
92
+ response:
93
+ status:
94
+ code: 200
95
+ message: OK
96
+ headers:
97
+ Date:
98
+ - Thu, 07 Mar 2013 10:20:24 +0000
99
+ Connection:
100
+ - keep-alive
101
+ Content-Length:
102
+ - '76'
103
+ Content-Type:
104
+ - application/json
105
+ Server:
106
+ - bitcoin-json-rpc/v0.7.2-beta
107
+ body:
108
+ encoding: US-ASCII
109
+ string: ! '{"result":"mkwWW2pnqFkDfH5esHxXBNARTN7GnUDpsv","error":null,"id":"jsonrpc"}
110
+
111
+ '
112
+ http_version:
113
+ recorded_at: Thu, 07 Mar 2013 10:20:24 GMT
114
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,188 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://admin1:123@localhost:19001/
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"method":"listaccounts","params":[1],"id":"jsonrpc"}'
9
+ headers:
10
+ Accept:
11
+ - ! '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '53'
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 07 Mar 2013 10:20:22 +0000
25
+ Connection:
26
+ - keep-alive
27
+ Content-Length:
28
+ - '58'
29
+ Content-Type:
30
+ - application/json
31
+ Server:
32
+ - bitcoin-json-rpc/v0.7.2-beta
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ! '{"result":{"":8800.00000000},"error":null,"id":"jsonrpc"}
36
+
37
+ '
38
+ http_version:
39
+ recorded_at: Thu, 07 Mar 2013 10:20:22 GMT
40
+ - request:
41
+ method: post
42
+ uri: http://admin1:123@localhost:19001/
43
+ body:
44
+ encoding: UTF-8
45
+ string: ! '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
46
+ headers:
47
+ Accept:
48
+ - ! '*/*; q=0.5, application/xml'
49
+ Accept-Encoding:
50
+ - gzip, deflate
51
+ Content-Length:
52
+ - '55'
53
+ User-Agent:
54
+ - Ruby
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Date:
61
+ - Thu, 07 Mar 2013 10:20:22 +0000
62
+ Connection:
63
+ - keep-alive
64
+ Content-Length:
65
+ - '76'
66
+ Content-Type:
67
+ - application/json
68
+ Server:
69
+ - bitcoin-json-rpc/v0.7.2-beta
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ! '{"result":"mi487X6jj8ggY6FAoG8ibv7qomcq9TXL1U","error":null,"id":"jsonrpc"}
73
+
74
+ '
75
+ http_version:
76
+ recorded_at: Thu, 07 Mar 2013 10:20:22 GMT
77
+ - request:
78
+ method: post
79
+ uri: http://admin1:123@localhost:19001/
80
+ body:
81
+ encoding: UTF-8
82
+ string: ! '{"method":"getnewaddress","params":["nona"],"id":"jsonrpc"}'
83
+ headers:
84
+ Accept:
85
+ - ! '*/*; q=0.5, application/xml'
86
+ Accept-Encoding:
87
+ - gzip, deflate
88
+ Content-Length:
89
+ - '59'
90
+ User-Agent:
91
+ - Ruby
92
+ response:
93
+ status:
94
+ code: 200
95
+ message: OK
96
+ headers:
97
+ Date:
98
+ - Thu, 07 Mar 2013 10:20:22 +0000
99
+ Connection:
100
+ - keep-alive
101
+ Content-Length:
102
+ - '76'
103
+ Content-Type:
104
+ - application/json
105
+ Server:
106
+ - bitcoin-json-rpc/v0.7.2-beta
107
+ body:
108
+ encoding: US-ASCII
109
+ string: ! '{"result":"mkwWW2pnqFkDfH5esHxXBNARTN7GnUDpsv","error":null,"id":"jsonrpc"}
110
+
111
+ '
112
+ http_version:
113
+ recorded_at: Thu, 07 Mar 2013 10:20:22 GMT
114
+ - request:
115
+ method: post
116
+ uri: http://admin1:123@localhost:19001/
117
+ body:
118
+ encoding: UTF-8
119
+ string: ! '{"method":"getbalance","params":["nona",0],"id":"jsonrpc"}'
120
+ headers:
121
+ Accept:
122
+ - ! '*/*; q=0.5, application/xml'
123
+ Accept-Encoding:
124
+ - gzip, deflate
125
+ Content-Length:
126
+ - '58'
127
+ User-Agent:
128
+ - Ruby
129
+ response:
130
+ status:
131
+ code: 200
132
+ message: OK
133
+ headers:
134
+ Date:
135
+ - Thu, 07 Mar 2013 10:20:22 +0000
136
+ Connection:
137
+ - keep-alive
138
+ Content-Length:
139
+ - '50'
140
+ Content-Type:
141
+ - application/json
142
+ Server:
143
+ - bitcoin-json-rpc/v0.7.2-beta
144
+ body:
145
+ encoding: US-ASCII
146
+ string: ! '{"result":0.00000000,"error":null,"id":"jsonrpc"}
147
+
148
+ '
149
+ http_version:
150
+ recorded_at: Thu, 07 Mar 2013 10:20:22 GMT
151
+ - request:
152
+ method: post
153
+ uri: http://admin1:123@localhost:19001/
154
+ body:
155
+ encoding: UTF-8
156
+ string: ! '{"method":"getbalance","params":["nona",0],"id":"jsonrpc"}'
157
+ headers:
158
+ Accept:
159
+ - ! '*/*; q=0.5, application/xml'
160
+ Accept-Encoding:
161
+ - gzip, deflate
162
+ Content-Length:
163
+ - '58'
164
+ User-Agent:
165
+ - Ruby
166
+ response:
167
+ status:
168
+ code: 200
169
+ message: OK
170
+ headers:
171
+ Date:
172
+ - Thu, 07 Mar 2013 10:20:22 +0000
173
+ Connection:
174
+ - keep-alive
175
+ Content-Length:
176
+ - '50'
177
+ Content-Type:
178
+ - application/json
179
+ Server:
180
+ - bitcoin-json-rpc/v0.7.2-beta
181
+ body:
182
+ encoding: US-ASCII
183
+ string: ! '{"result":0.00000000,"error":null,"id":"jsonrpc"}
184
+
185
+ '
186
+ http_version:
187
+ recorded_at: Thu, 07 Mar 2013 10:20:22 GMT
188
+ recorded_with: VCR 2.4.0