get_payment_history
Retrieve recent L402 Lightning Network payment records from the current session to track autonomous Bitcoin transactions and API access purchases.
Instructions
List recent L402 payments made during this session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of payments to return | |
| since | No | ISO timestamp to filter payments from |
Implementation Reference
- The handler function 'get_payment_history' which retrieves and returns the payment history as a JSON string.
async def get_payment_history( limit: int = 10, since: str | None = None, budget_manager: "BudgetManager | None" = None, ) -> str: """ List recent L402 payments made during this session. Args: limit: Maximum number of payments to return since: ISO timestamp to filter payments from budget_manager: Budget manager instance Returns: JSON with list of payments """ if not budget_manager: return json.dumps( {"success": False, "error": "Budget manager not initialized"} ) try: # Parse since timestamp if provided since_dt = None if since: try: since_dt = datetime.fromisoformat(since.replace("Z", "+00:00")) except ValueError: return json.dumps( { "success": False, "error": f"Invalid timestamp format: {since}. Use ISO format.", } ) # Get payment history payments = budget_manager.get_history(limit=limit, since=since_dt) # Get budget status status = budget_manager.get_status() result = { "success": True, "payments": [p.to_dict() for p in payments], "count": len(payments), "total_payments": status["payment_count"], "session_summary": { "total_spent": status["spent"], "remaining_budget": status["remaining"], "per_request_limit": status["limits"]["per_request"], "per_session_limit": status["limits"]["per_session"], }, } if payments: result["message"] = ( f"Showing {len(payments)} of {status['payment_count']} payments. " f"Total spent: {status['spent']} sats." ) else: result["message"] = "No payments recorded in this session." return json.dumps(result, indent=2) - The MCP tool definition and input schema registration for 'get_payment_history'.
Tool( name="get_payment_history", description="List recent L402 payments made during this session.", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Maximum number of payments to return", "default": 10, }, "since": { "type": "string", "description": "ISO timestamp to filter payments from", }, }, },