Fixed billing fees unreachable error propagation. Added USDT ledger creation. Fixed ledger boundaries operation types

This commit is contained in:
Stephan D
2026-02-26 16:25:52 +01:00
parent 54e5c799e8
commit 336f352858
37 changed files with 838 additions and 302 deletions

View File

@@ -19,15 +19,8 @@ import (
const (
discoveryBootstrapTimeout = 3 * time.Second
discoveryBootstrapSender = "server_bootstrap"
discoveryGatewayRailCrypto = "CRYPTO"
defaultClientDialTimeoutSecs = 5
defaultClientCallTimeoutSecs = 5
paymentQuoteOperation = "payment.quote"
paymentInitiateOperation = "payment.initiate"
ledgerDebitOperation = "ledger.debit"
ledgerCreditOperation = "ledger.credit"
gatewayReadBalanceOperation = "balance.read"
paymentMethodsReadOperation = "payment_methods.read"
)
var (
@@ -123,7 +116,7 @@ func (a *APIImp) resolveChainGatewayAddress(gateways []discovery.GatewaySummary)
endpoint, selected, ok := selectGatewayEndpoint(
gateways,
cfg.DefaultAsset.Chain,
[]string{gatewayReadBalanceOperation},
[]string{discovery.OperationBalanceRead},
)
if !ok {
return
@@ -146,7 +139,7 @@ func (a *APIImp) resolveLedgerAddress(services []discovery.ServiceSummary) {
endpoint, selected, ok := selectServiceEndpoint(
services,
ledgerDiscoveryServiceNames,
[]string{ledgerDebitOperation, ledgerCreditOperation},
discovery.LedgerServiceOperations(),
)
if !ok {
return
@@ -170,7 +163,7 @@ func (a *APIImp) resolvePaymentOrchestratorAddress(services []discovery.ServiceS
endpoint, selected, ok := selectServiceEndpoint(
services,
paymentOrchestratorDiscoveryServiceNames,
[]string{paymentInitiateOperation},
[]string{discovery.OperationPaymentInitiate},
)
if !ok {
return false, discoveryEndpoint{}
@@ -196,7 +189,7 @@ func (a *APIImp) resolvePaymentQuotationAddress(services []discovery.ServiceSumm
endpoint, selected, ok := selectServiceEndpoint(
services,
paymentQuotationDiscoveryServiceNames,
[]string{paymentQuoteOperation},
[]string{discovery.OperationPaymentQuote},
)
if !ok {
cfg := a.config.PaymentQuotation
@@ -229,7 +222,7 @@ func (a *APIImp) resolvePaymentMethodsAddress(services []discovery.ServiceSummar
endpoint, selected, ok := selectServiceEndpoint(
services,
paymentMethodsDiscoveryServiceNames,
[]string{paymentMethodsReadOperation},
[]string{discovery.OperationPaymentMethodsRead},
)
if !ok {
return
@@ -269,7 +262,7 @@ func selectServiceEndpoint(services []discovery.ServiceSummary, serviceNames []s
selections = append(selections, serviceSelection{
service: svc,
endpoint: endpoint,
opMatch: hasAnyOperation(svc.Ops, requiredOps),
opMatch: discovery.HasAnyOperation(svc.Ops, requiredOps),
nameRank: nameRank,
})
}
@@ -302,7 +295,7 @@ func selectGatewayEndpoint(gateways []discovery.GatewaySummary, preferredNetwork
if !gateway.Healthy {
continue
}
if !strings.EqualFold(strings.TrimSpace(gateway.Rail), discoveryGatewayRailCrypto) {
if !strings.EqualFold(strings.TrimSpace(gateway.Rail), discovery.RailCrypto) {
continue
}
if strings.TrimSpace(gateway.InvokeURI) == "" {
@@ -316,7 +309,7 @@ func selectGatewayEndpoint(gateways []discovery.GatewaySummary, preferredNetwork
gateway: gateway,
endpoint: endpoint,
networkMatch: preferredNetwork != "" && strings.EqualFold(strings.TrimSpace(gateway.Network), preferredNetwork),
opMatch: hasAnyOperation(gateway.Ops, requiredOps),
opMatch: discovery.HasAnyOperation(gateway.Ops, requiredOps),
})
}
if len(selections) == 0 {
@@ -412,24 +405,6 @@ func serviceRank(service string, names []string) (int, bool) {
return 0, false
}
func hasAnyOperation(ops []string, required []string) bool {
if len(required) == 0 {
return true
}
for _, op := range ops {
normalized := strings.TrimSpace(op)
if normalized == "" {
continue
}
for _, target := range required {
if strings.EqualFold(normalized, strings.TrimSpace(target)) {
return true
}
}
}
return false
}
func ensureLedgerConfig(cfg *eapi.Config) *eapi.LedgerConfig {
if cfg == nil {
return nil

View File

@@ -27,7 +27,7 @@ import (
const (
documentsServiceName = "BILLING_DOCUMENTS"
documentsOperationGet = "documents.get"
documentsOperationGet = discovery.OperationDocumentsGet
documentsDialTimeout = 5 * time.Second
documentsCallTimeout = 10 * time.Second
)