@@ -14,8 +14,6 @@ import (
1414 "strings"
1515 "text/template"
1616 "time"
17-
18- "github.com/trezor/blockbook/common"
1917)
2018
2119// Backend contains backend specific fields
@@ -303,11 +301,11 @@ func LoadConfig(configsDir, coin string) (*Config, error) {
303301 }
304302
305303 // Resolve RPC env by exact alias first and fall back to *_archive for shared test/deploy wiring.
306- if rpcURL , ok := common . LookupEnvWithArchiveFallback ("BB_RPC_URL_HTTP_" , config .Coin .Alias ); ok {
304+ if rpcURL , ok := lookupEnvWithArchiveFallback ("BB_RPC_URL_HTTP_" , config .Coin .Alias ); ok {
307305 // Prefer explicit env override so package generation/tests can target hosted RPC endpoints without editing JSON.
308306 config .IPC .RPCURLTemplate = rpcURL
309307 }
310- if rpcURLWS , ok := common . LookupEnvWithArchiveFallback ("BB_RPC_URL_WS_" , config .Coin .Alias ); ok {
308+ if rpcURLWS , ok := lookupEnvWithArchiveFallback ("BB_RPC_URL_WS_" , config .Coin .Alias ); ok {
311309 config .IPC .RPCURLWSTemplate = rpcURLWS
312310 }
313311
@@ -350,6 +348,29 @@ func isEmpty(config *Config, target string) bool {
350348 }
351349}
352350
351+ const archiveSuffix = "_archive"
352+
353+ func lookupEnvWithArchiveFallback (prefix , alias string ) (string , bool ) {
354+ if alias == "" {
355+ return "" , false
356+ }
357+
358+ for _ , candidate := range aliasCandidates (alias ) {
359+ if value , ok := os .LookupEnv (prefix + candidate ); ok && value != "" {
360+ return value , true
361+ }
362+ }
363+ return "" , false
364+ }
365+
366+ func aliasCandidates (alias string ) []string {
367+ candidates := []string {alias }
368+ if ! strings .HasSuffix (alias , archiveSuffix ) {
369+ candidates = append (candidates , alias + archiveSuffix )
370+ }
371+ return candidates
372+ }
373+
353374// GeneratePackageDefinitions generate the package definitions from the config
354375func GeneratePackageDefinitions (config * Config , templateDir , outputDir string ) error {
355376 templ := config .ParseTemplate ()
0 commit comments