From 0821c583e583ae4732d1dbc214449febda72e4a7 Mon Sep 17 00:00:00 2001 From: Francis Lam Date: Sun, 9 Feb 2014 13:43:02 -0500 Subject: [PATCH] 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. --- notifications.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/notifications.go b/notifications.go index 2d5fa72c..f00683a6 100644 --- a/notifications.go +++ b/notifications.go @@ -1031,8 +1031,8 @@ func (n *WalletLockStateNtfn) UnmarshalJSON(b []byte) error { // AllTxNtfn is a type handling custom marshaling and // unmarshaling of txmined JSON websocket notifications. type AllTxNtfn struct { - TxID string - Amount int64 + TxID string `json:"txid"` + Amount int64 `json:"amount"` } // 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 // unmarshaling of txmined JSON websocket notifications. type AllVerboseTxNtfn struct { - RawTx *btcjson.TxRawResult + RawTx *btcjson.TxRawResult `json:"rawtx"` } // Enforce that AllTxNtfn satisifies the btcjson.Cmd interface. @@ -1187,6 +1187,10 @@ func (n *AllVerboseTxNtfn) UnmarshalJSON(b []byte) error { return err } + if r.Id != nil { + return ErrNotANtfn + } + if len(r.Params) != 1 { return btcjson.ErrWrongNumberOfParams }