mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 10:16:15 +00:00
feat: add configurable payment amount precision
- add system.amount_precision setting with 2-6 validation
This commit is contained in:
@@ -119,6 +119,25 @@ func GetSettingBool(key string, fallback bool) bool {
|
||||
return b
|
||||
}
|
||||
|
||||
const (
|
||||
DefaultAmountPrecision = 2
|
||||
MinAmountPrecision = 2
|
||||
MaxAmountPrecision = 6
|
||||
)
|
||||
|
||||
// NormalizeAmountPrecision clamps external precision values to the supported
|
||||
// range used by order creation and transaction matching.
|
||||
func NormalizeAmountPrecision(precision int) int {
|
||||
if precision < MinAmountPrecision || precision > MaxAmountPrecision {
|
||||
return DefaultAmountPrecision
|
||||
}
|
||||
return precision
|
||||
}
|
||||
|
||||
func GetAmountPrecision() int {
|
||||
return NormalizeAmountPrecision(GetSettingInt(mdb.SettingKeyAmountPrecision, DefaultAmountPrecision))
|
||||
}
|
||||
|
||||
// SetSetting upserts a setting row and refreshes the cache entry.
|
||||
func SetSetting(group, key, value, valueType string) error {
|
||||
if valueType == "" {
|
||||
|
||||
Reference in New Issue
Block a user