@babylonlabs-io/ts-sdk 0.52.0 → 0.53.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/ApplicationRegistry.abi-CLaa6E99.cjs +2 -0
- package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +1 -0
- package/dist/{ApplicationRegistry.abi-Dn2qk6JG.js → ApplicationRegistry.abi-w5prf7Ig.js} +14 -1
- package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +1 -0
- package/dist/PayoutManager-1GWmbvI9.cjs +2 -0
- package/dist/PayoutManager-1GWmbvI9.cjs.map +1 -0
- package/dist/{PayoutManager-BwrV3xFW.js → PayoutManager-Ddo9_Ozc.js} +34 -32
- package/dist/PayoutManager-Ddo9_Ozc.js.map +1 -0
- package/dist/{PeginManager-BGWNJYPk.js → PeginManager-CTU0wgkJ.js} +37 -34
- package/dist/PeginManager-CTU0wgkJ.js.map +1 -0
- package/dist/PeginManager-De-eHl3v.cjs +2 -0
- package/dist/PeginManager-De-eHl3v.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs +2 -0
- package/dist/buildAndBroadcastRefund-BnD2qUDW.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-BAT5A6MP.js → buildAndBroadcastRefund-DjS9nf87.js} +188 -177
- package/dist/buildAndBroadcastRefund-DjS9nf87.js.map +1 -0
- package/dist/{challengeAssert-HNbugpqL.cjs → challengeAssert-DLQfNcfU.cjs} +2 -2
- package/dist/{challengeAssert-HNbugpqL.cjs.map → challengeAssert-DLQfNcfU.cjs.map} +1 -1
- package/dist/{challengeAssert-csvYXBJB.js → challengeAssert-DvdbpEDY.js} +2 -2
- package/dist/{challengeAssert-csvYXBJB.js.map → challengeAssert-DvdbpEDY.js.map} +1 -1
- package/dist/constants-BhclpREj.js +19 -0
- package/dist/constants-BhclpREj.js.map +1 -0
- package/dist/constants-CvbARMl-.cjs +2 -0
- package/dist/constants-CvbARMl-.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +182 -181
- package/dist/index.js.map +1 -1
- package/dist/{mempoolApi-Dc1KSVNI.js → mempoolApi-CB7bHuwi.js} +106 -101
- package/dist/mempoolApi-CB7bHuwi.js.map +1 -0
- package/dist/mempoolApi-DqJByvqR.cjs +2 -0
- package/dist/mempoolApi-DqJByvqR.cjs.map +1 -0
- package/dist/noPayout-8dDKwi6n.cjs +2 -0
- package/dist/noPayout-8dDKwi6n.cjs.map +1 -0
- package/dist/{noPayout-DVx3zxUz.js → noPayout-tZFoNun3.js} +30 -30
- package/dist/noPayout-tZFoNun3.js.map +1 -0
- package/dist/{peginInput-B5XDDHpy.js → peginInput-BKD_b3gq.js} +10 -11
- package/dist/peginInput-BKD_b3gq.js.map +1 -0
- package/dist/{peginInput-De0C6aSj.cjs → peginInput-CAiiDZeO.cjs} +2 -2
- package/dist/peginInput-CAiiDZeO.cjs.map +1 -0
- package/dist/primeVpAuth-CF4cH5_e.cjs +2 -0
- package/dist/primeVpAuth-CF4cH5_e.cjs.map +1 -0
- package/dist/{primeVpAuth-DxMuWQCi.js → primeVpAuth-l-5x_2UV.js} +91 -85
- package/dist/{primeVpAuth-yTddDmGy.cjs.map → primeVpAuth-l-5x_2UV.js.map} +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +8 -0
- package/dist/tbv/core/clients/eth/types.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/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/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +177 -176
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +6 -0
- 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/primitives/__tests__/vaultCoreVersion.test.d.ts +8 -0
- package/dist/tbv/core/primitives/__tests__/vaultCoreVersion.test.d.ts.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +37 -36
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts +6 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +7 -0
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts +6 -0
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
- package/dist/tbv/core/primitives/scripts/payout.d.ts +6 -0
- package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/vaultCoreVersion.d.ts +26 -0
- package/dist/tbv/core/primitives/vaultCoreVersion.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +7 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +6 -0
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts +8 -0
- package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.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/services/refund/buildAndBroadcastRefund.d.ts +6 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +177 -176
- package/dist/tbv/index.js.map +1 -1
- package/dist/{verifyScriptPathSchnorrSignature-BKECXOpa.js → verifyScriptPathSchnorrSignature-DpWZx5J0.js} +125 -130
- package/dist/verifyScriptPathSchnorrSignature-DpWZx5J0.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-a4Us7D3e.cjs.map +1 -0
- package/package.json +3 -3
- package/dist/ApplicationRegistry.abi-BAPhJch3.cjs +0 -2
- package/dist/ApplicationRegistry.abi-BAPhJch3.cjs.map +0 -1
- package/dist/ApplicationRegistry.abi-Dn2qk6JG.js.map +0 -1
- package/dist/PayoutManager-BwrV3xFW.js.map +0 -1
- package/dist/PayoutManager-CBfHfLfz.cjs +0 -2
- package/dist/PayoutManager-CBfHfLfz.cjs.map +0 -1
- package/dist/PeginManager-BGWNJYPk.js.map +0 -1
- package/dist/PeginManager-DDp-ZRIa.cjs +0 -2
- package/dist/PeginManager-DDp-ZRIa.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs +0 -2
- package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-BAT5A6MP.js.map +0 -1
- package/dist/constants-CSG2XeD8.cjs +0 -2
- package/dist/constants-CSG2XeD8.cjs.map +0 -1
- package/dist/constants-Cd_fN8VT.js +0 -12
- package/dist/constants-Cd_fN8VT.js.map +0 -1
- package/dist/mempoolApi-Dc1KSVNI.js.map +0 -1
- package/dist/mempoolApi-NMiYQAXI.cjs +0 -2
- package/dist/mempoolApi-NMiYQAXI.cjs.map +0 -1
- package/dist/noPayout-ChPNKTbm.cjs +0 -2
- package/dist/noPayout-ChPNKTbm.cjs.map +0 -1
- package/dist/noPayout-DVx3zxUz.js.map +0 -1
- package/dist/peginInput-B5XDDHpy.js.map +0 -1
- package/dist/peginInput-De0C6aSj.cjs.map +0 -1
- package/dist/primeVpAuth-DxMuWQCi.js.map +0 -1
- package/dist/primeVpAuth-yTddDmGy.cjs +0 -2
- package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts +0 -7
- package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts.map +0 -1
- package/dist/tbv/core/primitives/txGraphVersion.d.ts +0 -11
- package/dist/tbv/core/primitives/txGraphVersion.d.ts.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
var J = Object.defineProperty;
|
|
2
2
|
var Z = (e, r, t) => r in e ? J(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
-
var
|
|
3
|
+
var $ = (e, r, t) => Z(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
4
|
import { B as ee } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
|
|
5
5
|
import { e as te, v as re, s as p, u as X, p as A, f as E } from "./bitcoin-B5aNKtsk.js";
|
|
6
|
-
import { v as ne, P as oe, f as ae } from "./PayoutManager-
|
|
6
|
+
import { v as ne, P as oe, f as ae } from "./PayoutManager-Ddo9_Ozc.js";
|
|
7
7
|
import { D as w, c as se, a as ie, R as ue, d as z } from "./types-CQDRQvV-.js";
|
|
8
|
-
import { Transaction as
|
|
9
|
-
import { c as ce, d as
|
|
10
|
-
import { c as
|
|
8
|
+
import { Transaction as S, Psbt as le } from "bitcoinjs-lib";
|
|
9
|
+
import { c as ce, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-DpWZx5J0.js";
|
|
10
|
+
import { c as he, a as de, b as pe } from "./noPayout-tZFoNun3.js";
|
|
11
11
|
import { c as O } from "./signing-DaLvGwQe.js";
|
|
12
|
+
import { a as ge } from "./constants-BhclpREj.js";
|
|
12
13
|
const fe = /^0x[0-9a-fA-F]{64}$/, me = /^0x[0-9a-fA-F]{40}$/, Pe = /^0x([0-9a-fA-F]{2})*$/;
|
|
13
|
-
function
|
|
14
|
+
function V(e, r) {
|
|
14
15
|
if (e.length !== 66)
|
|
15
16
|
throw new Error(
|
|
16
17
|
`${r} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
@@ -32,22 +33,22 @@ function ye(e, r) {
|
|
|
32
33
|
`${r} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
|
-
async function
|
|
36
|
+
async function ut(e) {
|
|
36
37
|
const {
|
|
37
38
|
btcVaultRegistryAddress: r,
|
|
38
39
|
vaultId: t,
|
|
39
40
|
hashlock: n,
|
|
40
41
|
activationMetadata: s,
|
|
41
|
-
writeContract:
|
|
42
|
+
writeContract: l,
|
|
42
43
|
signal: a
|
|
43
44
|
} = e;
|
|
44
|
-
a == null || a.throwIfAborted(), be(r, "btcVaultRegistryAddress"),
|
|
45
|
+
a == null || a.throwIfAborted(), be(r, "btcVaultRegistryAddress"), V(t, "vaultId");
|
|
45
46
|
const i = te(e.secret);
|
|
46
|
-
if (
|
|
47
|
+
if (V(i, "secret"), n !== void 0 && (V(n, "hashlock"), !ne(i, n)))
|
|
47
48
|
throw new Error(
|
|
48
49
|
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
49
50
|
);
|
|
50
|
-
return ye(s, "activationMetadata"),
|
|
51
|
+
return ye(s, "activationMetadata"), l({
|
|
51
52
|
address: r,
|
|
52
53
|
abi: ee,
|
|
53
54
|
functionName: "activateVaultWithSecret",
|
|
@@ -61,7 +62,7 @@ async function G(e) {
|
|
|
61
62
|
peginTxid: t,
|
|
62
63
|
targetStatuses: n,
|
|
63
64
|
timeoutMs: s,
|
|
64
|
-
pollIntervalMs:
|
|
65
|
+
pollIntervalMs: l = we,
|
|
65
66
|
signal: a
|
|
66
67
|
} = e, i = Date.now();
|
|
67
68
|
for (; ; ) {
|
|
@@ -82,27 +83,27 @@ async function G(e) {
|
|
|
82
83
|
throw new Error(
|
|
83
84
|
`getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${t.slice(0, 8)}…`
|
|
84
85
|
);
|
|
85
|
-
const
|
|
86
|
-
if (n.has(
|
|
87
|
-
return
|
|
88
|
-
if (
|
|
86
|
+
const u = o.status;
|
|
87
|
+
if (n.has(u) || u === w.ACTIVATED)
|
|
88
|
+
return u;
|
|
89
|
+
if (u === w.EXPIRED || se.has(u))
|
|
89
90
|
throw new Error(
|
|
90
|
-
`Pegin ${t.slice(0, 8)}… reached terminal status "${
|
|
91
|
+
`Pegin ${t.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
|
|
91
92
|
);
|
|
92
93
|
} catch (o) {
|
|
93
94
|
if (!(o instanceof ie && o.code === ue.PEGIN_NOT_FOUND))
|
|
94
95
|
throw o;
|
|
95
96
|
}
|
|
96
|
-
await new Promise((o,
|
|
97
|
+
await new Promise((o, u) => {
|
|
97
98
|
const h = () => {
|
|
98
|
-
clearTimeout(c),
|
|
99
|
+
clearTimeout(c), u(
|
|
99
100
|
new Error(
|
|
100
101
|
`Polling aborted for pegin ${t.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
101
102
|
)
|
|
102
103
|
);
|
|
103
104
|
}, c = setTimeout(() => {
|
|
104
105
|
a == null || a.removeEventListener("abort", h), o();
|
|
105
|
-
},
|
|
106
|
+
}, l);
|
|
106
107
|
a == null || a.addEventListener("abort", h, { once: !0 });
|
|
107
108
|
});
|
|
108
109
|
}
|
|
@@ -111,13 +112,13 @@ const xe = 300 * 1e3, ve = /* @__PURE__ */ new Set([
|
|
|
111
112
|
w.PENDING_DEPOSITOR_WOTS_PK,
|
|
112
113
|
...z
|
|
113
114
|
]);
|
|
114
|
-
async function
|
|
115
|
+
async function lt(e) {
|
|
115
116
|
const {
|
|
116
117
|
statusReader: r,
|
|
117
118
|
wotsSubmitter: t,
|
|
118
119
|
peginTxid: n,
|
|
119
120
|
depositorPk: s,
|
|
120
|
-
wotsPublicKeys:
|
|
121
|
+
wotsPublicKeys: l,
|
|
121
122
|
timeoutMs: a = xe,
|
|
122
123
|
signal: i
|
|
123
124
|
} = e;
|
|
@@ -133,14 +134,14 @@ async function ut(e) {
|
|
|
133
134
|
{
|
|
134
135
|
pegin_txid: n,
|
|
135
136
|
depositor_pk: s,
|
|
136
|
-
wots_public_keys:
|
|
137
|
+
wots_public_keys: l
|
|
137
138
|
},
|
|
138
139
|
i
|
|
139
140
|
));
|
|
140
141
|
}
|
|
141
142
|
const K = 1, Ee = 1;
|
|
142
143
|
function Te(e, r) {
|
|
143
|
-
const t = p(r).toLowerCase(), s = e.map((
|
|
144
|
+
const t = p(r).toLowerCase(), s = e.map((l) => p(l).toLowerCase()).filter((l) => l !== t);
|
|
144
145
|
if (s.length === 0)
|
|
145
146
|
throw new Error(
|
|
146
147
|
"Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
|
|
@@ -159,28 +160,28 @@ function ke(e, r, t) {
|
|
|
159
160
|
throw new Error(
|
|
160
161
|
`Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
|
|
161
162
|
);
|
|
162
|
-
const
|
|
163
|
+
const l = [...r, ...n], a = e.map(
|
|
163
164
|
(c) => p(c.challenger_pubkey).toLowerCase()
|
|
164
165
|
), i = new Set(a);
|
|
165
166
|
if (i.size !== a.length)
|
|
166
167
|
throw new Error(
|
|
167
168
|
"Depositor graph contains duplicate challenger entries in challenger_presign_data"
|
|
168
169
|
);
|
|
169
|
-
const o = new Set(
|
|
170
|
-
if (
|
|
170
|
+
const o = new Set(l), u = l.filter((c) => !i.has(c)), h = a.filter((c) => !o.has(c));
|
|
171
|
+
if (u.length > 0 || h.length > 0)
|
|
171
172
|
throw new Error(
|
|
172
|
-
"Depositor graph challenger set does not match expected (local ∪ universal)" + (
|
|
173
|
+
"Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (h.length > 0 ? ` (unexpected: ${h.join(", ")})` : "")
|
|
173
174
|
);
|
|
174
175
|
}
|
|
175
176
|
function _e(e, r) {
|
|
176
177
|
const t = e.ins[r];
|
|
177
178
|
return X(new Uint8Array(t.hash).slice().reverse());
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
180
|
+
function R(e, r, t, n, s) {
|
|
181
|
+
const l = e.ins[r];
|
|
182
|
+
if (l.index !== 0)
|
|
182
183
|
throw new Error(
|
|
183
|
-
`NoPayout (challenger ${s}) input ${r} expected to spend ${n} vout 0, got vout ${
|
|
184
|
+
`NoPayout (challenger ${s}) input ${r} expected to spend ${n} vout 0, got vout ${l.index}`
|
|
184
185
|
);
|
|
185
186
|
const a = t.getId(), i = _e(e, r);
|
|
186
187
|
if (i !== a)
|
|
@@ -188,8 +189,8 @@ function B(e, r, t, n, s) {
|
|
|
188
189
|
`NoPayout (challenger ${s}) input ${r} does not reference ${n} (expected txid ${a}, got ${i})`
|
|
189
190
|
);
|
|
190
191
|
}
|
|
191
|
-
async function
|
|
192
|
-
const n = [], s = [],
|
|
192
|
+
async function Ce(e, r, t) {
|
|
193
|
+
const n = [], s = [], l = [], a = Te(
|
|
193
194
|
t.vaultKeeperBtcPubkeys,
|
|
194
195
|
t.depositorBtcPubkey
|
|
195
196
|
);
|
|
@@ -199,6 +200,7 @@ async function Se(e, r, t) {
|
|
|
199
200
|
t.universalChallengerBtcPubkeys
|
|
200
201
|
);
|
|
201
202
|
const i = await ce({
|
|
203
|
+
vaultCoreVersion: t.vaultCoreVersion,
|
|
202
204
|
payoutTxHex: e.payout_tx.tx_hex,
|
|
203
205
|
peginTxHex: t.peginTxHex,
|
|
204
206
|
assertTxHex: e.assert_tx.tx_hex,
|
|
@@ -218,16 +220,16 @@ async function Se(e, r, t) {
|
|
|
218
220
|
K
|
|
219
221
|
)
|
|
220
222
|
);
|
|
221
|
-
const o = p(t.depositorBtcPubkey),
|
|
223
|
+
const o = p(t.depositorBtcPubkey), u = S.fromHex(
|
|
222
224
|
p(e.assert_tx.tx_hex)
|
|
223
225
|
);
|
|
224
226
|
for (const h of e.challenger_presign_data) {
|
|
225
|
-
const c = p(h.challenger_pubkey), d = n.length, P = await
|
|
227
|
+
const c = p(h.challenger_pubkey), d = n.length, P = await Se({
|
|
226
228
|
challenger: h,
|
|
227
229
|
challengerPubkey: c,
|
|
228
230
|
claimerPubkey: o,
|
|
229
231
|
localChallengers: a,
|
|
230
|
-
assertTxParsed:
|
|
232
|
+
assertTxParsed: u,
|
|
231
233
|
ctx: t
|
|
232
234
|
});
|
|
233
235
|
n.push(P), s.push(
|
|
@@ -235,71 +237,71 @@ async function Se(e, r, t) {
|
|
|
235
237
|
r,
|
|
236
238
|
K
|
|
237
239
|
)
|
|
238
|
-
),
|
|
240
|
+
), l.push({
|
|
239
241
|
challengerPubkey: c,
|
|
240
242
|
noPayoutIdx: d
|
|
241
243
|
});
|
|
242
244
|
}
|
|
243
|
-
return { psbtHexes: n, signOptions: s, challengerEntries:
|
|
245
|
+
return { psbtHexes: n, signOptions: s, challengerEntries: l };
|
|
244
246
|
}
|
|
245
|
-
async function
|
|
247
|
+
async function Se(e) {
|
|
246
248
|
const {
|
|
247
249
|
challenger: r,
|
|
248
250
|
challengerPubkey: t,
|
|
249
251
|
claimerPubkey: n,
|
|
250
252
|
localChallengers: s,
|
|
251
|
-
assertTxParsed:
|
|
253
|
+
assertTxParsed: l,
|
|
252
254
|
ctx: a
|
|
253
255
|
} = e;
|
|
254
|
-
|
|
256
|
+
he(
|
|
255
257
|
r.nopayout_tx.tx_hex,
|
|
256
258
|
t,
|
|
257
259
|
a.network
|
|
258
260
|
);
|
|
259
|
-
const i =
|
|
261
|
+
const i = S.fromHex(
|
|
260
262
|
p(r.nopayout_tx.tx_hex)
|
|
261
|
-
), o =
|
|
263
|
+
), o = S.fromHex(
|
|
262
264
|
p(r.challenge_assert_x_tx.tx_hex)
|
|
263
|
-
),
|
|
265
|
+
), u = S.fromHex(
|
|
264
266
|
p(r.challenge_assert_y_tx.tx_hex)
|
|
265
267
|
);
|
|
266
268
|
if (i.ins.length !== 3)
|
|
267
269
|
throw new Error(
|
|
268
270
|
`NoPayout (challenger ${t}) must have exactly 3 inputs, got ${i.ins.length}`
|
|
269
271
|
);
|
|
270
|
-
|
|
272
|
+
R(
|
|
271
273
|
i,
|
|
272
274
|
0,
|
|
273
|
-
|
|
275
|
+
l,
|
|
274
276
|
"Assert",
|
|
275
277
|
t
|
|
276
|
-
),
|
|
278
|
+
), R(
|
|
277
279
|
i,
|
|
278
280
|
1,
|
|
279
281
|
o,
|
|
280
282
|
"ChallengeAssertX",
|
|
281
283
|
t
|
|
282
|
-
),
|
|
284
|
+
), R(
|
|
283
285
|
i,
|
|
284
286
|
2,
|
|
285
|
-
|
|
287
|
+
u,
|
|
286
288
|
"ChallengeAssertY",
|
|
287
289
|
t
|
|
288
290
|
);
|
|
289
291
|
const h = [
|
|
290
|
-
|
|
292
|
+
l.outs[0],
|
|
291
293
|
o.outs[0],
|
|
292
|
-
|
|
294
|
+
u.outs[0]
|
|
293
295
|
].map((c) => ({
|
|
294
296
|
script_pubkey: X(new Uint8Array(c.script)),
|
|
295
297
|
value: c.value
|
|
296
298
|
}));
|
|
297
|
-
return
|
|
299
|
+
return de({
|
|
298
300
|
noPayoutTxHex: r.nopayout_tx.tx_hex,
|
|
299
301
|
challengerPubkey: t,
|
|
300
302
|
prevouts: h,
|
|
301
303
|
connectorParams: {
|
|
302
|
-
txGraphVersion:
|
|
304
|
+
txGraphVersion: a.vaultCoreVersion,
|
|
303
305
|
claimer: n,
|
|
304
306
|
localChallengers: s,
|
|
305
307
|
universalChallengers: a.universalChallengerBtcPubkeys,
|
|
@@ -310,7 +312,7 @@ async function Ce(e) {
|
|
|
310
312
|
});
|
|
311
313
|
}
|
|
312
314
|
function Ae(e, r, t) {
|
|
313
|
-
|
|
315
|
+
I(e[0]);
|
|
314
316
|
const s = N(
|
|
315
317
|
e[0].returnedPsbtHex,
|
|
316
318
|
t
|
|
@@ -321,9 +323,9 @@ function Ae(e, r, t) {
|
|
|
321
323
|
signerXOnlyPubkeyHex: t,
|
|
322
324
|
inputIndex: 0
|
|
323
325
|
});
|
|
324
|
-
const
|
|
326
|
+
const l = {};
|
|
325
327
|
for (const a of r) {
|
|
326
|
-
|
|
328
|
+
I(e[a.noPayoutIdx]);
|
|
327
329
|
const i = N(
|
|
328
330
|
e[a.noPayoutIdx].returnedPsbtHex,
|
|
329
331
|
t
|
|
@@ -333,7 +335,7 @@ function Ae(e, r, t) {
|
|
|
333
335
|
signatureHex: i,
|
|
334
336
|
signerXOnlyPubkeyHex: t,
|
|
335
337
|
inputIndex: 0
|
|
336
|
-
}),
|
|
338
|
+
}), l[a.challengerPubkey] = {
|
|
337
339
|
nopayout_signature: i
|
|
338
340
|
};
|
|
339
341
|
}
|
|
@@ -341,10 +343,10 @@ function Ae(e, r, t) {
|
|
|
341
343
|
payout_signatures: {
|
|
342
344
|
payout_signature: s
|
|
343
345
|
},
|
|
344
|
-
per_challenger:
|
|
346
|
+
per_challenger: l
|
|
345
347
|
};
|
|
346
348
|
}
|
|
347
|
-
async function
|
|
349
|
+
async function $e(e, r, t) {
|
|
348
350
|
if (typeof e.signPsbts == "function")
|
|
349
351
|
return e.signPsbts(r, t);
|
|
350
352
|
const n = [];
|
|
@@ -352,43 +354,43 @@ async function Re(e, r, t) {
|
|
|
352
354
|
n.push(await e.signPsbt(r[s], t == null ? void 0 : t[s]));
|
|
353
355
|
return n;
|
|
354
356
|
}
|
|
355
|
-
async function
|
|
356
|
-
const { depositorGraph: r, btcWallet: t, signingContext: n } = e, s = await t.getPublicKeyHex(), { depositorPubkey:
|
|
357
|
+
async function Ve(e) {
|
|
358
|
+
const { depositorGraph: r, btcWallet: t, signingContext: n } = e, s = await t.getPublicKeyHex(), { depositorPubkey: l } = re(
|
|
357
359
|
s,
|
|
358
360
|
p(n.depositorBtcPubkey)
|
|
359
|
-
), { psbtHexes: a, signOptions: i, challengerEntries: o } = await
|
|
361
|
+
), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Ce(
|
|
360
362
|
r,
|
|
361
363
|
s,
|
|
362
364
|
n
|
|
363
|
-
),
|
|
365
|
+
), u = await $e(
|
|
364
366
|
t,
|
|
365
367
|
a,
|
|
366
368
|
i
|
|
367
369
|
);
|
|
368
|
-
if (
|
|
370
|
+
if (u.length !== a.length)
|
|
369
371
|
throw new Error(
|
|
370
|
-
`Wallet returned ${
|
|
372
|
+
`Wallet returned ${u.length} signed PSBTs, expected ${a.length}`
|
|
371
373
|
);
|
|
372
374
|
const h = a.map((c, d) => ({
|
|
373
375
|
requestedPsbtHex: c,
|
|
374
|
-
returnedPsbtHex:
|
|
376
|
+
returnedPsbtHex: u[d]
|
|
375
377
|
}));
|
|
376
378
|
return Ae(
|
|
377
379
|
h,
|
|
378
380
|
o,
|
|
379
|
-
|
|
381
|
+
l
|
|
380
382
|
);
|
|
381
383
|
}
|
|
382
|
-
const
|
|
384
|
+
const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
|
|
383
385
|
w.PENDING_ACKS,
|
|
384
386
|
w.PENDING_ACTIVATION,
|
|
385
387
|
w.ACTIVATED_PENDING_BROADCAST,
|
|
386
388
|
w.ACTIVATED
|
|
387
|
-
]),
|
|
389
|
+
]), Be = /* @__PURE__ */ new Set([
|
|
388
390
|
w.PENDING_DEPOSITOR_SIGNATURES,
|
|
389
391
|
...q
|
|
390
392
|
]);
|
|
391
|
-
function
|
|
393
|
+
function Ie(e) {
|
|
392
394
|
return e.map((r) => ({
|
|
393
395
|
claimerPubkeyXOnly: A(r.claimer_pubkey),
|
|
394
396
|
payoutTxHex: r.payout_tx.tx_hex,
|
|
@@ -399,11 +401,11 @@ function _(e) {
|
|
|
399
401
|
return A(e).toLowerCase();
|
|
400
402
|
}
|
|
401
403
|
function Ne(e, r, t, n) {
|
|
402
|
-
const s = _(n),
|
|
404
|
+
const s = _(n), l = [
|
|
403
405
|
_(r),
|
|
404
406
|
...t.map(_)
|
|
405
|
-
], a = new Set(
|
|
406
|
-
if (a.size !==
|
|
407
|
+
], a = new Set(l);
|
|
408
|
+
if (a.size !== l.length)
|
|
407
409
|
throw new Error(
|
|
408
410
|
"Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
|
|
409
411
|
);
|
|
@@ -418,7 +420,7 @@ function Ne(e, r, t, n) {
|
|
|
418
420
|
throw new Error(
|
|
419
421
|
"Presign response contains duplicate claimer entries"
|
|
420
422
|
);
|
|
421
|
-
const o = i.filter((d) => d !== s),
|
|
423
|
+
const o = i.filter((d) => d !== s), u = new Set(o), h = l.filter((d) => !u.has(d)), c = o.filter((d) => !a.has(d));
|
|
422
424
|
if (h.length > 0 || c.length > 0)
|
|
423
425
|
throw new Error(
|
|
424
426
|
"Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (h.length > 0 ? ` (missing: ${h.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
|
|
@@ -426,6 +428,7 @@ function Ne(e, r, t, n) {
|
|
|
426
428
|
}
|
|
427
429
|
function U(e, r) {
|
|
428
430
|
return {
|
|
431
|
+
vaultCoreVersion: r.vaultCoreVersion,
|
|
429
432
|
payoutTxHex: e.payoutTxHex,
|
|
430
433
|
peginTxHex: r.peginTxHex,
|
|
431
434
|
assertTxHex: e.assertTxHex,
|
|
@@ -443,21 +446,21 @@ async function He(e, r, t, n) {
|
|
|
443
446
|
const s = new oe({
|
|
444
447
|
network: r.network,
|
|
445
448
|
btcWallet: e
|
|
446
|
-
}),
|
|
447
|
-
n == null || n(0,
|
|
449
|
+
}), l = t.length;
|
|
450
|
+
n == null || n(0, l);
|
|
448
451
|
let a;
|
|
449
452
|
if (s.supportsBatchSigning())
|
|
450
453
|
a = (await s.signPayoutTransactionsBatch(
|
|
451
|
-
t.map((
|
|
452
|
-
)).map((
|
|
454
|
+
t.map((u) => U(u, r))
|
|
455
|
+
)).map((u) => u.payoutSignature);
|
|
453
456
|
else {
|
|
454
457
|
a = [];
|
|
455
458
|
for (let o = 0; o < t.length; o++) {
|
|
456
|
-
n == null || n(o,
|
|
457
|
-
const
|
|
459
|
+
n == null || n(o, l);
|
|
460
|
+
const u = await s.signPayoutTransaction(
|
|
458
461
|
U(t[o], r)
|
|
459
462
|
);
|
|
460
|
-
a.push(
|
|
463
|
+
a.push(u.signature);
|
|
461
464
|
}
|
|
462
465
|
}
|
|
463
466
|
const i = {};
|
|
@@ -465,23 +468,23 @@ async function He(e, r, t, n) {
|
|
|
465
468
|
i[t[o].claimerPubkeyXOnly] = {
|
|
466
469
|
payout_signature: a[o]
|
|
467
470
|
};
|
|
468
|
-
return n == null || n(
|
|
471
|
+
return n == null || n(l, l), i;
|
|
469
472
|
}
|
|
470
|
-
async function
|
|
473
|
+
async function ct(e) {
|
|
471
474
|
const {
|
|
472
475
|
statusReader: r,
|
|
473
476
|
presignClient: t,
|
|
474
477
|
btcWallet: n,
|
|
475
478
|
peginTxid: s,
|
|
476
|
-
depositorPk:
|
|
479
|
+
depositorPk: l,
|
|
477
480
|
signingContext: a,
|
|
478
|
-
timeoutMs: i =
|
|
481
|
+
timeoutMs: i = Re,
|
|
479
482
|
signal: o,
|
|
480
|
-
onProgress:
|
|
483
|
+
onProgress: u
|
|
481
484
|
} = e, h = await G({
|
|
482
485
|
statusReader: r,
|
|
483
486
|
peginTxid: s,
|
|
484
|
-
targetStatuses:
|
|
487
|
+
targetStatuses: Be,
|
|
485
488
|
timeoutMs: i,
|
|
486
489
|
signal: o
|
|
487
490
|
});
|
|
@@ -491,33 +494,34 @@ async function lt(e) {
|
|
|
491
494
|
const c = await t.requestDepositorPresignTransactions(
|
|
492
495
|
{
|
|
493
496
|
pegin_txid: s,
|
|
494
|
-
depositor_pk:
|
|
497
|
+
depositor_pk: l
|
|
495
498
|
},
|
|
496
499
|
o
|
|
497
500
|
);
|
|
498
501
|
o == null || o.throwIfAborted();
|
|
499
|
-
const d = _(
|
|
502
|
+
const d = _(l);
|
|
500
503
|
Ne(
|
|
501
504
|
c.txs,
|
|
502
505
|
a.vaultProviderBtcPubkey,
|
|
503
506
|
a.vaultKeeperBtcPubkeys,
|
|
504
|
-
|
|
507
|
+
l
|
|
505
508
|
);
|
|
506
509
|
const P = c.txs.filter(
|
|
507
510
|
(v) => _(v.claimer_pubkey) !== d
|
|
508
|
-
), m =
|
|
511
|
+
), m = Ie(P), y = await He(
|
|
509
512
|
n,
|
|
510
513
|
a,
|
|
511
514
|
m,
|
|
512
|
-
|
|
515
|
+
u
|
|
513
516
|
);
|
|
514
517
|
o == null || o.throwIfAborted();
|
|
515
|
-
const x = await
|
|
518
|
+
const x = await Ve({
|
|
516
519
|
depositorGraph: c.depositor_graph,
|
|
517
520
|
btcWallet: n,
|
|
518
521
|
signingContext: {
|
|
522
|
+
vaultCoreVersion: a.vaultCoreVersion,
|
|
519
523
|
peginTxHex: a.peginTxHex,
|
|
520
|
-
depositorBtcPubkey:
|
|
524
|
+
depositorBtcPubkey: l,
|
|
521
525
|
vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
|
|
522
526
|
vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
|
|
523
527
|
universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
|
|
@@ -531,10 +535,10 @@ async function lt(e) {
|
|
|
531
535
|
});
|
|
532
536
|
o == null || o.throwIfAborted();
|
|
533
537
|
const b = { ...y };
|
|
534
|
-
b[p(
|
|
538
|
+
b[p(l)] = x.payout_signatures, await t.submitDepositorPresignatures(
|
|
535
539
|
{
|
|
536
540
|
pegin_txid: s,
|
|
537
|
-
depositor_pk:
|
|
541
|
+
depositor_pk: l,
|
|
538
542
|
signatures: b,
|
|
539
543
|
depositor_claimer_presignatures: x
|
|
540
544
|
},
|
|
@@ -544,18 +548,18 @@ async function lt(e) {
|
|
|
544
548
|
function Oe(e) {
|
|
545
549
|
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
546
550
|
}
|
|
547
|
-
function
|
|
551
|
+
function ht(e) {
|
|
548
552
|
const {
|
|
549
553
|
amountSats: r,
|
|
550
554
|
minDeposit: t,
|
|
551
555
|
maxDeposit: n,
|
|
552
556
|
btcBalance: s,
|
|
553
|
-
estimatedFeeSats:
|
|
557
|
+
estimatedFeeSats: l,
|
|
554
558
|
depositorClaimValue: a
|
|
555
559
|
} = e;
|
|
556
|
-
return !(r <= 0n || r < t || n && n > 0n && r > n ||
|
|
560
|
+
return !(r <= 0n || r < t || n && n > 0n && r > n || l == null || a == null || r + l + a > s);
|
|
557
561
|
}
|
|
558
|
-
function
|
|
562
|
+
function dt(e, r, t) {
|
|
559
563
|
return e <= 0n ? {
|
|
560
564
|
valid: !1,
|
|
561
565
|
error: "Deposit amount must be greater than zero"
|
|
@@ -567,7 +571,7 @@ function ht(e, r, t) {
|
|
|
567
571
|
error: `Maximum deposit is ${E(t)} BTC`
|
|
568
572
|
} : { valid: !0 };
|
|
569
573
|
}
|
|
570
|
-
function
|
|
574
|
+
function pt(e) {
|
|
571
575
|
const { amount: r, effectiveRemaining: t } = e;
|
|
572
576
|
return t === null ? { valid: !0 } : t === 0n ? {
|
|
573
577
|
valid: !1,
|
|
@@ -577,7 +581,7 @@ function dt(e) {
|
|
|
577
581
|
error: `Vault size exceeds remaining capacity (${E(t)} BTC)`
|
|
578
582
|
} : { valid: !0 };
|
|
579
583
|
}
|
|
580
|
-
function
|
|
584
|
+
function gt(e, r) {
|
|
581
585
|
if (!e || e.length === 0)
|
|
582
586
|
return {
|
|
583
587
|
valid: !1,
|
|
@@ -642,13 +646,13 @@ function Me(e) {
|
|
|
642
646
|
if (e.length === 0)
|
|
643
647
|
throw new Error("No spendable UTXOs available");
|
|
644
648
|
}
|
|
645
|
-
function
|
|
649
|
+
function ft(e) {
|
|
646
650
|
const {
|
|
647
651
|
vaultAmounts: r,
|
|
648
652
|
confirmedUTXOs: t,
|
|
649
653
|
vaultProviderBtcPubkey: n,
|
|
650
654
|
vaultKeeperBtcPubkeys: s,
|
|
651
|
-
universalChallengerBtcPubkeys:
|
|
655
|
+
universalChallengerBtcPubkeys: l,
|
|
652
656
|
minDeposit: a,
|
|
653
657
|
maxDeposit: i
|
|
654
658
|
} = e, o = De(
|
|
@@ -658,58 +662,58 @@ function gt(e) {
|
|
|
658
662
|
);
|
|
659
663
|
if (!o.valid)
|
|
660
664
|
throw new Error(o.error);
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
663
|
-
throw new Error(
|
|
664
|
-
Ue(s), Fe(
|
|
665
|
+
const u = Ke(n);
|
|
666
|
+
if (!u.valid)
|
|
667
|
+
throw new Error(u.error);
|
|
668
|
+
Ue(s), Fe(l), Me(t);
|
|
665
669
|
}
|
|
666
|
-
async function
|
|
670
|
+
async function mt(e) {
|
|
667
671
|
const {
|
|
668
672
|
vaultRegistryReader: r,
|
|
669
673
|
vaultKeeperReader: t,
|
|
670
674
|
universalChallengerReader: n,
|
|
671
675
|
vaultProviderEthAddress: s,
|
|
672
|
-
applicationEntryPoint:
|
|
676
|
+
applicationEntryPoint: l,
|
|
673
677
|
expectedVaultProviderBtcPubkey: a,
|
|
674
678
|
expectedVaultKeeperBtcPubkeys: i,
|
|
675
679
|
expectedUniversalChallengerBtcPubkeys: o
|
|
676
680
|
} = e, [
|
|
677
|
-
|
|
681
|
+
u,
|
|
678
682
|
h,
|
|
679
683
|
c
|
|
680
684
|
] = await Promise.all([
|
|
681
685
|
r.getVaultProviderBtcPubKey(s),
|
|
682
|
-
t.getCurrentVaultKeepersVersion(
|
|
686
|
+
t.getCurrentVaultKeepersVersion(l),
|
|
683
687
|
n.getLatestUniversalChallengersVersion()
|
|
684
688
|
]), [d, P] = await Promise.all([
|
|
685
689
|
t.getVaultKeepersByVersion(
|
|
686
|
-
|
|
690
|
+
l,
|
|
687
691
|
h
|
|
688
692
|
),
|
|
689
693
|
n.getUniversalChallengersByVersion(
|
|
690
694
|
c
|
|
691
695
|
)
|
|
692
696
|
]), m = (g) => A(g).toLowerCase(), y = (g) => g.map(m).sort();
|
|
693
|
-
if (m(a) !==
|
|
697
|
+
if (m(a) !== u)
|
|
694
698
|
throw new Error(
|
|
695
699
|
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
|
|
696
700
|
);
|
|
697
701
|
const b = y(i), v = y(
|
|
698
702
|
d.map((g) => g.btcPubKey)
|
|
699
703
|
);
|
|
700
|
-
if (b.length !== v.length || b.some((g,
|
|
704
|
+
if (b.length !== v.length || b.some((g, C) => g !== v[C]))
|
|
701
705
|
throw new Error(
|
|
702
706
|
`Vault keeper BTC pubkeys (v${h}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
703
707
|
);
|
|
704
708
|
const T = y(o), k = y(
|
|
705
709
|
P.map((g) => g.btcPubKey)
|
|
706
710
|
);
|
|
707
|
-
if (T.length !== k.length || T.some((g,
|
|
711
|
+
if (T.length !== k.length || T.some((g, C) => g !== k[C]))
|
|
708
712
|
throw new Error(
|
|
709
713
|
`Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
710
714
|
);
|
|
711
715
|
return {
|
|
712
|
-
vaultProviderBtcPubkeyXOnly:
|
|
716
|
+
vaultProviderBtcPubkeyXOnly: u,
|
|
713
717
|
vaultKeeperBtcPubkeysSorted: v,
|
|
714
718
|
universalChallengerBtcPubkeysSorted: k,
|
|
715
719
|
expectedAppVaultKeepersVersion: h,
|
|
@@ -721,29 +725,32 @@ class j extends Error {
|
|
|
721
725
|
super(r), this.name = "RegisteredVaultVersionMismatchError";
|
|
722
726
|
}
|
|
723
727
|
}
|
|
724
|
-
function
|
|
728
|
+
function Pt(e) {
|
|
725
729
|
return e instanceof j || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
726
730
|
}
|
|
727
|
-
async function
|
|
731
|
+
async function bt(e) {
|
|
728
732
|
const {
|
|
729
733
|
vaultRegistryReader: r,
|
|
730
734
|
vaultIds: t,
|
|
731
735
|
expectedOffchainParamsVersion: n,
|
|
732
736
|
expectedAppVaultKeepersVersion: s,
|
|
733
|
-
expectedUniversalChallengersVersion:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
737
|
+
expectedUniversalChallengersVersion: l,
|
|
738
|
+
expectedVaultCoreVersion: a
|
|
739
|
+
} = e, i = await r.getProtocolInfoBatch(t), o = [];
|
|
740
|
+
if (i.forEach((u, h) => {
|
|
741
|
+
const c = t[h];
|
|
742
|
+
u.offchainParamsVersion !== n && o.push(
|
|
743
|
+
`vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
|
|
744
|
+
), u.appVaultKeepersVersion !== s && o.push(
|
|
745
|
+
`vault ${c}: appVaultKeepers expected v${s}, got v${u.appVaultKeepersVersion}`
|
|
746
|
+
), u.universalChallengersVersion !== l && o.push(
|
|
747
|
+
`vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
|
|
748
|
+
), u.vaultCoreVersion !== a && o.push(
|
|
749
|
+
`vault ${c}: vaultCoreVersion expected v${a} (build-time active), got v${u.vaultCoreVersion}`
|
|
750
|
+
);
|
|
751
|
+
}), o.length > 0)
|
|
745
752
|
throw new j(
|
|
746
|
-
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${
|
|
753
|
+
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${o.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
747
754
|
);
|
|
748
755
|
}
|
|
749
756
|
var Q = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(Q || {});
|
|
@@ -752,24 +759,24 @@ const Le = /* @__PURE__ */ new Set([
|
|
|
752
759
|
"PayoutBlocked"
|
|
753
760
|
/* PAYOUT_BLOCKED */
|
|
754
761
|
]);
|
|
755
|
-
function
|
|
762
|
+
function yt(e) {
|
|
756
763
|
return Object.values(Q).includes(
|
|
757
764
|
e
|
|
758
765
|
);
|
|
759
766
|
}
|
|
760
|
-
function
|
|
767
|
+
function wt(e) {
|
|
761
768
|
return !!e && Le.has(e);
|
|
762
769
|
}
|
|
763
770
|
class Xe extends Error {
|
|
764
771
|
constructor(t, n) {
|
|
765
772
|
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
766
|
-
|
|
767
|
-
|
|
773
|
+
$(this, "vaultId");
|
|
774
|
+
$(this, "cause");
|
|
768
775
|
this.name = "BIP68NotMatureError", this.vaultId = t, this.cause = n;
|
|
769
776
|
}
|
|
770
777
|
}
|
|
771
778
|
const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, W = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Y = 160, F = 2e3, M = 10n, L = 100n;
|
|
772
|
-
function
|
|
779
|
+
function xt(e) {
|
|
773
780
|
if (!Number.isFinite(e) || e <= 0)
|
|
774
781
|
throw new Error(
|
|
775
782
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
@@ -787,7 +794,7 @@ function D(e, r) {
|
|
|
787
794
|
`${r} must contain only hex characters after the 0x prefix`
|
|
788
795
|
);
|
|
789
796
|
}
|
|
790
|
-
function
|
|
797
|
+
function B(e, r) {
|
|
791
798
|
if (!Number.isInteger(e) || e < 0)
|
|
792
799
|
throw new Error(`${r} must be a non-negative integer, got ${e}`);
|
|
793
800
|
}
|
|
@@ -822,9 +829,12 @@ function Qe(e) {
|
|
|
822
829
|
throw new Error(
|
|
823
830
|
`batch[${e.htlcVout}].amount (${r.amount}) does not match target amount (${e.amount})`
|
|
824
831
|
);
|
|
825
|
-
if (
|
|
832
|
+
if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
|
|
826
833
|
e.universalChallengersVersion,
|
|
827
834
|
"universalChallengersVersion"
|
|
835
|
+
), ge(
|
|
836
|
+
e.vaultCoreVersion,
|
|
837
|
+
"VaultRefundData.vaultCoreVersion"
|
|
828
838
|
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
829
839
|
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
830
840
|
if (!Ge.test(e.unsignedPrePeginTxHex))
|
|
@@ -875,21 +885,21 @@ function Ye(e) {
|
|
|
875
885
|
}
|
|
876
886
|
return r.extractTransaction().toHex();
|
|
877
887
|
}
|
|
878
|
-
async function
|
|
888
|
+
async function vt(e) {
|
|
879
889
|
const {
|
|
880
890
|
vaultId: r,
|
|
881
891
|
readVault: t,
|
|
882
892
|
readPrePeginContext: n,
|
|
883
893
|
feeRate: s,
|
|
884
|
-
signPsbt:
|
|
894
|
+
signPsbt: l,
|
|
885
895
|
broadcastTx: a,
|
|
886
896
|
signal: i
|
|
887
897
|
} = e;
|
|
888
898
|
i == null || i.throwIfAborted(), D(r, "vaultId");
|
|
889
899
|
const o = await t();
|
|
890
900
|
Qe(o), i == null || i.throwIfAborted();
|
|
891
|
-
const
|
|
892
|
-
if (We(
|
|
901
|
+
const u = await n(o);
|
|
902
|
+
if (We(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
893
903
|
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
894
904
|
if (s > F)
|
|
895
905
|
throw new Error(
|
|
@@ -911,7 +921,7 @@ async function xt(e) {
|
|
|
911
921
|
const y = m == null ? void 0 : m.hash;
|
|
912
922
|
let x;
|
|
913
923
|
try {
|
|
914
|
-
x =
|
|
924
|
+
x = S.fromHex(P);
|
|
915
925
|
} catch (f) {
|
|
916
926
|
throw new Error(
|
|
917
927
|
`Failed to parse funded Pre-PegIn transaction hex: ${f instanceof Error ? f.message : String(f)}`
|
|
@@ -921,14 +931,15 @@ async function xt(e) {
|
|
|
921
931
|
throw new Error(
|
|
922
932
|
`Funded Pre-PegIn tx has ${x.outs.length} outputs but batch requires at least ${o.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
|
|
923
933
|
);
|
|
924
|
-
const { psbtHex: b } = await
|
|
934
|
+
const { psbtHex: b } = await pe({
|
|
925
935
|
prePeginParams: {
|
|
936
|
+
vaultCoreVersion: o.vaultCoreVersion,
|
|
926
937
|
depositorPubkey: d,
|
|
927
|
-
vaultProviderPubkey: p(
|
|
928
|
-
vaultKeeperPubkeys:
|
|
929
|
-
universalChallengerPubkeys:
|
|
938
|
+
vaultProviderPubkey: p(u.vaultProviderPubkey),
|
|
939
|
+
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(p),
|
|
940
|
+
universalChallengerPubkeys: u.universalChallengerPubkeys.map(p),
|
|
930
941
|
hashlocks: o.batch.map((f) => p(f.hashlock)),
|
|
931
|
-
timelockRefund:
|
|
942
|
+
timelockRefund: u.timelockRefund,
|
|
932
943
|
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
933
944
|
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
934
945
|
// reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
|
|
@@ -936,12 +947,12 @@ async function xt(e) {
|
|
|
936
947
|
// to the funded tx bytes, refusing the refund if the template's HTLC value
|
|
937
948
|
// disagrees with the on-chain commitment.
|
|
938
949
|
pegInAmounts: o.batch.map((f) => f.amount),
|
|
939
|
-
feeRate:
|
|
940
|
-
minPeginFeeRate:
|
|
941
|
-
numLocalChallengers:
|
|
942
|
-
councilQuorum:
|
|
943
|
-
councilSize:
|
|
944
|
-
network:
|
|
950
|
+
feeRate: u.feeRate,
|
|
951
|
+
minPeginFeeRate: u.minPeginFeeRate,
|
|
952
|
+
numLocalChallengers: u.numLocalChallengers,
|
|
953
|
+
councilQuorum: u.councilQuorum,
|
|
954
|
+
councilSize: u.councilSize,
|
|
955
|
+
network: u.network,
|
|
945
956
|
authAnchorHash: y
|
|
946
957
|
},
|
|
947
958
|
fundedPrePeginTxHex: P,
|
|
@@ -957,8 +968,8 @@ async function xt(e) {
|
|
|
957
968
|
const v = O(
|
|
958
969
|
o.depositorBtcPubkey,
|
|
959
970
|
qe
|
|
960
|
-
), T = await
|
|
961
|
-
|
|
971
|
+
), T = await l(b, v);
|
|
972
|
+
I({
|
|
962
973
|
requestedPsbtHex: b,
|
|
963
974
|
returnedPsbtHex: T
|
|
964
975
|
});
|
|
@@ -973,10 +984,10 @@ async function xt(e) {
|
|
|
973
984
|
signerXOnlyPubkeyHex: d,
|
|
974
985
|
inputIndex: k
|
|
975
986
|
});
|
|
976
|
-
const
|
|
987
|
+
const C = Ye(T);
|
|
977
988
|
i == null || i.throwIfAborted();
|
|
978
989
|
try {
|
|
979
|
-
return await a(
|
|
990
|
+
return await a(C);
|
|
980
991
|
} catch (f) {
|
|
981
992
|
throw f instanceof Error && je.test(f.message) ? new Xe(r, f) : f;
|
|
982
993
|
}
|
|
@@ -985,28 +996,28 @@ export {
|
|
|
985
996
|
Xe as B,
|
|
986
997
|
Q as C,
|
|
987
998
|
j as R,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
999
|
+
ut as a,
|
|
1000
|
+
Ve as b,
|
|
1001
|
+
pt as c,
|
|
1002
|
+
gt as d,
|
|
992
1003
|
De as e,
|
|
993
1004
|
Ke as f,
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1005
|
+
ft as g,
|
|
1006
|
+
mt as h,
|
|
1007
|
+
ht as i,
|
|
1008
|
+
Pt as j,
|
|
1009
|
+
bt as k,
|
|
1010
|
+
yt as l,
|
|
1011
|
+
wt as m,
|
|
1012
|
+
vt as n,
|
|
1013
|
+
xt as o,
|
|
1003
1014
|
L as p,
|
|
1004
1015
|
M as q,
|
|
1005
|
-
|
|
1006
|
-
|
|
1016
|
+
ct as r,
|
|
1017
|
+
lt as s,
|
|
1007
1018
|
F as t,
|
|
1008
1019
|
Y as u,
|
|
1009
|
-
|
|
1020
|
+
dt as v,
|
|
1010
1021
|
G as w
|
|
1011
1022
|
};
|
|
1012
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
1023
|
+
//# sourceMappingURL=buildAndBroadcastRefund-DjS9nf87.js.map
|