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.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lnrpc/client.rb', line 12 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.
5 6 7 |
# File 'lib/lnrpc/client.rb', line 5 def address @address end |
#credentials ⇒ Object
Returns the value of attribute credentials.
5 6 7 |
# File 'lib/lnrpc/client.rb', line 5 def credentials @credentials end |
#macaroon ⇒ Object
Returns the value of attribute macaroon.
5 6 7 |
# File 'lib/lnrpc/client.rb', line 5 def macaroon @macaroon end |
Instance Method Details
#autopilot ⇒ Object
34 35 36 |
# File 'lib/lnrpc/client.rb', line 34 def autopilot @autopilot ||= grpc_wrapper_for(Autopilotrpc::Autopilot) end |
#chain_notifier ⇒ Object
38 39 40 |
# File 'lib/lnrpc/client.rb', line 38 def chain_notifier @chain_notifier ||= grpc_wrapper_for(Chainrpc::ChainNotifier) end |
#inspect ⇒ Object
87 88 89 |
# File 'lib/lnrpc/client.rb', line 87 def inspect "#{self} @address=\"#{address}\"" end |
#invoices ⇒ Object
42 43 44 |
# File 'lib/lnrpc/client.rb', line 42 def invoices @invoices ||= grpc_wrapper_for(Invoicesrpc::Invoices) end |
#keysend(args) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/lnrpc/client.rb', line 74 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
30 31 32 |
# File 'lib/lnrpc/client.rb', line 30 def lightning @lightning ||= grpc_wrapper_for(Lnrpc::Lightning) end |
#pay(args) ⇒ Object
82 83 84 85 |
# File 'lib/lnrpc/client.rb', line 82 def pay(args) args[:timeout_seconds] ||= 60 router.send_payment_v2(args) end |
#router ⇒ Object
46 47 48 |
# File 'lib/lnrpc/client.rb', line 46 def router @router ||= grpc_wrapper_for(Routerrpc::Router) end |
#signer ⇒ Object
50 51 52 |
# File 'lib/lnrpc/client.rb', line 50 def signer @signer ||= grpc_wrapper_for(Signrpc::Signer) end |
#versioner ⇒ Object
54 55 56 |
# File 'lib/lnrpc/client.rb', line 54 def versioner @versioner ||= grpc_wrapper_for(Verrpc::Versioner) end |
#wallet_kit ⇒ Object
58 59 60 |
# File 'lib/lnrpc/client.rb', line 58 def wallet_kit @wallet_kit ||= grpc_wrapper_for(Walletrpc::WalletKit) end |
#wallet_unlocker ⇒ Object
62 63 64 |
# File 'lib/lnrpc/client.rb', line 62 def wallet_unlocker @wallet_unlocker ||= grpc_wrapper_for(Lnrpc::WalletUnlocker) end |
#watchtower ⇒ Object
66 67 68 |
# File 'lib/lnrpc/client.rb', line 66 def watchtower @watchtower ||= grpc_wrapper_for(Watchtowerrpc::Watchtower) end |
#watchtower_client ⇒ Object
70 71 72 |
# File 'lib/lnrpc/client.rb', line 70 def watchtower_client @watchtower_client ||= grpc_wrapper_for(Wtclientrpc::WatchtowerClient) end |