All Projects → joule-labs → Webln

joule-labs / Webln

Spec and client library for WebLN apps and providers

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Webln

Electrum
Electrum Bitcoin Wallet
Stars: ✭ 5,353 (+3144.24%)
Mutual labels:  lightning, lightning-network
Awesome Bitcoin Payment Processors
🌟 A curated list of Bitcoin payment processors enabling merchants, businesses and nonprofits to accept Bitcoin payments.
Stars: ✭ 129 (-21.82%)
Mutual labels:  lightning, lightning-network
Umbrel
A personal Bitcoin and Lightning node designed for everyone
Stars: ✭ 508 (+207.88%)
Mutual labels:  lightning, lightning-network
Lndmanage
Channel management tool for lightning network daemon (LND) operators.
Stars: ✭ 114 (-30.91%)
Mutual labels:  lightning, lightning-network
Paper
Lightning Network Paper
Stars: ✭ 136 (-17.58%)
Mutual labels:  lightning, lightning-network
Polar
One-click Bitcoin Lightning networks for local app development & testing
Stars: ✭ 265 (+60.61%)
Mutual labels:  lightning, lightning-network
Eclair
A scala implementation of the Lightning Network.
Stars: ✭ 892 (+440.61%)
Mutual labels:  lightning, lightning-network
trustedcoin
A lightningd plugin that replaces your own Bitcoin Core node with trusted public explorers.
Stars: ✭ 24 (-85.45%)
Mutual labels:  lightning, lightning-network
Phoenix
Phoenix is a non custodial Bitcoin wallet using Lightning to send/receive payments.
Stars: ✭ 129 (-21.82%)
Mutual labels:  lightning, lightning-network
Blixt Wallet
Bitcoin Lightning Wallet with focus on usability and user experience
Stars: ✭ 40 (-75.76%)
Mutual labels:  lightning, lightning-network
Umbrel Os
Run Umbrel Bitcoin and Lightning node on a Raspberry Pi in one click
Stars: ✭ 132 (-20%)
Mutual labels:  lightning, lightning-network
Lightning Rfc
Lightning Network Specifications
Stars: ✭ 1,224 (+641.82%)
Mutual labels:  lightning, lightning-network
BitcoinCacheMachine
Run privacy-preserving Bitcoin payment infrastructure at your home or office. Deploy on commodity x64_86.
Stars: ✭ 18 (-89.09%)
Mutual labels:  lightning, lightning-network
Joule Extension
Lightning payments extension for Chrome
Stars: ✭ 303 (+83.64%)
Mutual labels:  lightning, lightning-network
awesome-lnurl
A curated list of awesome lnurl things.
Stars: ✭ 252 (+52.73%)
Mutual labels:  lightning, lightning-network
Lnd
Lightning Network Daemon ⚡️
Stars: ✭ 5,623 (+3307.88%)
Mutual labels:  lightning, lightning-network
lightning-browser-extension
The Bitcoin Lightning Browser extension that connects to different wallet interfaces and brings deep lightning integration to the web
Stars: ✭ 194 (+17.58%)
Mutual labels:  lightning, lightning-network
rawtxapp
⚡️A lightning network wallet (https://rawtx.com).
Stars: ✭ 56 (-66.06%)
Mutual labels:  lightning, lightning-network
Lightninglib
lightninglib is a fork of lnd which aims to be usable as a go library inside any application, including mobile apps.
Stars: ✭ 11 (-93.33%)
Mutual labels:  lightning, lightning-network
Lightning Faucet
A faucet for the Lightning Network!
Stars: ✭ 56 (-66.06%)
Mutual labels:  lightning, lightning-network

WebLN

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 stages, and is subject to change. Join in the discussion in the issue queue, and please be mindful when building apps with it!

Documentation and Demos

Check out the documentation site at https://webln.dev/

If you'd like to contribute to the documentation, you can find it over at https://github.com/wbobeirne/webln-docs

TL;DR Docs

Installation

For use in node-built projects, install via npm or yarn:

npm install webln
# OR #
yarn add webln

If you don't have a build system, you can add the following script tag to your project which will add all functionality under the global WebLN namespace:

<script
  src="https://unpkg.com/[email protected]/dist/webln.min.js"
  integrity="sha384-Enk2tnv6U0yPoFk7RasscZ5oQIG2fzVYaG4ledkAf7MdEXP9fMazV74tAgEwvxm7"
  crossorigin="anonymous"
></script>

Make sure you leave the integrity hash in to prevent possibly malicious JS

Client Library

Apps that want to enable WebLN interactions can use the requestProvider function to grab a WebLN provider:

import { requestProvider } from 'webln';

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

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

WebLN Provider

Providers are classes that 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(signature: string, message: 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.

Errors

Both apps and providers will want to make use of WebLN's pre-defined errors. They can be found in webln/lib/errors and should be used when throwing and handling errors to best inform the user of what's going on:

// For example, an app should check if an uncommon method isn't supported,
// and let the user know what to do.
import { requestProvider } from 'webln';
import { UnsupportedMethodError } from 'webln/lib/errors';

async function signMsg(msg: string) {
  try {
    const webln = await requestProvider();
    const res = await webln.signMessage(msg);
    return res;
  } catch(err) {
    if (err.constructor === UnsupportedMethodError) {
      alert('Your WebLN provider doesn’t support message signing, please email [email protected] for manual verification');
    } else {
      alert(err.message);
    }
  }

And the provider should throw the correct error when possible:

// And a provider should correctly throw this error
import { WebLNProvider } from 'webln';
import { UnsupportedMethodError } from 'webln/lib/errors';

class MyProvider extends WebLNProvider {
  signMessage() {
    throw new UnsupportedMethodError('MyProvider doesn’t support message signatures!');
  }
}

See the full list of error types for more information.

Contributing

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].