Class: Bitcoin::Client
- Inherits:
-
Object
- Object
- Bitcoin::Client
- Defined in:
- lib/elchapo/bitcoin/client.rb
Direct Known Subclasses
Constant Summary collapse
- RPC_COMMANDS =
%w(addmultisigaddress addnode backupwallet createmultisig createrawtransaction decoderawtransaction dumpprivkey dumpwallet encryptwallet getaccount getaccountaddress getaddednodeinfo getaddressesbyaccount getbalance getbestblockhash getblock getblockcount getblockhash getblocknumber getblocktemplate getconnectioncount getdifficulty getgenerate gethashespersec getinfo getmemorypool getmininginfo getnewaddress getpeerinfo getrawchangeaddress getrawmempool getrawtransaction getreceivedbyaccount getreceivedbyaddress gettransaction gettxout gettxoutsetinfo getwork help importprivkey invalidateblock keypoolrefill listaccounts listaddressgroupings listreceivedbyaccount listreceivedbyaddress listsinceblock listtransactions listunspent listlockunspent lockunspent move sendfrom sendmany sendrawtransaction sendtoaddress setaccount setgenerate settxfee signmessage signrawtransaction stop submitblock validateaddress verifymessage walletlock walletpassphrase walletpassphrasechange)
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#default_account ⇒ Object
Returns the value of attribute default_account.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #get_id ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #reset_id ⇒ Object
- #send_command(command, args) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/elchapo/bitcoin/client.rb', line 9 def initialize @id = 0 end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/elchapo/bitcoin/client.rb', line 7 def command @command end |
#default_account ⇒ Object
Returns the value of attribute default_account.
7 8 9 |
# File 'lib/elchapo/bitcoin/client.rb', line 7 def default_account @default_account end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/elchapo/bitcoin/client.rb', line 7 def id @id end |
Instance Method Details
#get_id ⇒ Object
13 14 15 16 |
# File 'lib/elchapo/bitcoin/client.rb', line 13 def get_id @id += 1 return @id end |
#reset_id ⇒ Object
18 19 20 |
# File 'lib/elchapo/bitcoin/client.rb', line 18 def reset_id @id = 0 end |
#send_command(command, args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elchapo/bitcoin/client.rb', line 22 def send_command(command,args) payload = {jsonrpc: "2.0", method: command, params: args, id: get_id} @logger.info("Sending #{payload.to_json}") if @log output = JSON.parse(send_single(payload.to_json)) @logger.info("Received #{output.to_json}") if @log reset_id raise IOError, output["error"]["message"] if output["error"] return output["result"] end |