@@ -41,10 +41,38 @@ type GrpcLndServices struct {
4141func NewLndServices (lndAddress , application , network , macaroonDir ,
4242 tlsPath string ) (* GrpcLndServices , error ) {
4343
44- // If the macaroon directory isn't set, then we can't proceed as we
45- // need then to obtain the macaroons for all sub-servers .
44+ // Based on the network, if the macaroon directory isn't set, then
45+ // we'll use the expected default locations .
4646 if macaroonDir == "" {
47- return nil , fmt .Errorf ("macarooon dir must be set" )
47+ switch network {
48+ case "testnet" :
49+ macaroonDir = filepath .Join (
50+ defaultLndDir , defaultDataDir ,
51+ defaultChainSubDir , "bitcoin" , "testnet" ,
52+ )
53+
54+ case "mainnet" :
55+ macaroonDir = filepath .Join (
56+ defaultLndDir , defaultDataDir ,
57+ defaultChainSubDir , "bitcoin" , "mainnet" ,
58+ )
59+
60+ case "simnet" :
61+ macaroonDir = filepath .Join (
62+ defaultLndDir , defaultDataDir ,
63+ defaultChainSubDir , "bitcoin" , "simnet" ,
64+ )
65+
66+ case "regtest" :
67+ macaroonDir = filepath .Join (
68+ defaultLndDir , defaultDataDir ,
69+ defaultChainSubDir , "bitcoin" , "regtest" ,
70+ )
71+
72+ default :
73+ return nil , fmt .Errorf ("unsupported network: %v" ,
74+ network )
75+ }
4876 }
4977
5078 // Now that we've ensured our macaroon directory is set properly, we
@@ -88,7 +116,7 @@ func NewLndServices(lndAddress, application, network, macaroonDir,
88116 }
89117
90118 // With the network check passed, we'll now initialize the rest of the
91- // sub-sever connections, giving each of them their specific macaroon.
119+ // sub-server connections, giving each of them their specific macaroon.
92120 notifierClient := newChainNotifierClient (conn , macaroons .chainMac )
93121 signerClient := newSignerClient (conn , macaroons .signerMac )
94122 walletKitClient := newWalletKitClient (conn , macaroons .walletKitMac )
0 commit comments