From ac109cfb86e44df4c036b9eed6f5bdd7ce8baf35 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 29 Aug 2017 16:03:40 -0600 Subject: [PATCH] rpcserver: return correct error when --nocfilters is enabled --- rpcserver.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index eeb5f535..f6729d00 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2150,6 +2150,13 @@ func handleGetBlockTemplate(s *rpcServer, cmd interface{}, closeChan <-chan stru // handleGetCFilter implements the getcfilter command. func handleGetCFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { + if s.cfg.CfIndex == nil { + return nil, &btcjson.RPCError{ + Code: btcjson.ErrRPCNoCFIndex, + Message: "The CF index must be enabled for this command", + } + } + c := cmd.(*btcjson.GetCFilterCmd) hash, err := chainhash.NewHashFromStr(c.Hash) if err != nil { @@ -2172,6 +2179,13 @@ func handleGetCFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) // handleGetCFilterHeader implements the getcfilterheader command. func handleGetCFilterHeader(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { + if s.cfg.CfIndex == nil { + return nil, &btcjson.RPCError{ + Code: btcjson.ErrRPCNoCFIndex, + Message: "The CF index must be enabled for this command", + } + } + c := cmd.(*btcjson.GetCFilterHeaderCmd) hash, err := chainhash.NewHashFromStr(c.Hash) if err != nil {