@babylonlabs-io/ts-sdk 0.7.0 → 0.8.1
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/{PayoutManager-BVmU4UsM.js → PayoutManager-6IBl1Fdt.js} +249 -244
- package/dist/PayoutManager-6IBl1Fdt.js.map +1 -0
- package/dist/PayoutManager-EZFN4Y4Z.cjs +2 -0
- package/dist/PayoutManager-EZFN4Y4Z.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +72 -70
- package/dist/index.js.map +1 -1
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +5 -3
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/__tests__/signOptions.test.d.ts +2 -0
- package/dist/shared/wallets/__tests__/signOptions.test.d.ts.map +1 -0
- package/dist/shared/wallets/index.d.ts +1 -0
- package/dist/shared/wallets/index.d.ts.map +1 -1
- package/dist/shared/wallets/signOptions.d.ts +15 -0
- package/dist/shared/wallets/signOptions.d.ts.map +1 -0
- package/dist/signOptions-Deg5lCoC.cjs +2 -0
- package/dist/signOptions-Deg5lCoC.cjs.map +1 -0
- package/dist/signOptions-Drwr3bXB.js +16 -0
- package/dist/signOptions-Drwr3bXB.js.map +1 -0
- package/dist/tbv/core/clients/mempool/__tests__/mempoolApi.test.d.ts +2 -0
- package/dist/tbv/core/clients/mempool/__tests__/mempoolApi.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +1 -2
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +1 -1
- package/dist/tbv/integrations/aave/clients/abis/{AaveIntegrationController.abi.json.d.ts → AaveIntegrationAdapter.abi.json.d.ts} +39 -2
- package/dist/tbv/integrations/aave/clients/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/clients/query.d.ts +3 -3
- package/dist/tbv/integrations/aave/clients/transaction.d.ts +19 -7
- package/dist/tbv/integrations/aave/clients/transaction.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/constants.d.ts +2 -0
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +6 -6
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +141 -94
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/tbv/integrations/aave/types.d.ts +1 -1
- package/dist/tbv/integrations/aave/utils/__tests__/seizureSimulation.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/seizureSimulation.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/index.d.ts +2 -0
- package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/seizureSimulation.d.ts +109 -0
- package/dist/tbv/integrations/aave/utils/seizureSimulation.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts +1 -0
- package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/PayoutManager-BVmU4UsM.js.map +0 -1
- package/dist/PayoutManager-Ba6cNgHC.cjs +0 -2
- package/dist/PayoutManager-Ba6cNgHC.cjs.map +0 -1
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import * as
|
|
5
|
-
import { script as
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var G = (n, t, e) => t in n ? Z(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var S = (n, t, e) => G(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import * as Q from "bitcoinjs-lib";
|
|
5
|
+
import { script as Y, Transaction as $, address as tt, Psbt as F } from "bitcoinjs-lib";
|
|
6
6
|
import { Buffer as g } from "buffer";
|
|
7
|
-
import { P as
|
|
8
|
-
import { createPublicClient as
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import { P as et, x as nt, D as q, M as R, B as rt, T as st, A as C, t as k, b as ot, z as at, a as it, d as ct, e as ut, f as lt, r as B, p as dt, w as W, g as N, h as K } from "./challengeAssert-D50t_Qyo.js";
|
|
8
|
+
import { createPublicClient as M, http as X, encodeFunctionData as pt, zeroAddress as ht } from "viem";
|
|
9
|
+
import { c as O } from "./signOptions-Drwr3bXB.js";
|
|
10
|
+
import { SINGLE_DEPOSIT_HTLC_VOUT as D } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
11
|
+
function ft(n, t, e) {
|
|
11
12
|
if (n.length === 0)
|
|
12
13
|
throw new Error("Insufficient funds: no UTXOs available");
|
|
13
|
-
const
|
|
14
|
+
const r = n.filter((a) => {
|
|
14
15
|
const u = g.from(a.scriptPubKey, "hex");
|
|
15
|
-
return !!
|
|
16
|
+
return !!Y.decompile(u);
|
|
16
17
|
});
|
|
17
|
-
if (
|
|
18
|
+
if (r.length === 0)
|
|
18
19
|
throw new Error(
|
|
19
20
|
"Insufficient funds: no valid UTXOs available (all have invalid scripts)"
|
|
20
21
|
);
|
|
21
|
-
const o = [...
|
|
22
|
+
const o = [...r].sort((a, u) => u.value - a.value), s = [];
|
|
22
23
|
let c = 0n, i = 0n;
|
|
23
24
|
for (const a of o) {
|
|
24
|
-
|
|
25
|
-
const u =
|
|
26
|
-
if (i = BigInt(Math.ceil(p * e)) + BigInt(
|
|
27
|
-
const
|
|
25
|
+
s.push(a), c += BigInt(a.value);
|
|
26
|
+
const u = s.length * et, l = 2 * R, p = u + l + st;
|
|
27
|
+
if (i = BigInt(Math.ceil(p * e)) + BigInt(nt(e)), c - t - i > q) {
|
|
28
|
+
const y = BigInt(
|
|
28
29
|
Math.ceil(R * e)
|
|
29
30
|
);
|
|
30
|
-
i +=
|
|
31
|
+
i += y;
|
|
31
32
|
}
|
|
32
33
|
if (c >= t + i) {
|
|
33
|
-
const
|
|
34
|
+
const y = c - t - i;
|
|
34
35
|
return {
|
|
35
|
-
selectedUTXOs:
|
|
36
|
+
selectedUTXOs: s,
|
|
36
37
|
totalValue: c,
|
|
37
38
|
fee: i,
|
|
38
|
-
changeAmount:
|
|
39
|
+
changeAmount: y
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -43,17 +44,17 @@ function lt(n, t, e) {
|
|
|
43
44
|
`Insufficient funds: need ${t + i} sats (${t} pegin + ${i} fee), have ${c} sats`
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
return n >
|
|
47
|
+
function Ht(n) {
|
|
48
|
+
return n > q;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
50
|
+
function Ft() {
|
|
51
|
+
return rt;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function _(n) {
|
|
53
54
|
const t = n.startsWith("0x") ? n.slice(2) : n;
|
|
54
|
-
return `0x${
|
|
55
|
+
return `0x${$.fromHex(t).getId()}`;
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function Ct(n, t, e) {
|
|
57
58
|
if (n.length === 0)
|
|
58
59
|
throw new Error("No input UTXOs provided for split transaction");
|
|
59
60
|
if (t.length === 0)
|
|
@@ -63,24 +64,24 @@ function Et(n, t, e) {
|
|
|
63
64
|
throw new Error(
|
|
64
65
|
`Invalid output amount for ${a.address}: ${a.amount} satoshis. Amount must be greater than zero.`
|
|
65
66
|
);
|
|
66
|
-
const
|
|
67
|
+
const r = C(e), o = new $();
|
|
67
68
|
o.version = 2;
|
|
68
69
|
for (const a of n) {
|
|
69
70
|
const u = g.from(a.txid, "hex").reverse();
|
|
70
71
|
o.addInput(u, a.vout);
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
+
const s = [];
|
|
73
74
|
for (let a = 0; a < t.length; a++) {
|
|
74
75
|
const u = t[a];
|
|
75
76
|
let l;
|
|
76
77
|
try {
|
|
77
|
-
l =
|
|
78
|
+
l = tt.toOutputScript(u.address, r);
|
|
78
79
|
} catch (p) {
|
|
79
80
|
throw new Error(
|
|
80
81
|
`Failed to decode address "${u.address}": ${p instanceof Error ? p.message : String(p)}`
|
|
81
82
|
);
|
|
82
83
|
}
|
|
83
|
-
o.addOutput(l, Number(u.amount)),
|
|
84
|
+
o.addOutput(l, Number(u.amount)), s.push({
|
|
84
85
|
txid: "",
|
|
85
86
|
// Will be set after txid calculation
|
|
86
87
|
vout: a,
|
|
@@ -89,38 +90,38 @@ function Et(n, t, e) {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
const c = o.toHex(), i = o.getId();
|
|
92
|
-
for (const a of
|
|
93
|
+
for (const a of s)
|
|
93
94
|
a.txid = i;
|
|
94
95
|
return {
|
|
95
96
|
txHex: c,
|
|
96
97
|
txid: i,
|
|
97
|
-
outputs:
|
|
98
|
+
outputs: s
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
if (o.setVersion(
|
|
101
|
+
function Ot(n, t, e) {
|
|
102
|
+
const r = $.fromHex(n), o = new F();
|
|
103
|
+
if (o.setVersion(r.version), o.setLocktime(r.locktime), !g.isBuffer(e) || e.length !== 32)
|
|
103
104
|
throw new Error(
|
|
104
105
|
`Invalid publicKeyNoCoord: expected 32-byte Buffer (x-only pubkey), got ${g.isBuffer(e) ? `${e.length}-byte Buffer` : typeof e}`
|
|
105
106
|
);
|
|
106
|
-
if (t.length !==
|
|
107
|
+
if (t.length !== r.ins.length)
|
|
107
108
|
throw new Error(
|
|
108
|
-
`UTXO count mismatch: transaction has ${
|
|
109
|
+
`UTXO count mismatch: transaction has ${r.ins.length} input${r.ins.length !== 1 ? "s" : ""}, but ${t.length} UTXO${t.length !== 1 ? "s were" : " was"} provided`
|
|
109
110
|
);
|
|
110
|
-
for (let
|
|
111
|
-
const c =
|
|
111
|
+
for (let s = 0; s < r.ins.length; s++) {
|
|
112
|
+
const c = r.ins[s], i = t[s];
|
|
112
113
|
if (!i)
|
|
113
|
-
throw new Error(`Missing UTXO data for input ${
|
|
114
|
+
throw new Error(`Missing UTXO data for input ${s}`);
|
|
114
115
|
const a = g.from(c.hash).reverse().toString("hex"), u = c.index;
|
|
115
116
|
if (i.txid !== a || i.vout !== u)
|
|
116
117
|
throw new Error(
|
|
117
|
-
`Input ${
|
|
118
|
+
`Input ${s} outpoint mismatch: transaction expects ${a}:${u}, but UTXO ${i.txid}:${i.vout} was provided. Ensure inputs array matches the order used in createSplitTransaction().`
|
|
118
119
|
);
|
|
119
120
|
const l = g.from(i.scriptPubKey, "hex");
|
|
120
121
|
if (!(l.length === 34 && l[0] === 81 && // OP_1 (witness version 1)
|
|
121
122
|
l[1] === 32))
|
|
122
123
|
throw new Error(
|
|
123
|
-
`Input ${
|
|
124
|
+
`Input ${s} must be P2TR (Taproot). createSplitTransactionPsbt() requires P2TR inputs because it uses tapInternalKey for Taproot signing. ScriptPubKey: ${i.scriptPubKey.substring(0, 20)}...`
|
|
124
125
|
);
|
|
125
126
|
const h = {
|
|
126
127
|
script: g.from(i.scriptPubKey, "hex"),
|
|
@@ -134,15 +135,15 @@ function St(n, t, e) {
|
|
|
134
135
|
tapInternalKey: e
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
|
-
for (const
|
|
138
|
+
for (const s of r.outs)
|
|
138
139
|
o.addOutput({
|
|
139
|
-
script:
|
|
140
|
-
value:
|
|
140
|
+
script: s.script,
|
|
141
|
+
value: s.value
|
|
141
142
|
});
|
|
142
143
|
return o.toHex();
|
|
143
144
|
}
|
|
144
145
|
var E = /* @__PURE__ */ ((n) => (n.P2PKH = "P2PKH", n.P2SH = "P2SH", n.P2WPKH = "P2WPKH", n.P2WSH = "P2WSH", n.P2TR = "P2TR", n.UNKNOWN = "UNKNOWN", n))(E || {});
|
|
145
|
-
function
|
|
146
|
+
function gt(n) {
|
|
146
147
|
const t = n.length;
|
|
147
148
|
return t === 25 && n[0] === 118 && // OP_DUP
|
|
148
149
|
n[1] === 169 && // OP_HASH160
|
|
@@ -155,9 +156,9 @@ function dt(n) {
|
|
|
155
156
|
n[1] === 32 ? "P2WSH" : t === 34 && n[0] === 81 && // OP_1
|
|
156
157
|
n[1] === 32 ? "P2TR" : "UNKNOWN";
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
-
const e = g.from(n.scriptPubKey, "hex"),
|
|
160
|
-
switch (
|
|
159
|
+
function yt(n, t) {
|
|
160
|
+
const e = g.from(n.scriptPubKey, "hex"), r = gt(e);
|
|
161
|
+
switch (r) {
|
|
161
162
|
case E.P2WPKH:
|
|
162
163
|
return {
|
|
163
164
|
witnessUtxo: {
|
|
@@ -191,15 +192,25 @@ function pt(n, t) {
|
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
194
|
default:
|
|
194
|
-
throw new Error(`Unsupported script type: ${
|
|
195
|
+
throw new Error(`Unsupported script type: ${r}`);
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
|
-
const
|
|
198
|
+
const bt = 21e6 * 1e8, L = 1e4;
|
|
199
|
+
function j(n) {
|
|
200
|
+
return Number.isInteger(n) && n > 0 && n <= bt;
|
|
201
|
+
}
|
|
202
|
+
function mt(n) {
|
|
203
|
+
return Number.isInteger(n) && n > 0 && n <= L;
|
|
204
|
+
}
|
|
205
|
+
function J(n, t) {
|
|
206
|
+
return !Number.isInteger(n) || n < 0 ? !1 : t === void 0 || n < t;
|
|
207
|
+
}
|
|
208
|
+
const Pt = {
|
|
198
209
|
mainnet: "https://mempool.space/api",
|
|
199
210
|
testnet: "https://mempool.space/testnet/api",
|
|
200
211
|
signet: "https://mempool.space/signet/api"
|
|
201
212
|
};
|
|
202
|
-
async function
|
|
213
|
+
async function I(n, t) {
|
|
203
214
|
try {
|
|
204
215
|
const e = await fetch(n, t);
|
|
205
216
|
if (!e.ok) {
|
|
@@ -208,13 +219,13 @@ async function S(n, t) {
|
|
|
208
219
|
`Mempool API error (${e.status}): ${o || e.statusText}`
|
|
209
220
|
);
|
|
210
221
|
}
|
|
211
|
-
const
|
|
212
|
-
return
|
|
222
|
+
const r = e.headers.get("content-type");
|
|
223
|
+
return r != null && r.includes("application/json") ? await e.json() : await e.text();
|
|
213
224
|
} catch (e) {
|
|
214
225
|
throw e instanceof Error ? new Error(`Failed to fetch from mempool API: ${e.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
215
226
|
}
|
|
216
227
|
}
|
|
217
|
-
async function
|
|
228
|
+
async function xt(n, t) {
|
|
218
229
|
try {
|
|
219
230
|
const e = await fetch(`${t}/tx`, {
|
|
220
231
|
method: "POST",
|
|
@@ -225,14 +236,14 @@ async function yt(n, t) {
|
|
|
225
236
|
});
|
|
226
237
|
if (!e.ok) {
|
|
227
238
|
const o = await e.text();
|
|
228
|
-
let
|
|
239
|
+
let s;
|
|
229
240
|
try {
|
|
230
|
-
|
|
241
|
+
s = JSON.parse(o).message;
|
|
231
242
|
} catch {
|
|
232
|
-
|
|
243
|
+
s = o;
|
|
233
244
|
}
|
|
234
245
|
throw new Error(
|
|
235
|
-
|
|
246
|
+
s || `Failed to broadcast transaction: ${e.statusText}`
|
|
236
247
|
);
|
|
237
248
|
}
|
|
238
249
|
return await e.text();
|
|
@@ -240,16 +251,16 @@ async function yt(n, t) {
|
|
|
240
251
|
throw e instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${e.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
|
-
async function
|
|
244
|
-
return
|
|
254
|
+
async function wt(n, t) {
|
|
255
|
+
return I(`${t}/tx/${n}`);
|
|
245
256
|
}
|
|
246
|
-
async function
|
|
257
|
+
async function Ut(n, t) {
|
|
247
258
|
try {
|
|
248
259
|
const e = await fetch(`${t}/tx/${n}/hex`);
|
|
249
260
|
if (!e.ok) {
|
|
250
|
-
const
|
|
261
|
+
const r = await e.text();
|
|
251
262
|
throw new Error(
|
|
252
|
-
`Mempool API error (${e.status}): ${
|
|
263
|
+
`Mempool API error (${e.status}): ${r || e.statusText}`
|
|
253
264
|
);
|
|
254
265
|
}
|
|
255
266
|
return await e.text();
|
|
@@ -257,13 +268,15 @@ async function It(n, t) {
|
|
|
257
268
|
throw e instanceof Error ? new Error(`Failed to get transaction hex for ${n}: ${e.message}`) : new Error(`Failed to get transaction hex for ${n}: Unknown error`);
|
|
258
269
|
}
|
|
259
270
|
}
|
|
260
|
-
async function
|
|
261
|
-
const
|
|
262
|
-
if (t
|
|
271
|
+
async function Tt(n, t, e) {
|
|
272
|
+
const r = await wt(n, e);
|
|
273
|
+
if (!J(t, r.vout.length))
|
|
263
274
|
throw new Error(
|
|
264
|
-
`Invalid vout ${t} for transaction ${n} (has ${
|
|
275
|
+
`Invalid vout ${t} for transaction ${n} (has ${r.vout.length} outputs)`
|
|
265
276
|
);
|
|
266
|
-
const o =
|
|
277
|
+
const o = r.vout[t];
|
|
278
|
+
if (!j(o.value))
|
|
279
|
+
throw new Error(`Invalid UTXO value ${o.value} for ${n}:${t}`);
|
|
267
280
|
return {
|
|
268
281
|
txid: n,
|
|
269
282
|
vout: t,
|
|
@@ -271,19 +284,27 @@ async function ft(n, t, e) {
|
|
|
271
284
|
scriptPubKey: o.scriptpubkey
|
|
272
285
|
};
|
|
273
286
|
}
|
|
274
|
-
async function
|
|
287
|
+
async function At(n, t) {
|
|
275
288
|
try {
|
|
276
|
-
const e = await
|
|
277
|
-
if (!
|
|
289
|
+
const e = await I(`${t}/address/${n}/utxo`), r = await I(`${t}/v1/validate-address/${n}`);
|
|
290
|
+
if (!r.isvalid)
|
|
278
291
|
throw new Error(
|
|
279
292
|
`Invalid Bitcoin address: ${n}. Mempool API validation failed.`
|
|
280
293
|
);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
294
|
+
for (const s of e) {
|
|
295
|
+
if (!J(s.vout))
|
|
296
|
+
throw new Error(`Invalid vout ${s.vout} for ${s.txid}`);
|
|
297
|
+
if (!j(s.value))
|
|
298
|
+
throw new Error(
|
|
299
|
+
`Invalid UTXO value ${s.value} for ${s.txid}:${s.vout}`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
return e.sort((s, c) => c.value - s.value).map((s) => ({
|
|
303
|
+
txid: s.txid,
|
|
304
|
+
vout: s.vout,
|
|
305
|
+
value: s.value,
|
|
306
|
+
scriptPubKey: r.scriptPubKey,
|
|
307
|
+
confirmed: s.status.confirmed
|
|
287
308
|
}));
|
|
288
309
|
} catch (e) {
|
|
289
310
|
throw e instanceof Error ? new Error(
|
|
@@ -293,26 +314,37 @@ async function Bt(n, t) {
|
|
|
293
314
|
);
|
|
294
315
|
}
|
|
295
316
|
}
|
|
296
|
-
function
|
|
297
|
-
return
|
|
317
|
+
function Vt(n) {
|
|
318
|
+
return Pt[n];
|
|
298
319
|
}
|
|
299
|
-
async function
|
|
300
|
-
return
|
|
320
|
+
async function Rt(n, t) {
|
|
321
|
+
return I(`${t}/address/${n}/txs`);
|
|
301
322
|
}
|
|
302
|
-
async function
|
|
323
|
+
async function Wt(n) {
|
|
303
324
|
const t = await fetch(`${n}/v1/fees/recommended`);
|
|
304
325
|
if (!t.ok)
|
|
305
326
|
throw new Error(
|
|
306
327
|
`Failed to fetch network fees: ${t.status} ${t.statusText}`
|
|
307
328
|
);
|
|
308
|
-
const e = await t.json()
|
|
309
|
-
|
|
329
|
+
const e = await t.json(), r = [
|
|
330
|
+
"fastestFee",
|
|
331
|
+
"halfHourFee",
|
|
332
|
+
"hourFee",
|
|
333
|
+
"economyFee",
|
|
334
|
+
"minimumFee"
|
|
335
|
+
];
|
|
336
|
+
for (const o of r)
|
|
337
|
+
if (!mt(e[o]))
|
|
338
|
+
throw new Error(
|
|
339
|
+
`Invalid fee rate ${o}=${e[o]} from mempool API: expected a positive number ≤ ${L}`
|
|
340
|
+
);
|
|
341
|
+
if (e.minimumFee > e.economyFee || e.economyFee > e.hourFee || e.hourFee > e.halfHourFee || e.halfHourFee > e.fastestFee)
|
|
310
342
|
throw new Error(
|
|
311
|
-
|
|
343
|
+
`Fee rate ordering violation from mempool API: expected minimumFee (${e.minimumFee}) <= economyFee (${e.economyFee}) <= hourFee (${e.hourFee}) <= halfHourFee (${e.halfHourFee}) <= fastestFee (${e.fastestFee}).`
|
|
312
344
|
);
|
|
313
345
|
return e;
|
|
314
346
|
}
|
|
315
|
-
const
|
|
347
|
+
const H = [
|
|
316
348
|
{
|
|
317
349
|
type: "function",
|
|
318
350
|
name: "submitPeginRequest",
|
|
@@ -571,7 +603,7 @@ const $ = [
|
|
|
571
603
|
name: "PeginSignaturesIncomplete",
|
|
572
604
|
inputs: []
|
|
573
605
|
}
|
|
574
|
-
],
|
|
606
|
+
], P = {
|
|
575
607
|
// VaultAlreadyExists()
|
|
576
608
|
"0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
|
|
577
609
|
// ScriptPubKeyMismatch() - taproot output doesn't match expected script
|
|
@@ -601,68 +633,68 @@ const $ = [
|
|
|
601
633
|
// InvalidPeginFee(uint256,uint256)
|
|
602
634
|
"0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction."
|
|
603
635
|
};
|
|
604
|
-
function
|
|
636
|
+
function U(n) {
|
|
605
637
|
if (!n || typeof n != "object") return;
|
|
606
638
|
const t = n;
|
|
607
639
|
if (typeof t.data == "string" && t.data.startsWith("0x"))
|
|
608
640
|
return t.data;
|
|
609
641
|
if (typeof t.details == "string" && t.details.startsWith("0x"))
|
|
610
642
|
return t.details;
|
|
611
|
-
let e = t.cause,
|
|
643
|
+
let e = t.cause, r = 0;
|
|
612
644
|
const o = 5;
|
|
613
|
-
for (; e && typeof e == "object" &&
|
|
645
|
+
for (; e && typeof e == "object" && r < o; ) {
|
|
614
646
|
const i = e;
|
|
615
647
|
if (typeof i.data == "string" && i.data.startsWith("0x"))
|
|
616
648
|
return i.data;
|
|
617
|
-
e = i.cause,
|
|
649
|
+
e = i.cause, r++;
|
|
618
650
|
}
|
|
619
651
|
const c = (typeof t.message == "string" ? t.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
|
|
620
652
|
if (c)
|
|
621
653
|
return c[1];
|
|
622
654
|
}
|
|
623
|
-
function
|
|
624
|
-
const t =
|
|
655
|
+
function Nt(n) {
|
|
656
|
+
const t = U(n);
|
|
625
657
|
if (t) {
|
|
626
658
|
const e = t.substring(0, 10);
|
|
627
|
-
return
|
|
659
|
+
return P[t] ?? P[e];
|
|
628
660
|
}
|
|
629
661
|
}
|
|
630
|
-
function
|
|
631
|
-
const t =
|
|
662
|
+
function Kt(n) {
|
|
663
|
+
const t = U(n);
|
|
632
664
|
if (t === void 0) return !1;
|
|
633
665
|
const e = t.substring(0, 10);
|
|
634
|
-
return t in
|
|
666
|
+
return t in P || e in P;
|
|
635
667
|
}
|
|
636
668
|
function z(n) {
|
|
637
669
|
console.error("[Contract Error] Raw error:", n);
|
|
638
|
-
const t =
|
|
670
|
+
const t = U(n);
|
|
639
671
|
if (console.error("[Contract Error] Extracted error data:", t), t) {
|
|
640
|
-
const
|
|
672
|
+
const r = t.substring(0, 10), o = P[t] ?? P[r];
|
|
641
673
|
if (o)
|
|
642
674
|
throw console.error("[Contract Error] Known error:", o), new Error(o);
|
|
643
675
|
}
|
|
644
676
|
const e = (n == null ? void 0 : n.message) || "";
|
|
645
677
|
if (e.includes("gas limit too high") || e.includes("21000000") || e.includes("Internal JSON-RPC error")) {
|
|
646
|
-
const
|
|
678
|
+
const r = t ? ` (error code: ${t})` : "";
|
|
647
679
|
throw console.error(
|
|
648
680
|
"[Contract Error] Transaction rejected. Error code:",
|
|
649
681
|
t,
|
|
650
682
|
"Message:",
|
|
651
683
|
e
|
|
652
684
|
), new Error(
|
|
653
|
-
`Transaction failed: The contract rejected this transaction${
|
|
685
|
+
`Transaction failed: The contract rejected this transaction${r}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`
|
|
654
686
|
);
|
|
655
687
|
}
|
|
656
688
|
throw n instanceof Error ? (console.error("[Contract Error] Unhandled error:", n.message), n) : new Error(`Contract call failed: ${String(n)}`);
|
|
657
689
|
}
|
|
658
|
-
class
|
|
690
|
+
class Mt {
|
|
659
691
|
/**
|
|
660
692
|
* Creates a new PeginManager instance.
|
|
661
693
|
*
|
|
662
694
|
* @param config - Manager configuration including wallets and contract addresses
|
|
663
695
|
*/
|
|
664
696
|
constructor(t) {
|
|
665
|
-
|
|
697
|
+
S(this, "config");
|
|
666
698
|
this.config = t;
|
|
667
699
|
}
|
|
668
700
|
/**
|
|
@@ -686,15 +718,15 @@ class Ft {
|
|
|
686
718
|
* @throws Error if wallet operations fail or insufficient funds
|
|
687
719
|
*/
|
|
688
720
|
async preparePegin(t) {
|
|
689
|
-
const e = await this.config.btcWallet.getPublicKeyHex(),
|
|
721
|
+
const e = await this.config.btcWallet.getPublicKeyHex(), r = e.length === 66 ? e.slice(2) : e, o = k(t.vaultProviderBtcPubkey), s = t.vaultKeeperBtcPubkeys.map(k), c = t.universalChallengerBtcPubkeys.map(k);
|
|
690
722
|
if (t.hashlocks.length !== 1)
|
|
691
723
|
throw new Error(
|
|
692
724
|
"hashlocks must contain exactly one entry (batched deposits not yet supported)"
|
|
693
725
|
);
|
|
694
|
-
const i =
|
|
695
|
-
depositorPubkey:
|
|
726
|
+
const i = s.length, a = {
|
|
727
|
+
depositorPubkey: r,
|
|
696
728
|
vaultProviderPubkey: o,
|
|
697
|
-
vaultKeeperPubkeys:
|
|
729
|
+
vaultKeeperPubkeys: s,
|
|
698
730
|
universalChallengerPubkeys: c,
|
|
699
731
|
hashlocks: t.hashlocks,
|
|
700
732
|
timelockRefund: t.timelockRefund,
|
|
@@ -704,56 +736,47 @@ class Ft {
|
|
|
704
736
|
councilQuorum: t.councilQuorum,
|
|
705
737
|
councilSize: t.councilSize,
|
|
706
738
|
network: this.config.btcNetwork
|
|
707
|
-
}, u = await
|
|
739
|
+
}, u = await ot(a), l = ft(
|
|
708
740
|
[...t.availableUTXOs],
|
|
709
741
|
u.totalOutputValue,
|
|
710
742
|
t.mempoolFeeRate
|
|
711
|
-
), p =
|
|
743
|
+
), p = C(this.config.btcNetwork), h = at({
|
|
712
744
|
unfundedTxHex: u.psbtHex,
|
|
713
745
|
selectedUTXOs: l.selectedUTXOs,
|
|
714
746
|
changeAddress: t.changeAddress,
|
|
715
747
|
changeAmount: l.changeAmount,
|
|
716
748
|
network: p
|
|
717
|
-
}),
|
|
749
|
+
}), y = k(_(h)), m = await it({
|
|
718
750
|
prePeginParams: a,
|
|
719
751
|
timelockPegin: t.timelockPegin,
|
|
720
752
|
fundedPrePeginTxHex: h,
|
|
721
|
-
htlcVout:
|
|
722
|
-
}), x = await
|
|
723
|
-
peginTxHex:
|
|
753
|
+
htlcVout: D
|
|
754
|
+
}), x = await ct({
|
|
755
|
+
peginTxHex: m.txHex,
|
|
724
756
|
fundedPrePeginTxHex: h,
|
|
725
|
-
depositorPubkey:
|
|
757
|
+
depositorPubkey: r,
|
|
726
758
|
vaultProviderPubkey: o,
|
|
727
|
-
vaultKeeperPubkeys:
|
|
759
|
+
vaultKeeperPubkeys: s,
|
|
728
760
|
universalChallengerPubkeys: c,
|
|
729
761
|
hashlock: t.hashlocks[0],
|
|
730
762
|
timelockRefund: t.timelockRefund,
|
|
731
763
|
network: this.config.btcNetwork
|
|
732
764
|
}), d = await this.config.btcWallet.signPsbt(
|
|
733
765
|
x.psbtHex,
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
signInputs: [
|
|
737
|
-
{
|
|
738
|
-
index: 0,
|
|
739
|
-
publicKey: e,
|
|
740
|
-
disableTweakSigner: !0
|
|
741
|
-
}
|
|
742
|
-
]
|
|
743
|
-
}
|
|
744
|
-
), y = at(
|
|
766
|
+
O(e, 1)
|
|
767
|
+
), f = ut(
|
|
745
768
|
d,
|
|
746
|
-
|
|
747
|
-
), b =
|
|
769
|
+
r
|
|
770
|
+
), b = lt(d);
|
|
748
771
|
return {
|
|
749
772
|
fundedPrePeginTxHex: h,
|
|
750
773
|
htlcValue: u.htlcValue,
|
|
751
774
|
signedPeginInputPsbtHex: d,
|
|
752
|
-
peginInputSignature:
|
|
753
|
-
vaultScriptPubKey:
|
|
775
|
+
peginInputSignature: f,
|
|
776
|
+
vaultScriptPubKey: m.vaultScriptPubKey,
|
|
754
777
|
peginTxHex: b,
|
|
755
|
-
prePeginTxid:
|
|
756
|
-
peginTxid:
|
|
778
|
+
prePeginTxid: y,
|
|
779
|
+
peginTxid: m.txid,
|
|
757
780
|
selectedUTXOs: l.selectedUTXOs,
|
|
758
781
|
fee: l.fee,
|
|
759
782
|
changeAmount: l.changeAmount
|
|
@@ -775,12 +798,12 @@ class Ft {
|
|
|
775
798
|
* @throws Error if signing or broadcasting fails
|
|
776
799
|
*/
|
|
777
800
|
async signAndBroadcast(t) {
|
|
778
|
-
const { fundedPrePeginTxHex: e, depositorBtcPubkey:
|
|
779
|
-
if (
|
|
801
|
+
const { fundedPrePeginTxHex: e, depositorBtcPubkey: r } = t, o = e.startsWith("0x") ? e.slice(2) : e, s = $.fromHex(o);
|
|
802
|
+
if (s.ins.length === 0)
|
|
780
803
|
throw new Error("Transaction has no inputs");
|
|
781
|
-
const c = new
|
|
782
|
-
c.setVersion(
|
|
783
|
-
const i =
|
|
804
|
+
const c = new F();
|
|
805
|
+
c.setVersion(s.version), c.setLocktime(s.locktime);
|
|
806
|
+
const i = r.startsWith("0x") ? r.slice(2) : r;
|
|
784
807
|
if (i.length !== 64 || !/^[0-9a-fA-F]+$/.test(i))
|
|
785
808
|
throw new Error(
|
|
786
809
|
"Invalid depositorBtcPubkey: expected 64 hex characters (x-only pubkey)"
|
|
@@ -790,20 +813,20 @@ class Ft {
|
|
|
790
813
|
throw new Error(
|
|
791
814
|
`Invalid depositorBtcPubkey length: expected 32 bytes, got ${a.length}`
|
|
792
815
|
);
|
|
793
|
-
const u = this.config.mempoolApiUrl, l =
|
|
794
|
-
const
|
|
795
|
-
return
|
|
816
|
+
const u = this.config.mempoolApiUrl, l = s.ins.map((d) => {
|
|
817
|
+
const f = g.from(d.hash).reverse().toString("hex"), b = d.index;
|
|
818
|
+
return Tt(f, b, u).then((w) => ({
|
|
796
819
|
input: d,
|
|
797
820
|
utxoData: w,
|
|
798
|
-
txid:
|
|
821
|
+
txid: f,
|
|
799
822
|
vout: b
|
|
800
823
|
}));
|
|
801
824
|
}), p = await Promise.all(l);
|
|
802
|
-
for (const { input: d, utxoData:
|
|
803
|
-
const T =
|
|
825
|
+
for (const { input: d, utxoData: f, txid: b, vout: w } of p) {
|
|
826
|
+
const T = yt(
|
|
804
827
|
{
|
|
805
|
-
value:
|
|
806
|
-
scriptPubKey:
|
|
828
|
+
value: f.value,
|
|
829
|
+
scriptPubKey: f.scriptPubKey
|
|
807
830
|
},
|
|
808
831
|
a
|
|
809
832
|
);
|
|
@@ -814,24 +837,24 @@ class Ft {
|
|
|
814
837
|
...T
|
|
815
838
|
});
|
|
816
839
|
}
|
|
817
|
-
for (const d of
|
|
840
|
+
for (const d of s.outs)
|
|
818
841
|
c.addOutput({
|
|
819
842
|
script: d.script,
|
|
820
843
|
value: d.value
|
|
821
844
|
});
|
|
822
|
-
const h = await this.config.btcWallet.signPsbt(c.toHex()),
|
|
845
|
+
const h = await this.config.btcWallet.signPsbt(c.toHex()), y = F.fromHex(h);
|
|
823
846
|
try {
|
|
824
|
-
|
|
847
|
+
y.finalizeAllInputs();
|
|
825
848
|
} catch (d) {
|
|
826
|
-
if (!
|
|
849
|
+
if (!y.data.inputs.every(
|
|
827
850
|
(b) => b.finalScriptWitness || b.finalScriptSig
|
|
828
851
|
))
|
|
829
852
|
throw new Error(
|
|
830
853
|
`PSBT finalization failed and wallet did not auto-finalize: ${d}`
|
|
831
854
|
);
|
|
832
855
|
}
|
|
833
|
-
const
|
|
834
|
-
return await
|
|
856
|
+
const m = y.extractTransaction().toHex();
|
|
857
|
+
return await xt(m, u);
|
|
835
858
|
}
|
|
836
859
|
/**
|
|
837
860
|
* Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
|
|
@@ -853,9 +876,9 @@ class Ft {
|
|
|
853
876
|
async registerPeginOnChain(t) {
|
|
854
877
|
const {
|
|
855
878
|
depositorBtcPubkey: e,
|
|
856
|
-
unsignedPrePeginTx:
|
|
879
|
+
unsignedPrePeginTx: r,
|
|
857
880
|
depositorSignedPeginTx: o,
|
|
858
|
-
vaultProvider:
|
|
881
|
+
vaultProvider: s,
|
|
859
882
|
hashlock: c,
|
|
860
883
|
onPopSigned: i,
|
|
861
884
|
depositorPayoutBtcAddress: a,
|
|
@@ -869,51 +892,51 @@ class Ft {
|
|
|
869
892
|
l
|
|
870
893
|
);
|
|
871
894
|
i && await i();
|
|
872
|
-
const
|
|
895
|
+
const y = B(e), m = B(r), x = B(o), d = await this.resolvePayoutScriptPubKey(
|
|
873
896
|
a
|
|
874
|
-
),
|
|
875
|
-
if (await this.checkVaultExists(
|
|
897
|
+
), f = _(x);
|
|
898
|
+
if (await this.checkVaultExists(f))
|
|
876
899
|
throw new Error(
|
|
877
|
-
`Vault already exists for this transaction (ID: ${
|
|
900
|
+
`Vault already exists for this transaction (ID: ${f}). Vault IDs are deterministically derived from the unsigned Bitcoin transaction, so using the same UTXOs and amount will always produce the same vault. To create a new vault, please use different UTXOs or a different amount to generate a unique transaction.`
|
|
878
901
|
);
|
|
879
|
-
const w =
|
|
902
|
+
const w = M({
|
|
880
903
|
chain: this.config.ethChain,
|
|
881
|
-
transport:
|
|
904
|
+
transport: X()
|
|
882
905
|
});
|
|
883
906
|
let T;
|
|
884
907
|
try {
|
|
885
908
|
T = await w.readContract({
|
|
886
909
|
address: this.config.vaultContracts.btcVaultRegistry,
|
|
887
|
-
abi:
|
|
910
|
+
abi: H,
|
|
888
911
|
functionName: "getPegInFee",
|
|
889
|
-
args: [
|
|
912
|
+
args: [s]
|
|
890
913
|
});
|
|
891
914
|
} catch {
|
|
892
915
|
throw new Error(
|
|
893
916
|
"Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct."
|
|
894
917
|
);
|
|
895
918
|
}
|
|
896
|
-
const
|
|
897
|
-
abi:
|
|
919
|
+
const A = pt({
|
|
920
|
+
abi: H,
|
|
898
921
|
functionName: "submitPeginRequest",
|
|
899
922
|
args: [
|
|
900
923
|
p,
|
|
901
|
-
|
|
924
|
+
y,
|
|
902
925
|
h,
|
|
903
|
-
|
|
926
|
+
m,
|
|
904
927
|
x,
|
|
905
|
-
|
|
928
|
+
s,
|
|
906
929
|
c,
|
|
907
|
-
|
|
930
|
+
D,
|
|
908
931
|
d,
|
|
909
932
|
u
|
|
910
933
|
]
|
|
911
934
|
});
|
|
912
|
-
let
|
|
935
|
+
let V;
|
|
913
936
|
try {
|
|
914
|
-
|
|
937
|
+
V = await w.estimateGas({
|
|
915
938
|
to: this.config.vaultContracts.btcVaultRegistry,
|
|
916
|
-
data:
|
|
939
|
+
data: A,
|
|
917
940
|
value: T,
|
|
918
941
|
account: this.config.ethWallet.account.address
|
|
919
942
|
});
|
|
@@ -924,13 +947,13 @@ class Ft {
|
|
|
924
947
|
return {
|
|
925
948
|
ethTxHash: await this.config.ethWallet.sendTransaction({
|
|
926
949
|
to: this.config.vaultContracts.btcVaultRegistry,
|
|
927
|
-
data:
|
|
950
|
+
data: A,
|
|
928
951
|
value: T,
|
|
929
952
|
account: this.config.ethWallet.account,
|
|
930
953
|
chain: this.config.ethChain,
|
|
931
|
-
gas:
|
|
954
|
+
gas: V
|
|
932
955
|
}),
|
|
933
|
-
vaultId:
|
|
956
|
+
vaultId: f,
|
|
934
957
|
btcPopSignature: h
|
|
935
958
|
};
|
|
936
959
|
} catch (v) {
|
|
@@ -945,15 +968,15 @@ class Ft {
|
|
|
945
968
|
*/
|
|
946
969
|
async checkVaultExists(t) {
|
|
947
970
|
try {
|
|
948
|
-
return (await
|
|
971
|
+
return (await M({
|
|
949
972
|
chain: this.config.ethChain,
|
|
950
|
-
transport:
|
|
973
|
+
transport: X()
|
|
951
974
|
}).readContract({
|
|
952
975
|
address: this.config.vaultContracts.btcVaultRegistry,
|
|
953
|
-
abi:
|
|
976
|
+
abi: H,
|
|
954
977
|
functionName: "getBTCVault",
|
|
955
978
|
args: [t]
|
|
956
|
-
})).depositor !==
|
|
979
|
+
})).depositor !== ht;
|
|
957
980
|
} catch {
|
|
958
981
|
return !1;
|
|
959
982
|
}
|
|
@@ -972,7 +995,7 @@ class Ft {
|
|
|
972
995
|
else {
|
|
973
996
|
e = await this.config.btcWallet.getAddress();
|
|
974
997
|
const o = await this.config.btcWallet.getPublicKeyHex();
|
|
975
|
-
if (!
|
|
998
|
+
if (!dt(
|
|
976
999
|
e,
|
|
977
1000
|
o,
|
|
978
1001
|
this.config.btcNetwork
|
|
@@ -981,9 +1004,9 @@ class Ft {
|
|
|
981
1004
|
"The BTC address from your wallet does not match the wallet's public key. Please ensure your wallet is using a supported address type (Taproot or Native SegWit)."
|
|
982
1005
|
);
|
|
983
1006
|
}
|
|
984
|
-
const
|
|
1007
|
+
const r = C(this.config.btcNetwork);
|
|
985
1008
|
try {
|
|
986
|
-
return `0x${
|
|
1009
|
+
return `0x${Q.address.toOutputScript(e, r).toString("hex")}`;
|
|
987
1010
|
} catch {
|
|
988
1011
|
throw new Error(
|
|
989
1012
|
`Invalid BTC payout address: "${e}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`
|
|
@@ -999,11 +1022,11 @@ class Ft {
|
|
|
999
1022
|
async resolvePopSignature(t, e) {
|
|
1000
1023
|
if (e)
|
|
1001
1024
|
return e;
|
|
1002
|
-
const
|
|
1025
|
+
const r = this.config.vaultContracts.btcVaultRegistry, o = `${t.toLowerCase()}:${this.config.ethChain.id}:pegin:${r.toLowerCase()}`, s = await this.config.btcWallet.signMessage(
|
|
1003
1026
|
o,
|
|
1004
1027
|
"bip322-simple"
|
|
1005
1028
|
);
|
|
1006
|
-
return
|
|
1029
|
+
return s.startsWith("0x") ? s : `0x${g.from(s, "base64").toString("hex")}`;
|
|
1007
1030
|
}
|
|
1008
1031
|
/**
|
|
1009
1032
|
* Gets the configured Bitcoin network.
|
|
@@ -1022,14 +1045,14 @@ class Ft {
|
|
|
1022
1045
|
return this.config.vaultContracts.btcVaultRegistry;
|
|
1023
1046
|
}
|
|
1024
1047
|
}
|
|
1025
|
-
class
|
|
1048
|
+
class Xt {
|
|
1026
1049
|
/**
|
|
1027
1050
|
* Creates a new PayoutManager instance.
|
|
1028
1051
|
*
|
|
1029
1052
|
* @param config - Manager configuration including wallet
|
|
1030
1053
|
*/
|
|
1031
1054
|
constructor(t) {
|
|
1032
|
-
|
|
1055
|
+
S(this, "config");
|
|
1033
1056
|
this.config = t;
|
|
1034
1057
|
}
|
|
1035
1058
|
/**
|
|
@@ -1055,35 +1078,26 @@ class At {
|
|
|
1055
1078
|
* @throws Error if wallet operations fail or signature extraction fails
|
|
1056
1079
|
*/
|
|
1057
1080
|
async signPayoutTransaction(t) {
|
|
1058
|
-
const e = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey:
|
|
1081
|
+
const e = await this.config.btcWallet.getPublicKeyHex(), { depositorPubkey: r } = W(
|
|
1059
1082
|
e,
|
|
1060
1083
|
t.depositorBtcPubkey
|
|
1061
|
-
), o = await
|
|
1084
|
+
), o = await N({
|
|
1062
1085
|
payoutTxHex: t.payoutTxHex,
|
|
1063
1086
|
peginTxHex: t.peginTxHex,
|
|
1064
1087
|
assertTxHex: t.assertTxHex,
|
|
1065
|
-
depositorBtcPubkey:
|
|
1088
|
+
depositorBtcPubkey: r,
|
|
1066
1089
|
vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
|
|
1067
1090
|
vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
|
|
1068
1091
|
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
1069
1092
|
timelockPegin: t.timelockPegin,
|
|
1070
1093
|
network: this.config.network
|
|
1071
|
-
}),
|
|
1094
|
+
}), s = await this.config.btcWallet.signPsbt(
|
|
1072
1095
|
o.psbtHex,
|
|
1073
|
-
|
|
1074
|
-
autoFinalized: !1,
|
|
1075
|
-
signInputs: [
|
|
1076
|
-
{
|
|
1077
|
-
index: 0,
|
|
1078
|
-
publicKey: e,
|
|
1079
|
-
disableTweakSigner: !0
|
|
1080
|
-
}
|
|
1081
|
-
]
|
|
1082
|
-
}
|
|
1096
|
+
O(e, 1)
|
|
1083
1097
|
);
|
|
1084
1098
|
return {
|
|
1085
|
-
signature: K(
|
|
1086
|
-
depositorBtcPubkey:
|
|
1099
|
+
signature: K(s, r),
|
|
1100
|
+
depositorBtcPubkey: r
|
|
1087
1101
|
};
|
|
1088
1102
|
}
|
|
1089
1103
|
/**
|
|
@@ -1116,14 +1130,14 @@ class At {
|
|
|
1116
1130
|
throw new Error(
|
|
1117
1131
|
"Wallet does not support batch signing (signPsbts method not available)"
|
|
1118
1132
|
);
|
|
1119
|
-
const e = await this.config.btcWallet.getPublicKeyHex(),
|
|
1133
|
+
const e = await this.config.btcWallet.getPublicKeyHex(), r = [], o = [], s = [];
|
|
1120
1134
|
for (const a of t) {
|
|
1121
|
-
const { depositorPubkey: u } =
|
|
1135
|
+
const { depositorPubkey: u } = W(
|
|
1122
1136
|
e,
|
|
1123
1137
|
a.depositorBtcPubkey
|
|
1124
1138
|
);
|
|
1125
|
-
|
|
1126
|
-
const l = await
|
|
1139
|
+
s.push(u);
|
|
1140
|
+
const l = await N({
|
|
1127
1141
|
payoutTxHex: a.payoutTxHex,
|
|
1128
1142
|
peginTxHex: a.peginTxHex,
|
|
1129
1143
|
assertTxHex: a.assertTxHex,
|
|
@@ -1134,19 +1148,10 @@ class At {
|
|
|
1134
1148
|
timelockPegin: a.timelockPegin,
|
|
1135
1149
|
network: this.config.network
|
|
1136
1150
|
});
|
|
1137
|
-
|
|
1138
|
-
autoFinalized: !1,
|
|
1139
|
-
signInputs: [
|
|
1140
|
-
{
|
|
1141
|
-
index: 0,
|
|
1142
|
-
publicKey: e,
|
|
1143
|
-
disableTweakSigner: !0
|
|
1144
|
-
}
|
|
1145
|
-
]
|
|
1146
|
-
});
|
|
1151
|
+
r.push(l.psbtHex), o.push(O(e, 1));
|
|
1147
1152
|
}
|
|
1148
1153
|
const c = await this.config.btcWallet.signPsbts(
|
|
1149
|
-
|
|
1154
|
+
r,
|
|
1150
1155
|
o
|
|
1151
1156
|
);
|
|
1152
1157
|
if (c.length !== t.length)
|
|
@@ -1155,7 +1160,7 @@ class At {
|
|
|
1155
1160
|
);
|
|
1156
1161
|
const i = [];
|
|
1157
1162
|
for (let a = 0; a < t.length; a++) {
|
|
1158
|
-
const u =
|
|
1163
|
+
const u = s[a], l = K(
|
|
1159
1164
|
c[a],
|
|
1160
1165
|
u
|
|
1161
1166
|
);
|
|
@@ -1169,30 +1174,30 @@ class At {
|
|
|
1169
1174
|
}
|
|
1170
1175
|
export {
|
|
1171
1176
|
E as B,
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1177
|
+
P as C,
|
|
1178
|
+
Pt as M,
|
|
1179
|
+
Mt as P,
|
|
1180
|
+
Ht as a,
|
|
1181
|
+
Ct as b,
|
|
1182
|
+
_ as c,
|
|
1183
|
+
Ot as d,
|
|
1184
|
+
gt as e,
|
|
1185
|
+
yt as f,
|
|
1186
|
+
Ft as g,
|
|
1187
|
+
Xt as h,
|
|
1188
|
+
Rt as i,
|
|
1189
|
+
At as j,
|
|
1190
|
+
Vt as k,
|
|
1191
|
+
Wt as l,
|
|
1192
|
+
Ut as m,
|
|
1193
|
+
wt as n,
|
|
1194
|
+
Tt as o,
|
|
1195
|
+
xt as p,
|
|
1196
|
+
H as q,
|
|
1197
|
+
U as r,
|
|
1198
|
+
ft as s,
|
|
1199
|
+
Nt as t,
|
|
1200
|
+
Kt as u,
|
|
1196
1201
|
z as v
|
|
1197
1202
|
};
|
|
1198
|
-
//# sourceMappingURL=PayoutManager-
|
|
1203
|
+
//# sourceMappingURL=PayoutManager-6IBl1Fdt.js.map
|