Add reply parser for ListAddressTransactionCmd.

ok @jrick
This commit is contained in:
Dave Collins 2014-04-11 14:03:36 -05:00
parent 3208b7ae75
commit db5bc2c77c

14
cmds.go
View file

@ -36,7 +36,8 @@ func init() {
btcjson.RegisterCustomCmd("getunconfirmedbalance", btcjson.RegisterCustomCmd("getunconfirmedbalance",
parseGetUnconfirmedBalanceCmd, nil, `TODO(jrick) fillmein`) parseGetUnconfirmedBalanceCmd, nil, `TODO(jrick) fillmein`)
btcjson.RegisterCustomCmd("listaddresstransactions", btcjson.RegisterCustomCmd("listaddresstransactions",
parseListAddressTransactionsCmd, nil, `TODO(jrick) fillmein`) parseListAddressTransactionsCmd,
parseListAddressTransactionsCmdReply, `TODO(jrick) fillmein`)
btcjson.RegisterCustomCmd("listalltransactions", btcjson.RegisterCustomCmd("listalltransactions",
parseListAllTransactionsCmd, nil, `TODO(jrick) fillmein`) parseListAllTransactionsCmd, nil, `TODO(jrick) fillmein`)
btcjson.RegisterCustomCmd("notifyblocks", parseNotifyBlocksCmd, nil, btcjson.RegisterCustomCmd("notifyblocks", parseNotifyBlocksCmd, nil,
@ -1377,6 +1378,17 @@ func parseListAddressTransactionsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
return NewListAddressTransactionsCmd(r.Id, addresses, optArgs...) return NewListAddressTransactionsCmd(r.Id, addresses, optArgs...)
} }
// parseListAddressTransactionsCmdReply parses a the reply to a
// ListAddressTransactionsCmd into a concrete type and returns it packed into
// an interface. This is used when registering the custom command with btcjson.
func parseListAddressTransactionsCmdReply(message json.RawMessage) (interface{}, error) {
var res []btcjson.ListTransactionsResult
if err := json.Unmarshal(message, &res); err != nil {
return nil, err
}
return res, nil
}
// Id satisifies the Cmd interface by returning the ID of the command. // Id satisifies the Cmd interface by returning the ID of the command.
func (cmd *ListAddressTransactionsCmd) Id() interface{} { func (cmd *ListAddressTransactionsCmd) Id() interface{} {
return cmd.id return cmd.id