Browse Source

feature: add flags to use invoice & readonly macaroons

make_cert_optional
Otto Suess 6 years ago
parent
commit
c7d1608b0c
No known key found for this signature in database GPG Key ID: F7EFC44C2C240A11
  1. 14
      config.go
  2. 10
      zapconnect.go

14
config.go

@ -157,6 +157,8 @@ type zapConnectConfig struct {
Localhost bool `short:"l" long:"localhost" description:"Use 127.0.0.1 for ip."`
Json bool `short:"j" long:"json" description:"Generate json instead of a QRCode."`
Image bool `short:"o" long:"image" description:"Output QRCode to file."`
Invoice bool `long:"invoice" description:"use invoice macaroon"`
Readonly bool `long:"readonly" description:"use readonly macaroon"`
}
// config defines the configuration options for lnd.
@ -382,6 +384,8 @@ func loadConfig() (*config, error) {
cfg.DataDir = cleanAndExpandPath(cfg.DataDir)
cfg.TLSCertPath = cleanAndExpandPath(cfg.TLSCertPath)
cfg.AdminMacPath = cleanAndExpandPath(cfg.AdminMacPath)
cfg.ReadMacPath = cleanAndExpandPath(cfg.ReadMacPath)
cfg.InvoiceMacPath = cleanAndExpandPath(cfg.InvoiceMacPath)
networkDir := filepath.Join(
cfg.DataDir, defaultChainSubDirname,
@ -397,6 +401,16 @@ func loadConfig() (*config, error) {
networkDir, defaultAdminMacFilename,
)
}
if cfg.ReadMacPath == "" {
cfg.ReadMacPath = filepath.Join(
networkDir, defaultReadMacFilename,
)
}
if cfg.InvoiceMacPath == "" {
cfg.InvoiceMacPath = filepath.Join(
networkDir, defaultInvoiceMacFilename,
)
}
// At least one RPCListener is required. So listen on localhost per
// default.

10
zapconnect.go

@ -65,7 +65,15 @@ func main() {
certificate := b64.StdEncoding.EncodeToString([]byte(block.Bytes))
macBytes, err := ioutil.ReadFile(loadedConfig.AdminMacPath)
var macBytes []byte
if loadedConfig.ZapConnect.Invoice {
macBytes, err = ioutil.ReadFile(loadedConfig.InvoiceMacPath)
} else if loadedConfig.ZapConnect.Readonly {
macBytes, err = ioutil.ReadFile(loadedConfig.ReadMacPath)
} else {
macBytes, err = ioutil.ReadFile(loadedConfig.AdminMacPath)
}
if err != nil {
fmt.Println(err)
return

Loading…
Cancel
Save