class Tapyrus::Node::CLI
Public Instance Methods
createwallet(wallet_id)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 52 def createwallet(wallet_id) request('createwallet', wallet_id) end
decoderawtransaction(hexstring)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 34 def decoderawtransaction(hexstring) request('decoderawtransaction', hexstring) end
decodescript(hexstring)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 39 def decodescript(hexstring) request('decodescript', hexstring) end
encryptwallet(passhphrase)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 74 def encryptwallet(passhphrase) request('encryptwallet', passhphrase) end
getblockchaininfo()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 11 def getblockchaininfo request('getblockchaininfo') end
getblockheader(hash, verbose = true)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 22 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/tapyrus/node/cli.rb, line 79 def getnewaddress(account) request('getnewaddress', account) end
getpeerinfo()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 28 def getpeerinfo request('getpeerinfo') end
getwalletinfo()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 63 def getwalletinfo request('getwalletinfo') end
listaccounts()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 68 def listaccounts request('listaccounts') end
listwallets()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 58 def listwallets request('listwallets') end
sendrawtransaction(hex_tx)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 46 def sendrawtransaction(hex_tx) request('sendrawtransaction', hex_tx) end
stop()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 16 def stop request('stop') end
Private Instance Methods
config()
click to toggle source
# File lib/tapyrus/node/cli.rb, line 85 def config opts = {} opts[:network] = options['network'] if options['network'] @conf ||= Tapyrus::Node::Configuration.new(opts) end
request(command, *params)
click to toggle source
# File lib/tapyrus/node/cli.rb, line 91 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