Spec and client library for WebLN apps and providers
Switch branches/tags
Nothing to show
Clone or download
Latest commit 26a1919 Dec 3, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Update interface for makeInvoice. Update README. Dec 4, 2018
.gitignore Add files config, logs to gitignore. Dec 4, 2018
README.md Update interface for makeInvoice. Update README. Dec 4, 2018
package.json v0.0.3 Dec 4, 2018
tsconfig.json Initial commit Oct 26, 2018
yarn.lock Initial commit Oct 26, 2018



This library provides the spec and client libraries for WebLN, a way of interacting with a user's Lightning node via the browser.

Heads up: This spec is in early alpha, and is subject to a lot of change. Join in the discussion in the issue queue, and try not to build any mainnet software off of it yet!

Client Library

Apps that want to enable WebLN payments can use the client library in webln/lib/client. It provides the following functions:


Attempts to acquire and enable a WebLN provider. It's recommended you wait to run this until after DOMContentLoaded to ensure that any client providers have had time to inject the WebLN instance.




Promise (see below) that's already been enable()d.


  • If no providers are available
  • If the provider rejects the enable() call (e.g. user doesn't confirm)


import { requestProvider } from 'webln/lib/client';

let webln;
try {
  webln = await requestProvider();
} catch (err) {
  // Handle users without WebLN

// Elsewhere in the code...
if (webln) {
  // Call webln functions

Provider Spec

Providers must implement the interface provided in webln/lib/provider. The spec is as follows:

export interface WebLNProvider {
  /* Determines if the WebLNProvider will allow the page to use it */
  enable(): Promise<void>;

  /* Returns some basic information about the node */
  getInfo(): Promise<GetInfoResponse>;

  /* Prompts the user with a BOLT-11 payment request */
  sendPayment(paymentRequest: string): Promise<SendPaymentResponse>;

  /* Prompts the user to provide the page with an invoice */
  makeInvoice(amount: string | number | RequestInvoiceArgs): Promise<RequestInvoiceResponse>;

  /* Prompts the user to sign a message with their private key */
  signMessage(message: string): Promise<SignMessageResponse>;

  /* Shows the user a view that verifies a signed message */
  verifyMessage(signedMessage: string, rawMessage: string): Promise<void>;

See the typescript definitions for more detail about request objects and response shapes. The spec is far from complete, and will need more functions to be fully-fledged, but these methods should cover most use-cases.


Please join the issue queue to discuss the future of the WebLN spec.