Skip to content

feat: Lightning zap — send sats to a DID#155

Merged
macterra merged 5 commits intomainfrom
154-lightning-zap
Mar 4, 2026
Merged

feat: Lightning zap — send sats to a DID#155
macterra merged 5 commits intomainfrom
154-lightning-zap

Conversation

@macterra
Copy link
Collaborator

@macterra macterra commented Mar 4, 2026

Summary

  • Add publish-lightning / unpublish-lightning commands to register a DID's invoiceKey on Drawbridge and publish a Lightning service endpoint in the DID document
  • Add lightning-zap <did> <amount> command to send sats to any DID with a published Lightning endpoint
  • Add public GET /invoice/:did?amount=X endpoint on Drawbridge for unauthenticated invoice generation
  • Add W3C DID Core service array to DidCidDocument type

Test plan

  • publish-lightning registers invoiceKey on Drawbridge and adds service endpoint to DID doc
  • resolve-did shows the Lightning service endpoint
  • lightning-zap scully 25 successfully creates invoice and pays it
  • All existing tests pass (34 Lightning + 238 client)

Closes #154

🤖 Generated with Claude Code

macterra and others added 3 commits March 4, 2026 09:46
Adds publish-lightning, unpublish-lightning, and lightning-zap commands.
Recipients publish a Lightning service endpoint in their DID document;
senders resolve the DID, request an invoice from the endpoint, and pay it.

Closes #154

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds tests for addPollVoter, removePollVoter, listPollVoters, and
options variants for getVault, listVaultItems, getVaultItem,
getDmailMessage, and listDmailAttachments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end support for “Lightning zaps” to a DID by publishing a Lightning service endpoint in the DID document, enabling unauthenticated invoice generation on Drawbridge, and adding Keymaster APIs/CLI commands to publish/unpublish and pay invoices.

Changes:

  • Add publish-lightning, unpublish-lightning, and lightning-zap across Keymaster library, Keymaster server API, Keymaster client, and CLI.
  • Add Drawbridge support for storing published invoice keys and serving a public GET /invoice/:did?amount=... invoice endpoint.
  • Extend DID document typing to include a W3C DID Core service array and add/extend tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/keymaster/lightning.test.ts Adds unit tests for publish/unpublish and zap flows.
tests/keymaster/client.test.ts Adds client tests for new lightning endpoints (plus additional coverage for existing non-lightning methods).
services/keymaster/server/src/keymaster-api.ts Exposes /lightning/publish, /lightning/unpublish, and /lightning/zap endpoints.
services/drawbridge/server/src/types.ts Extends Drawbridge store interface for published Lightning mappings.
services/drawbridge/server/src/store.ts Implements published Lightning persistence in Redis.
services/drawbridge/server/src/drawbridge-api.ts Adds publish/unpublish routes and public invoice generation endpoint.
services/drawbridge/server/src/config.ts Introduces publicHost config knob (currently unused).
sample.env Documents ARCHON_DRAWBRIDGE_PUBLIC_HOST.
packages/keymaster/src/types.ts Extends public Keymaster interface with publish/unpublish/zap methods.
packages/keymaster/src/keymaster.ts Implements publish/unpublish (DID service mutation) and zap (resolve → fetch invoice → pay).
packages/keymaster/src/keymaster-client.ts Adds client wrappers for publish/unpublish/zap API calls.
packages/keymaster/src/cli.ts Adds CLI commands for publish/unpublish and lightning-zap.
packages/gatekeeper/src/types.ts Adds DrawbridgeInterface methods + DidCidDocument.service typing.
packages/gatekeeper/src/drawbridge-client.ts Adds Drawbridge client calls for publish/unpublish.
docker-compose.drawbridge.yml Wires ARCHON_DRAWBRIDGE_PUBLIC_HOST into Drawbridge container env.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Drawbridge now auto-discovers its .onion address via a shared Docker
volume and returns it when publishing Lightning service endpoints.
Zap requests route through Tor SOCKS proxy for .onion endpoints.
Renamed lightningZap to zapLightning and added alias support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 20 changed files in this pull request and generated 7 comments.

Files not reviewed (2)
  • services/drawbridge/server/package-lock.json: Language not supported
  • services/keymaster/server/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add optional memo to zapLightning across all layers
- Safe req.body?.id on publish/unpublish API routes
- Thread payer identity (id) through zap API route and client
- Validate amount as positive integer on Drawbridge zap endpoint
- Add SSRF protection: enforce https for non-.onion, block private IPs
- Use dynamic port in entrypoint Tor hostname fallback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lightning Zap: Send sats to a DID via service endpoint

2 participants