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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40f417190c2c9c8e45f58144545fc9e3bc1fb829
4
- data.tar.gz: 7360a0f8a7e9007766ad7e990d863b404eefdda2
3
+ metadata.gz: f90d9c95cead9c38573e536b4ae34d5be1fe4a25
4
+ data.tar.gz: d7289d42ddb38ac7c761c57de6705ed5b8b6209d
5
5
  SHA512:
6
- metadata.gz: a183d99f1b3540e94c8222be5091f86c2dd8c0d70286bb0c01082455df87ed1cddf7e351b725431731f4093538496929bf3f7a3933b1eda6e9d89be9c9dcd8a6
7
- data.tar.gz: 73daced9c4dd511b12e31165221363799f3b72bd29703403d2f77442e467ac8d0bf8bac43f31af2d861cfa940bba58b55a1317d8c4fda7ece4b9cc9a11efb162
6
+ metadata.gz: 7698b8b9f23ded54c0c59f4e15ef49053eedf633d3edca15651e94c821b7290942f3bcacf3de0fc9a58427746e8b63128e6be1be60e47b65260bdf14411ace1f
7
+ data.tar.gz: 2ec7bcb621416ae9e767a1aca602df7fb473a1ab20965980579582b70d61639f26f06efb0f449d81e8ac68c1feb5df68a36b75e8a1d98d05a66697fbb349192f
@@ -3,8 +3,7 @@ require 'httparty'
3
3
  require 'cryptobank/version'
4
4
  require 'cryptobank/error'
5
5
 
6
- module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
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(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)
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(verbosity = nil)
112
- payload = {
113
- method: 'getblock'
114
- }
115
- payload[:params] = [template_request] unless verbosity.nil?
116
- request(payload)
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
- payload = {
122
- method: 'getblockhash'
123
- }
124
- request(payload)
127
+ raise NotImplementedError
125
128
  end
126
129
 
127
- # getblockcount
128
- def block_count
129
- payload = {
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(template_request = nil)
137
- payload = {
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
- payload = {
147
- method: 'getconnectioncount'
148
- }
149
- request(payload)
142
+ raise NotImplementedError
150
143
  end
151
144
 
152
145
  # getdifficulty
153
146
  def difficulty
154
- payload = {
155
- method: 'getdifficulty'
156
- }
157
- request(payload)
147
+ raise NotImplementedError
158
148
  end
159
149
 
160
150
  # getgenerate
161
151
  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)
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
- # getmempoolinfo
190
- def memory_pool_info
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: 'getmempoolinfo'
182
+ method: 'getnewaddress'
193
183
  }
194
- request(payload)
195
- end
196
- end
197
184
 
198
- # getmininginfo
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
- # 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
187
+ request(payload)
188
+ end
214
189
 
