module Cryptobank
Constants
- Error
- HEADERS
- VERSION
Attributes
Public Instance Methods
getaccount A P2PKH or P2SH Bitcoin address belonging either to a specific account or the default account (“”) returns a base58 string
# File lib/cryptobank.rb, line 77 def account(bitcoin_address) payload = { method: 'getaccount' } payload[:params] = [bitcoin_address.to_string] request(payload) end
setaccount
# File lib/cryptobank.rb, line 363 def account=(_) raise NotImplementedError end
getaccountaddress
# File lib/cryptobank.rb, line 86 def account_address raise NotImplementedError end
addmultisigaddress
# File lib/cryptobank.rb, line 35 def add_multisig_address raise NotImplementedError end
addnode
# File lib/cryptobank.rb, line 40 def add_node raise NotImplementedError end
getaddednodeinfo
# File lib/cryptobank.rb, line 91 def added_node_info raise NotImplementedError end
getaddressesbyaccount
# File lib/cryptobank.rb, line 96 def addresses_by_account raise NotImplementedError end
backupwallet
# File lib/cryptobank.rb, line 45 def backup_wallet raise NotImplementedError end
getbalance There are additional parameters on the RPC docs to be implemented bitcoin.org/en/developer-reference#getbalance
# File lib/cryptobank.rb, line 102 def balance(account = nil) payload = { method: 'getbalance' } payload[:params] = [account] unless account.nil? request(payload) end
getbestblockhash
# File lib/cryptobank.rb, line 111 def best_block_hash raise NotImplementedError end
getblock
# File lib/cryptobank.rb, line 116 def block raise NotImplementedError end
getblockcount
# File lib/cryptobank.rb, line 121 def block_count raise NotImplementedError end
getblockhash
# File lib/cryptobank.rb, line 126 def block_hash raise NotImplementedError end
getblocknumber
# File lib/cryptobank.rb, line 131 def block_number raise NotImplementedError end
getblocktemplate
# File lib/cryptobank.rb, line 136 def block_template raise NotImplementedError end
# File lib/cryptobank.rb, line 30 def configure yield self end
getconnectioncount
# File lib/cryptobank.rb, line 141 def connection_count raise NotImplementedError end
createmultisig
# File lib/cryptobank.rb, line 50 def create_multisig raise NotImplementedError end
createrawtransaction
# File lib/cryptobank.rb, line 55 def create_raw_transaction raise NotImplementedError end
decoderawtransaction
# File lib/cryptobank.rb, line 60 def decode_raw_transaction raise NotImplementedError end
getdifficulty
# File lib/cryptobank.rb, line 146 def difficulty raise NotImplementedError end
dumpprivkey
# File lib/cryptobank.rb, line 65 def dump_priv_key raise NotImplementedError end
encryptwallet
# File lib/cryptobank.rb, line 70 def encrypt_wallet raise NotImplementedError end
getgenerate
# File lib/cryptobank.rb, line 151 def generate raise NotImplementedError end
setgenerate
# File lib/cryptobank.rb, line 368 def generate=(_) raise NotImplementedError end
gethashespersec
# File lib/cryptobank.rb, line 156 def hashes_per_sec raise NotImplementedError end
help
# File lib/cryptobank.rb, line 246 def help raise NotImplementedError end
# File lib/cryptobank.rb, line 14 def host @host || 'localhost' end
importprivkey
# File lib/cryptobank.rb, line 251 def import_priv_key raise NotImplementedError end
getinfo
# File lib/cryptobank.rb, line 161 def info payload = { method: 'getwalletinfo' } request(payload) end
keypoolrefill
# File lib/cryptobank.rb, line 256 def keypool_refill raise NotImplementedError end
listaccounts
# File lib/cryptobank.rb, line 261 def list_accounts(minconf = nil) payload = { method: 'listaccounts' } payload[:params] = [minconf] unless minconf.nil? request(payload) end
listaddressgroupings
# File lib/cryptobank.rb, line 272 def list_address_groupings raise NotImplementedError end
listlockunspent
# File lib/cryptobank.rb, line 312 def list_lock_unspent raise NotImplementedError end
listreceivedbyaccount
# File lib/cryptobank.rb, line 277 def list_received_by_account raise NotImplementedError end
listreceivedbyaddress
# File lib/cryptobank.rb, line 282 def list_received_by_address raise NotImplementedError end
listsinceblock
# File lib/cryptobank.rb, line 287 def list_since_block raise NotImplementedError end
listtransactions
# 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
listunspent
# File lib/cryptobank.rb, line 307 def list_unspent raise NotImplementedError end
lockunspent
# File lib/cryptobank.rb, line 317 def lock_unspent raise NotImplementedError end
getmemorypool
# File lib/cryptobank.rb, line 170 def memory_pool raise NotImplementedError end
getmininginfo
# File lib/cryptobank.rb, line 175 def mining_info raise NotImplementedError end
move
# 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
getnewaddress
# File lib/cryptobank.rb, line 180 def new_address(account = nil) payload = { method: 'getnewaddress' } payload[:params] = [account] unless account.nil? request(payload) end
# File lib/cryptobank.rb, line 26 def password @password || 'rpcpassword' end
getpeerinfo
# File lib/cryptobank.rb, line 191 def peer_info raise NotImplementedError end
# File lib/cryptobank.rb, line 18 def port @port || 8332 end
getrawchangeaddress
# File lib/cryptobank.rb, line 196 def raw_change_address raise NotImplementedError end
getrawmempool
# File lib/cryptobank.rb, line 201 def raw_mem_pool raise NotImplementedError end
getrawtransaction
# File lib/cryptobank.rb, line 206 def raw_transaction raise NotImplementedError end
getreceivedbyaccount
# File lib/cryptobank.rb, line 211 def received_by_account raise NotImplementedError end
getreceivedbyaddress
# File lib/cryptobank.rb, line 216 def received_by_address raise NotImplementedError end
sendfrom
# File lib/cryptobank.rb, line 335 def send_from raise NotImplementedError end
sendmany
# File lib/cryptobank.rb, line 340 def send_many raise NotImplementedError end
sendrawtransaction
# File lib/cryptobank.rb, line 345 def send_raw_transaction raise NotImplementedError end
sendtoaddress
# 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
signmessage
# File lib/cryptobank.rb, line 378 def sign_message raise NotImplementedError end
signrawtransaction
# File lib/cryptobank.rb, line 383 def sign_raw_transaction raise NotImplementedError end
stop
# File lib/cryptobank.rb, line 388 def stop raise NotImplementedError end
submitblock
# File lib/cryptobank.rb, line 393 def submit_block raise NotImplementedError end
gettransaction
# File lib/cryptobank.rb, line 221 def transaction(txid) payload = { method: 'gettransaction', params: [txid] } request(payload) end
settxfee
# File lib/cryptobank.rb, line 373 def tx_fee=(_) raise NotImplementedError end
gettxout
# File lib/cryptobank.rb, line 231 def tx_out raise NotImplementedError end
gettxoutsetinfo
# File lib/cryptobank.rb, line 236 def tx_out_set_info raise NotImplementedError end
# File lib/cryptobank.rb, line 22 def user @user || 'rpcuser' end
# File lib/cryptobank.rb, line 427 def valid_address?(address) validate_address(address)['isvalid'] end
validateaddress
# File lib/cryptobank.rb, line 398 def validate_address(address) payload = { method: 'validateaddress', params: [address] } request(payload) end
verifymessage
# File lib/cryptobank.rb, line 408 def verify_message raise NotImplementedError end
walletlock
# File lib/cryptobank.rb, line 413 def wallet_lock raise NotImplementedError end
walletpassphrase
# File lib/cryptobank.rb, line 418 def wallet_passphrase raise NotImplementedError end
walletpassphrasechange
# File lib/cryptobank.rb, line 423 def wallet_passphrase_change raise NotImplementedError end
getwork
# File lib/cryptobank.rb, line 241 def work raise NotImplementedError end
Private Instance Methods
# File lib/cryptobank.rb, line 433 def request(payload) response = HTTParty.post(url, body: payload.to_json, headers: HEADERS) raise Error, response.message unless response.code == 200 JSON.parse(response.body)['result'] end
# File lib/cryptobank.rb, line 441 def url "http://#{user}:#{password}@#{host}:#{port}" end