GithubHelp home page GithubHelp logo

porticoexchange / lnd_client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from roosoft/lnd_client

0.0 0.0 0.0 167 KB

Connects to the Lightning Network Daemon known as LND

License: MIT License

Elixir 100.00%

lnd_client's Introduction

LndClient ⚡

Connects to the Lightning Network Daemon's gRPC API known as LND

Prerequisites for umbrel users

with a fresh clone of this project, run

mix deps.get

copy those files from the umbrel to the computer running the app

  • /home/umbrel/umbrel/lnd/tls.cert must be copied to ~/.lnd/umbrel.cert
  • add /home/umbrel/umbrel/lnd/data/chain/bitcoin/mainnet/readonly.macaroon to the ~/.lnd
  • look below for the NODE environment variable that must be set when you run iex -S mix

How to use as a dependency

The package can be installed by adding lnd_client to your list of dependencies in mix.exs:

def deps do
  [
    {:lnd_client, "~> 0.1.7"}
  ]
end

How to use with IEx

Connect to a LND node directly from IEx

Execute this in the root folder if your LND listens on the localhost port 10009

Otherwise, replace NODE_IP and NODE_LND_PORT to fit your environment

NODE_IP=localhost
NODE_LND_PORT=10009
NODE=$NODE_LND_PORT:$NODE_LND_PORT iex -S mix

Then, it is possible to get the LND's basic informations by typing

LndClient.get_info

How to use in an app

Add this dependency in mix.exs

{:lnd_client, git: "https://github.com/RooSoft/lnd_client.git", tag: "0.1"}

Start the server, get node info and then stop the server

LndClient.start_link(nil)
LndClient.get_info
LndClient.stop

Library Maintenance

Get fresh protos

List of protos

Make sure protoc is properly installed. Here is how to do it on Debian.

sudo apt install -y protobuf-compiler
mix escript.install hex protobuf
asdf reshim
cd proto

curl -O https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
curl -O https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto

protoc --elixir_out=plugins=grpc:../lib/gRPC lightning.proto
protoc --elixir_out=plugins=grpc:../lib/gRPC router.proto

cd ..

HTLC examples

Routerrpc.ForwardEvent

%Routerrpc.HtlcEvent{
  event: {:forward_event,
   %Routerrpc.ForwardEvent{
     info: %Routerrpc.HtlcInfo{
       incoming_amt_msat: 11005,
       incoming_timelock: 680165,
       outgoing_amt_msat: 11000,
       outgoing_timelock: 680125
     }
   }},
  event_type: :FORWARD,
  incoming_channel_id: 744146171265875972,
  incoming_htlc_id: 87,
  outgoing_channel_id: 742921315233366017,
  outgoing_htlc_id: 379,
  timestamp_ns: 1619026298906259040
}

Routerrpc.ForwardFailEvent

%Routerrpc.HtlcEvent{
  event: {:forward_fail_event, %Routerrpc.ForwardFailEvent{}},
  event_type: :FORWARD,
  incoming_channel_id: 744146171265875972,
  incoming_htlc_id: 88,
  outgoing_channel_id: 742921315233366017,
  outgoing_htlc_id: 380,
  timestamp_ns: 1619028533664696456
}

Routerrpc.SettleEvent

%Routerrpc.HtlcEvent{
  event: {:settle_event, %Routerrpc.SettleEvent{}},
  event_type: :RECEIVE,
  incoming_channel_id: 744146171265875972,
  incoming_htlc_id: 90,
  outgoing_channel_id: 0,
  outgoing_htlc_id: 0,
  timestamp_ns: 1619028715648844495
}

Routerrpc.LinkFailEvent

%Routerrpc.HtlcEvent{
  event: {:link_fail_event,
   %Routerrpc.LinkFailEvent{
     failure_detail: :INVALID_KEYSEND,
     failure_string: "invalid keysend parameters",
     info: %Routerrpc.HtlcInfo{
       incoming_amt_msat: 10000,
       incoming_timelock: 680090,
       outgoing_amt_msat: 0,
       outgoing_timelock: 0
     },
     wire_failure: :INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
   }},
  event_type: :RECEIVE,
  incoming_channel_id: 744146171265875972,
  incoming_htlc_id: 89,
  outgoing_channel_id: 0,
  outgoing_htlc_id: 0,
  timestamp_ns: 1619028709202674659
}

lnd_client's People

Contributors

roosoft avatar codlco avatar ramontayag avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.