From 0fdbd4e6688a9ac47b0812c22ede529f297575bc Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Tue, 12 Apr 2022 17:55:56 +0900 Subject: [PATCH] client/dcr: Unlock wallet if acct not encrypted. --- client/asset/dcr/rpcwallet.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/asset/dcr/rpcwallet.go b/client/asset/dcr/rpcwallet.go index fe55f9bf1b..a7c63a4899 100644 --- a/client/asset/dcr/rpcwallet.go +++ b/client/asset/dcr/rpcwallet.go @@ -688,10 +688,19 @@ func (w *rpcWallet) LockAccount(ctx context.Context, acctName string) error { return translateRPCCancelErr(err) } -// UnlockAccount unlocks the specified account. -// Part of the Wallet interface. +// UnlockAccount unlocks the specified account or the wallet if account is not +// encrypted. Part of the Wallet interface. func (w *rpcWallet) UnlockAccount(ctx context.Context, pw []byte, acctName string) error { - return translateRPCCancelErr(w.rpcClient.UnlockAccount(ctx, acctName, string(pw))) + var res *walletjson.AccountUnlockedResult + res, err := w.rpcClient.AccountUnlocked(ctx, acctName) + if err != nil { + return err + } + if res.Encrypted { + return translateRPCCancelErr(w.rpcClient.UnlockAccount(ctx, acctName, string(pw))) + } + return w.unlockWallet(ctx, string(pw), 0) + } // SyncStatus returns the wallet's sync status.