From 8477ef569a6e2452f2adba7b1cddd076509dd25c Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 26 Dec 2013 11:19:32 -0600 Subject: [PATCH] Update btcctl getblock for recent changes. This commit allows btcctl to accept the optional verbosity parameters on getblock. --- rpcserver.go | 1 - util/btcctl/btcctl.go | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 7e47aafe8..bd6a6f044 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -756,7 +756,6 @@ func handleGetBlock(s *rpcServer, cmd btcjson.Cmd, walletNotification chan []byt } } idx := blk.Height() - _, maxidx, err := s.server.db.NewestSha() if err != nil { rpcsLog.Errorf("Cannot get newest sha: %v", err) diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index e575334bc..7e442d6f6 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -50,7 +50,7 @@ var commandHandlers = map[string]*handlerData{ "dumpprivkey": &handlerData{1, 0, displayGeneric, nil, makeDumpPrivKey, ""}, "getbalance": &handlerData{0, 2, displayGeneric, []conversionHandler{nil, toInt}, makeGetBalance, "[account] [minconf=1]"}, "getbestblockhash": &handlerData{0, 0, displayGeneric, nil, makeGetBestBlockHash, ""}, - "getblock": &handlerData{1, 0, displayJSONDump, nil, makeGetBlock, ""}, + "getblock": &handlerData{1, 2, displayJSONDump, []conversionHandler{nil, toBool, toBool}, makeGetBlock, ""}, "getblockcount": &handlerData{0, 0, displayFloat64, nil, makeGetBlockCount, ""}, "getblockhash": &handlerData{1, 0, displayGeneric, []conversionHandler{toInt64}, makeGetBlockHash, ""}, "getconnectioncount": &handlerData{0, 0, displayFloat64, nil, makeGetConnectionCount, ""}, @@ -188,7 +188,22 @@ func makeGetBestBlockHash(args []interface{}) (btcjson.Cmd, error) { // makeGetBlock generates the cmd structure for getblock comands. func makeGetBlock(args []interface{}) (btcjson.Cmd, error) { - return btcjson.NewGetBlockCmd("btcctl", args[0].(string)) + // Create the getblock command with defaults for the optional + // parameters. + getBlockCmd, err := btcjson.NewGetBlockCmd("btcctl", args[0].(string)) + if err != nil { + return nil, err + } + + // Override the optional parameters if they were specified. + if len(args) > 1 { + getBlockCmd.Verbose = args[1].(bool) + } + if len(args) > 2 { + getBlockCmd.VerboseTx = args[2].(bool) + } + + return getBlockCmd, nil } // makeGetBlockCount generates the cmd structure for getblockcount comands.