Repository navigation
Conversation
Add an opt-in background service that fetches USD/CNY rates from configurable public APIs and updates the balance recharge multiplier (optionally the subscription rate). Includes admin API/UI, manual sync, leader-locked scheduling, last-run status, SSRF-safe client and tests. No migration; disabled by default.
Address the errcheck finding from CI. The request URL remains admin-configured and is validated at dial time by the SSRF-safe client.
Disable save/sync until the admin configuration has loaded and add a reload action, so a failed load cannot overwrite the stored settings with defaults. Add a focused component test.
|
The |
The failing job hit an unrelated flaky assertion in TestFilterThinkingBlocksSignedHistorySkipsDecode (allocs 16 vs < 16); the backend is unchanged from 716611d, which passed the same suite.
|
CI update on 5ede39d: the
|
Summary
Add an opt-in periodic FX sync for the balance recharge multiplier:
open.er-api.com/frankfurter.appcompatible).BALANCE_RECHARGE_MULTIPLIERvia the existing 6-decimal formatter; optionally also update the subscription USD→CNY rate and apply a markup.Motivation
Operators collecting CNY need a live FX rate. #8642 (merged) raised the recharge multiplier precision to 6 decimals; this PR automates the refresh instead of requiring manual updates or an external CronJob.
This automates the existing recharge-multiplier flow. Full settlement/recharge currency separation (#5219) is out of scope.
Behavior
rates/conversion_ratesandbase/base_code, with USD/CNY cross-rate calculation and a 1–20 CNY/USD sanity check.1 / (market rate × (1 + markup/100)), rounded to 6 decimals. Credited balance still rounds to currency precision in the existing payment flow.409while another sync holds the lock.API / UI
GET/PUT /api/v1/admin/settings/payment-fxPOST /api/v1/admin/settings/payment-fx/syncTests
go build ./...,go vet ..., targetedTestPaymentFXSync*tests (rate formats/fallbacks, invalid rates, 6-decimal update, markup, optional subscription rate, failure status, due logic, validation, lock contention).vue-tsc, ESLint, i18n completeness, and production build.Related