module StartcoinClient::DSL
Public Instance Methods
Safely copies wallet.dat to destination, which can be a directory or a path with filename.
# File lib/startcoin_client/dsl.rb, line 64 def backupwallet(destination) bitcoin.backupwallet destination end
# File lib/startcoin_client/dsl.rb, line 2 def bitcoin if self.class.respond_to?(:bitcoin) @client ||= StartcoinClient::Client.new(self.class.bitcoin.user, self.class.bitcoin.pass, self.class.bitcoin.options) else @client ||= StartcoinClient::Client.new(nil, nil) end end
Returns the account associated with the given address.
# File lib/startcoin_client/dsl.rb, line 69 def getaccount(bitcoinaddress) bitcoin.getaccount bitcoinaddress end
Returns the current bitcoin address for receiving payments to this account.
# File lib/startcoin_client/dsl.rb, line 74 def getaccountaddress(account) bitcoin.getaccountaddress account end
Returns the list of addresses for the given account.
# File lib/startcoin_client/dsl.rb, line 79 def getaddressesbyaccount(account) bitcoin.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/startcoin_client/dsl.rb, line 85 def getbalance(account = nil, minconf = 1) bitcoin.getbalance account, minconf end
Returns the hash of the best (tip) block in the longest block chain.
# File lib/startcoin_client/dsl.rb, line 90 def getbestblockhash bitcoin.getbestblockhash end
Dumps the block existing with specified hash.
# File lib/startcoin_client/dsl.rb, line 101 def getblock(hash) bitcoin.getblock hash end
Dumps the block existing at specified height. Note: this is not available in the official release
# File lib/startcoin_client/dsl.rb, line 96 def getblockbycount(height) bitcoin.getblockbycount height end
Returns the number of blocks in the longest block chain.
# File lib/startcoin_client/dsl.rb, line 106 def getblockcount bitcoin.getblockcount end
Returns hash of block in best-block-chain at <index>; index 0 is the genesis block
# File lib/startcoin_client/dsl.rb, line 116 def getblockhash(index) bitcoin.getblockhash index end
Returns the block number of the latest block in the longest block chain.
# File lib/startcoin_client/dsl.rb, line 111 def getblocknumber bitcoin.getblocknumber end
Returns the number of connections to other nodes.
# File lib/startcoin_client/dsl.rb, line 121 def getconnectioncount bitcoin.getconnectioncount end
Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
# File lib/startcoin_client/dsl.rb, line 126 def getdifficulty bitcoin.getdifficulty end
Returns true or false whether bitcoind is currently generating hashes
# File lib/startcoin_client/dsl.rb, line 131 def getgenerate bitcoin.getgenerate end
Returns a recent hashes per second performance measurement while generating.
# File lib/startcoin_client/dsl.rb, line 136 def gethashespersec bitcoin.gethashespersec end
Returns an object containing various state info.
# File lib/startcoin_client/dsl.rb, line 141 def getinfo bitcoin.getinfo end
Returns an object containing various mining info.
# File lib/startcoin_client/dsl.rb, line 151 def getmininginfo bitcoin.getmininginfo end
Returns a new bitcoin 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/startcoin_client/dsl.rb, line 157 def getnewaddress(account = nil) bitcoin.getnewaddress account end
Returns data about each connected network node.
# File lib/startcoin_client/dsl.rb, line 146 def getpeerinfo bitcoin.getpeerinfo end
Gets all mempool txs (pedning/waiting to be added in a block)
# File lib/startcoin_client/dsl.rb, line 185 def getrawmempool bitcoin.getrawmempool end
Get raw transaction bout txid
. It outputs the whole transaction chain by default in HEX. If you want JSON, set verbose to 1. When in the bitcoind config is set txindex=1, after reindexing, you can ask about any transaction (not included in your wallet), with this command.
# File lib/startcoin_client/dsl.rb, line 180 def getrawtransaction(txid, verbose = 0) bitcoin.getrawtransaction txid verbose end
Returns the total amount received by addresses with account
in transactions with at least minconf
confirmations.
# File lib/startcoin_client/dsl.rb, line 163 def getreceivedbyaccount(account, minconf = 1) bitcoin.getreceivedbyaccount account, minconf end
Returns the total amount received by bitcoinaddress
in transactions with at least minconf
confirmations.
# File lib/startcoin_client/dsl.rb, line 168 def getreceivedbyaddress(bitcoinaddress, minconf = 1) bitcoin.getreceivedbyaddress bitcoinaddress, minconf end
Get detailed information about txid
# File lib/startcoin_client/dsl.rb, line 173 def gettransaction(txid) bitcoin.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/startcoin_client/dsl.rb, line 197 def getwork(data = nil) bitcoin.getwork data end
List commands, or get help for a command.
# File lib/startcoin_client/dsl.rb, line 202 def help(command = nil) bitcoin.help command end
# File lib/startcoin_client/dsl.rb, line 42 def host(value = nil) value ? bitcoin.host = value : bitcoin.host end
# File lib/startcoin_client/dsl.rb, line 18 def host=(value) bitcoin.host = value end
Returns Object
that has account names as keys, account balances as values.
# File lib/startcoin_client/dsl.rb, line 207 def listaccounts(minconf = 1) bitcoin.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/startcoin_client/dsl.rb, line 217 def listreceivedbyaccount(minconf = 1, includeempty = false) bitcoin.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 bitcoind listreceivedbyaddress 0 true
# File lib/startcoin_client/dsl.rb, line 229 def listreceivedbyaddress(minconf = 1, includeempty = false) bitcoin.listreceivedbyaddress minconf, includeempty end
Returns up to count
most recent transactions for account account
.
# File lib/startcoin_client/dsl.rb, line 234 def listtransactions(account = '', count = 10, from = 0) bitcoin.listtransactions account, count, from end
Move from one account in your wallet to another.
# File lib/startcoin_client/dsl.rb, line 239 def move(fromaccount, toaccount, amount, minconf = 1, comment = nil) bitcoin.move fromaccount, toaccount, amount, minconf, comment end
# File lib/startcoin_client/dsl.rb, line 38 def password(value = nil) value ? bitcoin.pass = value : bitcoin.pass end
# File lib/startcoin_client/dsl.rb, line 14 def password=(value) bitcoin.pass = value end
# File lib/startcoin_client/dsl.rb, line 46 def port(value = nil) value ? bitcoin.port = value : bitcoin.port end
# File lib/startcoin_client/dsl.rb, line 22 def port=(value) bitcoin.port = value end
# File lib/startcoin_client/dsl.rb, line 54 def proxy(value = nil) value.nil? ? bitcoin.proxy : bitcoin.proxy = value end
# File lib/startcoin_client/dsl.rb, line 30 def proxy=(value) bitcoin.proxy = value end
Return count transactions with <address> present in their scriptSig, skipping skip at the beginning. The ordering is oldest transaction first; if skip is negative the order returned is newest transaction first and skip+1 transactions are skipped. If verbose=0 only txids are returned rather than the full transactions.
# File lib/startcoin_client/dsl.rb, line 244 def searchrawtransactions(bitcoinaddress, verbose=1) bitcoin.searchrawtransactions bitcoinaddress, verbose end
amount
is a real and is rounded to 8 decimal places. Returns the transaction ID if successful.
# File lib/startcoin_client/dsl.rb, line 249 def sendfrom(fromaccount, tobitcoinaddress, amount, minconf = 1, comment = nil, comment_to = nil) bitcoin.sendfrom fromaccount, tobitcoinaddress, amount, minconf, comment, comment_to end
amount
is a real and is rounded to 8 decimal places
# File lib/startcoin_client/dsl.rb, line 254 def sendtoaddress(bitcoinaddress, amount, comment = nil, comment_to = nil) bitcoin.sendtoaddress bitcoinaddress, amount, comment, comment_to end
Sets the account associated with the given address.
# File lib/startcoin_client/dsl.rb, line 259 def setaccount(bitcoinaddress, account) bitcoin.setaccount bitcoinaddress, account end
generate
is true or false to turn generation on or off. Generation is limited to genproclimit
processors, -1 is unlimited.
# File lib/startcoin_client/dsl.rb, line 265 def setgenerate(generate, genproclimit = -1) bitcoin.setgenerate generate, genproclimit end
# File lib/startcoin_client/dsl.rb, line 50 def ssl(value = nil) value.nil? ? bitcoin.ssl : bitcoin.ssl = value end
# File lib/startcoin_client/dsl.rb, line 26 def ssl=(value) bitcoin.ssl = value end
# File lib/startcoin_client/dsl.rb, line 58 def ssl? bitcoin.ssl? end
Stop bitcoin server.
# File lib/startcoin_client/dsl.rb, line 270 def stop bitcoin.stop end
# File lib/startcoin_client/dsl.rb, line 34 def username(value = nil) value ? bitcoin.user = value : bitcoin.user end
# File lib/startcoin_client/dsl.rb, line 10 def username=(value) bitcoin.user = value end
Return information about bitcoinaddress
.
# File lib/startcoin_client/dsl.rb, line 275 def validateaddress(bitcoinaddress) bitcoin.validateaddress end