add getreceivedbyaccount and getreceivedbyaddress to btcctl

This commit is contained in:
David Hill 2014-01-30 12:08:50 -05:00
parent 2b9f5b8932
commit 8749cde081

View file

@ -70,6 +70,8 @@ var commandHandlers = map[string]*handlerData{
"getpeerinfo": &handlerData{0, 0, displayJSONDump, nil, makeGetPeerInfo, ""},
"getrawmempool": &handlerData{0, 1, displayJSONDump, []conversionHandler{toBool}, makeGetRawMempool, "[verbose=false]"},
"getrawtransaction": &handlerData{1, 1, displayJSONDump, []conversionHandler{nil, toInt}, makeGetRawTransaction, "<txhash> [verbose=0]"},
"getreceivedbyaccount": &handlerData{1, 1, displayGeneric, []conversionHandler{nil, toInt}, makeGetReceivedByAccount, "<account> [minconf=1]"},
"getreceivedbyaddress": &handlerData{1, 1, displayGeneric, []conversionHandler{nil, toInt}, makeGetReceivedByAddress, "<address> [minconf=1]"},
"getwork": &handlerData{0, 1, displayJSONDump, nil, makeGetWork, "[jsonrequestobject]"},
"help": &handlerData{0, 1, displayGeneric, nil, makeHelp, "[commandName]"},
"importprivkey": &handlerData{1, 2, displayGeneric, []conversionHandler{nil, nil, toBool}, makeImportPrivKey, "<wifprivkey> [label] [rescan=true]"},
@ -386,6 +388,26 @@ func makeGetRawMempool(args []interface{}) (btcjson.Cmd, error) {
return btcjson.NewGetRawMempoolCmd("btcctl", opt...)
}
// makeGetReceivedByAccount generates the cmd structure for
// getreceivedbyaccount commands.
func makeGetReceivedByAccount(args []interface{}) (btcjson.Cmd, error) {
opt := make([]int, 0, 1)
if len(args) > 1 {
opt = append(opt, args[1].(int))
}
return btcjson.NewGetReceivedByAccountCmd("btcctl", args[0].(string), opt...)
}
// makeGetReceivedByAddress generates the cmd structure for
// getreceivedbyaddress commands.
func makeGetReceivedByAddress(args []interface{}) (btcjson.Cmd, error) {
opt := make([]int, 0, 1)
if len(args) > 1 {
opt = append(opt, args[1].(int))
}
return btcjson.NewGetReceivedByAddressCmd("btcctl", args[0].(string), opt...)
}
func makeGetWork(args []interface{}) (btcjson.Cmd, error) {
cmd, err := btcjson.NewGetWorkCmd("btcctl")
if err != nil {