Class: Tapyrus::RPC::TapyrusCoreClient
- Inherits:
-
Object
- Object
- Tapyrus::RPC::TapyrusCoreClient
- Defined in:
- lib/tapyrus/rpc/tapyrus_core_client.rb
Overview
Client implementation for RPC to Tapyrus Core.
- Usage
-
config = ‘http’, host: ‘localhost’, port: 18332, user: ‘xxx’, password: ‘yyy’ client = Tapyrus::RPC::TapyrusCoreClient.new(config)
You can execute the CLI command supported by Tapyrus Core as follows:
client.listunspent client.getblockchaininfo
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ TapyrusCoreClient
constructor
A new instance of TapyrusCoreClient.
Constructor Details
#initialize(config) ⇒ TapyrusCoreClient
Returns a new instance of TapyrusCoreClient.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 67 def initialize(config) @config = config commands = request(:help) .split("\n") .inject([]) do |memo_ary, line| memo_ary << line.split(" ").first.to_sym if !line.empty? && !line.start_with?("==") memo_ary end TapyrusCoreClient.class_eval do commands.each { |command| define_method(command) { |*params| request(command, *params) } } end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
64 65 66 |
# File 'lib/tapyrus/rpc/tapyrus_core_client.rb', line 64 def config @config end |