upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/nostr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nostr.cpp')
-rw-r--r--src/nostr.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/nostr.cpp b/src/nostr.cpp
index ec02c2e..482a835 100644
--- a/src/nostr.cpp
+++ b/src/nostr.cpp
@@ -342,6 +342,36 @@ std::string BtfLocalAddress()
342 return g_nostrKey.BtfAddress(); 342 return g_nostrKey.BtfAddress();
343} 343}
344 344
345// This node's own descriptor, signed and self-certifying -- the same blob
346// PublishDescriptor puts on Nostr, but handed straight to a peer instead.
347//
348// Reads strBtfActiveRelay directly rather than going through BtfActiveRelay():
349// only a rendezvous we actually registered at is worth announcing. Handing out
350// a meeting node we are not reachable at would make every peer that receives
351// it burn a dial, and over peer exchange that mistake travels further than it
352// does over Nostr.
353std::string BtfLocalDescriptor()
354{
355 if (!EnsureNostrKey())
356 return "";
357 string meeting;
358 CRITICAL_BLOCK(cs_activeRelay)
359 meeting = strBtfActiveRelay;
360 if (meeting.empty())
361 return "";
362 return btf::SignDescriptor(g_nostrKey.ctx, g_nostrKey.seckey,
363 g_nostrKey.EncPubHex(), meeting, (uint64_t)GetTime());
364}
365
366// The shared secp256k1 context, so net.cpp can verify descriptors that arrive
367// from peers. NULL if the identity could not be loaded.
368void* BtfSecpContext()
369{
370 if (!EnsureNostrKey())
371 return NULL;
372 return (void*)g_nostrKey.ctx;
373}
374
345int GetDiscoveredPeerCount() 375int GetDiscoveredPeerCount()
346{ 376{
347 int n = 0; 377 int n = 0;