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