Skip to content

Commit

Permalink
Fix JSON-RPC error message when sending from locked wallet
Browse files Browse the repository at this point in the history
This error no longer returned a helpful error message about what to
run ever since the per-account encryption was implemented, because
walletpassphrase was not in all cases the correct method to run if the
account was encrypted by unique keys.  Fix this error message to
suggest either walletpassphrase or unlockaccount, and wrap
errors.Locked errors when the account is locked and created from an
xpriv, not an xpub.
  • Loading branch information
jrick committed Dec 14, 2020
1 parent bb60073 commit 6f45010
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/rpc/jsonrpc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var (

errWalletUnlockNeeded = &dcrjson.RPCError{
Code: dcrjson.ErrRPCWalletUnlockNeeded,
Message: "enter the wallet passphrase with walletpassphrase first",
Message: "wallet or account locked; use walletpassphrase or unlockaccount first",
}

errReservedAccountName = &dcrjson.RPCError{
Expand Down
5 changes: 5 additions & 0 deletions wallet/udb/addressmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ func deriveKey(acctInfo *accountInfo, branch, index uint32, private bool) (*hdke
return nil, errors.E(errors.Locked,
"account with unique passphrase is locked")
}
if len(acctInfo.acctKeyEncrypted) != 0 {
return nil, errors.E(errors.Locked,
"private key %s/%d/%d is locked",
acctInfo.acctName, branch, index)
}
return nil, errors.Errorf("no private key for %s/%d/%d",
acctInfo.acctName, branch, index)
}
Expand Down

0 comments on commit 6f45010

Please sign in to comment.