mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
cmd/loopd+lndclient: based on the network, update the macaron path if unset
This commit is contained in:
parent
5f6ad1161b
commit
6d00809575
2 changed files with 34 additions and 5 deletions
|
|
@ -34,7 +34,8 @@ func daemon(config *config) error {
|
|||
|
||||
// Create an instance of the loop client library.
|
||||
swapClient, cleanup, err := getClient(
|
||||
config.Network, config.SwapServer, config.Insecure, &lnd.LndServices,
|
||||
config.Network, config.SwapServer, config.Insecure,
|
||||
&lnd.LndServices,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -41,10 +41,38 @@ type GrpcLndServices struct {
|
|||
func NewLndServices(lndAddress, application, network, macaroonDir,
|
||||
tlsPath string) (*GrpcLndServices, error) {
|
||||
|
||||
// If the macaroon directory isn't set, then we can't proceed as we
|
||||
// need then to obtain the macaroons for all sub-servers.
|
||||
// Based on the network, if the macaroon directory isn't set, then
|
||||
// we'll use the expected default locations.
|
||||
if macaroonDir == "" {
|
||||
return nil, fmt.Errorf("macarooon dir must be set")
|
||||
switch network {
|
||||
case "testnet":
|
||||
macaroonDir = filepath.Join(
|
||||
defaultLndDir, defaultDataDir,
|
||||
defaultChainSubDir, "bitcoin", "testnet",
|
||||
)
|
||||
|
||||
case "mainnet":
|
||||
macaroonDir = filepath.Join(
|
||||
defaultLndDir, defaultDataDir,
|
||||
defaultChainSubDir, "bitcoin", "mainnet",
|
||||
)
|
||||
|
||||
case "simnet":
|
||||
macaroonDir = filepath.Join(
|
||||
defaultLndDir, defaultDataDir,
|
||||
defaultChainSubDir, "bitcoin", "simnet",
|
||||
)
|
||||
|
||||
case "regtest":
|
||||
macaroonDir = filepath.Join(
|
||||
defaultLndDir, defaultDataDir,
|
||||
defaultChainSubDir, "bitcoin", "regtest",
|
||||
)
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported network: %v",
|
||||
network)
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we've ensured our macaroon directory is set properly, we
|
||||
|
|
@ -88,7 +116,7 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
|
|||
}
|
||||
|
||||
// With the network check passed, we'll now initialize the rest of the
|
||||
// sub-sever connections, giving each of them their specific macaroon.
|
||||
// sub-server connections, giving each of them their specific macaroon.
|
||||
notifierClient := newChainNotifierClient(conn, macaroons.chainMac)
|
||||
signerClient := newSignerClient(conn, macaroons.signerMac)
|
||||
walletKitClient := newWalletKitClient(conn, macaroons.walletKitMac)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue