Class: Lnrpc::Client
- Inherits:
-
Object
- Object
- Lnrpc::Client
- Defined in:
- lib/lnrpc/client.rb
Constant Summary collapse
- LND_HOME_DIR =
ENV['LND_HOME'] || "~/.lnd"
- DEFAULT_ADDRESS =
'localhost:10009'
- DEFAULT_CREDENTIALS_PATH =
"#{LND_HOME_DIR}/tls.cert"
- DEFAULT_MACAROON_PATH =
"#{LND_HOME_DIR}/data/chain/bitcoin/mainnet/admin.macaroon"
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#macaroon ⇒ Object
Returns the value of attribute macaroon.
Instance Method Summary collapse
- #autopilot ⇒ Object
- #chain_notifier ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #invoices ⇒ Object
- #keysend(args) ⇒ Object
- #lightning ⇒ Object
- #pay(args) ⇒ Object
- #router ⇒ Object
- #signer ⇒ Object
- #versioner ⇒ Object
- #wallet_kit ⇒ Object
- #wallet_unlocker ⇒ Object
- #watchtower ⇒ Object
- #watchtower_client ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lnrpc/client.rb', line 13 def initialize(={}) self.address = [:address] || DEFAULT_ADDRESS if .has_key?(:credentials) # if there are non hex values prvided we assume it's the certificate file as string otherwise we assume it's the hex value self.credentials = [:credentials].match?(/\H/) ? [:credentials] : [[:credentials]].pack('H*') elsif File.exists?(::File.([:credentials_path] || DEFAULT_CREDENTIALS_PATH)) self.credentials = ::File.read(::File.([:credentials_path] || DEFAULT_CREDENTIALS_PATH)) else self.credentials = nil end if !.has_key?(:macaroon) && File.exists?(::File.([:macaroon_path] || DEFAULT_MACAROON_PATH)) [:macaroon] = ::File.read(::File.([:macaroon_path] || DEFAULT_MACAROON_PATH)).unpack("H*") end self.macaroon = [:macaroon] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
6 7 8 |
# File 'lib/lnrpc/client.rb', line 6 def address @address end |
#credentials ⇒ Object
Returns the value of attribute credentials.
6 7 8 |
# File 'lib/lnrpc/client.rb', line 6 def credentials @credentials end |
#macaroon ⇒ Object
Returns the value of attribute macaroon.
6 7 8 |
# File 'lib/lnrpc/client.rb', line 6 def macaroon @macaroon end |
Instance Method Details
#autopilot ⇒ Object
35 36 37 |
# File 'lib/lnrpc/client.rb', line 35 def autopilot @autopilot ||= grpc_wrapper_for(Autopilotrpc::Autopilot) end |
#chain_notifier ⇒ Object
39 40 41 |
# File 'lib/lnrpc/client.rb', line 39 def chain_notifier @chain_notifier ||= grpc_wrapper_for(Chainrpc::ChainNotifier) end |
#inspect ⇒ Object
88 89 90 |
# File 'lib/lnrpc/client.rb', line 88 def inspect "#{self} @address=\"#{address}\"" end |
#invoices ⇒ Object
43 44 45 |
# File 'lib/lnrpc/client.rb', line 43 def invoices @invoices ||= grpc_wrapper_for(Invoicesrpc::Invoices) end |
#keysend(args) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/lnrpc/client.rb', line 75 def keysend(args) args[:dest_custom_records] ||= {} args[:dest_custom_records][Lnrpc::KEY_SEND_PREIMAGE_TYPE] ||= Lnrpc.create_preimage args[:payment_hash] ||= Digest::SHA256.digest(args[:dest_custom_records][Lnrpc::KEY_SEND_PREIMAGE_TYPE]) args[:timeout_seconds] ||= 60 router.send_payment_v2(args) end |
#lightning ⇒ Object
31 32 33 |
# File 'lib/lnrpc/client.rb', line 31 def lightning @lightning ||= grpc_wrapper_for(Lnrpc::Lightning) end |
#pay(args) ⇒ Object
83 84 85 86 |
# File 'lib/lnrpc/client.rb', line 83 def pay(args) args[:timeout_seconds] ||= 60 router.send_payment_v2(args) end |
#router ⇒ Object
47 48 49 |
# File 'lib/lnrpc/client.rb', line 47 def router @router ||= grpc_wrapper_for(Routerrpc::Router) end |
#signer ⇒ Object
51 52 53 |
# File 'lib/lnrpc/client.rb', line 51 def signer @signer ||= grpc_wrapper_for(Signrpc::Signer) end |
#versioner ⇒ Object
55 56 57 |
# File 'lib/lnrpc/client.rb', line 55 def versioner @versioner ||= grpc_wrapper_for(Verrpc::Versioner) end |
#wallet_kit ⇒ Object
59 60 61 |
# File 'lib/lnrpc/client.rb', line 59 def wallet_kit @wallet_kit ||= grpc_wrapper_for(Walletrpc::WalletKit) end |
#wallet_unlocker ⇒ Object
63 64 65 |
# File 'lib/lnrpc/client.rb', line 63 def wallet_unlocker @wallet_unlocker ||= grpc_wrapper_for(Lnrpc::WalletUnlocker) end |
#watchtower ⇒ Object
67 68 69 |
# File 'lib/lnrpc/client.rb', line 67 def watchtower @watchtower ||= grpc_wrapper_for(Watchtowerrpc::Watchtower) end |
#watchtower_client ⇒ Object
71 72 73 |
# File 'lib/lnrpc/client.rb', line 71 def watchtower_client @watchtower_client ||= grpc_wrapper_for(Wtclientrpc::WatchtowerClient) end |