Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightning-rpc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightning-rpc

Statically generated Lightning gRPC library for Node.js, written in TypeScript.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lightning RPC

Statically generated Lightning gRPC library for Node.js, written in TypeScript.

Enviroment Variables

  • LND_HOST
  • LND_PORT
  • LND_CERT_PATH
  • LND_MACAROON_PATH
  • LND_WALLET_PASSWORD

Useage

import {
  GetInfoRequest,
  GetInfoResponse,
  Invoice,
  InvoiceSubscription,
  LightningRpcConfig,
  UnlockWalletRequest,
  UnlockWalletResponse,
  WalletBalanceRequest,
  WalletBalanceResponse,
  createLightning,
  createWalletUnlocker,
} from 'lightning-rpc';

const config = {
  host: String(process.env.LND_HOST),
  port: String(process.env.LND_PORT),
  certPath: String(process.env.LND_CERT_PATH),
  macaroonPath: String(process.env.LND_MACAROON_PATH),
};

const walletUnlocker = createWalletUnlocker(config);

walletUnlocker.waitForReady(Infinity, (error: Error | null) => {
  if (error) {
    console.error(error);
  }

  const unlockWalletRequest = new UnlockWalletRequest();

  if (!process.env.LND_WALLET_PASSWORD) {
    throw 'No wallet password. Set the LND_WALLET_PASSWORD enviroment variable.';
  }

  unlockWalletRequest.setWalletPassword(
    Buffer.from(process.env.LND_WALLET_PASSWORD),
  );

  walletUnlocker.unlockWallet(
    unlockWalletRequest,
    (error: ServiceError | null, response: UnlockWalletResponse) => {
      if (error) {
        console.error(error);
      }
      console.log('Wallet unlocked')
      const lightning = await createLightning(config);

      lightning.waitForReady(Infinity, (error: Error | null) => {
        if (error) {
          throw error;
        }
        const getInfoRequest = new GetInfoRequest();
        lightning.getInfo(
          getInfoRequest,
          (error: ServiceError | null, response: GetInfoResponse) => {
            if (error) {
              console.error(error);
            }
            console.log(response);
          },
        );

        const invoiceSubscription = new InvoiceSubscription();
        const stream: ClientReadableStream<Invoice> = lightning.subscribeInvoices(
          invoiceSubscription,
        );
        stream.on('data', (invoice: Invoice) => {
          console.log('invoice', invoice);
        })
      })
    }
  )
});

Compile from source

Requirements: protoc

git clone https://github.com/matthewlilley/lightning-rpc.git

cd lightning-rpc

yarn generate

Docs

https://matthewlilley.github.io/lightning-rpc

Contributing

Want to contribute? Awesome! Feel free to create an issue and/or pull request.

Licence

MIT

Keywords

FAQs

Package last updated on 20 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc