From 136aa954466dcc8ef5a3e72b53e8739e0710013e Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 23 Jan 2014 13:44:28 -0500 Subject: [PATCH] add getblocktemplate support to btcctl. --- util/btcctl/btcctl.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index d73c56cf..d033906c 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -57,6 +57,7 @@ var commandHandlers = map[string]*handlerData{ "getblock": &handlerData{1, 2, displayJSONDump, []conversionHandler{nil, toBool, toBool}, makeGetBlock, ""}, "getblockcount": &handlerData{0, 0, displayGeneric, nil, makeGetBlockCount, ""}, "getblockhash": &handlerData{1, 0, displayGeneric, []conversionHandler{toInt64}, makeGetBlockHash, ""}, + "getblocktemplate": &handlerData{0, 1, displayJSONDump, nil, makeGetBlockTemplate, "[jsonrequestobject]"}, "getconnectioncount": &handlerData{0, 0, displayGeneric, nil, makeGetConnectionCount, ""}, "getdifficulty": &handlerData{0, 0, displayFloat64, nil, makeGetDifficulty, ""}, "getgenerate": &handlerData{0, 0, displayGeneric, nil, makeGetGenerate, ""}, @@ -265,6 +266,21 @@ func makeGetBlockHash(args []interface{}) (btcjson.Cmd, error) { return btcjson.NewGetBlockHashCmd("btcctl", args[0].(int64)) } +// makeGetBlockTemplate generates the cmd structure for getblocktemplate commands. +func makeGetBlockTemplate(args []interface{}) (btcjson.Cmd, error) { + cmd, err := btcjson.NewGetBlockTemplateCmd("btcctl") + if err != nil { + return nil, err + } + if len(args) == 1 { + err = cmd.UnmarshalJSON([]byte(args[0].(string))) + if err != nil { + return nil, err + } + } + return cmd, nil +} + // makeGetConnectionCount generates the cmd structure for // getconnectioncount comands. func makeGetConnectionCount(args []interface{}) (btcjson.Cmd, error) {