Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions client/asset/eth/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This code is available on the terms of the project LICENSE.md file,
// also available online at https://blueoakcouncil.org/license/1.0.0.

package eth

import (
"fmt"

"decred.org/dcrdex/dex"
"decred.org/dcrdex/dex/config"
)

// Config holds the parameters needed to initialize an ETH wallet.
type Config struct {
AppDir string `ini:"appdir"`
NodeListenAddr string `ini:"nodelistenaddr"`
GasFee float64 `ini:"gasfee"`
}

// loadConfig loads the Config from a setting map and checks the network.
//
// TODO: Test this with windows.
func loadConfig(settings map[string]string, network dex.Network) (*Config, error) {
cfg := new(Config)
if err := config.Unmapify(settings, cfg); err != nil {
return nil, fmt.Errorf("error parsing config: %w", err)
}
switch network {
case dex.Simnet, dex.Testnet:
case dex.Mainnet:
// TODO: Allow.
return nil, fmt.Errorf("eth cannot be used on mainnet")
default:
return nil, fmt.Errorf("unknown network ID: %d", uint8(network))
}
return cfg, nil
}
Loading