Skip to content

feat(bitstamp): add Bitstamp Enterprise connector#679

Draft
flemzord wants to merge 3 commits intomainfrom
feat/connector/bitstamp
Draft

feat(bitstamp): add Bitstamp Enterprise connector#679
flemzord wants to merge 3 commits intomainfrom
feat/connector/bitstamp

Conversation

@flemzord
Copy link
Copy Markdown
Member

Summary

  • Add new Enterprise Edition PSP connector for Bitstamp exchange (ee/plugins/bitstamp/)
  • Capabilities: FETCH_ACCOUNTS, FETCH_BALANCES, FETCH_PAYMENTS (identical to Coinbase Prime)
  • API: Bitstamp REST v2 with HMAC-SHA256 authentication (hex signature, UUID nonce, ms timestamp)
  • Configurable baseUrl for UAT/staging environments (defaults to https://www.bitstamp.net)
  • 38 unit tests (Ginkgo/Gomega) with mocked HTTP client

Key implementation details

  • Auth: HMAC-SHA256 with X-Auth headers, form-urlencoded POST bodies
  • Accounts: One account per currency with non-zero balance (fixed CreatedAt = Bitstamp launch date)
  • Balances: Fetched via POST /api/v2/account_balances/, uses available field
  • Payments: Offset-based pagination on POST /api/v2/user_transactions/, deterministic asset selection for multi-currency trades (largest absolute value)
  • Currencies: Decimal precision loaded dynamically from GET /api/v2/currencies/ with atomic lazy-load safety net
  • Dynamic JSON keys: Custom UnmarshalJSON with positive-match against known currencies map

Files

  • 14 new files in ee/plugins/bitstamp/ (~2000 lines)
  • Modified: ee/plugins/list.go, enterprise_ce.go, v3-connectors-config.yaml, OpenAPI + SDK generated files

Test plan

  • go build ./ee/plugins/bitstamp/... compiles
  • go test ./ee/plugins/bitstamp/... — 38/38 pass
  • just pc passes (tidy, generate, lint, openapi, compile plugins & capabilities)
  • bitstamp registered in EnterpriseOnlyPlugins for CE error messaging
  • V3BitstampConfig schema in OpenAPI spec
  • Manual integration test with real Bitstamp API keys

Add a new Enterprise Edition PSP connector for Bitstamp exchange,
mirroring the Coinbase Prime connector pattern with Bitstamp-specific
adaptations for HMAC-SHA256 auth (hex signature, UUID nonce, ms timestamp),
offset-based pagination, and dynamic JSON key parsing.

Capabilities: FETCH_ACCOUNTS, FETCH_BALANCES, FETCH_PAYMENTS
API: Bitstamp REST v2 with form-urlencoded POST endpoints
Auth: HMAC-SHA256 with X-Auth headers

Key implementation details:
- Deterministic asset selection for multi-currency trades (largest absolute value)
- Positive-match currency key extraction against loaded currencies map
- Offset pagination with len(transactions) increment to avoid skipping records
- Named constants for Bitstamp transaction type codes
- Fixed epoch CreatedAt (Bitstamp launch date) for accounts
- Lazy-load currency precision from /api/v2/currencies/ with mutex safety net
Allow overriding the Bitstamp API base URL via the `baseUrl` config
field. When not set, defaults to https://www.bitstamp.net (production).
This enables testing against UAT or sandbox environments.
- Fix data race in ensureCurrencies: use atomic.Bool for fast path
  instead of unsafe map length check outside mutex
- Fix double otelhttp.NewTransport wrapping: httpwrapper.NewClient
  already adds the OTel layer, remove redundant wrapping in client
- Fix signRequest: use req.URL fields directly instead of re-parsing
  with url.Parse (which swallowed errors)
- Extract normalizeCurrency() and isZeroAmount() shared helpers to
  eliminate 6x duplicated strings.ToUpper(strings.TrimSpace()) and
  fragile hardcoded zero-string comparisons
- Merge resolveAssetAndPrecision + extractAmount into single-pass
  resolveAssetAndAmount, eliminating redundant map iteration
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c495c76c-6e0c-40ae-ba85-261c98f285ff

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/connector/bitstamp
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 50.88106% with 223 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.94%. Comparing base (a1ef879) to head (60987cb).

Files with missing lines Patch % Lines
ee/plugins/bitstamp/client/client.go 0.00% 114 Missing ⚠️
ee/plugins/bitstamp/client/client_generated.go 0.00% 33 Missing ⚠️
ee/plugins/bitstamp/plugin.go 55.55% 27 Missing and 5 partials ⚠️
ee/plugins/bitstamp/payments.go 78.18% 15 Missing and 9 partials ⚠️
ee/plugins/bitstamp/balances.go 76.31% 6 Missing and 3 partials ⚠️
ee/plugins/bitstamp/config.go 79.16% 3 Missing and 2 partials ⚠️
ee/plugins/bitstamp/accounts.go 88.57% 2 Missing and 2 partials ⚠️
ee/plugins/bitstamp/currency.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
- Coverage   63.09%   62.94%   -0.15%     
==========================================
  Files         832      841       +9     
  Lines       37635    38089     +454     
==========================================
+ Hits        23744    23975     +231     
- Misses      12316    12517     +201     
- Partials     1575     1597      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant