Method: Lnrpc::Client#initialize

Defined in:
lib/lnrpc/client.rb

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/lnrpc/client.rb', line 32

def initialize(options={})
  self.address = options[:address] || DEFAULT_ADDRESS

  if options.has_key?(:credentials)
    self.credentials = options[:credentials]
  elsif File.exists?(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
    self.credentials = ::File.read(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
  else
    self.credentials = nil
  end

  if !options.has_key?(:macaroon) && File.exists?(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH))
    options[:macaroon] = ::File.read(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH)).unpack("H*")
  end
  self.macaroon = options[:macaroon]
end