diff --git a/util/btcctl/btcctl.go b/util/btcctl/btcctl.go index bfafb2cd..e58ce729 100644 --- a/util/btcctl/btcctl.go +++ b/util/btcctl/btcctl.go @@ -47,6 +47,7 @@ var commandHandlers = map[string]*handlerData{ "debuglevel": &handlerData{1, 0, displayGeneric, nil, makeDebugLevel, ""}, "decoderawtransaction": &handlerData{1, 0, displaySpewDump, nil, makeDecodeRawTransaction, ""}, "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, displaySpewDump, nil, makeGetBlock, ""}, "getblockcount": &handlerData{0, 0, displayFloat64, nil, makeGetBlockCount, ""}, @@ -146,6 +147,20 @@ func makeDumpPrivKey(args []interface{}) (btcjson.Cmd, error) { return btcjson.NewDumpPrivKeyCmd("btcctl", args[0].(string)) } +// makeGetBalance generates the cmd structure for +// getbalance commands. +func makeGetBalance(args []interface{}) (btcjson.Cmd, error) { + optargs := make([]interface{}, 0, 2) + if len(args) > 0 { + optargs = append(optargs, args[0].(string)) + } + if len(args) > 1 { + optargs = append(optargs, args[1].(int)) + } + + return btcjson.NewGetBalanceCmd("btcctl", optargs...) +} + // makeGetBestBlockHash generates the cmd structure for // makebestblockhash comands. func makeGetBestBlockHash(args []interface{}) (btcjson.Cmd, error) {