Why Nostr? What is Njump?
2024-08-02 16:03:21

NDK 2.10 + ndk-wallet

Happy to announce a new major version of NDK. A lot of work has been going on behind the scenes to improve NDK in a lot of fronts.

Optimistic Signature verification

For most nostr apps, event signature verification is, by far, the most computationally-expensive part.

If you've ever felt your phone getting a bit hot while using a nostr app, this is probably why.

NDK introduces signature verification sampling. Each relay gets a lower and upper threshold of what ratio of events need to be verified. An unknown relay might start at getting 100% of it's events verified and, over time, lower the ratio to 50%. Whereas a relay the user has in their NIP-65 list might start at 50% and lower to 1%.

When the same event is fetched from multiple relays, only the first time an event is seen (might) have it's signature verified. If the signature is verified, subsequent relays that send the same event ID and signature, have their ratio updated, further reducing the number of signatures we need to check.

Relays should never send an invalid signature, so it only takes catching an evil relay lying about a signature once, to expel it from the pool and, perhaps, have the user add that relay to their relay blacklist event.

In order to activate this feature, developers MUST explicitly handle receiving an invalid signature, as they should probably warn the user that some trickery is happening.

👉 Tutorial

Nostr Cache Adapter

A new cache adapter, which leverages, well, nostr.

ndk-cache-nostr is a cache adapter that connects to a single local relay. This could be your a relay running in your user's computer/phone, like the nostr-tray-relay, Citrine, or it can even be a local relay you run in your server to assist in creating server-side-rendering.

If you've been envious of njump previews when sharing a link, now you can implement the same in your app by leveraging this adapter in your SSR calls.

👉 Docs

Refactored Zapping interface

This is the one breaking change; the code for sending zaps was tightly coupled to the assumption that LN was the interface. This new interface abstracts away the funding mechanism (NWC, WebLN, built-in-wallet) and the delivery mechanism (LN, ecash, Rai stones)

Major subscription Lifecycle refactor

The core of how NDK works was completely refactored from the ground-up, removing a lot of dependencies from nostr-tools, and bringing a lot of clarity to how NDK orchestrates subscriptions at the relay level.

👉 NDK Internal's documentation

Tutorials and other stuff

A few months ago I started a new effort to write more high-level documentation, instead of focusing on interface specs of NDK. https://nostr-dev-kit.github.io/ndk is the ongoing result.

ndk-wallet

A new NDK extension package, provides access to nostr-native NIP-60 wallets.

NIP-60 is a new NIP that proposes a nostr-native wallet that follows a user around any nostr application. Instead of having to manage a bunch of different NWC tokens, implement LN on their own, NIP-60 leverages multiple ecash mints, making it completely frictionless to onboard into Nostr with the capability to send and receive (via NIP-61 or a proxy like npub.cash) zaps.

ndk-wallet is the wallet that Nutsack.me is built on, providing: - wallet creation/discovery - token verification - nutzap redemption - UTXO management - balance tracking

With this package you'll be able to give your users a non-kyc wallet from which they can send both NIP-61 nutzaps and the usual NIP-57 lightning zaps.

Author Public Key
npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft