From ef47455b05938cf9e5a427a3ffd77a2162fbd3e7 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Fri, 22 Nov 2013 13:12:53 -0500 Subject: [PATCH] Add listtransactions support to btcctl. This is currently using the generic reply formater, and will likely be switched out for a custom one later. --- util/btcctl/btcctl.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index e4b8c94dd..53e870270 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -58,6 +58,7 @@ var commandHandlers = map[string]*handlerData{ "getrawmempool": &handlerData{0, 0, displaySpewDump, nil, makeGetRawMempool, ""}, "getrawtransaction": &handlerData{1, 1, displaySpewDump, []conversionHandler{nil, toInt}, makeGetRawTransaction, " [verbose=0]"}, "importprivkey": &handlerData{1, 2, displayGeneric, []conversionHandler{nil, nil, toBool}, makeImportPrivKey, " [label] [rescan=true]"}, + "listtransactions": &handlerData{0, 3, displayGeneric, []conversionHandler{nil, toInt, toInt}, makeListTransactions, " [account] [count=10] [from=0]"}, "verifychain": &handlerData{0, 2, displaySpewDump, []conversionHandler{toInt, toInt}, makeVerifyChain, "[level] [depth]"}, "stop": &handlerData{0, 0, displayGeneric, nil, makeStop, ""}, } @@ -222,6 +223,23 @@ func makeImportPrivKey(args []interface{}) (btcjson.Cmd, error) { return btcjson.NewImportPrivKeyCmd("btcctl", args[0].(string), optargs...) } +// makeListTransactions generates the cmd structure for +// listtransactions commands. +func makeListTransactions(args []interface{}) (btcjson.Cmd, error) { + var optargs = make([]interface{}, 0, 3) + if len(args) > 1 { + optargs = append(optargs, args[0].(string)) + } + if len(args) > 2 { + optargs = append(optargs, args[1].(int)) + } + if len(args) > 3 { + optargs = append(optargs, args[2].(int)) + } + + return btcjson.NewListTransactionsCmd("btcctl", optargs...) +} + // makeStop generates the cmd structure for stop comands. func makeStop(args []interface{}) (btcjson.Cmd, error) { return btcjson.NewStopCmd("btcctl")