bit_wallet 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,6 +28,8 @@ Or install it yourself as:
28
28
  account.send_amount 5.5, to: '8hdsakdjh82d9327ccb64642c' # sends 5.5 bitcoin to the address
29
29
  account.send_amount 5.5, to: address # sends 5.5 bitcoin to the BitWallet::Address#address
30
30
  account.send_many '8hdsakdjh82d9327ccb64642c' => 2.21, address => 0.332
31
+ wallet.move 'accountname', 'toanotheraccount', 2.1
32
+ wallet.move account_object, another_account_object, 1.1
31
33
  account.total_received # returns the total amount received by the account
32
34
  account.transactions # returns array of 10 BitWallet::Transaction
33
35
  account.transactions(limit: 5) # returns array of 5 BitWallet::Transaction
@@ -10,6 +10,7 @@ module BitWallet
10
10
  :received_at,
11
11
  :address_str]
12
12
  attr_reader *READER_ATTRS
13
+ delegate :wallet, to: :account
13
14
 
14
15
  def initialize(wallet, args)
15
16
  args = args.with_indifferent_access
@@ -1,3 +1,3 @@
1
1
  module BitWallet
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -16,6 +16,29 @@ module BitWallet
16
16
  end
17
17
  end
18
18
 
19
+ def move(from_account,
20
+ to_account,
21
+ amount,
22
+ min_conf=BitWallet.config.min_conf,
23
+ comment=nil)
24
+
25
+ from_account_str = if from_account.respond_to?(:name)
26
+ from_account.name
27
+ else
28
+ from_account
29
+ end
30
+ to_account_str = if to_account.respond_to?(:name)
31
+ to_account.name
32
+ else
33
+ to_account
34
+ end
35
+ client.move(from_account_str,
36
+ to_account_str,
37
+ amount,
38
+ min_conf,
39
+ comment)
40
+ end
41
+
19
42
  private
20
43
 
21
44
  def client
@@ -35,4 +35,15 @@ describe BitWallet::Wallet, vcr: true do
35
35
  end
36
36
  end
37
37
 
38
+ describe '#move' do
39
+ it 'should move funds from one account to another' do
40
+ wallet = build(:wallet)
41
+ default_account = wallet.accounts.new('')
42
+ account_1 = wallet.accounts.new('1')
43
+ wallet.move '', '1', 1.1
44
+ wallet.move default_account, account_1, 0.5
45
+ account_1.balance.should == 1.6
46
+ end
47
+ end
48
+
38
49
  end
