Skip to content

Commit e22649e

Browse files
committed
Add wallet name to config
1 parent fc09839 commit e22649e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

config/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
defaultRPCAddr = "localhost:19001"
2020
defaultRPCCookie = "admin1:123"
2121
defaultChain = "bitcoin"
22+
defaultWalletName = ""
2223
)
2324

2425
var defaultRegistryPath, _ = os.Getwd()
@@ -34,6 +35,7 @@ type Config interface {
3435
ElectrsURL() string
3536
Chain() string
3637
RegistryPath() string
38+
WalletName() string
3739
}
3840

3941
type config struct {
@@ -46,6 +48,7 @@ type config struct {
4648
port string
4749
chain string
4850
registryPath string
51+
walletName string
4952
}
5053
electrs struct {
5154
host string
@@ -72,6 +75,7 @@ func NewConfigFromFlags() (Config, error) {
7275
rpcCookie := flag.String("rpc-cookie", defaultRPCCookie, "RPC server user and password")
7376
chain := flag.String("chain", defaultChain, "Set default chain. Eihter 'bitcoin' or 'liquid'")
7477
registryPath := flag.String("registry-path", defaultRegistryPath, "(Liquid only) Set path for asset registry JSON file")
78+
walletName := flag.String("wallet-name", defaultWalletName, "Set default wallet name")
7579
flag.Parse()
7680

7781
host, port, ok := splitString(*addr)
@@ -112,6 +116,7 @@ func NewConfigFromFlags() (Config, error) {
112116
c.server.port = port
113117
c.server.chain = *chain
114118
c.server.registryPath = *registryPath
119+
c.server.walletName = *walletName
115120

116121
c.electrs.host = electrsHost
117122
c.electrs.port = electrsPort
@@ -156,6 +161,10 @@ func (c *config) Chain() string {
156161
return c.server.chain
157162
}
158163

164+
func (c *config) WalletName() string {
165+
return c.server.walletName
166+
}
167+
159168
func (c *config) RegistryPath() string {
160169
return c.server.registryPath
161170
}

router/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewRouter(config cfg.Config) *Router {
2727
router := mux.NewRouter().StrictSlash(true)
2828

2929
// here we are forcing always the calls against the bitcoin/elements default wallet ""
30-
rpcClient, _ := helpers.NewRpcClient(config.RPCServerURL()+"/wallet/", false, 10)
30+
rpcClient, _ := helpers.NewRpcClient(config.RPCServerURL()+"/wallet/"+config.WalletName(), false, 10)
3131

3232
r := &Router{router, config, rpcClient, nil, nil}
3333

0 commit comments

Comments
 (0)