Added explicit json key names to new tx notifications

Also added check for nil ID on AllVerboseTxNtfn.UnmarshalJSON to make it
consistent with other notification handling.
This commit is contained in:
Francis Lam 2014-02-09 13:43:02 -05:00
parent bb9d3696b4
commit 0821c583e5

View file

@ -1031,8 +1031,8 @@ func (n *WalletLockStateNtfn) UnmarshalJSON(b []byte) error {
// AllTxNtfn is a type handling custom marshaling and // AllTxNtfn is a type handling custom marshaling and
// unmarshaling of txmined JSON websocket notifications. // unmarshaling of txmined JSON websocket notifications.
type AllTxNtfn struct { type AllTxNtfn struct {
TxID string TxID string `json:"txid"`
Amount int64 Amount int64 `json:"amount"`
} }
// Enforce that AllTxNtfn satisifies the btcjson.Cmd interface. // Enforce that AllTxNtfn satisifies the btcjson.Cmd interface.
@ -1125,7 +1125,7 @@ func (n *AllTxNtfn) UnmarshalJSON(b []byte) error {
// AllVerboseTxNtfn is a type handling custom marshaling and // AllVerboseTxNtfn is a type handling custom marshaling and
// unmarshaling of txmined JSON websocket notifications. // unmarshaling of txmined JSON websocket notifications.
type AllVerboseTxNtfn struct { type AllVerboseTxNtfn struct {
RawTx *btcjson.TxRawResult RawTx *btcjson.TxRawResult `json:"rawtx"`
} }
// Enforce that AllTxNtfn satisifies the btcjson.Cmd interface. // Enforce that AllTxNtfn satisifies the btcjson.Cmd interface.
@ -1187,6 +1187,10 @@ func (n *AllVerboseTxNtfn) UnmarshalJSON(b []byte) error {
return err return err
} }
if r.Id != nil {
return ErrNotANtfn
}
if len(r.Params) != 1 { if len(r.Params) != 1 {
return btcjson.ErrWrongNumberOfParams return btcjson.ErrWrongNumberOfParams
} }