@babylonlabs-io/ts-sdk 0.66.1 → 0.68.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/dist/PeginManager--2R3T2S8.js +1458 -0
- package/dist/PeginManager--2R3T2S8.js.map +1 -0
- package/dist/PeginManager-CKWq8ouZ.cjs +2 -0
- package/dist/PeginManager-CKWq8ouZ.cjs.map +1 -0
- package/dist/{batchPoll-cIxrSLLJ.js → batchPoll-Cjj1du0i.js} +372 -421
- package/dist/batchPoll-Cjj1du0i.js.map +1 -0
- package/dist/batchPoll-REVZiE-M.cjs +2 -0
- package/dist/batchPoll-REVZiE-M.cjs.map +1 -0
- package/dist/{bitcoin-d9eaaZB_.js → bitcoin-Ch_jxnDa.js} +3 -3
- package/dist/{bitcoin-d9eaaZB_.js.map → bitcoin-Ch_jxnDa.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-C4LiPATK.js → buildAndBroadcastRefund-CpMDJ8up.js} +142 -150
- package/dist/buildAndBroadcastRefund-CpMDJ8up.js.map +1 -0
- package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs +2 -0
- package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs.map +1 -0
- package/dist/challengeAssert-BNQ8sToz.js +64 -0
- package/dist/challengeAssert-BNQ8sToz.js.map +1 -0
- package/dist/challengeAssert-BrpC3-cQ.cjs +2 -0
- package/dist/challengeAssert-BrpC3-cQ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +246 -243
- package/dist/mempoolApi-EU1La9wk.cjs +2 -0
- package/dist/{mempoolApi-CXfr-L6x.cjs.map → mempoolApi-EU1La9wk.cjs.map} +1 -1
- package/dist/{mempoolApi-BxSINXIB.js → mempoolApi-_D-jvtj_.js} +191 -117
- package/dist/{mempoolApi-BxSINXIB.js.map → mempoolApi-_D-jvtj_.js.map} +1 -1
- package/dist/{noPayout-BaZGRLD2.js → noPayout-CXn-geIS.js} +3 -3
- package/dist/{noPayout-BaZGRLD2.js.map → noPayout-CXn-geIS.js.map} +1 -1
- package/dist/{noPayout-CnQ1WLtr.cjs → noPayout-Ox27Td9x.cjs} +2 -2
- package/dist/{noPayout-CnQ1WLtr.cjs.map → noPayout-Ox27Td9x.cjs.map} +1 -1
- package/dist/{onChainBtcPubkey-DeF4cKoO.js → onChainBtcPubkey-BAHZyKQL.js} +2 -2
- package/dist/{onChainBtcPubkey-DeF4cKoO.js.map → onChainBtcPubkey-BAHZyKQL.js.map} +1 -1
- package/dist/{parseFundingOutpoints-pBRE11Hr.js → parseFundingOutpoints-CO-f6IHK.js} +2 -2
- package/dist/{parseFundingOutpoints-pBRE11Hr.js.map → parseFundingOutpoints-CO-f6IHK.js.map} +1 -1
- package/dist/{reservation-B4i_PQhY.js → reservation-CBAvoF3U.js} +2 -2
- package/dist/{reservation-B4i_PQhY.js.map → reservation-CBAvoF3U.js.map} +1 -1
- package/dist/{signPsbtsWithFallback-Bb66DfY5.js → signPsbtsWithFallback-Bv79gLFe.js} +122 -100
- package/dist/signPsbtsWithFallback-Bv79gLFe.js.map +1 -0
- package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs +2 -0
- package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +3 -3
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts +32 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts +9 -6
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts +45 -20
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts +2 -0
- package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts.map +1 -0
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts +42 -5
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts +10 -5
- package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +244 -241
- package/dist/tbv/core/managers/PayoutManager.d.ts +8 -2
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +7 -0
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts +11 -0
- package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts.map +1 -0
- package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts.map +1 -1
- package/dist/tbv/core/managers/pegin/index.d.ts +1 -0
- package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
- package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts +21 -0
- package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts.map +1 -0
- package/dist/tbv/core/primitives/challengers.d.ts +31 -5
- package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +2 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +43 -41
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +5 -0
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts +12 -0
- package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts +19 -7
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +2 -2
- package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts +64 -0
- package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts +40 -0
- package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts +2 -1
- package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts +13 -0
- package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/utils/taproot.d.ts +29 -0
- package/dist/tbv/core/primitives/utils/taproot.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +2 -2
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +2 -2
- package/dist/tbv/core/utils/index.js +2 -2
- package/dist/tbv/core/utils/witness/witnessStack.d.ts +24 -0
- package/dist/tbv/core/utils/witness/witnessStack.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +244 -241
- package/dist/tbv/integrations/aave/clients/__tests__/query.test.d.ts +11 -0
- package/dist/tbv/integrations/aave/clients/__tests__/query.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/query.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.js +132 -114
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/testing/MockBitcoinWallet.d.ts +10 -1
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
- package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts +2 -0
- package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts.map +1 -0
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +134 -47
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/signBip322P2wpkhWitness.d.ts +20 -0
- package/dist/testing/signBip322P2wpkhWitness.d.ts.map +1 -0
- package/dist/{toRefundInputs-BY_fcvrv.js → toRefundInputs-9hv_6k0E.js} +6 -6
- package/dist/{toRefundInputs-BY_fcvrv.js.map → toRefundInputs-9hv_6k0E.js.map} +1 -1
- package/dist/{toRefundInputs-DYL9C-aG.cjs → toRefundInputs-D8sFs44p.cjs} +2 -2
- package/dist/{toRefundInputs-DYL9C-aG.cjs.map → toRefundInputs-D8sFs44p.cjs.map} +1 -1
- package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs +2 -0
- package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs.map +1 -0
- package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js +363 -0
- package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js +931 -0
- package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/PeginManager-BBl4xkWz.js +0 -1359
- package/dist/PeginManager-BBl4xkWz.js.map +0 -1
- package/dist/PeginManager-p-ajwSxG.cjs +0 -2
- package/dist/PeginManager-p-ajwSxG.cjs.map +0 -1
- package/dist/batchPoll-6L5oToGr.cjs +0 -2
- package/dist/batchPoll-6L5oToGr.cjs.map +0 -1
- package/dist/batchPoll-cIxrSLLJ.js.map +0 -1
- package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +0 -2
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +0 -1
- package/dist/challengeAssert-BFRE2DM-.cjs +0 -2
- package/dist/challengeAssert-BFRE2DM-.cjs.map +0 -1
- package/dist/challengeAssert-C7PzyJ7g.js +0 -75
- package/dist/challengeAssert-C7PzyJ7g.js.map +0 -1
- package/dist/mempoolApi-CXfr-L6x.cjs +0 -2
- package/dist/peginInput-Ci921gTl.cjs +0 -2
- package/dist/peginInput-Ci921gTl.cjs.map +0 -1
- package/dist/peginInput-HQPWZfly.js +0 -123
- package/dist/peginInput-HQPWZfly.js.map +0 -1
- package/dist/signPsbtsWithFallback-Bb66DfY5.js.map +0 -1
- package/dist/signPsbtsWithFallback-PTgWxsG3.cjs +0 -2
- package/dist/signPsbtsWithFallback-PTgWxsG3.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-i-koT139.js +0 -817
- package/dist/verifyScriptPathSchnorrSignature-i-koT139.js.map +0 -1
|
@@ -1,45 +1,117 @@
|
|
|
1
|
+
import * as p from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
2
|
+
import { Transaction as u, payments as b, script as D } from "bitcoinjs-lib";
|
|
3
|
+
import { s as T } from "./sha2-BYVxyZzX.js";
|
|
4
|
+
import { Buffer as c } from "buffer";
|
|
1
5
|
import { B as a } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
|
|
2
|
-
import { B as
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import { B as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
|
|
6
|
+
import { B as y } from "./BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
|
|
7
|
+
import { a as A } from "./onChainBtcPubkey-BAHZyKQL.js";
|
|
8
|
+
import { a as G } from "./constants-GjWXdaqV.js";
|
|
9
|
+
import { B as L, H as W, K as Q, T as j, c as z } from "./validation-Dj3dqYtl.js";
|
|
10
|
+
const Y = "BIP0322-signed-message", Z = "TapTweak", N = 32, J = 64, q = 33, tt = 71, et = 72, g = 0, V = 0, C = 0, v = 0, ot = 32, nt = 4294967295, rt = 0, it = 0, st = 32, at = 106;
|
|
11
|
+
function k(t, e) {
|
|
12
|
+
const o = new TextEncoder().encode(t), n = T(o), i = new Uint8Array(n.length * 2 + e.length);
|
|
13
|
+
return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), T(i);
|
|
14
|
+
}
|
|
15
|
+
function ct(t) {
|
|
16
|
+
if (t.length !== N) return null;
|
|
17
|
+
const e = k(Z, t), o = p.xOnlyPointAddTweak(t, e);
|
|
18
|
+
return o ? o.xOnlyPubkey : null;
|
|
19
|
+
}
|
|
20
|
+
function U(t, e) {
|
|
21
|
+
const o = k(Y, t), n = new u();
|
|
22
|
+
n.version = V, n.locktime = C;
|
|
23
|
+
const i = c.concat([
|
|
24
|
+
c.from([it, st]),
|
|
25
|
+
c.from(o)
|
|
26
|
+
]);
|
|
27
|
+
n.addInput(
|
|
28
|
+
c.alloc(ot, 0),
|
|
29
|
+
nt,
|
|
30
|
+
v,
|
|
31
|
+
i
|
|
32
|
+
), n.addOutput(e, g);
|
|
33
|
+
const r = new u();
|
|
34
|
+
return r.version = V, r.locktime = C, r.addInput(
|
|
35
|
+
n.getHash(),
|
|
36
|
+
rt,
|
|
37
|
+
v
|
|
38
|
+
), r.addOutput(c.from([at]), g), r;
|
|
39
|
+
}
|
|
40
|
+
function At(t, e, o, n = u.SIGHASH_DEFAULT) {
|
|
41
|
+
if (e.length !== N || o.length !== J || n !== u.SIGHASH_DEFAULT && n !== u.SIGHASH_ALL)
|
|
42
|
+
return !1;
|
|
43
|
+
try {
|
|
44
|
+
const i = b.p2tr({
|
|
45
|
+
internalPubkey: c.from(e)
|
|
46
|
+
});
|
|
47
|
+
if (!i.output) return !1;
|
|
48
|
+
const r = i.output, h = U(t, r).hashForWitnessV1(
|
|
49
|
+
0,
|
|
50
|
+
[r],
|
|
51
|
+
[g],
|
|
52
|
+
n
|
|
53
|
+
), m = ct(e);
|
|
54
|
+
return m ? p.verifySchnorr(h, m, o) : !1;
|
|
55
|
+
} catch {
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function Vt(t, e, o) {
|
|
60
|
+
if (e.length !== q || o.length < tt || o.length > et)
|
|
61
|
+
return !1;
|
|
62
|
+
try {
|
|
63
|
+
if (!p.isPointCompressed(e)) return !1;
|
|
64
|
+
const { signature: n, hashType: i } = D.signature.decode(
|
|
65
|
+
c.from(o)
|
|
66
|
+
);
|
|
67
|
+
if (i !== u.SIGHASH_ALL) return !1;
|
|
68
|
+
const r = b.p2wpkh({ pubkey: c.from(e) });
|
|
69
|
+
if (!r.output || !r.hash) return !1;
|
|
70
|
+
const s = U(t, r.output), h = b.p2pkh({ hash: r.hash }).output;
|
|
71
|
+
if (!h) return !1;
|
|
72
|
+
const m = s.hashForWitnessV0(0, h, g, i);
|
|
73
|
+
return p.verify(m, e, n, !0);
|
|
74
|
+
} catch {
|
|
75
|
+
return !1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const P = 65535, S = 1e4, d = 4294967295, _ = 255;
|
|
79
|
+
function ut(t) {
|
|
80
|
+
if (!Number.isInteger(t) || t < 0 || t > d)
|
|
9
81
|
throw new Error(
|
|
10
82
|
`Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`
|
|
11
83
|
);
|
|
12
84
|
}
|
|
13
|
-
function
|
|
85
|
+
function lt(t) {
|
|
14
86
|
const e = [];
|
|
15
87
|
if (t.timelockAssert <= 0n && e.push(
|
|
16
88
|
`timelockAssert must be positive, got ${t.timelockAssert}`
|
|
17
|
-
), t.timelockAssert > BigInt(
|
|
18
|
-
`timelockAssert ${t.timelockAssert} exceeds uint16 max (${
|
|
89
|
+
), t.timelockAssert > BigInt(P) && e.push(
|
|
90
|
+
`timelockAssert ${t.timelockAssert} exceeds uint16 max (${P})`
|
|
19
91
|
), t.timelockChallengeAssert <= 0n && e.push(
|
|
20
92
|
`timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`
|
|
21
93
|
), 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(
|
|
22
94
|
`councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`
|
|
23
95
|
), t.feeRate <= 0n && e.push(`feeRate must be positive, got ${t.feeRate}`), t.minPeginFeeRate <= 0n && e.push(
|
|
24
96
|
`minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`
|
|
25
|
-
), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion >
|
|
97
|
+
), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > P) && e.push(
|
|
26
98
|
`proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`
|
|
27
|
-
), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth >
|
|
28
|
-
`minPrepeginDepth must be a uint32 in [1, ${
|
|
99
|
+
), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > d) && e.push(
|
|
100
|
+
`minPrepeginDepth must be a uint32 in [1, ${d}], got ${t.minPrepeginDepth}`
|
|
29
101
|
), t.babeTotalInstances <= 0 && e.push(
|
|
30
102
|
`babeTotalInstances must be positive, got ${t.babeTotalInstances}`
|
|
31
103
|
), t.babeInstancesToFinalize <= 0 && e.push(
|
|
32
104
|
`babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
|
|
33
105
|
), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
|
|
34
106
|
`babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
|
|
35
|
-
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps >
|
|
36
|
-
`minVpCommissionBps must be in [0, ${
|
|
107
|
+
), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > S) && e.push(
|
|
108
|
+
`minVpCommissionBps must be in [0, ${S}], got ${t.minVpCommissionBps}`
|
|
37
109
|
), e.length > 0)
|
|
38
110
|
throw new Error(
|
|
39
111
|
`Invalid offchain protocol parameters: ${e.join("; ")}`
|
|
40
112
|
);
|
|
41
113
|
}
|
|
42
|
-
function
|
|
114
|
+
function ft(t) {
|
|
43
115
|
const e = [];
|
|
44
116
|
if (t.minimumPegInAmount <= 0n && e.push(
|
|
45
117
|
`minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`
|
|
@@ -49,25 +121,25 @@ function R(t) {
|
|
|
49
121
|
`pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
|
|
50
122
|
), t.pegInActivationTimeout <= 0n && e.push(
|
|
51
123
|
`pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
|
|
52
|
-
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount >
|
|
53
|
-
`maxHtlcOutputCount must be an integer in [1, ${
|
|
124
|
+
), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > _) && e.push(
|
|
125
|
+
`maxHtlcOutputCount must be an integer in [1, ${_}], got ${t.maxHtlcOutputCount}`
|
|
54
126
|
), (typeof t.expiredPegInGraceBlocks != "bigint" || t.expiredPegInGraceBlocks <= 0n) && e.push(
|
|
55
127
|
`expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`
|
|
56
128
|
), e.length > 0)
|
|
57
129
|
throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
|
|
58
130
|
}
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
131
|
+
function Ct(t) {
|
|
132
|
+
if (ft(t), lt(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > d)
|
|
61
133
|
throw new Error(
|
|
62
134
|
`Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
|
|
63
135
|
);
|
|
64
|
-
|
|
136
|
+
G(
|
|
65
137
|
t.activeVaultCoreVersion,
|
|
66
138
|
"ProtocolParams.activeVaultCoreVersion()"
|
|
67
139
|
);
|
|
68
140
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
141
|
+
const B = 9999;
|
|
142
|
+
function F(t) {
|
|
71
143
|
return {
|
|
72
144
|
depositor: t.depositor,
|
|
73
145
|
depositorBtcPubKey: t.depositorBtcPubKey,
|
|
@@ -78,9 +150,9 @@ function P(t) {
|
|
|
78
150
|
createdAt: t.createdAt
|
|
79
151
|
};
|
|
80
152
|
}
|
|
81
|
-
function
|
|
153
|
+
function I(t) {
|
|
82
154
|
const e = Number(t.offchainParamsVersion);
|
|
83
|
-
return
|
|
155
|
+
return ut(e), {
|
|
84
156
|
depositorSignedPeginTx: t.depositorSignedPeginTx,
|
|
85
157
|
universalChallengersVersion: t.universalChallengersVersion,
|
|
86
158
|
appVaultKeepersVersion: t.appVaultKeepersVersion,
|
|
@@ -96,26 +168,26 @@ function m(t) {
|
|
|
96
168
|
vaultCoreVersion: t.vaultCoreVersion
|
|
97
169
|
};
|
|
98
170
|
}
|
|
99
|
-
const
|
|
100
|
-
function
|
|
101
|
-
if (t < 0n || t >=
|
|
171
|
+
const ht = 1n << 64n, x = 0n;
|
|
172
|
+
function E(t, e, o) {
|
|
173
|
+
if (t < 0n || t >= ht)
|
|
102
174
|
throw new Error(
|
|
103
175
|
`getBtcVaultProtocolInfo returned ${e}=${t} for vault ${o}, outside the uint64 range — the registry may predate RFC-006`
|
|
104
176
|
);
|
|
105
177
|
return t;
|
|
106
178
|
}
|
|
107
|
-
function
|
|
179
|
+
function O(t, e) {
|
|
108
180
|
return {
|
|
109
|
-
vpKeyEpoch:
|
|
110
|
-
appKeeperKeyEpoch:
|
|
181
|
+
vpKeyEpoch: E(t.vpKeyEpoch, "vpKeyEpoch", e),
|
|
182
|
+
appKeeperKeyEpoch: E(
|
|
111
183
|
t.appKeeperKeyEpoch,
|
|
112
184
|
"appKeeperKeyEpoch",
|
|
113
185
|
e
|
|
114
186
|
),
|
|
115
|
-
ucKeyEpoch:
|
|
187
|
+
ucKeyEpoch: E(t.ucKeyEpoch, "ucKeyEpoch", e)
|
|
116
188
|
};
|
|
117
189
|
}
|
|
118
|
-
class
|
|
190
|
+
class vt {
|
|
119
191
|
constructor(e, o) {
|
|
120
192
|
this.publicClient = e, this.contractAddress = o;
|
|
121
193
|
}
|
|
@@ -147,11 +219,11 @@ class W {
|
|
|
147
219
|
address: this.contractAddress,
|
|
148
220
|
abi: a,
|
|
149
221
|
functionName: "getOperationBtcKeyAtEpoch",
|
|
150
|
-
args: [e,
|
|
222
|
+
args: [e, x]
|
|
151
223
|
});
|
|
152
|
-
return
|
|
224
|
+
return A(
|
|
153
225
|
o,
|
|
154
|
-
`getOperationBtcKeyAtEpoch (vp=${e}, epoch=${
|
|
226
|
+
`getOperationBtcKeyAtEpoch (vp=${e}, epoch=${x})`
|
|
155
227
|
);
|
|
156
228
|
}
|
|
157
229
|
/**
|
|
@@ -172,7 +244,7 @@ class W {
|
|
|
172
244
|
functionName: "getCurrentOperationBtcKey",
|
|
173
245
|
args: [e]
|
|
174
246
|
});
|
|
175
|
-
return
|
|
247
|
+
return A(
|
|
176
248
|
o,
|
|
177
249
|
`getCurrentOperationBtcKey (vp=${e})`
|
|
178
250
|
);
|
|
@@ -196,23 +268,23 @@ class W {
|
|
|
196
268
|
async getVaultKeyEpochs(e) {
|
|
197
269
|
const o = await this.publicClient.readContract({
|
|
198
270
|
address: this.contractAddress,
|
|
199
|
-
abi:
|
|
271
|
+
abi: y,
|
|
200
272
|
functionName: "getBtcVaultProtocolInfo",
|
|
201
273
|
args: [e]
|
|
202
274
|
});
|
|
203
|
-
return
|
|
275
|
+
return O(o, e);
|
|
204
276
|
}
|
|
205
277
|
async getVaultKeyEpochsBatch(e) {
|
|
206
278
|
return e.length === 0 ? [] : (await this.publicClient.multicall({
|
|
207
279
|
contracts: e.map((n) => ({
|
|
208
280
|
address: this.contractAddress,
|
|
209
|
-
abi:
|
|
281
|
+
abi: y,
|
|
210
282
|
functionName: "getBtcVaultProtocolInfo",
|
|
211
283
|
args: [n]
|
|
212
284
|
})),
|
|
213
285
|
allowFailure: !1
|
|
214
286
|
})).map(
|
|
215
|
-
(n, i) =>
|
|
287
|
+
(n, i) => O(n, e[i])
|
|
216
288
|
);
|
|
217
289
|
}
|
|
218
290
|
async getVaultBasicInfo(e) {
|
|
@@ -222,7 +294,7 @@ class W {
|
|
|
222
294
|
functionName: "getBtcVaultBasicInfo",
|
|
223
295
|
args: [e]
|
|
224
296
|
});
|
|
225
|
-
return
|
|
297
|
+
return F(o);
|
|
226
298
|
}
|
|
227
299
|
async getVaultProtocolInfo(e) {
|
|
228
300
|
const o = await this.publicClient.readContract({
|
|
@@ -231,7 +303,7 @@ class W {
|
|
|
231
303
|
functionName: "getBtcVaultProtocolInfo",
|
|
232
304
|
args: [e]
|
|
233
305
|
});
|
|
234
|
-
return
|
|
306
|
+
return I(o);
|
|
235
307
|
}
|
|
236
308
|
async getProtocolInfoBatch(e) {
|
|
237
309
|
return e.length === 0 ? [] : (await this.publicClient.multicall({
|
|
@@ -248,7 +320,7 @@ class W {
|
|
|
248
320
|
throw new Error(
|
|
249
321
|
`Vault ${e[i]} not found on-chain or has no pegin transaction`
|
|
250
322
|
);
|
|
251
|
-
return
|
|
323
|
+
return I(r);
|
|
252
324
|
});
|
|
253
325
|
}
|
|
254
326
|
/**
|
|
@@ -277,9 +349,9 @@ class W {
|
|
|
277
349
|
functionName: "getVaultProviderCommission",
|
|
278
350
|
args: [e]
|
|
279
351
|
});
|
|
280
|
-
if (!Number.isInteger(o) || o < 0 || o >
|
|
352
|
+
if (!Number.isInteger(o) || o < 0 || o > B)
|
|
281
353
|
throw new Error(
|
|
282
|
-
`getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${
|
|
354
|
+
`getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${B}]`
|
|
283
355
|
);
|
|
284
356
|
return o;
|
|
285
357
|
}
|
|
@@ -300,7 +372,7 @@ class W {
|
|
|
300
372
|
}
|
|
301
373
|
],
|
|
302
374
|
allowFailure: !1
|
|
303
|
-
}), i =
|
|
375
|
+
}), i = F(o), r = I(n);
|
|
304
376
|
if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
|
|
305
377
|
throw new Error(
|
|
306
378
|
`Vault ${e} not found on-chain or has no pegin transaction`
|
|
@@ -308,14 +380,14 @@ class W {
|
|
|
308
380
|
return { basic: i, protocol: r };
|
|
309
381
|
}
|
|
310
382
|
}
|
|
311
|
-
const
|
|
312
|
-
async function
|
|
383
|
+
const mt = 21e6 * 1e8, K = 3e4;
|
|
384
|
+
async function w(t, e) {
|
|
313
385
|
const o = new AbortController(), n = setTimeout(
|
|
314
386
|
() => o.abort(),
|
|
315
|
-
|
|
387
|
+
K
|
|
316
388
|
), i = [o.signal, e == null ? void 0 : e.signal].filter(
|
|
317
389
|
Boolean
|
|
318
|
-
), r =
|
|
390
|
+
), r = z(i);
|
|
319
391
|
try {
|
|
320
392
|
return await fetch(t, {
|
|
321
393
|
...e,
|
|
@@ -323,48 +395,48 @@ async function f(t, e) {
|
|
|
323
395
|
});
|
|
324
396
|
} catch (s) {
|
|
325
397
|
throw clearTimeout(n), r.cleanup(), s != null && typeof s == "object" && "name" in s && s.name === "AbortError" ? new Error(
|
|
326
|
-
`Mempool API request timed out after ${
|
|
398
|
+
`Mempool API request timed out after ${K}ms: ${t}`
|
|
327
399
|
) : s;
|
|
328
400
|
}
|
|
329
401
|
}
|
|
330
|
-
const
|
|
331
|
-
function
|
|
332
|
-
return Number.isInteger(t) && t > 0 && t <=
|
|
402
|
+
const R = 1e4;
|
|
403
|
+
function H(t) {
|
|
404
|
+
return Number.isInteger(t) && t > 0 && t <= mt;
|
|
333
405
|
}
|
|
334
|
-
function
|
|
335
|
-
return Number.isInteger(t) && t > 0 && t <=
|
|
406
|
+
function pt(t) {
|
|
407
|
+
return Number.isInteger(t) && t > 0 && t <= R;
|
|
336
408
|
}
|
|
337
|
-
function
|
|
409
|
+
function $(t, e) {
|
|
338
410
|
return !Number.isInteger(t) || t < 0 ? !1 : e === void 0 || t < e;
|
|
339
411
|
}
|
|
340
|
-
function
|
|
341
|
-
if (!
|
|
412
|
+
function f(t) {
|
|
413
|
+
if (!j.test(t))
|
|
342
414
|
throw new Error(`Invalid transaction ID format: ${t}`);
|
|
343
415
|
}
|
|
344
|
-
function
|
|
345
|
-
if (!
|
|
416
|
+
function M(t) {
|
|
417
|
+
if (!L.test(t))
|
|
346
418
|
throw new Error(`Invalid Bitcoin address format: ${t}`);
|
|
347
419
|
}
|
|
348
|
-
function
|
|
349
|
-
if (!
|
|
420
|
+
function X(t, e) {
|
|
421
|
+
if (!W.test(t))
|
|
350
422
|
throw new Error(
|
|
351
423
|
`Invalid scriptPubKey: not valid hex for ${e}`
|
|
352
424
|
);
|
|
353
|
-
if (!
|
|
425
|
+
if (!Q.some(
|
|
354
426
|
(n) => t.toLowerCase().startsWith(n)
|
|
355
427
|
))
|
|
356
428
|
throw new Error(
|
|
357
429
|
`Unrecognized scriptPubKey type for ${e}: prefix ${t.slice(0, 6)} does not match any known Bitcoin script type`
|
|
358
430
|
);
|
|
359
431
|
}
|
|
360
|
-
const
|
|
432
|
+
const gt = {
|
|
361
433
|
mainnet: "https://mempool.space/api",
|
|
362
434
|
testnet: "https://mempool.space/testnet/api",
|
|
363
435
|
signet: "https://mempool.space/signet/api"
|
|
364
436
|
};
|
|
365
|
-
async function
|
|
437
|
+
async function l(t, e) {
|
|
366
438
|
try {
|
|
367
|
-
const o = await
|
|
439
|
+
const o = await w(t, e);
|
|
368
440
|
if (!o.ok) {
|
|
369
441
|
const i = await o.text();
|
|
370
442
|
throw new Error(
|
|
@@ -377,9 +449,9 @@ async function c(t, e) {
|
|
|
377
449
|
throw o instanceof Error ? new Error(`Failed to fetch from mempool API: ${o.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
378
450
|
}
|
|
379
451
|
}
|
|
380
|
-
async function
|
|
452
|
+
async function St(t, e) {
|
|
381
453
|
try {
|
|
382
|
-
const o = await
|
|
454
|
+
const o = await w(`${e}/tx`, {
|
|
383
455
|
method: "POST",
|
|
384
456
|
body: t,
|
|
385
457
|
headers: {
|
|
@@ -404,26 +476,26 @@ async function J(t, e) {
|
|
|
404
476
|
throw o instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${o.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
405
477
|
}
|
|
406
478
|
}
|
|
407
|
-
async function
|
|
408
|
-
return
|
|
479
|
+
async function dt(t, e) {
|
|
480
|
+
return f(t), l(`${e}/tx/${t}`);
|
|
409
481
|
}
|
|
410
|
-
async function
|
|
411
|
-
const e = await
|
|
482
|
+
async function _t(t) {
|
|
483
|
+
const e = await l(`${t}/blocks/tip/height`), o = e.trim();
|
|
412
484
|
if (!/^\d+$/.test(o))
|
|
413
485
|
throw new Error(
|
|
414
486
|
`Mempool API returned an invalid block tip height: "${e}"`
|
|
415
487
|
);
|
|
416
488
|
return Number.parseInt(o, 10);
|
|
417
489
|
}
|
|
418
|
-
async function
|
|
419
|
-
if (
|
|
490
|
+
async function Bt(t, e, o) {
|
|
491
|
+
if (f(t), !$(e))
|
|
420
492
|
throw new Error(`Invalid vout ${e} for transaction ${t}`);
|
|
421
|
-
return
|
|
493
|
+
return l(`${o}/tx/${t}/outspend/${e}`);
|
|
422
494
|
}
|
|
423
|
-
async function
|
|
424
|
-
|
|
495
|
+
async function Ft(t, e) {
|
|
496
|
+
f(t);
|
|
425
497
|
try {
|
|
426
|
-
const o = await
|
|
498
|
+
const o = await w(`${e}/tx/${t}/hex`);
|
|
427
499
|
if (!o.ok) {
|
|
428
500
|
const n = await o.text();
|
|
429
501
|
throw new Error(
|
|
@@ -435,36 +507,36 @@ async function Z(t, e) {
|
|
|
435
507
|
throw o instanceof Error ? new Error(`Failed to get transaction hex for ${t}: ${o.message}`) : new Error(`Failed to get transaction hex for ${t}: Unknown error`);
|
|
436
508
|
}
|
|
437
509
|
}
|
|
438
|
-
async function
|
|
439
|
-
|
|
440
|
-
const n = await
|
|
441
|
-
if (
|
|
510
|
+
async function xt(t, e, o) {
|
|
511
|
+
f(t);
|
|
512
|
+
const n = await dt(t, o);
|
|
513
|
+
if (!$(e, n.vout.length))
|
|
442
514
|
throw new Error(
|
|
443
515
|
`Invalid vout ${e} for transaction ${t} (has ${n.vout.length} outputs)`
|
|
444
516
|
);
|
|
445
517
|
const i = n.vout[e];
|
|
446
|
-
if (!
|
|
518
|
+
if (!H(i.value))
|
|
447
519
|
throw new Error(`Invalid UTXO value ${i.value} for ${t}:${e}`);
|
|
448
|
-
return
|
|
520
|
+
return X(i.scriptpubkey, `${t}:${e}`), {
|
|
449
521
|
txid: t,
|
|
450
522
|
vout: e,
|
|
451
523
|
value: i.value,
|
|
452
524
|
scriptPubKey: i.scriptpubkey
|
|
453
525
|
};
|
|
454
526
|
}
|
|
455
|
-
async function
|
|
456
|
-
|
|
527
|
+
async function Ot(t, e) {
|
|
528
|
+
M(t);
|
|
457
529
|
try {
|
|
458
|
-
const o = await
|
|
530
|
+
const o = await l(`${e}/address/${t}/utxo`), n = await l(`${e}/v1/validate-address/${t}`);
|
|
459
531
|
if (!n.isvalid)
|
|
460
532
|
throw new Error(
|
|
461
533
|
`Invalid Bitcoin address: ${t}. Mempool API validation failed.`
|
|
462
534
|
);
|
|
463
|
-
|
|
535
|
+
X(n.scriptPubKey, t);
|
|
464
536
|
for (const r of o) {
|
|
465
|
-
if (
|
|
537
|
+
if (f(r.txid), !$(r.vout))
|
|
466
538
|
throw new Error(`Invalid vout ${r.vout} for ${r.txid}`);
|
|
467
|
-
if (!
|
|
539
|
+
if (!H(r.value))
|
|
468
540
|
throw new Error(
|
|
469
541
|
`Invalid UTXO value ${r.value} for ${r.txid}:${r.vout}`
|
|
470
542
|
);
|
|
@@ -484,14 +556,14 @@ async function et(t, e) {
|
|
|
484
556
|
);
|
|
485
557
|
}
|
|
486
558
|
}
|
|
487
|
-
function
|
|
488
|
-
return
|
|
559
|
+
function Kt(t) {
|
|
560
|
+
return gt[t];
|
|
489
561
|
}
|
|
490
|
-
async function
|
|
491
|
-
return
|
|
562
|
+
async function Nt(t, e) {
|
|
563
|
+
return M(t), l(`${e}/address/${t}/txs`);
|
|
492
564
|
}
|
|
493
|
-
async function
|
|
494
|
-
const e = await
|
|
565
|
+
async function kt(t) {
|
|
566
|
+
const e = await w(`${t}/v1/fees/recommended`);
|
|
495
567
|
if (!e.ok)
|
|
496
568
|
throw new Error(
|
|
497
569
|
`Failed to fetch network fees: ${e.status} ${e.statusText}`
|
|
@@ -504,9 +576,9 @@ async function rt(t) {
|
|
|
504
576
|
"minimumFee"
|
|
505
577
|
];
|
|
506
578
|
for (const i of n)
|
|
507
|
-
if (!
|
|
579
|
+
if (!pt(o[i]))
|
|
508
580
|
throw new Error(
|
|
509
|
-
`Invalid fee rate ${i}=${o[i]} from mempool API: expected a positive number ≤ ${
|
|
581
|
+
`Invalid fee rate ${i}=${o[i]} from mempool API: expected a positive number ≤ ${R}`
|
|
510
582
|
);
|
|
511
583
|
if (o.minimumFee > o.economyFee || o.economyFee > o.hourFee || o.hourFee > o.halfHourFee || o.halfHourFee > o.fastestFee)
|
|
512
584
|
throw new Error(
|
|
@@ -515,21 +587,23 @@ async function rt(t) {
|
|
|
515
587
|
return o;
|
|
516
588
|
}
|
|
517
589
|
export {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
590
|
+
gt as M,
|
|
591
|
+
vt as V,
|
|
592
|
+
Ot as a,
|
|
593
|
+
Kt as b,
|
|
594
|
+
kt as c,
|
|
595
|
+
Bt as d,
|
|
596
|
+
_t as e,
|
|
597
|
+
Ft as f,
|
|
598
|
+
Nt as g,
|
|
599
|
+
dt as h,
|
|
600
|
+
xt as i,
|
|
601
|
+
Ct as j,
|
|
602
|
+
ft as k,
|
|
603
|
+
At as l,
|
|
604
|
+
Vt as m,
|
|
605
|
+
ut as n,
|
|
606
|
+
St as p,
|
|
607
|
+
lt as v
|
|
534
608
|
};
|
|
535
|
-
//# sourceMappingURL=mempoolApi-
|
|
609
|
+
//# sourceMappingURL=mempoolApi-_D-jvtj_.js.map
|