@atomiqlabs/lp-lib 14.0.0-dev.24 → 14.0.0-dev.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -115,7 +115,7 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
115
115
  await this.saveSwapData(swap);
116
116
  }
117
117
  }
118
- if (swap.state === SpvVaultSwap_1.SpvVaultSwapState.SENT) {
118
+ if (swap.state === SpvVaultSwap_1.SpvVaultSwapState.SENT || swap.state === SpvVaultSwap_1.SpvVaultSwapState.BTC_CONFIRMED) {
119
119
  //Check if confirmed or double-spent
120
120
  const tx = await this.bitcoinRpc.getTransaction(swap.btcTxId);
121
121
  if (tx == null) {
@@ -123,8 +123,10 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
123
123
  return;
124
124
  }
125
125
  else if (tx.confirmations > 0) {
126
- await swap.setState(SpvVaultSwap_1.SpvVaultSwapState.BTC_CONFIRMED);
127
- await this.saveSwapData(swap);
126
+ if (swap.state !== SpvVaultSwap_1.SpvVaultSwapState.BTC_CONFIRMED) {
127
+ await swap.setState(SpvVaultSwap_1.SpvVaultSwapState.BTC_CONFIRMED);
128
+ await this.saveSwapData(swap);
129
+ }
128
130
  }
129
131
  }
130
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "14.0.0-dev.24",
3
+ "version": "14.0.0-dev.25",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -181,15 +181,17 @@ export class SpvVaultSwapHandler extends SwapHandler<SpvVaultSwap, SpvVaultSwapS
181
181
  }
182
182
  }
183
183
 
184
- if(swap.state===SpvVaultSwapState.SENT) {
184
+ if(swap.state===SpvVaultSwapState.SENT || swap.state===SpvVaultSwapState.BTC_CONFIRMED) {
185
185
  //Check if confirmed or double-spent
186
186
  const tx = await this.bitcoinRpc.getTransaction(swap.btcTxId);
187
187
  if(tx==null) {
188
188
  await this.removeSwapData(swap, SpvVaultSwapState.DOUBLE_SPENT);
189
189
  return;
190
190
  } else if(tx.confirmations > 0) {
191
- await swap.setState(SpvVaultSwapState.BTC_CONFIRMED)
192
- await this.saveSwapData(swap);
191
+ if(swap.state!==SpvVaultSwapState.BTC_CONFIRMED) {
192
+ await swap.setState(SpvVaultSwapState.BTC_CONFIRMED)
193
+ await this.saveSwapData(swap);
194
+ }
193
195
  }
194
196
  }
195
197
  }