215
- # getpeerinfo
216
- def peer_info
217
- payload = {
218
- method: 'getpeerinfo'
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
- payload = {
226
- method: 'getrawchangeaddress'
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(verbose_format = false)
233
- payload = {
234
- method: 'getrawmempool'
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
- # 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
205
+ # getrawtransaction
206
+ def raw_transaction
207
+ raise NotImplementedError
208
+ end
249
209
 
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
210
+ # getreceivedbyaccount
211
+ def received_by_account
212
+ raise NotImplementedError
213
+ end
259
214
 
260
- # gettransaction
261
- def transaction(txid)
262
- payload = {
263
- method: 'gettransaction',
264
- params: [txid]
265
- }
215
+ # getreceivedbyaddress
216
+ def received_by_address
217
+ raise NotImplementedError
218
+ end
266
219
 
267
- request(payload)
268
- end
220
+ # gettransaction
221
+ def transaction(txid)
222
+ payload = {
223
+ method: 'gettransaction',
224
+ params: [txid]
225
+ }
269
226
 
270
- # gettxout
271
- def tx_out
272
- raise NotImplementedError
273
- end
227
+ request(payload)
228
+ end
274
229
 
275
- # gettxoutsetinfo
276
- def tx_out_set_info
277
- raise NotImplementedError
278
- end
230
+ # gettxout
231
+ def tx_out
232
+ raise NotImplementedError
233
+ end
279
234
 
280
- # getwork
281
- def work
282
- raise NotImplementedError
283
- end
235
+ # gettxoutsetinfo
236
+ def tx_out_set_info
237
+ raise NotImplementedError
238
+ end
284
239
 
285
- # help
286
- def help
287
- raise NotImplementedError
288
- end
240
+ # getwork
241
+ def work
242
+ raise NotImplementedError
243
+ end
289
244
 
290
- # importprivkey
291
- def import_priv_key
292
- raise NotImplementedError
293
- end
245
+ # help
246
+ def help
247
+ raise NotImplementedError
248
+ end
294
249
 
295
- # keypoolrefill
296
- def keypool_refill
297
- raise NotImplementedError
298
- end
250
+ # importprivkey
251
+ def import_priv_key
252
+ raise NotImplementedError
253
+ end
299
254
 
300
- # listaccounts
301
- def list_accounts(minconf = nil)
302
- payload = {
303
- method: 'listaccounts'
304
- }
255
+ # keypoolrefill
256
+ def keypool_refill
257
+ raise NotImplementedError
258
+ end
305
259
 
306
- payload[:params] = [minconf] unless minconf.nil?
260
+ # listaccounts
261
+ def list_accounts(minconf = nil)
262
+ payload = {
263
+ method: 'listaccounts'
264
+ }
307
265
 
308
- request(payload)
309
- end
266
+ payload[:params] = [minconf] unless minconf.nil?
310
267
 
311
- # listaddressgroupings
312
- def list_address_groupings
313
- raise NotImplementedError
314
- end
268
+ request(payload)
269
+ end
315
270
 
316
- # listreceivedbyaccount
317
- def list_received_by_account
318
- raise NotImplementedError
319
- end
271
+ # listaddressgroupings
272
+ def list_address_groupings
273
+ raise NotImplementedError
274
+ end
320
275
 
321
- # listreceivedbyaddress
322
- def list_received_by_address
323
- raise NotImplementedError
324
- end
276
+ # listreceivedbyaccount
277
+ def list_received_by_account
278
+ raise NotImplementedError
279
+ end
325
280
 
326
- # listsinceblock
327
- def list_since_block
328
- raise NotImplementedError
329
- end
281
+ # listreceivedbyaddress
282
+ def list_received_by_address
283
+ raise NotImplementedError
284
+ end
330
285
 
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
286
+ # listsinceblock
287
+ def list_since_block
288
+ raise NotImplementedError
289
+ end
343
290
 
344
- # listunspent
345
- def list_unspent
346
- raise NotImplementedError
347
- end
291
+ # listtransactions
292
+ def list_transactions(account = nil, count = nil, from = nil)
293
+ payload = {
294
+ method: 'listtransactions'
295
+ }
348
296
 
349
- # listlockunspent
350
- def list_lock_unspent
351
- raise NotImplementedError
352
- end
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
- # lockunspent
355
- def lock_unspent
356
- raise NotImplementedError
357
- end
303
+ request(payload)
304
+ end
358
305
 
359
- # move
360
- def move
361
- raise NotImplementedError
362
- end
306
+ # listunspent
307
+ def list_unspent
308
+ raise NotImplementedError
309
+ end
363
310
 
364
- # sendfrom
365
- def send_from
366
- raise NotImplementedError
367
- end
311
+ # listlockunspent
312
+ def list_lock_unspent
313
+ raise NotImplementedError
314
+ end
368
315
 
369
- # sendmany
370
- def send_many
371
- raise NotImplementedError
372
- end
316
+ # lockunspent
317
+ def lock_unspent
318
+ raise NotImplementedError
319
+ end
373
320
 
374
- # sendrawtransaction
375
- def send_raw_transaction
376
- raise NotImplementedError
377
- end
321
+ # move
322
+ def move(from_account, to_account, amount)
323
+ payload = {
324
+ method: 'move'
325
+ }
378
326
 
379
- def send_money(address, amount)
380
- payload = {
381
- method: 'sendtoaddress',
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
- def send_from_to(from_address, to_address, amount)
389
- payload = {
390
- method: 'move'
391
- }
331
+ request(payload)
332
+ end
392
333
 
393
- payload[:params] = [from_address, to_address, amount]
334
+ # sendfrom
335
+ def send_from
336
+ raise NotImplementedError
337
+ end
394
338
 
395
- request(payload)
396
- end
339
+ # sendmany
340
+ def send_many
341
+ raise NotImplementedError
342
+ end
397
343
 
398
- def send_from_address_to_address(from_address, to_address, amount)
399
- payload = {
400
- method: 'move'
401
- }
344
+ # sendrawtransaction
345
+ def send_raw_transaction
346
+ raise NotImplementedError
347
+ end
402
348
 
403
- payload[:params] = [from_address, to_address, amount]
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
- request(payload)
406
- end
356
+ payload[:params] << comment unless comment.nil?
357
+ payload[:params] << comment_to unless comment_to.nil?
407
358
 
408
- # sendtoaddress
409
- def send_to_address(address, amount, comment = nil, comment_to = nil)
410
- payload = {
411
- method: 'sendtoaddress',
412
- params: [address, amount]
413
- }
359
+ request(payload)
360
+ end
414
361
 
415
- payload[:params] << comment unless comment.nil?
416
- payload[:params] << comment_to unless comment_to.nil?
362
+ # setaccount
363
+ def account=(_)
364
+ raise NotImplementedError
365
+ end
417
366
 
418
- request(payload)
419
- end
367
+ # setgenerate
368
+ def generate=(_)
369
+ raise NotImplementedError
370
+ end
420
371
 
421
- # setaccount
422
- def account=(_)
423
- raise NotImplementedError
424
- end
372
+ # settxfee
373
+ def tx_fee=(_)
374
+ raise NotImplementedError
375
+ end
425
376
 
426
- # setgenerate
427
- def generate=(_)
428
- raise NotImplementedError
429
- end
377
+ # signmessage
378
+ def sign_message
379
+ raise NotImplementedError
380
+ end
430
381
 
431
- # settxfee
432
- def tx_fee=(_)
433
- raise NotImplementedError
434
- end
382
+ # signrawtransaction
383
+ def sign_raw_transaction
384
+ raise NotImplementedError
385
+ end
435
386
 
436
- # signmessage
437
- def sign_message
438
- raise NotImplementedError
439
- end
387
+ # stop
388
+ def stop
389
+ raise NotImplementedError
390
+ end
440
391
 
441
- # signrawtransaction
442
- def sign_raw_transaction
443
- raise NotImplementedError
444
- end
392
+ # submitblock
393
+ def submit_block
394
+ raise NotImplementedError
395
+ end
445
396
 
446
- # stop
447
- def stop
448
- raise NotImplementedError
449
- end
397
+ # validateaddress
398
+ def validate_address(address)
399
+ payload = {
400
+ method: 'validateaddress',
401
+ params: [address]
402
+ }
450
403
 
451
- # submitblock
452
- def submit_block
453
- raise NotImplementedError
454
- end
404
+ request(payload)
405
+ end
455
406
 
456
- # validateaddress
457
- def validate_address(address)
458
- payload = {
459
- method: 'validateaddress',
460
- params: [address]
461
- }
407
+ # verifymessage
408
+ def verify_message
409
+ raise NotImplementedError
410
+ end
462
411
 
463
- request(payload)
464
- end
412
+ # walletlock
413
+ def wallet_lock
414
+ raise NotImplementedError
415
+ end
465
416
 
466
- # verifymessage
467
- def verify_message
468
- raise NotImplementedError
469
- end
417
+ # walletpassphrase
418
+ def wallet_passphrase
419
+ raise NotImplementedError
420
+ end
470
421
 
471
- # walletlock
472
- def wallet_lock
473
- raise NotImplementedError
474
- end
422
+ # walletpassphrasechange
423
+ def wallet_passphrase_change
424
+ raise NotImplementedError
425
+ end
475
426
 
476
- # walletpassphrase
477
- def wallet_passphrase
478
- raise NotImplementedError
479
- end
427
+ def valid_address?(address)
428
+ validate_address(address)['isvalid']
429
+ end
480
430
 
481
- # walletpassphrasechange
482
- def wallet_passphrase_change
483
- raise NotImplementedError
484
- end
431
+ private
485
432
 
486
- def valid_address?(address)
487
- validate_address(address)['isvalid']
488
- end
433
+ def request(payload)
434
+ response = HTTParty.post(url, body: payload.to_json, headers: HEADERS)
489
435
 
490
- private
436
+ raise Error, response.message unless response.code == 200
491
437
 
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
438
+ JSON.parse(response.body)['result']
439
+ end
497
440
 
498
- def url
499
- "http://#{user}:#{password}@#{host}:#{port}"
441
+ def url
442
+ "http://#{user}:#{password}@#{host}:#{port}"
443
+ end
500
444
  end
@@ -1,3 +1,3 @@
1
1
  module Cryptobank
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptobank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grace Christenbery