cryptobank 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +5 -5
- data/README.md +5 -5
- data/cryptobank.gemspec +2 -2
- data/lib/cryptobank.rb +492 -463
- data/lib/cryptobank/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40f417190c2c9c8e45f58144545fc9e3bc1fb829
|
4
|
+
data.tar.gz: 7360a0f8a7e9007766ad7e990d863b404eefdda2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a183d99f1b3540e94c8222be5091f86c2dd8c0d70286bb0c01082455df87ed1cddf7e351b725431731f4093538496929bf3f7a3933b1eda6e9d89be9c9dcd8a6
|
7
|
+
data.tar.gz: 73daced9c4dd511b12e31165221363799f3b72bd29703403d2f77442e467ac8d0bf8bac43f31af2d861cfa940bba58b55a1317d8c4fda7ece4b9cc9a11efb162
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cryptobank (0.1.
|
5
|
-
httparty
|
4
|
+
cryptobank (0.1.1)
|
5
|
+
httparty (~> 0.15.6)
|
6
|
+
json (~> 2.1.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
httparty (0.
|
11
|
-
json (~> 1.8)
|
11
|
+
httparty (0.15.6)
|
12
12
|
multi_xml (>= 0.5.2)
|
13
|
-
json (1.
|
13
|
+
json (2.1.0)
|
14
14
|
minitest (5.10.3)
|
15
15
|
multi_xml (0.6.0)
|
16
16
|
rake (10.5.0)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Cryptobank provides Ruby wrappers for the Bitcoin API JSON-RPC.
|
4
4
|
|
5
|
-
This gem is still in development. Please feel free to contribute and make a pull request. As the gem is called 'cryptobank', it will
|
5
|
+
This gem is still in development. Please feel free to contribute and make a pull request. As the gem is called 'cryptobank', it will evolve into a more general toolbox for working with crypocurrencies.
|
6
6
|
|
7
7
|
|
8
8
|
## Installation
|
@@ -31,8 +31,8 @@ end
|
|
31
31
|
Bitcoind.configure do |config|
|
32
32
|
config.host = '127.0.0.1' # default: 'localhost'
|
33
33
|
config.port = 8332 # default: 8543
|
34
|
-
config.user = '
|
35
|
-
config.password = '
|
34
|
+
config.user = 'lion' # default: 'rpcuser'
|
35
|
+
config.password = 'tiger' # default: 'rpcpassword'
|
36
36
|
end
|
37
37
|
|
38
38
|
Bitcoind.new_address #=> '14gnToPKhRKhRKXZHV4mJyu8N5EFAoFU6G'
|
@@ -52,7 +52,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
52
52
|
|
53
53
|
## Contributing
|
54
54
|
|
55
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Grace/Cryptobank. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
56
56
|
|
57
57
|
## License
|
58
58
|
|
@@ -64,4 +64,4 @@ Everyone interacting in the Cryptobank project’s codebases, issue trackers, ch
|
|
64
64
|
|
65
65
|
## Credit
|
66
66
|
|
67
|
-
Credit goes to the gem '
|
67
|
+
Credit goes to the gem 'coinable' for inspiring this gem.
|
data/cryptobank.gemspec
CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.add_runtime_dependency '
|
32
|
-
|
31
|
+
spec.add_runtime_dependency 'json', '~> 2.1.0'
|
32
|
+
spec.add_runtime_dependency 'httparty', '~> 0.15.6'
|
33
33
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
34
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
35
35
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
data/lib/cryptobank.rb
CHANGED
@@ -5,467 +5,496 @@ require 'cryptobank/error'
|
|
5
5
|
|
6
6
|
module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
8
|
+
HEADERS = {
|
9
|
+
'Content-Type' => 'application/json',
|
10
|
+
'Accept' => 'application/json'
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
attr_writer :host, :port, :user, :password
|
14
|
+
|
15
|
+
def host
|
16
|
+
@host || 'localhost'
|
17
|
+
end
|
18
|
+
|
19
|
+
def port
|
20
|
+
@port || 8332
|
21
|
+
end
|
22
|
+
|
23
|
+
def user
|
24
|
+
@user || 'rpcuser'
|
25
|
+
end
|
26
|
+
|
27
|
+
def password
|
28
|
+
@password || 'rpcpassword'
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure
|
32
|
+
yield self
|
33
|
+
end
|
34
|
+
|
35
|
+
# addmultisigaddress
|
36
|
+
def add_multisig_address(minimum_number_of_sigs, key_or_addresses, account = '')
|
37
|
+
payload = {
|
38
|
+
method: 'addmultisigaddress'
|
39
|
+
}
|
40
|
+
payload[:params] = [minimum_number_of_sigs.to_int, key_or_addresses.to_string, account.to_string]
|
41
|
+
request(payload)
|
42
|
+
end
|
43
|
+
|
44
|
+
# addnode
|
45
|
+
def add_node
|
46
|
+
raise NotImplementedError
|
47
|
+
end
|
48
|
+
|
49
|
+
# backupwallet
|
50
|
+
def backup_wallet
|
51
|
+
raise NotImplementedError
|
52
|
+
end
|
53
|
+
|
54
|
+
# createmultisig
|
55
|
+
def create_multisig
|
56
|
+
raise NotImplementedError
|
57
|
+
end
|
58
|
+
|
59
|
+
# createrawtransaction
|
60
|
+
def create_raw_transaction
|
61
|
+
raise NotImplementedError
|
62
|
+
end
|
63
|
+
|
64
|
+
# decoderawtransaction
|
65
|
+
def decode_raw_transaction
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
68
|
+
|
69
|
+
# dumpprivkey
|
70
|
+
def dump_priv_key
|
71
|
+
raise NotImplementedError
|
72
|
+
end
|
73
|
+
|
74
|
+
# encryptwallet
|
75
|
+
def encrypt_wallet
|
76
|
+
raise NotImplementedError
|
77
|
+
end
|
78
|
+
|
79
|
+
# getaccount
|
80
|
+
# A P2PKH or P2SH Bitcoin address belonging either to a specific account or the default account (“”)
|
81
|
+
# returns a base58 string
|
82
|
+
def account(bitcoin_address)
|
83
|
+
payload = {
|
84
|
+
method: 'getaccount'
|
85
|
+
}
|
86
|
+
payload[:params] = [bitcoin_address.to_string]
|
87
|
+
request(payload)
|
88
|
+
end
|
89
|
+
|
90
|
+
# getaddednodeinfo
|
91
|
+
def added_node_info
|
92
|
+
raise NotImplementedError
|
93
|
+
end
|
94
|
+
|
95
|
+
# getbalance
|
96
|
+
# There are additional parameters on the RPC docs to be implemented https://bitcoin.org/en/developer-reference#getbalance
|
97
|
+
def balance(account = nil)
|
98
|
+
payload = {
|
99
|
+
method: 'getbalance'
|
100
|
+
}
|
101
|
+
payload[:params] = [account] unless account.nil?
|
102
|
+
request(payload)
|
103
|
+
end
|
104
|
+
|
105
|
+
# getbestblockhash
|
106
|
+
def best_block_hash
|
107
|
+
raise NotImplementedError
|
108
|
+
end
|
109
|
+
|
110
|
+
# getblock
|
111
|
+
def block(verbosity = nil)
|
112
|
+
payload = {
|
113
|
+
method: 'getblock'
|
114
|
+
}
|
115
|
+
payload[:params] = [template_request] unless verbosity.nil?
|
116
|
+
request(payload)
|
117
|
+
end
|
118
|
+
|
119
|
+
# getblockhash
|
120
|
+
def block_hash
|
121
|
+
payload = {
|
122
|
+
method: 'getblockhash'
|
123
|
+
}
|
124
|
+
request(payload)
|
125
|
+
end
|
126
|
+
|
127
|
+
# getblockcount
|
128
|
+
def block_count
|
129
|
+
payload = {
|
130
|
+
method: 'getblockcount'
|
131
|
+
}
|
132
|
+
request(payload)
|
133
|
+
end
|
134
|
+
|
135
|
+
# getblocktemplate
|
136
|
+
def block_template(template_request = nil)
|
137
|
+
payload = {
|
138
|
+
method: 'getblocktemplate'
|
139
|
+
}
|
140
|
+
payload[:params] = [template_request] unless template_request.nil?
|
141
|
+
request(payload)
|
142
|
+
end
|
143
|
+
|
144
|
+
# getconnectioncount
|
145
|
+
def connection_count
|
146
|
+
payload = {
|
147
|
+
method: 'getconnectioncount'
|
148
|
+
}
|
149
|
+
request(payload)
|
150
|
+
end
|
151
|
+
|
152
|
+
# getdifficulty
|
153
|
+
def difficulty
|
154
|
+
payload = {
|
155
|
+
method: 'getdifficulty'
|
156
|
+
}
|
157
|
+
request(payload)
|
158
|
+
end
|
159
|
+
|
160
|
+
# getgenerate
|
161
|
+
def generate
|
162
|
+
payload = {
|
163
|
+
method: 'getgenerate'
|
164
|
+
}
|
165
|
+
request(payload)
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_account_addresses(account)
|
169
|
+
payload = {
|
170
|
+
method: 'getaddressesbyaccount'
|
171
|
+
}
|
172
|
+
payload[:params] = [account]
|
173
|
+
request(payload)
|
174
|
+
end
|
175
|
+
|
176
|
+
# gethashespersec
|
177
|
+
def hashes_per_sec
|
178
|
+
raise NotImplementedError
|
179
|
+
end
|
180
|
+
|
181
|
+
# getinfo
|
182
|
+
def info
|
183
|
+
payload = {
|
184
|
+
method: 'getwalletinfo'
|
185
|
+
}
|
186
|
+
request(payload)
|
187
|
+
end
|
188
|
+
|
189
|
+
# getmempoolinfo
|
190
|
+
def memory_pool_info
|
191
|
+
payload = {
|
192
|
+
method: 'getmempoolinfo'
|
193
|
+
}
|
194
|
+
request(payload)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# getmininginfo
|
199
|
+
def mining_info
|
200
|
+
payload = {
|
201
|
+
method: 'getmininginfo'
|
202
|
+
}
|
203
|
+
request(payload)
|
204
|
+
end
|
205
|
+
|
206
|
+
# getnewaddress
|
207
|
+
def new_address(account = nil)
|
208
|
+
payload = {
|
209
|
+
method: 'getnewaddress'
|
210
|
+
}
|
211
|
+
payload[:params] = [account] unless account.nil?
|
212
|
+
request(payload)
|
213
|
+
end
|
214
|
+
|
215
|
+
# getpeerinfo
|
216
|
+
def peer_info
|
217
|
+
payload = {
|
218
|
+
method: 'getpeerinfo'
|
219
|
+
}
|
220
|
+
request(payload)
|
221
|
+
end
|
222
|
+
|
223
|
+
# getrawchangeaddress
|
224
|
+
def raw_change_address
|
225
|
+
payload = {
|
226
|
+
method: 'getrawchangeaddress'
|
227
|
+
}
|
228
|
+
request(payload)
|
229
|
+
end
|
230
|
+
|
231
|
+
# getrawmempool
|
232
|
+
def raw_mem_pool(verbose_format = false)
|
233
|
+
payload = {
|
234
|
+
method: 'getrawmempool'
|
235
|
+
}
|
236
|
+
payload[:params] = [1] if verbose_format?
|
237
|
+
request(payload)
|
238
|
+
end
|
239
|
+
|
240
|
+
# getrawtransaction
|
241
|
+
# The TXID of the transaction to get, encoded as hex in RPC byte order
|
242
|
+
def raw_transaction(txid)
|
243
|
+
payload = {
|
244
|
+
method: 'getrawtransaction'
|
245
|
+
}
|
246
|
+
payload[:params] = [txid]
|
247
|
+
request(payload)
|
248
|
+
end
|
249
|
+
|
250
|
+
# getreceivedbyaddress
|
251
|
+
'''The getreceivedbyaddress RPC returns the total amount received by the specified address in transactions with the specified number of confirmations. It does not count coinbase transactions.'''
|
252
|
+
def received_by_address(address)
|
253
|
+
payload = {
|
254
|
+
method: 'getreceivedbyaddress'
|
255
|
+
}
|
256
|
+
payload[:params] = [address]
|
257
|
+
request(payload)
|
258
|
+
end
|
259
|
+
|
260
|
+
# gettransaction
|
261
|
+
def transaction(txid)
|
262
|
+
payload = {
|
263
|
+
method: 'gettransaction',
|
264
|
+
params: [txid]
|
265
|
+
}
|
266
|
+
|
267
|
+
request(payload)
|
268
|
+
end
|
269
|
+
|
270
|
+
# gettxout
|
271
|
+
def tx_out
|
272
|
+
raise NotImplementedError
|
273
|
+
end
|
274
|
+
|
275
|
+
# gettxoutsetinfo
|
276
|
+
def tx_out_set_info
|
277
|
+
raise NotImplementedError
|
278
|
+
end
|
279
|
+
|
280
|
+
# getwork
|
281
|
+
def work
|
282
|
+
raise NotImplementedError
|
283
|
+
end
|
284
|
+
|
285
|
+
# help
|
286
|
+
def help
|
287
|
+
raise NotImplementedError
|
288
|
+
end
|
289
|
+
|
290
|
+
# importprivkey
|
291
|
+
def import_priv_key
|
292
|
+
raise NotImplementedError
|
293
|
+
end
|
294
|
+
|
295
|
+
# keypoolrefill
|
296
|
+
def keypool_refill
|
297
|
+
raise NotImplementedError
|
298
|
+
end
|
299
|
+
|
300
|
+
# listaccounts
|
301
|
+
def list_accounts(minconf = nil)
|
302
|
+
payload = {
|
303
|
+
method: 'listaccounts'
|
304
|
+
}
|
305
|
+
|
306
|
+
payload[:params] = [minconf] unless minconf.nil?
|
307
|
+
|
308
|
+
request(payload)
|
309
|
+
end
|
310
|
+
|
311
|
+
# listaddressgroupings
|
312
|
+
def list_address_groupings
|
313
|
+
raise NotImplementedError
|
314
|
+
end
|
315
|
+
|
316
|
+
# listreceivedbyaccount
|
317
|
+
def list_received_by_account
|
318
|
+
raise NotImplementedError
|
319
|
+
end
|
320
|
+
|
321
|
+
# listreceivedbyaddress
|
322
|
+
def list_received_by_address
|
323
|
+
raise NotImplementedError
|
324
|
+
end
|
325
|
+
|
326
|
+
# listsinceblock
|
327
|
+
def list_since_block
|
328
|
+
raise NotImplementedError
|
329
|
+
end
|
330
|
+
|
331
|
+
# listtransactions
|
332
|
+
def list_transactions(account = nil, count = nil, from = nil)
|
333
|
+
payload = {
|
334
|
+
method: 'listtransactions'
|
335
|
+
}
|
336
|
+
unless account.nil?
|
337
|
+
payload[:params] = [account]
|
338
|
+
payload[:params] << count unless count.nil?
|
339
|
+
payload[:params] << from unless from.nil?
|
340
|
+
end
|
341
|
+
request(payload)
|
342
|
+
end
|
343
|
+
|
344
|
+
# listunspent
|
345
|
+
def list_unspent
|
346
|
+
raise NotImplementedError
|
347
|
+
end
|
348
|
+
|
349
|
+
# listlockunspent
|
350
|
+
def list_lock_unspent
|
351
|
+
raise NotImplementedError
|
352
|
+
end
|
353
|
+
|
354
|
+
# lockunspent
|
355
|
+
def lock_unspent
|
356
|
+
raise NotImplementedError
|
357
|
+
end
|
358
|
+
|
359
|
+
# move
|
360
|
+
def move
|
361
|
+
raise NotImplementedError
|
362
|
+
end
|
363
|
+
|
364
|
+
# sendfrom
|
365
|
+
def send_from
|
366
|
+
raise NotImplementedError
|
367
|
+
end
|
368
|
+
|
369
|
+
# sendmany
|
370
|
+
def send_many
|
371
|
+
raise NotImplementedError
|
372
|
+
end
|
373
|
+
|
374
|
+
# sendrawtransaction
|
375
|
+
def send_raw_transaction
|
376
|
+
raise NotImplementedError
|
377
|
+
end
|
378
|
+
|
379
|
+
def send_money(address, amount)
|
380
|
+
payload = {
|
381
|
+
method: 'sendtoaddress',
|
382
|
+
params: [address, amount]
|
383
|
+
}
|
384
|
+
payload[:params]
|
385
|
+
request(payload)
|
386
|
+
end
|
387
|
+
|
388
|
+
def send_from_to(from_address, to_address, amount)
|
389
|
+
payload = {
|
390
|
+
method: 'move'
|
391
|
+
}
|
392
|
+
|
393
|
+
payload[:params] = [from_address, to_address, amount]
|
394
|
+
|
395
|
+
request(payload)
|
396
|
+
end
|
397
|
+
|
398
|
+
def send_from_address_to_address(from_address, to_address, amount)
|
399
|
+
payload = {
|
400
|
+
method: 'move'
|
401
|
+
}
|
402
|
+
|
403
|
+
payload[:params] = [from_address, to_address, amount]
|
404
|
+
|
405
|
+
request(payload)
|
406
|
+
end
|
407
|
+
|
408
|
+
# sendtoaddress
|
409
|
+
def send_to_address(address, amount, comment = nil, comment_to = nil)
|
410
|
+
payload = {
|
411
|
+
method: 'sendtoaddress',
|
412
|
+
params: [address, amount]
|
413
|
+
}
|
414
|
+
|
415
|
+
payload[:params] << comment unless comment.nil?
|
416
|
+
payload[:params] << comment_to unless comment_to.nil?
|
417
|
+
|
418
|
+
request(payload)
|
419
|
+
end
|
420
|
+
|
421
|
+
# setaccount
|
422
|
+
def account=(_)
|
423
|
+
raise NotImplementedError
|
424
|
+
end
|
425
|
+
|
426
|
+
# setgenerate
|
427
|
+
def generate=(_)
|
428
|
+
raise NotImplementedError
|
429
|
+
end
|
430
|
+
|
431
|
+
# settxfee
|
432
|
+
def tx_fee=(_)
|
433
|
+
raise NotImplementedError
|
434
|
+
end
|
435
|
+
|
436
|
+
# signmessage
|
437
|
+
def sign_message
|
438
|
+
raise NotImplementedError
|
439
|
+
end
|
440
|
+
|
441
|
+
# signrawtransaction
|
442
|
+
def sign_raw_transaction
|
443
|
+
raise NotImplementedError
|
444
|
+
end
|
445
|
+
|
446
|
+
# stop
|
447
|
+
def stop
|
448
|
+
raise NotImplementedError
|
449
|
+
end
|
450
|
+
|
451
|
+
# submitblock
|
452
|
+
def submit_block
|
453
|
+
raise NotImplementedError
|
454
|
+
end
|
455
|
+
|
456
|
+
# validateaddress
|
457
|
+
def validate_address(address)
|
458
|
+
payload = {
|
459
|
+
method: 'validateaddress',
|
460
|
+
params: [address]
|
461
|
+
}
|
462
|
+
|
463
|
+
request(payload)
|
464
|
+
end
|
465
|
+
|
466
|
+
# verifymessage
|
467
|
+
def verify_message
|
468
|
+
raise NotImplementedError
|
469
|
+
end
|
470
|
+
|
471
|
+
# walletlock
|
472
|
+
def wallet_lock
|
473
|
+
raise NotImplementedError
|
474
|
+
end
|
475
|
+
|
476
|
+
# walletpassphrase
|
477
|
+
def wallet_passphrase
|
478
|
+
raise NotImplementedError
|
479
|
+
end
|
480
|
+
|
481
|
+
# walletpassphrasechange
|
482
|
+
def wallet_passphrase_change
|
483
|
+
raise NotImplementedError
|
484
|
+
end
|
485
|
+
|
486
|
+
def valid_address?(address)
|
487
|
+
validate_address(address)['isvalid']
|
488
|
+
end
|
489
|
+
|
490
|
+
private
|
491
|
+
|
492
|
+
def request(payload)
|
493
|
+
response = HTTParty.post(url, body: payload.to_json, headers: HEADERS)
|
494
|
+
raise Error, response.message unless response.code == 200
|
495
|
+
JSON.parse(response.body)['result']
|
496
|
+
end
|
497
|
+
|
498
|
+
def url
|
499
|
+
"http://#{user}:#{password}@#{host}:#{port}"
|
471
500
|
end
|
data/lib/cryptobank/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptobank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grace Christenbery
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: httparty
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
33
|
+
version: 0.15.6
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: 0.15.6
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|