From d6f7adeba8ca027225759d2ba0da6660c5bfbfbe Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 13 May 2014 15:24:00 -0500 Subject: [PATCH] Improve btcctl handling of empty RPC data returns. There are several RPCs which do not return any data on success. btcctl was improperly treating this as an error condition. --- util/btcctl/btcctl.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index fb88704e..93d77d65 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -38,7 +38,6 @@ type handlerData struct { // Errors used in the various handlers. var ( - ErrNoData = errors.New("No data returned.") ErrNoDisplayHandler = errors.New("No display handler specified.") ErrUsage = errors.New("btcctl usage") // Real usage is shown. ) @@ -792,10 +791,6 @@ func send(cfg *config, msg []byte) (interface{}, error) { return nil, reply.Error } - if reply.Result == nil { - return nil, ErrNoData - } - return reply.Result, nil } @@ -869,9 +864,12 @@ func commandHandler(cfg *config, command string, data *handlerData, args []strin // Display the results of the JSON-RPC command using the provided // display handler. - err = data.displayHandler(reply) - if err != nil { - return err + if reply != nil { + err = data.displayHandler(reply) + if err != nil { + return err + + } } return nil