From 77d8848a01a87bfe02a41508f206e8c40dc4bc55 Mon Sep 17 00:00:00 2001 From: Pablo Fernandez
Date: Tue, 2 Jan 2024 12:21:56 +0000
Subject: [PATCH] improvements around nip89 announcement
---
README.md | 24 ++++++++++++++
src/commands/start.ts | 77 ++++++++++++++++++++++++++++++++++++++++++-
src/config/index.ts | 5 +++
3 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 28b5495..efa3de3 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,18 @@ To enable this you'll need to configure a few things on your `nsecbunker.json` c
"your-domain-here": {
"nip05": "/your-nip05-nostr.json-file", // The location where NIP-05 entries to your domain are stored
+ "nip89": {
+ "profile": { // a kind:0-like profile
+ "name": "my cool nsecbunker instance", // The name of your nsecBunker instance
+ "about": "...",
+ },
+ "operator": "npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft", // (optional) npub of the operator of this nsecbunker
+ "relays": [ // list of relays where to publush the nip89 announcement
+ "https://relay.damus.io",
+ "https://pyramid.fiatjaf.com"
+ ]
+ }
+
// Wallet configuration (optional)
"wallet": {
"lnbits": {
@@ -142,6 +154,18 @@ For this to work you'll need to run, in addition to `nsecbunkerd`, an lnbits ins
- [ ] TODO: Add NWC support
+When booting up, the nsecbunkerd will publish a NIP-89 announcement (`kind:31990`), which is the way clients find out about your nsecbunker.
+
+When a bunker provides a wallet and zapping service (`wallet` and `nostdressUrl` are configured), it will add tags:
+```json
+{
+ "tags": [
+ [ "f", "wallet" ],
+ [ "f", "zaps" ]
+ ]
+}
+```
+
# Authors
* [pablof7z](nostr:npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft)
diff --git a/src/commands/start.ts b/src/commands/start.ts
index 7e6619f..8b0e75d 100644
--- a/src/commands/start.ts
+++ b/src/commands/start.ts
@@ -1,8 +1,10 @@
import readline from 'readline';
-import { getCurrentConfig, saveCurrentConfig } from '../config/index.js';
+import { DomainConfig, IConfig, getCurrentConfig, saveCurrentConfig } from '../config/index.js';
import { decryptNsec } from '../config/keys.js';
import { fork } from 'child_process';
import { resolve } from 'path';
+import NDK, { NDKAppHandlerEvent, NDKKind, NDKPrivateKeySigner, NDKUser, NostrEvent } from '@nostr-dev-kit/ndk';
+import { debug } from 'console';
interface IOpts {
keys: string[];
@@ -11,6 +13,77 @@ interface IOpts {
adminNpubs: string[];
}
+async function nip89announcement(configData: IConfig) {
+ const domains = configData.domains as Record