Skip to content

ivanacostarubio/lightning_network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LIGHTNING.RB

⊂_ヽ
  \\ Λ_Λ
   \( ˇωˇ)
    / ⌒
  /  へ\
  /  / \\
   レ ノ   ヽ_つ
  / /  So you are telling me I can use Lightning from Ruby now? ⚡️ 
 ( (ヽ
 | |、 \
 | 丿 \
 | |  ) /
ノ )  Lノ

A Ruby library to talk to Lightning Nodes

Install

gem install lightning_network

Now we need to configure environment variables for:

  • admin.macaroons : ENV['lnd_macaroon']
  • cert.tls : ENV['lnd_cert']
  • Lightning Network Node : ENV['lnd_host']

require 'lightning_network'

irb(main):002:0> ENV["lnd_host"] = "lightning:10009"
=> "lightning:10009"
irb(main):006:0> ENV["lnd_cert"] = "./tls.cert"
=> "./tls.cert"

irb(main):009:0> ENV["lnd_macaroon"] = "./admin.macaroon"
=> "./admin.macaroon"

irb(main):012:0> Node.new.get_info
=> ⚡️ 


Backends

We curently fully support LND.

Authentication

We use Macaroons and the certificate generated by lnd to authenticate. See Node.rb.

TODO:

  • Yard Documentation for:
  • Node::Payments
  • Node::Channels
  • Node::OnChain
  • Node::Peers
  • Node::Wallet

LND

We fully support lnd-cli with a Ruby like API. For example:

Node.new.get_info 

Node::Payments.new.list_invoices

Node::Channels.new.list_channels

Node::OnChain.new.send_coins(address, number)

Node::Peers.new.list_peers

Node::Wallet.new_address

LN-CLI HELP

The following is the help from ln-cli. We wrapped most of the commands below with a Ruby like syntax.


############
  Legend
############

* DONE
- WON'T DO
p PENDING

------------



COMMANDS:

*     getinfo     Returns basic information related to the active daemon.
-     debuglevel  Set the debug level.
-     stop        Stop and shutdown the daemon.
-     help, h     Shows a list of commands or help for one command

   Startup:
-     create  Initialize a wallet when starting lnd for the first time.
-     unlock  Unlock an encrypted wallet at startup.




   Payments:

p    getchaninfo       Get the state of a channel.
p    queryroutes    Query a route to a destination.
p    fwdinghistory  Query the history of all forwarded HTLCs.



*     payinvoice     Pay an invoice over lightning.
*     sendpayment    Send a payment over lightning.
*     addinvoice     Add a new invoice.
*     lookupinvoice  Lookup an existing invoice by its payment hash.
*     decodepayreq   Decode a payment request.
*     listinvoices   List all invoices currently stored.
*     listpayments   List all outgoing payments.

   Channels:

p     openchannel       Open a channel to a node or an existing peer.
*     closechannel      Close an existing channel.
*     closeallchannels  Close all existing channels.

*     channelbalance    Returns the sum of the total available channel balance across all open chans
*     pendingchannels   Display information pertaining to pending channels.
*     listchannels      List all open channels.
*     getnetworkinfo    Get statistical information about the current state of the network.
*     feereport         Display the current fee policies of all active channels.
-     updatechanpolicy  Update the channel policy for all channels, or a single channel.



   On-chain:

*     sendmany       Send bitcoin on-chain to multiple addresses.
*     sendcoins      Send bitcoin on-chain to an address.
*     listchaintxns  List transactions from the wallet.


*   Peers:

*     connect        Connect to a remote lnd peer.
*     disconnect     Disconnect a remote lnd peer identified by public key.
*     listpeers      List all active, currently connected peers.
*     describegraph  Describe the network graph.
*     getnodeinfo    Get information on a specific node.

   Wallet:

*     newaddress     Generates a new address.
*     walletbalance  Compute and display the wallet's current balance.
*     signmessage    Sign a message with the node's private key.
*     verifymessage  Verify a message signed with the signature.

About

Lightning Network in Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published