From b7cef610c04523e196f2f4de0c1a8c03e7f71b71 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 26 May 2015 11:39:22 -0400 Subject: [PATCH] Fix JSON-RPC error code for walletpassphrase failures. --- rpcserver.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 5f93ae0..45bcf9b 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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,