GithubHelp home page GithubHelp logo

lnd-pathfinding's Introduction

Lightning Network Pathfinding

npm version

Methods

calculateHops

Calculate hops between start and end nodes

{
  channels: [{
    capacity: <Capacity Tokens Number>
    id: <Standard Channel Id String>
    policies: [{
      base_fee_mtokens: <Base Fee Millitokens String>
      cltv_delta: <CLTV Delta Number>
      fee_rate: <Fee Rate Number>
      is_disabled: <Channel is Disabled Bool>
      max_htlc_mtokens: <Maximum HTLC Millitokens String>
      min_htlc_mtokens: <Minimum HTLC Millitokens String>
      public_key: <Public Key Hex String>
    }]
  }]
  end: <End Public Key Hex String>
  [ignore]: [{
    [channel]: <Standard Format Channel Id String>
    public_key: <Public Key Hex String>
  }]
  mtokens: <Millitokens Number>
  start: <Start Public Key Hex String>
}

@throws
<Error>

@returns
{
  [hops]: [{
    base_fee_mtokens: <Base Fee Millitokens String>
    channel: <Standard Channel Id String>
    channel_capacity: <Channel Capacity Tokens Number>
    cltv_delta: <CLTV Delta Number>
    fee_rate: <Fee Rate Number>
    public_key: <Public Key Hex String>
  }]
}

Example:

const {calculateHops} = require('ln-pathfinding');
const {getIdentity, getNetworkGraph} = require('ln-service');
const {channels} = await getNetworkGraph({lnd});
const end = 'destinationPublicKeyHexString';
const start = (await getIdentity({lnd})).public_key;
const {hops} = calculateHops({channels, end, start, mtokens: '1000'});

calculatePaths

Calculate multiple routes to a destination

{
  channels: [{
    capacity: <Capacity Tokens Number>
    id: <Standard Channel Id String>
    policies: [{
      base_fee_mtokens: <Base Fee Millitokens String>
      cltv_delta: <CLTV Delta Number>
      fee_rate: <Fee Rate Number>
      is_disabled: <Channel is Disabled Bool>
      max_htlc_mtokens: <Maximum HTLC Millitokens String>
      min_htlc_mtokens: <Minimum HTLC Millitokens String>
      public_key: <Public Key Hex String>
    }]
  }]
  end: <End Public Key Hex String>
  [limit]: <Paths To Return Limit Number>
  mtokens: <Millitokens Number>
  start: <Start Public Key Hex String>
}

@throws
<Error>

@returns
{
  [paths]: [{
    hops: [{
      base_fee_mtokens: <Base Fee Millitokens String>
      channel: <Standard Channel Id String>
      channel_capacity: <Channel Capacity Tokens Number>
      cltv_delta: <CLTV Delta Number>
      fee_rate: <Fee Rate Number>
      public_key: <Public Key Hex String>
    }]
  }]
}

Example:

const {calculatePaths} = require('ln-pathfinding');
const {getIdentity, getNetworkGraph} = require('ln-service');
const {channels} = await getNetworkGraph({lnd});
const end = 'destinationPublicKeyHexString';
const start = (await getIdentity({lnd})).public_key;
const {paths} = calculatePaths({channels, end, start, mtokens: '1000'});

lnd-pathfinding's People

Contributors

alexbosworth avatar filipchalupa 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.