From db8a4226c28995c95452cf08b39d1039f90055db Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Thu, 7 Sep 2023 06:43:38 +0100 Subject: [PATCH] Bitfinex: Improve websocket type assertion checks for order processing (#1292) * Bitfinex: Error if ws data id/cid is not a float64 * Bitfinex: Add annotation to WS id/cid assest errs --- 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 f06b35688f3..3a5c617436f 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], channelName+" cid") + } 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], channelName+" id") + } else if id > 0 { if b.Websocket.Match.IncomingWithData(int64(id), respRaw) { return nil }