getAlby / nostr-wallet-connect

Nostr Wallet Connect (NIP-47) application to allow apps to connect to your node
https://nwc.getalby.com
Apache License 2.0
101 stars 29 forks source link
bitcoin lightning lightning-network nostr value4value zaps

Nostr Wallet Connect

❗ We're working on a brand new version of NWC here.

This application allows you to control your Lightning node or wallet over Nostr. Connect applications like Damus or Amethyst to your node.

Specification: NIP-47

Supported Backends

Installation

Requirements

The application has no runtime dependencies. (simple Go executable).

As data storage SQLite or PostgreSQL (recommended) can be used.

$ cp .env.example .env
# edit the config for your needs
vim .env

To get a new random Nostr key use openssl rand -hex 32 or similar.

Development

go run . or gow -e=go,mod,html,css run . using gow

To build the CSS run:

  1. npm install
  2. npm run css

Testing

go test

Configuration parameters

Application deeplink options

/apps/new deeplink options

Clients can use a deeplink to allow the user to add a new connection. Depending on the client this URL has different query options:

NWC created secret

The default option is that the NWC app creates a secret and the user uses the nostr wallet connect URL string to enable the client application.

Query parameter options

Example:

/apps/new?name=myapp

Client created secret

If the client creates the secret the client only needs to share the public key of that secret for authorization. The user authorized that pubkey and no sensitivate data needs to be shared.

Query parameter options for /new

Example:

/apps/new?name=myapp&pubkey=47c5a21...&return_to=https://example.com

Web-flow: client created secret

Web clients can open a new prompt popup to load the authorization page. Once the user has authorized the app connection a nwc:success message is sent to the opening page (using postMessage) to indicate that the connection is authorized. See the initNWC() function in the alby-js-sdk

Example:

import { webln } from "alby-js-sdk";
const nwc = new webln.NWC();
// initNWC opens a prompt with /apps/new?c=myapp&pubkey=xxxx
// the promise resolves once the user has authorized the connection (when the `nwc:success` message is received) and the popup is closed automatically
// the promise rejects if the user cancels by closing the prompt popup
await nwc.initNWC({name: 'myapp'});

❓️ Help

⚡️ Donations

Want to support the work on Alby?

Support the Alby team ⚡️hello@getalby.com You can also contribute to our bounty program: ⚡️bounties@getalby.com

NIP-47 Supported Methods

✅ NIP-47 info event

expiration tag in requests

LND

get_info

get_balance

pay_invoice

pay_keysend

make_invoice

lookup_invoice

list_transactions

multi_pay_invoice

multi_pay_keysend (TBC)

Alby OAuth API

get_info

get_balance

pay_invoice

pay_keysend

make_invoice

lookup_invoice

list_transactions

multi_pay_invoice

multi_pay_keysend (TBC)