Module: Cryptobank

Defined in:
lib/cryptobank.rb,
lib/cryptobank/error.rb,
lib/cryptobank/version.rb

Constant Summary collapse

HEADERS =
{
  'Content-Type' => 'application/json',
  'Accept' => 'application/json'
}.freeze
Error =
Class.new(StandardError)
VERSION =
"0.1.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject



14
15
16
# File 'lib/cryptobank.rb', line 14

def host
  @host || 'localhost'
end

#passwordObject



26
27
28
# File 'lib/cryptobank.rb', line 26

def password
  @password || 'rpcpassword'
end

#portObject



18
19
20
# File 'lib/cryptobank.rb', line 18

def port
  @port || 8332
end

#userObject



22
23
24
# File 'lib/cryptobank.rb', line 22

def user
  @user || 'rpcuser'
end

Instance Method Details

#account(bitcoin_address) ⇒ Object

getaccount A P2PKH or P2SH Bitcoin address belonging either to a specific account or the default account (“”) returns a base58 string



77
78
79
80
81
82
83
# File 'lib/cryptobank.rb', line 77

def (bitcoin_address)
  payload = {
    method: 'getaccount'
  }
  payload[:params] = [bitcoin_address.to_string]
  request(payload)
end

#account=(_) ⇒ Object

setaccount

Raises:

  • (NotImplementedError)


363
364
365
# File 'lib/cryptobank.rb', line 363

def account=(_)
  raise NotImplementedError
end

#account_addressObject

getaccountaddress

Raises:

  • (NotImplementedError)


86
87
88
# File 'lib/cryptobank.rb', line 86

def 
  raise NotImplementedError
end

#add_multisig_addressObject

addmultisigaddress

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/cryptobank.rb', line 35

def add_multisig_address
  raise NotImplementedError
end

#add_nodeObject

addnode

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/cryptobank.rb', line 40

def add_node
  raise NotImplementedError
end

#added_node_infoObject

getaddednodeinfo

Raises:

  • (NotImplementedError)


91
92
93
# File 'lib/cryptobank.rb', line 91

def added_node_info
  raise NotImplementedError
end

#addresses_by_accountObject

getaddressesbyaccount

Raises:

  • (NotImplementedError)


96
97
98
# File 'lib/cryptobank.rb', line 96

def 
  raise NotImplementedError
end

#backup_walletObject

backupwallet

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/cryptobank.rb', line 45

def backup_wallet
  raise NotImplementedError
end

#balance(account = nil) ⇒ Object

getbalance There are additional parameters on the RPC docs to be implemented bitcoin.org/en/developer-reference#getbalance



102
103
104
105
106
107
108
# File 'lib/cryptobank.rb', line 102

def balance( = nil)
  payload = {
    method: 'getbalance'
  }
  payload[:params] = [] unless .nil?
  request(payload)
end

#best_block_hashObject

getbestblockhash

Raises:

  • (NotImplementedError)


111
112
113
# File 'lib/cryptobank.rb', line 111

def best_block_hash
  raise NotImplementedError
end

#blockObject

getblock

Raises:

  • (NotImplementedError)


116
117
118
# File 'lib/cryptobank.rb', line 116

def block
  raise NotImplementedError
end

#block_countObject

getblockcount

Raises:

  • (NotImplementedError)


121
122
123
# File 'lib/cryptobank.rb', line 121

def block_count
  raise NotImplementedError
end

#block_hashObject

getblockhash

Raises:

  • (NotImplementedError)


126
127
128
# File 'lib/cryptobank.rb', line 126

def block_hash
  raise NotImplementedError
end

#block_numberObject

getblocknumber

Raises:

  • (NotImplementedError)


131
132
133
# File 'lib/cryptobank.rb', line 131

def block_number
  raise NotImplementedError
end

#block_templateObject

getblocktemplate

Raises:

  • (NotImplementedError)


136
137
138
# File 'lib/cryptobank.rb', line 136

def block_template
  raise NotImplementedError
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Cryptobank)

    the object that the method was called on



30
31
32
# File 'lib/cryptobank.rb', line 30

def configure
  yield self
end

#connection_countObject

getconnectioncount

Raises:

  • (NotImplementedError)


141
142
143
# File 'lib/cryptobank.rb', line 141

def connection_count
  raise NotImplementedError
end

#create_multisigObject

createmultisig

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/cryptobank.rb', line 50

def create_multisig
  raise NotImplementedError
end

#create_raw_transactionObject

createrawtransaction

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/cryptobank.rb', line 55

def create_raw_transaction
  raise NotImplementedError
end

#decode_raw_transactionObject

decoderawtransaction

Raises:

  • (NotImplementedError)


60
61
62
# File 'lib/cryptobank.rb', line 60

def decode_raw_transaction
  raise NotImplementedError
end

#difficultyObject

getdifficulty

Raises:

  • (NotImplementedError)


146
147
148
# File 'lib/cryptobank.rb', line 146

def difficulty
  raise NotImplementedError
end

#dump_priv_keyObject

dumpprivkey

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/cryptobank.rb', line 65

def dump_priv_key
  raise NotImplementedError
end

#encrypt_walletObject

encryptwallet

Raises:

  • (NotImplementedError)


70
71
72
# File 'lib/cryptobank.rb', line 70

def encrypt_wallet
  raise NotImplementedError
end

#generateObject

getgenerate

Raises:

  • (NotImplementedError)


151
152
153
# File 'lib/cryptobank.rb', line 151

def generate
  raise NotImplementedError
end

#generate=(_) ⇒ Object

setgenerate

Raises:

  • (NotImplementedError)


368
369
370
# File 'lib/cryptobank.rb', line 368

def generate=(_)
  raise NotImplementedError
end

#hashes_per_secObject

gethashespersec

Raises:

  • (NotImplementedError)


156
157
158
# File 'lib/cryptobank.rb', line 156

def hashes_per_sec
  raise NotImplementedError
end

#helpObject

help

Raises:

  • (NotImplementedError)


246
247
248
# File 'lib/cryptobank.rb', line 246

def help
  raise NotImplementedError
end

#import_priv_keyObject

importprivkey

Raises:

  • (NotImplementedError)


251
252
253
# File 'lib/cryptobank.rb', line 251

def import_priv_key
  raise NotImplementedError
end

#infoObject

getinfo



161
162
163
164
165
166
167
# File 'lib/cryptobank.rb', line 161

def info
  payload = {
    method: 'getwalletinfo'
  }

  request(payload)
end

#keypool_refillObject

keypoolrefill

Raises:

  • (NotImplementedError)


256
257
258
# File 'lib/cryptobank.rb', line 256

def keypool_refill
  raise NotImplementedError
end

#list_accounts(minconf = nil) ⇒ Object

listaccounts



261
262
263
264
265
266
267
268
269
# File 'lib/cryptobank.rb', line 261

def list_accounts(minconf = nil)
  payload = {
    method: 'listaccounts'
  }

  payload[:params] = [minconf] unless minconf.nil?

  request(payload)
end

#list_address_groupingsObject

listaddressgroupings

Raises:

  • (NotImplementedError)


272
273
274
# File 'lib/cryptobank.rb', line 272

def list_address_groupings
  raise NotImplementedError
end

#list_lock_unspentObject

listlockunspent

Raises:

  • (NotImplementedError)


312
313
314
# File 'lib/cryptobank.rb', line 312

def list_lock_unspent
  raise NotImplementedError
end

#list_received_by_accountObject

listreceivedbyaccount

Raises:

  • (NotImplementedError)


277
278
279
# File 'lib/cryptobank.rb', line 277

def 
  raise NotImplementedError
end

#list_received_by_addressObject

listreceivedbyaddress

Raises:

  • (NotImplementedError)


282
283
284
# File 'lib/cryptobank.rb', line 282

def list_received_by_address
  raise NotImplementedError
end

#list_since_blockObject

listsinceblock

Raises:

  • (NotImplementedError)


287
288
289
# File 'lib/cryptobank.rb', line 287

def list_since_block
  raise NotImplementedError
end

#list_transactions(account = nil, count = nil, from = nil) ⇒ Object

listtransactions



292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/cryptobank.rb', line 292

def list_transactions( = nil, count = nil, from = nil)
  payload = {
    method: 'listtransactions'
  }

  unless .nil?
    payload[:params] = []
    payload[:params] << count unless count.nil?
    payload[:params] << from unless from.nil?
  end

  request(payload)
end

#list_unspentObject

listunspent

Raises:

  • (NotImplementedError)


307
308
309
# File 'lib/cryptobank.rb', line 307

def list_unspent
  raise NotImplementedError
end

#lock_unspentObject

lockunspent

Raises:

  • (NotImplementedError)


317
318
319
# File 'lib/cryptobank.rb', line 317

def lock_unspent
  raise NotImplementedError
end

#memory_poolObject

getmemorypool

Raises:

  • (NotImplementedError)


170
171
172
# File 'lib/cryptobank.rb', line 170

def memory_pool
  raise NotImplementedError
end

#mining_infoObject

getmininginfo

Raises:

  • (NotImplementedError)


175
176
177
# File 'lib/cryptobank.rb', line 175

def mining_info
  raise NotImplementedError
end

#move(from_account, to_account, amount) ⇒ Object

move



322
323
324
325
326
327
328
329
330
331
332
# File 'lib/cryptobank.rb', line 322

def move(, , amount)
  payload = {
    method: 'move'
  }

  payload[:params] = []
  payload[:params] << 
  payload[:params] << amount

  request(payload)
end

#new_address(account = nil) ⇒ Object

getnewaddress



180
181
182
183
184
185
186
187
188
# File 'lib/cryptobank.rb', line 180

def new_address( = nil)
  payload = {
    method: 'getnewaddress'
  }

  payload[:params] = [] unless .nil?

  request(payload)
end

#peer_infoObject

getpeerinfo

Raises:

  • (NotImplementedError)


191
192
193
# File 'lib/cryptobank.rb', line 191

def peer_info
  raise NotImplementedError
end

#raw_change_addressObject

getrawchangeaddress

Raises:

  • (NotImplementedError)


196
197
198
# File 'lib/cryptobank.rb', line 196

def raw_change_address
  raise NotImplementedError
end

#raw_mem_poolObject

getrawmempool

Raises:

  • (NotImplementedError)


201
202
203
# File 'lib/cryptobank.rb', line 201

def raw_mem_pool
  raise NotImplementedError
end

#raw_transactionObject

getrawtransaction

Raises:

  • (NotImplementedError)


206
207
208
# File 'lib/cryptobank.rb', line 206

def raw_transaction
  raise NotImplementedError
end

#received_by_accountObject

getreceivedbyaccount

Raises:

  • (NotImplementedError)


211
212
213
# File 'lib/cryptobank.rb', line 211

def 
  raise NotImplementedError
end

#received_by_addressObject

getreceivedbyaddress

Raises:

  • (NotImplementedError)


216
217
218
# File 'lib/cryptobank.rb', line 216

def received_by_address
  raise NotImplementedError
end

#send_fromObject

sendfrom

Raises:

  • (NotImplementedError)


335
336
337
# File 'lib/cryptobank.rb', line 335

def send_from
  raise NotImplementedError
end

#send_manyObject

sendmany

Raises:

  • (NotImplementedError)


340
341
342
# File 'lib/cryptobank.rb', line 340

def send_many
  raise NotImplementedError
end

#send_raw_transactionObject

sendrawtransaction

Raises:

  • (NotImplementedError)


345
346
347
# File 'lib/cryptobank.rb', line 345

def send_raw_transaction
  raise NotImplementedError
end

#send_to_address(address, amount, comment = nil, comment_to = nil) ⇒ Object

sendtoaddress



350
351
352
353
354
355
356
357
358
359
360
# File 'lib/cryptobank.rb', line 350

def send_to_address(address, amount, comment = nil, comment_to = nil)
  payload = {
    method: 'sendtoaddress',
    params: [address, amount]
  }

  payload[:params] << comment unless comment.nil?
  payload[:params] << comment_to unless comment_to.nil?

  request(payload)
end

#sign_messageObject

signmessage

Raises:

  • (NotImplementedError)


378
379
380
# File 'lib/cryptobank.rb', line 378

def sign_message
  raise NotImplementedError
end

#sign_raw_transactionObject

signrawtransaction

Raises:

  • (NotImplementedError)


383
384
385
# File 'lib/cryptobank.rb', line 383

def sign_raw_transaction
  raise NotImplementedError
end

#stopObject

stop

Raises:

  • (NotImplementedError)


388
389
390
# File 'lib/cryptobank.rb', line 388

def stop
  raise NotImplementedError
end

#submit_blockObject

submitblock

Raises:

  • (NotImplementedError)


393
394
395
# File 'lib/cryptobank.rb', line 393

def submit_block
  raise NotImplementedError
end

#transaction(txid) ⇒ Object

gettransaction



221
222
223
224
225
226
227
228
# File 'lib/cryptobank.rb', line 221

def transaction(txid)
  payload = {
    method: 'gettransaction',
    params: [txid]
  }

  request(payload)
end

#tx_fee=(_) ⇒ Object

settxfee

Raises:

  • (NotImplementedError)


373
374
375
# File 'lib/cryptobank.rb', line 373

def tx_fee=(_)
  raise NotImplementedError
end

#tx_outObject

gettxout

Raises:

  • (NotImplementedError)


231
232
233
# File 'lib/cryptobank.rb', line 231

def tx_out
  raise NotImplementedError
end

#tx_out_set_infoObject

gettxoutsetinfo

Raises:

  • (NotImplementedError)


236
237
238
# File 'lib/cryptobank.rb', line 236

def tx_out_set_info
  raise NotImplementedError
end

#valid_address?(address) ⇒ Boolean



427
428
429
# File 'lib/cryptobank.rb', line 427

def valid_address?(address)
  validate_address(address)['isvalid']
end

#validate_address(address) ⇒ Object

validateaddress



398
399
400
401
402
403
404
405
# File 'lib/cryptobank.rb', line 398

def validate_address(address)
  payload = {
    method: 'validateaddress',
    params: [address]
  }

  request(payload)
end

#verify_messageObject

verifymessage

Raises:

  • (NotImplementedError)


408
409
410
# File 'lib/cryptobank.rb', line 408

def verify_message
  raise NotImplementedError
end

#wallet_lockObject

walletlock

Raises:

  • (NotImplementedError)


413
414
415
# File 'lib/cryptobank.rb', line 413

def wallet_lock
  raise NotImplementedError
end

#wallet_passphraseObject

walletpassphrase

Raises:

  • (NotImplementedError)


418
419
420
# File 'lib/cryptobank.rb', line 418

def wallet_passphrase
  raise NotImplementedError
end

#wallet_passphrase_changeObject

walletpassphrasechange

Raises:

  • (NotImplementedError)


423
424
425
# File 'lib/cryptobank.rb', line 423

def wallet_passphrase_change
  raise NotImplementedError
end

#workObject

getwork

Raises:

  • (NotImplementedError)


241
242
243
# File 'lib/cryptobank.rb', line 241

def work
  raise NotImplementedError
end