Fix JSON-RPC error code for walletpassphrase failures.

This commit is contained in:
Josh Rickmar 2015-05-26 11:39:22 -04:00
parent fbf744bc5e
commit b7cef610c0

View file

@ -1460,7 +1460,7 @@ func jsonError(err error) *btcjson.RPCError {
return nil
}
var code btcjson.RPCErrorCode
code := btcjson.ErrRPCWallet
switch e := err.(type) {
case btcjson.RPCError:
return &e
@ -1472,8 +1472,11 @@ func jsonError(err error) *btcjson.RPCError {
code = btcjson.ErrRPCInvalidParameter
case ParseError:
code = btcjson.ErrRPCParse.Code
default: // All other errors get the wallet error code.
code = btcjson.ErrRPCWallet
case waddrmgr.ManagerError:
switch e.ErrorCode {
case waddrmgr.ErrWrongPassphrase:
code = btcjson.ErrRPCWalletPassphraseIncorrect
}
}
return &btcjson.RPCError{
Code: code,