Rename new transaction register/notifications.
This commit renames the notifyallnewtxs RPC to notifynewtransactions to be more consistent with the standard RPC names and to more accurately reflect its intention which is to register for new transactions as they are accepted to the memory pool. In addition, the notifications produced have been renamed to txaccepted and txacceptedverbose depending on whether or not the verbose flag was set when the client registered to receive the notifications via notifynewtransactions. This closes conformal/btcd#98.
This commit is contained in:
parent
f389d39c43
commit
ce48290169
4 changed files with 78 additions and 78 deletions
50
cmds.go
50
cmds.go
|
@ -44,8 +44,8 @@ func init() {
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifyreceived", parseNotifyReceivedCmd, nil,
|
btcjson.RegisterCustomCmd("notifyreceived", parseNotifyReceivedCmd, nil,
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifyallnewtxs", parseNotifyAllNewTXsCmd,
|
btcjson.RegisterCustomCmd("notifynewtransactions",
|
||||||
nil, `TODO(flam) fillmein`)
|
parseNotifyNewTransactionsCmd, nil, `TODO(flam) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("notifyspent", parseNotifySpentCmd,
|
btcjson.RegisterCustomCmd("notifyspent", parseNotifySpentCmd,
|
||||||
nil, `TODO(jrick) fillmein`)
|
nil, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd("recoveraddresses", parseRecoverAddressesCmd,
|
btcjson.RegisterCustomCmd("recoveraddresses", parseRecoverAddressesCmd,
|
||||||
|
@ -863,7 +863,7 @@ type NotifyReceivedCmd struct {
|
||||||
// Enforce that NotifyReceivedCmd satisifies the btcjson.Cmd interface.
|
// Enforce that NotifyReceivedCmd satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &NotifyReceivedCmd{}
|
var _ btcjson.Cmd = &NotifyReceivedCmd{}
|
||||||
|
|
||||||
// NewNotifyNewTXsCmd creates a new NotifyNewTXsCmd.
|
// NewNotifyReceivedCmd creates a new NotifyReceivedCmd.
|
||||||
func NewNotifyReceivedCmd(id interface{}, addresses []string) *NotifyReceivedCmd {
|
func NewNotifyReceivedCmd(id interface{}, addresses []string) *NotifyReceivedCmd {
|
||||||
return &NotifyReceivedCmd{
|
return &NotifyReceivedCmd{
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -938,20 +938,20 @@ func (cmd *NotifyReceivedCmd) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyAllNewTXsCmd is a type handling custom marshaling and
|
// NotifyNewTransactionsCmd is a type handling custom marshaling and
|
||||||
// unmarshaling of notifynewtxs JSON websocket extension
|
// unmarshaling of notifynewtransactions JSON websocket extension
|
||||||
// commands.
|
// commands.
|
||||||
type NotifyAllNewTXsCmd struct {
|
type NotifyNewTransactionsCmd struct {
|
||||||
id interface{}
|
id interface{}
|
||||||
Verbose bool
|
Verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that NotifyAllNewTXsCmd satisifies the btcjson.Cmd interface.
|
// Enforce that NotifyNewTransactionsCmd satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &NotifyAllNewTXsCmd{}
|
var _ btcjson.Cmd = &NotifyNewTransactionsCmd{}
|
||||||
|
|
||||||
// NewNotifyAllNewTXsCmd creates a new NotifyAllNewTXsCmd that optionally
|
// NewNotifyNewTransactionsCmd creates a new NotifyNewTransactionsCmd that
|
||||||
// takes a single verbose parameter that defaults to false.
|
// optionally takes a single verbose parameter that defaults to false.
|
||||||
func NewNotifyAllNewTXsCmd(id interface{}, optArgs ...bool) (*NotifyAllNewTXsCmd, error) {
|
func NewNotifyNewTransactionsCmd(id interface{}, optArgs ...bool) (*NotifyNewTransactionsCmd, error) {
|
||||||
verbose := false
|
verbose := false
|
||||||
|
|
||||||
optArgsLen := len(optArgs)
|
optArgsLen := len(optArgs)
|
||||||
|
@ -962,16 +962,16 @@ func NewNotifyAllNewTXsCmd(id interface{}, optArgs ...bool) (*NotifyAllNewTXsCmd
|
||||||
verbose = optArgs[0]
|
verbose = optArgs[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
return &NotifyAllNewTXsCmd{
|
return &NotifyNewTransactionsCmd{
|
||||||
id: id,
|
id: id,
|
||||||
Verbose: verbose,
|
Verbose: verbose,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseNotifyAllNewTXsCmd parses a NotifyAllNewTXsCmd into a concrete type
|
// parseNotifyNewTransactionsCmd parses a NotifyNewTransactionsCmd into a
|
||||||
// satisifying the btcjson.Cmd interface. This is used when registering
|
// concrete type satisifying the btcjson.Cmd interface. This is used when
|
||||||
// the custom command with the btcjson parser.
|
// registering the custom command with the btcjson parser.
|
||||||
func parseNotifyAllNewTXsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
func parseNotifyNewTransactionsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
if len(r.Params) > 1 {
|
if len(r.Params) > 1 {
|
||||||
return nil, btcjson.ErrWrongNumberOfParams
|
return nil, btcjson.ErrWrongNumberOfParams
|
||||||
}
|
}
|
||||||
|
@ -986,26 +986,26 @@ func parseNotifyAllNewTXsCmd(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
optArgs = append(optArgs, verbose)
|
optArgs = append(optArgs, verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewNotifyAllNewTXsCmd(r.Id, optArgs...)
|
return NewNotifyNewTransactionsCmd(r.Id, optArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 *NotifyAllNewTXsCmd) Id() interface{} {
|
func (cmd *NotifyNewTransactionsCmd) 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 *NotifyAllNewTXsCmd) SetId(id interface{}) {
|
func (cmd *NotifyNewTransactionsCmd) 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 *NotifyAllNewTXsCmd) Method() string {
|
func (cmd *NotifyNewTransactionsCmd) Method() string {
|
||||||
return "notifyallnewtxs"
|
return "notifynewtransactions"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 *NotifyAllNewTXsCmd) MarshalJSON() ([]byte, error) {
|
func (cmd *NotifyNewTransactionsCmd) MarshalJSON() ([]byte, error) {
|
||||||
params := []interface{}{
|
params := []interface{}{
|
||||||
cmd.Verbose,
|
cmd.Verbose,
|
||||||
}
|
}
|
||||||
|
@ -1019,19 +1019,19 @@ func (cmd *NotifyAllNewTXsCmd) 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 *NotifyAllNewTXsCmd) UnmarshalJSON(b []byte) error {
|
func (cmd *NotifyNewTransactionsCmd) 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 := parseNotifyAllNewTXsCmd(&r)
|
newCmd, err := parseNotifyNewTransactionsCmd(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
concreteCmd, ok := newCmd.(*NotifyAllNewTXsCmd)
|
concreteCmd, ok := newCmd.(*NotifyNewTransactionsCmd)
|
||||||
if !ok {
|
if !ok {
|
||||||
return btcjson.ErrInternal
|
return btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,13 +173,13 @@ var cmdtests = []struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "notifyallnewtxs",
|
name: "notifynewtransactions",
|
||||||
f: func() (btcjson.Cmd, error) {
|
f: func() (btcjson.Cmd, error) {
|
||||||
return NewNotifyAllNewTXsCmd(
|
return NewNotifyNewTransactionsCmd(
|
||||||
float64(1),
|
float64(1),
|
||||||
true)
|
true)
|
||||||
},
|
},
|
||||||
result: &NotifyAllNewTXsCmd{
|
result: &NotifyNewTransactionsCmd{
|
||||||
id: float64(1),
|
id: float64(1),
|
||||||
Verbose: true,
|
Verbose: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,13 +22,13 @@ const (
|
||||||
// accountbalance notification.
|
// accountbalance notification.
|
||||||
AccountBalanceNtfnMethod = "accountbalance"
|
AccountBalanceNtfnMethod = "accountbalance"
|
||||||
|
|
||||||
// AllTxNtfnMethod is the method of the btcd alltx
|
// TxAcceptedNtfnMethod is the method of the btcd txaccepted
|
||||||
// notification
|
// notification
|
||||||
AllTxNtfnMethod = "alltx"
|
TxAcceptedNtfnMethod = "txaccepted"
|
||||||
|
|
||||||
// AllVerboseTxNtfnMethod is the method of the btcd
|
// TxAcceptedVerboseNtfnMethod is the method of the btcd
|
||||||
// allverbosetx notifications.
|
// txacceptedverbose notifications.
|
||||||
AllVerboseTxNtfnMethod = "allverbosetx"
|
TxAcceptedVerboseNtfnMethod = "txacceptedverbose"
|
||||||
|
|
||||||
// BlockConnectedNtfnMethod is the method of the btcd
|
// BlockConnectedNtfnMethod is the method of the btcd
|
||||||
// blockconnected notification.
|
// blockconnected notification.
|
||||||
|
@ -82,10 +82,10 @@ func init() {
|
||||||
`TODO(jrick) fillmein`)
|
`TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd(WalletLockStateNtfnMethod,
|
btcjson.RegisterCustomCmd(WalletLockStateNtfnMethod,
|
||||||
parseWalletLockStateNtfn, nil, `TODO(jrick) fillmein`)
|
parseWalletLockStateNtfn, nil, `TODO(jrick) fillmein`)
|
||||||
btcjson.RegisterCustomCmd(AllTxNtfnMethod, parseAllTxNtfn, nil,
|
btcjson.RegisterCustomCmd(TxAcceptedNtfnMethod, parseTxAcceptedNtfn, nil,
|
||||||
`TODO(flam) fillmein`)
|
`TODO(flam) fillmein`)
|
||||||
btcjson.RegisterCustomCmd(AllVerboseTxNtfnMethod, parseAllVerboseTxNtfn,
|
btcjson.RegisterCustomCmd(TxAcceptedVerboseNtfnMethod,
|
||||||
nil, `TODO(flam) fillmein`)
|
parseTxAcceptedVerboseNtfn, nil, `TODO(flam) fillmein`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockDetails describes details of a tx in a block.
|
// BlockDetails describes details of a tx in a block.
|
||||||
|
@ -982,28 +982,28 @@ func (n *WalletLockStateNtfn) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllTxNtfn is a type handling custom marshaling and
|
// TxAcceptedNtfn is a type handling custom marshaling and
|
||||||
// unmarshaling of txmined JSON websocket notifications.
|
// unmarshaling of txmined JSON websocket notifications.
|
||||||
type AllTxNtfn struct {
|
type TxAcceptedNtfn struct {
|
||||||
TxID string `json:"txid"`
|
TxID string `json:"txid"`
|
||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that AllTxNtfn satisifies the btcjson.Cmd interface.
|
// Enforce that TxAcceptedNtfn satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &AllTxNtfn{}
|
var _ btcjson.Cmd = &TxAcceptedNtfn{}
|
||||||
|
|
||||||
// NewAllTxNtfn creates a new AllTxNtfn.
|
// NewTxAcceptedNtfn creates a new TxAcceptedNtfn.
|
||||||
func NewAllTxNtfn(txid string, amount int64) *AllTxNtfn {
|
func NewTxAcceptedNtfn(txid string, amount int64) *TxAcceptedNtfn {
|
||||||
return &AllTxNtfn{
|
return &TxAcceptedNtfn{
|
||||||
TxID: txid,
|
TxID: txid,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseAllTxNtfn parses a RawCmd into a concrete type satisifying
|
// parseTxAcceptedNtfn parses a RawCmd into a concrete type satisifying
|
||||||
// the btcjson.Cmd interface. This is used when registering the notification
|
// the btcjson.Cmd interface. This is used when registering the notification
|
||||||
// with the btcjson parser.
|
// with the btcjson parser.
|
||||||
func parseAllTxNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
func parseTxAcceptedNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
if r.Id != nil {
|
if r.Id != nil {
|
||||||
return nil, ErrNotANtfn
|
return nil, ErrNotANtfn
|
||||||
}
|
}
|
||||||
|
@ -1024,28 +1024,28 @@ func parseAllTxNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
"integer: " + err.Error())
|
"integer: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewAllTxNtfn(txid, amount), nil
|
return NewTxAcceptedNtfn(txid, amount), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
||||||
// notification ID.
|
// notification ID.
|
||||||
func (n *AllTxNtfn) Id() interface{} {
|
func (n *TxAcceptedNtfn) Id() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
||||||
// notification id is not modified.
|
// notification id is not modified.
|
||||||
func (n *AllTxNtfn) SetId(id interface{}) {}
|
func (n *TxAcceptedNtfn) SetId(id interface{}) {}
|
||||||
|
|
||||||
// Method satisifies the btcjson.Cmd interface by returning the method
|
// Method satisifies the btcjson.Cmd interface by returning the method
|
||||||
// of the notification.
|
// of the notification.
|
||||||
func (n *AllTxNtfn) Method() string {
|
func (n *TxAcceptedNtfn) Method() string {
|
||||||
return AllTxNtfnMethod
|
return TxAcceptedNtfnMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
||||||
// interface.
|
// interface.
|
||||||
func (n *AllTxNtfn) MarshalJSON() ([]byte, error) {
|
func (n *TxAcceptedNtfn) MarshalJSON() ([]byte, error) {
|
||||||
params := []interface{}{
|
params := []interface{}{
|
||||||
n.TxID,
|
n.TxID,
|
||||||
n.Amount,
|
n.Amount,
|
||||||
|
@ -1061,19 +1061,19 @@ func (n *AllTxNtfn) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
||||||
// the btcjson.Cmd interface.
|
// the btcjson.Cmd interface.
|
||||||
func (n *AllTxNtfn) UnmarshalJSON(b []byte) error {
|
func (n *TxAcceptedNtfn) 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
|
||||||
}
|
}
|
||||||
|
|
||||||
newNtfn, err := parseAllTxNtfn(&r)
|
newNtfn, err := parseTxAcceptedNtfn(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
concreteNtfn, ok := newNtfn.(*AllTxNtfn)
|
concreteNtfn, ok := newNtfn.(*TxAcceptedNtfn)
|
||||||
if !ok {
|
if !ok {
|
||||||
return btcjson.ErrInternal
|
return btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
@ -1081,26 +1081,26 @@ func (n *AllTxNtfn) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllVerboseTxNtfn is a type handling custom marshaling and
|
// TxAcceptedVerboseNtfn is a type handling custom marshaling and
|
||||||
// unmarshaling of txmined JSON websocket notifications.
|
// unmarshaling of txmined JSON websocket notifications.
|
||||||
type AllVerboseTxNtfn struct {
|
type TxAcceptedVerboseNtfn struct {
|
||||||
RawTx *btcjson.TxRawResult `json:"rawtx"`
|
RawTx *btcjson.TxRawResult `json:"rawtx"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that AllTxNtfn satisifies the btcjson.Cmd interface.
|
// Enforce that TxAcceptedNtfn satisifies the btcjson.Cmd interface.
|
||||||
var _ btcjson.Cmd = &AllVerboseTxNtfn{}
|
var _ btcjson.Cmd = &TxAcceptedVerboseNtfn{}
|
||||||
|
|
||||||
// NewAllVerboseTxNtfn creates a new AllVerboseTxNtfn.
|
// NewTxAcceptedVerboseNtfn creates a new TxAcceptedVerboseNtfn.
|
||||||
func NewAllVerboseTxNtfn(rawTx *btcjson.TxRawResult) *AllVerboseTxNtfn {
|
func NewTxAcceptedVerboseNtfn(rawTx *btcjson.TxRawResult) *TxAcceptedVerboseNtfn {
|
||||||
return &AllVerboseTxNtfn{
|
return &TxAcceptedVerboseNtfn{
|
||||||
RawTx: rawTx,
|
RawTx: rawTx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseAllVerboseTxNtfn parses a RawCmd into a concrete type satisifying
|
// parseTxAcceptedVerboseNtfn parses a RawCmd into a concrete type satisifying
|
||||||
// the btcjson.Cmd interface. This is used when registering the notification
|
// the btcjson.Cmd interface. This is used when registering the notification
|
||||||
// with the btcjson parser.
|
// with the btcjson parser.
|
||||||
func parseAllVerboseTxNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
func parseTxAcceptedVerboseNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
if r.Id != nil {
|
if r.Id != nil {
|
||||||
return nil, ErrNotANtfn
|
return nil, ErrNotANtfn
|
||||||
}
|
}
|
||||||
|
@ -1114,28 +1114,28 @@ func parseAllVerboseTxNtfn(r *btcjson.RawCmd) (btcjson.Cmd, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewAllVerboseTxNtfn(rawTx), nil
|
return NewTxAcceptedVerboseNtfn(rawTx), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
// Id satisifies the btcjson.Cmd interface by returning nil for a
|
||||||
// notification ID.
|
// notification ID.
|
||||||
func (n *AllVerboseTxNtfn) Id() interface{} {
|
func (n *TxAcceptedVerboseNtfn) Id() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
// SetId is implemented to satisify the btcjson.Cmd interface. The
|
||||||
// notification id is not modified.
|
// notification id is not modified.
|
||||||
func (n *AllVerboseTxNtfn) SetId(id interface{}) {}
|
func (n *TxAcceptedVerboseNtfn) SetId(id interface{}) {}
|
||||||
|
|
||||||
// Method satisifies the btcjson.Cmd interface by returning the method
|
// Method satisifies the btcjson.Cmd interface by returning the method
|
||||||
// of the notification.
|
// of the notification.
|
||||||
func (n *AllVerboseTxNtfn) Method() string {
|
func (n *TxAcceptedVerboseNtfn) Method() string {
|
||||||
return AllVerboseTxNtfnMethod
|
return TxAcceptedVerboseNtfnMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
// MarshalJSON returns the JSON encoding of n. Part of the btcjson.Cmd
|
||||||
// interface.
|
// interface.
|
||||||
func (n *AllVerboseTxNtfn) MarshalJSON() ([]byte, error) {
|
func (n *TxAcceptedVerboseNtfn) MarshalJSON() ([]byte, error) {
|
||||||
params := []interface{}{
|
params := []interface{}{
|
||||||
n.RawTx,
|
n.RawTx,
|
||||||
}
|
}
|
||||||
|
@ -1150,18 +1150,18 @@ func (n *AllVerboseTxNtfn) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
// UnmarshalJSON unmarshals the JSON encoding of n into n. Part of
|
||||||
// the btcjson.Cmd interface.
|
// the btcjson.Cmd interface.
|
||||||
func (n *AllVerboseTxNtfn) UnmarshalJSON(b []byte) error {
|
func (n *TxAcceptedVerboseNtfn) UnmarshalJSON(b []byte) error {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
newNtfn, err := parseAllVerboseTxNtfn(&r)
|
newNtfn, err := parseTxAcceptedVerboseNtfn(&r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
concreteNtfn, ok := newNtfn.(*AllVerboseTxNtfn)
|
concreteNtfn, ok := newNtfn.(*TxAcceptedVerboseNtfn)
|
||||||
if !ok {
|
if !ok {
|
||||||
return btcjson.ErrInternal
|
return btcjson.ErrInternal
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,28 +188,28 @@ var ntfntests = []struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "alltx",
|
name: "txaccepted",
|
||||||
f: func() btcjson.Cmd {
|
f: func() btcjson.Cmd {
|
||||||
return btcws.NewAllTxNtfn(
|
return btcws.NewTxAcceptedNtfn(
|
||||||
"062f2b5f7d28c787e0f3aee382132241cd590efb7b83bd2c7f506de5aa4ef275",
|
"062f2b5f7d28c787e0f3aee382132241cd590efb7b83bd2c7f506de5aa4ef275",
|
||||||
34567765)
|
34567765)
|
||||||
},
|
},
|
||||||
result: &btcws.AllTxNtfn{
|
result: &btcws.TxAcceptedNtfn{
|
||||||
TxID: "062f2b5f7d28c787e0f3aee382132241cd590efb7b83bd2c7f506de5aa4ef275",
|
TxID: "062f2b5f7d28c787e0f3aee382132241cd590efb7b83bd2c7f506de5aa4ef275",
|
||||||
Amount: 34567765,
|
Amount: 34567765,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "allverbosetx",
|
name: "txacceptedverbose",
|
||||||
f: func() btcjson.Cmd {
|
f: func() btcjson.Cmd {
|
||||||
return btcws.NewAllVerboseTxNtfn(&btcjson.TxRawResult{
|
return btcws.NewTxAcceptedVerboseNtfn(&btcjson.TxRawResult{
|
||||||
Hex: "01000000010cdf900074a3622499a2f28f44a94476f27a8900a2bdd60e042754b6cab09741000000008a473044022012e11012fad1eb21ba1c82deb8da98778b08e714b72f281293064528343fae0502204294d7520f469f9673087a55395de0ce0e9074dce236db9fe7f30013b5fd00b90141047b6ff7832b4a763666e5481a0bd9eedb656d9f882d215c16fe9563d7b191cd67b2a41601a853a9f9d92773ae6f912ef451a089148e510623759cf55c408efdefffffffff02f4063f00000000001976a914b269e0ceec5d5b5e192cf580ae42341e0f79b0b588aca8c84b02000000001976a91439233c0d43a1411e547c60bad8985bae3530b6af88ac00000000",
|
Hex: "01000000010cdf900074a3622499a2f28f44a94476f27a8900a2bdd60e042754b6cab09741000000008a473044022012e11012fad1eb21ba1c82deb8da98778b08e714b72f281293064528343fae0502204294d7520f469f9673087a55395de0ce0e9074dce236db9fe7f30013b5fd00b90141047b6ff7832b4a763666e5481a0bd9eedb656d9f882d215c16fe9563d7b191cd67b2a41601a853a9f9d92773ae6f912ef451a089148e510623759cf55c408efdefffffffff02f4063f00000000001976a914b269e0ceec5d5b5e192cf580ae42341e0f79b0b588aca8c84b02000000001976a91439233c0d43a1411e547c60bad8985bae3530b6af88ac00000000",
|
||||||
Txid: "0cfeb968fb5d0f6b9a2a1de37c0607a1964dd3e335f203377cec90e03b20869e",
|
Txid: "0cfeb968fb5d0f6b9a2a1de37c0607a1964dd3e335f203377cec90e03b20869e",
|
||||||
Version: 0x1,
|
Version: 0x1,
|
||||||
LockTime: 0x0,
|
LockTime: 0x0,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
result: &btcws.AllVerboseTxNtfn{
|
result: &btcws.TxAcceptedVerboseNtfn{
|
||||||
RawTx: &btcjson.TxRawResult{
|
RawTx: &btcjson.TxRawResult{
|
||||||
Hex: "01000000010cdf900074a3622499a2f28f44a94476f27a8900a2bdd60e042754b6cab09741000000008a473044022012e11012fad1eb21ba1c82deb8da98778b08e714b72f281293064528343fae0502204294d7520f469f9673087a55395de0ce0e9074dce236db9fe7f30013b5fd00b90141047b6ff7832b4a763666e5481a0bd9eedb656d9f882d215c16fe9563d7b191cd67b2a41601a853a9f9d92773ae6f912ef451a089148e510623759cf55c408efdefffffffff02f4063f00000000001976a914b269e0ceec5d5b5e192cf580ae42341e0f79b0b588aca8c84b02000000001976a91439233c0d43a1411e547c60bad8985bae3530b6af88ac00000000",
|
Hex: "01000000010cdf900074a3622499a2f28f44a94476f27a8900a2bdd60e042754b6cab09741000000008a473044022012e11012fad1eb21ba1c82deb8da98778b08e714b72f281293064528343fae0502204294d7520f469f9673087a55395de0ce0e9074dce236db9fe7f30013b5fd00b90141047b6ff7832b4a763666e5481a0bd9eedb656d9f882d215c16fe9563d7b191cd67b2a41601a853a9f9d92773ae6f912ef451a089148e510623759cf55c408efdefffffffff02f4063f00000000001976a914b269e0ceec5d5b5e192cf580ae42341e0f79b0b588aca8c84b02000000001976a91439233c0d43a1411e547c60bad8985bae3530b6af88ac00000000",
|
||||||
Txid: "0cfeb968fb5d0f6b9a2a1de37c0607a1964dd3e335f203377cec90e03b20869e",
|
Txid: "0cfeb968fb5d0f6b9a2a1de37c0607a1964dd3e335f203377cec90e03b20869e",
|
||||||
|
|
Loading…
Add table
Reference in a new issue