This service connects Lightning Network payments to the Nostr protocol, enabling zap functionality for Blink Bitcoin. It listens for Lightning invoice payments and broadcasts corresponding zap receipts to Nostr relays.
Blink Nostr is a bridge service that:
- Connects to a Lightning Network node (LND)
- Listens for paid invoices
- Retrieves zap request metadata from Redis
- Creates and signs Nostr zap receipt events (kind 9735)
- Broadcasts these events to specified Nostr relays
- index.js: Entry point that initializes the zapper service
- zapper.js: Main service that monitors LN payments and triggers zap processing
- lnd.js: Lightning Network connection and subscription handling
- redis.js: Redis connection for storing and retrieving invoice metadata
- relay.js: Nostr event creation and relay communication
To run this service, you need:
-
Lightning Network Node (LND)
- Access to an LND instance
- TLS certificate
- Macaroon for authentication
-
Redis
- Redis instance with Sentinel setup
- Redis password
-
Nostr
- Private key for signing Nostr events
-
Node.js Environment
- Node.js 22 or later
- pnpm package manager
# Nostr
NOSTR_PRIVATE_KEY=<your_nostr_private_key_hex>
# LND
LND1_TLS=<base64_encoded_tls_cert>
LND1_MACAROON=<hex_encoded_macaroon>
LND1_DNS=<lnd_host>
# Redis
REDIS_PASSWORD=<redis_password>
REDIS_MASTER_NAME=mymaster
REDIS_0_DNS=<redis_sentinel_0_host>
REDIS_1_DNS=<redis_sentinel_1_host>
REDIS_2_DNS=<redis_sentinel_2_host>
REDIS_0_SENTINEL_PORT=26379
REDIS_1_SENTINEL_PORT=26379
REDIS_2_SENTINEL_PORT=26379
# Clone the repository
git clone https://github.com/blinkbitcoin/blink-nostr.git
cd blink-nostr
# Install dependencies
pnpm install
# Build the project
pnpm build
node src/index.js
This project uses:
- ESLint for code quality
- Prettier for code formatting
- Nix for development environment management
# Set up development environment with Nix
direnv allow # If using direnv with "use flake" in .envrc
# Check code quality
pnpm code:check
# Fix formatting issues
pnpm prettier:fix
- When a Lightning invoice is paid, the service receives a notification
- It looks up the associated zap request metadata in Redis
- It creates a Nostr zap receipt event (kind 9735)
- It signs the event with the configured Nostr private key
- It broadcasts the event to the relays specified in the zap request
This enables Nostr clients to display zap receipts for payments made through the Blink Bitcoin Lightning Network node.
- grab a nostr account with a zappable note somewhere
- configure the lightning address in that account (needs to be an address to a staging blink wallet which used signet )
- grab the note from that account and zap it, you'll get a invoice
- Pay the invoice with another wallet (NOT blink)
- Check whether the zaps are shown in your nostr client