@@ -0,0 +1,225 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://admin1:123@localhost:19001/
6
+ body:
7
+ encoding: US-ASCII
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
+ - Sun, 14 Apr 2013 14:07:37 +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: Sun, 14 Apr 2013 14:07:37 GMT
40
+ - request:
41
+ method: post
42
+ uri: http://admin1:123@localhost:19001/
43
+ body:
44
+ encoding: US-ASCII
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
+ - Sun, 14 Apr 2013 14:07:38 +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: Sun, 14 Apr 2013 14:07:38 GMT
77
+ - request:
78
+ method: post
79
+ uri: http://admin1:123@localhost:19001/
80
+ body:
81
+ encoding: US-ASCII
82
+ string: ! '{"method":"getnewaddress","params":["1"],"id":"jsonrpc"}'
83
+ headers:
84
+ Accept:
85
+ - ! '*/*; q=0.5, application/xml'
86
+ Accept-Encoding:
87
+ - gzip, deflate
88
+ Content-Length:
89
+ - '56'
90
+ User-Agent:
91
+ - Ruby
92
+ response:
93
+ status:
94
+ code: 200
95
+ message: OK
96
+ headers:
97
+ Date:
98
+ - Sun, 14 Apr 2013 14:07:38 +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: Sun, 14 Apr 2013 14:07:38 GMT
114
+ - request:
115
+ method: post
116
+ uri: http://admin1:123@localhost:19001/
117
+ body:
118
+ encoding: US-ASCII
119
+ string: ! '{"method":"move","params":["","1",1.1,0],"id":"jsonrpc"}'
120
+ headers:
121
+ Accept:
122
+ - ! '*/*; q=0.5, application/xml'
123
+ Accept-Encoding:
124
+ - gzip, deflate
125
+ Content-Length:
126
+ - '56'
127
+ User-Agent:
128
+ - Ruby
129
+ response:
130
+ status:
131
+ code: 200
132
+ message: OK
133
+ headers:
134
+ Date:
135
+ - Sun, 14 Apr 2013 14:07:38 +0000
136
+ Connection:
137
+ - keep-alive
138
+ Content-Length:
139
+ - '44'
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":true,"error":null,"id":"jsonrpc"}
147
+
148
+ '
149
+ http_version:
150
+ recorded_at: Sun, 14 Apr 2013 14:07:38 GMT
151
+ - request:
152
+ method: post
153
+ uri: http://admin1:123@localhost:19001/
154
+ body:
155
+ encoding: US-ASCII
156
+ string: ! '{"method":"move","params":["","1",0.5,0],"id":"jsonrpc"}'
157
+ headers:
158
+ Accept:
159
+ - ! '*/*; q=0.5, application/xml'
160
+ Accept-Encoding:
161
+ - gzip, deflate
162
+ Content-Length:
163
+ - '56'
164
+ User-Agent:
165
+ - Ruby
166
+ response:
167
+ status:
168
+ code: 200
169
+ message: OK
170
+ headers:
171
+ Date:
172
+ - Sun, 14 Apr 2013 14:07:38 +0000
173
+ Connection:
174
+ - keep-alive
175
+ Content-Length:
176
+ - '44'
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":true,"error":null,"id":"jsonrpc"}
184
+
185
+ '
186
+ http_version:
187
+ recorded_at: Sun, 14 Apr 2013 14:07:38 GMT
188
+ - request:
189
+ method: post
190
+ uri: http://admin1:123@localhost:19001/
191
+ body:
192
+ encoding: US-ASCII
193
+ string: ! '{"method":"getbalance","params":["1",0],"id":"jsonrpc"}'
194
+ headers:
195
+ Accept:
196
+ - ! '*/*; q=0.5, application/xml'
197
+ Accept-Encoding:
198
+ - gzip, deflate
199
+ Content-Length:
200
+ - '55'
201
+ User-Agent:
202
+ - Ruby
203
+ response:
204
+ status:
205
+ code: 200
206
+ message: OK
207
+ headers:
208
+ Date:
209
+ - Sun, 14 Apr 2013 14:07:38 +0000
210
+ Connection:
211
+ - keep-alive
212
+ Content-Length:
213
+ - '50'
214
+ Content-Type:
215
+ - application/json
216
+ Server:
217
+ - bitcoin-json-rpc/v0.7.2-beta
218
+ body:
219
+ encoding: US-ASCII
220
+ string: ! '{"result":1.60000000,"error":null,"id":"jsonrpc"}
221
+
222
+ '
223
+ http_version:
224
+ recorded_at: Sun, 14 Apr 2013 14:07:38 GMT
225
+ recorded_with: VCR 2.4.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bit_wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-13 00:00:00.000000000 Z
12
+ date: 2013-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bitcoin-client
@@ -201,6 +201,7 @@ files:
201
201
  - spec/fixtures/vcr_cassettes/BitWallet_Addresses/new/.yml
202
202
  - spec/fixtures/vcr_cassettes/BitWallet_Transaction/on_initialization/should_be_able_to_take_a_bitcoind_hash.yml
203
203
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_accounts/should_return_array_of_BitWallet_Accounts.yml
204
+ - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_move/should_move_funds_from_one_account_to_another.yml
204
205
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_allow_overriding_of_the_transaction_limit.yml
205
206
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_return_the_most_recent_transactions_of_all_accounts_defaulting_to_10_transactions.yml
206
207
  - spec/spec_helper.rb
@@ -267,6 +268,7 @@ test_files:
267
268
  - spec/fixtures/vcr_cassettes/BitWallet_Addresses/new/.yml
268
269
  - spec/fixtures/vcr_cassettes/BitWallet_Transaction/on_initialization/should_be_able_to_take_a_bitcoind_hash.yml
269
270
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_accounts/should_return_array_of_BitWallet_Accounts.yml
271
+ - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_move/should_move_funds_from_one_account_to_another.yml
270
272
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_allow_overriding_of_the_transaction_limit.yml
271
273
  - spec/fixtures/vcr_cassettes/BitWallet_Wallet/_recent_transactions/should_return_the_most_recent_transactions_of_all_accounts_defaulting_to_10_transactions.yml
272
274
  - spec/spec_helper.rb