lnd: generate default macaroons independently
This modifies the `genMacaroons` logic to indepently check for each of the three default macaroons (admin, readonly, invoice) and generate whichever are missing. Previously, this was an all or nothing routine. In other words, either all three didn't exist on disk and all three are created, or no macaroons are created. Although that works for the first run of a new node, it can result in inconsistent states if only one or two of the macaroons is deleted. See https://github.com/lightningnetwork/lnd/discussions/7566.
This commit is contained in:
3 files changed
+57
-37
No files matched your search
+4
-8
@@ -470,14 +470,10 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
|
||||
|
||||
// If the user requested a stateless initialization, no macaroon
|
||||
// files should be created.
|
||||
if !walletInitParams.StatelessInit &&
|
||||
!lnrpc.FileExists(d.cfg.AdminMacPath) &&
|
||||
!lnrpc.FileExists(d.cfg.ReadMacPath) &&
|
||||
!lnrpc.FileExists(d.cfg.InvoiceMacPath) {
|
||||
|
||||
// Create macaroon files for lncli to use if they don't
|
||||
// exist.
|
||||
err = genMacaroons(
|
||||
if !walletInitParams.StatelessInit {
|
||||
// Create default macaroon files for lncli to use if
|
||||
// they don't exist.
|
||||
err = genDefaultMacaroons(
|
||||
ctx, macaroonService, d.cfg.AdminMacPath,
|
||||
d.cfg.ReadMacPath, d.cfg.InvoiceMacPath,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user