cdk-npubcash
Rust client SDK for the NpubCash v2 API.
Features
- HTTP Client: Fetch quotes with automatic pagination
- NIP-98 Authentication: Sign requests using Nostr keys
- JWT Token Caching: Automatic token refresh and caching
- Quote Polling: Subscribe to quote updates via polling
- Settings Management: Configure mint URL
Usage
use ;
use Keys;
async
Examples
The SDK includes several examples to help you get started:
basic_usage.rs- Demonstrates fetching quotes and basic client usagemanage_settings.rs- Illustrates settings management (mint URL)create_and_wait_payment.rs- Demonstrates creating a npub.cash address and monitoring for payments
Note: Quotes are always locked by default on the NPubCash server for security. The ability to toggle quote locking has been removed from the SDK.
Run an example with:
Set environment variables to customize behavior:
# Optional: use specific Nostr keys
Authentication
The SDK uses NIP-98 (Nostr HTTP Auth) to authenticate with the NpubCash service:
- Creates a NIP-98 signed event with the request URL and method
- Exchanges the NIP-98 token for a JWT token
- Caches the JWT token for subsequent requests
- Automatically refreshes the token when it expires
License
MIT