cryptobank 0.1.2 → 0.1.3
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/lib/cryptobank.rb +246 -302
- data/lib/cryptobank/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90d9c95cead9c38573e536b4ae34d5be1fe4a25
|
4
|
+
data.tar.gz: d7289d42ddb38ac7c761c57de6705ed5b8b6209d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7698b8b9f23ded54c0c59f4e15ef49053eedf633d3edca15651e94c821b7290942f3bcacf3de0fc9a58427746e8b63128e6be1be60e47b65260bdf14411ace1f
|
7
|
+
data.tar.gz: 2ec7bcb621416ae9e767a1aca602df7fb473a1ab20965980579582b70d61639f26f06efb0f449d81e8ac68c1feb5df68a36b75e8a1d98d05a66697fbb349192f
|
data/lib/cryptobank.rb
CHANGED
@@ -3,8 +3,7 @@ require 'httparty'
|
|
3
3
|
require 'cryptobank/version'
|
4
4
|
require 'cryptobank/error'
|
5
5
|
|
6
|
-
module Cryptobank
|
7
|
-
|
6
|
+
module Cryptobank
|
8
7
|
HEADERS = {
|
9
8
|
'Content-Type' => 'application/json',
|
10
9
|
'Accept' => 'application/json'
|
@@ -33,12 +32,8 @@ module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
|
33
32
|
end
|
34
33
|
|
35
34
|
# addmultisigaddress
|
36
|
-
def add_multisig_address
|
37
|
-
|
38
|
-
method: 'addmultisigaddress'
|
39
|
-
}
|
40
|
-
payload[:params] = [minimum_number_of_sigs.to_int, key_or_addresses.to_string, account.to_string]
|
41
|
-
request(payload)
|
35
|
+
def add_multisig_address
|
36
|
+
raise NotImplementedError
|
42
37
|
end
|
43
38
|
|
44
39
|
# addnode
|
@@ -87,11 +82,21 @@ module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
|
87
82
|
request(payload)
|
88
83
|
end
|
89
84
|
|
85
|
+
# getaccountaddress
|
86
|
+
def account_address
|
87
|
+
raise NotImplementedError
|
88
|
+
end
|
89
|
+
|
90
90
|
# getaddednodeinfo
|
91
91
|
def added_node_info
|
92
92
|
raise NotImplementedError
|
93
93
|
end
|
94
94
|
|
95
|
+
# getaddressesbyaccount
|
96
|
+
def addresses_by_account
|
97
|
+
raise NotImplementedError
|
98
|
+
end
|
99
|
+
|
95
100
|
# getbalance
|
96
101
|
# There are additional parameters on the RPC docs to be implemented https://bitcoin.org/en/developer-reference#getbalance
|
97
102
|
def balance(account = nil)
|
@@ -108,69 +113,43 @@ module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
|
108
113
|
end
|
109
114
|
|
110
115
|
# getblock
|
111
|
-
def block
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
def block
|
117
|
+
raise NotImplementedError
|
118
|
+
end
|
119
|
+
|
120
|
+
# getblockcount
|
121
|
+
def block_count
|
122
|
+
raise NotImplementedError
|
117
123
|
end
|
118
124
|
|
119
125
|
# getblockhash
|
120
126
|
def block_hash
|
121
|
-
|
122
|
-
method: 'getblockhash'
|
123
|
-
}
|
124
|
-
request(payload)
|
127
|
+
raise NotImplementedError
|
125
128
|
end
|
126
129
|
|
127
|
-
#
|
128
|
-
def
|
129
|
-
|
130
|
-
method: 'getblockcount'
|
131
|
-
}
|
132
|
-
request(payload)
|
130
|
+
# getblocknumber
|
131
|
+
def block_number
|
132
|
+
raise NotImplementedError
|
133
133
|
end
|
134
134
|
|
135
135
|
# getblocktemplate
|
136
|
-
def block_template
|
137
|
-
|
138
|
-
method: 'getblocktemplate'
|
139
|
-
}
|
140
|
-
payload[:params] = [template_request] unless template_request.nil?
|
141
|
-
request(payload)
|
136
|
+
def block_template
|
137
|
+
raise NotImplementedError
|
142
138
|
end
|
143
139
|
|
144
140
|
# getconnectioncount
|
145
141
|
def connection_count
|
146
|
-
|
147
|
-
method: 'getconnectioncount'
|
148
|
-
}
|
149
|
-
request(payload)
|
142
|
+
raise NotImplementedError
|
150
143
|
end
|
151
144
|
|
152
145
|
# getdifficulty
|
153
146
|
def difficulty
|
154
|
-
|
155
|
-
method: 'getdifficulty'
|
156
|
-
}
|
157
|
-
request(payload)
|
147
|
+
raise NotImplementedError
|
158
148
|
end
|
159
149
|
|
160
150
|
# getgenerate
|
161
151
|
def generate
|
162
|
-
|
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)
|
152
|
+
raise NotImplementedError
|
174
153
|
end
|
175
154
|
|
176
155
|
# gethashespersec
|
@@ -183,318 +162,283 @@ module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
|
183
162
|
payload = {
|
184
163
|
method: 'getwalletinfo'
|
185
164
|
}
|
165
|
+
|
186
166
|
request(payload)
|
187
167
|
end
|
188
168
|
|
189
|
-
#
|
190
|
-
def
|
169
|
+
# getmemorypool
|
170
|
+
def memory_pool
|
171
|
+
raise NotImplementedError
|
172
|
+
end
|
173
|
+
|
174
|
+
# getmininginfo
|
175
|
+
def mining_info
|
176
|
+
raise NotImplementedError
|
177
|
+
end
|
178
|
+
|
179
|
+
# getnewaddress
|
180
|
+
def new_address(account = nil)
|
191
181
|
payload = {
|
192
|
-
method: '
|
182
|
+
method: 'getnewaddress'
|
193
183
|
}
|
194
|
-
request(payload)
|
195
|
-
end
|
196
|
-
end
|
197
184
|
|
198
|
-
|
199
|
-
def mining_info
|
200
|
-
payload = {
|
201
|
-
method: 'getmininginfo'
|
202
|
-
}
|
203
|
-
request(payload)
|
204
|
-
end
|
185
|
+
payload[:params] = [account] unless account.nil?
|
205
186
|
|
206
|
-
|
207
|
-
|
208
|
-
payload = {
|
209
|
-
method: 'getnewaddress'
|
210
|
-
}
|
211
|
-
payload[:params] = [account] unless account.nil?
|
212
|
-
request(payload)
|
213
|
-
end
|
187
|
+
request(payload)
|
188
|
+
end
|
214
189
|
|
215
|
-
# getpeerinfo
|
216
|
-
def peer_info
|
217
|
-
|
218
|
-
|
219
|
-
}
|
220
|
-
request(payload)
|
221
|
-
end
|
190
|
+
# getpeerinfo
|
191
|
+
def peer_info
|
192
|
+
raise NotImplementedError
|
193
|
+
end
|
222
194
|
|
223
|
-
# getrawchangeaddress
|
224
|
-
def raw_change_address
|
225
|
-
|
226
|
-
|
227
|
-
}
|
228
|
-
request(payload)
|
229
|
-
end
|
195
|
+
# getrawchangeaddress
|
196
|
+
def raw_change_address
|
197
|
+
raise NotImplementedError
|
198
|
+
end
|
230
199
|
|
231
|
-
# getrawmempool
|
232
|
-
def raw_mem_pool
|
233
|
-
|
234
|
-
|
235
|
-
}
|
236
|
-
payload[:params] = [1] if verbose_format?
|
237
|
-
request(payload)
|
238
|
-
end
|
200
|
+
# getrawmempool
|
201
|
+
def raw_mem_pool
|
202
|
+
raise NotImplementedError
|
203
|
+
end
|
239
204
|
|
240
|
-
# getrawtransaction
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
method: 'getrawtransaction'
|
245
|
-
}
|
246
|
-
payload[:params] = [txid]
|
247
|
-
request(payload)
|
248
|
-
end
|
205
|
+
# getrawtransaction
|
206
|
+
def raw_transaction
|
207
|
+
raise NotImplementedError
|
208
|
+
end
|
249
209
|
|
250
|
-
#
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
method: 'getreceivedbyaddress'
|
255
|
-
}
|
256
|
-
payload[:params] = [address]
|
257
|
-
request(payload)
|
258
|
-
end
|
210
|
+
# getreceivedbyaccount
|
211
|
+
def received_by_account
|
212
|
+
raise NotImplementedError
|
213
|
+
end
|
259
214
|
|
260
|
-
#
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
params: [txid]
|
265
|
-
}
|
215
|
+
# getreceivedbyaddress
|
216
|
+
def received_by_address
|
217
|
+
raise NotImplementedError
|
218
|
+
end
|
266
219
|
|
267
|
-
|
268
|
-
|
220
|
+
# gettransaction
|
221
|
+
def transaction(txid)
|
222
|
+
payload = {
|
223
|
+
method: 'gettransaction',
|
224
|
+
params: [txid]
|
225
|
+
}
|
269
226
|
|
270
|
-
|
271
|
-
|
272
|
-
raise NotImplementedError
|
273
|
-
end
|
227
|
+
request(payload)
|
228
|
+
end
|
274
229
|
|
275
|
-
#
|
276
|
-
def
|
277
|
-
|
278
|
-
end
|
230
|
+
# gettxout
|
231
|
+
def tx_out
|
232
|
+
raise NotImplementedError
|
233
|
+
end
|
279
234
|
|
280
|
-
#
|
281
|
-
def
|
282
|
-
|
283
|
-
end
|
235
|
+
# gettxoutsetinfo
|
236
|
+
def tx_out_set_info
|
237
|
+
raise NotImplementedError
|
238
|
+
end
|
284
239
|
|
285
|
-
#
|
286
|
-
def
|
287
|
-
|
288
|
-
end
|
240
|
+
# getwork
|
241
|
+
def work
|
242
|
+
raise NotImplementedError
|
243
|
+
end
|
289
244
|
|
290
|
-
#
|
291
|
-
def
|
292
|
-
|
293
|
-
end
|
245
|
+
# help
|
246
|
+
def help
|
247
|
+
raise NotImplementedError
|
248
|
+
end
|
294
249
|
|
295
|
-
#
|
296
|
-
def
|
297
|
-
|
298
|
-
end
|
250
|
+
# importprivkey
|
251
|
+
def import_priv_key
|
252
|
+
raise NotImplementedError
|
253
|
+
end
|
299
254
|
|
300
|
-
#
|
301
|
-
def
|
302
|
-
|
303
|
-
|
304
|
-
}
|
255
|
+
# keypoolrefill
|
256
|
+
def keypool_refill
|
257
|
+
raise NotImplementedError
|
258
|
+
end
|
305
259
|
|
306
|
-
|
260
|
+
# listaccounts
|
261
|
+
def list_accounts(minconf = nil)
|
262
|
+
payload = {
|
263
|
+
method: 'listaccounts'
|
264
|
+
}
|
307
265
|
|
308
|
-
|
309
|
-
end
|
266
|
+
payload[:params] = [minconf] unless minconf.nil?
|
310
267
|
|
311
|
-
|
312
|
-
|
313
|
-
raise NotImplementedError
|
314
|
-
end
|
268
|
+
request(payload)
|
269
|
+
end
|
315
270
|
|
316
|
-
#
|
317
|
-
def
|
318
|
-
|
319
|
-
end
|
271
|
+
# listaddressgroupings
|
272
|
+
def list_address_groupings
|
273
|
+
raise NotImplementedError
|
274
|
+
end
|
320
275
|
|
321
|
-
#
|
322
|
-
def
|
323
|
-
|
324
|
-
end
|
276
|
+
# listreceivedbyaccount
|
277
|
+
def list_received_by_account
|
278
|
+
raise NotImplementedError
|
279
|
+
end
|
325
280
|
|
326
|
-
#
|
327
|
-
def
|
328
|
-
|
329
|
-
end
|
281
|
+
# listreceivedbyaddress
|
282
|
+
def list_received_by_address
|
283
|
+
raise NotImplementedError
|
284
|
+
end
|
330
285
|
|
331
|
-
#
|
332
|
-
def
|
333
|
-
|
334
|
-
|
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
|
286
|
+
# listsinceblock
|
287
|
+
def list_since_block
|
288
|
+
raise NotImplementedError
|
289
|
+
end
|
343
290
|
|
344
|
-
#
|
345
|
-
def
|
346
|
-
|
347
|
-
|
291
|
+
# listtransactions
|
292
|
+
def list_transactions(account = nil, count = nil, from = nil)
|
293
|
+
payload = {
|
294
|
+
method: 'listtransactions'
|
295
|
+
}
|
348
296
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
297
|
+
unless account.nil?
|
298
|
+
payload[:params] = [account]
|
299
|
+
payload[:params] << count unless count.nil?
|
300
|
+
payload[:params] << from unless from.nil?
|
301
|
+
end
|
353
302
|
|
354
|
-
|
355
|
-
|
356
|
-
raise NotImplementedError
|
357
|
-
end
|
303
|
+
request(payload)
|
304
|
+
end
|
358
305
|
|
359
|
-
#
|
360
|
-
def
|
361
|
-
|
362
|
-
end
|
306
|
+
# listunspent
|
307
|
+
def list_unspent
|
308
|
+
raise NotImplementedError
|
309
|
+
end
|
363
310
|
|
364
|
-
#
|
365
|
-
def
|
366
|
-
|
367
|
-
end
|
311
|
+
# listlockunspent
|
312
|
+
def list_lock_unspent
|
313
|
+
raise NotImplementedError
|
314
|
+
end
|
368
315
|
|
369
|
-
#
|
370
|
-
def
|
371
|
-
|
372
|
-
end
|
316
|
+
# lockunspent
|
317
|
+
def lock_unspent
|
318
|
+
raise NotImplementedError
|
319
|
+
end
|
373
320
|
|
374
|
-
#
|
375
|
-
def
|
376
|
-
|
377
|
-
|
321
|
+
# move
|
322
|
+
def move(from_account, to_account, amount)
|
323
|
+
payload = {
|
324
|
+
method: 'move'
|
325
|
+
}
|
378
326
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
params: [address, amount]
|
383
|
-
}
|
384
|
-
payload[:params]
|
385
|
-
request(payload)
|
386
|
-
end
|
327
|
+
payload[:params] = [from_account]
|
328
|
+
payload[:params] << to_account
|
329
|
+
payload[:params] << amount
|
387
330
|
|
388
|
-
|
389
|
-
|
390
|
-
method: 'move'
|
391
|
-
}
|
331
|
+
request(payload)
|
332
|
+
end
|
392
333
|
|
393
|
-
|
334
|
+
# sendfrom
|
335
|
+
def send_from
|
336
|
+
raise NotImplementedError
|
337
|
+
end
|
394
338
|
|
395
|
-
|
396
|
-
|
339
|
+
# sendmany
|
340
|
+
def send_many
|
341
|
+
raise NotImplementedError
|
342
|
+
end
|
397
343
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
344
|
+
# sendrawtransaction
|
345
|
+
def send_raw_transaction
|
346
|
+
raise NotImplementedError
|
347
|
+
end
|
402
348
|
|
403
|
-
|
349
|
+
# sendtoaddress
|
350
|
+
def send_to_address(address, amount, comment = nil, comment_to = nil)
|
351
|
+
payload = {
|
352
|
+
method: 'sendtoaddress',
|
353
|
+
params: [address, amount]
|
354
|
+
}
|
404
355
|
|
405
|
-
|
406
|
-
|
356
|
+
payload[:params] << comment unless comment.nil?
|
357
|
+
payload[:params] << comment_to unless comment_to.nil?
|
407
358
|
|
408
|
-
|
409
|
-
|
410
|
-
payload = {
|
411
|
-
method: 'sendtoaddress',
|
412
|
-
params: [address, amount]
|
413
|
-
}
|
359
|
+
request(payload)
|
360
|
+
end
|
414
361
|
|
415
|
-
|
416
|
-
|
362
|
+
# setaccount
|
363
|
+
def account=(_)
|
364
|
+
raise NotImplementedError
|
365
|
+
end
|
417
366
|
|
418
|
-
|
419
|
-
|
367
|
+
# setgenerate
|
368
|
+
def generate=(_)
|
369
|
+
raise NotImplementedError
|
370
|
+
end
|
420
371
|
|
421
|
-
#
|
422
|
-
def
|
423
|
-
|
424
|
-
end
|
372
|
+
# settxfee
|
373
|
+
def tx_fee=(_)
|
374
|
+
raise NotImplementedError
|
375
|
+
end
|
425
376
|
|
426
|
-
#
|
427
|
-
def
|
428
|
-
|
429
|
-
end
|
377
|
+
# signmessage
|
378
|
+
def sign_message
|
379
|
+
raise NotImplementedError
|
380
|
+
end
|
430
381
|
|
431
|
-
#
|
432
|
-
def
|
433
|
-
|
434
|
-
end
|
382
|
+
# signrawtransaction
|
383
|
+
def sign_raw_transaction
|
384
|
+
raise NotImplementedError
|
385
|
+
end
|
435
386
|
|
436
|
-
#
|
437
|
-
def
|
438
|
-
|
439
|
-
end
|
387
|
+
# stop
|
388
|
+
def stop
|
389
|
+
raise NotImplementedError
|
390
|
+
end
|
440
391
|
|
441
|
-
#
|
442
|
-
def
|
443
|
-
|
444
|
-
end
|
392
|
+
# submitblock
|
393
|
+
def submit_block
|
394
|
+
raise NotImplementedError
|
395
|
+
end
|
445
396
|
|
446
|
-
#
|
447
|
-
def
|
448
|
-
|
449
|
-
|
397
|
+
# validateaddress
|
398
|
+
def validate_address(address)
|
399
|
+
payload = {
|
400
|
+
method: 'validateaddress',
|
401
|
+
params: [address]
|
402
|
+
}
|
450
403
|
|
451
|
-
|
452
|
-
|
453
|
-
raise NotImplementedError
|
454
|
-
end
|
404
|
+
request(payload)
|
405
|
+
end
|
455
406
|
|
456
|
-
#
|
457
|
-
def
|
458
|
-
|
459
|
-
|
460
|
-
params: [address]
|
461
|
-
}
|
407
|
+
# verifymessage
|
408
|
+
def verify_message
|
409
|
+
raise NotImplementedError
|
410
|
+
end
|
462
411
|
|
463
|
-
|
464
|
-
|
412
|
+
# walletlock
|
413
|
+
def wallet_lock
|
414
|
+
raise NotImplementedError
|
415
|
+
end
|
465
416
|
|
466
|
-
#
|
467
|
-
def
|
468
|
-
|
469
|
-
end
|
417
|
+
# walletpassphrase
|
418
|
+
def wallet_passphrase
|
419
|
+
raise NotImplementedError
|
420
|
+
end
|
470
421
|
|
471
|
-
#
|
472
|
-
def
|
473
|
-
|
474
|
-
end
|
422
|
+
# walletpassphrasechange
|
423
|
+
def wallet_passphrase_change
|
424
|
+
raise NotImplementedError
|
425
|
+
end
|
475
426
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
end
|
427
|
+
def valid_address?(address)
|
428
|
+
validate_address(address)['isvalid']
|
429
|
+
end
|
480
430
|
|
481
|
-
|
482
|
-
def wallet_passphrase_change
|
483
|
-
raise NotImplementedError
|
484
|
-
end
|
431
|
+
private
|
485
432
|
|
486
|
-
def
|
487
|
-
|
488
|
-
end
|
433
|
+
def request(payload)
|
434
|
+
response = HTTParty.post(url, body: payload.to_json, headers: HEADERS)
|
489
435
|
|
490
|
-
|
436
|
+
raise Error, response.message unless response.code == 200
|
491
437
|
|
492
|
-
|
493
|
-
|
494
|
-
raise Error, response.message unless response.code == 200
|
495
|
-
JSON.parse(response.body)['result']
|
496
|
-
end
|
438
|
+
JSON.parse(response.body)['result']
|
439
|
+
end
|
497
440
|
|
498
|
-
def url
|
499
|
-
|
441
|
+
def url
|
442
|
+
"http://#{user}:#{password}@#{host}:#{port}"
|
443
|
+
end
|
500
444
|
end
|
data/lib/cryptobank/version.rb
CHANGED