인터페이스는 현지화되어 있으며, Skill 소개와 설명 문서는 선택한 언어로 AI가 자동 번역합니다. 코드·명령어·경로·전문 용어는 원문을 유지하며 원작자 문서가 우선합니다.
Skills 둘러보기
디자인 및 창작 · SKILL.md

lightning-webln

lightning-webln

WebLN: browser API for Lightning. window.webln exposed by wallet extensions / mobile webviews. Methods: enable, getInfo, sendPayment, makeInvoice, signMessage. Bitcoin Connect (modern wrapper). USE WHEN: building web apps with Lightning payments, integrating with Alby/getalby, designing WebLN-compatible flows.

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill 문서

GitHub

name: lightning-webln description: | WebLN: browser API for Lightning. window.webln exposed by wallet extensions / mobile webviews. Methods: enable, getInfo, sendPayment, makeInvoice, signMessage. Bitcoin Connect (modern wrapper). USE WHEN: building web apps with Lightning payments, integrating with Alby/getalby, designing WebLN-compatible flows. allowed-tools: Read, Grep, Glob

WebLN

WebLN is a JavaScript API that lets web pages interact with the user's Lightning wallet via a browser extension or in-page provider.

Spec: https://www.webln.guide/

Detection

if (typeof window.webln !== "undefined") {
    await window.webln.enable();
    // Now you can call other methods
}

enable() triggers a permission prompt the first time on a new domain.

Methods

getInfo()

const info = await window.webln.getInfo();
// { node: { alias, pubkey, color }, methods: [...] }

Returns wallet info; methods lists supported operations.

sendPayment(invoice)

const r = await window.webln.sendPayment("lnbc100u...");
// { preimage: "abcd..." }

Invokes wallet UI to confirm payment. Returns preimage on success.

makeInvoice(args)

const r = await window.webln.makeInvoice({
    amount: 1000,    // sats
    defaultMemo: "Coffee"
});
// { paymentRequest: "lnbc1u..." }

User confirms amount; wallet generates invoice.

signMessage(message)

const r = await window.webln.signMessage("Hello");
// { signature: "...", message: "Hello" }

Signs with the wallet's node key (BIP137-style). Used for auth.

verifyMessage(signature, message)

Verify a signature against the wallet's node pubkey.

keysend(args) (some impls)

await window.webln.keysend({
    destination: "<pubkey>",
    amount: 100,
    customRecords: { "1234": "abc" }
});

Providers

ProviderType
Alby Browser ExtensionMost popular, supports custodial + connect-to-node
getalby.com hostedWeb-based, login provides webln
JouleOlder, less maintained
Mutiny WalletWeb-based, exposes webln in its iframe
Custom (e.g., businesses)Backend-API-backed window.webln shim

Bitcoin Connect

A wrapper library that handles WebLN + LNURL + NWC fallbacks:

<script src="https://cdn.jsdelivr.net/npm/@getalby/bitcoin-connect/dist/index.js"></script>
<bc-button label="Connect Wallet"></bc-button>
<script>
window.bitcoinConnect.onConnected(() => {
  window.webln.sendPayment(invoice);
});
</script>

Auto-detects:

  • Existing webln provider.
  • Connect via NWC (Nostr Wallet Connect) URL paste.
  • Connect via LNC (Lightning Node Connect, LND-specific).
  • Connect via Alby OAuth.

Permissions model

Per-domain. User explicitly approves:

  • enable() first time.
  • Each sendPayment call by default (some wallets allow auto-approve rules).

makeInvoice typically silent (no permission needed; it's just generating a receive-side invoice).

Use cases

  • Tipping buttons on blogs.
  • Browser-based donation pages.
  • Lightning paywalls (server-issued invoice → window.webln pays → unlock content).
  • LN-based auth (signMessage + server verification).

Common bugs

  • window.webln exists but enable() not called → all methods reject.
  • Hard-coding amount in sats vs millisats — webln uses sats for makeInvoice's amount, but invoices internally are msat.
  • Not handling user rejection (user closes wallet popup).
  • Detecting webln via feature detection only; some wallets expose WebLN via shim that fails on actual call.

See also

저장한 Skills