add getblocktemplate support to btcctl.

This commit is contained in:
David Hill 2014-01-23 13:44:28 -05:00
parent 5859deea7e
commit 136aa95446

View file

@ -57,6 +57,7 @@ var commandHandlers = map[string]*handlerData{
"getblock": &handlerData{1, 2, displayJSONDump, []conversionHandler{nil, toBool, toBool}, makeGetBlock, "<blockhash>"},
"getblockcount": &handlerData{0, 0, displayGeneric, nil, makeGetBlockCount, ""},
"getblockhash": &handlerData{1, 0, displayGeneric, []conversionHandler{toInt64}, makeGetBlockHash, "<blocknumber>"},
"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) {