class Dogecoin::Client
Attributes
Public Class Methods
# File lib/dogecoin/client.rb, line 19 def initialize(user, pass, options = {}) @api = Dogecoin::API.new({ :user => user, :pass => pass }.merge(options)) end
Public Instance Methods
Safely copies wallet.dat to destination, which can be a directory or a path with filename.
# File lib/dogecoin/client.rb, line 24 def backupwallet(destination) @api.request 'backupwallet', destination end
Returns the account associated with the given address.
# File lib/dogecoin/client.rb, line 29 def getaccount(dogecoinaddress) @api.request 'getaccount', dogecoinaddress end
Returns the current dogecoin address for receiving payments to this account.
# File lib/dogecoin/client.rb, line 34 def getaccountaddress(account) @api.request 'getaccountaddress', account end
Returns the list of addresses for the given account.
# File lib/dogecoin/client.rb, line 39 def getaddressesbyaccount(account) @api.request 'getaddressesbyaccount', account end
If account
is not specified, returns the server’s total available balance. If account
is specified, returns the balance in the account.
# File lib/dogecoin/client.rb, line 45 def getbalance(account = nil, minconf = 1) @api.request 'getbalance', account, minconf end
Returns the hash of the best (tip) block in the longest block chain.
# File lib/dogecoin/client.rb, line 103 def getbestblockhash @api.request 'getbestblockhash' end
Dumps the block existing with specified hash.
# File lib/dogecoin/client.rb, line 56 def getblock(hash) block = @api.request 'getblock', hash block["time"] = Time.at(block["time"]).utc block end
Dumps the block existing at specified height. Note: this is not available in the official release
# File lib/dogecoin/client.rb, line 51 def getblockbycount(height) @api.request 'getblockbycount', height end
Returns the number of blocks in the longest block chain.
# File lib/dogecoin/client.rb, line 63 def getblockcount @api.request 'getblockcount' end
Returns the hash given a block id
# File lib/dogecoin/client.rb, line 98 def getblockhash(idx) @api.request 'getblockhash', idx end
Returns the block number of the latest block in the longest block chain.
# File lib/dogecoin/client.rb, line 73 def getblocknumber @api.request 'getblocknumber' end
Returns the number of connections to other nodes.
# File lib/dogecoin/client.rb, line 78 def getconnectioncount @api.request 'getconnectioncount' end
Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
# File lib/dogecoin/client.rb, line 83 def getdifficulty @api.request 'getdifficulty' end
Returns true or false whether dogecoind is currently generating hashes
# File lib/dogecoin/client.rb, line 88 def getgenerate @api.request 'getgenerate' end
Returns a recent hashes per second performance measurement while generating.
# File lib/dogecoin/client.rb, line 93 def gethashespersec @api.request 'gethashespersec' end
Returns an object containing various state info.
# File lib/dogecoin/client.rb, line 108 def getinfo @api.request 'getinfo' end
Returns an object containing mining info.
# File lib/dogecoin/client.rb, line 113 def getmininginfo @api.request 'getmininginfo' end
Returns a new dogecoin address for receiving payments. If account
is specified (recommended), it is added to the address book so payments received with the address will be credited to account
.
# File lib/dogecoin/client.rb, line 119 def getnewaddress(account = nil) @api.request 'getnewaddress', account end
Returns the total amount received by addresses with account
in transactions with at least minconf
confirmations.
# File lib/dogecoin/client.rb, line 125 def getreceivedbyaccount(account, minconf = 1) @api.request 'getreceivedbyaccount', account, minconf end
Returns the total amount received by dogecoinaddress
in transactions with at least minconf
confirmations.
# File lib/dogecoin/client.rb, line 130 def getreceivedbyaddress(dogecoinaddress, minconf = 1) @api.request 'getreceivedbyaddress', dogecoinaddress, minconf end
Get detailed information about txid
# File lib/dogecoin/client.rb, line 135 def gettransaction(txid) @api.request 'gettransaction', txid end
If data
is not specified, returns formatted hash data to work on:
:midstate => precomputed hash state after hashing the first half of the data :data => block data :hash1 => formatted hash buffer for second hash :target => little endian hash target
If data
is specified, tries to solve the block and returns true if it was successful.
# File lib/dogecoin/client.rb, line 147 def getwork(data = nil) @api.request 'getwork', data end
List commands, or get help for a command.
# File lib/dogecoin/client.rb, line 152 def help(command = nil) @api.request 'help', command end
# File lib/dogecoin/client.rb, line 5 def host; api.host; end
# File lib/dogecoin/client.rb, line 11 def host=(a); api.host = a; end
Returns Object
that has account names as keys, account balances as values.
# File lib/dogecoin/client.rb, line 157 def listaccounts(minconf = 1) @api.request 'listaccounts', minconf end
Returns an array of objects containing:
:account => the account of the receiving addresses :amount => total amount received by addresses with this account :confirmations => number of confirmations of the most recent transaction included
# File lib/dogecoin/client.rb, line 167 def listreceivedbyaccount(minconf = 1, includeempty = false) @api.request 'listreceivedbyaccount', minconf, includeempty end
Returns an array of objects containing:
:address => receiving address :account => the account of the receiving address :amount => total amount received by the address :confirmations => number of confirmations of the most recent transaction included
To get a list of accounts on the system, execute dogecoind listreceivedbyaddress 0 true
# File lib/dogecoin/client.rb, line 179 def listreceivedbyaddress(minconf = 1, includeempty = false) @api.request 'listreceivedbyaddress', minconf, includeempty end
Returns up to count
most recent transactions for account account
.
# File lib/dogecoin/client.rb, line 184 def listtransactions(account, count = 10) @api.request 'listtransactions', account, count end
Move from one account in your wallet to another.
# File lib/dogecoin/client.rb, line 189 def move(fromaccount, toaccount, amount, minconf = 1, comment = nil) @api.request 'move', fromaccount, toaccount, amount, minconf, comment end
# File lib/dogecoin/client.rb, line 15 def options api.options end
# File lib/dogecoin/client.rb, line 4 def pass; api.pass; end
# File lib/dogecoin/client.rb, line 10 def pass=(a); api.pass = a; end
# File lib/dogecoin/client.rb, line 6 def port; api.port; end
# File lib/dogecoin/client.rb, line 12 def port=(a); api.port = a; end
amount
is a real and is rounded to 8 decimal places. Returns the transaction ID if successful.
# File lib/dogecoin/client.rb, line 194 def sendfrom(fromaccount, todogecoinaddress, amount, minconf = 1, comment = nil, comment_to = nil) @api.request 'sendfrom', fromaccount, todogecoinaddress, amount, minconf, comment, comment_to end
# File lib/dogecoin/client.rb, line 203 def sendmany(fromaccount, addresses_amounts, minconf = 1, comment = nil) @api.request 'sendmany', fromaccount, addresses_amounts, minconf, comment end
amount
is a real and is rounded to 8 decimal places
# File lib/dogecoin/client.rb, line 199 def sendtoaddress(dogecoinaddress, amount, comment = nil, comment_to = nil) @api.request 'sendtoaddress', dogecoinaddress, amount, comment, comment_to end
Sets the account associated with the given address.
# File lib/dogecoin/client.rb, line 208 def setaccount(dogecoinaddress, account) @api.request 'setaccount', dogecoinaddress, account end
generate
is true or false to turn generation on or off. Generation is limited to genproclimit
processors, -1 is unlimited.
# File lib/dogecoin/client.rb, line 214 def setgenerate(generate, genproclimit = -1) @api.request 'setgenerate', generate, genproclimit end
Sets the default transaction fee
# File lib/dogecoin/client.rb, line 68 def settxfee(amount) @api.request 'settxfee', amount end
Sign a message using dogecoinaddress
.
# File lib/dogecoin/client.rb, line 229 def signmessage(dogecoinaddress, message) @api.request 'signmessage', dogecoinaddress, message end
# File lib/dogecoin/client.rb, line 7 def ssl; api.ssl; end
# File lib/dogecoin/client.rb, line 13 def ssl=(a); api.ssl = a; end
# File lib/dogecoin/client.rb, line 8 def ssl?; api.ssl?; end
Stop dogecoin server.
# File lib/dogecoin/client.rb, line 219 def stop @api.request 'stop' end
# File lib/dogecoin/client.rb, line 3 def user; api.user; end
# File lib/dogecoin/client.rb, line 9 def user=(a); api.user = a; end
Return information about dogecoinaddress
.
# File lib/dogecoin/client.rb, line 224 def validateaddress(dogecoinaddress) @api.request 'validateaddress', dogecoinaddress end
Verify signature made by dogecoinaddress
.
# File lib/dogecoin/client.rb, line 234 def verifymessage(dogecoinaddress, signature, message) @api.request 'verifymessage', dogecoinaddress, signature, message end
Removes the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked.
# File lib/dogecoin/client.rb, line 247 def walletlock @api.request 'walletlock' end
Stores the wallet decryption key in memory for timeout
seconds.
# File lib/dogecoin/client.rb, line 239 def walletpassphrase(passphrase, timeout) @api.request 'walletpassphrase', passphrase, timeout end