forked from nostr-dev-kit/ndk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate NIP-60 quote events and wip refactor of ndk-wallet's service
- Loading branch information
Showing
16 changed files
with
552 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Sweeping NIP-61 nutzaps | ||
When a user receives a nutzap, they should sweep the public tokens into their wallet, the `@nostr-dev-kit/ndk-wallet` package takes care of this for you when | ||
the `NDKWalletService` is running by default. | ||
|
||
```typescript | ||
const walletService = new NDKWalletService(ndk); | ||
walletService.start(); | ||
walletService.on("nutzap", (nutzap: NDKNutzap) => { | ||
console.log("Received a nutzap from " + nutzap.pubkey + " for " + nutzap.amount + " " + nutzap.unit + " on mint " + nutzap.mint); | ||
// -> Received a nutzap from fa98..... for 1 usd on mint https://... | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { NDKEvent } from "@nostr-dev-kit/ndk"; | ||
import createDebug from "debug"; | ||
|
||
const debug = createDebug("ndk-wallet:cashu:decrypt"); | ||
|
||
/** | ||
* Decrypts an NDKEvent using nip44, and if that fails, using nip04. | ||
*/ | ||
export async function decrypt(event: NDKEvent) { | ||
try { | ||
await event.decrypt(undefined, undefined, "nip44"); | ||
return; | ||
} catch (e) { | ||
debug("unable to decerypt with nip44, attempting with nip04", e); | ||
await event.decrypt(undefined, undefined, "nip04"); | ||
debug("✅ decrypted with nip04"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.