Module: LightningSDK

Defined in:
lib/lightning/node.rb,
lib/lightning/stub.rb,
lib/lightning/invoice.rb,
lib/lightning/version.rb

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.add(**args) ⇒ Lnrpc::AddInvoiceResponse

Attempts to add a new invoice to the invoice database and returns a payment request.

Examples:

Create a new invoice

Lightning::Invoice.add(value: 500, memo: '1x Cappuccino')

Parameters:

  • args (Hash)

    a customizable set of options

Options Hash (**args):

  • :value (Integer) — default: 0

    Amount in satoshis

  • :expiry (Integer) — default: 3600

    Payment request expiry time in seconds.

  • :memo (String) — default: ''

    An optional memo to attach along with the invoice. Used for record keeping purposes for the invoices creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used.

Returns:

  • (Lnrpc::AddInvoiceResponse)

    response



22
23
24
25
26
27
28
29
30
# File 'lib/lightning/invoice.rb', line 22

def add(**args)
  value = args[:value]
  expiry = args[:expiry]
  memo = args[:memo]

  return_res stub.add_invoice(
    Lnrpc::Invoice.new(value: value, expiry: expiry, memo: memo)
  )
end

.infoLnrpc::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.

Examples:

Receive node info

Lightning::Node.info #=> {:identity_pubkey=>... }

Returns:

  • (Lnrpc::GetInfoResponse)

    the response



11
12
13
# File 'lib/lightning/node.rb', line 11

def info
  return_res stub.get_info(Lnrpc::GetInfoRequest.new)
end

.list(**args) ⇒ Lnrpc::ListInvoiceResponse

Returns a list of all the invoices currently stored within the database. Any active debug invoices are ignored. It has full support for paginated 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. By default, the first 100 invoices created will be returned. Backwards pagination is also supported through the Reversed flag.

Examples:

List all invoices

Lightning::Invoice.list

Returns:

  • (Lnrpc::ListInvoiceResponse)

    response



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/lightning/invoice.rb', line 45

def list(**args)
  num_max_invoices = args[:num_max_invoices]
  index_offset = args[:index_offset]
  pending_only = args[:pending_only]
  reversed = args[:reversed]

  return_res stub.list_invoices(
    Lnrpc::ListInvoiceRequest.new(
      num_max_invoices: num_max_invoices, index_offset: index_offset,
      pending_only: pending_only, reversed: reversed
    )
  )
end