@babylonlabs-io/ts-sdk 0.33.3 → 0.33.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
- package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
- package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
- package/dist/PayoutManager-C9XHKZ5j.js +200 -0
- package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
- package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
- package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
- package/dist/PeginManager-BXg2S1mH.cjs +2 -0
- package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
- package/dist/{PeginManager-C-L3huRO.js → PeginManager-C5HaMAcw.js} +328 -437
- package/dist/PeginManager-C5HaMAcw.js.map +1 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
- package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
- package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs +2 -0
- package/dist/buildAndBroadcastRefund-CIPPpchL.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-D_QlvCsw.js +777 -0
- package/dist/buildAndBroadcastRefund-D_QlvCsw.js.map +1 -0
- package/dist/challengeAssert-BzxQmdZy.js +128 -0
- package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
- package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
- package/dist/errors-9AkghWyk.js +22 -0
- package/dist/errors-9AkghWyk.js.map +1 -0
- package/dist/errors-BP73_stm.cjs +2 -0
- package/dist/errors-BP73_stm.cjs.map +1 -0
- package/dist/errors-Bu0H-dZD.cjs +2 -0
- package/dist/errors-Bu0H-dZD.cjs.map +1 -0
- package/dist/errors-CznAK5NB.js +96 -0
- package/dist/errors-CznAK5NB.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +156 -146
- package/dist/index.js.map +1 -1
- package/dist/mempoolApi-CAIge7Nj.js +205 -0
- package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
- package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
- package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
- package/dist/noPayout-BXeUw0Qq.cjs +2 -0
- package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
- package/dist/noPayout-DBX6G96_.js +141 -0
- package/dist/noPayout-DBX6G96_.js.map +1 -0
- package/dist/payout-BNFMBXS6.js +193 -0
- package/dist/payout-BNFMBXS6.js.map +1 -0
- package/dist/payout-DQ_fmJUA.cjs +2 -0
- package/dist/payout-DQ_fmJUA.cjs.map +1 -0
- package/dist/peginInput-C2QPvuhR.js +177 -0
- package/dist/peginInput-C2QPvuhR.js.map +1 -0
- package/dist/peginInput-tbw9BpZy.cjs +2 -0
- package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
- package/dist/peginState-BijNNT15.cjs +2 -0
- package/dist/peginState-BijNNT15.cjs.map +1 -0
- package/dist/peginState-CBAlxgXk.js +51 -0
- package/dist/peginState-CBAlxgXk.js.map +1 -0
- package/dist/psbtInputFields-2224j2ZY.js +128 -0
- package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
- package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
- package/dist/reservation-CHUGW0F_.js +142 -0
- package/dist/reservation-CHUGW0F_.js.map +1 -0
- package/dist/reservation-ho7mjW3X.cjs +2 -0
- package/dist/reservation-ho7mjW3X.cjs.map +1 -0
- package/dist/signing-Bnsro0hE.cjs +2 -0
- package/dist/signing-Bnsro0hE.cjs.map +1 -0
- package/dist/signing-DaLvGwQe.js +16 -0
- package/dist/signing-DaLvGwQe.js.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +31 -30
- package/dist/tbv/core/clients/index.js.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +2 -0
- package/dist/tbv/core/contracts/index.cjs.map +1 -0
- package/dist/tbv/core/contracts/index.js +14 -0
- package/dist/tbv/core/contracts/index.js.map +1 -0
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +156 -146
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/index.cjs +2 -0
- package/dist/tbv/core/managers/index.cjs.map +1 -0
- package/dist/tbv/core/managers/index.js +7 -0
- package/dist/tbv/core/managers/index.js.map +1 -0
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +31 -29
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +28 -27
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +21 -20
- package/dist/tbv/core/utils/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +156 -146
- package/dist/tbv/index.js.map +1 -1
- package/dist/types-ByW6nSLj.js +318 -0
- package/dist/types-ByW6nSLj.js.map +1 -0
- package/dist/types-CfCZyfid.cjs +2 -0
- package/dist/types-CfCZyfid.cjs.map +1 -0
- package/dist/vault-registry-reader-OK2V08tk.cjs +2 -0
- package/dist/vault-registry-reader-OK2V08tk.cjs.map +1 -0
- package/dist/{vault-registry-reader-CWGbw_wZ.js → vault-registry-reader-WiNVOsnD.js} +263 -840
- package/dist/vault-registry-reader-WiNVOsnD.js.map +1 -0
- package/package.json +11 -1
- package/dist/PeginManager-C-L3huRO.js.map +0 -1
- package/dist/PeginManager-DmPmzPHz.cjs +0 -2
- package/dist/PeginManager-DmPmzPHz.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-Dx09Zbla.js +0 -965
- package/dist/buildAndBroadcastRefund-Dx09Zbla.js.map +0 -1
- package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs +0 -2
- package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs.map +0 -1
- package/dist/challengeAssert-D3tHnLWb.js +0 -298
- package/dist/challengeAssert-D3tHnLWb.js.map +0 -1
- package/dist/challengeAssert-Dp9d1bg1.cjs +0 -2
- package/dist/challengeAssert-Dp9d1bg1.cjs.map +0 -1
- package/dist/noPayout-BnsetBKW.js +0 -327
- package/dist/noPayout-BnsetBKW.js.map +0 -1
- package/dist/noPayout-DWaCtpMU.cjs +0 -2
- package/dist/noPayout-DWaCtpMU.cjs.map +0 -1
- package/dist/psbtInputFields-6sRcZqdb.cjs +0 -2
- package/dist/psbtInputFields-6sRcZqdb.cjs.map +0 -1
- package/dist/psbtInputFields-C5QPn1YK.js +0 -264
- package/dist/psbtInputFields-C5QPn1YK.js.map +0 -1
- package/dist/signing-BZigafm0.js +0 -64
- package/dist/signing-BZigafm0.js.map +0 -1
- package/dist/signing-DHSXjhLM.cjs +0 -2
- package/dist/signing-DHSXjhLM.cjs.map +0 -1
- package/dist/types-PthVHz5q.cjs +0 -2
- package/dist/types-PthVHz5q.cjs.map +0 -1
- package/dist/types-SYvSQWnc.js +0 -732
- package/dist/types-SYvSQWnc.js.map +0 -1
- package/dist/vault-registry-reader-CKe9TbX6.cjs +0 -2
- package/dist/vault-registry-reader-CKe9TbX6.cjs.map +0 -1
- package/dist/vault-registry-reader-CWGbw_wZ.js.map +0 -1
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var U = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var v = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { B as F } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
|
|
5
|
+
import { e as X, s as c, u as R, p as m, f as p } from "./bitcoin-B0S8SHCX.js";
|
|
6
|
+
import { v as z, P as G } from "./PayoutManager-C9XHKZ5j.js";
|
|
7
|
+
import { c as Q, a as W, R as Y, d as $, D as b } from "./types-ByW6nSLj.js";
|
|
8
|
+
import * as j from "bitcoinjs-lib";
|
|
9
|
+
import { Transaction as y, Psbt as q } from "bitcoinjs-lib";
|
|
10
|
+
import { Buffer as J } from "buffer";
|
|
11
|
+
import { c as Z, a as ee, b as te } from "./noPayout-DBX6G96_.js";
|
|
12
|
+
import { a as re, b as oe, e as A } from "./payout-BNFMBXS6.js";
|
|
13
|
+
import { c as _ } from "./signing-DaLvGwQe.js";
|
|
14
|
+
const ne = /^0x[0-9a-fA-F]{64}$/, ae = /^0x[0-9a-fA-F]{40}$/, se = /^0x([0-9a-fA-F]{2})*$/;
|
|
15
|
+
function T(e, t) {
|
|
16
|
+
if (e.length !== 66)
|
|
17
|
+
throw new Error(
|
|
18
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
19
|
+
);
|
|
20
|
+
if (!ne.test(e))
|
|
21
|
+
throw new Error(
|
|
22
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function ie(e, t) {
|
|
26
|
+
if (!ae.test(e))
|
|
27
|
+
throw new Error(
|
|
28
|
+
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function ue(e, t) {
|
|
32
|
+
if (!se.test(e))
|
|
33
|
+
throw new Error(
|
|
34
|
+
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function je(e) {
|
|
38
|
+
const {
|
|
39
|
+
btcVaultRegistryAddress: t,
|
|
40
|
+
vaultId: r,
|
|
41
|
+
hashlock: o,
|
|
42
|
+
activationMetadata: s,
|
|
43
|
+
writeContract: u,
|
|
44
|
+
signal: n
|
|
45
|
+
} = e;
|
|
46
|
+
n == null || n.throwIfAborted(), ie(t, "btcVaultRegistryAddress"), T(r, "vaultId");
|
|
47
|
+
const i = X(e.secret);
|
|
48
|
+
if (T(i, "secret"), o !== void 0 && (T(o, "hashlock"), !z(i, o)))
|
|
49
|
+
throw new Error(
|
|
50
|
+
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
51
|
+
);
|
|
52
|
+
return ue(s, "activationMetadata"), u({
|
|
53
|
+
address: t,
|
|
54
|
+
abi: F,
|
|
55
|
+
functionName: "activateVaultWithSecret",
|
|
56
|
+
args: [r, i, s]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const le = 1e4;
|
|
60
|
+
async function N(e) {
|
|
61
|
+
const {
|
|
62
|
+
statusReader: t,
|
|
63
|
+
peginTxid: r,
|
|
64
|
+
targetStatuses: o,
|
|
65
|
+
timeoutMs: s,
|
|
66
|
+
pollIntervalMs: u = le,
|
|
67
|
+
signal: n
|
|
68
|
+
} = e, i = Date.now();
|
|
69
|
+
for (; ; ) {
|
|
70
|
+
if (n != null && n.aborted)
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
73
|
+
);
|
|
74
|
+
if (Date.now() - i >= s)
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
77
|
+
);
|
|
78
|
+
try {
|
|
79
|
+
const l = (await t.getPeginStatus(
|
|
80
|
+
{ pegin_txid: r },
|
|
81
|
+
n
|
|
82
|
+
)).status;
|
|
83
|
+
if (o.has(l))
|
|
84
|
+
return l;
|
|
85
|
+
if (Q.has(l) && !o.has(l))
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Pegin ${r.slice(0, 8)}… reached terminal status "${l}" while waiting for ${[...o].join(", ")}`
|
|
88
|
+
);
|
|
89
|
+
} catch (a) {
|
|
90
|
+
if (!(a instanceof W && a.code === Y.NOT_FOUND || a instanceof Error && a.message.includes("PegIn not found")))
|
|
91
|
+
throw a;
|
|
92
|
+
}
|
|
93
|
+
await new Promise((a, l) => {
|
|
94
|
+
const f = () => {
|
|
95
|
+
clearTimeout(d), l(
|
|
96
|
+
new Error(
|
|
97
|
+
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
}, d = setTimeout(() => {
|
|
101
|
+
n == null || n.removeEventListener("abort", f), a();
|
|
102
|
+
}, u);
|
|
103
|
+
n == null || n.addEventListener("abort", f, { once: !0 });
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const ce = 300 * 1e3, de = /* @__PURE__ */ new Set([
|
|
108
|
+
b.PENDING_DEPOSITOR_WOTS_PK,
|
|
109
|
+
...$
|
|
110
|
+
]);
|
|
111
|
+
async function qe(e) {
|
|
112
|
+
const {
|
|
113
|
+
statusReader: t,
|
|
114
|
+
wotsSubmitter: r,
|
|
115
|
+
peginTxid: o,
|
|
116
|
+
depositorPk: s,
|
|
117
|
+
wotsPublicKeys: u,
|
|
118
|
+
timeoutMs: n = ce,
|
|
119
|
+
signal: i
|
|
120
|
+
} = e;
|
|
121
|
+
i == null || i.throwIfAborted();
|
|
122
|
+
const a = await N({
|
|
123
|
+
statusReader: t,
|
|
124
|
+
peginTxid: o,
|
|
125
|
+
targetStatuses: de,
|
|
126
|
+
timeoutMs: n,
|
|
127
|
+
signal: i
|
|
128
|
+
});
|
|
129
|
+
$.has(a) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
130
|
+
{
|
|
131
|
+
pegin_txid: o,
|
|
132
|
+
depositor_pk: s,
|
|
133
|
+
wots_public_keys: u
|
|
134
|
+
},
|
|
135
|
+
i
|
|
136
|
+
));
|
|
137
|
+
}
|
|
138
|
+
const B = 1;
|
|
139
|
+
function fe(e, t, r) {
|
|
140
|
+
const o = c(r).toLowerCase(), u = [e, ...t].map(
|
|
141
|
+
(n) => c(n).toLowerCase()
|
|
142
|
+
).filter((n) => n !== o);
|
|
143
|
+
if (u.length === 0)
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Cannot derive localChallengers: removing depositor from {vaultProvider, vaultKeepers} left an empty set"
|
|
146
|
+
);
|
|
147
|
+
return u;
|
|
148
|
+
}
|
|
149
|
+
function he(e, t) {
|
|
150
|
+
const r = e.ins[t];
|
|
151
|
+
return R(new Uint8Array(r.hash).slice().reverse());
|
|
152
|
+
}
|
|
153
|
+
function k(e, t, r, o, s) {
|
|
154
|
+
const u = e.ins[t];
|
|
155
|
+
if (u.index !== 0)
|
|
156
|
+
throw new Error(
|
|
157
|
+
`NoPayout (challenger ${s}) input ${t} expected to spend ${o} vout 0, got vout ${u.index}`
|
|
158
|
+
);
|
|
159
|
+
const n = r.getId(), i = he(e, t);
|
|
160
|
+
if (i !== n)
|
|
161
|
+
throw new Error(
|
|
162
|
+
`NoPayout (challenger ${s}) input ${t} does not reference ${o} (expected txid ${n}, got ${i})`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
async function pe(e, t, r) {
|
|
166
|
+
const o = [], s = [], u = [];
|
|
167
|
+
re(
|
|
168
|
+
e.payout_tx.tx_hex,
|
|
169
|
+
r.registeredPayoutScriptPubKey
|
|
170
|
+
);
|
|
171
|
+
const n = await oe({
|
|
172
|
+
payoutTxHex: e.payout_tx.tx_hex,
|
|
173
|
+
peginTxHex: r.peginTxHex,
|
|
174
|
+
assertTxHex: e.assert_tx.tx_hex,
|
|
175
|
+
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
176
|
+
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
177
|
+
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
|
|
178
|
+
universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
|
|
179
|
+
timelockPegin: r.timelockPegin,
|
|
180
|
+
network: r.network
|
|
181
|
+
});
|
|
182
|
+
o.push(n.psbtHex), s.push(
|
|
183
|
+
_(
|
|
184
|
+
t,
|
|
185
|
+
B
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
const i = fe(
|
|
189
|
+
r.vaultProviderBtcPubkey,
|
|
190
|
+
r.vaultKeeperBtcPubkeys,
|
|
191
|
+
r.depositorBtcPubkey
|
|
192
|
+
), a = c(r.depositorBtcPubkey), l = y.fromHex(
|
|
193
|
+
c(e.assert_tx.tx_hex)
|
|
194
|
+
);
|
|
195
|
+
for (const f of e.challenger_presign_data) {
|
|
196
|
+
const d = c(f.challenger_pubkey), g = o.length, P = await ge({
|
|
197
|
+
challenger: f,
|
|
198
|
+
challengerPubkey: d,
|
|
199
|
+
claimerPubkey: a,
|
|
200
|
+
localChallengers: i,
|
|
201
|
+
assertTxParsed: l,
|
|
202
|
+
ctx: r
|
|
203
|
+
});
|
|
204
|
+
o.push(P), s.push(
|
|
205
|
+
_(
|
|
206
|
+
t,
|
|
207
|
+
B
|
|
208
|
+
)
|
|
209
|
+
), u.push({
|
|
210
|
+
challengerPubkey: d,
|
|
211
|
+
noPayoutIdx: g
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return { psbtHexes: o, signOptions: s, challengerEntries: u };
|
|
215
|
+
}
|
|
216
|
+
async function ge(e) {
|
|
217
|
+
const {
|
|
218
|
+
challenger: t,
|
|
219
|
+
challengerPubkey: r,
|
|
220
|
+
claimerPubkey: o,
|
|
221
|
+
localChallengers: s,
|
|
222
|
+
assertTxParsed: u,
|
|
223
|
+
ctx: n
|
|
224
|
+
} = e;
|
|
225
|
+
Z(
|
|
226
|
+
t.nopayout_tx.tx_hex,
|
|
227
|
+
r,
|
|
228
|
+
n.network
|
|
229
|
+
);
|
|
230
|
+
const i = y.fromHex(
|
|
231
|
+
c(t.nopayout_tx.tx_hex)
|
|
232
|
+
), a = y.fromHex(
|
|
233
|
+
c(t.challenge_assert_x_tx.tx_hex)
|
|
234
|
+
), l = y.fromHex(
|
|
235
|
+
c(t.challenge_assert_y_tx.tx_hex)
|
|
236
|
+
);
|
|
237
|
+
if (i.ins.length !== 3)
|
|
238
|
+
throw new Error(
|
|
239
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
|
|
240
|
+
);
|
|
241
|
+
k(
|
|
242
|
+
i,
|
|
243
|
+
0,
|
|
244
|
+
u,
|
|
245
|
+
"Assert",
|
|
246
|
+
r
|
|
247
|
+
), k(
|
|
248
|
+
i,
|
|
249
|
+
1,
|
|
250
|
+
a,
|
|
251
|
+
"ChallengeAssertX",
|
|
252
|
+
r
|
|
253
|
+
), k(
|
|
254
|
+
i,
|
|
255
|
+
2,
|
|
256
|
+
l,
|
|
257
|
+
"ChallengeAssertY",
|
|
258
|
+
r
|
|
259
|
+
);
|
|
260
|
+
const f = [
|
|
261
|
+
u.outs[0],
|
|
262
|
+
a.outs[0],
|
|
263
|
+
l.outs[0]
|
|
264
|
+
].map((d) => ({
|
|
265
|
+
script_pubkey: R(new Uint8Array(d.script)),
|
|
266
|
+
value: d.value
|
|
267
|
+
}));
|
|
268
|
+
return ee({
|
|
269
|
+
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
270
|
+
challengerPubkey: r,
|
|
271
|
+
prevouts: f,
|
|
272
|
+
connectorParams: {
|
|
273
|
+
claimer: o,
|
|
274
|
+
localChallengers: s,
|
|
275
|
+
universalChallengers: n.universalChallengerBtcPubkeys,
|
|
276
|
+
timelockAssert: n.timelockAssert,
|
|
277
|
+
councilMembers: n.councilMembers,
|
|
278
|
+
councilQuorum: n.councilQuorum
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function Pe(e, t, r) {
|
|
283
|
+
const o = A(
|
|
284
|
+
e[0],
|
|
285
|
+
r
|
|
286
|
+
), s = {};
|
|
287
|
+
for (const u of t)
|
|
288
|
+
s[u.challengerPubkey] = {
|
|
289
|
+
nopayout_signature: A(
|
|
290
|
+
e[u.noPayoutIdx],
|
|
291
|
+
r
|
|
292
|
+
)
|
|
293
|
+
};
|
|
294
|
+
return {
|
|
295
|
+
payout_signatures: {
|
|
296
|
+
payout_signature: o
|
|
297
|
+
},
|
|
298
|
+
per_challenger: s
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
async function be(e, t, r) {
|
|
302
|
+
if (typeof e.signPsbts == "function")
|
|
303
|
+
return e.signPsbts(t, r);
|
|
304
|
+
const o = [];
|
|
305
|
+
for (let s = 0; s < t.length; s++)
|
|
306
|
+
o.push(await e.signPsbt(t[s], r == null ? void 0 : r[s]));
|
|
307
|
+
return o;
|
|
308
|
+
}
|
|
309
|
+
async function ye(e) {
|
|
310
|
+
const { depositorGraph: t, btcWallet: r, signingContext: o } = e, s = c(o.depositorBtcPubkey), u = await r.getPublicKeyHex(), { psbtHexes: n, signOptions: i, challengerEntries: a } = await pe(
|
|
311
|
+
t,
|
|
312
|
+
u,
|
|
313
|
+
o
|
|
314
|
+
), l = await be(
|
|
315
|
+
r,
|
|
316
|
+
n,
|
|
317
|
+
i
|
|
318
|
+
);
|
|
319
|
+
if (l.length !== n.length)
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Wallet returned ${l.length} signed PSBTs, expected ${n.length}`
|
|
322
|
+
);
|
|
323
|
+
return Pe(
|
|
324
|
+
l,
|
|
325
|
+
a,
|
|
326
|
+
s
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
const me = 1200 * 1e3, H = /* @__PURE__ */ new Set([
|
|
330
|
+
b.PENDING_ACKS,
|
|
331
|
+
b.PENDING_ACTIVATION,
|
|
332
|
+
b.ACTIVATED
|
|
333
|
+
]), we = /* @__PURE__ */ new Set([
|
|
334
|
+
b.PENDING_DEPOSITOR_SIGNATURES,
|
|
335
|
+
...H
|
|
336
|
+
]);
|
|
337
|
+
function xe(e) {
|
|
338
|
+
return e.map((t) => ({
|
|
339
|
+
claimerPubkeyXOnly: m(t.claimer_pubkey),
|
|
340
|
+
payoutTxHex: t.payout_tx.tx_hex,
|
|
341
|
+
assertTxHex: t.assert_tx.tx_hex
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
function ve(e) {
|
|
345
|
+
const { output: t } = j.payments.p2tr({
|
|
346
|
+
internalPubkey: J.from(e, "hex")
|
|
347
|
+
});
|
|
348
|
+
if (!t)
|
|
349
|
+
throw new Error("Failed to derive BIP-86 P2TR scriptPubKey");
|
|
350
|
+
return t.toString("hex");
|
|
351
|
+
}
|
|
352
|
+
function Te(e, t) {
|
|
353
|
+
const r = c(e).toLowerCase(), o = c(
|
|
354
|
+
t.vaultProviderBtcPubkey
|
|
355
|
+
).toLowerCase(), s = c(
|
|
356
|
+
t.depositorBtcPubkey
|
|
357
|
+
).toLowerCase();
|
|
358
|
+
if (r === o || r === s)
|
|
359
|
+
return t.registeredPayoutScriptPubKey;
|
|
360
|
+
if (!t.vaultKeeperBtcPubkeys.some(
|
|
361
|
+
(i) => c(i).toLowerCase() === r
|
|
362
|
+
))
|
|
363
|
+
throw new Error(
|
|
364
|
+
`Unknown claimer pubkey ${r}: not VP, depositor, or a registered vault keeper`
|
|
365
|
+
);
|
|
366
|
+
return `0x${ve(r)}`;
|
|
367
|
+
}
|
|
368
|
+
function I(e, t) {
|
|
369
|
+
return {
|
|
370
|
+
payoutTxHex: e.payoutTxHex,
|
|
371
|
+
peginTxHex: t.peginTxHex,
|
|
372
|
+
assertTxHex: e.assertTxHex,
|
|
373
|
+
vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
|
|
374
|
+
vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
|
|
375
|
+
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
376
|
+
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
377
|
+
timelockPegin: t.timelockPegin,
|
|
378
|
+
registeredPayoutScriptPubKey: Te(
|
|
379
|
+
e.claimerPubkeyXOnly,
|
|
380
|
+
t
|
|
381
|
+
)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
async function ke(e, t, r, o) {
|
|
385
|
+
const s = new G({
|
|
386
|
+
network: t.network,
|
|
387
|
+
btcWallet: e
|
|
388
|
+
}), u = r.length;
|
|
389
|
+
o == null || o(0, u);
|
|
390
|
+
let n;
|
|
391
|
+
if (s.supportsBatchSigning())
|
|
392
|
+
n = (await s.signPayoutTransactionsBatch(
|
|
393
|
+
r.map((l) => I(l, t))
|
|
394
|
+
)).map((l) => l.payoutSignature);
|
|
395
|
+
else {
|
|
396
|
+
n = [];
|
|
397
|
+
for (let a = 0; a < r.length; a++) {
|
|
398
|
+
o == null || o(a, u);
|
|
399
|
+
const l = await s.signPayoutTransaction(
|
|
400
|
+
I(r[a], t)
|
|
401
|
+
);
|
|
402
|
+
n.push(l.signature);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const i = {};
|
|
406
|
+
for (let a = 0; a < r.length; a++)
|
|
407
|
+
i[r[a].claimerPubkeyXOnly] = {
|
|
408
|
+
payout_signature: n[a]
|
|
409
|
+
};
|
|
410
|
+
return o == null || o(u, u), i;
|
|
411
|
+
}
|
|
412
|
+
async function Je(e) {
|
|
413
|
+
const {
|
|
414
|
+
statusReader: t,
|
|
415
|
+
presignClient: r,
|
|
416
|
+
btcWallet: o,
|
|
417
|
+
peginTxid: s,
|
|
418
|
+
depositorPk: u,
|
|
419
|
+
signingContext: n,
|
|
420
|
+
timeoutMs: i = me,
|
|
421
|
+
signal: a,
|
|
422
|
+
onProgress: l
|
|
423
|
+
} = e, f = await N({
|
|
424
|
+
statusReader: t,
|
|
425
|
+
peginTxid: s,
|
|
426
|
+
targetStatuses: we,
|
|
427
|
+
timeoutMs: i,
|
|
428
|
+
signal: a
|
|
429
|
+
});
|
|
430
|
+
if (H.has(f))
|
|
431
|
+
return;
|
|
432
|
+
a == null || a.throwIfAborted();
|
|
433
|
+
const d = await r.requestDepositorPresignTransactions(
|
|
434
|
+
{
|
|
435
|
+
pegin_txid: s,
|
|
436
|
+
depositor_pk: u
|
|
437
|
+
},
|
|
438
|
+
a
|
|
439
|
+
);
|
|
440
|
+
a == null || a.throwIfAborted();
|
|
441
|
+
const g = m(u), P = d.txs.filter(
|
|
442
|
+
(L) => m(L.claimer_pubkey) !== g
|
|
443
|
+
), w = xe(P), x = await ke(
|
|
444
|
+
o,
|
|
445
|
+
n,
|
|
446
|
+
w,
|
|
447
|
+
l
|
|
448
|
+
);
|
|
449
|
+
a == null || a.throwIfAborted();
|
|
450
|
+
const h = await ye({
|
|
451
|
+
depositorGraph: d.depositor_graph,
|
|
452
|
+
btcWallet: o,
|
|
453
|
+
signingContext: {
|
|
454
|
+
peginTxHex: n.peginTxHex,
|
|
455
|
+
depositorBtcPubkey: u,
|
|
456
|
+
vaultProviderBtcPubkey: n.vaultProviderBtcPubkey,
|
|
457
|
+
vaultKeeperBtcPubkeys: n.vaultKeeperBtcPubkeys,
|
|
458
|
+
universalChallengerBtcPubkeys: n.universalChallengerBtcPubkeys,
|
|
459
|
+
timelockPegin: n.timelockPegin,
|
|
460
|
+
timelockAssert: n.timelockAssert,
|
|
461
|
+
councilMembers: n.councilMembers,
|
|
462
|
+
councilQuorum: n.councilQuorum,
|
|
463
|
+
network: n.network,
|
|
464
|
+
registeredPayoutScriptPubKey: n.registeredPayoutScriptPubKey
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
a == null || a.throwIfAborted();
|
|
468
|
+
const S = { ...x };
|
|
469
|
+
S[c(u)] = h.payout_signatures, await r.submitDepositorPresignatures(
|
|
470
|
+
{
|
|
471
|
+
pegin_txid: s,
|
|
472
|
+
depositor_pk: u,
|
|
473
|
+
signatures: S,
|
|
474
|
+
depositor_claimer_presignatures: h
|
|
475
|
+
},
|
|
476
|
+
a
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
function Ee(e) {
|
|
480
|
+
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
481
|
+
}
|
|
482
|
+
function Ze(e) {
|
|
483
|
+
const {
|
|
484
|
+
amountSats: t,
|
|
485
|
+
minDeposit: r,
|
|
486
|
+
maxDeposit: o,
|
|
487
|
+
btcBalance: s,
|
|
488
|
+
estimatedFeeSats: u,
|
|
489
|
+
depositorClaimValue: n
|
|
490
|
+
} = e;
|
|
491
|
+
return !(t <= 0n || t < r || o && o > 0n && t > o || u == null || n == null || t + u + n > s);
|
|
492
|
+
}
|
|
493
|
+
function et(e, t, r) {
|
|
494
|
+
return e <= 0n ? {
|
|
495
|
+
valid: !1,
|
|
496
|
+
error: "Deposit amount must be greater than zero"
|
|
497
|
+
} : e < t ? {
|
|
498
|
+
valid: !1,
|
|
499
|
+
error: `Minimum deposit is ${p(t)} BTC`
|
|
500
|
+
} : r && r > 0n && e > r ? {
|
|
501
|
+
valid: !1,
|
|
502
|
+
error: `Maximum deposit is ${p(r)} BTC`
|
|
503
|
+
} : { valid: !0 };
|
|
504
|
+
}
|
|
505
|
+
function tt(e) {
|
|
506
|
+
const { amount: t, effectiveRemaining: r } = e;
|
|
507
|
+
return r === null ? { valid: !0 } : r === 0n ? {
|
|
508
|
+
valid: !1,
|
|
509
|
+
error: "Supply cap reached — deposits temporarily paused"
|
|
510
|
+
} : t > r ? {
|
|
511
|
+
valid: !1,
|
|
512
|
+
error: `Vault size exceeds remaining capacity (${p(r)} BTC)`
|
|
513
|
+
} : { valid: !0 };
|
|
514
|
+
}
|
|
515
|
+
function rt(e, t) {
|
|
516
|
+
if (!e || e.length === 0)
|
|
517
|
+
return {
|
|
518
|
+
valid: !1,
|
|
519
|
+
error: "At least one vault provider must be selected"
|
|
520
|
+
};
|
|
521
|
+
const r = t.map(
|
|
522
|
+
(s) => s.toLowerCase()
|
|
523
|
+
);
|
|
524
|
+
return e.filter(
|
|
525
|
+
(s) => !r.includes(s.toLowerCase())
|
|
526
|
+
).length > 0 ? {
|
|
527
|
+
valid: !1,
|
|
528
|
+
error: "Invalid vault provider selected"
|
|
529
|
+
} : { valid: !0 };
|
|
530
|
+
}
|
|
531
|
+
function _e(e, t, r) {
|
|
532
|
+
if (!e || e.length === 0)
|
|
533
|
+
return {
|
|
534
|
+
valid: !1,
|
|
535
|
+
error: "At least one vault amount required"
|
|
536
|
+
};
|
|
537
|
+
for (let o = 0; o < e.length; o++) {
|
|
538
|
+
const s = e[o];
|
|
539
|
+
if (s <= 0n)
|
|
540
|
+
return {
|
|
541
|
+
valid: !1,
|
|
542
|
+
error: `Vault ${o + 1} amount must be positive`
|
|
543
|
+
};
|
|
544
|
+
if (t && s < t)
|
|
545
|
+
return {
|
|
546
|
+
valid: !1,
|
|
547
|
+
error: `Vault ${o + 1} amount ${p(s)} BTC is below minimum deposit ${p(t)} BTC`
|
|
548
|
+
};
|
|
549
|
+
if (r && s > r)
|
|
550
|
+
return {
|
|
551
|
+
valid: !1,
|
|
552
|
+
error: `Vault ${o + 1} amount ${p(s)} BTC exceeds maximum deposit ${p(r)} BTC`
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
return { valid: !0 };
|
|
556
|
+
}
|
|
557
|
+
function Se(e) {
|
|
558
|
+
const t = c(e);
|
|
559
|
+
return Ee(t) ? { valid: !0 } : {
|
|
560
|
+
valid: !1,
|
|
561
|
+
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function Ae(e) {
|
|
565
|
+
if (!e || e.length === 0)
|
|
566
|
+
throw new Error(
|
|
567
|
+
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
function Be(e) {
|
|
571
|
+
if (!e || e.length === 0)
|
|
572
|
+
throw new Error(
|
|
573
|
+
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
function Ie(e) {
|
|
577
|
+
if (e.length === 0)
|
|
578
|
+
throw new Error("No spendable UTXOs available");
|
|
579
|
+
}
|
|
580
|
+
function ot(e) {
|
|
581
|
+
const {
|
|
582
|
+
vaultAmounts: t,
|
|
583
|
+
confirmedUTXOs: r,
|
|
584
|
+
vaultProviderBtcPubkey: o,
|
|
585
|
+
vaultKeeperBtcPubkeys: s,
|
|
586
|
+
universalChallengerBtcPubkeys: u,
|
|
587
|
+
minDeposit: n,
|
|
588
|
+
maxDeposit: i
|
|
589
|
+
} = e, a = _e(
|
|
590
|
+
t,
|
|
591
|
+
n,
|
|
592
|
+
i
|
|
593
|
+
);
|
|
594
|
+
if (!a.valid)
|
|
595
|
+
throw new Error(a.error);
|
|
596
|
+
const l = Se(o);
|
|
597
|
+
if (!l.valid)
|
|
598
|
+
throw new Error(l.error);
|
|
599
|
+
Ae(s), Be(u), Ie(r);
|
|
600
|
+
}
|
|
601
|
+
var O = /* @__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))(O || {});
|
|
602
|
+
const Ce = /* @__PURE__ */ new Set([
|
|
603
|
+
"PayoutBroadcast",
|
|
604
|
+
"Failed"
|
|
605
|
+
/* FAILED */
|
|
606
|
+
]);
|
|
607
|
+
function nt(e) {
|
|
608
|
+
return Object.values(O).includes(
|
|
609
|
+
e
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
function at(e) {
|
|
613
|
+
return !!e && Ce.has(e);
|
|
614
|
+
}
|
|
615
|
+
class Re extends Error {
|
|
616
|
+
constructor(r, o) {
|
|
617
|
+
super(`Refund not yet mature (BIP68 not final): ${o.message}`);
|
|
618
|
+
v(this, "vaultId");
|
|
619
|
+
v(this, "cause");
|
|
620
|
+
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
const $e = /^0x[0-9a-fA-F]{64}$/, Ne = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, V = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, D = 160;
|
|
624
|
+
function st(e) {
|
|
625
|
+
if (!Number.isFinite(e) || e <= 0)
|
|
626
|
+
throw new Error(
|
|
627
|
+
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
628
|
+
);
|
|
629
|
+
return BigInt(Math.ceil(e * D));
|
|
630
|
+
}
|
|
631
|
+
const He = 1, C = 65535, Oe = /non-BIP68-final/i;
|
|
632
|
+
function K(e, t) {
|
|
633
|
+
if (e.length !== 66)
|
|
634
|
+
throw new Error(
|
|
635
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
636
|
+
);
|
|
637
|
+
if (!$e.test(e))
|
|
638
|
+
throw new Error(
|
|
639
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
function E(e, t) {
|
|
643
|
+
if (!Number.isInteger(e) || e < 0)
|
|
644
|
+
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
645
|
+
}
|
|
646
|
+
function Ve(e) {
|
|
647
|
+
if (K(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0 || e.htlcVout > C)
|
|
648
|
+
throw new Error(
|
|
649
|
+
`htlcVout must be an integer 0-${C}, got ${e.htlcVout}`
|
|
650
|
+
);
|
|
651
|
+
if (E(e.offchainParamsVersion, "offchainParamsVersion"), E(e.appVaultKeepersVersion, "appVaultKeepersVersion"), E(
|
|
652
|
+
e.universalChallengersVersion,
|
|
653
|
+
"universalChallengersVersion"
|
|
654
|
+
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
655
|
+
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
656
|
+
if (!Ne.test(e.unsignedPrePeginTxHex))
|
|
657
|
+
throw new Error(
|
|
658
|
+
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
659
|
+
);
|
|
660
|
+
if (!e.depositorBtcPubkey || !V.test(e.depositorBtcPubkey))
|
|
661
|
+
throw new Error(
|
|
662
|
+
"depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
|
|
663
|
+
);
|
|
664
|
+
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
665
|
+
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
666
|
+
}
|
|
667
|
+
function De(e) {
|
|
668
|
+
if (!e.vaultProviderPubkey || !V.test(e.vaultProviderPubkey))
|
|
669
|
+
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
670
|
+
if (e.vaultKeeperPubkeys.length === 0)
|
|
671
|
+
throw new Error("vaultKeeperPubkeys must be non-empty");
|
|
672
|
+
if (e.universalChallengerPubkeys.length === 0)
|
|
673
|
+
throw new Error("universalChallengerPubkeys must be non-empty");
|
|
674
|
+
if (!Number.isInteger(e.timelockRefund) || e.timelockRefund <= 0)
|
|
675
|
+
throw new Error(
|
|
676
|
+
`timelockRefund must be a positive integer, got ${e.timelockRefund}`
|
|
677
|
+
);
|
|
678
|
+
if (typeof e.feeRate != "bigint" || e.feeRate <= 0n)
|
|
679
|
+
throw new Error(
|
|
680
|
+
`protocol feeRate must be a positive bigint, got ${e.feeRate}`
|
|
681
|
+
);
|
|
682
|
+
if (!Number.isInteger(e.numLocalChallengers) || e.numLocalChallengers < 0)
|
|
683
|
+
throw new Error("numLocalChallengers must be a non-negative integer");
|
|
684
|
+
if (!Number.isInteger(e.councilQuorum) || !Number.isInteger(e.councilSize) || e.councilQuorum <= 0 || e.councilSize <= 0 || e.councilQuorum > e.councilSize)
|
|
685
|
+
throw new Error(
|
|
686
|
+
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
function Ke(e) {
|
|
690
|
+
const t = q.fromHex(e);
|
|
691
|
+
try {
|
|
692
|
+
t.finalizeAllInputs();
|
|
693
|
+
} catch (r) {
|
|
694
|
+
const o = r instanceof Error ? r.message : String(r);
|
|
695
|
+
if (!o.includes("already finalized"))
|
|
696
|
+
throw new Error(`Failed to finalize refund PSBT: ${o}`);
|
|
697
|
+
}
|
|
698
|
+
return t.extractTransaction().toHex();
|
|
699
|
+
}
|
|
700
|
+
async function it(e) {
|
|
701
|
+
const {
|
|
702
|
+
vaultId: t,
|
|
703
|
+
readVault: r,
|
|
704
|
+
readPrePeginContext: o,
|
|
705
|
+
feeRate: s,
|
|
706
|
+
signPsbt: u,
|
|
707
|
+
broadcastTx: n,
|
|
708
|
+
signal: i
|
|
709
|
+
} = e;
|
|
710
|
+
i == null || i.throwIfAborted(), K(t, "vaultId");
|
|
711
|
+
const a = await r();
|
|
712
|
+
Ve(a), i == null || i.throwIfAborted();
|
|
713
|
+
const l = await o(a);
|
|
714
|
+
if (De(l), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
715
|
+
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
716
|
+
const f = BigInt(Math.ceil(s * D));
|
|
717
|
+
i == null || i.throwIfAborted();
|
|
718
|
+
const d = m(
|
|
719
|
+
a.depositorBtcPubkey
|
|
720
|
+
), { psbtHex: g } = await te({
|
|
721
|
+
prePeginParams: {
|
|
722
|
+
depositorPubkey: d,
|
|
723
|
+
vaultProviderPubkey: c(l.vaultProviderPubkey),
|
|
724
|
+
vaultKeeperPubkeys: l.vaultKeeperPubkeys.map(c),
|
|
725
|
+
universalChallengerPubkeys: l.universalChallengerPubkeys.map(c),
|
|
726
|
+
hashlocks: [c(a.hashlock)],
|
|
727
|
+
timelockRefund: l.timelockRefund,
|
|
728
|
+
pegInAmounts: [a.amount],
|
|
729
|
+
feeRate: l.feeRate,
|
|
730
|
+
numLocalChallengers: l.numLocalChallengers,
|
|
731
|
+
councilQuorum: l.councilQuorum,
|
|
732
|
+
councilSize: l.councilSize,
|
|
733
|
+
network: l.network
|
|
734
|
+
},
|
|
735
|
+
fundedPrePeginTxHex: c(a.unsignedPrePeginTxHex),
|
|
736
|
+
htlcVout: a.htlcVout,
|
|
737
|
+
refundFee: f,
|
|
738
|
+
// buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
|
|
739
|
+
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
740
|
+
// value would derive the wrong refund script leaf and yield an
|
|
741
|
+
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
742
|
+
hashlock: c(a.hashlock)
|
|
743
|
+
});
|
|
744
|
+
i == null || i.throwIfAborted();
|
|
745
|
+
const P = _(
|
|
746
|
+
a.depositorBtcPubkey,
|
|
747
|
+
He
|
|
748
|
+
), w = await u(g, P), x = Ke(w);
|
|
749
|
+
i == null || i.throwIfAborted();
|
|
750
|
+
try {
|
|
751
|
+
return await n(x);
|
|
752
|
+
} catch (h) {
|
|
753
|
+
throw h instanceof Error && Oe.test(h.message) ? new Re(t, h) : h;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
export {
|
|
757
|
+
Re as B,
|
|
758
|
+
O as C,
|
|
759
|
+
D as R,
|
|
760
|
+
je as a,
|
|
761
|
+
ye as b,
|
|
762
|
+
tt as c,
|
|
763
|
+
rt as d,
|
|
764
|
+
_e as e,
|
|
765
|
+
Se as f,
|
|
766
|
+
ot as g,
|
|
767
|
+
nt as h,
|
|
768
|
+
Ze as i,
|
|
769
|
+
at as j,
|
|
770
|
+
it as k,
|
|
771
|
+
st as l,
|
|
772
|
+
Je as r,
|
|
773
|
+
qe as s,
|
|
774
|
+
et as v,
|
|
775
|
+
N as w
|
|
776
|
+
};
|
|
777
|
+
//# sourceMappingURL=buildAndBroadcastRefund-D_QlvCsw.js.map
|