Module: Lightning
- Defined in:
- lib/lightning/node.rb,
lib/lightning/stub.rb,
lib/lightning/config.rb,
lib/lightning/version.rb,
lib/lightning/channels.rb,
lib/lightning/invoices.rb
Overview
Namespace for classes and modules that handle communication with your LND node
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
Current SDK version number.
'0.1.1'.freeze
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.addinvoice(**args) ⇒ Lnrpc::AddInvoiceResponse
Add a new invoice, expressing intent for a future payment.
-
.closedchannels(**args) ⇒ Lnrpc::ClosedChannelsResponse
Closedchannels returns a description of all the closed channels that this node was a participant in.
-
.configure {|configuration| ... } ⇒ Object
The configure class method stores a Configuration object inside the Lightning module.
-
.decodepayreq(pay_req) ⇒ Lnrpc::PayReq
Decodepayreq takes an encoded payment request string and attempts to decode it, returning a full description of the conditions encoded within the payment request.
-
.getinfo ⇒ Lnrpc::GetInfoResponse
Returns general information concerning the lightning node including it's identity pubkey, alias, the chains it is connected to, and information concerning the number of open+pending channels.
-
.getnetworkinfo ⇒ Lnrpc::NetworkInfo
Getnetworkinfo returns some basic stats about the known channel graph from the point of view of the node.
-
.getnodeinfo(pubkey) ⇒ Lnrpc::NodeInfo
Getnodeinfo returns the latest advertised, aggregated, and authenticated channel information for the specified node identified by its public key.
-
.listchannels(**args) ⇒ Lnrpc::ListChannelsResponse
Listchannels returns a description of all the open channels that this node is a participant in.
-
.listinvoices(**args) ⇒ Lnrpc::ListInvoiceResponse
Listinvoices the retrieval of all invoices currently stored within the database.
-
.pendingchannels ⇒ Lnrpc::PendingChannelsResponse
Pendingchannels returns a list of all the channels that are currently considered “pending”.
-
.subscribeinvoices(**args) ⇒ Array<Lnrpc::Invoice>
Subscribeinvoices returns a uni-directional stream (server -> client) for notifying the client of newly added/settled invoices.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration
4 5 6 |
# File 'lib/lightning/config.rb', line 4 def configuration @configuration end |
Class Method Details
.addinvoice(**args) ⇒ Lnrpc::AddInvoiceResponse
Add a new invoice, expressing intent for a future payment. Invoices without an amount can be created by not supplying any parameters or providing an amount of 0. These invoices allow the payee to specify the amount of satoshis they wish to send.
26 27 28 29 30 31 32 33 |
# File 'lib/lightning/invoices.rb', line 26 def addinvoice(**args) stub.add_invoice( Lnrpc::Invoice.new( value: args[:value], expiry: args[:expiry], memo: args[:memo] ) ) end |
.closedchannels(**args) ⇒ Lnrpc::ClosedChannelsResponse
Closedchannels returns a description of all the closed channels that this node was a participant in.
22 23 24 25 26 27 28 29 30 |
# File 'lib/lightning/channels.rb', line 22 def closedchannels(**args) stub.closed_channels( Lnrpc::ClosedChannelsRequest.new( cooperative: args[:cooperative], local_force: args[:local_force], remote_force: args[:remote_force], breach: args[:breach], funding_canceled: args[:funding_canceled], abandoned: args[:abandoned] ) ) end |
.configure {|configuration| ... } ⇒ Object
The configure class method stores a Configuration object inside the Lightning module. Anything set from the configure block is an attr_accessor on the Configuration class.
20 21 22 23 |
# File 'lib/lightning/config.rb', line 20 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.decodepayreq(pay_req) ⇒ Lnrpc::PayReq
Decodepayreq takes an encoded payment request string and attempts to decode it, returning a full description of the conditions encoded within the payment request.
46 47 48 49 |
# File 'lib/lightning/invoices.rb', line 46 def decodepayreq(pay_req) opts = { pay_req: pay_req } stub.decode_pay_req(Lnrpc::PayReqString.new(opts)) end |
.getinfo ⇒ Lnrpc::GetInfoResponse
Returns general information concerning the lightning node including it's identity pubkey, alias, the chains it is connected to, and information concerning the number of open+pending channels.
13 14 15 |
# File 'lib/lightning/node.rb', line 13 def getinfo stub.get_info(Lnrpc::GetInfoRequest.new) end |
.getnetworkinfo ⇒ Lnrpc::NetworkInfo
Getnetworkinfo returns some basic stats about the known channel graph from the point of view of the node.
25 26 27 28 29 |
# File 'lib/lightning/node.rb', line 25 def getnetworkinfo stub.get_network_info( Lnrpc::NetworkInfoRequest.new ) end |
.getnodeinfo(pubkey) ⇒ Lnrpc::NodeInfo
Getnodeinfo returns the latest advertised, aggregated, and authenticated channel information for the specified node identified by its public key.
40 41 42 43 44 |
# File 'lib/lightning/node.rb', line 40 def getnodeinfo(pubkey) stub.get_node_info( Lnrpc::NodeInfoRequest.new(pub_key: pubkey) ) end |
.listchannels(**args) ⇒ Lnrpc::ListChannelsResponse
Listchannels returns a description of all the open channels that this node is a participant in.
45 46 47 48 49 50 51 52 |
# File 'lib/lightning/channels.rb', line 45 def listchannels(**args) stub.list_channels( Lnrpc::ListChannelsRequest.new( active_only: args[:active_only], inactive_only: args[:inactive_only], public_only: args[:public_only], private_only: args[:private_only] ) ) end |
.listinvoices(**args) ⇒ Lnrpc::ListInvoiceResponse
Listinvoices the retrieval of all invoices currently stored within the database. It has full support for paginationed responses, allowing users to query for specific invoices through their add_index. This can be done by using either the first_index_offset or last_index_offset fields included in the response as the index_offset of the next request. The reversed flag is set by default in order to paginate backwards. If you wish to paginate forwards, you must explicitly set the flag to false. If none of the parameters are specified, then the last 100 invoices will be returned. For example: if you have 200 invoices, “listinvoices” will return the last 100 created. If you wish to retrieve the previous 100, the first_offset_index of the response can be used as the index_offset of the next listinvoices request.
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/lightning/invoices.rb', line 84 def listinvoices(**args) num_max_invoices = args[:num_max_invoices] index_offset = args[:index_offset] pending_only = args[:pending_only] reversed = args[:reversed] stub.list_invoices( Lnrpc::ListInvoiceRequest.new( num_max_invoices: num_max_invoices, index_offset: index_offset, pending_only: pending_only, reversed: reversed ) ) end |
.pendingchannels ⇒ Lnrpc::PendingChannelsResponse
Pendingchannels returns a list of all the channels that are currently considered “pending”. A channel is pending if it has finished the funding workflow and is waiting for confirmations for the funding txn, or is in the process of closure, either initiated cooperatively or non- cooperatively.
65 66 67 68 69 |
# File 'lib/lightning/channels.rb', line 65 def pendingchannels stub.pending_channels( Lnrpc::PendingChannelsRequest.new ) end |
.subscribeinvoices(**args) ⇒ Array<Lnrpc::Invoice>
Subscribeinvoices returns a uni-directional stream (server -> client) for notifying the client of newly added/settled invoices. The caller can optionally specify the add_index and/or the settle_index. If the add_index is specified, then we'll first start by sending add invoice events for all invoices with an add_index greater than the specified value. If the settle_index is specified, the next, we'll send out all settle events for invoices with a settle_index greater than the specified value. One or both of these fields can be set. If no fields are set, then we'll only send out the latest add/settle events.
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/lightning/invoices.rb', line 122 def subscribeinvoices(**args) stub.subscribe_invoices( Lnrpc::InvoiceSubscription.new( add_index: args[:add_index], settle_index: args[:settle_index] ) ) do |invoice| yield(invoice) end end |