From a03e4829bbe5e2527d8d516b93d85bb43475a2e9 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Sat, 2 Sep 2023 12:17:00 +0700 Subject: [PATCH 1/2] Bitfinex: Error if ws data id/cid is not a float64 --- exchanges/bitfinex/bitfinex_websocket.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index 611f89cf815..3775dcd99f2 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -916,7 +916,9 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error { } case strings.Contains(channelName, wsOrderNewRequest): if data[2] != nil { - if cid, ok := data[2].(float64); ok && cid > 0 { + if cid, ok := data[2].(float64); !ok { + return common.GetTypeAssertError("float64", data[2]) + } else if cid > 0 { if b.Websocket.Match.IncomingWithData(int64(cid), respRaw) { return nil } @@ -926,7 +928,9 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error { case strings.Contains(channelName, wsOrderUpdateRequest), strings.Contains(channelName, wsOrderCancelRequest): if data[0] != nil { - if id, ok := data[0].(float64); ok && id > 0 { + if id, ok := data[0].(float64); !ok { + return common.GetTypeAssertError("float64", data[0]) + } else if id > 0 { if b.Websocket.Match.IncomingWithData(int64(id), respRaw) { return nil } From fb623bffb480418a9bd14d24f77b041b70a726a5 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Thu, 7 Sep 2023 10:08:30 +0700 Subject: [PATCH 2/2] Bitfinex: Add annotation to WS id/cid assest errs --- exchanges/bitfinex/bitfinex_websocket.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exchanges/bitfinex/bitfinex_websocket.go b/exchanges/bitfinex/bitfinex_websocket.go index 3775dcd99f2..bd93a5e0efb 100644 --- a/exchanges/bitfinex/bitfinex_websocket.go +++ b/exchanges/bitfinex/bitfinex_websocket.go @@ -917,7 +917,7 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error { case strings.Contains(channelName, wsOrderNewRequest): if data[2] != nil { if cid, ok := data[2].(float64); !ok { - return common.GetTypeAssertError("float64", data[2]) + return common.GetTypeAssertError("float64", data[2], channelName+" cid") } else if cid > 0 { if b.Websocket.Match.IncomingWithData(int64(cid), respRaw) { return nil @@ -929,7 +929,7 @@ func (b *Bitfinex) handleWSNotification(d []interface{}, respRaw []byte) error { strings.Contains(channelName, wsOrderCancelRequest): if data[0] != nil { if id, ok := data[0].(float64); !ok { - return common.GetTypeAssertError("float64", data[0]) + return common.GetTypeAssertError("float64", data[0], channelName+" id") } else if id > 0 { if b.Websocket.Match.IncomingWithData(int64(id), respRaw) { return nil