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
-
#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.
-
#account=(_) ⇒ Object
setaccount.
-
#account_address ⇒ Object
getaccountaddress.
-
#add_multisig_address ⇒ Object
addmultisigaddress.
-
#add_node ⇒ Object
addnode.
-
#added_node_info ⇒ Object
getaddednodeinfo.
-
#addresses_by_account ⇒ Object
getaddressesbyaccount.
-
#backup_wallet ⇒ Object
backupwallet.
-
#balance(account = nil) ⇒ Object
getbalance There are additional parameters on the RPC docs to be implemented bitcoin.org/en/developer-reference#getbalance.
-
#best_block_hash ⇒ Object
getbestblockhash.
-
#block ⇒ Object
getblock.
-
#block_count ⇒ Object
getblockcount.
-
#block_hash ⇒ Object
getblockhash.
-
#block_number ⇒ Object
getblocknumber.
-
#block_template ⇒ Object
getblocktemplate.
- #configure {|_self| ... } ⇒ Object
-
#connection_count ⇒ Object
getconnectioncount.
-
#create_multisig ⇒ Object
createmultisig.
-
#create_raw_transaction ⇒ Object
createrawtransaction.
-
#decode_raw_transaction ⇒ Object
decoderawtransaction.
-
#difficulty ⇒ Object
getdifficulty.
-
#dump_priv_key ⇒ Object
dumpprivkey.
-
#encrypt_wallet ⇒ Object
encryptwallet.
-
#generate ⇒ Object
getgenerate.
-
#generate=(_) ⇒ Object
setgenerate.
-
#hashes_per_sec ⇒ Object
gethashespersec.
-
#help ⇒ Object
help.
-
#import_priv_key ⇒ Object
importprivkey.
-
#info ⇒ Object
getinfo.
-
#keypool_refill ⇒ Object
keypoolrefill.
-
#list_accounts(minconf = nil) ⇒ Object
listaccounts.
-
#list_address_groupings ⇒ Object
listaddressgroupings.
-
#list_lock_unspent ⇒ Object
listlockunspent.
-
#list_received_by_account ⇒ Object
listreceivedbyaccount.
-
#list_received_by_address ⇒ Object
listreceivedbyaddress.
-
#list_since_block ⇒ Object
listsinceblock.
-
#list_transactions(account = nil, count = nil, from = nil) ⇒ Object
listtransactions.
-
#list_unspent ⇒ Object
listunspent.
-
#lock_unspent ⇒ Object
lockunspent.
-
#memory_pool ⇒ Object
getmemorypool.
-
#mining_info ⇒ Object
getmininginfo.
-
#move(from_account, to_account, amount) ⇒ Object
move.
-
#new_address(account = nil) ⇒ Object
getnewaddress.
-
#peer_info ⇒ Object
getpeerinfo.
-
#raw_change_address ⇒ Object
getrawchangeaddress.
-
#raw_mem_pool ⇒ Object
getrawmempool.
-
#raw_transaction ⇒ Object
getrawtransaction.
-
#received_by_account ⇒ Object
getreceivedbyaccount.
-
#received_by_address ⇒ Object
getreceivedbyaddress.
-
#send_from ⇒ Object
sendfrom.
-
#send_many ⇒ Object
sendmany.
-
#send_raw_transaction ⇒ Object
sendrawtransaction.
-
#send_to_address(address, amount, comment = nil, comment_to = nil) ⇒ Object
sendtoaddress.
-
#sign_message ⇒ Object
signmessage.
-
#sign_raw_transaction ⇒ Object
signrawtransaction.
-
#stop ⇒ Object
stop.
-
#submit_block ⇒ Object
submitblock.
-
#transaction(txid) ⇒ Object
gettransaction.
-
#tx_fee=(_) ⇒ Object
settxfee.
-
#tx_out ⇒ Object
gettxout.
-
#tx_out_set_info ⇒ Object
gettxoutsetinfo.
- #valid_address?(address) ⇒ Boolean
-
#validate_address(address) ⇒ Object
validateaddress.
-
#verify_message ⇒ Object
verifymessage.
-
#wallet_lock ⇒ Object
walletlock.
-
#wallet_passphrase ⇒ Object
walletpassphrase.
-
#wallet_passphrase_change ⇒ Object
walletpassphrasechange.
-
#work ⇒ Object
getwork.
Instance Attribute Details
#host ⇒ Object
14 15 16 |
# File 'lib/cryptobank.rb', line 14 def host @host || 'localhost' end |
#password ⇒ Object
26 27 28 |
# File 'lib/cryptobank.rb', line 26 def password @password || 'rpcpassword' end |
#port ⇒ Object
18 19 20 |
# File 'lib/cryptobank.rb', line 18 def port @port || 8332 end |
#user ⇒ Object
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 account(bitcoin_address) payload = { method: 'getaccount' } payload[:params] = [bitcoin_address.to_string] request(payload) end |
#account=(_) ⇒ Object
setaccount
363 364 365 |
# File 'lib/cryptobank.rb', line 363 def account=(_) raise NotImplementedError end |
#account_address ⇒ Object
getaccountaddress
86 87 88 |
# File 'lib/cryptobank.rb', line 86 def account_address raise NotImplementedError end |
#add_multisig_address ⇒ Object
addmultisigaddress
35 36 37 |
# File 'lib/cryptobank.rb', line 35 def add_multisig_address raise NotImplementedError end |
#add_node ⇒ Object
addnode
40 41 42 |
# File 'lib/cryptobank.rb', line 40 def add_node raise NotImplementedError end |
#added_node_info ⇒ Object
getaddednodeinfo
91 92 93 |
# File 'lib/cryptobank.rb', line 91 def added_node_info raise NotImplementedError end |
#addresses_by_account ⇒ Object
getaddressesbyaccount
96 97 98 |
# File 'lib/cryptobank.rb', line 96 def addresses_by_account raise NotImplementedError end |
#backup_wallet ⇒ Object
backupwallet
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(account = nil) payload = { method: 'getbalance' } payload[:params] = [account] unless account.nil? request(payload) end |
#best_block_hash ⇒ Object
getbestblockhash
111 112 113 |
# File 'lib/cryptobank.rb', line 111 def best_block_hash raise NotImplementedError end |
#block ⇒ Object
getblock
116 117 118 |
# File 'lib/cryptobank.rb', line 116 def block raise NotImplementedError end |
#block_count ⇒ Object
getblockcount
121 122 123 |
# File 'lib/cryptobank.rb', line 121 def block_count raise NotImplementedError end |
#block_hash ⇒ Object
getblockhash
126 127 128 |
# File 'lib/cryptobank.rb', line 126 def block_hash raise NotImplementedError end |
#block_number ⇒ Object
getblocknumber
131 132 133 |
# File 'lib/cryptobank.rb', line 131 def block_number raise NotImplementedError end |
#block_template ⇒ Object
getblocktemplate
136 137 138 |
# File 'lib/cryptobank.rb', line 136 def block_template raise NotImplementedError end |
#configure {|_self| ... } ⇒ Object
30 31 32 |
# File 'lib/cryptobank.rb', line 30 def configure yield self end |
#connection_count ⇒ Object
getconnectioncount
141 142 143 |
# File 'lib/cryptobank.rb', line 141 def connection_count raise NotImplementedError end |
#create_multisig ⇒ Object
createmultisig
50 51 52 |
# File 'lib/cryptobank.rb', line 50 def create_multisig raise NotImplementedError end |
#create_raw_transaction ⇒ Object
createrawtransaction
55 56 57 |
# File 'lib/cryptobank.rb', line 55 def create_raw_transaction raise NotImplementedError end |
#decode_raw_transaction ⇒ Object
decoderawtransaction
60 61 62 |
# File 'lib/cryptobank.rb', line 60 def decode_raw_transaction raise NotImplementedError end |
#difficulty ⇒ Object
getdifficulty
146 147 148 |
# File 'lib/cryptobank.rb', line 146 def difficulty raise NotImplementedError end |
#dump_priv_key ⇒ Object
dumpprivkey
65 66 67 |
# File 'lib/cryptobank.rb', line 65 def dump_priv_key raise NotImplementedError end |
#encrypt_wallet ⇒ Object
encryptwallet
70 71 72 |
# File 'lib/cryptobank.rb', line 70 def encrypt_wallet raise NotImplementedError end |
#generate ⇒ Object
getgenerate
151 152 153 |
# File 'lib/cryptobank.rb', line 151 def generate raise NotImplementedError end |
#generate=(_) ⇒ Object
setgenerate
368 369 370 |
# File 'lib/cryptobank.rb', line 368 def generate=(_) raise NotImplementedError end |
#hashes_per_sec ⇒ Object
gethashespersec
156 157 158 |
# File 'lib/cryptobank.rb', line 156 def hashes_per_sec raise NotImplementedError end |
#help ⇒ Object
help
246 247 248 |
# File 'lib/cryptobank.rb', line 246 def help raise NotImplementedError end |
#import_priv_key ⇒ Object
importprivkey
251 252 253 |
# File 'lib/cryptobank.rb', line 251 def import_priv_key raise NotImplementedError end |
#info ⇒ Object
getinfo
161 162 163 164 165 166 167 |
# File 'lib/cryptobank.rb', line 161 def info payload = { method: 'getwalletinfo' } request(payload) end |
#keypool_refill ⇒ Object
keypoolrefill
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_groupings ⇒ Object
listaddressgroupings
272 273 274 |
# File 'lib/cryptobank.rb', line 272 def list_address_groupings raise NotImplementedError end |
#list_lock_unspent ⇒ Object
listlockunspent
312 313 314 |
# File 'lib/cryptobank.rb', line 312 def list_lock_unspent raise NotImplementedError end |
#list_received_by_account ⇒ Object
listreceivedbyaccount
277 278 279 |
# File 'lib/cryptobank.rb', line 277 def list_received_by_account raise NotImplementedError end |
#list_received_by_address ⇒ Object
listreceivedbyaddress
282 283 284 |
# File 'lib/cryptobank.rb', line 282 def list_received_by_address raise NotImplementedError end |
#list_since_block ⇒ Object
listsinceblock
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(account = nil, count = nil, from = nil) payload = { method: 'listtransactions' } unless account.nil? payload[:params] = [account] payload[:params] << count unless count.nil? payload[:params] << from unless from.nil? end request(payload) end |
#list_unspent ⇒ Object
listunspent
307 308 309 |
# File 'lib/cryptobank.rb', line 307 def list_unspent raise NotImplementedError end |
#lock_unspent ⇒ Object
lockunspent
317 318 319 |
# File 'lib/cryptobank.rb', line 317 def lock_unspent raise NotImplementedError end |
#memory_pool ⇒ Object
getmemorypool
170 171 172 |
# File 'lib/cryptobank.rb', line 170 def memory_pool raise NotImplementedError end |
#mining_info ⇒ Object
getmininginfo
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(from_account, to_account, amount) payload = { method: 'move' } payload[:params] = [from_account] payload[:params] << to_account 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(account = nil) payload = { method: 'getnewaddress' } payload[:params] = [account] unless account.nil? request(payload) end |
#peer_info ⇒ Object
getpeerinfo
191 192 193 |
# File 'lib/cryptobank.rb', line 191 def peer_info raise NotImplementedError end |
#raw_change_address ⇒ Object
getrawchangeaddress
196 197 198 |
# File 'lib/cryptobank.rb', line 196 def raw_change_address raise NotImplementedError end |
#raw_mem_pool ⇒ Object
getrawmempool
201 202 203 |
# File 'lib/cryptobank.rb', line 201 def raw_mem_pool raise NotImplementedError end |
#raw_transaction ⇒ Object
getrawtransaction
206 207 208 |
# File 'lib/cryptobank.rb', line 206 def raw_transaction raise NotImplementedError end |
#received_by_account ⇒ Object
getreceivedbyaccount
211 212 213 |
# File 'lib/cryptobank.rb', line 211 def received_by_account raise NotImplementedError end |
#received_by_address ⇒ Object
getreceivedbyaddress
216 217 218 |
# File 'lib/cryptobank.rb', line 216 def received_by_address raise NotImplementedError end |
#send_from ⇒ Object
sendfrom
335 336 337 |
# File 'lib/cryptobank.rb', line 335 def send_from raise NotImplementedError end |
#send_many ⇒ Object
sendmany
340 341 342 |
# File 'lib/cryptobank.rb', line 340 def send_many raise NotImplementedError end |
#send_raw_transaction ⇒ Object
sendrawtransaction
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_message ⇒ Object
signmessage
378 379 380 |
# File 'lib/cryptobank.rb', line 378 def raise NotImplementedError end |
#sign_raw_transaction ⇒ Object
signrawtransaction
383 384 385 |
# File 'lib/cryptobank.rb', line 383 def sign_raw_transaction raise NotImplementedError end |
#stop ⇒ Object
stop
388 389 390 |
# File 'lib/cryptobank.rb', line 388 def stop raise NotImplementedError end |
#submit_block ⇒ Object
submitblock
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
373 374 375 |
# File 'lib/cryptobank.rb', line 373 def tx_fee=(_) raise NotImplementedError end |
#tx_out ⇒ Object
gettxout
231 232 233 |
# File 'lib/cryptobank.rb', line 231 def tx_out raise NotImplementedError end |
#tx_out_set_info ⇒ Object
gettxoutsetinfo
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_message ⇒ Object
verifymessage
408 409 410 |
# File 'lib/cryptobank.rb', line 408 def raise NotImplementedError end |
#wallet_lock ⇒ Object
walletlock
413 414 415 |
# File 'lib/cryptobank.rb', line 413 def wallet_lock raise NotImplementedError end |
#wallet_passphrase ⇒ Object
walletpassphrase
418 419 420 |
# File 'lib/cryptobank.rb', line 418 def wallet_passphrase raise NotImplementedError end |
#wallet_passphrase_change ⇒ Object
walletpassphrasechange
423 424 425 |
# File 'lib/cryptobank.rb', line 423 def wallet_passphrase_change raise NotImplementedError end |
#work ⇒ Object
getwork
241 242 243 |
# File 'lib/cryptobank.rb', line 241 def work raise NotImplementedError end |