@atomicfinance/bitcoin-dlc-provider 3.4.7 → 3.5.1

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.
@@ -24,7 +24,7 @@ class BitcoinDlcProvider extends provider_1.default {
24
24
  }
25
25
  async CfdLoaded() {
26
26
  while (!this._cfdDlcJs) {
27
- await utils_1.sleep(10);
27
+ await (0, utils_1.sleep)(10);
28
28
  }
29
29
  }
30
30
  async GetPrivKeysForInputs(inputs) {
@@ -86,8 +86,8 @@ class BitcoinDlcProvider extends provider_1.default {
86
86
  const fundingInputs = await Promise.all(inputs.map(async (input) => {
87
87
  return this.inputToFundingInput(input);
88
88
  }));
89
- const payoutSerialId = Utils_1.generateSerialId();
90
- const changeSerialId = Utils_1.generateSerialId();
89
+ const payoutSerialId = (0, Utils_1.generateSerialId)();
90
+ const changeSerialId = (0, Utils_1.generateSerialId)();
91
91
  return {
92
92
  fundingPubKey,
93
93
  payoutSPK,
@@ -104,7 +104,7 @@ class BitcoinDlcProvider extends provider_1.default {
104
104
  return this.inputToFundingInput(input);
105
105
  }));
106
106
  const initializeResponses = [];
107
- const changeSerialId = Utils_1.generateSerialId();
107
+ const changeSerialId = (0, Utils_1.generateSerialId)();
108
108
  const changeAddress = await this.client.wallet.getUnusedAddress(true);
109
109
  const changeSPK = bitcoinjs_lib_1.address.toOutputScript(changeAddress.address, network);
110
110
  for (let i = 0; i < collaterals.length; i++) {
@@ -114,7 +114,7 @@ class BitcoinDlcProvider extends provider_1.default {
114
114
  const fundingPubKey = Buffer.from(fundingAddress.publicKey, 'hex');
115
115
  if (fundingAddress.address === payoutAddress.address)
116
116
  throw Error('Address reuse');
117
- const payoutSerialId = Utils_1.generateSerialId();
117
+ const payoutSerialId = (0, Utils_1.generateSerialId)();
118
118
  initializeResponses.push({
119
119
  fundingPubKey,
120
120
  payoutSPK,
@@ -159,11 +159,11 @@ class BitcoinDlcProvider extends provider_1.default {
159
159
  cetPayouts.forEach((p) => {
160
160
  payoutGroups.push({
161
161
  payout: p.payout,
162
- groups: core_1.groupByIgnoringDigits(p.indexFrom, p.indexTo, eventDescriptor.base, contractDescriptor.numDigits),
162
+ groups: (0, core_1.groupByIgnoringDigits)(p.indexFrom, p.indexTo, eventDescriptor.base, contractDescriptor.numDigits),
163
163
  });
164
164
  });
165
165
  const rValuesMessagesList = this.GenerateMessages(oracleInfo);
166
- const { payouts, messagesList } = Utils_1.outputsToPayouts(payoutGroups, rValuesMessagesList, dlcOffer.offerCollateralSatoshis, dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateralSatoshis, true);
166
+ const { payouts, messagesList } = (0, Utils_1.outputsToPayouts)(payoutGroups, rValuesMessagesList, dlcOffer.offerCollateralSatoshis, dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateralSatoshis, true);
167
167
  return { payouts, payoutGroups, messagesList };
168
168
  }
169
169
  GetPayoutsFromPolynomialPayoutFunction(_dlcOffer, contractDescriptor, oracleInfo, totalCollateral) {
@@ -189,15 +189,15 @@ class BitcoinDlcProvider extends provider_1.default {
189
189
  cetPayouts.forEach((p) => {
190
190
  payoutGroups.push({
191
191
  payout: p.payout,
192
- groups: core_1.groupByIgnoringDigits(p.indexFrom, p.indexTo, eventDescriptor.base, contractDescriptor.numDigits),
192
+ groups: (0, core_1.groupByIgnoringDigits)(p.indexFrom, p.indexTo, eventDescriptor.base, contractDescriptor.numDigits),
193
193
  });
194
194
  });
195
195
  const rValuesMessagesList = this.GenerateMessages(oracleInfo);
196
- const { payouts, messagesList } = Utils_1.outputsToPayouts(payoutGroups, rValuesMessagesList, dlcOffer.offerCollateralSatoshis, dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateralSatoshis, true);
196
+ const { payouts, messagesList } = (0, Utils_1.outputsToPayouts)(payoutGroups, rValuesMessagesList, dlcOffer.offerCollateralSatoshis, dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateralSatoshis, true);
197
197
  return { payouts, payoutGroups, messagesList };
198
198
  }
199
199
  GetPayouts(_dlcOffer) {
200
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
200
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
201
201
  const contractInfo = dlcOffer.contractInfo;
202
202
  const totalCollateral = contractInfo.totalCollateral;
203
203
  const contractOraclePairs = this.GetContractOraclePairs(contractInfo);
@@ -250,7 +250,7 @@ class BitcoinDlcProvider extends provider_1.default {
250
250
  }
251
251
  }
252
252
  async createDlcTxs(_dlcOffer, _dlcAccept) {
253
- const { dlcOffer, dlcAccept } = Utils_1.checkTypes({
253
+ const { dlcOffer, dlcAccept } = (0, Utils_1.checkTypes)({
254
254
  _dlcOffer,
255
255
  _dlcAccept,
256
256
  });
@@ -313,10 +313,10 @@ class BitcoinDlcProvider extends provider_1.default {
313
313
  }
314
314
  async createBatchDlcTxs(_dlcOffers, _dlcAccepts) {
315
315
  const dlcOffers = _dlcOffers.map((dlcOffer) => {
316
- return Utils_1.checkTypes({ _dlcOffer: dlcOffer }).dlcOffer;
316
+ return (0, Utils_1.checkTypes)({ _dlcOffer: dlcOffer }).dlcOffer;
317
317
  });
318
318
  const dlcAccepts = _dlcAccepts.map((dlcAccept) => {
319
- return Utils_1.checkTypes({ _dlcAccept: dlcAccept }).dlcAccept;
319
+ return (0, Utils_1.checkTypes)({ _dlcAccept: dlcAccept }).dlcAccept;
320
320
  });
321
321
  const localFundPubkeys = dlcOffers.map((dlcOffer) => dlcOffer.fundingPubKey.toString('hex'));
322
322
  const remoteFundPubkeys = dlcAccepts.map((dlcAccept) => dlcAccept.fundingPubKey.toString('hex'));
@@ -446,14 +446,14 @@ class BitcoinDlcProvider extends provider_1.default {
446
446
  }
447
447
  }
448
448
  async CreateCetAdaptorAndRefundSigs(_dlcOffer, _dlcAccept, _dlcTxs, messagesList, isOfferer) {
449
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
449
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
450
450
  _dlcOffer,
451
451
  _dlcAccept,
452
452
  _dlcTxs,
453
453
  });
454
454
  const network = await this.getConnectedNetwork();
455
455
  const cetsHex = dlcTxs.cets.map((cet) => cet.serialize().toString('hex'));
456
- const fundingSPK = bitcoin_1.Script.p2wpkhLock(crypto_1.hash160(isOfferer ? dlcOffer.fundingPubKey : dlcAccept.fundingPubKey))
456
+ const fundingSPK = bitcoin_1.Script.p2wpkhLock((0, crypto_1.hash160)(isOfferer ? dlcOffer.fundingPubKey : dlcAccept.fundingPubKey))
457
457
  .serialize()
458
458
  .slice(1);
459
459
  const fundingAddress = bitcoinjs_lib_1.address.fromOutputScript(fundingSPK, network);
@@ -515,7 +515,7 @@ class BitcoinDlcProvider extends provider_1.default {
515
515
  return { cetSignatures, refundSignature };
516
516
  }
517
517
  async VerifyCetAdaptorAndRefundSigs(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs, messagesList, isOfferer) {
518
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
518
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
519
519
  _dlcOffer,
520
520
  _dlcAccept,
521
521
  _dlcSign,
@@ -584,7 +584,7 @@ class BitcoinDlcProvider extends provider_1.default {
584
584
  }
585
585
  }
586
586
  async CreateFundingSigs(_dlcOffer, _dlcAccept, _dlcTxs, isOfferer) {
587
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
587
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
588
588
  _dlcOffer,
589
589
  _dlcAccept,
590
590
  _dlcTxs,
@@ -627,7 +627,7 @@ class BitcoinDlcProvider extends provider_1.default {
627
627
  return fundingSignatures;
628
628
  }
629
629
  async VerifyFundingSigs(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs, isOfferer) {
630
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
630
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
631
631
  _dlcOffer,
632
632
  _dlcAccept,
633
633
  _dlcSign,
@@ -660,7 +660,7 @@ class BitcoinDlcProvider extends provider_1.default {
660
660
  }
661
661
  }
662
662
  async CreateFundingTx(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs, fundingSignatures) {
663
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
663
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
664
664
  _dlcOffer,
665
665
  _dlcAccept,
666
666
  _dlcSign,
@@ -675,7 +675,7 @@ class BitcoinDlcProvider extends provider_1.default {
675
675
  ...dlcAccept.fundingInputs,
676
676
  ];
677
677
  let fundTxHex = dlcTxs.fundTx.serialize().toString('hex');
678
- await Utils_1.asyncForEach(witnessElements, async (witnessElement, i) => {
678
+ await (0, Utils_1.asyncForEach)(witnessElements, async (witnessElement, i) => {
679
679
  const signature = witnessElement[0].witness.toString('hex');
680
680
  const pubkey = witnessElement[1].witness.toString('hex');
681
681
  const fundingInput = fundingInputs[i];
@@ -693,7 +693,7 @@ class BitcoinDlcProvider extends provider_1.default {
693
693
  return fundTx;
694
694
  }
695
695
  async FindOutcomeIndexFromPolynomialPayoutCurvePiece(_dlcOffer, contractDescriptor, contractOraclePairIndex, polynomialPayoutCurvePiece, oracleAttestation, outcome) {
696
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
696
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
697
697
  const polynomialCurve = core_1.PolynomialPayoutCurve.fromPayoutCurvePiece(polynomialPayoutCurvePiece);
698
698
  const payouts = polynomialPayoutCurvePiece.points.map((point) => Number(point.outcomePayout));
699
699
  const minPayout = Math.min(...payouts);
@@ -707,7 +707,7 @@ class BitcoinDlcProvider extends provider_1.default {
707
707
  ...contractDescriptor.roundingIntervals.intervals,
708
708
  ].sort((a, b) => Number(b.beginInterval) - Number(a.beginInterval));
709
709
  const interval = intervalsSorted.find((interval) => Number(outcome) >= Number(interval.beginInterval));
710
- const roundedPayout = BigInt(clampBN(new bignumber_js_1.default(core_1.roundPayout(payout, interval.roundingMod).toString())).toString());
710
+ const roundedPayout = BigInt(clampBN(new bignumber_js_1.default((0, core_1.roundPayout)(payout, interval.roundingMod).toString())).toString());
711
711
  const outcomesFormatted = oracleAttestation.outcomes.map((outcome) => parseInt(outcome));
712
712
  let index = 0;
713
713
  let groupIndex = -1;
@@ -734,7 +734,7 @@ Payout Group not found');
734
734
  return { index: payoutIndexOffset + index, groupLength };
735
735
  }
736
736
  async FindOutcomeIndexFromHyperbolaPayoutCurvePiece(_dlcOffer, contractDescriptor, contractOraclePairIndex, hyperbolaPayoutCurvePiece, oracleAttestation, outcome) {
737
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
737
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
738
738
  const hyperbolaCurve = core_1.HyperbolaPayoutCurve.fromPayoutCurvePiece(hyperbolaPayoutCurvePiece);
739
739
  const clampBN = (val) => bignumber_js_1.default.max(0, bignumber_js_1.default.min(val, dlcOffer.contractInfo.totalCollateral.toString()));
740
740
  const payout = clampBN(hyperbolaCurve.getPayout(outcome));
@@ -745,12 +745,11 @@ Payout Group not found');
745
745
  ...contractDescriptor.roundingIntervals.intervals,
746
746
  ].sort((a, b) => Number(b.beginInterval) - Number(a.beginInterval));
747
747
  const interval = intervalsSorted.find((interval) => Number(outcome) >= Number(interval.beginInterval));
748
- const roundedPayout = BigInt(clampBN(new bignumber_js_1.default(core_1.roundPayout(payout, interval.roundingMod).toString())).toString());
748
+ const roundedPayout = BigInt(clampBN(new bignumber_js_1.default((0, core_1.roundPayout)(payout, interval.roundingMod).toString())).toString());
749
749
  const outcomesFormatted = oracleAttestation.outcomes.map((outcome) => parseInt(outcome));
750
750
  let index = 0;
751
751
  let groupIndex = -1;
752
752
  let groupLength = 0;
753
- const payoutGroupFound = false;
754
753
  for (const [i, payoutGroup] of payoutGroups.entries()) {
755
754
  if (payoutGroup.payout === roundedPayout) {
756
755
  groupIndex = payoutGroup.groups.findIndex((group) => {
@@ -762,7 +761,8 @@ Payout Group not found');
762
761
  break;
763
762
  }
764
763
  }
765
- else if (payoutGroup.payout === BigInt(Math.round(Number(payout.toString())))) {
764
+ else if (payoutGroup.payout === BigInt(Math.round(Number(payout.toString()))) &&
765
+ i !== 0) {
766
766
  // Edge case to account for case where payout is maximum payout for DLC
767
767
  // But rounded payout does not round down
768
768
  if (payoutGroups[i - 1].payout === roundedPayout) {
@@ -783,29 +783,23 @@ Payout Group not found');
783
783
  }
784
784
  }
785
785
  if (groupIndex === -1) {
786
- if (payoutGroupFound) {
787
- throw Error('Failed to Find OutcomeIndex From HyperbolaPayoutCurvePiece. \
788
- Payout Group found but incorrect group index');
789
- }
790
- else {
791
- throw Error('Failed to Find OutcomeIndex From HyperbolaPayoutCurvePiece. \
792
- Payout Group not found');
793
- }
786
+ throw Error('Failed to Find OutcomeIndex From HyperbolaPayoutCurvePiece. \
787
+ Payout Group not found');
794
788
  }
795
789
  return { index: payoutIndexOffset + index, groupLength };
796
790
  }
797
791
  async FindOutcomeIndex(_dlcOffer, oracleAttestation) {
798
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
792
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
799
793
  const contractOraclePairs = this.GetContractOraclePairs(dlcOffer.contractInfo);
800
794
  const contractOraclePairIndex = contractOraclePairs.findIndex(({ oracleInfo }) => oracleInfo.announcement.oracleEvent.eventId ===
801
795
  oracleAttestation.eventId);
802
- assert_1.default(contractOraclePairIndex !== -1, 'OracleAttestation must be for an existing OracleEvent');
796
+ (0, assert_1.default)(contractOraclePairIndex !== -1, 'OracleAttestation must be for an existing OracleEvent');
803
797
  const contractOraclePair = contractOraclePairs[contractOraclePairIndex];
804
798
  const { contractDescriptor: _contractDescriptor, oracleInfo, } = contractOraclePair;
805
- assert_1.default(_contractDescriptor.type === messaging_1.MessageType.ContractDescriptorV1, 'ContractDescriptor must be V1');
799
+ (0, assert_1.default)(_contractDescriptor.type === messaging_1.MessageType.ContractDescriptorV1, 'ContractDescriptor must be V1');
806
800
  const contractDescriptor = _contractDescriptor;
807
801
  const _payoutFunction = contractDescriptor.payoutFunction;
808
- assert_1.default(_payoutFunction.type === messaging_1.MessageType.PayoutFunctionV0, 'PayoutFunction must be V0');
802
+ (0, assert_1.default)(_payoutFunction.type === messaging_1.MessageType.PayoutFunctionV0, 'PayoutFunction must be V0');
809
803
  const eventDescriptor = oracleInfo.announcement.oracleEvent
810
804
  .eventDescriptor;
811
805
  const payoutFunction = _payoutFunction;
@@ -827,7 +821,7 @@ Payout Group found but incorrect group index');
827
821
  }
828
822
  }
829
823
  ValidateEvent(_dlcOffer, oracleAttestation) {
830
- const { dlcOffer } = Utils_1.checkTypes({
824
+ const { dlcOffer } = (0, Utils_1.checkTypes)({
831
825
  _dlcOffer,
832
826
  });
833
827
  switch (dlcOffer.contractInfo.type) {
@@ -861,7 +855,7 @@ Payout Group found but incorrect group index');
861
855
  }
862
856
  }
863
857
  async FindAndSignCet(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs, oracleAttestation, isOfferer) {
864
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
858
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
865
859
  _dlcOffer,
866
860
  _dlcAccept,
867
861
  _dlcSign,
@@ -893,7 +887,7 @@ Payout Group found but incorrect group index');
893
887
  }
894
888
  async GetFundAddress(dlcOffer, dlcAccept, isOfferer) {
895
889
  const network = await this.getConnectedNetwork();
896
- const fundingSPK = bitcoin_1.Script.p2wpkhLock(crypto_1.hash160(isOfferer ? dlcOffer.fundingPubKey : dlcAccept.fundingPubKey))
890
+ const fundingSPK = bitcoin_1.Script.p2wpkhLock((0, crypto_1.hash160)(isOfferer ? dlcOffer.fundingPubKey : dlcAccept.fundingPubKey))
897
891
  .serialize()
898
892
  .slice(1);
899
893
  const fundingAddress = bitcoinjs_lib_1.address.fromOutputScript(fundingSPK, network);
@@ -910,7 +904,7 @@ Payout Group found but incorrect group index');
910
904
  return Buffer.from(fundPrivateKeyPair.privateKey).toString('hex');
911
905
  }
912
906
  async CreateCloseRawTxs(_dlcOffer, _dlcAccept, _dlcTxs, closeInputAmount, isOfferer, _dlcCloses = [], fundingInputs, initiatorPayouts) {
913
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
907
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
914
908
  _dlcOffer,
915
909
  _dlcAccept,
916
910
  _dlcTxs,
@@ -942,7 +936,7 @@ Payout Group found but incorrect group index');
942
936
  : closeInputAmount + payoutMinusOfferFees;
943
937
  }
944
938
  else {
945
- const dlcClose = Utils_1.checkTypes({ _dlcClose: _dlcCloses[i] }).dlcClose;
939
+ const dlcClose = (0, Utils_1.checkTypes)({ _dlcClose: _dlcCloses[i] }).dlcClose;
946
940
  offerPayoutValue = dlcClose.offerPayoutSatoshis;
947
941
  acceptPayoutValue = dlcClose.acceptPayoutSatoshis;
948
942
  }
@@ -983,7 +977,7 @@ Payout Group found but incorrect group index');
983
977
  return rawCloseTxs.flat();
984
978
  }
985
979
  async CreateSignatureHashes(_dlcOffer, _dlcAccept, _dlcTxs, rawCloseTxs) {
986
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
980
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
987
981
  _dlcOffer,
988
982
  _dlcAccept,
989
983
  _dlcTxs,
@@ -1052,12 +1046,12 @@ Payout Group found but incorrect group index');
1052
1046
  return sigs.flat();
1053
1047
  }
1054
1048
  async VerifySignatures(_dlcOffer, _dlcAccept, _dlcTxs, _dlcCloses, rawCloseTxs, isOfferer) {
1055
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
1049
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
1056
1050
  _dlcOffer,
1057
1051
  _dlcAccept,
1058
1052
  _dlcTxs,
1059
1053
  });
1060
- const dlcCloses = _dlcCloses.map((_dlcClose) => Utils_1.checkTypes({ _dlcClose }).dlcClose);
1054
+ const dlcCloses = _dlcCloses.map((_dlcClose) => (0, Utils_1.checkTypes)({ _dlcClose }).dlcClose);
1061
1055
  const network = await this.getConnectedNetwork();
1062
1056
  const fundingPubKeys = Buffer.compare(dlcOffer.fundingPubKey, dlcAccept.fundingPubKey) === -1
1063
1057
  ? [dlcOffer.fundingPubKey, dlcAccept.fundingPubKey]
@@ -1105,15 +1099,15 @@ Payout Group found but incorrect group index');
1105
1099
  * @returns {Promise<boolean>}
1106
1100
  */
1107
1101
  async isOfferer(_dlcOffer, _dlcAccept) {
1108
- const { dlcOffer, dlcAccept } = Utils_1.checkTypes({
1102
+ const { dlcOffer, dlcAccept } = (0, Utils_1.checkTypes)({
1109
1103
  _dlcOffer,
1110
1104
  _dlcAccept,
1111
1105
  });
1112
1106
  const network = await this.getConnectedNetwork();
1113
- const offerFundingSPK = bitcoin_1.Script.p2wpkhLock(crypto_1.hash160(dlcOffer.fundingPubKey))
1107
+ const offerFundingSPK = bitcoin_1.Script.p2wpkhLock((0, crypto_1.hash160)(dlcOffer.fundingPubKey))
1114
1108
  .serialize()
1115
1109
  .slice(1);
1116
- const acceptFundingSPK = bitcoin_1.Script.p2wpkhLock(crypto_1.hash160(dlcAccept.fundingPubKey))
1110
+ const acceptFundingSPK = bitcoin_1.Script.p2wpkhLock((0, crypto_1.hash160)(dlcAccept.fundingPubKey))
1117
1111
  .serialize()
1118
1112
  .slice(1);
1119
1113
  const offerFundingAddress = bitcoinjs_lib_1.address.fromOutputScript(offerFundingSPK, network);
@@ -1144,13 +1138,13 @@ Payout Group found but incorrect group index');
1144
1138
  const network = await this.getConnectedNetwork();
1145
1139
  const dlcOffer = new messaging_1.DlcOfferV0();
1146
1140
  const { fundingPubKey, payoutSPK, payoutSerialId, fundingInputs: _fundingInputs, changeSPK, changeSerialId, } = await this.Initialize(offerCollateralSatoshis, feeRatePerVb, fixedInputs);
1147
- _fundingInputs.forEach((input) => assert_1.default(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1141
+ _fundingInputs.forEach((input) => (0, assert_1.default)(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1148
1142
  const fundingInputs = _fundingInputs.map((input) => input);
1149
1143
  fundingInputs.sort((a, b) => Number(a.inputSerialId) - Number(b.inputSerialId));
1150
- const fundOutputSerialId = Utils_1.generateSerialId();
1151
- assert_1.default(changeSerialId !== fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1144
+ const fundOutputSerialId = (0, Utils_1.generateSerialId)();
1145
+ (0, assert_1.default)(changeSerialId !== fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1152
1146
  dlcOffer.contractFlags = Buffer.from('00', 'hex');
1153
- dlcOffer.chainHash = bitcoin_networks_1.chainHashFromNetwork(network);
1147
+ dlcOffer.chainHash = (0, bitcoin_networks_1.chainHashFromNetwork)(network);
1154
1148
  dlcOffer.contractInfo = contractInfo;
1155
1149
  dlcOffer.fundingPubKey = fundingPubKey;
1156
1150
  dlcOffer.payoutSPK = payoutSPK;
@@ -1163,7 +1157,7 @@ Payout Group found but incorrect group index');
1163
1157
  dlcOffer.feeRatePerVb = feeRatePerVb;
1164
1158
  dlcOffer.cetLocktime = cetLocktime;
1165
1159
  dlcOffer.refundLocktime = refundLocktime;
1166
- assert_1.default((() => {
1160
+ (0, assert_1.default)((() => {
1167
1161
  const finalizer = new core_1.DualFundingTxFinalizer(dlcOffer.fundingInputs, dlcOffer.payoutSPK, dlcOffer.changeSPK, null, null, null, dlcOffer.feeRatePerVb);
1168
1162
  const funding = fundingInputs.reduce((total, input) => {
1169
1163
  return total + input.prevTx.outputs[input.prevTxVout].value.sats;
@@ -1184,10 +1178,10 @@ Payout Group found but incorrect group index');
1184
1178
  }
1185
1179
  const network = await this.getConnectedNetwork();
1186
1180
  const { fundingInputs: _fundingInputs, changeSPK, changeSerialId, initializeResponses, } = await this.BatchInitialize(offerCollaterals, feeRatePerVb, fixedInputs);
1187
- _fundingInputs.forEach((input) => assert_1.default(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1181
+ _fundingInputs.forEach((input) => (0, assert_1.default)(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1188
1182
  const fundingInputs = _fundingInputs.map((input) => input);
1189
1183
  fundingInputs.sort((a, b) => Number(a.inputSerialId) - Number(b.inputSerialId));
1190
- const fundOutputsSerialIds = Utils_1.generateSerialIds(contractInfos.length);
1184
+ const fundOutputsSerialIds = (0, Utils_1.generateSerialIds)(contractInfos.length);
1191
1185
  for (let i = 0; i < contractInfos.length; i++) {
1192
1186
  const contractInfo = contractInfos[i];
1193
1187
  const offerCollateralSatoshis = offerCollaterals[i];
@@ -1196,7 +1190,7 @@ Payout Group found but incorrect group index');
1196
1190
  const refundLocktime = refundLocktimes[i];
1197
1191
  const dlcOffer = new messaging_1.DlcOfferV0();
1198
1192
  dlcOffer.contractFlags = Buffer.from('00', 'hex');
1199
- dlcOffer.chainHash = bitcoin_networks_1.chainHashFromNetwork(network);
1193
+ dlcOffer.chainHash = (0, bitcoin_networks_1.chainHashFromNetwork)(network);
1200
1194
  dlcOffer.contractInfo = contractInfo;
1201
1195
  dlcOffer.fundingPubKey = fundingPubKey;
1202
1196
  dlcOffer.payoutSPK = payoutSPK;
@@ -1209,7 +1203,7 @@ Payout Group found but incorrect group index');
1209
1203
  dlcOffer.feeRatePerVb = feeRatePerVb;
1210
1204
  dlcOffer.cetLocktime = cetLocktime;
1211
1205
  dlcOffer.refundLocktime = refundLocktime;
1212
- assert_1.default((() => {
1206
+ (0, assert_1.default)((() => {
1213
1207
  const finalizer = new core_1.DualFundingTxFinalizer(dlcOffer.fundingInputs, dlcOffer.payoutSPK, dlcOffer.changeSPK, null, null, null, dlcOffer.feeRatePerVb);
1214
1208
  const funding = fundingInputs.reduce((total, input) => {
1215
1209
  return total + input.prevTx.outputs[input.prevTxVout].value.sats;
@@ -1228,19 +1222,19 @@ Payout Group found but incorrect group index');
1228
1222
  * @returns {Promise<AcceptDlcOfferResponse}
1229
1223
  */
1230
1224
  async acceptDlcOffer(_dlcOffer, fixedInputs) {
1231
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
1225
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
1232
1226
  dlcOffer.validate();
1233
1227
  const acceptCollateralSatoshis = dlcOffer.contractInfo.totalCollateral - dlcOffer.offerCollateralSatoshis;
1234
- assert_1.default(acceptCollateralSatoshis ===
1228
+ (0, assert_1.default)(acceptCollateralSatoshis ===
1235
1229
  dlcOffer.contractInfo.totalCollateral -
1236
1230
  dlcOffer.offerCollateralSatoshis, 'acceptCollaterialSatoshis should equal totalCollateral - offerCollateralSatoshis');
1237
1231
  const { fundingPubKey, payoutSPK, payoutSerialId, fundingInputs: _fundingInputs, changeSPK, changeSerialId, } = await this.Initialize(acceptCollateralSatoshis, dlcOffer.feeRatePerVb, fixedInputs);
1238
- assert_1.default(Buffer.compare(dlcOffer.fundingPubKey, fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1239
- _fundingInputs.forEach((input) => assert_1.default(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1232
+ (0, assert_1.default)(Buffer.compare(dlcOffer.fundingPubKey, fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1233
+ _fundingInputs.forEach((input) => (0, assert_1.default)(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1240
1234
  const fundingInputs = _fundingInputs.map((input) => input);
1241
1235
  fundingInputs.sort((a, b) => Number(a.inputSerialId) - Number(b.inputSerialId));
1242
1236
  const dlcAccept = new messaging_1.DlcAcceptV0();
1243
- dlcAccept.tempContractId = crypto_1.sha256(dlcOffer.serialize());
1237
+ dlcAccept.tempContractId = (0, crypto_1.sha256)(dlcOffer.serialize());
1244
1238
  dlcAccept.acceptCollateralSatoshis = acceptCollateralSatoshis;
1245
1239
  dlcAccept.fundingPubKey = fundingPubKey;
1246
1240
  dlcAccept.payoutSPK = payoutSPK;
@@ -1248,9 +1242,9 @@ Payout Group found but incorrect group index');
1248
1242
  dlcAccept.fundingInputs = fundingInputs;
1249
1243
  dlcAccept.changeSPK = changeSPK;
1250
1244
  dlcAccept.changeSerialId = dlcAccept.changeSerialId = changeSerialId;
1251
- assert_1.default(dlcAccept.changeSerialId !== dlcOffer.fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1252
- assert_1.default(dlcOffer.payoutSerialId !== dlcAccept.payoutSerialId, 'offer.payoutSerialId cannot equal accept.payoutSerialId');
1253
- assert_1.default((() => {
1245
+ (0, assert_1.default)(dlcAccept.changeSerialId !== dlcOffer.fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1246
+ (0, assert_1.default)(dlcOffer.payoutSerialId !== dlcAccept.payoutSerialId, 'offer.payoutSerialId cannot equal accept.payoutSerialId');
1247
+ (0, assert_1.default)((() => {
1254
1248
  const ids = [
1255
1249
  dlcOffer.changeSerialId,
1256
1250
  dlcAccept.changeSerialId,
@@ -1259,7 +1253,7 @@ Payout Group found but incorrect group index');
1259
1253
  return new Set(ids).size === ids.length;
1260
1254
  })(), 'offer.changeSerialID, accept.changeSerialId and fundOutputSerialId must be unique');
1261
1255
  dlcAccept.validate();
1262
- assert_1.default((() => {
1256
+ (0, assert_1.default)((() => {
1263
1257
  const finalizer = new core_1.DualFundingTxFinalizer(dlcOffer.fundingInputs, dlcOffer.payoutSPK, dlcOffer.changeSPK, dlcAccept.fundingInputs, dlcAccept.payoutSPK, dlcAccept.changeSPK, dlcOffer.feeRatePerVb);
1264
1258
  const funding = fundingInputs.reduce((total, input) => {
1265
1259
  return total + input.prevTx.outputs[input.prevTxVout].value.sats;
@@ -1268,9 +1262,9 @@ Payout Group found but incorrect group index');
1268
1262
  })(), 'fundingInputs for dlcAccept must be greater than acceptCollateralSatoshis plus acceptFees');
1269
1263
  const { dlcTransactions, messagesList } = await this.createDlcTxs(dlcOffer, dlcAccept);
1270
1264
  const { cetSignatures, refundSignature, } = await this.CreateCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcTransactions, messagesList, false);
1271
- assert_1.default(dlcTransactions.type === messaging_1.MessageType.DlcTransactionsV0, 'DlcTransactions must be V0');
1265
+ (0, assert_1.default)(dlcTransactions.type === messaging_1.MessageType.DlcTransactionsV0, 'DlcTransactions must be V0');
1272
1266
  const _dlcTransactions = dlcTransactions;
1273
- const contractId = crypto_1.xor(_dlcTransactions.fundTx.txId.serialize(), dlcAccept.tempContractId);
1267
+ const contractId = (0, crypto_1.xor)(_dlcTransactions.fundTx.txId.serialize(), dlcAccept.tempContractId);
1274
1268
  _dlcTransactions.contractId = contractId;
1275
1269
  dlcAccept.cetSignatures = cetSignatures;
1276
1270
  dlcAccept.refundSignature = refundSignature;
@@ -1279,7 +1273,7 @@ Payout Group found but incorrect group index');
1279
1273
  }
1280
1274
  async batchAcceptDlcOffer(_dlcOffers, fixedInputs) {
1281
1275
  const dlcOffers = _dlcOffers.map((_dlcOffer) => {
1282
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
1276
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
1283
1277
  dlcOffer.validate();
1284
1278
  return dlcOffer;
1285
1279
  });
@@ -1290,10 +1284,10 @@ Payout Group found but incorrect group index');
1290
1284
  // dlcOffers and the dlcAccepts (from initializeResponses)
1291
1285
  dlcOffers.forEach((dlcOffer) => {
1292
1286
  initializeResponses.forEach((initializeResponse) => {
1293
- assert_1.default(Buffer.compare(dlcOffer.fundingPubKey, initializeResponse.fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1287
+ (0, assert_1.default)(Buffer.compare(dlcOffer.fundingPubKey, initializeResponse.fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1294
1288
  });
1295
1289
  });
1296
- _fundingInputs.forEach((input) => assert_1.default(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1290
+ _fundingInputs.forEach((input) => (0, assert_1.default)(input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0'));
1297
1291
  const fundingInputs = _fundingInputs.map((input) => input);
1298
1292
  fundingInputs.sort((a, b) => Number(a.inputSerialId) - Number(b.inputSerialId));
1299
1293
  const dlcAccepts = [];
@@ -1301,7 +1295,7 @@ Payout Group found but incorrect group index');
1301
1295
  const dlcOffer = dlcOffers[i];
1302
1296
  const dlcAccept = new messaging_1.DlcAcceptV0();
1303
1297
  const { fundingPubKey, payoutSPK, payoutSerialId } = initializeResponse;
1304
- dlcAccept.tempContractId = crypto_1.sha256(dlcOffers[i].serialize());
1298
+ dlcAccept.tempContractId = (0, crypto_1.sha256)(dlcOffers[i].serialize());
1305
1299
  dlcAccept.acceptCollateralSatoshis = acceptCollaterals[i];
1306
1300
  dlcAccept.fundingPubKey = fundingPubKey;
1307
1301
  dlcAccept.payoutSPK = payoutSPK;
@@ -1309,9 +1303,9 @@ Payout Group found but incorrect group index');
1309
1303
  dlcAccept.fundingInputs = fundingInputs;
1310
1304
  dlcAccept.changeSPK = changeSPK;
1311
1305
  dlcAccept.changeSerialId = changeSerialId;
1312
- assert_1.default(dlcAccept.changeSerialId !== dlcOffer.fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1313
- assert_1.default(dlcOffer.payoutSerialId !== dlcAccept.payoutSerialId, 'offer.payoutSerialId cannot equal accept.payoutSerialId');
1314
- assert_1.default((() => {
1306
+ (0, assert_1.default)(dlcAccept.changeSerialId !== dlcOffer.fundOutputSerialId, 'changeSerialId cannot equal the fundOutputSerialId');
1307
+ (0, assert_1.default)(dlcOffer.payoutSerialId !== dlcAccept.payoutSerialId, 'offer.payoutSerialId cannot equal accept.payoutSerialId');
1308
+ (0, assert_1.default)((() => {
1315
1309
  const ids = [
1316
1310
  dlcOffer.changeSerialId,
1317
1311
  dlcAccept.changeSerialId,
@@ -1320,7 +1314,7 @@ Payout Group found but incorrect group index');
1320
1314
  return new Set(ids).size === ids.length;
1321
1315
  })(), 'offer.changeSerialID, accept.changeSerialId and fundOutputSerialId must be unique');
1322
1316
  dlcAccept.validate();
1323
- assert_1.default((() => {
1317
+ (0, assert_1.default)((() => {
1324
1318
  const finalizer = new core_1.DualFundingTxFinalizer(dlcOffer.fundingInputs, dlcOffer.payoutSPK, dlcOffer.changeSPK, dlcAccept.fundingInputs, dlcAccept.payoutSPK, dlcAccept.changeSPK, dlcOffer.feeRatePerVb);
1325
1319
  const funding = fundingInputs.reduce((total, input) => {
1326
1320
  return total + input.prevTx.outputs[input.prevTxVout].value.sats;
@@ -1336,9 +1330,9 @@ Payout Group found but incorrect group index');
1336
1330
  const dlcTransactions = dlcTransactionsList[i];
1337
1331
  const messagesList = nestedMessagesList[i];
1338
1332
  const { cetSignatures, refundSignature, } = await this.CreateCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcTransactions, messagesList, false);
1339
- assert_1.default(dlcTransactions.type === messaging_1.MessageType.DlcTransactionsV0, 'DlcTransactions must be V0');
1333
+ (0, assert_1.default)(dlcTransactions.type === messaging_1.MessageType.DlcTransactionsV0, 'DlcTransactions must be V0');
1340
1334
  const _dlcTransactions = dlcTransactions;
1341
- const contractId = crypto_1.xor(_dlcTransactions.fundTx.txId.serialize(), dlcAccept.tempContractId);
1335
+ const contractId = (0, crypto_1.xor)(_dlcTransactions.fundTx.txId.serialize(), dlcAccept.tempContractId);
1342
1336
  _dlcTransactions.contractId = contractId;
1343
1337
  dlcAccepts[i].cetSignatures = cetSignatures;
1344
1338
  dlcAccepts[i].refundSignature = refundSignature;
@@ -1353,21 +1347,21 @@ Payout Group found but incorrect group index');
1353
1347
  * @returns {Promise<SignDlcAcceptResponse}
1354
1348
  */
1355
1349
  async signDlcAccept(_dlcOffer, _dlcAccept) {
1356
- const { dlcOffer, dlcAccept } = Utils_1.checkTypes({
1350
+ const { dlcOffer, dlcAccept } = (0, Utils_1.checkTypes)({
1357
1351
  _dlcOffer,
1358
1352
  _dlcAccept,
1359
1353
  });
1360
1354
  dlcOffer.validate();
1361
1355
  dlcAccept.validate();
1362
- assert_1.default(Buffer.compare(dlcOffer.fundingPubKey, dlcAccept.fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1356
+ (0, assert_1.default)(Buffer.compare(dlcOffer.fundingPubKey, dlcAccept.fundingPubKey) !== 0, 'DlcOffer and DlcAccept FundingPubKey cannot be the same');
1363
1357
  const dlcSign = new messaging_1.DlcSignV0();
1364
1358
  const { dlcTransactions, messagesList } = await this.createDlcTxs(dlcOffer, dlcAccept);
1365
1359
  await this.VerifyCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcSign, dlcTransactions, messagesList, true);
1366
1360
  const { cetSignatures, refundSignature, } = await this.CreateCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcTransactions, messagesList, true);
1367
1361
  const fundingSignatures = await this.CreateFundingSigs(dlcOffer, dlcAccept, dlcTransactions, true);
1368
1362
  const dlcTxs = dlcTransactions;
1369
- const contractId = crypto_1.xor(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId);
1370
- assert_1.default(Buffer.compare(contractId, crypto_1.xor(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId)) === 0, 'contractId must be the xor of funding txid, fundingOutputIndex and the tempContractId');
1363
+ const contractId = (0, crypto_1.xor)(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId);
1364
+ (0, assert_1.default)(Buffer.compare(contractId, (0, crypto_1.xor)(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId)) === 0, 'contractId must be the xor of funding txid, fundingOutputIndex and the tempContractId');
1371
1365
  dlcTxs.contractId = contractId;
1372
1366
  dlcSign.contractId = contractId;
1373
1367
  dlcSign.cetSignatures = cetSignatures;
@@ -1377,12 +1371,12 @@ Payout Group found but incorrect group index');
1377
1371
  }
1378
1372
  async batchSignDlcAccept(_dlcOffers, _dlcAccepts) {
1379
1373
  const dlcOffers = _dlcOffers.map((_dlcOffer) => {
1380
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
1374
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
1381
1375
  dlcOffer.validate();
1382
1376
  return dlcOffer;
1383
1377
  });
1384
1378
  const dlcAccepts = _dlcAccepts.map((_dlcAccept) => {
1385
- const { dlcAccept } = Utils_1.checkTypes({ _dlcAccept });
1379
+ const { dlcAccept } = (0, Utils_1.checkTypes)({ _dlcAccept });
1386
1380
  dlcAccept.validate();
1387
1381
  return dlcAccept;
1388
1382
  });
@@ -1398,7 +1392,7 @@ Payout Group found but incorrect group index');
1398
1392
  await this.VerifyCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcSign, dlcTransactions, messagesList, true);
1399
1393
  const { cetSignatures, refundSignature, } = await this.CreateCetAdaptorAndRefundSigs(dlcOffer, dlcAccept, dlcTransactions, messagesList, true);
1400
1394
  const dlcTxs = dlcTransactions;
1401
- const contractId = crypto_1.xor(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId);
1395
+ const contractId = (0, crypto_1.xor)(dlcTxs.fundTx.txId.serialize(), dlcAccept.tempContractId);
1402
1396
  dlcTxs.contractId = contractId;
1403
1397
  dlcSign.contractId = contractId;
1404
1398
  dlcSign.cetSignatures = cetSignatures;
@@ -1417,7 +1411,7 @@ Payout Group found but incorrect group index');
1417
1411
  * @returns {Promise<Tx>}
1418
1412
  */
1419
1413
  async finalizeDlcSign(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs) {
1420
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
1414
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
1421
1415
  _dlcOffer,
1422
1416
  _dlcAccept,
1423
1417
  _dlcSign,
@@ -1433,21 +1427,21 @@ Payout Group found but incorrect group index');
1433
1427
  }
1434
1428
  async batchFinalizeDlcSign(_dlcOffers, _dlcAccepts, _dlcSigns, _dlcTxsList) {
1435
1429
  const dlcOffers = _dlcOffers.map((_dlcOffer) => {
1436
- const { dlcOffer } = Utils_1.checkTypes({ _dlcOffer });
1430
+ const { dlcOffer } = (0, Utils_1.checkTypes)({ _dlcOffer });
1437
1431
  dlcOffer.validate();
1438
1432
  return dlcOffer;
1439
1433
  });
1440
1434
  const dlcAccepts = _dlcAccepts.map((_dlcAccept) => {
1441
- const { dlcAccept } = Utils_1.checkTypes({ _dlcAccept });
1435
+ const { dlcAccept } = (0, Utils_1.checkTypes)({ _dlcAccept });
1442
1436
  dlcAccept.validate();
1443
1437
  return dlcAccept;
1444
1438
  });
1445
1439
  const dlcSigns = _dlcSigns.map((_dlcSign) => {
1446
- const { dlcSign } = Utils_1.checkTypes({ _dlcSign });
1440
+ const { dlcSign } = (0, Utils_1.checkTypes)({ _dlcSign });
1447
1441
  return dlcSign;
1448
1442
  });
1449
1443
  const dlcTxsList = _dlcTxsList.map((_dlcTxs) => {
1450
- const { dlcTxs } = Utils_1.checkTypes({ _dlcTxs });
1444
+ const { dlcTxs } = (0, Utils_1.checkTypes)({ _dlcTxs });
1451
1445
  return dlcTxs;
1452
1446
  });
1453
1447
  await this.VerifyFundingSigs(dlcOffers[0], dlcAccepts[0], dlcSigns[0], dlcTxsList[0], false);
@@ -1475,7 +1469,7 @@ Payout Group found but incorrect group index');
1475
1469
  * @returns {Promise<Tx>}
1476
1470
  */
1477
1471
  async execute(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs, oracleAttestation, isOfferer) {
1478
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
1472
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
1479
1473
  _dlcOffer,
1480
1474
  _dlcAccept,
1481
1475
  _dlcSign,
@@ -1495,7 +1489,7 @@ Payout Group found but incorrect group index');
1495
1489
  * @returns {Promise<Tx>}
1496
1490
  */
1497
1491
  async refund(_dlcOffer, _dlcAccept, _dlcSign, _dlcTxs) {
1498
- const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = Utils_1.checkTypes({
1492
+ const { dlcOffer, dlcAccept, dlcSign, dlcTxs } = (0, Utils_1.checkTypes)({
1499
1493
  _dlcOffer,
1500
1494
  _dlcAccept,
1501
1495
  _dlcSign,
@@ -1538,7 +1532,7 @@ Payout Group found but incorrect group index');
1538
1532
  * @returns {Promise<DlcClose>}
1539
1533
  */
1540
1534
  async createDlcClose(_dlcOffer, _dlcAccept, _dlcTxs, initiatorPayoutSatoshis, isOfferer, _inputs) {
1541
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
1535
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
1542
1536
  _dlcOffer,
1543
1537
  _dlcAccept,
1544
1538
  _dlcTxs,
@@ -1568,7 +1562,7 @@ Payout Group found but incorrect group index');
1568
1562
  inputs = _inputs.map((input) => {
1569
1563
  return {
1570
1564
  ...input,
1571
- inputSerialId: input.inputSerialId || Utils_1.generateSerialId(),
1565
+ inputSerialId: input.inputSerialId || (0, Utils_1.generateSerialId)(),
1572
1566
  toUtxo: input.toUtxo,
1573
1567
  };
1574
1568
  });
@@ -1576,7 +1570,7 @@ Payout Group found but incorrect group index');
1576
1570
  const address = await this.getMethod('getWalletAddress')(input.address);
1577
1571
  return Buffer.from(address.publicKey, 'hex');
1578
1572
  }));
1579
- const fundingInputSerialId = Utils_1.generateSerialId();
1573
+ const fundingInputSerialId = (0, Utils_1.generateSerialId)();
1580
1574
  // Make temporary array to hold all inputs and then sort them
1581
1575
  // this method can be improved later
1582
1576
  const psbtInputs = [];
@@ -1694,7 +1688,7 @@ Payout Group found but incorrect group index');
1694
1688
  * @returns {Promise<DlcClose[]>}
1695
1689
  */
1696
1690
  async createBatchDlcClose(_dlcOffer, _dlcAccept, _dlcTxs, initiatorPayouts, isOfferer, _inputs) {
1697
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
1691
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
1698
1692
  _dlcOffer,
1699
1693
  _dlcAccept,
1700
1694
  _dlcTxs,
@@ -1703,7 +1697,7 @@ Payout Group found but incorrect group index');
1703
1697
  isOfferer = await this.isOfferer(dlcOffer, dlcAccept);
1704
1698
  if (_inputs && _inputs.length > 0)
1705
1699
  throw Error('funding inputs not supported on BatchDlcClose'); // TODO support multiple funding inputs
1706
- const fundingInputSerialId = Utils_1.generateSerialId();
1700
+ const fundingInputSerialId = (0, Utils_1.generateSerialId)();
1707
1701
  const fundingInputs = []; // TODO: support multiple funding inputs
1708
1702
  const finalizer = new core_1.DualClosingTxFinalizer(fundingInputs, dlcOffer.payoutSPK, dlcAccept.payoutSPK, dlcOffer.feeRatePerVb);
1709
1703
  // Generate keypair to sign inputs
@@ -1755,19 +1749,19 @@ Payout Group found but incorrect group index');
1755
1749
  * @returns {Promise<void>}
1756
1750
  */
1757
1751
  async verifyBatchDlcClose(_dlcOffer, _dlcAccept, _dlcTxs, _dlcCloses, isOfferer) {
1758
- const { dlcOffer, dlcAccept, dlcTxs } = Utils_1.checkTypes({
1752
+ const { dlcOffer, dlcAccept, dlcTxs } = (0, Utils_1.checkTypes)({
1759
1753
  _dlcOffer,
1760
1754
  _dlcAccept,
1761
1755
  _dlcTxs,
1762
1756
  });
1763
- const dlcCloses = _dlcCloses.map((_dlcClose) => Utils_1.checkTypes({ _dlcClose }).dlcClose);
1757
+ const dlcCloses = _dlcCloses.map((_dlcClose) => (0, Utils_1.checkTypes)({ _dlcClose }).dlcClose);
1764
1758
  if (isOfferer === undefined)
1765
1759
  isOfferer = await this.isOfferer(dlcOffer, dlcAccept);
1766
- assert_1.default(dlcCloses.every((dlcClose) => dlcClose.fundingInputs.length === 0), 'funding inputs not supported on verify BatchDlcClose'); // TODO support multiple funding inputs
1760
+ (0, assert_1.default)(dlcCloses.every((dlcClose) => dlcClose.fundingInputs.length === 0), 'funding inputs not supported on verify BatchDlcClose'); // TODO support multiple funding inputs
1767
1761
  const closeInputAmount = BigInt(0); // TODO support multiple funding inputs
1768
1762
  const rawCloseTxs = await this.CreateCloseRawTxs(dlcOffer, dlcAccept, dlcTxs, closeInputAmount, isOfferer, dlcCloses);
1769
1763
  const areSigsValid = await this.VerifySignatures(dlcOffer, dlcAccept, dlcTxs, dlcCloses, rawCloseTxs, isOfferer);
1770
- assert_1.default(areSigsValid, 'Signatures invalid in Verify Batch DlcClose');
1764
+ (0, assert_1.default)(areSigsValid, 'Signatures invalid in Verify Batch DlcClose');
1771
1765
  }
1772
1766
  /**
1773
1767
  * Goal of finalize Dlc Close is for bob to
@@ -1785,7 +1779,7 @@ Payout Group found but incorrect group index');
1785
1779
  * @returns {Promise<Tx>}
1786
1780
  */
1787
1781
  async finalizeDlcClose(_dlcOffer, _dlcAccept, _dlcClose, _dlcTxs) {
1788
- const { dlcOffer, dlcAccept, dlcClose, dlcTxs } = Utils_1.checkTypes({
1782
+ const { dlcOffer, dlcAccept, dlcClose, dlcTxs } = (0, Utils_1.checkTypes)({
1789
1783
  _dlcOffer,
1790
1784
  _dlcAccept,
1791
1785
  _dlcClose,
@@ -1867,7 +1861,7 @@ Payout Group found but incorrect group index');
1867
1861
  const partialSig = [
1868
1862
  {
1869
1863
  pubkey: offerer ? dlcAccept.fundingPubKey : dlcOffer.fundingPubKey,
1870
- signature: await bitcoinjs_lib_1.script.signature.encode(dlcClose.closeSignature, 1),
1864
+ signature: await bitcoinjs_lib_1.script.signature.encode(dlcClose.closeSignature, 1), // encode using SIGHASH_ALL
1871
1865
  },
1872
1866
  ];
1873
1867
  psbt.updateInput(fundingInputIndex, { partialSig });
@@ -1876,7 +1870,7 @@ Payout Group found but incorrect group index');
1876
1870
  continue;
1877
1871
  if (!psbt.data.inputs[i].partialSig)
1878
1872
  psbt.data.inputs[i].partialSig = [];
1879
- const witnessI = dlcClose.fundingSignatures.witnessElements.findIndex((el) => Buffer.compare(bitcoin_1.Script.p2wpkhLock(crypto_1.hash160(el[1].witness)).serialize().slice(1), psbt.data.inputs[i].witnessUtxo.script) === 0);
1873
+ const witnessI = dlcClose.fundingSignatures.witnessElements.findIndex((el) => Buffer.compare(bitcoin_1.Script.p2wpkhLock((0, crypto_1.hash160)(el[1].witness)).serialize().slice(1), psbt.data.inputs[i].witnessUtxo.script) === 0);
1880
1874
  const partialSig = [
1881
1875
  {
1882
1876
  pubkey: dlcClose.fundingSignatures.witnessElements[witnessI][1].witness,
@@ -1962,7 +1956,7 @@ Payout Group found but incorrect group index');
1962
1956
  return this._cfdDlcJs.VerifyRefundTxSignature(jsonObject);
1963
1957
  }
1964
1958
  async fundingInputToInput(_input, findDerivationPath = true) {
1965
- assert_1.default(_input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0');
1959
+ (0, assert_1.default)(_input.type === messaging_1.MessageType.FundingInputV0, 'FundingInput must be V0');
1966
1960
  const network = await this.getConnectedNetwork();
1967
1961
  const input = _input;
1968
1962
  const prevTx = input.prevTx;
@@ -2021,7 +2015,7 @@ Payout Group found but incorrect group index');
2021
2015
  : Buffer.from('', 'hex');
2022
2016
  fundingInput.inputSerialId = input.inputSerialId
2023
2017
  ? input.inputSerialId
2024
- : Utils_1.generateSerialId();
2018
+ : (0, Utils_1.generateSerialId)();
2025
2019
  return fundingInput;
2026
2020
  }
2027
2021
  async getConnectedNetwork() {