Skip to main content
Glama

get_transactions

Retrieve transaction history from a Bitcoin Lightning wallet, including both incoming and outgoing payments, with pagination support for managing large datasets.

Instructions

Get the agent transaction history. Returns both incoming and outgoing payments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax transactions to return
offsetNoNumber to skip for pagination

Implementation Reference

  • The tool request handler for 'get_transactions' in the MCP server implementation. It parses the request arguments using 'GetTransactionsSchema', calls the 'LightningFaucetClient' method, and formats the response.
    case 'get_transactions': {
      const parsed = GetTransactionsSchema.parse(args);
      const result = await session.requireClient().getTransactions(parsed.limit, parsed.offset);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              transactions: result.transactions,
              total: result.total,
              has_more: result.has_more,
            }, null, 2),
          },
        ],
      };
    }
  • The Zod schema definition for input validation of the 'get_transactions' tool.
    const GetTransactionsSchema = z.object({
      limit: z.number().min(1).max(200).default(50).describe('Max transactions to return'),
      offset: z.number().min(0).default(0).describe('Number to skip for pagination'),
    });
  • The actual implementation of the 'getTransactions' method in the 'LightningFaucetClient' class, which communicates with the Lightning Faucet API.
    async getTransactions(
      limit: number = 50,
      offset: number = 0
    ): Promise<{
      transactions: Array<{
        type: 'incoming' | 'outgoing';
        amount_sats: number;
        fee_sats?: number;
        memo?: string;
        payment_hash?: string;
        timestamp?: string;
        balance_after?: number;
      }>;
      total: number;
      has_more: boolean;
      rawResponse: GetTransactionsResponse;
    }> {
      const result = await this.request<GetTransactionsResponse>('get_transactions', {
        limit,
        offset,
      });
    
      const transactions = (result.transactions || []).map(tx => ({
        type: (tx.type === 'deposit' || tx.type === 'incoming' || tx.amount_sats > 0
          ? 'incoming' : 'outgoing') as 'incoming' | 'outgoing',
        amount_sats: Math.abs(tx.amount_sats),
        fee_sats: tx.fee_sats,
        memo: tx.memo || tx.description,
        payment_hash: tx.payment_hash,
        timestamp: tx.timestamp || tx.created_at || tx.settled_at,
        balance_after: tx.balance_after,
      }));
    
      return {
        transactions,
        total: result.total || transactions.length,
        has_more: result.has_more || false,
        rawResponse: result,
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lightningfaucet/lightning-wallet-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server