@atomiqlabs/lp-lib 15.0.11 → 15.0.13

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.
@@ -44,6 +44,8 @@ class AmountAssertions {
44
44
  * @throws {DefinedRuntimeError} will throw an error if the response is an error
45
45
  */
46
46
  static handlePluginErrorResponses(res) {
47
+ if (res == null)
48
+ return;
47
49
  if ((0, IPlugin_1.isQuoteThrow)(res))
48
50
  throw {
49
51
  code: 29999,
@@ -344,8 +344,6 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
344
344
  msg: "Used vault not found!"
345
345
  };
346
346
  }
347
- //Check the posted quote with the plugins
348
- AmountAssertions_1.AmountAssertions.handlePluginErrorResponses(await PluginManager_1.PluginManager.onHandlePostedFromBtcQuote(this.type, { chainIdentifier: swap.chainIdentifier, raw: req, parsed: parsedBody, metadata }, swap));
349
347
  //Try parse psbt
350
348
  let transaction;
351
349
  try {
@@ -358,7 +356,6 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
358
356
  msg: "Error parsing PSBT, hex format required!"
359
357
  };
360
358
  }
361
- //Check correct psbt
362
359
  for (let i = 1; i < transaction.inputsLength; i++) { //Skip first vault input
363
360
  const txIn = transaction.getInput(i);
364
361
  if ((0, BitcoinUtils_1.isLegacyInput)(txIn))
@@ -366,6 +363,12 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
366
363
  code: 20514,
367
364
  msg: "Legacy (pre-segwit) inputs in tx are not allowed!"
368
365
  };
366
+ }
367
+ //Check the posted quote with the plugins
368
+ AmountAssertions_1.AmountAssertions.handlePluginErrorResponses(await PluginManager_1.PluginManager.onHandlePostedFromBtcQuote(this.type, { chainIdentifier: swap.chainIdentifier, raw: req, parsed: parsedBody, metadata }, swap));
369
+ //Check correct psbt
370
+ for (let i = 1; i < transaction.inputsLength; i++) { //Skip first vault input
371
+ const txIn = transaction.getInput(i);
369
372
  //Check UTXOs exist and are unspent
370
373
  if (await this.bitcoinRpc.isSpent(Buffer.from(txIn.txid).toString("hex") + ":" + txIn.index.toString(10)))
371
374
  throw {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "15.0.11",
3
+ "version": "15.0.13",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -52,6 +52,7 @@ export abstract class AmountAssertions {
52
52
  * @throws {DefinedRuntimeError} will throw an error if the response is an error
53
53
  */
54
54
  static handlePluginErrorResponses(res: any): void {
55
+ if(res==null) return;
55
56
  if(isQuoteThrow(res)) throw {
56
57
  code: 29999,
57
58
  msg: res.message
@@ -471,13 +471,6 @@ export class SpvVaultSwapHandler extends SwapHandler<SpvVaultSwap, SpvVaultSwapS
471
471
  };
472
472
  }
473
473
 
474
- //Check the posted quote with the plugins
475
- AmountAssertions.handlePluginErrorResponses(await PluginManager.onHandlePostedFromBtcQuote(
476
- this.type,
477
- {chainIdentifier: swap.chainIdentifier, raw: req, parsed: parsedBody, metadata},
478
- swap
479
- ));
480
-
481
474
  //Try parse psbt
482
475
  let transaction: Transaction;
483
476
  try {
@@ -490,13 +483,24 @@ export class SpvVaultSwapHandler extends SwapHandler<SpvVaultSwap, SpvVaultSwapS
490
483
  };
491
484
  }
492
485
 
493
- //Check correct psbt
494
486
  for(let i=1;i<transaction.inputsLength;i++) { //Skip first vault input
495
487
  const txIn = transaction.getInput(i);
496
- if(isLegacyInput(txIn)) throw {
488
+ if (isLegacyInput(txIn)) throw {
497
489
  code: 20514,
498
490
  msg: "Legacy (pre-segwit) inputs in tx are not allowed!"
499
491
  };
492
+ }
493
+
494
+ //Check the posted quote with the plugins
495
+ AmountAssertions.handlePluginErrorResponses(await PluginManager.onHandlePostedFromBtcQuote(
496
+ this.type,
497
+ {chainIdentifier: swap.chainIdentifier, raw: req, parsed: parsedBody, metadata},
498
+ swap
499
+ ));
500
+
501
+ //Check correct psbt
502
+ for(let i=1;i<transaction.inputsLength;i++) { //Skip first vault input
503
+ const txIn = transaction.getInput(i);
500
504
  //Check UTXOs exist and are unspent
501
505
  if(await this.bitcoinRpc.isSpent(Buffer.from(txIn.txid).toString("hex")+":"+txIn.index.toString(10))) throw {
502
506
  code: 20515,