Rename NotifyNewTXsCmd to NotifyReceivedCmd.
This commit renamed the notifynewtxs RPC to notifyreceived since it more accurately reflects its intention which is to register addresses to be notified about when they receive funds. This is work towards conformal/btcd#98. ok @jrick.
This commit is contained in:
parent
db5bc2c77c
commit
0b4401ddb6
1 changed files with 19 additions and 19 deletions
38
cmds.go
38
cmds.go
|
@ -42,7 +42,7 @@ func init() {
|
||||||
parseListAllTransactionsCmd, nil, `TODO(jrick) fillmein`)
|
parseListAllTransactionsCmd, nil, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifyblocks", parseNotifyBlocksCmd, nil,
|
btcjson.RegisterCustomCmd("notifyblocks", parseNotifyBlocksCmd, nil,
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifynewtxs", parseNotifyNewTXsCmd, nil,
|
btcjson.RegisterCustomCmd("notifyreceived", parseNotifyReceivedCmd, nil,
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifyallnewtxs", parseNotifyAllNewTXsCmd,
|
btcjson.RegisterCustomCmd("notifyallnewtxs", parseNotifyAllNewTXsCmd,
|
||||||
nil, `TODO(flam) fillmein`)
|
nil, `TODO(flam) fillmein`)
|
||||||
|
@ -852,29 +852,29 @@ func (cmd *NotifyBlocksCmd) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyNewTXsCmd is a type handling custom marshaling and
|
// NotifyReceivedCmd is a type handling custom marshaling and
|
||||||
// unmarshaling of notifynewtxs JSON websocket extension
|
// unmarshaling of notifyreceived JSON websocket extension
|
||||||
// commands.
|
// commands.
|
||||||
type NotifyNewTXsCmd struct {
|
type NotifyReceivedCmd struct {
|
||||||
id interface{}
|
id interface{}
|
||||||
Addresses []string
|
Addresses []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that NotifyNewTXsCmd satisifies the btcjson.Cmd interface.
|
// Enforce that NotifyReceivedCmd satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &NotifyNewTXsCmd{}
|
var _ btcjson.Cmd = &NotifyReceivedCmd{}
|
||||||
|
|
||||||
// NewNotifyNewTXsCmd creates a new NotifyNewTXsCmd.
|
// NewNotifyNewTXsCmd creates a new NotifyNewTXsCmd.
|
||||||
func NewNotifyNewTXsCmd(id interface{}, addresses []string) *NotifyNewTXsCmd {
|
func NewNotifyReceivedCmd(id interface{}, addresses []string) *NotifyReceivedCmd {
|
||||||
return &NotifyNewTXsCmd{
|
return &NotifyReceivedCmd{
|
||||||
id: id,
|
id: id,
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseNotifyNewTXsCmd parses a NotifyNewTXsCmd into a concrete type
|
// parseNotifyReceivedCmd parses a NotifyNewTXsCmd into a concrete type
|
||||||
// satisifying the btcjson.Cmd interface. This is used when registering
|
// satisifying the btcjson.Cmd interface. This is used when registering
|
||||||
// the custom command with the btcjson parser.
|
// the custom command with the btcjson parser.
|
||||||
func parseNotifyNewTXsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
func parseNotifyReceivedCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
if len(r.Params) != 1 {
|
if len(r.Params) != 1 {
|
||||||
return nil, btcjson.ErrWrongNumberOfParams
|
return nil, btcjson.ErrWrongNumberOfParams
|
||||||
}
|
}
|
||||||
|
@ -885,26 +885,26 @@ func parseNotifyNewTXsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
"an array of strings: " + err.Error())
|
"an array of strings: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewNotifyNewTXsCmd(r.Id, addresses), nil
|
return NewNotifyReceivedCmd(r.Id, addresses), 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 *NotifyNewTXsCmd) Id() interface{} {
|
func (cmd *NotifyReceivedCmd) Id() interface{} {
|
||||||
return cmd.id
|
return cmd.id
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetId satisifies the Cmd interface by setting the ID of the command.
|
// SetId satisifies the Cmd interface by setting the ID of the command.
|
||||||
func (cmd *NotifyNewTXsCmd) SetId(id interface{}) {
|
func (cmd *NotifyReceivedCmd) SetId(id interface{}) {
|
||||||
cmd.id = id
|
cmd.id = id
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method satisfies the Cmd interface by returning the RPC method.
|
// Method satisfies the Cmd interface by returning the RPC method.
|
||||||
func (cmd *NotifyNewTXsCmd) Method() string {
|
func (cmd *NotifyReceivedCmd) Method() string {
|
||||||
return "notifynewtxs"
|
return "notifyreceived"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON returns the JSON encoding of cmd. Part of the Cmd interface.
|
// MarshalJSON returns the JSON encoding of cmd. Part of the Cmd interface.
|
||||||
func (cmd *NotifyNewTXsCmd) MarshalJSON() ([]byte, error) {
|
func (cmd *NotifyReceivedCmd) MarshalJSON() ([]byte, error) {
|
||||||
params := []interface{}{
|
params := []interface{}{
|
||||||
cmd.Addresses,
|
cmd.Addresses,
|
||||||
}
|
}
|
||||||
|
@ -918,19 +918,19 @@ func (cmd *NotifyNewTXsCmd) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals the JSON encoding of cmd into cmd. Part of
|
// UnmarshalJSON unmarshals the JSON encoding of cmd into cmd. Part of
|
||||||
// the Cmd interface.
|
// the Cmd interface.
|
||||||
func (cmd *NotifyNewTXsCmd) UnmarshalJSON(b []byte) error {
|
func (cmd *NotifyReceivedCmd) UnmarshalJSON(b []byte) error {
|
||||||
// Unmarshal into a RawCmd.
|
// Unmarshal into a RawCmd.
|
||||||
var r btcjson.RawCmd
|
var r btcjson.RawCmd
|
||||||
if err := json.Unmarshal(b, &r); err != nil {
|
if err := json.Unmarshal(b, &r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newCmd, err := parseNotifyNewTXsCmd(&r)
|
newCmd, err := parseNotifyReceivedCmd(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
concreteCmd, ok := newCmd.(*NotifyNewTXsCmd)
|
concreteCmd, ok := newCmd.(*NotifyReceivedCmd)
|
||||||
if !ok {
|
if !ok {
|
||||||
return btcjson.ErrInternal
|
return btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue