@babylonlabs-io/ts-sdk 0.51.1 → 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-D26nGR-e.js → PayoutManager-Ddo9_Ozc.js} +34 -32
- package/dist/PayoutManager-Ddo9_Ozc.js.map +1 -0
- package/dist/{PeginManager-COxRVrxa.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-Bmz9WJuN.js → buildAndBroadcastRefund-DjS9nf87.js} +221 -209
- 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 +193 -190
- 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-C1WCsqfd.js → noPayout-tZFoNun3.js} +12 -10
- package/dist/noPayout-tZFoNun3.js.map +1 -0
- package/dist/{peginInput-BPRB9tUi.js → peginInput-BKD_b3gq.js} +8 -7
- package/dist/peginInput-BKD_b3gq.js.map +1 -0
- package/dist/peginInput-CAiiDZeO.cjs +2 -0
- 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 +191 -188
- 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 +2 -1
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +39 -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/core/vault-secrets/__tests__/expand.test.d.ts +5 -2
- package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +191 -188
- package/dist/tbv/index.js.map +1 -1
- package/dist/{verifyScriptPathSchnorrSignature-CeZp6tMw.js → verifyScriptPathSchnorrSignature-DpWZx5J0.js} +67 -61
- 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 +1 -1
- 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-BZVEyi10.cjs +0 -2
- package/dist/PayoutManager-BZVEyi10.cjs.map +0 -1
- package/dist/PayoutManager-D26nGR-e.js.map +0 -1
- package/dist/PeginManager-BvxfSwsr.cjs +0 -2
- package/dist/PeginManager-BvxfSwsr.cjs.map +0 -1
- package/dist/PeginManager-COxRVrxa.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Bmz9WJuN.js.map +0 -1
- package/dist/buildAndBroadcastRefund-ob1n2iB3.cjs +0 -2
- package/dist/buildAndBroadcastRefund-ob1n2iB3.cjs.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-C1WCsqfd.js.map +0 -1
- package/dist/noPayout-lyIRiUyG.cjs +0 -2
- package/dist/noPayout-lyIRiUyG.cjs.map +0 -1
- package/dist/peginInput-BPRB9tUi.js.map +0 -1
- package/dist/peginInput-DH6X4ITS.cjs +0 -2
- package/dist/peginInput-DH6X4ITS.cjs.map +0 -1
- package/dist/primeVpAuth-DxMuWQCi.js.map +0 -1
- package/dist/primeVpAuth-yTddDmGy.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CeZp6tMw.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-Cl7tu77P.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-Cl7tu77P.cjs.map +0 -1
|
@@ -3,65 +3,66 @@ var Z = (e, r, t) => r in e ? J(e, r, { enumerable: !0, configurable: !0, writab
|
|
|
3
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 he, a as de, b as pe } from "./noPayout-
|
|
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
|
-
|
|
13
|
-
|
|
12
|
+
import { a as ge } from "./constants-BhclpREj.js";
|
|
13
|
+
const fe = /^0x[0-9a-fA-F]{64}$/, me = /^0x[0-9a-fA-F]{40}$/, Pe = /^0x([0-9a-fA-F]{2})*$/;
|
|
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}`
|
|
17
18
|
);
|
|
18
|
-
if (!
|
|
19
|
+
if (!fe.test(e))
|
|
19
20
|
throw new Error(
|
|
20
21
|
`${r} must contain only hex characters after the 0x prefix`
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
24
|
+
function be(e, r) {
|
|
25
|
+
if (!me.test(e))
|
|
25
26
|
throw new Error(
|
|
26
27
|
`${r} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
if (!
|
|
30
|
+
function ye(e, r) {
|
|
31
|
+
if (!Pe.test(e))
|
|
31
32
|
throw new Error(
|
|
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(),
|
|
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
|
|
51
|
+
return ye(s, "activationMetadata"), l({
|
|
51
52
|
address: r,
|
|
52
53
|
abi: ee,
|
|
53
54
|
functionName: "activateVaultWithSecret",
|
|
54
55
|
args: [t, i, s]
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
+
const we = 1e4;
|
|
58
59
|
async function G(e) {
|
|
59
60
|
const {
|
|
60
61
|
statusReader: r,
|
|
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,50 +83,50 @@ 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
|
}
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
+
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
|
-
timeoutMs: a =
|
|
121
|
+
wotsPublicKeys: l,
|
|
122
|
+
timeoutMs: a = xe,
|
|
122
123
|
signal: i
|
|
123
124
|
} = e;
|
|
124
125
|
i == null || i.throwIfAborted();
|
|
125
126
|
const o = await G({
|
|
126
127
|
statusReader: r,
|
|
127
128
|
peginTxid: n,
|
|
128
|
-
targetStatuses:
|
|
129
|
+
targetStatuses: ve,
|
|
129
130
|
timeoutMs: a,
|
|
130
131
|
signal: i
|
|
131
132
|
});
|
|
@@ -133,14 +134,14 @@ async function it(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
|
-
const K = 1,
|
|
142
|
-
function
|
|
143
|
-
const t = p(r).toLowerCase(), s = e.map((
|
|
142
|
+
const K = 1, Ee = 1;
|
|
143
|
+
function Te(e, r) {
|
|
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)"
|
|
@@ -151,7 +152,7 @@ function Ee(e, r) {
|
|
|
151
152
|
);
|
|
152
153
|
return s;
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
+
function ke(e, r, t) {
|
|
155
156
|
const n = t.map(
|
|
156
157
|
(c) => p(c).toLowerCase()
|
|
157
158
|
), s = r.filter((c) => n.includes(c));
|
|
@@ -159,46 +160,47 @@ function Te(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
|
-
function
|
|
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
180
|
function R(e, r, t, n, s) {
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
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
|
-
const a = t.getId(), i =
|
|
186
|
+
const a = t.getId(), i = _e(e, r);
|
|
186
187
|
if (i !== a)
|
|
187
188
|
throw new Error(
|
|
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
|
);
|
|
196
|
-
|
|
197
|
+
ke(
|
|
197
198
|
e.challenger_presign_data,
|
|
198
199
|
a,
|
|
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,
|
|
@@ -210,7 +212,7 @@ async function _e(e, r, t) {
|
|
|
210
212
|
network: t.network,
|
|
211
213
|
claimerBtcPubkey: t.depositorBtcPubkey,
|
|
212
214
|
registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
|
|
213
|
-
commissionBps:
|
|
215
|
+
commissionBps: Ee
|
|
214
216
|
});
|
|
215
217
|
n.push(i.psbtHex), s.push(
|
|
216
218
|
O(
|
|
@@ -218,7 +220,7 @@ async function _e(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) {
|
|
@@ -227,7 +229,7 @@ async function _e(e, r, t) {
|
|
|
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,12 +237,12 @@ async function _e(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
247
|
async function Se(e) {
|
|
246
248
|
const {
|
|
@@ -248,7 +250,7 @@ async function Se(e) {
|
|
|
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(
|
|
@@ -256,11 +258,11 @@ async function Se(e) {
|
|
|
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)
|
|
@@ -270,7 +272,7 @@ async function Se(e) {
|
|
|
270
272
|
R(
|
|
271
273
|
i,
|
|
272
274
|
0,
|
|
273
|
-
|
|
275
|
+
l,
|
|
274
276
|
"Assert",
|
|
275
277
|
t
|
|
276
278
|
), R(
|
|
@@ -282,14 +284,14 @@ async function Se(e) {
|
|
|
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
|
|
@@ -299,6 +301,7 @@ async function Se(e) {
|
|
|
299
301
|
challengerPubkey: t,
|
|
300
302
|
prevouts: h,
|
|
301
303
|
connectorParams: {
|
|
304
|
+
txGraphVersion: a.vaultCoreVersion,
|
|
302
305
|
claimer: n,
|
|
303
306
|
localChallengers: s,
|
|
304
307
|
universalChallengers: a.universalChallengerBtcPubkeys,
|
|
@@ -308,8 +311,8 @@ async function Se(e) {
|
|
|
308
311
|
}
|
|
309
312
|
});
|
|
310
313
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
314
|
+
function Ae(e, r, t) {
|
|
315
|
+
I(e[0]);
|
|
313
316
|
const s = N(
|
|
314
317
|
e[0].returnedPsbtHex,
|
|
315
318
|
t
|
|
@@ -320,9 +323,9 @@ function Ce(e, r, t) {
|
|
|
320
323
|
signerXOnlyPubkeyHex: t,
|
|
321
324
|
inputIndex: 0
|
|
322
325
|
});
|
|
323
|
-
const
|
|
326
|
+
const l = {};
|
|
324
327
|
for (const a of r) {
|
|
325
|
-
|
|
328
|
+
I(e[a.noPayoutIdx]);
|
|
326
329
|
const i = N(
|
|
327
330
|
e[a.noPayoutIdx].returnedPsbtHex,
|
|
328
331
|
t
|
|
@@ -332,7 +335,7 @@ function Ce(e, r, t) {
|
|
|
332
335
|
signatureHex: i,
|
|
333
336
|
signerXOnlyPubkeyHex: t,
|
|
334
337
|
inputIndex: 0
|
|
335
|
-
}),
|
|
338
|
+
}), l[a.challengerPubkey] = {
|
|
336
339
|
nopayout_signature: i
|
|
337
340
|
};
|
|
338
341
|
}
|
|
@@ -340,10 +343,10 @@ function Ce(e, r, t) {
|
|
|
340
343
|
payout_signatures: {
|
|
341
344
|
payout_signature: s
|
|
342
345
|
},
|
|
343
|
-
per_challenger:
|
|
346
|
+
per_challenger: l
|
|
344
347
|
};
|
|
345
348
|
}
|
|
346
|
-
async function
|
|
349
|
+
async function $e(e, r, t) {
|
|
347
350
|
if (typeof e.signPsbts == "function")
|
|
348
351
|
return e.signPsbts(r, t);
|
|
349
352
|
const n = [];
|
|
@@ -351,39 +354,39 @@ async function Ae(e, r, t) {
|
|
|
351
354
|
n.push(await e.signPsbt(r[s], t == null ? void 0 : t[s]));
|
|
352
355
|
return n;
|
|
353
356
|
}
|
|
354
|
-
async function
|
|
355
|
-
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(
|
|
356
359
|
s,
|
|
357
360
|
p(n.depositorBtcPubkey)
|
|
358
|
-
), { psbtHexes: a, signOptions: i, challengerEntries: o } = await
|
|
361
|
+
), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Ce(
|
|
359
362
|
r,
|
|
360
363
|
s,
|
|
361
364
|
n
|
|
362
|
-
),
|
|
365
|
+
), u = await $e(
|
|
363
366
|
t,
|
|
364
367
|
a,
|
|
365
368
|
i
|
|
366
369
|
);
|
|
367
|
-
if (
|
|
370
|
+
if (u.length !== a.length)
|
|
368
371
|
throw new Error(
|
|
369
|
-
`Wallet returned ${
|
|
372
|
+
`Wallet returned ${u.length} signed PSBTs, expected ${a.length}`
|
|
370
373
|
);
|
|
371
374
|
const h = a.map((c, d) => ({
|
|
372
375
|
requestedPsbtHex: c,
|
|
373
|
-
returnedPsbtHex:
|
|
376
|
+
returnedPsbtHex: u[d]
|
|
374
377
|
}));
|
|
375
|
-
return
|
|
378
|
+
return Ae(
|
|
376
379
|
h,
|
|
377
380
|
o,
|
|
378
|
-
|
|
381
|
+
l
|
|
379
382
|
);
|
|
380
383
|
}
|
|
381
|
-
const
|
|
384
|
+
const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
|
|
382
385
|
w.PENDING_ACKS,
|
|
383
386
|
w.PENDING_ACTIVATION,
|
|
384
387
|
w.ACTIVATED_PENDING_BROADCAST,
|
|
385
388
|
w.ACTIVATED
|
|
386
|
-
]),
|
|
389
|
+
]), Be = /* @__PURE__ */ new Set([
|
|
387
390
|
w.PENDING_DEPOSITOR_SIGNATURES,
|
|
388
391
|
...q
|
|
389
392
|
]);
|
|
@@ -397,12 +400,12 @@ function Ie(e) {
|
|
|
397
400
|
function _(e) {
|
|
398
401
|
return A(e).toLowerCase();
|
|
399
402
|
}
|
|
400
|
-
function
|
|
401
|
-
const s = _(n),
|
|
403
|
+
function Ne(e, r, t, n) {
|
|
404
|
+
const s = _(n), l = [
|
|
402
405
|
_(r),
|
|
403
406
|
...t.map(_)
|
|
404
|
-
], a = new Set(
|
|
405
|
-
if (a.size !==
|
|
407
|
+
], a = new Set(l);
|
|
408
|
+
if (a.size !== l.length)
|
|
406
409
|
throw new Error(
|
|
407
410
|
"Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
|
|
408
411
|
);
|
|
@@ -417,7 +420,7 @@ function Ve(e, r, t, n) {
|
|
|
417
420
|
throw new Error(
|
|
418
421
|
"Presign response contains duplicate claimer entries"
|
|
419
422
|
);
|
|
420
|
-
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));
|
|
421
424
|
if (h.length > 0 || c.length > 0)
|
|
422
425
|
throw new Error(
|
|
423
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(", ")})` : "")
|
|
@@ -425,6 +428,7 @@ function Ve(e, r, t, n) {
|
|
|
425
428
|
}
|
|
426
429
|
function U(e, r) {
|
|
427
430
|
return {
|
|
431
|
+
vaultCoreVersion: r.vaultCoreVersion,
|
|
428
432
|
payoutTxHex: e.payoutTxHex,
|
|
429
433
|
peginTxHex: r.peginTxHex,
|
|
430
434
|
assertTxHex: e.assertTxHex,
|
|
@@ -438,25 +442,25 @@ function U(e, r) {
|
|
|
438
442
|
commissionBps: r.commissionBps
|
|
439
443
|
};
|
|
440
444
|
}
|
|
441
|
-
async function
|
|
445
|
+
async function He(e, r, t, n) {
|
|
442
446
|
const s = new oe({
|
|
443
447
|
network: r.network,
|
|
444
448
|
btcWallet: e
|
|
445
|
-
}),
|
|
446
|
-
n == null || n(0,
|
|
449
|
+
}), l = t.length;
|
|
450
|
+
n == null || n(0, l);
|
|
447
451
|
let a;
|
|
448
452
|
if (s.supportsBatchSigning())
|
|
449
453
|
a = (await s.signPayoutTransactionsBatch(
|
|
450
|
-
t.map((
|
|
451
|
-
)).map((
|
|
454
|
+
t.map((u) => U(u, r))
|
|
455
|
+
)).map((u) => u.payoutSignature);
|
|
452
456
|
else {
|
|
453
457
|
a = [];
|
|
454
458
|
for (let o = 0; o < t.length; o++) {
|
|
455
|
-
n == null || n(o,
|
|
456
|
-
const
|
|
459
|
+
n == null || n(o, l);
|
|
460
|
+
const u = await s.signPayoutTransaction(
|
|
457
461
|
U(t[o], r)
|
|
458
462
|
);
|
|
459
|
-
a.push(
|
|
463
|
+
a.push(u.signature);
|
|
460
464
|
}
|
|
461
465
|
}
|
|
462
466
|
const i = {};
|
|
@@ -464,23 +468,23 @@ async function Ne(e, r, t, n) {
|
|
|
464
468
|
i[t[o].claimerPubkeyXOnly] = {
|
|
465
469
|
payout_signature: a[o]
|
|
466
470
|
};
|
|
467
|
-
return n == null || n(
|
|
471
|
+
return n == null || n(l, l), i;
|
|
468
472
|
}
|
|
469
|
-
async function
|
|
473
|
+
async function ct(e) {
|
|
470
474
|
const {
|
|
471
475
|
statusReader: r,
|
|
472
476
|
presignClient: t,
|
|
473
477
|
btcWallet: n,
|
|
474
478
|
peginTxid: s,
|
|
475
|
-
depositorPk:
|
|
479
|
+
depositorPk: l,
|
|
476
480
|
signingContext: a,
|
|
477
|
-
timeoutMs: i =
|
|
481
|
+
timeoutMs: i = Re,
|
|
478
482
|
signal: o,
|
|
479
|
-
onProgress:
|
|
483
|
+
onProgress: u
|
|
480
484
|
} = e, h = await G({
|
|
481
485
|
statusReader: r,
|
|
482
486
|
peginTxid: s,
|
|
483
|
-
targetStatuses:
|
|
487
|
+
targetStatuses: Be,
|
|
484
488
|
timeoutMs: i,
|
|
485
489
|
signal: o
|
|
486
490
|
});
|
|
@@ -490,33 +494,34 @@ async function ut(e) {
|
|
|
490
494
|
const c = await t.requestDepositorPresignTransactions(
|
|
491
495
|
{
|
|
492
496
|
pegin_txid: s,
|
|
493
|
-
depositor_pk:
|
|
497
|
+
depositor_pk: l
|
|
494
498
|
},
|
|
495
499
|
o
|
|
496
500
|
);
|
|
497
501
|
o == null || o.throwIfAborted();
|
|
498
|
-
const d = _(
|
|
499
|
-
|
|
502
|
+
const d = _(l);
|
|
503
|
+
Ne(
|
|
500
504
|
c.txs,
|
|
501
505
|
a.vaultProviderBtcPubkey,
|
|
502
506
|
a.vaultKeeperBtcPubkeys,
|
|
503
|
-
|
|
507
|
+
l
|
|
504
508
|
);
|
|
505
509
|
const P = c.txs.filter(
|
|
506
510
|
(v) => _(v.claimer_pubkey) !== d
|
|
507
|
-
), m = Ie(P), y = await
|
|
511
|
+
), m = Ie(P), y = await He(
|
|
508
512
|
n,
|
|
509
513
|
a,
|
|
510
514
|
m,
|
|
511
|
-
|
|
515
|
+
u
|
|
512
516
|
);
|
|
513
517
|
o == null || o.throwIfAborted();
|
|
514
|
-
const x = await
|
|
518
|
+
const x = await Ve({
|
|
515
519
|
depositorGraph: c.depositor_graph,
|
|
516
520
|
btcWallet: n,
|
|
517
521
|
signingContext: {
|
|
522
|
+
vaultCoreVersion: a.vaultCoreVersion,
|
|
518
523
|
peginTxHex: a.peginTxHex,
|
|
519
|
-
depositorBtcPubkey:
|
|
524
|
+
depositorBtcPubkey: l,
|
|
520
525
|
vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
|
|
521
526
|
vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
|
|
522
527
|
universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
|
|
@@ -530,31 +535,31 @@ async function ut(e) {
|
|
|
530
535
|
});
|
|
531
536
|
o == null || o.throwIfAborted();
|
|
532
537
|
const b = { ...y };
|
|
533
|
-
b[p(
|
|
538
|
+
b[p(l)] = x.payout_signatures, await t.submitDepositorPresignatures(
|
|
534
539
|
{
|
|
535
540
|
pegin_txid: s,
|
|
536
|
-
depositor_pk:
|
|
541
|
+
depositor_pk: l,
|
|
537
542
|
signatures: b,
|
|
538
543
|
depositor_claimer_presignatures: x
|
|
539
544
|
},
|
|
540
545
|
o
|
|
541
546
|
);
|
|
542
547
|
}
|
|
543
|
-
function
|
|
548
|
+
function Oe(e) {
|
|
544
549
|
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
545
550
|
}
|
|
546
|
-
function
|
|
551
|
+
function ht(e) {
|
|
547
552
|
const {
|
|
548
553
|
amountSats: r,
|
|
549
554
|
minDeposit: t,
|
|
550
555
|
maxDeposit: n,
|
|
551
556
|
btcBalance: s,
|
|
552
|
-
estimatedFeeSats:
|
|
557
|
+
estimatedFeeSats: l,
|
|
553
558
|
depositorClaimValue: a
|
|
554
559
|
} = e;
|
|
555
|
-
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);
|
|
556
561
|
}
|
|
557
|
-
function
|
|
562
|
+
function dt(e, r, t) {
|
|
558
563
|
return e <= 0n ? {
|
|
559
564
|
valid: !1,
|
|
560
565
|
error: "Deposit amount must be greater than zero"
|
|
@@ -566,7 +571,7 @@ function ct(e, r, t) {
|
|
|
566
571
|
error: `Maximum deposit is ${E(t)} BTC`
|
|
567
572
|
} : { valid: !0 };
|
|
568
573
|
}
|
|
569
|
-
function
|
|
574
|
+
function pt(e) {
|
|
570
575
|
const { amount: r, effectiveRemaining: t } = e;
|
|
571
576
|
return t === null ? { valid: !0 } : t === 0n ? {
|
|
572
577
|
valid: !1,
|
|
@@ -576,7 +581,7 @@ function ht(e) {
|
|
|
576
581
|
error: `Vault size exceeds remaining capacity (${E(t)} BTC)`
|
|
577
582
|
} : { valid: !0 };
|
|
578
583
|
}
|
|
579
|
-
function
|
|
584
|
+
function gt(e, r) {
|
|
580
585
|
if (!e || e.length === 0)
|
|
581
586
|
return {
|
|
582
587
|
valid: !1,
|
|
@@ -592,7 +597,7 @@ function dt(e, r) {
|
|
|
592
597
|
error: "Invalid vault provider selected"
|
|
593
598
|
} : { valid: !0 };
|
|
594
599
|
}
|
|
595
|
-
function
|
|
600
|
+
function De(e, r, t) {
|
|
596
601
|
if (!e || e.length === 0)
|
|
597
602
|
return {
|
|
598
603
|
valid: !1,
|
|
@@ -618,97 +623,97 @@ function Oe(e, r, t) {
|
|
|
618
623
|
}
|
|
619
624
|
return { valid: !0 };
|
|
620
625
|
}
|
|
621
|
-
function
|
|
626
|
+
function Ke(e) {
|
|
622
627
|
const r = p(e);
|
|
623
|
-
return
|
|
628
|
+
return Oe(r) ? { valid: !0 } : {
|
|
624
629
|
valid: !1,
|
|
625
630
|
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
626
631
|
};
|
|
627
632
|
}
|
|
628
|
-
function
|
|
633
|
+
function Ue(e) {
|
|
629
634
|
if (!e || e.length === 0)
|
|
630
635
|
throw new Error(
|
|
631
636
|
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
632
637
|
);
|
|
633
638
|
}
|
|
634
|
-
function
|
|
639
|
+
function Fe(e) {
|
|
635
640
|
if (!e || e.length === 0)
|
|
636
641
|
throw new Error(
|
|
637
642
|
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
638
643
|
);
|
|
639
644
|
}
|
|
640
|
-
function
|
|
645
|
+
function Me(e) {
|
|
641
646
|
if (e.length === 0)
|
|
642
647
|
throw new Error("No spendable UTXOs available");
|
|
643
648
|
}
|
|
644
|
-
function
|
|
649
|
+
function ft(e) {
|
|
645
650
|
const {
|
|
646
651
|
vaultAmounts: r,
|
|
647
652
|
confirmedUTXOs: t,
|
|
648
653
|
vaultProviderBtcPubkey: n,
|
|
649
654
|
vaultKeeperBtcPubkeys: s,
|
|
650
|
-
universalChallengerBtcPubkeys:
|
|
655
|
+
universalChallengerBtcPubkeys: l,
|
|
651
656
|
minDeposit: a,
|
|
652
657
|
maxDeposit: i
|
|
653
|
-
} = e, o =
|
|
658
|
+
} = e, o = De(
|
|
654
659
|
r,
|
|
655
660
|
a,
|
|
656
661
|
i
|
|
657
662
|
);
|
|
658
663
|
if (!o.valid)
|
|
659
664
|
throw new Error(o.error);
|
|
660
|
-
const
|
|
661
|
-
if (!
|
|
662
|
-
throw new Error(
|
|
663
|
-
|
|
665
|
+
const u = Ke(n);
|
|
666
|
+
if (!u.valid)
|
|
667
|
+
throw new Error(u.error);
|
|
668
|
+
Ue(s), Fe(l), Me(t);
|
|
664
669
|
}
|
|
665
|
-
async function
|
|
670
|
+
async function mt(e) {
|
|
666
671
|
const {
|
|
667
672
|
vaultRegistryReader: r,
|
|
668
673
|
vaultKeeperReader: t,
|
|
669
674
|
universalChallengerReader: n,
|
|
670
675
|
vaultProviderEthAddress: s,
|
|
671
|
-
applicationEntryPoint:
|
|
676
|
+
applicationEntryPoint: l,
|
|
672
677
|
expectedVaultProviderBtcPubkey: a,
|
|
673
678
|
expectedVaultKeeperBtcPubkeys: i,
|
|
674
679
|
expectedUniversalChallengerBtcPubkeys: o
|
|
675
680
|
} = e, [
|
|
676
|
-
|
|
681
|
+
u,
|
|
677
682
|
h,
|
|
678
683
|
c
|
|
679
684
|
] = await Promise.all([
|
|
680
685
|
r.getVaultProviderBtcPubKey(s),
|
|
681
|
-
t.getCurrentVaultKeepersVersion(
|
|
686
|
+
t.getCurrentVaultKeepersVersion(l),
|
|
682
687
|
n.getLatestUniversalChallengersVersion()
|
|
683
688
|
]), [d, P] = await Promise.all([
|
|
684
689
|
t.getVaultKeepersByVersion(
|
|
685
|
-
|
|
690
|
+
l,
|
|
686
691
|
h
|
|
687
692
|
),
|
|
688
693
|
n.getUniversalChallengersByVersion(
|
|
689
694
|
c
|
|
690
695
|
)
|
|
691
696
|
]), m = (g) => A(g).toLowerCase(), y = (g) => g.map(m).sort();
|
|
692
|
-
if (m(a) !==
|
|
697
|
+
if (m(a) !== u)
|
|
693
698
|
throw new Error(
|
|
694
699
|
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
|
|
695
700
|
);
|
|
696
701
|
const b = y(i), v = y(
|
|
697
702
|
d.map((g) => g.btcPubKey)
|
|
698
703
|
);
|
|
699
|
-
if (b.length !== v.length || b.some((g,
|
|
704
|
+
if (b.length !== v.length || b.some((g, C) => g !== v[C]))
|
|
700
705
|
throw new Error(
|
|
701
706
|
`Vault keeper BTC pubkeys (v${h}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
702
707
|
);
|
|
703
708
|
const T = y(o), k = y(
|
|
704
709
|
P.map((g) => g.btcPubKey)
|
|
705
710
|
);
|
|
706
|
-
if (T.length !== k.length || T.some((g,
|
|
711
|
+
if (T.length !== k.length || T.some((g, C) => g !== k[C]))
|
|
707
712
|
throw new Error(
|
|
708
713
|
`Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
709
714
|
);
|
|
710
715
|
return {
|
|
711
|
-
vaultProviderBtcPubkeyXOnly:
|
|
716
|
+
vaultProviderBtcPubkeyXOnly: u,
|
|
712
717
|
vaultKeeperBtcPubkeysSorted: v,
|
|
713
718
|
universalChallengerBtcPubkeysSorted: k,
|
|
714
719
|
expectedAppVaultKeepersVersion: h,
|
|
@@ -720,46 +725,49 @@ class j extends Error {
|
|
|
720
725
|
super(r), this.name = "RegisteredVaultVersionMismatchError";
|
|
721
726
|
}
|
|
722
727
|
}
|
|
723
|
-
function
|
|
728
|
+
function Pt(e) {
|
|
724
729
|
return e instanceof j || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
725
730
|
}
|
|
726
|
-
async function
|
|
731
|
+
async function bt(e) {
|
|
727
732
|
const {
|
|
728
733
|
vaultRegistryReader: r,
|
|
729
734
|
vaultIds: t,
|
|
730
735
|
expectedOffchainParamsVersion: n,
|
|
731
736
|
expectedAppVaultKeepersVersion: s,
|
|
732
|
-
expectedUniversalChallengersVersion:
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
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)
|
|
744
752
|
throw new j(
|
|
745
|
-
`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.`
|
|
746
754
|
);
|
|
747
755
|
}
|
|
748
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 || {});
|
|
749
|
-
const
|
|
757
|
+
const Le = /* @__PURE__ */ new Set([
|
|
750
758
|
"PayoutBroadcast",
|
|
751
759
|
"PayoutBlocked"
|
|
752
760
|
/* PAYOUT_BLOCKED */
|
|
753
761
|
]);
|
|
754
|
-
function
|
|
762
|
+
function yt(e) {
|
|
755
763
|
return Object.values(Q).includes(
|
|
756
764
|
e
|
|
757
765
|
);
|
|
758
766
|
}
|
|
759
|
-
function
|
|
760
|
-
return !!e &&
|
|
767
|
+
function wt(e) {
|
|
768
|
+
return !!e && Le.has(e);
|
|
761
769
|
}
|
|
762
|
-
class
|
|
770
|
+
class Xe extends Error {
|
|
763
771
|
constructor(t, n) {
|
|
764
772
|
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
765
773
|
$(this, "vaultId");
|
|
@@ -767,30 +775,30 @@ class Le extends Error {
|
|
|
767
775
|
this.name = "BIP68NotMatureError", this.vaultId = t, this.cause = n;
|
|
768
776
|
}
|
|
769
777
|
}
|
|
770
|
-
const
|
|
771
|
-
function
|
|
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;
|
|
779
|
+
function xt(e) {
|
|
772
780
|
if (!Number.isFinite(e) || e <= 0)
|
|
773
781
|
throw new Error(
|
|
774
782
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
775
783
|
);
|
|
776
784
|
return BigInt(Math.ceil(e * Y));
|
|
777
785
|
}
|
|
778
|
-
const
|
|
786
|
+
const qe = 1, je = /non-BIP68-final/i;
|
|
779
787
|
function D(e, r) {
|
|
780
788
|
if (e.length !== 66)
|
|
781
789
|
throw new Error(
|
|
782
790
|
`${r} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
783
791
|
);
|
|
784
|
-
if (!
|
|
792
|
+
if (!ze.test(e))
|
|
785
793
|
throw new Error(
|
|
786
794
|
`${r} must contain only hex characters after the 0x prefix`
|
|
787
795
|
);
|
|
788
796
|
}
|
|
789
|
-
function
|
|
797
|
+
function B(e, r) {
|
|
790
798
|
if (!Number.isInteger(e) || e < 0)
|
|
791
799
|
throw new Error(`${r} must be a non-negative integer, got ${e}`);
|
|
792
800
|
}
|
|
793
|
-
function
|
|
801
|
+
function Qe(e) {
|
|
794
802
|
if (D(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
|
|
795
803
|
throw new Error(
|
|
796
804
|
`htlcVout must be a non-negative integer, got ${e.htlcVout}`
|
|
@@ -821,12 +829,15 @@ function je(e) {
|
|
|
821
829
|
throw new Error(
|
|
822
830
|
`batch[${e.htlcVout}].amount (${r.amount}) does not match target amount (${e.amount})`
|
|
823
831
|
);
|
|
824
|
-
if (
|
|
832
|
+
if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
|
|
825
833
|
e.universalChallengersVersion,
|
|
826
834
|
"universalChallengersVersion"
|
|
835
|
+
), ge(
|
|
836
|
+
e.vaultCoreVersion,
|
|
837
|
+
"VaultRefundData.vaultCoreVersion"
|
|
827
838
|
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
828
839
|
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
829
|
-
if (!
|
|
840
|
+
if (!Ge.test(e.unsignedPrePeginTxHex))
|
|
830
841
|
throw new Error(
|
|
831
842
|
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
832
843
|
);
|
|
@@ -837,7 +848,7 @@ function je(e) {
|
|
|
837
848
|
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
838
849
|
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
839
850
|
}
|
|
840
|
-
function
|
|
851
|
+
function We(e) {
|
|
841
852
|
if (!e.vaultProviderPubkey || !W.test(e.vaultProviderPubkey))
|
|
842
853
|
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
843
854
|
if (e.vaultKeeperPubkeys.length === 0)
|
|
@@ -863,7 +874,7 @@ function Qe(e) {
|
|
|
863
874
|
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
864
875
|
);
|
|
865
876
|
}
|
|
866
|
-
function
|
|
877
|
+
function Ye(e) {
|
|
867
878
|
const r = le.fromHex(e);
|
|
868
879
|
try {
|
|
869
880
|
r.finalizeAllInputs();
|
|
@@ -874,21 +885,21 @@ function We(e) {
|
|
|
874
885
|
}
|
|
875
886
|
return r.extractTransaction().toHex();
|
|
876
887
|
}
|
|
877
|
-
async function
|
|
888
|
+
async function vt(e) {
|
|
878
889
|
const {
|
|
879
890
|
vaultId: r,
|
|
880
891
|
readVault: t,
|
|
881
892
|
readPrePeginContext: n,
|
|
882
893
|
feeRate: s,
|
|
883
|
-
signPsbt:
|
|
894
|
+
signPsbt: l,
|
|
884
895
|
broadcastTx: a,
|
|
885
896
|
signal: i
|
|
886
897
|
} = e;
|
|
887
898
|
i == null || i.throwIfAborted(), D(r, "vaultId");
|
|
888
899
|
const o = await t();
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
if (
|
|
900
|
+
Qe(o), i == null || i.throwIfAborted();
|
|
901
|
+
const u = await n(o);
|
|
902
|
+
if (We(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
892
903
|
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
893
904
|
if (s > F)
|
|
894
905
|
throw new Error(
|
|
@@ -910,7 +921,7 @@ async function wt(e) {
|
|
|
910
921
|
const y = m == null ? void 0 : m.hash;
|
|
911
922
|
let x;
|
|
912
923
|
try {
|
|
913
|
-
x =
|
|
924
|
+
x = S.fromHex(P);
|
|
914
925
|
} catch (f) {
|
|
915
926
|
throw new Error(
|
|
916
927
|
`Failed to parse funded Pre-PegIn transaction hex: ${f instanceof Error ? f.message : String(f)}`
|
|
@@ -922,12 +933,13 @@ async function wt(e) {
|
|
|
922
933
|
);
|
|
923
934
|
const { psbtHex: b } = await pe({
|
|
924
935
|
prePeginParams: {
|
|
936
|
+
vaultCoreVersion: o.vaultCoreVersion,
|
|
925
937
|
depositorPubkey: d,
|
|
926
|
-
vaultProviderPubkey: p(
|
|
927
|
-
vaultKeeperPubkeys:
|
|
928
|
-
universalChallengerPubkeys:
|
|
938
|
+
vaultProviderPubkey: p(u.vaultProviderPubkey),
|
|
939
|
+
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(p),
|
|
940
|
+
universalChallengerPubkeys: u.universalChallengerPubkeys.map(p),
|
|
929
941
|
hashlocks: o.batch.map((f) => p(f.hashlock)),
|
|
930
|
-
timelockRefund:
|
|
942
|
+
timelockRefund: u.timelockRefund,
|
|
931
943
|
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
932
944
|
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
933
945
|
// reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
|
|
@@ -935,12 +947,12 @@ async function wt(e) {
|
|
|
935
947
|
// to the funded tx bytes, refusing the refund if the template's HTLC value
|
|
936
948
|
// disagrees with the on-chain commitment.
|
|
937
949
|
pegInAmounts: o.batch.map((f) => f.amount),
|
|
938
|
-
feeRate:
|
|
939
|
-
minPeginFeeRate:
|
|
940
|
-
numLocalChallengers:
|
|
941
|
-
councilQuorum:
|
|
942
|
-
councilSize:
|
|
943
|
-
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,
|
|
944
956
|
authAnchorHash: y
|
|
945
957
|
},
|
|
946
958
|
fundedPrePeginTxHex: P,
|
|
@@ -955,9 +967,9 @@ async function wt(e) {
|
|
|
955
967
|
i == null || i.throwIfAborted();
|
|
956
968
|
const v = O(
|
|
957
969
|
o.depositorBtcPubkey,
|
|
958
|
-
|
|
959
|
-
), T = await
|
|
960
|
-
|
|
970
|
+
qe
|
|
971
|
+
), T = await l(b, v);
|
|
972
|
+
I({
|
|
961
973
|
requestedPsbtHex: b,
|
|
962
974
|
returnedPsbtHex: T
|
|
963
975
|
});
|
|
@@ -972,40 +984,40 @@ async function wt(e) {
|
|
|
972
984
|
signerXOnlyPubkeyHex: d,
|
|
973
985
|
inputIndex: k
|
|
974
986
|
});
|
|
975
|
-
const
|
|
987
|
+
const C = Ye(T);
|
|
976
988
|
i == null || i.throwIfAborted();
|
|
977
989
|
try {
|
|
978
|
-
return await a(
|
|
990
|
+
return await a(C);
|
|
979
991
|
} catch (f) {
|
|
980
|
-
throw f instanceof Error &&
|
|
992
|
+
throw f instanceof Error && je.test(f.message) ? new Xe(r, f) : f;
|
|
981
993
|
}
|
|
982
994
|
}
|
|
983
995
|
export {
|
|
984
|
-
|
|
996
|
+
Xe as B,
|
|
985
997
|
Q as C,
|
|
986
998
|
j as R,
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
999
|
+
ut as a,
|
|
1000
|
+
Ve as b,
|
|
1001
|
+
pt as c,
|
|
1002
|
+
gt as d,
|
|
1003
|
+
De as e,
|
|
1004
|
+
Ke as f,
|
|
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,
|
|
1002
1014
|
L as p,
|
|
1003
1015
|
M as q,
|
|
1004
|
-
|
|
1005
|
-
|
|
1016
|
+
ct as r,
|
|
1017
|
+
lt as s,
|
|
1006
1018
|
F as t,
|
|
1007
1019
|
Y as u,
|
|
1008
|
-
|
|
1020
|
+
dt as v,
|
|
1009
1021
|
G as w
|
|
1010
1022
|
};
|
|
1011
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
1023
|
+
//# sourceMappingURL=buildAndBroadcastRefund-DjS9nf87.js.map
|