@babylonlabs-io/ts-sdk 0.78.0 → 0.79.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/{BTCVaultRegistry.abi-BT3eo60h.js → BTCVaultRegistry.abi-B0x9_Bza.js} +43 -1
- package/dist/BTCVaultRegistry.abi-B0x9_Bza.js.map +1 -0
- package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs +2 -0
- package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs.map +1 -0
- package/dist/{BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js → BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js} +57 -20
- package/dist/BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js.map +1 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs +2 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs.map +1 -0
- package/dist/{PeginManager-Cz0Ytdwo.js → PeginManager-BXlh3ar0.js} +289 -348
- package/dist/PeginManager-BXlh3ar0.js.map +1 -0
- package/dist/PeginManager-BuVSknB0.cjs +2 -0
- package/dist/PeginManager-BuVSknB0.cjs.map +1 -0
- package/dist/ProtocolParams.abi-Db2USqQm.cjs +2 -0
- package/dist/ProtocolParams.abi-Db2USqQm.cjs.map +1 -0
- package/dist/ProtocolParams.abi-q0AidvYX.js +526 -0
- package/dist/ProtocolParams.abi-q0AidvYX.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs.map +1 -0
- package/dist/{buildAndBroadcastReclaim-DD50pVB1.js → buildAndBroadcastReclaim-O6z9kvc4.js} +502 -468
- package/dist/buildAndBroadcastReclaim-O6z9kvc4.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +227 -222
- package/dist/pegin-registration-client-CZgcU2_0.cjs +2 -0
- package/dist/pegin-registration-client-CZgcU2_0.cjs.map +1 -0
- package/dist/{pegin-registration-client-7Vbtdypu.js → pegin-registration-client-pcczkzMg.js} +184 -143
- package/dist/pegin-registration-client-pcczkzMg.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +2 -2
- package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts +17 -0
- package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +2 -0
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +28 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +12 -0
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts +24 -0
- package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +14 -0
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +38 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/errors.d.ts +41 -4
- package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.cjs.map +1 -1
- package/dist/tbv/core/contracts/index.d.ts +1 -1
- package/dist/tbv/core/contracts/index.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.js +15 -492
- package/dist/tbv/core/contracts/index.js.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +222 -217
- package/dist/tbv/core/managers/PeginManager.d.ts +13 -25
- 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.d.ts +2 -2
- package/dist/tbv/core/managers/index.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.js +4 -5
- package/dist/tbv/core/pegin-fingerprint/index.d.ts +1 -1
- package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -1
- package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +10 -0
- package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/index.d.ts +1 -1
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +50 -3
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +56 -54
- package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +222 -217
- package/dist/{toRefundInputs-D708M8MA.js → toRefundInputs-9inv4Ai4.js} +96 -92
- package/dist/toRefundInputs-9inv4Ai4.js.map +1 -0
- package/dist/toRefundInputs-DitGWAnz.cjs +2 -0
- package/dist/toRefundInputs-DitGWAnz.cjs.map +1 -0
- package/dist/{types-BwqkOoJ6.js → types-B9YhlXe8.js} +109 -83
- package/dist/types-B9YhlXe8.js.map +1 -0
- package/dist/types-C1tpDycc.cjs +2 -0
- package/dist/types-C1tpDycc.cjs.map +1 -0
- package/package.json +3 -3
- package/dist/BTCVaultRegistry.abi-BJnjzEWD.cjs +0 -2
- package/dist/BTCVaultRegistry.abi-BJnjzEWD.cjs.map +0 -1
- package/dist/BTCVaultRegistry.abi-BT3eo60h.js.map +0 -1
- package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs +0 -2
- package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map +0 -1
- package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map +0 -1
- package/dist/PeginManager-Cz0Ytdwo.js.map +0 -1
- package/dist/PeginManager-DE2lTWMl.cjs +0 -2
- package/dist/PeginManager-DE2lTWMl.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-CB5VPETy.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-CB5VPETy.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-DD50pVB1.js.map +0 -1
- package/dist/pegin-registration-client-7Vbtdypu.js.map +0 -1
- package/dist/pegin-registration-client-CSe1vOum.cjs +0 -2
- package/dist/pegin-registration-client-CSe1vOum.cjs.map +0 -1
- package/dist/toRefundInputs-BH3wkNC4.cjs +0 -2
- package/dist/toRefundInputs-BH3wkNC4.cjs.map +0 -1
- package/dist/toRefundInputs-D708M8MA.js.map +0 -1
- package/dist/types-BN0jOH8K.cjs +0 -2
- package/dist/types-BN0jOH8K.cjs.map +0 -1
- package/dist/types-BwqkOoJ6.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var re = Object.defineProperty;
|
|
2
2
|
var ne = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var _ = (e, t, r) => ne(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { keccak256 as G, toHex as oe, encodeAbiParameters as se, isAddress as
|
|
4
|
+
import { keccak256 as G, toHex as oe, encodeAbiParameters as se, isAddress as ie, zeroAddress as ae } from "viem";
|
|
5
5
|
import { s as ce } from "./sha2-CLpQd0Rd.js";
|
|
6
6
|
import { a as M } from "./signPsbtsWithFallback-f7QLp0q8.js";
|
|
7
|
-
import { b as ue,
|
|
8
|
-
import { s as
|
|
9
|
-
import { computeMinClaimValue as Q, computeMinPeginFee as
|
|
7
|
+
import { b as ue, a as le } from "./PeginManager-BXlh3ar0.js";
|
|
8
|
+
import { s as f, h as he, p as W, u as de, e as me } from "./bitcoin-C-TuHb-v.js";
|
|
9
|
+
import { computeMinClaimValue as Q, computeMinPeginFee as q, peginP2aAnchorOutput as X, getPrePeginHtlcConnectorInfo as pe, expandAuthAnchor as ge } from "./tbv/core/wasm/index.js";
|
|
10
10
|
import { p as Pe, d as fe } from "./parseFundingOutpoints-BQWvINfm.js";
|
|
11
11
|
import { Transaction as J } from "bitcoinjs-lib";
|
|
12
12
|
import { o as ve, H as z } from "./verifyScriptPathSchnorrSignature-D_epga4j.js";
|
|
@@ -20,7 +20,7 @@ class be extends Error {
|
|
|
20
20
|
this.name = Z, this.reason = n;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function Xe(e) {
|
|
24
24
|
if (e instanceof be) return !0;
|
|
25
25
|
if (typeof e != "object" || e === null) return !1;
|
|
26
26
|
const t = e;
|
|
@@ -41,7 +41,7 @@ async function ye(e) {
|
|
|
41
41
|
throw new Error(
|
|
42
42
|
`rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`
|
|
43
43
|
);
|
|
44
|
-
const r =
|
|
44
|
+
const r = f(e.prepeginTxid).toLowerCase(), n = f(
|
|
45
45
|
Y(e.fundedPrePeginTxHex)
|
|
46
46
|
).toLowerCase();
|
|
47
47
|
if (n !== r)
|
|
@@ -49,7 +49,7 @@ async function ye(e) {
|
|
|
49
49
|
`Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prepeginTxid). Resume refused.`
|
|
50
50
|
);
|
|
51
51
|
const h = M(
|
|
52
|
-
|
|
52
|
+
f(e.fundedPrePeginTxHex)
|
|
53
53
|
);
|
|
54
54
|
if (h === void 0)
|
|
55
55
|
throw new Error(
|
|
@@ -66,31 +66,31 @@ async function ye(e) {
|
|
|
66
66
|
e.councilQuorum,
|
|
67
67
|
e.councilSize,
|
|
68
68
|
e.protocolFeeRate
|
|
69
|
-
),
|
|
69
|
+
), a = await q(
|
|
70
70
|
e.vaultCoreVersion,
|
|
71
71
|
c,
|
|
72
72
|
u,
|
|
73
73
|
e.minPeginFeeRate
|
|
74
|
-
), d = await
|
|
74
|
+
), d = await X(e.vaultCoreVersion), s = (d == null ? void 0 : d.value) ?? 0n;
|
|
75
75
|
if (l <= 0n)
|
|
76
76
|
throw new Error(
|
|
77
77
|
`WASM returned non-positive depositorClaimValue ${l}; expected > 0. Resume refused.`
|
|
78
78
|
);
|
|
79
|
-
if (
|
|
79
|
+
if (a <= 0n)
|
|
80
80
|
throw new Error(
|
|
81
|
-
`WASM returned non-positive peginMaxFee ${
|
|
81
|
+
`WASM returned non-positive peginMaxFee ${a}; expected > 0. Resume refused.`
|
|
82
82
|
);
|
|
83
83
|
if (s < 0n)
|
|
84
84
|
throw new Error(
|
|
85
85
|
`WASM returned negative P2A anchor value ${s}. Resume refused.`
|
|
86
86
|
);
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
87
|
+
const i = a + s, v = e.minPeginFeeRate * O;
|
|
88
|
+
if (i <= 0n || i > v)
|
|
89
89
|
throw new Error(
|
|
90
|
-
`WASM implied PegIn reserve ${
|
|
90
|
+
`WASM implied PegIn reserve ${i} sat is outside (0, ${v}] (minPeginFeeRate=${e.minPeginFeeRate} × ${O} vbytes). Resume refused.`
|
|
91
91
|
);
|
|
92
92
|
const w = e.siblings.map(
|
|
93
|
-
(o) => o.amount + l +
|
|
93
|
+
(o) => o.amount + l + a + s
|
|
94
94
|
), C = await Promise.all(
|
|
95
95
|
e.siblings.map(async (o) => (await pe({
|
|
96
96
|
txGraphVersion: e.vaultCoreVersion,
|
|
@@ -98,12 +98,12 @@ async function ye(e) {
|
|
|
98
98
|
vaultProviderPubkey: e.vaultProviderBtcPubkey,
|
|
99
99
|
vaultKeeperPubkeys: [...e.vaultKeeperBtcPubkeys],
|
|
100
100
|
universalChallengerPubkeys: [...e.universalChallengerBtcPubkeys],
|
|
101
|
-
hashlock:
|
|
101
|
+
hashlock: f(o.hashlock),
|
|
102
102
|
timelockRefund: e.timelockRefund,
|
|
103
103
|
network: e.network
|
|
104
104
|
})).scriptPubKey)
|
|
105
105
|
), E = J.fromHex(
|
|
106
|
-
|
|
106
|
+
f(e.fundedPrePeginTxHex)
|
|
107
107
|
).outs.map((o) => ({ value: o.value, script: o.script }));
|
|
108
108
|
return ve(
|
|
109
109
|
E,
|
|
@@ -123,7 +123,7 @@ async function ye(e) {
|
|
|
123
123
|
maxAcceptableCommissionBps: e.maxAcceptableCommissionBps,
|
|
124
124
|
peginAmounts: e.siblings.map((o) => o.amount),
|
|
125
125
|
depositorClaimValue: l,
|
|
126
|
-
peginMaxFee:
|
|
126
|
+
peginMaxFee: a
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function Je(e) {
|
|
@@ -133,42 +133,45 @@ function Je(e) {
|
|
|
133
133
|
const we = "TBV.PeginFingerprint.v1", Ee = G(
|
|
134
134
|
oe(we)
|
|
135
135
|
), U = 65535, D = 2n ** 64n - 1n, Ce = 2n ** 256n - 1n, Re = /^0x[0-9a-fA-F]{64}$/, L = 1;
|
|
136
|
-
class
|
|
136
|
+
class P extends Error {
|
|
137
137
|
constructor(t) {
|
|
138
138
|
super(t), this.name = "PeginFingerprintInputError";
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Ye(e) {
|
|
142
|
+
return e instanceof P || e instanceof Error && e.name === "PeginFingerprintInputError";
|
|
143
|
+
}
|
|
144
|
+
function F(e, t, r, n) {
|
|
142
145
|
if (typeof t != "bigint")
|
|
143
|
-
throw new
|
|
146
|
+
throw new P(
|
|
144
147
|
`${e} must be a bigint (Solidity ${n}), got ${typeof t}`
|
|
145
148
|
);
|
|
146
149
|
if (t < 0n || t > r)
|
|
147
|
-
throw new
|
|
150
|
+
throw new P(
|
|
148
151
|
`${e} must fit Solidity ${n} (0..${r}), got ${t}`
|
|
149
152
|
);
|
|
150
153
|
}
|
|
151
154
|
function $(e, t) {
|
|
152
155
|
if (!Number.isInteger(t) || t < 0 || t > U)
|
|
153
|
-
throw new
|
|
156
|
+
throw new P(
|
|
154
157
|
`${e} must be an integer fitting Solidity uint16 (0..${U}), got ${t}`
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
160
|
function ke(e, t) {
|
|
158
161
|
if (!Re.test(t))
|
|
159
|
-
throw new
|
|
162
|
+
throw new P(
|
|
160
163
|
`${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`
|
|
161
164
|
);
|
|
162
165
|
return t.toLowerCase();
|
|
163
166
|
}
|
|
164
167
|
function xe(e) {
|
|
165
|
-
if (!
|
|
166
|
-
throw new
|
|
168
|
+
if (!ie(e, { strict: !1 }))
|
|
169
|
+
throw new P(
|
|
167
170
|
`registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`
|
|
168
171
|
);
|
|
169
172
|
const t = e.toLowerCase();
|
|
170
|
-
if (t ===
|
|
171
|
-
throw new
|
|
173
|
+
if (t === ae)
|
|
174
|
+
throw new P(
|
|
172
175
|
"registryAddress must not be the zero address; a zero here means the registry address was never resolved"
|
|
173
176
|
);
|
|
174
177
|
return t;
|
|
@@ -186,24 +189,24 @@ const Ve = [
|
|
|
186
189
|
{ name: "vaultCoreVersion", type: "uint16" }
|
|
187
190
|
];
|
|
188
191
|
function $e(e) {
|
|
189
|
-
if (
|
|
190
|
-
throw new
|
|
192
|
+
if (F("chainId", e.chainId, Ce, "uint256"), e.chainId === 0n)
|
|
193
|
+
throw new P(
|
|
191
194
|
"chainId must not be 0; a zero here means the chain id was never resolved"
|
|
192
195
|
);
|
|
193
196
|
const t = xe(e.registryAddress), r = ke(
|
|
194
197
|
"vaultProviderBtcKey",
|
|
195
198
|
e.vaultProviderBtcKey
|
|
196
199
|
);
|
|
197
|
-
if (
|
|
200
|
+
if (F(
|
|
198
201
|
"appKeeperKeyEpoch",
|
|
199
202
|
e.appKeeperKeyEpoch,
|
|
200
203
|
D,
|
|
201
204
|
"uint64"
|
|
202
|
-
),
|
|
205
|
+
), F("ucKeyEpoch", e.ucKeyEpoch, D, "uint64"), $("appVaultKeepersVersion", e.appVaultKeepersVersion), $(
|
|
203
206
|
"universalChallengersVersion",
|
|
204
207
|
e.universalChallengersVersion
|
|
205
208
|
), $("offchainParamsVersion", e.offchainParamsVersion), $("vaultCoreVersion", e.vaultCoreVersion), e.vaultCoreVersion < L)
|
|
206
|
-
throw new
|
|
209
|
+
throw new P(
|
|
207
210
|
`vaultCoreVersion must be at least ${L}; ${e.vaultCoreVersion} means the version was never resolved`
|
|
208
211
|
);
|
|
209
212
|
return se(Ve, [
|
|
@@ -219,7 +222,7 @@ function $e(e) {
|
|
|
219
222
|
e.vaultCoreVersion
|
|
220
223
|
]);
|
|
221
224
|
}
|
|
222
|
-
function
|
|
225
|
+
function Ze(e) {
|
|
223
226
|
return G($e(e));
|
|
224
227
|
}
|
|
225
228
|
class Te extends Error {
|
|
@@ -248,7 +251,7 @@ class Ie extends Error {
|
|
|
248
251
|
), this.survivorLabels = t, this.name = "PeginParamsAmbiguousError";
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
|
-
class
|
|
254
|
+
class Fe extends Error {
|
|
252
255
|
constructor(t, r) {
|
|
253
256
|
super(
|
|
254
257
|
`A candidate matched this Pre-PegIn (${t}), but ${r.length} version(s) could not be resolved, so the search space did not provably contain the true parameters: ${r.join(" | ")}. A version sharing the matched timelockRefund and participants is indistinguishable from the true one, so the match cannot be trusted. Reconstruction refused.`
|
|
@@ -260,8 +263,8 @@ class T extends Error {
|
|
|
260
263
|
super(`${t}. Reconstruction refused.`), this.name = "PeginSizingIntegrityError";
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
|
-
async function
|
|
264
|
-
const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h =
|
|
266
|
+
async function et(e) {
|
|
267
|
+
const { wallet: t, depositorBtcPubkey: r, fundedPrePeginTxHex: n } = e, h = f(n), c = M(h);
|
|
265
268
|
if (c === void 0)
|
|
266
269
|
throw new K(
|
|
267
270
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path."
|
|
@@ -271,7 +274,7 @@ async function Ze(e) {
|
|
|
271
274
|
throw new K(
|
|
272
275
|
"Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover."
|
|
273
276
|
);
|
|
274
|
-
const l = Pe(h),
|
|
277
|
+
const l = Pe(h), a = await fe(t, {
|
|
275
278
|
// The vault context takes the 32-byte x-only key; a wallet's compressed
|
|
276
279
|
// key would otherwise fail a byte-length check deep in the encoder with
|
|
277
280
|
// nothing pointing back at the caller.
|
|
@@ -281,22 +284,22 @@ async function Ze(e) {
|
|
|
281
284
|
fundingOutpoints: l
|
|
282
285
|
});
|
|
283
286
|
try {
|
|
284
|
-
const s = await ge(
|
|
285
|
-
let
|
|
287
|
+
const s = await ge(a);
|
|
288
|
+
let i;
|
|
286
289
|
try {
|
|
287
|
-
|
|
290
|
+
i = de(ce(s));
|
|
288
291
|
} finally {
|
|
289
292
|
s.fill(0);
|
|
290
293
|
}
|
|
291
|
-
if (
|
|
292
|
-
throw new Te(
|
|
294
|
+
if (i !== c.hash)
|
|
295
|
+
throw new Te(i, c.hash);
|
|
293
296
|
} catch (s) {
|
|
294
|
-
throw
|
|
297
|
+
throw a.fill(0), s;
|
|
295
298
|
}
|
|
296
|
-
const { hashlocks: d } = await le(
|
|
299
|
+
const { hashlocks: d } = await le(a, u);
|
|
297
300
|
return { vaultCount: u, hashlocks: d, authAnchorHash: c.hash };
|
|
298
301
|
}
|
|
299
|
-
function
|
|
302
|
+
function tt(e) {
|
|
300
303
|
const { vaultCoreVersion: t, offchainParams: r, participantKeySets: n } = e;
|
|
301
304
|
if (!Number.isInteger(t) || t < 1)
|
|
302
305
|
throw new Error(
|
|
@@ -320,10 +323,10 @@ function et(e) {
|
|
|
320
323
|
});
|
|
321
324
|
return h;
|
|
322
325
|
}
|
|
323
|
-
function
|
|
326
|
+
function Be(e) {
|
|
324
327
|
return `${e.axis} v${e.version} (${e.reason})`;
|
|
325
328
|
}
|
|
326
|
-
function
|
|
329
|
+
function B(e) {
|
|
327
330
|
const { participants: t } = e;
|
|
328
331
|
return `core=${e.vaultCoreVersion} offchain=${e.offchainParams.version} keepers=${t.appVaultKeepersVersion} challengers=${t.universalChallengersVersion} vp=${t.vaultProvider}`;
|
|
329
332
|
}
|
|
@@ -356,14 +359,14 @@ async function Se(e) {
|
|
|
356
359
|
t.councilSize,
|
|
357
360
|
t.protocolFeeRate
|
|
358
361
|
),
|
|
359
|
-
|
|
362
|
+
q(
|
|
360
363
|
e.vaultCoreVersion,
|
|
361
364
|
n,
|
|
362
365
|
h,
|
|
363
366
|
t.minPeginFeeRate
|
|
364
367
|
),
|
|
365
|
-
|
|
366
|
-
]),
|
|
368
|
+
X(e.vaultCoreVersion)
|
|
369
|
+
]), a = (l == null ? void 0 : l.value) ?? 0n;
|
|
367
370
|
if (c <= 0n)
|
|
368
371
|
throw new T(
|
|
369
372
|
`WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`
|
|
@@ -372,13 +375,13 @@ async function Se(e) {
|
|
|
372
375
|
throw new T(
|
|
373
376
|
`WASM returned non-positive peginMaxFee ${u} for graph version ${e.vaultCoreVersion}`
|
|
374
377
|
);
|
|
375
|
-
if (
|
|
378
|
+
if (a < 0n)
|
|
376
379
|
throw new T(
|
|
377
|
-
`WASM returned negative P2A anchor value ${
|
|
380
|
+
`WASM returned negative P2A anchor value ${a} for graph version ${e.vaultCoreVersion}`
|
|
378
381
|
);
|
|
379
|
-
return { depositorClaimValue: c, peginMaxFee: u, p2aAnchorValue:
|
|
382
|
+
return { depositorClaimValue: c, peginMaxFee: u, p2aAnchorValue: a };
|
|
380
383
|
}
|
|
381
|
-
async function
|
|
384
|
+
async function rt(e) {
|
|
382
385
|
const {
|
|
383
386
|
hashlocks: t,
|
|
384
387
|
fundedPrePeginTxHex: r,
|
|
@@ -387,7 +390,7 @@ async function tt(e) {
|
|
|
387
390
|
maxAcceptableCommissionBps: c,
|
|
388
391
|
network: u,
|
|
389
392
|
candidates: l,
|
|
390
|
-
unresolvedVersions:
|
|
393
|
+
unresolvedVersions: a
|
|
391
394
|
} = e;
|
|
392
395
|
if (t.length === 0)
|
|
393
396
|
throw new Error(
|
|
@@ -395,16 +398,16 @@ async function tt(e) {
|
|
|
395
398
|
);
|
|
396
399
|
if (l.length === 0)
|
|
397
400
|
throw new Error("reconstructPeginParams: candidate space is empty");
|
|
398
|
-
const d = W(n), s =
|
|
399
|
-
if (
|
|
401
|
+
const d = W(n), s = f(r), i = M(s);
|
|
402
|
+
if (i === void 0)
|
|
400
403
|
throw new K(
|
|
401
404
|
"Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused."
|
|
402
405
|
);
|
|
403
|
-
if (
|
|
406
|
+
if (i.vout !== t.length)
|
|
404
407
|
throw new Error(
|
|
405
|
-
`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${
|
|
408
|
+
`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${i.vout}, so the transaction funds ${i.vout} HTLC output(s). Reconstruction refused.`
|
|
406
409
|
);
|
|
407
|
-
const v = J.fromHex(s).outs, w = t.map((m, p) => BigInt(v[p].value)), C =
|
|
410
|
+
const v = J.fromHex(s).outs, w = t.map((m, p) => BigInt(v[p].value)), C = f(
|
|
408
411
|
Y(s)
|
|
409
412
|
).toLowerCase(), E = /* @__PURE__ */ new Map(), o = [], b = [], A = [];
|
|
410
413
|
let S = 0;
|
|
@@ -450,34 +453,34 @@ async function tt(e) {
|
|
|
450
453
|
} catch (p) {
|
|
451
454
|
if (p instanceof T)
|
|
452
455
|
throw p;
|
|
453
|
-
const g =
|
|
456
|
+
const g = B(m), R = p instanceof Error ? p.message : String(p);
|
|
454
457
|
p instanceof z ? b.length < j && b.push(`[${g}] ${R}`) : (S++, A.length < j && A.push(`${g} (${R})`));
|
|
455
458
|
}
|
|
456
|
-
const ee =
|
|
457
|
-
...
|
|
459
|
+
const ee = a.length + S, H = [
|
|
460
|
+
...a.map(Be),
|
|
458
461
|
...A
|
|
459
462
|
];
|
|
460
463
|
if (o.length === 0)
|
|
461
464
|
throw new Ae(l.length, b, H);
|
|
462
465
|
if (new Set(o.map((m) => m.fingerprint)).size > 1)
|
|
463
466
|
throw new Ie(
|
|
464
|
-
o.map((m) =>
|
|
467
|
+
o.map((m) => B(m.candidate))
|
|
465
468
|
);
|
|
466
469
|
if (ee > 0)
|
|
467
|
-
throw new
|
|
468
|
-
|
|
470
|
+
throw new Fe(
|
|
471
|
+
B(o[0].candidate),
|
|
469
472
|
H
|
|
470
473
|
);
|
|
471
474
|
return {
|
|
472
475
|
candidate: o[0].candidate,
|
|
473
476
|
terms: o[0].terms,
|
|
474
477
|
peginAmounts: o[0].peginAmounts,
|
|
475
|
-
authAnchorHash:
|
|
478
|
+
authAnchorHash: i.hash,
|
|
476
479
|
candidatesTried: l.length,
|
|
477
480
|
matchedCandidates: o.map((m) => m.candidate)
|
|
478
481
|
};
|
|
479
482
|
}
|
|
480
|
-
function
|
|
483
|
+
function nt(e, t) {
|
|
481
484
|
const {
|
|
482
485
|
htlcVout: r,
|
|
483
486
|
depositorBtcPubkey: n,
|
|
@@ -485,7 +488,7 @@ function rt(e, t) {
|
|
|
485
488
|
fundedPrePeginTxHex: c,
|
|
486
489
|
hashlocks: u,
|
|
487
490
|
network: l
|
|
488
|
-
} = t, { candidate:
|
|
491
|
+
} = t, { candidate: a, peginAmounts: d } = e, { offchainParams: s, participants: i } = a;
|
|
489
492
|
if (u.length !== d.length)
|
|
490
493
|
throw new Error(
|
|
491
494
|
`toRefundInputs: ${u.length} hashlock(s) but ${d.length} reconstructed amount(s); the reconstruction and the hashlock vector describe different transactions.`
|
|
@@ -499,28 +502,28 @@ function rt(e, t) {
|
|
|
499
502
|
amount: E,
|
|
500
503
|
htlcVout: o
|
|
501
504
|
})), w = {
|
|
502
|
-
vaultCoreVersion:
|
|
505
|
+
vaultCoreVersion: a.vaultCoreVersion,
|
|
503
506
|
hashlock: v[r].hashlock,
|
|
504
507
|
htlcVout: r,
|
|
505
508
|
offchainParamsVersion: s.version,
|
|
506
|
-
appVaultKeepersVersion:
|
|
507
|
-
universalChallengersVersion:
|
|
508
|
-
vaultProvider:
|
|
509
|
+
appVaultKeepersVersion: i.appVaultKeepersVersion,
|
|
510
|
+
universalChallengersVersion: i.universalChallengersVersion,
|
|
511
|
+
vaultProvider: i.vaultProvider,
|
|
509
512
|
applicationEntryPoint: h,
|
|
510
513
|
amount: d[r],
|
|
511
514
|
unsignedPrePeginTxHex: c,
|
|
512
515
|
depositorBtcPubkey: n,
|
|
513
516
|
batch: v
|
|
514
517
|
}, C = {
|
|
515
|
-
vaultProviderPubkey:
|
|
516
|
-
vaultKeeperPubkeys:
|
|
517
|
-
universalChallengerPubkeys:
|
|
518
|
+
vaultProviderPubkey: i.vaultProviderBtcPubkey,
|
|
519
|
+
vaultKeeperPubkeys: i.vaultKeeperBtcPubkeys,
|
|
520
|
+
universalChallengerPubkeys: i.universalChallengerBtcPubkeys,
|
|
518
521
|
timelockRefund: s.timelockRefund,
|
|
519
522
|
feeRate: s.protocolFeeRate,
|
|
520
523
|
minPeginFeeRate: s.minPeginFeeRate,
|
|
521
524
|
// Depositor-as-claimer: the local-challenger count is the keeper count,
|
|
522
525
|
// the vault provider excluded — btc-vault graph.rs derive_challengers.
|
|
523
|
-
numLocalChallengers:
|
|
526
|
+
numLocalChallengers: i.vaultKeeperBtcPubkeys.length,
|
|
524
527
|
councilQuorum: s.councilQuorum,
|
|
525
528
|
councilSize: s.councilSize,
|
|
526
529
|
network: l
|
|
@@ -533,22 +536,23 @@ export {
|
|
|
533
536
|
K as U,
|
|
534
537
|
Te as V,
|
|
535
538
|
we as a,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
P as b,
|
|
540
|
+
Ze as c,
|
|
541
|
+
Ye as d,
|
|
539
542
|
$e as e,
|
|
540
|
-
|
|
541
|
-
|
|
543
|
+
be as f,
|
|
544
|
+
Xe as g,
|
|
542
545
|
et as h,
|
|
543
546
|
Je as i,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
547
|
+
tt as j,
|
|
548
|
+
Be as k,
|
|
549
|
+
B as l,
|
|
550
|
+
rt as m,
|
|
551
|
+
Ae as n,
|
|
552
|
+
Ie as o,
|
|
553
|
+
Fe as p,
|
|
554
|
+
T as q,
|
|
551
555
|
ye as r,
|
|
552
|
-
|
|
556
|
+
nt as t
|
|
553
557
|
};
|
|
554
|
-
//# sourceMappingURL=toRefundInputs-
|
|
558
|
+
//# sourceMappingURL=toRefundInputs-9inv4Ai4.js.map
|