class Bitcoin::Node::CLI
Public Instance Methods
createwallet(wallet_id)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 51 def createwallet(wallet_id) request('createwallet', wallet_id) end
decoderawtransaction(hexstring)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 34 def decoderawtransaction(hexstring) request('decoderawtransaction', hexstring) end
decodescript(hexstring)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 39 def decodescript(hexstring) request('decodescript', hexstring) end
encryptwallet(passhphrase)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 71 def encryptwallet(passhphrase) request('encryptwallet', passhphrase) end
getblockchaininfo()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 13 def getblockchaininfo request('getblockchaininfo') end
getblockheader(hash, verbose = true)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 23 def getblockheader(hash, verbose = true) verbose = verbose.is_a?(String) ? (verbose == 'true') : verbose request('getblockheader', hash, verbose) end
getnewaddress(account)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 76 def getnewaddress(account) request('getnewaddress', account) end
getpeerinfo()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 29 def getpeerinfo request('getpeerinfo') end
getwalletinfo()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 61 def getwalletinfo request('getwalletinfo') end
listaccounts()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 66 def listaccounts request('listaccounts') end
listwallets()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 56 def listwallets request('listwallets') end
sendrawtransaction(hex_tx)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 46 def sendrawtransaction(hex_tx) request('sendrawtransaction', hex_tx) end
stop()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 18 def stop request('stop') end
Private Instance Methods
config()
click to toggle source
# File lib/bitcoin/node/cli.rb, line 82 def config opts = {} opts[:network] = options['network'] if options['network'] @conf ||= Bitcoin::Node::Configuration.new(opts) end
request(command, *params)
click to toggle source
# File lib/bitcoin/node/cli.rb, line 88 def request(command, *params) data = { :method => command, :params => params, :id => 'jsonrpc' } begin uri = URI.parse(config.server_url) http = Net::HTTP.new(uri.hostname, uri.port) http.use_ssl = uri.scheme === "https" request = Net::HTTP::Post.new('/') request.content_type = 'application/json' request.body = data.to_json response = http.request(request) body = response.body begin json = JSON.parse(body.to_str) puts JSON.pretty_generate(json) rescue Exception puts body.to_str end rescue Exception => e puts e.message end end