Skip to content

feat: add Strike lightning backend#8

Open
gudnuf wants to merge 4 commits intodevfrom
strike-backend
Open

feat: add Strike lightning backend#8
gudnuf wants to merge 4 commits intodevfrom
strike-backend

Conversation

@gudnuf
Copy link

@gudnuf gudnuf commented Jan 23, 2026

Summary

  • Add new cdk-strike crate implementing Strike API client for Lightning payments
  • Integrate Strike backend into cdk-mintd with configuration, environment variables, and setup
  • Support webhook-based payment notifications with polling fallback
  • Vendor Strike API client with comprehensive error handling and types

Changes

  • New crate: cdk-strike (~3,100 lines)

    • Strike API client with full endpoint coverage (invoices, payments, currency exchange)
    • Webhook handling with HMAC-SHA256 signature verification
    • MintPayment trait implementation for CDK integration
  • cdk-mintd integration:

    • New strike feature flag (enabled by default)
    • Configuration via [strike] section or CDK_MINTD_STRIKE_* env vars
    • Webhook router integration for real-time payment notifications

Configuration

[strike]
api_key = "your_strike_api_key"
supported_units = ["sat"]
# Optional: Override webhook URL for NAT/proxy scenarios
webhook_url = "https://your-public-domain.com"

Test plan

  • Unit tests pass (cargo test -p cdk-strike)
  • Build succeeds with Strike feature
  • Manual testing with Strike API sandbox

🤖 Generated with Claude Code

gudnuf and others added 4 commits January 22, 2026 16:15
Remove all fiat currency (USD/EUR) support from the Strike backend,
keeping only BTC/sats/msats. This removes ~400 lines of currency
exchange complexity including cross-currency payment handling.

Changes:
- Simplify conversion functions to only handle Sat/Msat ↔ BTC
- Remove exchange logic (execute_currency_exchange_by_id,
  process_internal_settlement, check_exchange_payment)
- Remove cross-currency branch from handle_internal_payment_quote
- Remove internal invoice currency check from make_payment
- Update to new cdk-common API (DynKVStore, Amount<CurrencyUnit>)
- Update example config to show only sat as supported unit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add optional webhook_url configuration to override auto-constructed
webhook URLs when the mint runs behind NAT or has different
internal/external URLs.

Configuration via config.toml:
  [strike]
  webhook_url = "https://public.example.com"

Or environment variable:
  CDK_MINTD_STRIKE_WEBHOOK_URL="https://public.example.com"

Also fixes pre-existing bugs:
- Missing comma in cfg attribute for strike feature
- Incorrect return types for configure_mint_builder and
  configure_lightning_backend functions
- Wrong type DynMintKVStore -> DynKVStore in setup.rs
- Replace strike-rs git dependency with vendored api module
- Add serde rename for InvoiceState to handle Strike's uppercase values (UNPAID, PAID, etc.)
- Handle InvoiceState::Cancelled in all match arms
- Add amount field to PayInvoiceQuoteRequest

let invoice_list = self
.strike_api
.get_invoices(Some(query_params))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude look into the strike documentation and see if there's a way that we can do this more efficiently so that we don't have to list all invoices every time

)
.filter_map(|event| async move { event });

let combined_stream =
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude why do we have a combined stream? This seems confusing. I expect polling of rdev and webhooks for prod

unit: &CurrencyUnit,
pending_invoices: &Arc<Mutex<HashMap<String, u64>>>,
) -> Option<Event> {
match strike_api.get_incoming_invoice(invoice_id).await {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude can you look into the strike documentation and make sure that this is necessary? Do we not get the invoice data we need from the webhook. I'd rather not refetch the invoice if possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant