-
Notifications
You must be signed in to change notification settings - Fork 122
Support single macaroon for lnd #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "crypto/x509" | ||
| "fmt" | ||
| "os" | ||
| "path" | ||
| "path/filepath" | ||
| "time" | ||
|
|
||
|
|
@@ -46,6 +47,10 @@ var ( | |
|
|
||
| defaultSelfSignedOrganization = "loop autogenerated cert" | ||
|
|
||
| // defaultLndMacaroon is the default macaroon file we use if the old, | ||
| // deprecated --lnd.macaroondir config option is used. | ||
| defaultLndMacaroon = "admin.macaroon" | ||
|
|
||
| // DefaultTLSCertPath is the default full path of the autogenerated TLS | ||
| // certificate. | ||
| DefaultTLSCertPath = filepath.Join( | ||
|
|
@@ -70,9 +75,20 @@ var ( | |
| ) | ||
|
|
||
| type lndConfig struct { | ||
| Host string `long:"host" description:"lnd instance rpc address"` | ||
| MacaroonDir string `long:"macaroondir" description:"Path to the directory containing all the required lnd macaroons"` | ||
| TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"` | ||
| Host string `long:"host" description:"lnd instance rpc address"` | ||
|
|
||
| // MacaroonDir is the directory that contains all the macaroon files | ||
| // required for the remote connection. | ||
| MacaroonDir string `long:"macaroondir" description:"DEPRECATED: Use macaroonpath."` | ||
|
|
||
| // MacaroonPath is the path to the single macaroon that should be used | ||
| // instead of needing to specify the macaroon directory that contains | ||
| // all of lnd's macaroons. The specified macaroon MUST have all | ||
| // permissions that all the subservers use, otherwise permission errors | ||
| // will occur. | ||
| MacaroonPath string `long:"macaroonpath" description:"The full path to the single macaroon to use, either the admin.macaroon or a custom baked one. Cannot be specified at the same time as macaroondir. A custom macaroon must contain ALL permissions required for all subservers to work, otherwise permission errors will occur."` | ||
|
|
||
| TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"` | ||
| } | ||
|
|
||
| type loopServerConfig struct { | ||
|
|
@@ -235,6 +251,30 @@ func Validate(cfg *Config) error { | |
| return err | ||
| } | ||
|
|
||
| // Make sure only one of the macaroon options is used. | ||
| switch { | ||
| case cfg.Lnd.MacaroonPath != "" && cfg.Lnd.MacaroonDir != "": | ||
| return fmt.Errorf("use --lnd.macaroonpath only") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Shouldn't this be either
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. But since the |
||
|
|
||
| case cfg.Lnd.MacaroonDir != "": | ||
| // With the new version of lndclient we can only specify a | ||
| // single macaroon instead of all of them. If the old | ||
| // macaroondir is used, we use the admin macaroon located in | ||
| // that directory. | ||
| cfg.Lnd.MacaroonPath = path.Join( | ||
| lncfg.CleanAndExpandPath(cfg.Lnd.MacaroonDir), | ||
| defaultLndMacaroon, | ||
| ) | ||
|
|
||
| case cfg.Lnd.MacaroonPath != "": | ||
| cfg.Lnd.MacaroonPath = lncfg.CleanAndExpandPath( | ||
| cfg.Lnd.MacaroonPath, | ||
| ) | ||
|
|
||
| default: | ||
| return fmt.Errorf("must specify --lnd.macaroonpath") | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a weird non-breaking space that probably got in there through copy/paste. My IDE showed it so I removed it.