bit_wallet 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/bit_wallet/accounts.rb +4 -20
  4. data/lib/bit_wallet/version.rb +1 -1
  5. data/spec/bit_wallet/account_spec.rb +2 -3
  6. data/spec/bit_wallet/accounts_spec.rb +1 -8
  7. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_be_able_to_override_the_min_conf.yml +3 -79
  8. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_default_to_the_config_min_conf.yml +3 -79
  9. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_balance/should_return_the_balance_of_the_account.yml +7 -83
  10. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_recent_transactions/should_default_to_list_10_transactions.yml +53 -91
  11. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_recent_transactions/when_transaction_limit_is_6/should_list_the_6_most_recent_transactions.yml +41 -79
  12. 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 +14 -52
  13. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_amount/account_does_not_have_enough_money/should_fail_with_the_InsufficientFunds_error.yml +11 -49
  14. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_amount/should_send_money_to_the_given_address.yml +14 -52
  15. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_send_many/should_send_the_amounts_of_money_to_the_specified_accounts.yml +17 -55
  16. data/spec/fixtures/vcr_cassettes/BitWallet_Account/_total_received/should_return_the_total_amount_received_by_the_address.yml +3 -3
  17. data/spec/fixtures/vcr_cassettes/BitWallet_Account/addresses/.yml +3 -3
  18. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/should_be_assigned_that_name.yml +3 -79
  19. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/should_have_a_default_name.yml +3 -3
  20. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/when_the_account_name_already_exists/should_return_that_same_address.yml +3 -79
  21. data/spec/fixtures/vcr_cassettes/BitWallet_Account/wallet/.yml +3 -3
  22. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_new/should_create_a_new_BitWallet_Account_with_a_default_address.yml +3 -79
  23. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_with_balance/should_return_accounts_with_a_balance_0.yml +23 -61
  24. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_move/should_move_funds_from_one_account_to_another.yml +12 -50
  25. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_allow_overriding_of_the_transaction_limit.yml +53 -91
  26. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_return_the_most_recent_transactions_of_all_accounts_defaulting_to_10_transactions.yml +53 -91
  27. metadata +2 -10
  28. data/spec/fixtures/vcr_cassettes/BitWallet_Account/on_initialization/name_is_nil/raises_an_error.yml +0 -79
  29. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/_includes_account_name_account_/should_return_true_if_the_array_includes_the_account.yml +0 -117
  30. data/spec/fixtures/vcr_cassettes/BitWallet_Accounts/wallet/.yml +0 -79
  31. data/spec/fixtures/vcr_cassettes/BitWallet_Wallet/_accounts/should_return_array_of_BitWallet_Accounts.yml +0 -79
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3906097f190977399d9e67c58d06f1ff0a966b2
4
- data.tar.gz: 955806fced4ca7f1021a65b8b244c02e4ff981f9
3
+ metadata.gz: fce5a76715e28fb69f0391e3a763a2db3c2c1e48
4
+ data.tar.gz: 26a75f592cecd3e15341b33477058d3508c79d6b
5
5
  SHA512:
6
- metadata.gz: 63af80885ebf86afdef1303b1e79f2ab487717a5eb9a11581e10fb545a48a6a53cb3a53d9f82db3b66fbaf120c3775ec5e68237ad05490982ef0c827464f27e8
7
- data.tar.gz: fdbf0c48e1f9eaadb2e4dab80c5eda5705a0b8aab0ae26a87736c9bf0a1d53e0b41392d77e2118bb15e38d9ec791f095e5bb056fbd916a8b020fd4d52672ed4d
6
+ metadata.gz: 3517c5fa85d12f6b5715f05455a7effc6c31f2bbb0138295a1650f96d5fedc1dcde0a6940f51bd525066ec5ecff78651bcb181c666f6c6bd57baa439902d3014
7
+ data.tar.gz: a290f020b07faf475546d10e036eeb983c039202b3cea87f9681e437563752b50d12fdc43cad35c4c9c44de7cdecfa436b2e40358be7cb6d5d429c14e84e92dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.7.3
2
+
3
+ - [#3](https://github.com/ramontayag/bit_wallet/issues/3): no longer fetch list of accounts during initialization
4
+
1
5
  # v0.7.2
2
6
 
3
7
  - Raise error when an account name is nil
@@ -10,31 +10,15 @@ module BitWallet
10
10
 
11
11
  def initialize(wallet)
12
12
  @wallet = wallet
13
-
14
- existing_accounts.each do |name|
15
- self.new(name)
16
- end
17
13
  end
18
14
 
19
15
  def new(name)
20
- if self.includes_account_name?(name)
21
- account = self.find {|a| a.name == name}
22
- else
23
- account = BitWallet::Account.new(wallet, name)
24
- self << account
25
- end
16
+ account = self.find {|a| a.name == name}
17
+ return account if account
18
+ account = BitWallet::Account.new(wallet, name)
19
+ self << account
26
20
  account
27
21
  end
28
22
 
29
- def includes_account_name?(account_name)
30
- self.find {|a| a.name == account_name}.present?
31
- end
32
-
33
- private
34
-
35
- def existing_accounts
36
- client.listaccounts.keys
37
- end
38
-
39
23
  end
40
24
  end
@@ -1,3 +1,3 @@
1
1
  module BitWallet
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
@@ -19,8 +19,7 @@ describe BitWallet::Account, vcr: {record: :once}, bitcoin_cleaner: true do
19
19
  :port,
20
20
  :password))
21
21
  account = wallet.accounts.new('nona')
22
-
23
- wallet.accounts.includes_account_name?('nona').should be_true
22
+ expect(account.name).to eq "nona"
24
23
  end
25
24
 
26
25
  context 'when the account name already exists' do
@@ -28,7 +27,7 @@ describe BitWallet::Account, vcr: {record: :once}, bitcoin_cleaner: true do
28
27
  wallet = BitWallet::Wallet.new(Config.slice(:username,
29
28
  :port,
30
29
  :password))
31
- account = wallet.accounts.new('nona')
30
+ wallet.accounts.new('nona')
32
31
 
33
32
  expect {
34
33
  wallet.accounts.new('nona')
@@ -21,20 +21,13 @@ module BitWallet
21
21
  end
22
22
  end
23
23
 
24
- describe '#includes_account_name?(account)' do
25
- it 'should return true if the array includes the account' do
26
- account = subject.new('accountname')
27
- subject.includes_account_name?('accountname').should == true
28
- end
29
- end
30
-
31
24
  describe '.with_balance' do
32
25
  it 'should return accounts with a balance > 0' do
33
26
  default_account = subject.new('')
34
27
  account_1 = subject.new('nomoney')
35
28
  account_2 = subject.new('moneyd')
36
29
 
37
- default_account.send_amount 10, to: account_2.addresses.first
30
+ default_account.send_amount 5, to: account_2.addresses.first
38
31
 
39
32
  accounts_with_balance = subject.with_balance
40
33
  accounts_with_balance.should include(default_account)
@@ -1,81 +1,5 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: post
5
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@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-Type:
15
- - application/json
16
- Content-Length:
17
- - '53'
18
- User-Agent:
19
- - Ruby
20
- response:
21
- status:
22
- code: 200
23
- message: OK
24
- headers:
25
- Date:
26
- - Sat, 23 Aug 2014 09:44:35 +0000
27
- Connection:
28
- - keep-alive
29
- Content-Length:
30
- - '56'
31
- Content-Type:
32
- - application/json
33
- Server:
34
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
35
- body:
36
- encoding: UTF-8
37
- string: |
38
- {"result":{"":50.00000000},"error":null,"id":"jsonrpc"}
39
- http_version:
40
- recorded_at: Sat, 23 Aug 2014 09:44:35 GMT
41
- - request:
42
- method: post
43
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
44
- body:
45
- encoding: UTF-8
46
- string: '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
47
- headers:
48
- Accept:
49
- - "*/*; q=0.5, application/xml"
50
- Accept-Encoding:
51
- - gzip, deflate
52
- Content-Type:
53
- - application/json
54
- Content-Length:
55
- - '55'
56
- User-Agent:
57
- - Ruby
58
- response:
59
- status:
60
- code: 200
61
- message: OK
62
- headers:
63
- Date:
64
- - Sat, 23 Aug 2014 09:44:35 +0000
65
- Connection:
66
- - keep-alive
67
- Content-Length:
68
- - '76'
69
- Content-Type:
70
- - application/json
71
- Server:
72
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
73
- body:
74
- encoding: UTF-8
75
- string: |
76
- {"result":"n1V9qhf9PbNXF2NE2iFkKiHFv3owW3trkb","error":null,"id":"jsonrpc"}
77
- http_version:
78
- recorded_at: Sat, 23 Aug 2014 09:44:35 GMT
79
3
  - request:
80
4
  method: post
81
5
  uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
@@ -99,7 +23,7 @@ http_interactions:
99
23
  message: OK
100
24
  headers:
101
25
  Date:
102
- - Sat, 23 Aug 2014 09:44:35 +0000
26
+ - Sun, 24 Aug 2014 06:47:18 +0000
103
27
  Connection:
104
28
  - keep-alive
105
29
  Content-Length:
@@ -111,7 +35,7 @@ http_interactions:
111
35
  body:
112
36
  encoding: UTF-8
113
37
  string: |
114
- {"result":"mfkAkryGgB9BW28NNY212Fu27WzuLTf1V1","error":null,"id":"jsonrpc"}
38
+ {"result":"mgajLc8bC4TMsqEiRS2irxbMW29EWMcq43","error":null,"id":"jsonrpc"}
115
39
  http_version:
116
- recorded_at: Sat, 23 Aug 2014 09:44:35 GMT
40
+ recorded_at: Sun, 24 Aug 2014 06:47:18 GMT
117
41
  recorded_with: VCR 2.8.0
@@ -1,81 +1,5 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: post
5
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@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-Type:
15
- - application/json
16
- Content-Length:
17
- - '53'
18
- User-Agent:
19
- - Ruby
20
- response:
21
- status:
22
- code: 200
23
- message: OK
24
- headers:
25
- Date:
26
- - Sat, 23 Aug 2014 09:44:28 +0000
27
- Connection:
28
- - keep-alive
29
- Content-Length:
30
- - '56'
31
- Content-Type:
32
- - application/json
33
- Server:
34
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
35
- body:
36
- encoding: UTF-8
37
- string: |
38
- {"result":{"":50.00000000},"error":null,"id":"jsonrpc"}
39
- http_version:
40
- recorded_at: Sat, 23 Aug 2014 09:44:28 GMT
41
- - request:
42
- method: post
43
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
44
- body:
45
- encoding: UTF-8
46
- string: '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
47
- headers:
48
- Accept:
49
- - "*/*; q=0.5, application/xml"
50
- Accept-Encoding:
51
- - gzip, deflate
52
- Content-Type:
53
- - application/json
54
- Content-Length:
55
- - '55'
56
- User-Agent:
57
- - Ruby
58
- response:
59
- status:
60
- code: 200
61
- message: OK
62
- headers:
63
- Date:
64
- - Sat, 23 Aug 2014 09:44:28 +0000
65
- Connection:
66
- - keep-alive
67
- Content-Length:
68
- - '76'
69
- Content-Type:
70
- - application/json
71
- Server:
72
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
73
- body:
74
- encoding: UTF-8
75
- string: |
76
- {"result":"mh8e67FEbWhyf13TbvSuvzrGjrWBWChqsp","error":null,"id":"jsonrpc"}
77
- http_version:
78
- recorded_at: Sat, 23 Aug 2014 09:44:28 GMT
79
3
  - request:
80
4
  method: post
81
5
  uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
@@ -99,7 +23,7 @@ http_interactions:
99
23
  message: OK
100
24
  headers:
101
25
  Date:
102
- - Sat, 23 Aug 2014 09:44:28 +0000
26
+ - Sun, 24 Aug 2014 06:47:10 +0000
103
27
  Connection:
104
28
  - keep-alive
105
29
  Content-Length:
@@ -111,7 +35,7 @@ http_interactions:
111
35
  body:
112
36
  encoding: UTF-8
113
37
  string: |
114
- {"result":"mn3fo5zLS5jqFpwNVa9dYuEsmnvZF1HNLY","error":null,"id":"jsonrpc"}
38
+ {"result":"mrQVZdWQWUGEPJVdubb1YBwopRHmwrxQVh","error":null,"id":"jsonrpc"}
115
39
  http_version:
116
- recorded_at: Sat, 23 Aug 2014 09:44:28 GMT
40
+ recorded_at: Sun, 24 Aug 2014 06:47:10 GMT
117
41
  recorded_with: VCR 2.8.0
@@ -1,81 +1,5 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: post
5
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@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-Type:
15
- - application/json
16
- Content-Length:
17
- - '53'
18
- User-Agent:
19
- - Ruby
20
- response:
21
- status:
22
- code: 200
23
- message: OK
24
- headers:
25
- Date:
26
- - Sat, 23 Aug 2014 09:44:42 +0000
27
- Connection:
28
- - keep-alive
29
- Content-Length:
30
- - '56'
31
- Content-Type:
32
- - application/json
33
- Server:
34
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
35
- body:
36
- encoding: UTF-8
37
- string: |
38
- {"result":{"":50.00000000},"error":null,"id":"jsonrpc"}
39
- http_version:
40
- recorded_at: Sat, 23 Aug 2014 09:44:42 GMT
41
- - request:
42
- method: post
43
- uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
44
- body:
45
- encoding: UTF-8
46
- string: '{"method":"getnewaddress","params":[""],"id":"jsonrpc"}'
47
- headers:
48
- Accept:
49
- - "*/*; q=0.5, application/xml"
50
- Accept-Encoding:
51
- - gzip, deflate
52
- Content-Type:
53
- - application/json
54
- Content-Length:
55
- - '55'
56
- User-Agent:
57
- - Ruby
58
- response:
59
- status:
60
- code: 200
61
- message: OK
62
- headers:
63
- Date:
64
- - Sat, 23 Aug 2014 09:44:42 +0000
65
- Connection:
66
- - keep-alive
67
- Content-Length:
68
- - '76'
69
- Content-Type:
70
- - application/json
71
- Server:
72
- - bitcoin-json-rpc/v0.9.2.1-g354c0f3-beta
73
- body:
74
- encoding: UTF-8
75
- string: |
76
- {"result":"mgZ6eXazQ367vVfuvHSgi8VQD8YK8wQPBg","error":null,"id":"jsonrpc"}
77
- http_version:
78
- recorded_at: Sat, 23 Aug 2014 09:44:42 GMT
79
3
  - request:
80
4
  method: post
81
5
  uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
@@ -99,7 +23,7 @@ http_interactions:
99
23
  message: OK
100
24
  headers:
101
25
  Date:
102
- - Sat, 23 Aug 2014 09:44:42 +0000
26
+ - Sun, 24 Aug 2014 06:47:03 +0000
103
27
  Connection:
104
28
  - keep-alive
105
29
  Content-Length:
@@ -111,9 +35,9 @@ http_interactions:
111
35
  body:
112
36
  encoding: UTF-8
113
37
  string: |
114
- {"result":"mgfhj6ZKRfBWH8BrtuzaWimMsQYCG2Yakn","error":null,"id":"jsonrpc"}
38
+ {"result":"n2pYkqqAr6jYPqahnVjLMezeWPGvAddAB3","error":null,"id":"jsonrpc"}
115
39
  http_version:
116
- recorded_at: Sat, 23 Aug 2014 09:44:42 GMT
40
+ recorded_at: Sun, 24 Aug 2014 06:47:03 GMT
117
41
  - request:
118
42
  method: post
119
43
  uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
@@ -137,7 +61,7 @@ http_interactions:
137
61
  message: OK
138
62
  headers:
139
63
  Date:
140
- - Sat, 23 Aug 2014 09:44:42 +0000
64
+ - Sun, 24 Aug 2014 06:47:03 +0000
141
65
  Connection:
142
66
  - keep-alive
143
67
  Content-Length:
@@ -151,7 +75,7 @@ http_interactions:
151
75
  string: |
152
76
  {"result":0.00000000,"error":null,"id":"jsonrpc"}
153
77
  http_version:
154
- recorded_at: Sat, 23 Aug 2014 09:44:42 GMT
78
+ recorded_at: Sun, 24 Aug 2014 06:47:03 GMT
155
79
  - request:
156
80
  method: post
157
81
  uri: http://bitcoinrpc:thisisjustapasswordfortesting@localhost:19001/
@@ -175,7 +99,7 @@ http_interactions:
175
99
  message: OK
176
100
  headers:
177
101
  Date:
178
- - Sat, 23 Aug 2014 09:44:42 +0000
102
+ - Sun, 24 Aug 2014 06:47:03 +0000
179
103
  Connection:
180
104
  - keep-alive
181
105
  Content-Length:
@@ -189,5 +113,5 @@ http_interactions:
189
113
  string: |
190
114
  {"result":0.00000000,"error":null,"id":"jsonrpc"}
191
115
  http_version:
192
- recorded_at: Sat, 23 Aug 2014 09:44:42 GMT
116
+ recorded_at: Sun, 24 Aug 2014 06:47:03 GMT
193
117
  recorded_with: VCR 2.8.0