Repository: lightningnetwork/lnd (language: go)

Issue:
[bug]: 0.19.0rc1 on testnet4:  `lncli` reports all errors as "wallet is encrypted"
### Background

Any lnd error returns the same message to lncli

### Your environment

* version of `lnd` 0.19.0-beta.rc1 commit=v0.19.0-beta.rc1
* which operating system (`uname -a` on *Nix) macos/docker
* version of `btcd`, `bitcoind`, or other backend bitcoind 28.1
* any other relevant environment details fresh install of testnet4

### Steps to reproduce
 ```
% lncli openchannel --node_key 030f289f0f931cd33cc3435dc5f5fc2a6a65bb0297327d43e82562aded10df74a7 --fee_rate_ppm 1 --local_amt 15000000
[lncli] wallet is encrypted - please unlock using 'lncli unlock', or set password using 'lncli create' if this is the first time starting lnd
```

while in the log:
```
2025-03-26 13:24:03.150 [INF] CHFD: Performing funding tx coin selection using 8626 sat/kw as fee rate
2025-03-26 13:24:03.150 [ERR] RPCS: unable to open channel to NodeKey(030f289f0f931cd33cc3435dc5f5fc2a6a65bb0297327d43e82562aded10df74a7): not enough witness outputs to create funding transaction, need 0.15000000 BTC only have 0 BTC available
2025-03-26 13:24:03.151 [ERR] RPCS: [/lnrpc.Lightning/OpenChannel]: not enough witness outputs to create funding transaction, need 0.15000000 BTC only have 0 BTC available
```




Discussion / hints:

Fix patch:
diff --git a/cmd/commands/commands.go b/cmd/commands/commands.go
index 9cbd0bf7a7..29060ae9a6 100644
--- a/cmd/commands/commands.go
+++ b/cmd/commands/commands.go
@@ -24,6 +24,7 @@ import (
 	"github.com/lightningnetwork/lnd/lnwire"
 	"github.com/lightningnetwork/lnd/routing"
 	"github.com/lightningnetwork/lnd/routing/route"
+	"github.com/lightningnetwork/lnd/rpcperms"
 	"github.com/lightningnetwork/lnd/signal"
 	"github.com/urfave/cli"
 	"golang.org/x/term"
@@ -258,7 +259,7 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error {
 			return nil
 		}
 
-		// Try to parse the Status representatio from this error.
+		// Try to parse the Status representation from this error.
 		s, ok := status.FromError(err)
 
 		// 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 {
 		// 'unlock') but the wallet is already unlocked, then these
 		// methods aren't recognized any more because this service is
 		// shut down after successful unlock.
-		if s.Code() == codes.Unknown &&
-			(c.Command.Name == "create" ||
-				c.Command.Name == "unlock" ||
-				c.Command.Name == "changepassword" ||
-				c.Command.Name == "createwatchonly") {
+		if s.Code() == codes.Unknown && strings.Contains(
+			s.Message(), rpcperms.ErrWalletUnlocked.Error(),
+		) && (c.Command.Name == "create" ||
+			c.Command.Name == "unlock" ||
+			c.Command.Name == "changepassword" ||
+			c.Command.Name == "createwatchonly") {
 
 			return errors.New("wallet is already unlocked")
 		}
 
 		// lnd might be active, but not possible to contact using RPC if
-		// the wallet is encrypted. If we get error code Unknown, it
-		// means that lnd is running, but the RPC server is not active
-		// yet (only WalletUnlocker server active) and most likely this
-		// is because of an encrypted wallet.
-		if s.Code() == codes.Unknown {
+		// the wallet is encrypted.
+		if s.Code() == codes.Unknown && strings.Contains(
+			s.Message(), rpcperms.ErrWalletLocked.Error(),
+		) {
+
 			return errors.New("wallet is encrypted - please " +
 				"unlock using 'lncli unlock', or set " +
 				"password using 'lncli create' if this is " +


Test patch: