diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c0886a..e782966b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- fixed: Update NowNodes URL's for DASH, GRS, and FIRO. + ## 3.3.0 (2024-08-20) - added: Support for blockbook server connections with "%{key-name}" key parameters diff --git a/src/common/utxobased/info/dash.ts b/src/common/utxobased/info/dash.ts index 17ad7d23..a177cd47 100644 --- a/src/common/utxobased/info/dash.ts +++ b/src/common/utxobased/info/dash.ts @@ -39,7 +39,7 @@ const currencyInfo: EdgeCurrencyInfo = { 'wss://dash3.trezor.io', 'wss://dash4.trezor.io', 'wss://dash5.trezor.io', - 'wss://dashbook.nownodes.io/wss/%{nowNodesApiKey}' + 'wss://dash.nownodes.io/wss/%{nowNodesApiKey}' ], enableCustomServers: false }, diff --git a/src/common/utxobased/info/groestlcoin.ts b/src/common/utxobased/info/groestlcoin.ts index 61a5de34..7bc54baf 100644 --- a/src/common/utxobased/info/groestlcoin.ts +++ b/src/common/utxobased/info/groestlcoin.ts @@ -49,7 +49,7 @@ const engineInfo: EngineInfo = { serverConfigs: [ { type: 'blockbook-nownode', - uris: ['https://grsbook.nownodes.io'] + uris: ['https://grs.nownodes.io'] } ], formats: ['bip49', 'bip84', 'bip44', 'bip32'], diff --git a/src/common/utxobased/info/zcoin.ts b/src/common/utxobased/info/zcoin.ts index bd37578d..04958670 100644 --- a/src/common/utxobased/info/zcoin.ts +++ b/src/common/utxobased/info/zcoin.ts @@ -32,7 +32,7 @@ export const currencyInfo: EdgeCurrencyInfo = { customFeeSettings: ['satPerByte'], blockbookServers: [ 'wss://blockbook.firo.org', - 'wss://firobook.nownodes.io/wss/%{nowNodesApiKey}' + 'wss://firo.nownodes.io/wss/%{nowNodesApiKey}' ], enableCustomServers: false }, diff --git a/src/common/utxobased/network/Socket.ts b/src/common/utxobased/network/Socket.ts index e702be98..c414f574 100644 --- a/src/common/utxobased/network/Socket.ts +++ b/src/common/utxobased/network/Socket.ts @@ -134,7 +134,7 @@ export function makeSocket(uri: string, config: SocketConfig): Socket { let connected = false let cancelConnect = false const timeout: number = 1000 * (config.timeout ?? 30) - let trackedError: unknown | undefined + let trackedError: unknown let timer: NodeJS.Timeout const handleError = (e: unknown): void => { @@ -153,14 +153,14 @@ export function makeSocket(uri: string, config: SocketConfig): Socket { removeIdFromQueue(socketQueueId) } - const onSocketClose = (): void => { + const onSocketClose = (code: number): void => { const errObj = - trackedError != null - ? trackedError instanceof Error - ? trackedError - : new Error(String(trackedError)) - : new Error('Socket closed without error') - log.warn(`onSocketClose with server ${uri}: ${errObj.message}`) + trackedError == null + ? new Error('Socket closed without error') + : trackedError instanceof Error + ? trackedError + : new Error(String(trackedError)) + log.warn(`onSocketClose with server ${uri}: ${code} ${errObj.message}`) clearTimeout(timer) connected = false socket = null @@ -174,8 +174,8 @@ export function makeSocket(uri: string, config: SocketConfig): Socket { pendingRequests = {} try { emitter.emit(SocketEvent.CONNECTION_CLOSE, uri, errObj) - } catch (e) { - log.error(e.message) + } catch (e: unknown) { + log.error(String(e)) } } @@ -403,7 +403,7 @@ export function makeSocket(uri: string, config: SocketConfig): Socket { }, onMessage: onMessage, onError: err => { - trackedError = new Error(String(err)) + trackedError = err }, onClose: onSocketClose } diff --git a/src/common/utxobased/network/nodejsWS.ts b/src/common/utxobased/network/nodejsWS.ts index ee9368f7..dd8935e5 100644 --- a/src/common/utxobased/network/nodejsWS.ts +++ b/src/common/utxobased/network/nodejsWS.ts @@ -22,8 +22,8 @@ export function setupWS( ws.on('error', error => { callbacks.onError(error) }) - ws.on('close', _event => { - callbacks.onClose() + ws.on('close', (code: number, reason: string) => { + callbacks.onClose(code, reason) }) return { diff --git a/src/common/utxobased/network/types.ts b/src/common/utxobased/network/types.ts index d2835131..58de4072 100644 --- a/src/common/utxobased/network/types.ts +++ b/src/common/utxobased/network/types.ts @@ -1,7 +1,12 @@ export interface InnerSocketCallbacks { - onError: (error?: unknown) => void + /** + * Called when the socket closes. + * See rfc6455 section 7.4.1 for status codes. + */ + onClose: (code: number, reason: string) => void + + onError: (error?: Event | Error) => void onMessage: (message: string) => void - onClose: (error?: Error) => void onOpen: () => void } diff --git a/src/common/utxobased/network/windowWS.ts b/src/common/utxobased/network/windowWS.ts index c5de16a9..bf9b1f7f 100644 --- a/src/common/utxobased/network/windowWS.ts +++ b/src/common/utxobased/network/windowWS.ts @@ -17,8 +17,8 @@ export function setupBrowser( socket.onerror = event => { callbacks.onError(event) } - socket.onclose = () => { - callbacks.onClose() + socket.onclose = event => { + callbacks.onClose(event.code, event.reason) } return {