@babylonlabs-io/ts-sdk 0.36.1 → 0.36.3
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-BPXVXu8t.cjs +2 -0
- package/dist/{PeginManager-cPQuJTB9.cjs.map → PeginManager-BPXVXu8t.cjs.map} +1 -1
- package/dist/{PeginManager-DF1oinIQ.js → PeginManager-CB-dVkT2.js} +387 -369
- package/dist/{PeginManager-DF1oinIQ.js.map → PeginManager-CB-dVkT2.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-D4YqqClN.js → buildAndBroadcastRefund-C2VqXiOx.js} +241 -220
- package/dist/buildAndBroadcastRefund-C2VqXiOx.js.map +1 -0
- package/dist/buildAndBroadcastRefund-CBIfcF47.cjs +2 -0
- package/dist/buildAndBroadcastRefund-CBIfcF47.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/reservation-DF0uiCUC.cjs +2 -0
- package/dist/reservation-DF0uiCUC.cjs.map +1 -0
- package/dist/{reservation-CHUGW0F_.js → reservation-fZUvejYK.js} +36 -35
- package/dist/reservation-fZUvejYK.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +4 -4
- package/dist/tbv/core/managers/PeginManager.d.ts +22 -4
- 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 +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 +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +4 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.d.ts +1 -0
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +4 -4
- package/dist/vault-registry-reader-Br9m8bHF.cjs +2 -0
- package/dist/vault-registry-reader-Br9m8bHF.cjs.map +1 -0
- package/dist/{vault-registry-reader-CrLodprY.js → vault-registry-reader-CohvzvoH.js} +129 -124
- package/dist/vault-registry-reader-CohvzvoH.js.map +1 -0
- package/package.json +1 -1
- package/dist/PeginManager-cPQuJTB9.cjs +0 -2
- package/dist/buildAndBroadcastRefund-D4YqqClN.js.map +0 -1
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs +0 -2
- package/dist/buildAndBroadcastRefund-DSELaUiR.cjs.map +0 -1
- package/dist/reservation-CHUGW0F_.js.map +0 -1
- package/dist/reservation-ho7mjW3X.cjs +0 -2
- package/dist/reservation-ho7mjW3X.cjs.map +0 -1
- package/dist/vault-registry-reader-CLnhAUN4.cjs +0 -2
- package/dist/vault-registry-reader-CLnhAUN4.cjs.map +0 -1
- package/dist/vault-registry-reader-CrLodprY.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
2
|
var W = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var
|
|
3
|
+
var S = (e, t, r) => W(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { B as Q } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
5
|
-
import { e as Y, v as j, s as c, u as N, p as
|
|
5
|
+
import { e as Y, v as j, s as c, u as N, p as k, f as m } from "./bitcoin-B0S8SHCX.js";
|
|
6
6
|
import { v as q, P as J } from "./PayoutManager-s_uH8Uuj.js";
|
|
7
7
|
import { c as Z, a as ee, R as te, d as H, D as x } from "./types-TiIjyo2b.js";
|
|
8
8
|
import * as re from "bitcoinjs-lib";
|
|
9
|
-
import { Transaction as
|
|
9
|
+
import { Transaction as T, Psbt as ne } from "bitcoinjs-lib";
|
|
10
10
|
import { Buffer as oe } from "buffer";
|
|
11
11
|
import { c as ae, a as se, b as ie } from "./noPayout-DBX6G96_.js";
|
|
12
|
-
import { a as ue, b as le, e as
|
|
12
|
+
import { a as ue, b as le, e as V } from "./payout-BNFMBXS6.js";
|
|
13
13
|
import { c as R } from "./signing-DaLvGwQe.js";
|
|
14
|
-
const ce = /^0x[0-9a-fA-F]{64}$/, de = /^0x[0-9a-fA-F]{40}$/,
|
|
15
|
-
function
|
|
14
|
+
const ce = /^0x[0-9a-fA-F]{64}$/, de = /^0x[0-9a-fA-F]{40}$/, he = /^0x([0-9a-fA-F]{2})*$/;
|
|
15
|
+
function C(e, t) {
|
|
16
16
|
if (e.length !== 66)
|
|
17
17
|
throw new Error(
|
|
18
18
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
@@ -22,19 +22,19 @@ function S(e, t) {
|
|
|
22
22
|
`${t} must contain only hex characters after the 0x prefix`
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function pe(e, t) {
|
|
26
26
|
if (!de.test(e))
|
|
27
27
|
throw new Error(
|
|
28
28
|
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
function fe(e, t) {
|
|
32
|
-
if (!
|
|
32
|
+
if (!he.test(e))
|
|
33
33
|
throw new Error(
|
|
34
34
|
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function nt(e) {
|
|
38
38
|
const {
|
|
39
39
|
btcVaultRegistryAddress: t,
|
|
40
40
|
vaultId: r,
|
|
@@ -43,9 +43,9 @@ async function rt(e) {
|
|
|
43
43
|
writeContract: u,
|
|
44
44
|
signal: a
|
|
45
45
|
} = e;
|
|
46
|
-
a == null || a.throwIfAborted(),
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
46
|
+
a == null || a.throwIfAborted(), pe(t, "btcVaultRegistryAddress"), C(r, "vaultId");
|
|
47
|
+
const o = Y(e.secret);
|
|
48
|
+
if (C(o, "secret"), n !== void 0 && (C(n, "hashlock"), !q(o, n)))
|
|
49
49
|
throw new Error(
|
|
50
50
|
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
51
51
|
);
|
|
@@ -53,7 +53,7 @@ async function rt(e) {
|
|
|
53
53
|
address: t,
|
|
54
54
|
abi: Q,
|
|
55
55
|
functionName: "activateVaultWithSecret",
|
|
56
|
-
args: [r,
|
|
56
|
+
args: [r, o, i]
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
const ge = 1e4;
|
|
@@ -65,79 +65,79 @@ async function L(e) {
|
|
|
65
65
|
timeoutMs: i,
|
|
66
66
|
pollIntervalMs: u = ge,
|
|
67
67
|
signal: a
|
|
68
|
-
} = e,
|
|
68
|
+
} = e, o = Date.now();
|
|
69
69
|
for (; ; ) {
|
|
70
70
|
if (a != null && a.aborted)
|
|
71
71
|
throw new Error(
|
|
72
72
|
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
73
73
|
);
|
|
74
|
-
if (Date.now() -
|
|
74
|
+
if (Date.now() - o >= i)
|
|
75
75
|
throw new Error(
|
|
76
76
|
`Polling timeout after ${i}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
77
77
|
);
|
|
78
78
|
try {
|
|
79
|
-
const
|
|
79
|
+
const s = await t.getPeginStatus(
|
|
80
80
|
{ pegin_txid: r },
|
|
81
81
|
a
|
|
82
82
|
);
|
|
83
|
-
if (
|
|
83
|
+
if (s.pegin_txid.toLowerCase() !== r.toLowerCase())
|
|
84
84
|
throw new Error(
|
|
85
|
-
`getPeginStatus returned status for pegin ${
|
|
85
|
+
`getPeginStatus returned status for pegin ${s.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
|
|
86
86
|
);
|
|
87
|
-
const l =
|
|
87
|
+
const l = s.status;
|
|
88
88
|
if (n.has(l))
|
|
89
89
|
return l;
|
|
90
90
|
if (Z.has(l) && !n.has(l))
|
|
91
91
|
throw new Error(
|
|
92
92
|
`Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...n].join(", ")}`
|
|
93
93
|
);
|
|
94
|
-
} catch (
|
|
95
|
-
if (!(
|
|
96
|
-
throw
|
|
94
|
+
} catch (s) {
|
|
95
|
+
if (!(s instanceof ee && s.code === te.NOT_FOUND || s instanceof Error && s.message.includes("PegIn not found")))
|
|
96
|
+
throw s;
|
|
97
97
|
}
|
|
98
|
-
await new Promise((
|
|
98
|
+
await new Promise((s, l) => {
|
|
99
99
|
const d = () => {
|
|
100
|
-
clearTimeout(
|
|
100
|
+
clearTimeout(h), l(
|
|
101
101
|
new Error(
|
|
102
102
|
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
103
103
|
)
|
|
104
104
|
);
|
|
105
|
-
},
|
|
106
|
-
a == null || a.removeEventListener("abort", d),
|
|
105
|
+
}, h = setTimeout(() => {
|
|
106
|
+
a == null || a.removeEventListener("abort", d), s();
|
|
107
107
|
}, u);
|
|
108
108
|
a == null || a.addEventListener("abort", d, { once: !0 });
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const ye = 300 * 1e3, Pe = /* @__PURE__ */ new Set([
|
|
113
113
|
x.PENDING_DEPOSITOR_WOTS_PK,
|
|
114
114
|
...H
|
|
115
115
|
]);
|
|
116
|
-
async function
|
|
116
|
+
async function ot(e) {
|
|
117
117
|
const {
|
|
118
118
|
statusReader: t,
|
|
119
119
|
wotsSubmitter: r,
|
|
120
120
|
peginTxid: n,
|
|
121
121
|
depositorPk: i,
|
|
122
122
|
wotsPublicKeys: u,
|
|
123
|
-
timeoutMs: a =
|
|
124
|
-
signal:
|
|
123
|
+
timeoutMs: a = ye,
|
|
124
|
+
signal: o
|
|
125
125
|
} = e;
|
|
126
|
-
|
|
127
|
-
const
|
|
126
|
+
o == null || o.throwIfAborted();
|
|
127
|
+
const s = await L({
|
|
128
128
|
statusReader: t,
|
|
129
129
|
peginTxid: n,
|
|
130
|
-
targetStatuses:
|
|
130
|
+
targetStatuses: Pe,
|
|
131
131
|
timeoutMs: a,
|
|
132
|
-
signal:
|
|
132
|
+
signal: o
|
|
133
133
|
});
|
|
134
|
-
H.has(
|
|
134
|
+
H.has(s) || (o == null || o.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
135
135
|
{
|
|
136
136
|
pegin_txid: n,
|
|
137
137
|
depositor_pk: i,
|
|
138
138
|
wots_public_keys: u
|
|
139
139
|
},
|
|
140
|
-
|
|
140
|
+
o
|
|
141
141
|
));
|
|
142
142
|
}
|
|
143
143
|
const I = 1;
|
|
@@ -149,31 +149,56 @@ function me(e, t, r) {
|
|
|
149
149
|
throw new Error(
|
|
150
150
|
"Cannot derive localChallengers: removing depositor from {vaultProvider, vaultKeepers} left an empty set"
|
|
151
151
|
);
|
|
152
|
+
if (new Set(u).size !== u.length)
|
|
153
|
+
throw new Error(
|
|
154
|
+
"Cannot derive localChallengers: vaultProvider key duplicates a vaultKeeper key — signing context is misconfigured"
|
|
155
|
+
);
|
|
152
156
|
return u;
|
|
153
157
|
}
|
|
154
158
|
function be(e, t) {
|
|
159
|
+
const r = e.map(
|
|
160
|
+
(o) => c(o.challenger_pubkey).toLowerCase()
|
|
161
|
+
), n = new Set(r);
|
|
162
|
+
if (n.size !== r.length)
|
|
163
|
+
throw new Error(
|
|
164
|
+
"Depositor graph contains duplicate challenger entries in challenger_presign_data"
|
|
165
|
+
);
|
|
166
|
+
const i = new Set(t), u = t.filter((o) => !n.has(o)), a = r.filter((o) => !i.has(o));
|
|
167
|
+
if (u.length > 0 || a.length > 0)
|
|
168
|
+
throw new Error(
|
|
169
|
+
"Depositor graph challenger set does not match localChallengers" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (a.length > 0 ? ` (unexpected: ${a.join(", ")})` : "")
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function we(e, t) {
|
|
155
173
|
const r = e.ins[t];
|
|
156
174
|
return N(new Uint8Array(r.hash).slice().reverse());
|
|
157
175
|
}
|
|
158
|
-
function
|
|
176
|
+
function B(e, t, r, n, i) {
|
|
159
177
|
const u = e.ins[t];
|
|
160
178
|
if (u.index !== 0)
|
|
161
179
|
throw new Error(
|
|
162
180
|
`NoPayout (challenger ${i}) input ${t} expected to spend ${n} vout 0, got vout ${u.index}`
|
|
163
181
|
);
|
|
164
|
-
const a = r.getId(),
|
|
165
|
-
if (
|
|
182
|
+
const a = r.getId(), o = we(e, t);
|
|
183
|
+
if (o !== a)
|
|
166
184
|
throw new Error(
|
|
167
|
-
`NoPayout (challenger ${i}) input ${t} does not reference ${n} (expected txid ${a}, got ${
|
|
185
|
+
`NoPayout (challenger ${i}) input ${t} does not reference ${n} (expected txid ${a}, got ${o})`
|
|
168
186
|
);
|
|
169
187
|
}
|
|
170
188
|
async function ve(e, t, r) {
|
|
171
|
-
const n = [], i = [], u = []
|
|
172
|
-
|
|
189
|
+
const n = [], i = [], u = [], a = me(
|
|
190
|
+
r.vaultProviderBtcPubkey,
|
|
191
|
+
r.vaultKeeperBtcPubkeys,
|
|
192
|
+
r.depositorBtcPubkey
|
|
193
|
+
);
|
|
194
|
+
be(
|
|
195
|
+
e.challenger_presign_data,
|
|
196
|
+
a
|
|
197
|
+
), ue(
|
|
173
198
|
e.payout_tx.tx_hex,
|
|
174
199
|
r.registeredPayoutScriptPubKey
|
|
175
200
|
);
|
|
176
|
-
const
|
|
201
|
+
const o = await le({
|
|
177
202
|
payoutTxHex: e.payout_tx.tx_hex,
|
|
178
203
|
peginTxHex: r.peginTxHex,
|
|
179
204
|
assertTxHex: e.assert_tx.tx_hex,
|
|
@@ -184,41 +209,37 @@ async function ve(e, t, r) {
|
|
|
184
209
|
timelockPegin: r.timelockPegin,
|
|
185
210
|
network: r.network
|
|
186
211
|
});
|
|
187
|
-
n.push(
|
|
212
|
+
n.push(o.psbtHex), i.push(
|
|
188
213
|
R(
|
|
189
214
|
t,
|
|
190
215
|
I
|
|
191
216
|
)
|
|
192
217
|
);
|
|
193
|
-
const s =
|
|
194
|
-
r.vaultProviderBtcPubkey,
|
|
195
|
-
r.vaultKeeperBtcPubkeys,
|
|
196
|
-
r.depositorBtcPubkey
|
|
197
|
-
), o = c(r.depositorBtcPubkey), l = k.fromHex(
|
|
218
|
+
const s = c(r.depositorBtcPubkey), l = T.fromHex(
|
|
198
219
|
c(e.assert_tx.tx_hex)
|
|
199
220
|
);
|
|
200
221
|
for (const d of e.challenger_presign_data) {
|
|
201
|
-
const
|
|
222
|
+
const h = c(d.challenger_pubkey), y = n.length, P = await xe({
|
|
202
223
|
challenger: d,
|
|
203
|
-
challengerPubkey:
|
|
204
|
-
claimerPubkey:
|
|
205
|
-
localChallengers:
|
|
224
|
+
challengerPubkey: h,
|
|
225
|
+
claimerPubkey: s,
|
|
226
|
+
localChallengers: a,
|
|
206
227
|
assertTxParsed: l,
|
|
207
228
|
ctx: r
|
|
208
229
|
});
|
|
209
|
-
n.push(
|
|
230
|
+
n.push(P), i.push(
|
|
210
231
|
R(
|
|
211
232
|
t,
|
|
212
233
|
I
|
|
213
234
|
)
|
|
214
235
|
), u.push({
|
|
215
|
-
challengerPubkey:
|
|
216
|
-
noPayoutIdx:
|
|
236
|
+
challengerPubkey: h,
|
|
237
|
+
noPayoutIdx: y
|
|
217
238
|
});
|
|
218
239
|
}
|
|
219
240
|
return { psbtHexes: n, signOptions: i, challengerEntries: u };
|
|
220
241
|
}
|
|
221
|
-
async function
|
|
242
|
+
async function xe(e) {
|
|
222
243
|
const {
|
|
223
244
|
challenger: t,
|
|
224
245
|
challengerPubkey: r,
|
|
@@ -232,31 +253,31 @@ async function we(e) {
|
|
|
232
253
|
r,
|
|
233
254
|
a.network
|
|
234
255
|
);
|
|
235
|
-
const
|
|
256
|
+
const o = T.fromHex(
|
|
236
257
|
c(t.nopayout_tx.tx_hex)
|
|
237
|
-
),
|
|
258
|
+
), s = T.fromHex(
|
|
238
259
|
c(t.challenge_assert_x_tx.tx_hex)
|
|
239
|
-
), l =
|
|
260
|
+
), l = T.fromHex(
|
|
240
261
|
c(t.challenge_assert_y_tx.tx_hex)
|
|
241
262
|
);
|
|
242
|
-
if (
|
|
263
|
+
if (o.ins.length !== 3)
|
|
243
264
|
throw new Error(
|
|
244
|
-
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${
|
|
265
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${o.ins.length}`
|
|
245
266
|
);
|
|
246
|
-
|
|
247
|
-
|
|
267
|
+
B(
|
|
268
|
+
o,
|
|
248
269
|
0,
|
|
249
270
|
u,
|
|
250
271
|
"Assert",
|
|
251
272
|
r
|
|
252
|
-
),
|
|
253
|
-
s,
|
|
254
|
-
1,
|
|
273
|
+
), B(
|
|
255
274
|
o,
|
|
275
|
+
1,
|
|
276
|
+
s,
|
|
256
277
|
"ChallengeAssertX",
|
|
257
278
|
r
|
|
258
|
-
),
|
|
259
|
-
|
|
279
|
+
), B(
|
|
280
|
+
o,
|
|
260
281
|
2,
|
|
261
282
|
l,
|
|
262
283
|
"ChallengeAssertY",
|
|
@@ -264,11 +285,11 @@ async function we(e) {
|
|
|
264
285
|
);
|
|
265
286
|
const d = [
|
|
266
287
|
u.outs[0],
|
|
267
|
-
|
|
288
|
+
s.outs[0],
|
|
268
289
|
l.outs[0]
|
|
269
|
-
].map((
|
|
270
|
-
script_pubkey: N(new Uint8Array(
|
|
271
|
-
value:
|
|
290
|
+
].map((h) => ({
|
|
291
|
+
script_pubkey: N(new Uint8Array(h.script)),
|
|
292
|
+
value: h.value
|
|
272
293
|
}));
|
|
273
294
|
return se({
|
|
274
295
|
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
@@ -284,14 +305,14 @@ async function we(e) {
|
|
|
284
305
|
}
|
|
285
306
|
});
|
|
286
307
|
}
|
|
287
|
-
function
|
|
288
|
-
const n =
|
|
308
|
+
function ke(e, t, r) {
|
|
309
|
+
const n = V(
|
|
289
310
|
e[0],
|
|
290
311
|
r
|
|
291
312
|
), i = {};
|
|
292
313
|
for (const u of t)
|
|
293
314
|
i[u.challengerPubkey] = {
|
|
294
|
-
nopayout_signature:
|
|
315
|
+
nopayout_signature: V(
|
|
295
316
|
e[u.noPayoutIdx],
|
|
296
317
|
r
|
|
297
318
|
)
|
|
@@ -311,45 +332,45 @@ async function Te(e, t, r) {
|
|
|
311
332
|
n.push(await e.signPsbt(t[i], r == null ? void 0 : r[i]));
|
|
312
333
|
return n;
|
|
313
334
|
}
|
|
314
|
-
async function
|
|
335
|
+
async function Ee(e) {
|
|
315
336
|
const { depositorGraph: t, btcWallet: r, signingContext: n } = e, i = await r.getPublicKeyHex(), { depositorPubkey: u } = j(
|
|
316
337
|
i,
|
|
317
338
|
c(n.depositorBtcPubkey)
|
|
318
|
-
), { psbtHexes: a, signOptions:
|
|
339
|
+
), { psbtHexes: a, signOptions: o, challengerEntries: s } = await ve(
|
|
319
340
|
t,
|
|
320
341
|
i,
|
|
321
342
|
n
|
|
322
343
|
), l = await Te(
|
|
323
344
|
r,
|
|
324
345
|
a,
|
|
325
|
-
|
|
346
|
+
o
|
|
326
347
|
);
|
|
327
348
|
if (l.length !== a.length)
|
|
328
349
|
throw new Error(
|
|
329
350
|
`Wallet returned ${l.length} signed PSBTs, expected ${a.length}`
|
|
330
351
|
);
|
|
331
|
-
return
|
|
352
|
+
return ke(
|
|
332
353
|
l,
|
|
333
|
-
|
|
354
|
+
s,
|
|
334
355
|
u
|
|
335
356
|
);
|
|
336
357
|
}
|
|
337
|
-
const
|
|
358
|
+
const _e = 1200 * 1e3, D = /* @__PURE__ */ new Set([
|
|
338
359
|
x.PENDING_ACKS,
|
|
339
360
|
x.PENDING_ACTIVATION,
|
|
340
361
|
x.ACTIVATED
|
|
341
|
-
]),
|
|
362
|
+
]), Se = /* @__PURE__ */ new Set([
|
|
342
363
|
x.PENDING_DEPOSITOR_SIGNATURES,
|
|
343
364
|
...D
|
|
344
365
|
]);
|
|
345
|
-
function
|
|
366
|
+
function Ce(e) {
|
|
346
367
|
return e.map((t) => ({
|
|
347
|
-
claimerPubkeyXOnly:
|
|
368
|
+
claimerPubkeyXOnly: k(t.claimer_pubkey),
|
|
348
369
|
payoutTxHex: t.payout_tx.tx_hex,
|
|
349
370
|
assertTxHex: t.assert_tx.tx_hex
|
|
350
371
|
}));
|
|
351
372
|
}
|
|
352
|
-
function
|
|
373
|
+
function Be(e) {
|
|
353
374
|
const { output: t } = re.payments.p2tr({
|
|
354
375
|
internalPubkey: oe.from(e, "hex")
|
|
355
376
|
});
|
|
@@ -357,7 +378,7 @@ function Se(e) {
|
|
|
357
378
|
throw new Error("Failed to derive BIP-86 P2TR scriptPubKey");
|
|
358
379
|
return t.toString("hex");
|
|
359
380
|
}
|
|
360
|
-
function
|
|
381
|
+
function Ae(e, t) {
|
|
361
382
|
const r = c(e).toLowerCase(), n = c(
|
|
362
383
|
t.vaultProviderBtcPubkey
|
|
363
384
|
).toLowerCase(), i = c(
|
|
@@ -366,12 +387,12 @@ function Ce(e, t) {
|
|
|
366
387
|
if (r === n || r === i)
|
|
367
388
|
return t.registeredPayoutScriptPubKey;
|
|
368
389
|
if (!t.vaultKeeperBtcPubkeys.some(
|
|
369
|
-
(
|
|
390
|
+
(o) => c(o).toLowerCase() === r
|
|
370
391
|
))
|
|
371
392
|
throw new Error(
|
|
372
393
|
`Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
|
|
373
394
|
);
|
|
374
|
-
return `0x${
|
|
395
|
+
return `0x${Be(r)}`;
|
|
375
396
|
}
|
|
376
397
|
function K(e, t) {
|
|
377
398
|
return {
|
|
@@ -383,13 +404,13 @@ function K(e, t) {
|
|
|
383
404
|
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
384
405
|
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
385
406
|
timelockPegin: t.timelockPegin,
|
|
386
|
-
registeredPayoutScriptPubKey:
|
|
407
|
+
registeredPayoutScriptPubKey: Ae(
|
|
387
408
|
e.claimerPubkeyXOnly,
|
|
388
409
|
t
|
|
389
410
|
)
|
|
390
411
|
};
|
|
391
412
|
}
|
|
392
|
-
async function
|
|
413
|
+
async function Re(e, t, r, n) {
|
|
393
414
|
const i = new J({
|
|
394
415
|
network: t.network,
|
|
395
416
|
btcWallet: e
|
|
@@ -402,22 +423,22 @@ async function Ae(e, t, r, n) {
|
|
|
402
423
|
)).map((l) => l.payoutSignature);
|
|
403
424
|
else {
|
|
404
425
|
a = [];
|
|
405
|
-
for (let
|
|
406
|
-
n == null || n(
|
|
426
|
+
for (let s = 0; s < r.length; s++) {
|
|
427
|
+
n == null || n(s, u);
|
|
407
428
|
const l = await i.signPayoutTransaction(
|
|
408
|
-
K(r[
|
|
429
|
+
K(r[s], t)
|
|
409
430
|
);
|
|
410
431
|
a.push(l.signature);
|
|
411
432
|
}
|
|
412
433
|
}
|
|
413
|
-
const
|
|
414
|
-
for (let
|
|
415
|
-
|
|
416
|
-
payout_signature: a[
|
|
434
|
+
const o = {};
|
|
435
|
+
for (let s = 0; s < r.length; s++)
|
|
436
|
+
o[r[s].claimerPubkeyXOnly] = {
|
|
437
|
+
payout_signature: a[s]
|
|
417
438
|
};
|
|
418
|
-
return n == null || n(u, u),
|
|
439
|
+
return n == null || n(u, u), o;
|
|
419
440
|
}
|
|
420
|
-
async function
|
|
441
|
+
async function at(e) {
|
|
421
442
|
const {
|
|
422
443
|
statusReader: t,
|
|
423
444
|
presignClient: r,
|
|
@@ -425,38 +446,38 @@ async function ot(e) {
|
|
|
425
446
|
peginTxid: i,
|
|
426
447
|
depositorPk: u,
|
|
427
448
|
signingContext: a,
|
|
428
|
-
timeoutMs:
|
|
429
|
-
signal:
|
|
449
|
+
timeoutMs: o = _e,
|
|
450
|
+
signal: s,
|
|
430
451
|
onProgress: l
|
|
431
452
|
} = e, d = await L({
|
|
432
453
|
statusReader: t,
|
|
433
454
|
peginTxid: i,
|
|
434
|
-
targetStatuses:
|
|
435
|
-
timeoutMs:
|
|
436
|
-
signal:
|
|
455
|
+
targetStatuses: Se,
|
|
456
|
+
timeoutMs: o,
|
|
457
|
+
signal: s
|
|
437
458
|
});
|
|
438
459
|
if (D.has(d))
|
|
439
460
|
return;
|
|
440
|
-
|
|
441
|
-
const
|
|
461
|
+
s == null || s.throwIfAborted();
|
|
462
|
+
const h = await r.requestDepositorPresignTransactions(
|
|
442
463
|
{
|
|
443
464
|
pegin_txid: i,
|
|
444
465
|
depositor_pk: u
|
|
445
466
|
},
|
|
446
|
-
|
|
467
|
+
s
|
|
447
468
|
);
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
(
|
|
451
|
-
), b =
|
|
469
|
+
s == null || s.throwIfAborted();
|
|
470
|
+
const y = k(u), P = h.txs.filter(
|
|
471
|
+
(v) => k(v.claimer_pubkey) !== y
|
|
472
|
+
), b = Ce(P), f = await Re(
|
|
452
473
|
n,
|
|
453
474
|
a,
|
|
454
475
|
b,
|
|
455
476
|
l
|
|
456
477
|
);
|
|
457
|
-
|
|
458
|
-
const g = await
|
|
459
|
-
depositorGraph:
|
|
478
|
+
s == null || s.throwIfAborted();
|
|
479
|
+
const g = await Ee({
|
|
480
|
+
depositorGraph: h.depositor_graph,
|
|
460
481
|
btcWallet: n,
|
|
461
482
|
signingContext: {
|
|
462
483
|
peginTxHex: a.peginTxHex,
|
|
@@ -472,22 +493,22 @@ async function ot(e) {
|
|
|
472
493
|
registeredPayoutScriptPubKey: a.registeredPayoutScriptPubKey
|
|
473
494
|
}
|
|
474
495
|
});
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
496
|
+
s == null || s.throwIfAborted();
|
|
497
|
+
const w = { ...f };
|
|
498
|
+
w[c(u)] = g.payout_signatures, await r.submitDepositorPresignatures(
|
|
478
499
|
{
|
|
479
500
|
pegin_txid: i,
|
|
480
501
|
depositor_pk: u,
|
|
481
|
-
signatures:
|
|
502
|
+
signatures: w,
|
|
482
503
|
depositor_claimer_presignatures: g
|
|
483
504
|
},
|
|
484
|
-
|
|
505
|
+
s
|
|
485
506
|
);
|
|
486
507
|
}
|
|
487
|
-
function
|
|
508
|
+
function $e(e) {
|
|
488
509
|
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
489
510
|
}
|
|
490
|
-
function
|
|
511
|
+
function st(e) {
|
|
491
512
|
const {
|
|
492
513
|
amountSats: t,
|
|
493
514
|
minDeposit: r,
|
|
@@ -498,7 +519,7 @@ function at(e) {
|
|
|
498
519
|
} = e;
|
|
499
520
|
return !(t <= 0n || t < r || n && n > 0n && t > n || u == null || a == null || t + u + a > i);
|
|
500
521
|
}
|
|
501
|
-
function
|
|
522
|
+
function it(e, t, r) {
|
|
502
523
|
return e <= 0n ? {
|
|
503
524
|
valid: !1,
|
|
504
525
|
error: "Deposit amount must be greater than zero"
|
|
@@ -510,7 +531,7 @@ function st(e, t, r) {
|
|
|
510
531
|
error: `Maximum deposit is ${m(r)} BTC`
|
|
511
532
|
} : { valid: !0 };
|
|
512
533
|
}
|
|
513
|
-
function
|
|
534
|
+
function ut(e) {
|
|
514
535
|
const { amount: t, effectiveRemaining: r } = e;
|
|
515
536
|
return r === null ? { valid: !0 } : r === 0n ? {
|
|
516
537
|
valid: !1,
|
|
@@ -520,7 +541,7 @@ function it(e) {
|
|
|
520
541
|
error: `Vault size exceeds remaining capacity (${m(r)} BTC)`
|
|
521
542
|
} : { valid: !0 };
|
|
522
543
|
}
|
|
523
|
-
function
|
|
544
|
+
function lt(e, t) {
|
|
524
545
|
if (!e || e.length === 0)
|
|
525
546
|
return {
|
|
526
547
|
valid: !1,
|
|
@@ -562,30 +583,30 @@ function Ve(e, t, r) {
|
|
|
562
583
|
}
|
|
563
584
|
return { valid: !0 };
|
|
564
585
|
}
|
|
565
|
-
function
|
|
586
|
+
function Ie(e) {
|
|
566
587
|
const t = c(e);
|
|
567
|
-
return
|
|
588
|
+
return $e(t) ? { valid: !0 } : {
|
|
568
589
|
valid: !1,
|
|
569
590
|
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
570
591
|
};
|
|
571
592
|
}
|
|
572
|
-
function
|
|
593
|
+
function Ke(e) {
|
|
573
594
|
if (!e || e.length === 0)
|
|
574
595
|
throw new Error(
|
|
575
596
|
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
576
597
|
);
|
|
577
598
|
}
|
|
578
|
-
function
|
|
599
|
+
function Oe(e) {
|
|
579
600
|
if (!e || e.length === 0)
|
|
580
601
|
throw new Error(
|
|
581
602
|
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
582
603
|
);
|
|
583
604
|
}
|
|
584
|
-
function
|
|
605
|
+
function Ne(e) {
|
|
585
606
|
if (e.length === 0)
|
|
586
607
|
throw new Error("No spendable UTXOs available");
|
|
587
608
|
}
|
|
588
|
-
function
|
|
609
|
+
function ct(e) {
|
|
589
610
|
const {
|
|
590
611
|
vaultAmounts: t,
|
|
591
612
|
confirmedUTXOs: r,
|
|
@@ -593,20 +614,20 @@ function lt(e) {
|
|
|
593
614
|
vaultKeeperBtcPubkeys: i,
|
|
594
615
|
universalChallengerBtcPubkeys: u,
|
|
595
616
|
minDeposit: a,
|
|
596
|
-
maxDeposit:
|
|
597
|
-
} = e,
|
|
617
|
+
maxDeposit: o
|
|
618
|
+
} = e, s = Ve(
|
|
598
619
|
t,
|
|
599
620
|
a,
|
|
600
|
-
|
|
621
|
+
o
|
|
601
622
|
);
|
|
602
|
-
if (!
|
|
603
|
-
throw new Error(
|
|
604
|
-
const l =
|
|
623
|
+
if (!s.valid)
|
|
624
|
+
throw new Error(s.error);
|
|
625
|
+
const l = Ie(n);
|
|
605
626
|
if (!l.valid)
|
|
606
627
|
throw new Error(l.error);
|
|
607
|
-
|
|
628
|
+
Ke(i), Oe(u), Ne(r);
|
|
608
629
|
}
|
|
609
|
-
async function
|
|
630
|
+
async function dt(e) {
|
|
610
631
|
const {
|
|
611
632
|
vaultRegistryReader: t,
|
|
612
633
|
vaultKeeperReader: r,
|
|
@@ -614,49 +635,49 @@ async function ct(e) {
|
|
|
614
635
|
vaultProviderEthAddress: i,
|
|
615
636
|
applicationEntryPoint: u,
|
|
616
637
|
expectedVaultProviderBtcPubkey: a,
|
|
617
|
-
expectedVaultKeeperBtcPubkeys:
|
|
618
|
-
expectedUniversalChallengerBtcPubkeys:
|
|
638
|
+
expectedVaultKeeperBtcPubkeys: o,
|
|
639
|
+
expectedUniversalChallengerBtcPubkeys: s
|
|
619
640
|
} = e, [
|
|
620
641
|
l,
|
|
621
642
|
d,
|
|
622
|
-
|
|
643
|
+
h
|
|
623
644
|
] = await Promise.all([
|
|
624
645
|
t.getVaultProviderBtcPubKey(i),
|
|
625
646
|
r.getCurrentVaultKeepersVersion(u),
|
|
626
647
|
n.getLatestUniversalChallengersVersion()
|
|
627
|
-
]), [
|
|
648
|
+
]), [y, P] = await Promise.all([
|
|
628
649
|
r.getVaultKeepersByVersion(
|
|
629
650
|
u,
|
|
630
651
|
d
|
|
631
652
|
),
|
|
632
653
|
n.getUniversalChallengersByVersion(
|
|
633
|
-
|
|
654
|
+
h
|
|
634
655
|
)
|
|
635
|
-
]), b = (
|
|
656
|
+
]), b = (p) => k(p).toLowerCase(), f = (p) => p.map(b).sort();
|
|
636
657
|
if (b(a) !== l)
|
|
637
658
|
throw new Error(
|
|
638
659
|
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${i}. Refresh and try again.`
|
|
639
660
|
);
|
|
640
|
-
const
|
|
641
|
-
|
|
661
|
+
const w = f(o), v = f(
|
|
662
|
+
y.map((p) => p.btcPubKey)
|
|
642
663
|
);
|
|
643
|
-
if (
|
|
664
|
+
if (w.length !== v.length || w.some((p, _) => p !== v[_]))
|
|
644
665
|
throw new Error(
|
|
645
666
|
`Vault keeper BTC pubkeys (v${d}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
646
667
|
);
|
|
647
|
-
const
|
|
648
|
-
|
|
668
|
+
const $ = f(s), E = f(
|
|
669
|
+
P.map((p) => p.btcPubKey)
|
|
649
670
|
);
|
|
650
|
-
if (
|
|
671
|
+
if ($.length !== E.length || $.some((p, _) => p !== E[_]))
|
|
651
672
|
throw new Error(
|
|
652
|
-
`Universal challenger BTC pubkeys (v${
|
|
673
|
+
`Universal challenger BTC pubkeys (v${h}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
653
674
|
);
|
|
654
675
|
return {
|
|
655
676
|
vaultProviderBtcPubkeyXOnly: l,
|
|
656
|
-
vaultKeeperBtcPubkeysSorted:
|
|
677
|
+
vaultKeeperBtcPubkeysSorted: v,
|
|
657
678
|
universalChallengerBtcPubkeysSorted: E,
|
|
658
679
|
expectedAppVaultKeepersVersion: d,
|
|
659
|
-
expectedUniversalChallengersVersion:
|
|
680
|
+
expectedUniversalChallengersVersion: h
|
|
660
681
|
};
|
|
661
682
|
}
|
|
662
683
|
class M extends Error {
|
|
@@ -664,7 +685,7 @@ class M extends Error {
|
|
|
664
685
|
super(t), this.name = "RegisteredVaultVersionMismatchError";
|
|
665
686
|
}
|
|
666
687
|
}
|
|
667
|
-
function
|
|
688
|
+
function ht(e) {
|
|
668
689
|
return e instanceof M || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
669
690
|
}
|
|
670
691
|
async function pt(e) {
|
|
@@ -674,58 +695,58 @@ async function pt(e) {
|
|
|
674
695
|
expectedOffchainParamsVersion: n,
|
|
675
696
|
expectedAppVaultKeepersVersion: i,
|
|
676
697
|
expectedUniversalChallengersVersion: u
|
|
677
|
-
} = e, a = await t.getProtocolInfoBatch(r),
|
|
678
|
-
if (a.forEach((
|
|
698
|
+
} = e, a = await t.getProtocolInfoBatch(r), o = [];
|
|
699
|
+
if (a.forEach((s, l) => {
|
|
679
700
|
const d = r[l];
|
|
680
|
-
|
|
681
|
-
`vault ${d}: offchainParams expected v${n}, got v${
|
|
682
|
-
),
|
|
683
|
-
`vault ${d}: appVaultKeepers expected v${i}, got v${
|
|
684
|
-
),
|
|
685
|
-
`vault ${d}: universalChallengers expected v${u}, got v${
|
|
701
|
+
s.offchainParamsVersion !== n && o.push(
|
|
702
|
+
`vault ${d}: offchainParams expected v${n}, got v${s.offchainParamsVersion}`
|
|
703
|
+
), s.appVaultKeepersVersion !== i && o.push(
|
|
704
|
+
`vault ${d}: appVaultKeepers expected v${i}, got v${s.appVaultKeepersVersion}`
|
|
705
|
+
), s.universalChallengersVersion !== u && o.push(
|
|
706
|
+
`vault ${d}: universalChallengers expected v${u}, got v${s.universalChallengersVersion}`
|
|
686
707
|
);
|
|
687
|
-
}),
|
|
708
|
+
}), o.length > 0)
|
|
688
709
|
throw new M(
|
|
689
|
-
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${
|
|
710
|
+
`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.`
|
|
690
711
|
);
|
|
691
712
|
}
|
|
692
713
|
var U = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.CHALLENGE_ASSERT_OBSERVED = "ChallengeAssertObserved", e.WRONGLY_CHALLENGED_BROADCAST = "WronglyChallengedBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.FAILED = "Failed", e))(U || {});
|
|
693
|
-
const
|
|
714
|
+
const He = /* @__PURE__ */ new Set([
|
|
694
715
|
"PayoutBroadcast",
|
|
695
716
|
"Failed"
|
|
696
717
|
/* FAILED */
|
|
697
718
|
]);
|
|
698
|
-
function
|
|
719
|
+
function ft(e) {
|
|
699
720
|
return Object.values(U).includes(
|
|
700
721
|
e
|
|
701
722
|
);
|
|
702
723
|
}
|
|
703
|
-
function
|
|
704
|
-
return !!e &&
|
|
724
|
+
function gt(e) {
|
|
725
|
+
return !!e && He.has(e);
|
|
705
726
|
}
|
|
706
|
-
class
|
|
727
|
+
class Le extends Error {
|
|
707
728
|
constructor(r, n) {
|
|
708
729
|
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
709
|
-
|
|
710
|
-
|
|
730
|
+
S(this, "vaultId");
|
|
731
|
+
S(this, "cause");
|
|
711
732
|
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
|
|
712
733
|
}
|
|
713
734
|
}
|
|
714
|
-
const
|
|
715
|
-
function
|
|
735
|
+
const De = /^0x[0-9a-fA-F]{64}$/, Me = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, F = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, X = 160;
|
|
736
|
+
function yt(e) {
|
|
716
737
|
if (!Number.isFinite(e) || e <= 0)
|
|
717
738
|
throw new Error(
|
|
718
739
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
719
740
|
);
|
|
720
741
|
return BigInt(Math.ceil(e * X));
|
|
721
742
|
}
|
|
722
|
-
const
|
|
743
|
+
const Ue = 1, O = 65535, Fe = /non-BIP68-final/i;
|
|
723
744
|
function z(e, t) {
|
|
724
745
|
if (e.length !== 66)
|
|
725
746
|
throw new Error(
|
|
726
747
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
727
748
|
);
|
|
728
|
-
if (!
|
|
749
|
+
if (!De.test(e))
|
|
729
750
|
throw new Error(
|
|
730
751
|
`${t} must contain only hex characters after the 0x prefix`
|
|
731
752
|
);
|
|
@@ -734,7 +755,7 @@ function A(e, t) {
|
|
|
734
755
|
if (!Number.isInteger(e) || e < 0)
|
|
735
756
|
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
736
757
|
}
|
|
737
|
-
function
|
|
758
|
+
function Xe(e) {
|
|
738
759
|
if (z(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > O)
|
|
739
760
|
throw new Error(
|
|
740
761
|
`htlcVout must be an integer 0-${O}, got ${e.htlcVout}`
|
|
@@ -744,7 +765,7 @@ function Fe(e) {
|
|
|
744
765
|
"universalChallengersVersion"
|
|
745
766
|
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
746
767
|
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
747
|
-
if (!
|
|
768
|
+
if (!Me.test(e.unsignedPrePeginTxHex))
|
|
748
769
|
throw new Error(
|
|
749
770
|
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
750
771
|
);
|
|
@@ -755,7 +776,7 @@ function Fe(e) {
|
|
|
755
776
|
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
756
777
|
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
757
778
|
}
|
|
758
|
-
function
|
|
779
|
+
function ze(e) {
|
|
759
780
|
if (!e.vaultProviderPubkey || !F.test(e.vaultProviderPubkey))
|
|
760
781
|
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
761
782
|
if (e.vaultKeeperPubkeys.length === 0)
|
|
@@ -777,7 +798,7 @@ function Xe(e) {
|
|
|
777
798
|
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
778
799
|
);
|
|
779
800
|
}
|
|
780
|
-
function
|
|
801
|
+
function Ge(e) {
|
|
781
802
|
const t = ne.fromHex(e);
|
|
782
803
|
try {
|
|
783
804
|
t.finalizeAllInputs();
|
|
@@ -796,77 +817,77 @@ async function Pt(e) {
|
|
|
796
817
|
feeRate: i,
|
|
797
818
|
signPsbt: u,
|
|
798
819
|
broadcastTx: a,
|
|
799
|
-
signal:
|
|
820
|
+
signal: o
|
|
800
821
|
} = e;
|
|
801
|
-
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
const l = await n(
|
|
805
|
-
if (
|
|
822
|
+
o == null || o.throwIfAborted(), z(t, "vaultId");
|
|
823
|
+
const s = await r();
|
|
824
|
+
Xe(s), o == null || o.throwIfAborted();
|
|
825
|
+
const l = await n(s);
|
|
826
|
+
if (ze(l), o == null || o.throwIfAborted(), !Number.isFinite(i) || i <= 0)
|
|
806
827
|
throw new Error(`feeRate must be a positive number, got ${i}`);
|
|
807
828
|
const d = BigInt(Math.ceil(i * X));
|
|
808
|
-
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
), { psbtHex:
|
|
829
|
+
o == null || o.throwIfAborted();
|
|
830
|
+
const h = k(
|
|
831
|
+
s.depositorBtcPubkey
|
|
832
|
+
), { psbtHex: y } = await ie({
|
|
812
833
|
prePeginParams: {
|
|
813
|
-
depositorPubkey:
|
|
834
|
+
depositorPubkey: h,
|
|
814
835
|
vaultProviderPubkey: c(l.vaultProviderPubkey),
|
|
815
836
|
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
|
|
816
837
|
universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
|
|
817
|
-
hashlocks: [c(
|
|
838
|
+
hashlocks: [c(s.hashlock)],
|
|
818
839
|
timelockRefund: l.timelockRefund,
|
|
819
|
-
pegInAmounts: [
|
|
840
|
+
pegInAmounts: [s.amount],
|
|
820
841
|
feeRate: l.feeRate,
|
|
821
842
|
numLocalChallengers: l.numLocalChallengers,
|
|
822
843
|
councilQuorum: l.councilQuorum,
|
|
823
844
|
councilSize: l.councilSize,
|
|
824
845
|
network: l.network
|
|
825
846
|
},
|
|
826
|
-
fundedPrePeginTxHex: c(
|
|
827
|
-
htlcVout:
|
|
847
|
+
fundedPrePeginTxHex: c(s.unsignedPrePeginTxHex),
|
|
848
|
+
htlcVout: s.htlcVout,
|
|
828
849
|
refundFee: d,
|
|
829
850
|
// buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
|
|
830
851
|
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
831
852
|
// value would derive the wrong refund script leaf and yield an
|
|
832
853
|
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
833
|
-
hashlock: c(
|
|
854
|
+
hashlock: c(s.hashlock)
|
|
834
855
|
});
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
), b = await u(
|
|
840
|
-
|
|
856
|
+
o == null || o.throwIfAborted();
|
|
857
|
+
const P = R(
|
|
858
|
+
s.depositorBtcPubkey,
|
|
859
|
+
Ue
|
|
860
|
+
), b = await u(y, P), f = Ge(b);
|
|
861
|
+
o == null || o.throwIfAborted();
|
|
841
862
|
try {
|
|
842
863
|
return await a(f);
|
|
843
864
|
} catch (g) {
|
|
844
|
-
throw g instanceof Error &&
|
|
865
|
+
throw g instanceof Error && Fe.test(g.message) ? new Le(t, g) : g;
|
|
845
866
|
}
|
|
846
867
|
}
|
|
847
868
|
export {
|
|
848
|
-
|
|
869
|
+
Le as B,
|
|
849
870
|
U as C,
|
|
850
871
|
M as R,
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
872
|
+
nt as a,
|
|
873
|
+
Ee as b,
|
|
874
|
+
ut as c,
|
|
875
|
+
lt as d,
|
|
855
876
|
Ve as e,
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
877
|
+
Ie as f,
|
|
878
|
+
ct as g,
|
|
879
|
+
dt as h,
|
|
880
|
+
st as i,
|
|
881
|
+
ht as j,
|
|
861
882
|
pt as k,
|
|
862
|
-
|
|
863
|
-
|
|
883
|
+
ft as l,
|
|
884
|
+
gt as m,
|
|
864
885
|
Pt as n,
|
|
865
|
-
|
|
886
|
+
yt as o,
|
|
866
887
|
X as p,
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
888
|
+
at as r,
|
|
889
|
+
ot as s,
|
|
890
|
+
it as v,
|
|
870
891
|
L as w
|
|
871
892
|
};
|
|
872
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
893
|
+
//# sourceMappingURL=buildAndBroadcastRefund-C2VqXiOx.js.map
|