From 0a4d149481f3561a4360fcce7552647773c03c64 Mon Sep 17 00:00:00 2001 From: Offer Markovich Date: Mon, 10 Dec 2018 22:48:05 +0200 Subject: [PATCH 1/2] fix(swap): allow one extrac block to be created during swap --- lib/swaps/Swaps.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/swaps/Swaps.ts b/lib/swaps/Swaps.ts index ee729a769..622e93abc 100644 --- a/lib/swaps/Swaps.ts +++ b/lib/swaps/Swaps.ts @@ -569,7 +569,8 @@ class Swaps extends EventEmitter { return false; } - if (cltvDelta > resolveRequest.getTimeout() - resolveRequest.getHeightNow()) { + // allow 1 additional one block to be created during the swap + if (cltvDelta - 1 > resolveRequest.getTimeout() - resolveRequest.getHeightNow()) { this.logger.error(`got timeout ${resolveRequest.getTimeout()} at height ${resolveRequest.getHeightNow()}`); this.logger.error(`cltvDelta is ${resolveRequest.getTimeout() - resolveRequest.getHeightNow()} expected delta of ${cltvDelta}`); this.setDealState(deal, SwapState.Error, From 08bf9571404b161ad1f0540e13e42bbb196265e8 Mon Sep 17 00:00:00 2001 From: Offer Markovich Date: Wed, 12 Dec 2018 23:47:12 +0200 Subject: [PATCH 2/2] fix(swap): Avoid fraction in cltvDelta --- lib/swaps/Swaps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/swaps/Swaps.ts b/lib/swaps/Swaps.ts index 622e93abc..afa3c8ead 100644 --- a/lib/swaps/Swaps.ts +++ b/lib/swaps/Swaps.ts @@ -429,10 +429,10 @@ class Swaps extends EventEmitter { const cltvDeltaFactor = this.lndLtcClient.cltvDelta / this.lndBtcClient.cltvDelta; switch (makerCurrency) { case 'BTC': - deal.makerCltvDelta = this.lndBtcClient.cltvDelta + routeCltvDelta / cltvDeltaFactor; + deal.makerCltvDelta = this.lndBtcClient.cltvDelta + Math.ceil(routeCltvDelta / cltvDeltaFactor); break; case 'LTC': - deal.makerCltvDelta = this.lndLtcClient.cltvDelta + routeCltvDelta * cltvDeltaFactor; + deal.makerCltvDelta = this.lndLtcClient.cltvDelta + Math.ceil(routeCltvDelta * cltvDeltaFactor); break; }