{"id":31786164,"url":"https://github.com/bitkarrot/khatru-payments","last_synced_at":"2025-10-10T12:48:33.607Z","repository":{"id":312142122,"uuid":"1045256487","full_name":"bitkarrot/khatru-payments","owner":"bitkarrot","description":"lighting payments module for khatru based relays","archived":false,"fork":false,"pushed_at":"2025-08-28T21:17:18.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T01:25:59.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitkarrot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-26T22:17:45.000Z","updated_at":"2025-08-28T21:17:21.000Z","dependencies_parsed_at":"2025-08-29T01:26:03.777Z","dependency_job_id":"2793d216-b016-43a9-a1f2-061d0073c5a3","html_url":"https://github.com/bitkarrot/khatru-payments","commit_stats":null,"previous_names":["bitkarrot/khatru-payments"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bitkarrot/khatru-payments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitkarrot%2Fkhatru-payments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitkarrot%2Fkhatru-payments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitkarrot%2Fkhatru-payments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitkarrot%2Fkhatru-payments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitkarrot","download_url":"https://codeload.github.com/bitkarrot/khatru-payments/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitkarrot%2Fkhatru-payments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003889,"owners_count":26083641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-10T12:48:29.743Z","updated_at":"2025-10-10T12:48:33.602Z","avatar_url":"https://github.com/bitkarrot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Khatru Payments\n\nA Lightning payment library for Nostr relays built with the khatru framework. This library provides a pluggable payment system that allows relay operators to require Lightning payments for access from users not in their Web of Trust (WoT).\n\n## Features\n\n- **Multiple Payment Providers**: Support for ZBD and phoenixd backends\n- **Real Payment Verification**: Actual API calls to verify payment status with providers\n- **Smart Payment Tracking**: Payment hash to pubkey mapping for accurate verification\n- **Flexible Access Control**: Configurable payment amounts and access durations\n- **Persistent Storage**: JSON-based storage for paid access and payment tracking\n- **Webhook Support**: Automatic payment verification via webhooks\n- **Manual Verification**: REST endpoints for manual payment verification\n- **Automatic Cleanup**: Expired access cleanup with configurable intervals\n\n## Supported Providers\n\n- **ZBD**: Integration with ZBD's Lightning API\n- **phoenixd**: Integration with phoenixd Lightning node\n- TODO: Add CLN\n- **Extensible**: Easy to add new providers (LNBits, Strike, Blink.sv, etc.) Pull requests are welcome.\n\n## Installation\n\n```bash\ngo get github.com/bitkarrot/khatru-payments\n```\n\n## Quick Start\n\n```go\nimport (\n    \"context\"\n    \"log\"\n    \"net/http\"\n    \n    \"github.com/bitkarrot/khatru-payments\"\n    \"github.com/fiatjaf/khatru\"\n    \"github.com/nbd-wtf/go-nostr\"\n)\n\nfunc main() {\n    // Initialize payment system from environment variables\n    paymentSystem, err := payments.NewFromEnv()\n    if err != nil {\n        log.Fatal(\"Failed to initialize payment system:\", err)\n    }\n\n    // Create relay\n    relay := khatru.NewRelay()\n    \n    // Add payment-based rejection for non-WoT users\n    relay.RejectEvent = append(relay.RejectEvent, func(ctx context.Context, event *nostr.Event) (bool, string) {\n        // Check your Web of Trust logic first\n        if isInWebOfTrust(event.PubKey) {\n            return false, \"\" // Allow WoT users\n        }\n        \n        // For non-WoT users, check payment or create invoice\n        return paymentSystem.RejectEventHandler(ctx, event)\n    })\n\n    // Register payment endpoints\n    mux := relay.Router()\n    paymentSystem.RegisterHandlers(mux)\n    \n    log.Println(\"Relay with payments running on :3334\")\n    http.ListenAndServe(\":3334\", relay)\n}\n\nfunc isInWebOfTrust(pubkey string) bool {\n    // Your WoT logic here\n    return false\n}\n```\n\n## Configuration\n\nSet environment variables or use the Config struct:\n\n```bash\n# Payment Provider\nPAYMENT_PROVIDER=zbd  # or \"phoenixd\"\n\n# ZBD Configuration\nZBD_API_KEY=your-zbd-api-key\nLIGHTNING_ADDRESS=fund@honey.hivetalk.org\n\n# phoenixd Configuration (alternative)\nPHOENIXD_URL=http://localhost:9740\nPHOENIXD_PASSWORD=your-phoenixd-password\n\n# Payment Settings\nPAYMENT_AMOUNT_MSAT=21000  # 21 sats\nACCESS_DURATION=1month     # 1week, 1month, 1year, forever\n\n# Storage\nPAID_ACCESS_FILE=./data/paid_access.json\nCHARGE_MAPPING_FILE=./data/charge_mappings.json\n\n# Optional\nPAYMENT_REJECT_MESSAGE=\"You are not part of the WoT, payment required to join relay\"\n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitkarrot%2Fkhatru-payments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitkarrot%2Fkhatru-payments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitkarrot%2Fkhatru-payments/lists"}