@babylonlabs-io/ts-sdk 0.79.1 → 1.1.0
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.
- package/README.md +11 -5
- package/dist/{signPsbtsWithFallback-f7QLp0q8.js → PayoutManager-CHTOwj0E.js} +26 -26
- package/dist/PayoutManager-CHTOwj0E.js.map +1 -0
- package/dist/PayoutManager-CpfQjtL0.cjs +2 -0
- package/dist/PayoutManager-CpfQjtL0.cjs.map +1 -0
- package/dist/PeginManager-6tjlGd0t.cjs +2 -0
- package/dist/PeginManager-6tjlGd0t.cjs.map +1 -0
- package/dist/{PeginManager-BXlh3ar0.js → PeginManager-DEldv_Ro.js} +23 -22
- package/dist/PeginManager-DEldv_Ro.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs.map +1 -0
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js +1919 -0
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js.map +1 -0
- package/dist/challengeAssert-Cp_GeRg8.js.map +1 -1
- package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -1
- package/dist/deriveVaultRoot-BwbXmN0x.js +79 -0
- package/dist/deriveVaultRoot-BwbXmN0x.js.map +1 -0
- package/dist/deriveVaultRoot-DvhkHzNb.cjs +2 -0
- package/dist/deriveVaultRoot-DvhkHzNb.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +286 -268
- package/dist/index.js.map +1 -1
- package/dist/noPayout-DAWBQ0eG.cjs +2 -0
- package/dist/noPayout-DAWBQ0eG.cjs.map +1 -0
- package/dist/{noPayout-DiGr4eas.js → noPayout-qBXWKwav.js} +3 -3
- package/dist/noPayout-qBXWKwav.js.map +1 -0
- package/dist/onChainBtcPubkey-BXry_CM4.cjs +2 -0
- package/dist/onChainBtcPubkey-BXry_CM4.cjs.map +1 -0
- package/dist/onChainBtcPubkey-C1WqyxPM.js +159 -0
- package/dist/onChainBtcPubkey-C1WqyxPM.js.map +1 -0
- package/dist/parseFundingOutpoints-C_-PT9BT.cjs +2 -0
- package/dist/parseFundingOutpoints-C_-PT9BT.cjs.map +1 -0
- package/dist/parseFundingOutpoints-GSM-IaaK.js +17 -0
- package/dist/parseFundingOutpoints-GSM-IaaK.js.map +1 -0
- package/dist/{pegin-registration-client-pcczkzMg.js → pegin-registration-client-1sZ-74UC.js} +260 -383
- package/dist/pegin-registration-client-1sZ-74UC.js.map +1 -0
- package/dist/pegin-registration-client-BNV44jzw.cjs +2 -0
- package/dist/pegin-registration-client-BNV44jzw.cjs.map +1 -0
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +6 -3
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
- package/dist/signing-3l5Aqd-H.cjs +2 -0
- package/dist/signing-3l5Aqd-H.cjs.map +1 -0
- package/dist/signing-Dhr2t0Z6.js +39 -0
- package/dist/signing-Dhr2t0Z6.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +8 -8
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +8 -8
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +1 -1
- package/dist/tbv/core/index.js +284 -266
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +1 -1
- package/dist/tbv/core/primitives/index.js +3 -3
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +5 -3
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts +8 -0
- package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +6 -0
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +2 -2
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts +13 -7
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +4 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/recovery/recoveryErrors.d.ts +1 -1
- package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts +15 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts +11 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts +10 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts +10 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts +11 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +46 -0
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +72 -0
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts +63 -0
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/index.d.ts +55 -0
- package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts +65 -0
- package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +70 -0
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/types.d.ts +105 -0
- package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts +44 -0
- package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +1 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +73 -56
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +44 -43
- package/dist/tbv/core/utils/signing.d.ts +24 -0
- package/dist/tbv/core/utils/signing.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/__tests__/context.golden.test.d.ts +4 -4
- package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts +1 -2
- package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/__tests__/deriveContextHash.vectors.test.d.ts +40 -0
- package/dist/tbv/core/vault-secrets/__tests__/deriveContextHash.vectors.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/context.d.ts +2 -2
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +5 -6
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.d.ts +2 -2
- package/dist/tbv/core/vault-secrets/index.js +9 -8
- package/dist/tbv/core/vault-secrets/index.js.map +1 -1
- package/dist/tbv/core/wasm/index.cjs +1 -1
- package/dist/tbv/core/wasm/index.cjs.map +1 -1
- package/dist/tbv/core/wasm/index.d.ts +113 -14
- package/dist/tbv/core/wasm/index.d.ts.map +1 -1
- package/dist/tbv/core/wasm/index.js +180 -94
- package/dist/tbv/core/wasm/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +284 -266
- package/dist/tbv/index.js.map +1 -1
- package/dist/tbv/integrations/aave/types.d.ts +1 -1
- package/dist/testing/MockBitcoinWallet.d.ts +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/toRefundInputs-BaN9XluU.cjs +2 -0
- package/dist/toRefundInputs-BaN9XluU.cjs.map +1 -0
- package/dist/{toRefundInputs-9inv4Ai4.js → toRefundInputs-mtuuYezp.js} +24 -23
- package/dist/toRefundInputs-mtuuYezp.js.map +1 -0
- package/dist/{types-B9YhlXe8.js → types-BdCEoANP.js} +2 -2
- package/dist/{types-B9YhlXe8.js.map → types-BdCEoANP.js.map} +1 -1
- package/dist/{types-C1tpDycc.cjs → types-BuxreSq4.cjs} +2 -2
- package/dist/{types-C1tpDycc.cjs.map → types-BuxreSq4.cjs.map} +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-BVtNwgK6.js → verifyKeyPathSchnorrSignature-BQHNhRj6.js} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-BVtNwgK6.js.map → verifyKeyPathSchnorrSignature-BQHNhRj6.js.map} +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-BjB8Znly.cjs → verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-BjB8Znly.cjs.map → verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs.map} +1 -1
- package/dist/verifyScriptPathSchnorrSignature-BKZihCjk.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-BKZihCjk.cjs.map +1 -0
- package/dist/{verifyScriptPathSchnorrSignature-D_epga4j.js → verifyScriptPathSchnorrSignature-CpjSTfMj.js} +371 -330
- package/dist/verifyScriptPathSchnorrSignature-CpjSTfMj.js.map +1 -0
- package/package.json +3 -3
- package/dist/PeginManager-BXlh3ar0.js.map +0 -1
- package/dist/PeginManager-BuVSknB0.cjs +0 -2
- package/dist/PeginManager-BuVSknB0.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-O6z9kvc4.js +0 -1545
- package/dist/buildAndBroadcastReclaim-O6z9kvc4.js.map +0 -1
- package/dist/noPayout-4RZB2g1e.cjs +0 -2
- package/dist/noPayout-4RZB2g1e.cjs.map +0 -1
- package/dist/noPayout-DiGr4eas.js.map +0 -1
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs +0 -2
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs.map +0 -1
- package/dist/onChainBtcPubkey-C-6UWpD8.js +0 -34
- package/dist/onChainBtcPubkey-C-6UWpD8.js.map +0 -1
- package/dist/parseFundingOutpoints-B4iQeX6q.cjs +0 -2
- package/dist/parseFundingOutpoints-B4iQeX6q.cjs.map +0 -1
- package/dist/parseFundingOutpoints-BQWvINfm.js +0 -93
- package/dist/parseFundingOutpoints-BQWvINfm.js.map +0 -1
- package/dist/pegin-registration-client-CZgcU2_0.cjs +0 -2
- package/dist/pegin-registration-client-CZgcU2_0.cjs.map +0 -1
- package/dist/pegin-registration-client-pcczkzMg.js.map +0 -1
- package/dist/signPsbtsWithFallback-DtwzL5AA.cjs +0 -2
- package/dist/signPsbtsWithFallback-DtwzL5AA.cjs.map +0 -1
- package/dist/signPsbtsWithFallback-f7QLp0q8.js.map +0 -1
- package/dist/signing-BJ3X66b-.cjs +0 -2
- package/dist/signing-BJ3X66b-.cjs.map +0 -1
- package/dist/signing-Cm-McVR2.js +0 -22
- package/dist/signing-Cm-McVR2.js.map +0 -1
- package/dist/toRefundInputs-9inv4Ai4.js.map +0 -1
- package/dist/toRefundInputs-DitGWAnz.cjs +0 -2
- package/dist/toRefundInputs-DitGWAnz.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs.map +0 -1
package/dist/{pegin-registration-client-pcczkzMg.js → pegin-registration-client-1sZ-74UC.js}
RENAMED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { B as
|
|
6
|
-
import { B as
|
|
7
|
-
import { M as
|
|
8
|
-
import { waitForTransactionReceiptSmartAware as
|
|
9
|
-
import { a as
|
|
10
|
-
import { s as
|
|
11
|
-
import { c as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
if (!Number.isInteger(t) || t < 0 || t >=
|
|
1
|
+
var dt = Object.defineProperty;
|
|
2
|
+
var pt = (t, e, o) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var m = (t, e, o) => pt(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
import { getAbiItem as _, encodeFunctionData as N, isAddressEqual as gt, zeroAddress as ft } from "viem";
|
|
5
|
+
import { B as h } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
|
|
6
|
+
import { B as K, h as T } from "./BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js";
|
|
7
|
+
import { M as H, b as O } from "./constants-D5vORbQE.js";
|
|
8
|
+
import { waitForTransactionReceiptSmartAware as mt } from "./tbv/core/utils/eth/index.js";
|
|
9
|
+
import { a as C, c as Pt, d as bt } from "./onChainBtcPubkey-C1WqyxPM.js";
|
|
10
|
+
import { s as Y, b as w, a as yt } from "./secp256k1-D-H9jmd7.js";
|
|
11
|
+
import { c as wt, H as Ct, r as E, a as F, h as j, b as R, s as Et } from "./sha2-CLpQd0Rd.js";
|
|
12
|
+
const v = 25, xt = 9999;
|
|
13
|
+
function M(t) {
|
|
14
|
+
if (!Number.isInteger(t) || t < 0 || t >= H)
|
|
15
15
|
throw new Error(
|
|
16
|
-
`Quoted commissionBps must be an integer in [0, ${
|
|
16
|
+
`Quoted commissionBps must be an integer in [0, ${H}), got ${t}`
|
|
17
17
|
);
|
|
18
18
|
return Math.min(
|
|
19
|
-
t +
|
|
20
|
-
|
|
19
|
+
t + v,
|
|
20
|
+
xt
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const It = /* @__PURE__ */ Uint8Array.from([
|
|
24
24
|
7,
|
|
25
25
|
4,
|
|
26
26
|
13,
|
|
@@ -37,304 +37,183 @@ const Bt = /* @__PURE__ */ Uint8Array.from([
|
|
|
37
37
|
14,
|
|
38
38
|
11,
|
|
39
39
|
8
|
|
40
|
-
]),
|
|
41
|
-
const o = [[
|
|
40
|
+
]), Z = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), Bt = Z.map((t) => (9 * t + 5) % 16), J = /* @__PURE__ */ (() => {
|
|
41
|
+
const o = [[Z], [Bt]];
|
|
42
42
|
for (let n = 0; n < 4; n++)
|
|
43
43
|
for (let i of o)
|
|
44
|
-
i.push(i[n].map((
|
|
44
|
+
i.push(i[n].map((s) => It[s]));
|
|
45
45
|
return o;
|
|
46
|
-
})(),
|
|
46
|
+
})(), tt = J[0], et = J[1], ot = /* @__PURE__ */ [
|
|
47
47
|
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
48
48
|
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
49
49
|
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
50
50
|
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
51
51
|
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
52
|
-
].map((t) => Uint8Array.from(t)),
|
|
52
|
+
].map((t) => Uint8Array.from(t)), Tt = /* @__PURE__ */ tt.map((t, e) => t.map((o) => ot[e][o])), Vt = /* @__PURE__ */ et.map((t, e) => t.map((o) => ot[e][o])), At = /* @__PURE__ */ Uint32Array.from([
|
|
53
53
|
0,
|
|
54
54
|
1518500249,
|
|
55
55
|
1859775393,
|
|
56
56
|
2400959708,
|
|
57
57
|
2840853838
|
|
58
|
-
]),
|
|
58
|
+
]), St = /* @__PURE__ */ Uint32Array.from([
|
|
59
59
|
1352829926,
|
|
60
60
|
1548603684,
|
|
61
61
|
1836072691,
|
|
62
62
|
2053994217,
|
|
63
63
|
0
|
|
64
64
|
]);
|
|
65
|
-
function
|
|
65
|
+
function U(t, e, o, n) {
|
|
66
66
|
return t === 0 ? e ^ o ^ n : t === 1 ? e & o | ~e & n : t === 2 ? (e | ~o) ^ n : t === 3 ? e & n | o & ~n : e ^ (o | ~n);
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
class
|
|
68
|
+
const x = /* @__PURE__ */ new Uint32Array(16);
|
|
69
|
+
class vt extends Ct {
|
|
70
70
|
constructor() {
|
|
71
71
|
super(64, 20, 8, !0);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
m(this, "h0", 1732584193);
|
|
73
|
+
m(this, "h1", -271733879);
|
|
74
|
+
m(this, "h2", -1732584194);
|
|
75
|
+
m(this, "h3", 271733878);
|
|
76
|
+
m(this, "h4", -1009589776);
|
|
77
77
|
}
|
|
78
78
|
get() {
|
|
79
|
-
const { h0: o, h1: n, h2: i, h3:
|
|
80
|
-
return [o, n, i,
|
|
79
|
+
const { h0: o, h1: n, h2: i, h3: s, h4: r } = this;
|
|
80
|
+
return [o, n, i, s, r];
|
|
81
81
|
}
|
|
82
|
-
set(o, n, i,
|
|
83
|
-
this.h0 = o | 0, this.h1 = n | 0, this.h2 = i | 0, this.h3 =
|
|
82
|
+
set(o, n, i, s, r) {
|
|
83
|
+
this.h0 = o | 0, this.h1 = n | 0, this.h2 = i | 0, this.h3 = s | 0, this.h4 = r | 0;
|
|
84
84
|
}
|
|
85
85
|
process(o, n) {
|
|
86
|
-
for (let
|
|
87
|
-
|
|
88
|
-
let i = this.h0 | 0,
|
|
89
|
-
for (let
|
|
90
|
-
const
|
|
91
|
-
for (let
|
|
92
|
-
const
|
|
93
|
-
i =
|
|
86
|
+
for (let a = 0; a < 16; a++, n += 4)
|
|
87
|
+
x[a] = o.getUint32(n, !0);
|
|
88
|
+
let i = this.h0 | 0, s = i, r = this.h1 | 0, c = r, u = this.h2 | 0, l = u, g = this.h3 | 0, b = g, f = this.h4 | 0, y = f;
|
|
89
|
+
for (let a = 0; a < 5; a++) {
|
|
90
|
+
const d = 4 - a, rt = At[a], at = St[a], ct = tt[a], ut = et[a], ht = Tt[a], lt = Vt[a];
|
|
91
|
+
for (let p = 0; p < 16; p++) {
|
|
92
|
+
const B = E(i + U(a, r, u, g) + x[ct[p]] + rt, ht[p]) + f | 0;
|
|
93
|
+
i = f, f = g, g = E(u, 10) | 0, u = r, r = B;
|
|
94
94
|
}
|
|
95
|
-
for (let
|
|
96
|
-
const
|
|
97
|
-
|
|
95
|
+
for (let p = 0; p < 16; p++) {
|
|
96
|
+
const B = E(s + U(d, c, l, b) + x[ut[p]] + at, lt[p]) + y | 0;
|
|
97
|
+
s = y, y = b, b = E(l, 10) | 0, l = c, c = B;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
this.set(this.h1 +
|
|
100
|
+
this.set(this.h1 + u + b | 0, this.h2 + g + y | 0, this.h3 + f + s | 0, this.h4 + i + c | 0, this.h0 + r + l | 0);
|
|
101
101
|
}
|
|
102
102
|
roundClean() {
|
|
103
|
-
|
|
103
|
+
F(x);
|
|
104
104
|
}
|
|
105
105
|
destroy() {
|
|
106
|
-
this.destroyed = !0,
|
|
106
|
+
this.destroyed = !0, F(this.buffer), this.set(0, 0, 0, 0, 0);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
function
|
|
109
|
+
const $t = /* @__PURE__ */ wt(() => new vt()), kt = "5120", $ = "0014", Rt = 20, q = 33, _t = 65, Nt = 2, Kt = 3, Ht = 4;
|
|
110
|
+
function nt(t, e) {
|
|
111
111
|
const o = t.startsWith("0x") || t.startsWith("0X") ? t.slice(2) : t;
|
|
112
112
|
if (!/^(?:[0-9a-fA-F]{2})+$/.test(o))
|
|
113
113
|
throw new Error(`${e} must be non-empty, even-length hex`);
|
|
114
114
|
return `0x${o.toLowerCase()}`;
|
|
115
115
|
}
|
|
116
116
|
function Ot(t) {
|
|
117
|
-
const e =
|
|
118
|
-
|
|
117
|
+
const e = j(t), o = w.utils.lift_x(BigInt(`0x${t}`)), n = w.utils.bytesToNumberBE(
|
|
118
|
+
w.utils.taggedHash("TapTweak", e)
|
|
119
119
|
);
|
|
120
|
-
if (n >=
|
|
120
|
+
if (n >= Y.CURVE.n)
|
|
121
121
|
throw new Error("Proof of possession BTC pubkey has an invalid TapTweak");
|
|
122
|
-
const i = n === 0n ? o : o.add(
|
|
123
|
-
return `0x${
|
|
124
|
-
|
|
122
|
+
const i = n === 0n ? o : o.add(w.Point.BASE.multiply(n));
|
|
123
|
+
return `0x${kt}${R(
|
|
124
|
+
w.utils.pointToBytes(i)
|
|
125
125
|
)}`;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
const e =
|
|
127
|
+
function Ft(t) {
|
|
128
|
+
const e = nt(t, "depositorBtcPubkeyRaw"), o = j(e.slice(2));
|
|
129
129
|
if (o.length === 32)
|
|
130
130
|
return {
|
|
131
|
-
xOnlyPubkey:
|
|
131
|
+
xOnlyPubkey: C(e, "Payout BTC pubkey")
|
|
132
132
|
};
|
|
133
|
-
const n = o.length ===
|
|
133
|
+
const n = o.length === q && (o[0] === Nt || o[0] === Kt), i = o.length === _t && o[0] === Ht;
|
|
134
134
|
if (!n && !i)
|
|
135
135
|
throw new Error(
|
|
136
136
|
"depositorBtcPubkeyRaw must be x-only, compressed, or uncompressed"
|
|
137
137
|
);
|
|
138
138
|
try {
|
|
139
|
-
|
|
139
|
+
Y.Point.fromBytes(o);
|
|
140
140
|
} catch {
|
|
141
141
|
throw new Error("depositorBtcPubkeyRaw is not a valid BTC pubkey");
|
|
142
142
|
}
|
|
143
143
|
return {
|
|
144
|
-
xOnlyPubkey:
|
|
144
|
+
xOnlyPubkey: R(o.subarray(1, q)),
|
|
145
145
|
compressedPubkey: n ? o : void 0
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return `0x${
|
|
148
|
+
function Mt(t) {
|
|
149
|
+
return `0x${$}${R($t(Et(t)))}`;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const n =
|
|
151
|
+
function Ut(t, e, o) {
|
|
152
|
+
const n = nt(
|
|
153
153
|
t,
|
|
154
154
|
"depositorPayoutScriptPubKey"
|
|
155
155
|
);
|
|
156
|
-
if ((n.length - 2) / 2 >
|
|
156
|
+
if ((n.length - 2) / 2 > O)
|
|
157
157
|
throw new Error(
|
|
158
|
-
`depositorPayoutScriptPubKey exceeds ${
|
|
158
|
+
`depositorPayoutScriptPubKey exceeds ${O} bytes`
|
|
159
159
|
);
|
|
160
|
-
const i = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e,
|
|
160
|
+
const i = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e, s = C(
|
|
161
161
|
`0x${i}`,
|
|
162
162
|
"Proof of possession BTC pubkey"
|
|
163
|
-
),
|
|
164
|
-
if (
|
|
163
|
+
), r = Ft(o);
|
|
164
|
+
if (r.xOnlyPubkey !== s)
|
|
165
165
|
throw new Error(
|
|
166
166
|
"depositorBtcPubkeyRaw does not match the proof of possession BTC pubkey"
|
|
167
167
|
);
|
|
168
|
-
if (n === Ot(
|
|
168
|
+
if (n === Ot(s))
|
|
169
169
|
return n;
|
|
170
|
-
if (n.startsWith(`0x${
|
|
171
|
-
if (!
|
|
170
|
+
if (n.startsWith(`0x${$}`) && n.length === 2 + $.length + Rt * 2) {
|
|
171
|
+
if (!r.compressedPubkey)
|
|
172
172
|
throw new Error("A P2WPKH payout requires a compressed BTC pubkey");
|
|
173
|
-
if (n ===
|
|
173
|
+
if (n === Mt(r.compressedPubkey))
|
|
174
174
|
return n;
|
|
175
175
|
}
|
|
176
176
|
throw new Error(
|
|
177
177
|
"depositorPayoutScriptPubKey does not match the proof of possession BTC pubkey"
|
|
178
178
|
);
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
throw new Error(`${e} must be non-empty, even-length hex`);
|
|
184
|
-
if (!/^[0-9a-fA-F]+$/.test(o))
|
|
185
|
-
throw new Error(`${e} contains non-hex characters`);
|
|
186
|
-
const n = new Uint8Array(o.length / 2);
|
|
187
|
-
for (let i = 0; i < n.length; i++)
|
|
188
|
-
n[i] = Number.parseInt(o.slice(i * 2, i * 2 + 2), 16);
|
|
189
|
-
return n;
|
|
190
|
-
}
|
|
191
|
-
function Dt(t) {
|
|
192
|
-
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join(
|
|
193
|
-
""
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
function Lt(t) {
|
|
197
|
-
const e = new Uint8Array(
|
|
198
|
-
t.reduce((n, i) => n + i.length, 0)
|
|
199
|
-
);
|
|
200
|
-
let o = 0;
|
|
201
|
-
for (const n of t)
|
|
202
|
-
e.set(n, o), o += n.length;
|
|
203
|
-
return e;
|
|
204
|
-
}
|
|
205
|
-
function Xt(t) {
|
|
206
|
-
let e = 0;
|
|
207
|
-
const o = (s, l) => {
|
|
208
|
-
if (!Number.isSafeInteger(s) || s < 0)
|
|
209
|
-
throw new Error(`Invalid ${l} length ${s}`);
|
|
210
|
-
if (e + s > t.length)
|
|
211
|
-
throw new Error(`Truncated Bitcoin transaction while reading ${l}`);
|
|
212
|
-
const r = t.slice(e, e + s);
|
|
213
|
-
return e += s, r;
|
|
214
|
-
}, n = (s, l) => {
|
|
215
|
-
const r = o(s, l);
|
|
216
|
-
let u = 0n;
|
|
217
|
-
for (let b = r.length - 1; b >= 0; b--)
|
|
218
|
-
u = u << 8n | BigInt(r[b]);
|
|
219
|
-
return u;
|
|
220
|
-
}, i = (s) => {
|
|
221
|
-
const l = e, r = o(1, s)[0];
|
|
222
|
-
let u;
|
|
223
|
-
if (r < 253)
|
|
224
|
-
u = BigInt(r);
|
|
225
|
-
else if (r === 253) {
|
|
226
|
-
if (u = n(2, s), u < 0xfdn) throw new Error(`Non-canonical ${s}`);
|
|
227
|
-
} else if (r === 254) {
|
|
228
|
-
if (u = n(4, s), u <= 0xffffn) throw new Error(`Non-canonical ${s}`);
|
|
229
|
-
} else if (u = n(8, s), u <= 0xffffffffn) throw new Error(`Non-canonical ${s}`);
|
|
230
|
-
if (u > BigInt(Number.MAX_SAFE_INTEGER))
|
|
231
|
-
throw new Error(`${s} exceeds JavaScript's safe integer range`);
|
|
232
|
-
return {
|
|
233
|
-
encoded: t.slice(l, e),
|
|
234
|
-
value: Number(u)
|
|
235
|
-
};
|
|
236
|
-
}, a = o(4, "version"), c = t[e] === 0 && t[e + 1] === 1;
|
|
237
|
-
c && (e += 2);
|
|
238
|
-
const h = i("input count"), d = [];
|
|
239
|
-
for (let s = 0; s < h.value; s++) {
|
|
240
|
-
const l = e;
|
|
241
|
-
o(32, `input ${s} previous transaction hash`), o(4, `input ${s} previous output index`);
|
|
242
|
-
const r = i(`input ${s} script length`);
|
|
243
|
-
o(r.value, `input ${s} script`), o(4, `input ${s} sequence`), d.push(t.slice(l, e));
|
|
244
|
-
}
|
|
245
|
-
const p = i("output count"), f = [];
|
|
246
|
-
for (let s = 0; s < p.value; s++) {
|
|
247
|
-
const l = e;
|
|
248
|
-
o(8, `output ${s} value`);
|
|
249
|
-
const r = i(`output ${s} script length`);
|
|
250
|
-
o(r.value, `output ${s} script`), f.push(t.slice(l, e));
|
|
251
|
-
}
|
|
252
|
-
if (c) {
|
|
253
|
-
let s = !1;
|
|
254
|
-
for (let l = 0; l < h.value; l++) {
|
|
255
|
-
const r = i(`input ${l} witness item count`);
|
|
256
|
-
s || (s = r.value > 0);
|
|
257
|
-
for (let u = 0; u < r.value; u++) {
|
|
258
|
-
const b = i(
|
|
259
|
-
`input ${l} witness item ${u} length`
|
|
260
|
-
);
|
|
261
|
-
o(b.value, `input ${l} witness item ${u}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (!s)
|
|
265
|
-
throw new Error("Bitcoin transaction has superfluous witness marker");
|
|
266
|
-
}
|
|
267
|
-
const P = o(4, "locktime");
|
|
268
|
-
if (e !== t.length)
|
|
269
|
-
throw new Error(
|
|
270
|
-
`Bitcoin transaction has ${t.length - e} trailing byte(s)`
|
|
271
|
-
);
|
|
272
|
-
return Lt([
|
|
273
|
-
a,
|
|
274
|
-
h.encoded,
|
|
275
|
-
...d,
|
|
276
|
-
p.encoded,
|
|
277
|
-
...f,
|
|
278
|
-
P
|
|
279
|
-
]);
|
|
280
|
-
}
|
|
281
|
-
function zt(t) {
|
|
282
|
-
const e = Xt(
|
|
283
|
-
Wt(t, "transactionHex")
|
|
284
|
-
), o = S(S(e));
|
|
285
|
-
return o.reverse(), `0x${Dt(o)}`;
|
|
286
|
-
}
|
|
287
|
-
function Gt(t, e) {
|
|
288
|
-
const o = t.startsWith("0x") ? t : `0x${t}`;
|
|
289
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(o))
|
|
290
|
-
throw new Error("peginTxHash must be a 32-byte hex value");
|
|
291
|
-
const n = e.startsWith("0x") ? e : `0x${e}`;
|
|
292
|
-
if (!ft(n, { strict: !0 }))
|
|
293
|
-
throw new Error(`Invalid depositor Ethereum address: ${e}`);
|
|
294
|
-
return mt(
|
|
295
|
-
Pt(
|
|
296
|
-
[{ type: "bytes32" }, { type: "address" }],
|
|
297
|
-
[o, n]
|
|
298
|
-
)
|
|
299
|
-
).slice(2);
|
|
300
|
-
}
|
|
301
|
-
const T = 65535, L = 1e4, B = 4294967295, X = 255;
|
|
302
|
-
function Qt(t) {
|
|
303
|
-
if (!Number.isInteger(t) || t < 0 || t > B)
|
|
180
|
+
const V = 65535, D = 1e4, I = 4294967295, W = 255;
|
|
181
|
+
function qt(t) {
|
|
182
|
+
if (!Number.isInteger(t) || t < 0 || t > I)
|
|
304
183
|
throw new Error(
|
|
305
184
|
`Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`
|
|
306
185
|
);
|
|
307
186
|
}
|
|
308
|
-
function
|
|
187
|
+
function Dt(t) {
|
|
309
188
|
const e = [];
|
|
310
189
|
if (t.timelockAssert <= 0n && e.push(
|
|
311
190
|
`timelockAssert must be positive, got ${t.timelockAssert}`
|
|
312
|
-
), t.timelockAssert > BigInt(
|
|
313
|
-
`timelockAssert ${t.timelockAssert} exceeds uint16 max (${
|
|
191
|
+
), t.timelockAssert > BigInt(V) && e.push(
|
|
192
|
+
`timelockAssert ${t.timelockAssert} exceeds uint16 max (${V})`
|
|
314
193
|
), t.timelockChallengeAssert <= 0n && e.push(
|
|
315
194
|
`timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`
|
|
316
195
|
), t.tRefund <= 0 && e.push(`tRefund must be positive, got ${t.tRefund}`), t.tStale <= 0 && e.push(`tStale must be positive, got ${t.tStale}`), t.securityCouncilKeys.length === 0 && e.push("securityCouncilKeys must not be empty"), t.councilQuorum <= 0 && e.push(`councilQuorum must be positive, got ${t.councilQuorum}`), t.councilQuorum > t.securityCouncilKeys.length && e.push(
|
|
317
196
|
`councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`
|
|
318
197
|
), t.feeRate <= 0n && e.push(`feeRate must be positive, got ${t.feeRate}`), t.minPeginFeeRate <= 0n && e.push(
|
|
319
198
|
`minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`
|
|
320
|
-
), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion >
|
|
199
|
+
), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > V) && e.push(
|
|
321
200
|
`proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`
|
|
322
|
-
), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth >
|
|
323
|
-
`minPrepeginDepth must be a uint32 in [1, ${
|
|
201
|
+
), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > I) && e.push(
|
|
202
|
+
`minPrepeginDepth must be a uint32 in [1, ${I}], got ${t.minPrepeginDepth}`
|
|
324
203
|
), t.babeTotalInstances <= 0 && e.push(
|
|
325
204
|
`babeTotalInstances must be positive, got ${t.babeTotalInstances}`
|
|
326
205
|
), t.babeInstancesToFinalize <= 0 && e.push(
|
|
327
206
|
`babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
|
|
328
207
|
), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
|
|
329
208
|
`babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
|
|
330
|
-
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps >
|
|
331
|
-
`minVpCommissionBps must be in [0, ${
|
|
209
|
+
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > D) && e.push(
|
|
210
|
+
`minVpCommissionBps must be in [0, ${D}], got ${t.minVpCommissionBps}`
|
|
332
211
|
), e.length > 0)
|
|
333
212
|
throw new Error(
|
|
334
213
|
`Invalid offchain protocol parameters: ${e.join("; ")}`
|
|
335
214
|
);
|
|
336
215
|
}
|
|
337
|
-
function
|
|
216
|
+
function Wt(t) {
|
|
338
217
|
const e = [];
|
|
339
218
|
if (t.minimumPegInAmount <= 0n && e.push(
|
|
340
219
|
`minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`
|
|
@@ -344,38 +223,38 @@ function jt(t) {
|
|
|
344
223
|
`pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
|
|
345
224
|
), t.pegInActivationTimeout <= 0n && e.push(
|
|
346
225
|
`pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
|
|
347
|
-
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount >
|
|
348
|
-
`maxHtlcOutputCount must be an integer in [1, ${
|
|
226
|
+
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > W) && e.push(
|
|
227
|
+
`maxHtlcOutputCount must be an integer in [1, ${W}], got ${t.maxHtlcOutputCount}`
|
|
349
228
|
), (typeof t.expiredPegInGraceBlocks != "bigint" || t.expiredPegInGraceBlocks <= 0n) && e.push(
|
|
350
229
|
`expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`
|
|
351
230
|
), e.length > 0)
|
|
352
231
|
throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
|
|
353
232
|
}
|
|
354
|
-
function
|
|
355
|
-
if (
|
|
233
|
+
function ce(t) {
|
|
234
|
+
if (Wt(t), Dt(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > I)
|
|
356
235
|
throw new Error(
|
|
357
236
|
`Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
|
|
358
237
|
);
|
|
359
|
-
|
|
238
|
+
yt(
|
|
360
239
|
t.activeVaultCoreVersion,
|
|
361
240
|
"ProtocolParams.activeVaultCoreVersion()"
|
|
362
241
|
);
|
|
363
242
|
}
|
|
364
|
-
const
|
|
365
|
-
class
|
|
243
|
+
const it = "RegistrationLogsUnavailableError";
|
|
244
|
+
class st extends Error {
|
|
366
245
|
constructor(o) {
|
|
367
246
|
super(
|
|
368
247
|
`The Ethereum node returned no registration logs for block ${o}, which holds a vault registration; the node may not have indexed that block yet. Try again.`
|
|
369
248
|
);
|
|
370
|
-
|
|
371
|
-
this.name =
|
|
249
|
+
m(this, "blockNumber");
|
|
250
|
+
this.name = it, this.blockNumber = o;
|
|
372
251
|
}
|
|
373
252
|
}
|
|
374
|
-
function
|
|
375
|
-
return t instanceof
|
|
253
|
+
function ue(t) {
|
|
254
|
+
return t instanceof st ? !0 : typeof t != "object" || t === null ? !1 : t.name === it;
|
|
376
255
|
}
|
|
377
|
-
const
|
|
378
|
-
function
|
|
256
|
+
const L = 9999;
|
|
257
|
+
function X(t) {
|
|
379
258
|
return {
|
|
380
259
|
depositor: t.depositor,
|
|
381
260
|
depositorBtcPubKey: t.depositorBtcPubKey,
|
|
@@ -388,7 +267,7 @@ function G(t) {
|
|
|
388
267
|
}
|
|
389
268
|
function A(t) {
|
|
390
269
|
const e = Number(t.offchainParamsVersion);
|
|
391
|
-
return
|
|
270
|
+
return qt(e), {
|
|
392
271
|
depositorSignedPeginTx: t.depositorSignedPeginTx,
|
|
393
272
|
universalChallengersVersion: t.universalChallengersVersion,
|
|
394
273
|
appVaultKeepersVersion: t.appVaultKeepersVersion,
|
|
@@ -403,29 +282,29 @@ function A(t) {
|
|
|
403
282
|
vaultCoreVersion: t.vaultCoreVersion
|
|
404
283
|
};
|
|
405
284
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
285
|
+
const Lt = 1n << 64n, z = 0n, Xt = [
|
|
286
|
+
_({ abi: h, name: "PegInSubmitted" }),
|
|
287
|
+
_({ abi: h, name: "PegInSubmittedV2" })
|
|
409
288
|
];
|
|
410
|
-
function
|
|
411
|
-
if (t < 0n || t >=
|
|
289
|
+
function S(t, e, o) {
|
|
290
|
+
if (t < 0n || t >= Lt)
|
|
412
291
|
throw new Error(
|
|
413
292
|
`getBtcVaultProtocolInfo returned ${e}=${t} for vault ${o}, outside the uint64 range — the registry may predate RFC-006`
|
|
414
293
|
);
|
|
415
294
|
return t;
|
|
416
295
|
}
|
|
417
|
-
function
|
|
296
|
+
function G(t, e) {
|
|
418
297
|
return {
|
|
419
|
-
vpKeyEpoch:
|
|
420
|
-
appKeeperKeyEpoch:
|
|
298
|
+
vpKeyEpoch: S(t.vpKeyEpoch, "vpKeyEpoch", e),
|
|
299
|
+
appKeeperKeyEpoch: S(
|
|
421
300
|
t.appKeeperKeyEpoch,
|
|
422
301
|
"appKeeperKeyEpoch",
|
|
423
302
|
e
|
|
424
303
|
),
|
|
425
|
-
ucKeyEpoch:
|
|
304
|
+
ucKeyEpoch: S(t.ucKeyEpoch, "ucKeyEpoch", e)
|
|
426
305
|
};
|
|
427
306
|
}
|
|
428
|
-
class
|
|
307
|
+
class zt {
|
|
429
308
|
constructor(e, o) {
|
|
430
309
|
this.publicClient = e, this.contractAddress = o;
|
|
431
310
|
}
|
|
@@ -455,14 +334,14 @@ class te {
|
|
|
455
334
|
async getVaultProviderGenesisBtcPubKey(e, o) {
|
|
456
335
|
const n = await this.publicClient.readContract({
|
|
457
336
|
address: this.contractAddress,
|
|
458
|
-
abi:
|
|
337
|
+
abi: h,
|
|
459
338
|
functionName: "getOperationBtcKeyAtEpoch",
|
|
460
|
-
args: [e,
|
|
339
|
+
args: [e, z],
|
|
461
340
|
blockNumber: o
|
|
462
341
|
});
|
|
463
|
-
return
|
|
342
|
+
return C(
|
|
464
343
|
n,
|
|
465
|
-
`getOperationBtcKeyAtEpoch (vp=${e}, epoch=${
|
|
344
|
+
`getOperationBtcKeyAtEpoch (vp=${e}, epoch=${z})`
|
|
466
345
|
);
|
|
467
346
|
}
|
|
468
347
|
/**
|
|
@@ -479,7 +358,7 @@ class te {
|
|
|
479
358
|
async getVaultProviderApplication(e, o) {
|
|
480
359
|
return await this.publicClient.readContract({
|
|
481
360
|
address: this.contractAddress,
|
|
482
|
-
abi:
|
|
361
|
+
abi: h,
|
|
483
362
|
functionName: "getVaultProviderApplication",
|
|
484
363
|
args: [e],
|
|
485
364
|
blockNumber: o
|
|
@@ -499,11 +378,11 @@ class te {
|
|
|
499
378
|
async getCurrentVaultProviderOperationBtcKey(e) {
|
|
500
379
|
const o = await this.publicClient.readContract({
|
|
501
380
|
address: this.contractAddress,
|
|
502
|
-
abi:
|
|
381
|
+
abi: h,
|
|
503
382
|
functionName: "getCurrentOperationBtcKey",
|
|
504
383
|
args: [e]
|
|
505
384
|
});
|
|
506
|
-
return
|
|
385
|
+
return C(
|
|
507
386
|
o,
|
|
508
387
|
`getCurrentOperationBtcKey (vp=${e})`
|
|
509
388
|
);
|
|
@@ -527,38 +406,38 @@ class te {
|
|
|
527
406
|
async getVaultKeyEpochs(e) {
|
|
528
407
|
const o = await this.publicClient.readContract({
|
|
529
408
|
address: this.contractAddress,
|
|
530
|
-
abi:
|
|
409
|
+
abi: K,
|
|
531
410
|
functionName: "getBtcVaultProtocolInfo",
|
|
532
411
|
args: [e]
|
|
533
412
|
});
|
|
534
|
-
return
|
|
413
|
+
return G(o, e);
|
|
535
414
|
}
|
|
536
415
|
async getVaultKeyEpochsBatch(e) {
|
|
537
416
|
return e.length === 0 ? [] : (await this.publicClient.multicall({
|
|
538
417
|
contracts: e.map((n) => ({
|
|
539
418
|
address: this.contractAddress,
|
|
540
|
-
abi:
|
|
419
|
+
abi: K,
|
|
541
420
|
functionName: "getBtcVaultProtocolInfo",
|
|
542
421
|
args: [n]
|
|
543
422
|
})),
|
|
544
423
|
allowFailure: !1
|
|
545
424
|
})).map(
|
|
546
|
-
(n, i) =>
|
|
425
|
+
(n, i) => G(n, e[i])
|
|
547
426
|
);
|
|
548
427
|
}
|
|
549
428
|
async getVaultBasicInfo(e) {
|
|
550
429
|
const o = await this.publicClient.readContract({
|
|
551
430
|
address: this.contractAddress,
|
|
552
|
-
abi:
|
|
431
|
+
abi: h,
|
|
553
432
|
functionName: "getBtcVaultBasicInfo",
|
|
554
433
|
args: [e]
|
|
555
434
|
});
|
|
556
|
-
return
|
|
435
|
+
return X(o);
|
|
557
436
|
}
|
|
558
437
|
async getVaultProtocolInfo(e) {
|
|
559
438
|
const o = await this.publicClient.readContract({
|
|
560
439
|
address: this.contractAddress,
|
|
561
|
-
abi:
|
|
440
|
+
abi: h,
|
|
562
441
|
functionName: "getBtcVaultProtocolInfo",
|
|
563
442
|
args: [e]
|
|
564
443
|
});
|
|
@@ -568,18 +447,18 @@ class te {
|
|
|
568
447
|
return e.length === 0 ? [] : (await this.publicClient.multicall({
|
|
569
448
|
contracts: e.map((n) => ({
|
|
570
449
|
address: this.contractAddress,
|
|
571
|
-
abi:
|
|
450
|
+
abi: h,
|
|
572
451
|
functionName: "getBtcVaultProtocolInfo",
|
|
573
452
|
args: [n]
|
|
574
453
|
})),
|
|
575
454
|
allowFailure: !1
|
|
576
455
|
})).map((n, i) => {
|
|
577
|
-
const
|
|
578
|
-
if (!
|
|
456
|
+
const s = n;
|
|
457
|
+
if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
|
|
579
458
|
throw new Error(
|
|
580
459
|
`Vault ${e[i]} not found on-chain or has no pegin transaction`
|
|
581
460
|
);
|
|
582
|
-
return A(
|
|
461
|
+
return A(s);
|
|
583
462
|
});
|
|
584
463
|
}
|
|
585
464
|
/**
|
|
@@ -589,7 +468,7 @@ class te {
|
|
|
589
468
|
async getPegInFee(e) {
|
|
590
469
|
return await this.publicClient.readContract({
|
|
591
470
|
address: this.contractAddress,
|
|
592
|
-
abi:
|
|
471
|
+
abi: h,
|
|
593
472
|
functionName: "getPegInFee",
|
|
594
473
|
args: [e]
|
|
595
474
|
});
|
|
@@ -604,13 +483,13 @@ class te {
|
|
|
604
483
|
async getVaultProviderCommission(e) {
|
|
605
484
|
const o = await this.publicClient.readContract({
|
|
606
485
|
address: this.contractAddress,
|
|
607
|
-
abi:
|
|
486
|
+
abi: h,
|
|
608
487
|
functionName: "getVaultProviderCommission",
|
|
609
488
|
args: [e]
|
|
610
489
|
});
|
|
611
|
-
if (!Number.isInteger(o) || o < 0 || o >
|
|
490
|
+
if (!Number.isInteger(o) || o < 0 || o > L)
|
|
612
491
|
throw new Error(
|
|
613
|
-
`getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${
|
|
492
|
+
`getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${L}]`
|
|
614
493
|
);
|
|
615
494
|
return o;
|
|
616
495
|
}
|
|
@@ -619,24 +498,24 @@ class te {
|
|
|
619
498
|
contracts: [
|
|
620
499
|
{
|
|
621
500
|
address: this.contractAddress,
|
|
622
|
-
abi:
|
|
501
|
+
abi: h,
|
|
623
502
|
functionName: "getBtcVaultBasicInfo",
|
|
624
503
|
args: [e]
|
|
625
504
|
},
|
|
626
505
|
{
|
|
627
506
|
address: this.contractAddress,
|
|
628
|
-
abi:
|
|
507
|
+
abi: h,
|
|
629
508
|
functionName: "getBtcVaultProtocolInfo",
|
|
630
509
|
args: [e]
|
|
631
510
|
}
|
|
632
511
|
],
|
|
633
512
|
allowFailure: !1
|
|
634
|
-
}), i =
|
|
635
|
-
if (!
|
|
513
|
+
}), i = X(o), s = A(n);
|
|
514
|
+
if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
|
|
636
515
|
throw new Error(
|
|
637
516
|
`Vault ${e} not found on-chain or has no pegin transaction`
|
|
638
517
|
);
|
|
639
|
-
return { basic: i, protocol:
|
|
518
|
+
return { basic: i, protocol: s };
|
|
640
519
|
}
|
|
641
520
|
/**
|
|
642
521
|
* Read the depositor's commission ceiling (`maxAcceptableCommissionBps`)
|
|
@@ -660,23 +539,23 @@ class te {
|
|
|
660
539
|
if (e.length === 0) return [];
|
|
661
540
|
const n = await this.publicClient.getLogs({
|
|
662
541
|
address: this.contractAddress,
|
|
663
|
-
events:
|
|
542
|
+
events: Xt,
|
|
664
543
|
fromBlock: o,
|
|
665
544
|
toBlock: o,
|
|
666
545
|
strict: !0
|
|
667
546
|
});
|
|
668
547
|
if (n.length === 0)
|
|
669
|
-
throw new
|
|
548
|
+
throw new st(o);
|
|
670
549
|
return e.map((i) => {
|
|
671
|
-
const
|
|
672
|
-
let
|
|
673
|
-
const
|
|
674
|
-
for (const
|
|
675
|
-
|
|
676
|
-
if (
|
|
677
|
-
throw
|
|
678
|
-
`Expected one PegInSubmittedV2 log for vault ${i} at block ${o}, found ${
|
|
679
|
-
) :
|
|
550
|
+
const s = i.toLowerCase();
|
|
551
|
+
let r = !1;
|
|
552
|
+
const c = [];
|
|
553
|
+
for (const u of n)
|
|
554
|
+
u.args.vaultId.toLowerCase() === s && (r = !0, u.eventName === "PegInSubmittedV2" && c.push(u.args.maxAcceptableCommissionBps));
|
|
555
|
+
if (c.length === 1) return c[0];
|
|
556
|
+
throw c.length > 1 ? new Error(
|
|
557
|
+
`Expected one PegInSubmittedV2 log for vault ${i} at block ${o}, found ${c.length} PegInSubmittedV2 logs`
|
|
558
|
+
) : r ? new Error(
|
|
680
559
|
`Vault ${i} was registered before the registry emitted the depositor's commission ceiling (no PegInSubmittedV2 log at block ${o}), so the ceiling cannot be recovered on-chain`
|
|
681
560
|
) : new Error(
|
|
682
561
|
`Vault ${i} has no registration log at its on-chain registration block ${o}`
|
|
@@ -684,29 +563,29 @@ class te {
|
|
|
684
563
|
});
|
|
685
564
|
}
|
|
686
565
|
}
|
|
687
|
-
const
|
|
688
|
-
function
|
|
566
|
+
const Gt = 0, Qt = 255, Yt = 12e4;
|
|
567
|
+
function P(t, e) {
|
|
689
568
|
const o = t.startsWith("0x") ? t : t.startsWith("0X") ? `0x${t.slice(2)}` : `0x${t}`;
|
|
690
569
|
if (!/^0x(?:[0-9a-fA-F]{2})+$/.test(o))
|
|
691
570
|
throw new Error(`${e} must be non-empty, even-length hex`);
|
|
692
571
|
return o;
|
|
693
572
|
}
|
|
694
|
-
function
|
|
573
|
+
function k(t, e) {
|
|
695
574
|
if (!/^0x[0-9a-fA-F]{64}$/.test(t))
|
|
696
575
|
throw new Error(`${e} must be a 32-byte hex value`);
|
|
697
576
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
700
|
-
if (
|
|
577
|
+
const jt = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
578
|
+
function Q(t) {
|
|
579
|
+
if (k(t, "expectedFingerprint"), t.toLowerCase() === jt)
|
|
701
580
|
throw new Error(
|
|
702
581
|
"expectedFingerprint must not be zero: the registry cannot resolve a zero fingerprint, so this submission would always revert"
|
|
703
582
|
);
|
|
704
583
|
}
|
|
705
|
-
function
|
|
706
|
-
if (!Number.isInteger(t) || t < 0 || t >
|
|
584
|
+
function Zt(t) {
|
|
585
|
+
if (!Number.isInteger(t) || t < 0 || t > Qt)
|
|
707
586
|
throw new Error(`htlcVout must be a uint8, got ${t}`);
|
|
708
587
|
}
|
|
709
|
-
class
|
|
588
|
+
class he {
|
|
710
589
|
constructor(e) {
|
|
711
590
|
this.config = e;
|
|
712
591
|
}
|
|
@@ -715,36 +594,36 @@ class Pe {
|
|
|
715
594
|
...e,
|
|
716
595
|
popSignature: { ...e.popSignature }
|
|
717
596
|
};
|
|
718
|
-
this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps),
|
|
719
|
-
const n = this.assertPopMatchesEthAccount(o.popSignature), i = this.normalizeBtcPubkey(o.popSignature),
|
|
597
|
+
this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), Q(o.expectedFingerprint);
|
|
598
|
+
const n = this.assertPopMatchesEthAccount(o.popSignature), i = this.normalizeBtcPubkey(o.popSignature), s = P(
|
|
720
599
|
o.popSignature.btcPopSignature,
|
|
721
600
|
"btcPopSignature"
|
|
722
|
-
),
|
|
601
|
+
), r = this.normalizeRequest(
|
|
723
602
|
o,
|
|
724
603
|
n,
|
|
725
604
|
i
|
|
726
605
|
);
|
|
727
606
|
await this.assertVaultDoesNotExist(
|
|
728
|
-
|
|
729
|
-
|
|
607
|
+
r.vaultId,
|
|
608
|
+
r.peginTxHash
|
|
730
609
|
);
|
|
731
|
-
const
|
|
610
|
+
const c = await this.readPeginFee(o.vaultProvider), u = await this.resolveMaxAcceptableCommissionBps(
|
|
732
611
|
o.vaultProvider,
|
|
733
612
|
o.quotedCommissionBps
|
|
734
|
-
),
|
|
735
|
-
abi:
|
|
613
|
+
), l = N({
|
|
614
|
+
abi: h,
|
|
736
615
|
functionName: "submitPeginRequest",
|
|
737
616
|
args: [
|
|
738
617
|
n,
|
|
739
618
|
i,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
619
|
+
s,
|
|
620
|
+
r.unsignedPrePeginTx,
|
|
621
|
+
r.depositorSignedPeginTx,
|
|
743
622
|
o.vaultProvider,
|
|
744
|
-
|
|
623
|
+
u,
|
|
745
624
|
o.hashlock,
|
|
746
625
|
o.htlcVout,
|
|
747
|
-
|
|
626
|
+
r.payoutScript,
|
|
748
627
|
o.depositorWotsPkHash,
|
|
749
628
|
// Appended last on the singular overload; the batch takes it at
|
|
750
629
|
// position 4 instead. Order is the selector, so do not "tidy" either.
|
|
@@ -753,83 +632,83 @@ class Pe {
|
|
|
753
632
|
});
|
|
754
633
|
return {
|
|
755
634
|
ethTxHash: await this.sendAndWait(
|
|
756
|
-
|
|
757
|
-
|
|
635
|
+
l,
|
|
636
|
+
c,
|
|
758
637
|
!1,
|
|
759
638
|
n
|
|
760
639
|
),
|
|
761
|
-
vaultId:
|
|
762
|
-
peginTxHash:
|
|
640
|
+
vaultId: r.vaultId,
|
|
641
|
+
peginTxHash: r.peginTxHash
|
|
763
642
|
};
|
|
764
643
|
}
|
|
765
644
|
async registerPeginBatchOnChain(e) {
|
|
766
645
|
const o = {
|
|
767
646
|
...e,
|
|
768
647
|
popSignature: { ...e.popSignature },
|
|
769
|
-
requests: e.requests.map((
|
|
648
|
+
requests: e.requests.map((a) => ({ ...a }))
|
|
770
649
|
};
|
|
771
650
|
if (o.requests.length === 0)
|
|
772
651
|
throw new Error("Batch pegin requires at least one request");
|
|
773
|
-
this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps),
|
|
774
|
-
const n = this.assertPopMatchesEthAccount(o.popSignature), i =
|
|
652
|
+
this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), Q(o.expectedFingerprint);
|
|
653
|
+
const n = this.assertPopMatchesEthAccount(o.popSignature), i = P(
|
|
775
654
|
o.unsignedPrePeginTx,
|
|
776
655
|
"unsignedPrePeginTx"
|
|
777
|
-
),
|
|
656
|
+
), s = this.normalizeBtcPubkey(o.popSignature), r = P(
|
|
778
657
|
o.popSignature.btcPopSignature,
|
|
779
658
|
"btcPopSignature"
|
|
780
|
-
),
|
|
781
|
-
for (const
|
|
782
|
-
const
|
|
659
|
+
), c = [], u = [], l = /* @__PURE__ */ new Set();
|
|
660
|
+
for (const a of o.requests) {
|
|
661
|
+
const d = this.normalizeRequest(
|
|
783
662
|
{
|
|
784
|
-
...
|
|
663
|
+
...a,
|
|
785
664
|
unsignedPrePeginTx: o.unsignedPrePeginTx,
|
|
786
665
|
vaultProvider: o.vaultProvider,
|
|
787
666
|
depositorBtcPubkeyRaw: o.depositorBtcPubkeyRaw
|
|
788
667
|
},
|
|
789
668
|
n,
|
|
790
|
-
|
|
669
|
+
s
|
|
791
670
|
);
|
|
792
|
-
if (
|
|
793
|
-
throw new Error(`Duplicate vault in batch: ${
|
|
794
|
-
|
|
795
|
-
vaultId:
|
|
796
|
-
peginTxHash:
|
|
797
|
-
}),
|
|
798
|
-
depositorBtcPubKey:
|
|
799
|
-
btcPopSignature:
|
|
671
|
+
if (l.has(d.vaultId))
|
|
672
|
+
throw new Error(`Duplicate vault in batch: ${d.vaultId}`);
|
|
673
|
+
l.add(d.vaultId), c.push({
|
|
674
|
+
vaultId: d.vaultId,
|
|
675
|
+
peginTxHash: d.peginTxHash
|
|
676
|
+
}), u.push({
|
|
677
|
+
depositorBtcPubKey: s,
|
|
678
|
+
btcPopSignature: r,
|
|
800
679
|
unsignedPrePeginTx: i,
|
|
801
|
-
depositorSignedPeginTx:
|
|
802
|
-
hashlock:
|
|
803
|
-
htlcVout:
|
|
804
|
-
referralCode:
|
|
805
|
-
depositorPayoutBtcAddress:
|
|
806
|
-
depositorWotsPkHash:
|
|
680
|
+
depositorSignedPeginTx: d.depositorSignedPeginTx,
|
|
681
|
+
hashlock: a.hashlock,
|
|
682
|
+
htlcVout: a.htlcVout,
|
|
683
|
+
referralCode: Gt,
|
|
684
|
+
depositorPayoutBtcAddress: d.payoutScript,
|
|
685
|
+
depositorWotsPkHash: a.depositorWotsPkHash
|
|
807
686
|
});
|
|
808
687
|
}
|
|
809
|
-
for (const
|
|
810
|
-
await this.assertVaultDoesNotExist(
|
|
811
|
-
const
|
|
688
|
+
for (const a of c)
|
|
689
|
+
await this.assertVaultDoesNotExist(a.vaultId, a.peginTxHash);
|
|
690
|
+
const g = await this.readPeginFee(o.vaultProvider), b = await this.resolveMaxAcceptableCommissionBps(
|
|
812
691
|
o.vaultProvider,
|
|
813
692
|
o.quotedCommissionBps
|
|
814
|
-
),
|
|
815
|
-
abi:
|
|
693
|
+
), f = N({
|
|
694
|
+
abi: h,
|
|
816
695
|
functionName: "submitPeginRequestBatch",
|
|
817
696
|
// `expectedFingerprint` sits BEFORE `requests`, not appended. Reordering
|
|
818
697
|
// these five changes the selector and the call stops existing.
|
|
819
698
|
args: [
|
|
820
699
|
n,
|
|
821
700
|
o.vaultProvider,
|
|
822
|
-
|
|
701
|
+
b,
|
|
823
702
|
o.expectedFingerprint,
|
|
824
|
-
|
|
703
|
+
u
|
|
825
704
|
]
|
|
826
705
|
});
|
|
827
706
|
return { ethTxHash: await this.sendAndWait(
|
|
828
|
-
|
|
829
|
-
|
|
707
|
+
f,
|
|
708
|
+
g * BigInt(o.requests.length),
|
|
830
709
|
!0,
|
|
831
710
|
n
|
|
832
|
-
), vaults:
|
|
711
|
+
), vaults: c };
|
|
833
712
|
}
|
|
834
713
|
assertQuotedCommissionPresentWhenRequired(e) {
|
|
835
714
|
if (e === void 0 && this.config.requireQuotedCommissionBps)
|
|
@@ -843,15 +722,15 @@ class Pe {
|
|
|
843
722
|
assertEthAccount(e) {
|
|
844
723
|
const o = this.config.ethWallet.account;
|
|
845
724
|
if (!o) throw new Error("Ethereum wallet account not found");
|
|
846
|
-
if (!
|
|
725
|
+
if (!gt(e, o.address))
|
|
847
726
|
throw new Error(
|
|
848
727
|
`Proof of possession was signed for ${e} but the Ethereum wallet is currently connected to ${o.address}. Reconnect the original account or sign a new proof of possession.`
|
|
849
728
|
);
|
|
850
729
|
return o.address;
|
|
851
730
|
}
|
|
852
731
|
normalizeBtcPubkey(e) {
|
|
853
|
-
return `0x${
|
|
854
|
-
|
|
732
|
+
return `0x${C(
|
|
733
|
+
P(e.depositorBtcPubkey, "Proof of possession BTC pubkey"),
|
|
855
734
|
"Proof of possession BTC pubkey"
|
|
856
735
|
)}`;
|
|
857
736
|
}
|
|
@@ -860,33 +739,33 @@ class Pe {
|
|
|
860
739
|
// value through a per-request helper that has no use for it. It is validated
|
|
861
740
|
// once per call, at the top of each public method.
|
|
862
741
|
normalizeRequest(e, o, n) {
|
|
863
|
-
|
|
864
|
-
const i =
|
|
742
|
+
k(e.hashlock, "hashlock"), k(e.depositorWotsPkHash, "depositorWotsPkHash"), Zt(e.htlcVout);
|
|
743
|
+
const i = P(
|
|
865
744
|
e.unsignedPrePeginTx,
|
|
866
745
|
"unsignedPrePeginTx"
|
|
867
|
-
),
|
|
746
|
+
), s = P(
|
|
868
747
|
e.depositorSignedPeginTx,
|
|
869
748
|
"depositorSignedPeginTx"
|
|
870
|
-
),
|
|
749
|
+
), r = Pt(s);
|
|
871
750
|
return {
|
|
872
751
|
unsignedPrePeginTx: i,
|
|
873
|
-
depositorSignedPeginTx:
|
|
874
|
-
payoutScript:
|
|
752
|
+
depositorSignedPeginTx: s,
|
|
753
|
+
payoutScript: Ut(
|
|
875
754
|
e.depositorPayoutScriptPubKey,
|
|
876
755
|
n,
|
|
877
756
|
e.depositorBtcPubkeyRaw
|
|
878
757
|
),
|
|
879
|
-
peginTxHash:
|
|
880
|
-
vaultId:
|
|
758
|
+
peginTxHash: r,
|
|
759
|
+
vaultId: P(bt(r, o), "vaultId")
|
|
881
760
|
};
|
|
882
761
|
}
|
|
883
762
|
async assertVaultDoesNotExist(e, o) {
|
|
884
763
|
if ((await this.config.publicClient.readContract({
|
|
885
764
|
address: this.config.btcVaultRegistry,
|
|
886
|
-
abi:
|
|
765
|
+
abi: h,
|
|
887
766
|
functionName: "getBtcVaultBasicInfo",
|
|
888
767
|
args: [e]
|
|
889
|
-
})).depositor !==
|
|
768
|
+
})).depositor !== ft)
|
|
890
769
|
throw new Error(
|
|
891
770
|
`Vault already exists (ID: ${e}, peginTxHash: ${o}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
|
|
892
771
|
);
|
|
@@ -895,7 +774,7 @@ class Pe {
|
|
|
895
774
|
try {
|
|
896
775
|
return await this.config.publicClient.readContract({
|
|
897
776
|
address: this.config.btcVaultRegistry,
|
|
898
|
-
abi:
|
|
777
|
+
abi: h,
|
|
899
778
|
functionName: "getPegInFee",
|
|
900
779
|
args: [e]
|
|
901
780
|
});
|
|
@@ -909,7 +788,7 @@ class Pe {
|
|
|
909
788
|
async resolveMaxAcceptableCommissionBps(e, o) {
|
|
910
789
|
let n;
|
|
911
790
|
try {
|
|
912
|
-
n = await new
|
|
791
|
+
n = await new zt(
|
|
913
792
|
this.config.publicClient,
|
|
914
793
|
this.config.btcVaultRegistry
|
|
915
794
|
).getVaultProviderCommission(e);
|
|
@@ -920,67 +799,65 @@ class Pe {
|
|
|
920
799
|
);
|
|
921
800
|
}
|
|
922
801
|
if (o !== void 0) {
|
|
923
|
-
if (n > o +
|
|
802
|
+
if (n > o + v)
|
|
924
803
|
throw new Error(
|
|
925
|
-
`Vault provider commission changed since quote: quoted ${o} bps, chain currently reports ${n} bps (allowed drift ${
|
|
804
|
+
`Vault provider commission changed since quote: quoted ${o} bps, chain currently reports ${n} bps (allowed drift ${v} bps). Please refresh and try again.`
|
|
926
805
|
);
|
|
927
|
-
return
|
|
806
|
+
return M(o);
|
|
928
807
|
}
|
|
929
|
-
return
|
|
808
|
+
return M(n);
|
|
930
809
|
}
|
|
931
810
|
async sendAndWait(e, o, n, i) {
|
|
932
|
-
let
|
|
811
|
+
let s = this.assertEthAccount(i), r;
|
|
933
812
|
try {
|
|
934
|
-
|
|
813
|
+
r = await this.config.publicClient.estimateGas({
|
|
935
814
|
to: this.config.btcVaultRegistry,
|
|
936
815
|
data: e,
|
|
937
816
|
value: o,
|
|
938
|
-
account:
|
|
817
|
+
account: s
|
|
939
818
|
});
|
|
940
|
-
} catch (
|
|
941
|
-
|
|
819
|
+
} catch (l) {
|
|
820
|
+
T(l);
|
|
942
821
|
}
|
|
943
|
-
|
|
944
|
-
let
|
|
822
|
+
s = this.assertEthAccount(i);
|
|
823
|
+
let c;
|
|
945
824
|
try {
|
|
946
|
-
|
|
825
|
+
c = await this.config.ethWallet.sendTransaction({
|
|
947
826
|
to: this.config.btcVaultRegistry,
|
|
948
827
|
data: e,
|
|
949
828
|
value: o,
|
|
950
|
-
gas:
|
|
951
|
-
account:
|
|
829
|
+
gas: r,
|
|
830
|
+
account: s,
|
|
952
831
|
chain: this.config.ethChain
|
|
953
832
|
});
|
|
954
|
-
} catch (
|
|
955
|
-
|
|
833
|
+
} catch (l) {
|
|
834
|
+
T(l);
|
|
956
835
|
}
|
|
957
|
-
const
|
|
836
|
+
const u = await mt({
|
|
958
837
|
publicClient: this.config.publicClient,
|
|
959
838
|
walletAddress: i,
|
|
960
|
-
hash:
|
|
961
|
-
timeout: this.config.receiptTimeoutMs ??
|
|
839
|
+
hash: c,
|
|
840
|
+
timeout: this.config.receiptTimeoutMs ?? Yt
|
|
962
841
|
});
|
|
963
|
-
return
|
|
842
|
+
return u.status === "reverted" && T(
|
|
964
843
|
new Error(
|
|
965
|
-
`${n ? "Batch transaction" : "Transaction"} reverted. Hash: ${
|
|
844
|
+
`${n ? "Batch transaction" : "Transaction"} reverted. Hash: ${u.transactionHash}. Check a block explorer for details.`
|
|
966
845
|
)
|
|
967
|
-
),
|
|
846
|
+
), u.transactionHash;
|
|
968
847
|
}
|
|
969
848
|
}
|
|
970
849
|
export {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
kt as r,
|
|
984
|
-
Yt as v
|
|
850
|
+
v as C,
|
|
851
|
+
xt as M,
|
|
852
|
+
st as R,
|
|
853
|
+
he as V,
|
|
854
|
+
ce as a,
|
|
855
|
+
Wt as b,
|
|
856
|
+
zt as c,
|
|
857
|
+
M as d,
|
|
858
|
+
qt as e,
|
|
859
|
+
ue as i,
|
|
860
|
+
$t as r,
|
|
861
|
+
Dt as v
|
|
985
862
|
};
|
|
986
|
-
//# sourceMappingURL=pegin-registration-client-
|
|
863
|
+
//# sourceMappingURL=pegin-registration-client-1sZ-74UC.js.map
|