@@ -24,6 +24,7 @@ import (
24
24
"github.com/lightningnetwork/lnd/lnwire"
25
25
"github.com/lightningnetwork/lnd/routing"
26
26
"github.com/lightningnetwork/lnd/routing/route"
27
+ "github.com/lightningnetwork/lnd/rpcperms"
27
28
"github.com/lightningnetwork/lnd/signal"
28
29
"github.com/urfave/cli"
29
30
"golang.org/x/term"
@@ -258,7 +259,7 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error {
258
259
return nil
259
260
}
260
261
261
- // Try to parse the Status representatio from this error.
262
+ // Try to parse the Status representation from this error.
262
263
s , ok := status .FromError (err )
263
264
264
265
// If this cannot be represented by a Status, exit early.
@@ -270,21 +271,22 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error {
270
271
// 'unlock') but the wallet is already unlocked, then these
271
272
// methods aren't recognized any more because this service is
272
273
// shut down after successful unlock.
273
- if s .Code () == codes .Unknown &&
274
- (c .Command .Name == "create" ||
275
- c .Command .Name == "unlock" ||
276
- c .Command .Name == "changepassword" ||
277
- c .Command .Name == "createwatchonly" ) {
274
+ if s .Code () == codes .Unknown && strings .Contains (
275
+ s .Message (), rpcperms .ErrWalletUnlocked .Error (),
276
+ ) && (c .Command .Name == "create" ||
277
+ c .Command .Name == "unlock" ||
278
+ c .Command .Name == "changepassword" ||
279
+ c .Command .Name == "createwatchonly" ) {
278
280
279
281
return errors .New ("wallet is already unlocked" )
280
282
}
281
283
282
284
// lnd might be active, but not possible to contact using RPC if
283
- // the wallet is encrypted. If we get error code Unknown, it
284
- // means that lnd is running, but the RPC server is not active
285
- // yet (only WalletUnlocker server active) and most likely this
286
- // is because of an encrypted wallet.
287
- if s . Code () == codes . Unknown {
285
+ // the wallet is encrypted.
286
+ if s . Code () == codes . Unknown && strings . Contains (
287
+ s . Message (), rpcperms . ErrWalletLocked . Error (),
288
+ ) {
289
+
288
290
return errors .New ("wallet is encrypted - please " +
289
291
"unlock using 'lncli unlock', or set " +
290
292
"password using 'lncli create' if this is " +
0 commit comments