feat: Add zap command for sending Bitcoin Lightning tips

- Implemented the `zap` command in the CLI to allow users to send sats to a user, event, or snippet using a NIP-60 wallet.
- Created a new `zap.ts` file to handle the command logic and integrated it into the MCP server.
- Added wallet balance command to check the balance of a user's wallet.
- Enhanced the MCP server to register the new zap command and wallet balance command.
- Introduced caching for wallets to optimize performance and reduce redundant network requests.
- Updated database schema to include snippets table for storing code snippets.
- Improved logging functionality for better debugging and tracking of operations.
- Added functionality to save snippets to the database upon retrieval.
- Updated project overview documentation to reflect new features and structure.
- Refactored existing commands and logic for better modularity and maintainability.
This commit is contained in:
pablof7z
2025-04-08 18:10:16 +01:00
parent f74736191a
commit 10fbca0824
19 changed files with 723 additions and 35 deletions

View File

@@ -0,0 +1,26 @@
import type { Database } from "bun:sqlite";
export async function up(db: Database): Promise<void> {
db.run(`
CREATE TABLE IF NOT EXISTS snippets (
id TEXT PRIMARY KEY NOT NULL, -- Nostr event ID
title TEXT NOT NULL,
description TEXT NOT NULL,
code TEXT NOT NULL,
language TEXT NOT NULL,
pubkey TEXT NOT NULL, -- Author's pubkey
createdAt INTEGER NOT NULL, -- Unix timestamp
tags TEXT NOT NULL -- JSON string array of tags
)
`);
// Optional: Add indexes for frequently queried columns
db.run('CREATE INDEX IF NOT EXISTS idx_snippets_pubkey ON snippets (pubkey)');
db.run('CREATE INDEX IF NOT EXISTS idx_snippets_language ON snippets (language)');
db.run('CREATE INDEX IF NOT EXISTS idx_snippets_createdAt ON snippets (createdAt)');
}
export async function down(db: Database): Promise<void> {
db.run("DROP TABLE IF EXISTS snippets");
}