diff --git a/lib/lndclient/LndClient.ts b/lib/lndclient/LndClient.ts index 5f3dc5e1e..1b8c17551 100644 --- a/lib/lndclient/LndClient.ts +++ b/lib/lndclient/LndClient.ts @@ -348,7 +348,7 @@ class LndClient extends BaseClient { request.setPubKey(destination); try { const routes = (await this.queryRoutes(request)).getRoutesList(); - this.logger.debug(`got ${routes.length} route(s) to destination: ${routes}`); + this.logger.debug(`got ${routes.length} route(s) to destination ${destination}: ${routes}`); return routes; } catch (err) { if (typeof err.message === 'string' && ( diff --git a/lib/orderbook/OrderBook.ts b/lib/orderbook/OrderBook.ts index 515e3c4a3..2c828988a 100644 --- a/lib/orderbook/OrderBook.ts +++ b/lib/orderbook/OrderBook.ts @@ -374,27 +374,25 @@ class OrderBook extends EventEmitter { onUpdate && onUpdate({ type: PlaceOrderEventType.SwapSuccess, payload: swapResult }); } catch (err) { const failMsg = `swap for ${portion.quantity} failed during order matching`; - let failureReason: SwapFailureReason; - if (typeof err === 'number') { + if (typeof err === 'number' && SwapFailureReason[err] !== undefined) { // treat the error as a SwapFailureReason this.logger.warn(`${failMsg} due to ${SwapFailureReason[err]}, will repeat matching routine for failed quantity`); - failureReason = err; + + const swapFailure: SwapFailure = { + failureReason: err, + orderId: maker.id, + pairId: maker.pairId, + quantity: portion.quantity, + peerPubKey: maker.peerPubKey, + }; + swapFailures.push(swapFailure); + onUpdate && onUpdate({ type: PlaceOrderEventType.SwapFailure, payload: swapFailure }); + await retryFailedSwap(portion.quantity); } else { - this.logger.error(`${failMsg} due to unexpected error, will repeat matching routine for failed quantity`, err); - failureReason = SwapFailureReason.UnknownError; + // treat this as a critical error and abort matching, we only expect SwapFailureReasons to be thrown in the try block above + this.logger.error(`${failMsg} due to unexpected error`, err); throw err; } - - const swapFailure: SwapFailure = { - failureReason, - orderId: maker.id, - pairId: maker.pairId, - quantity: portion.quantity, - peerPubKey: maker.peerPubKey, - }; - swapFailures.push(swapFailure); - onUpdate && onUpdate({ type: PlaceOrderEventType.SwapFailure, payload: swapFailure }); - await retryFailedSwap(portion.quantity); } } };