@babylonlabs-io/ts-sdk 0.52.0 → 0.55.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-BJmPnyRP.js +260 -0
- package/dist/PayoutManager-BJmPnyRP.js.map +1 -0
- package/dist/PayoutManager-aqtsj60t.cjs +2 -0
- package/dist/PayoutManager-aqtsj60t.cjs.map +1 -0
- package/dist/{PeginManager-BGWNJYPk.js → PeginManager-D22MLWfM.js} +132 -144
- package/dist/PeginManager-D22MLWfM.js.map +1 -0
- package/dist/PeginManager-vUUfZCzj.cjs +2 -0
- package/dist/PeginManager-vUUfZCzj.cjs.map +1 -0
- package/dist/{buildAndBroadcastRefund-BAT5A6MP.js → buildAndBroadcastRefund-BiSO4zg2.js} +358 -360
- package/dist/buildAndBroadcastRefund-BiSO4zg2.js.map +1 -0
- package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs +2 -0
- package/dist/buildAndBroadcastRefund-Bwi1I5we.cjs.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/{fundPeginTransaction-96FxwYYJ.js → fundPeginTransaction-B2wyjqp0.js} +21 -22
- package/dist/fundPeginTransaction-B2wyjqp0.js.map +1 -0
- package/dist/fundPeginTransaction-BLD8FRL9.cjs +2 -0
- package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +192 -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-CNMqNNpc.cjs +2 -0
- package/dist/noPayout-CNMqNNpc.cjs.map +1 -0
- package/dist/{noPayout-DVx3zxUz.js → noPayout-CfBg3HzC.js} +30 -30
- package/dist/noPayout-CfBg3HzC.js.map +1 -0
- package/dist/{peginInput-B5XDDHpy.js → peginInput-BKD_b3gq.js} +10 -11
- package/dist/peginInput-BKD_b3gq.js.map +1 -0
- package/dist/{peginInput-De0C6aSj.cjs → peginInput-CAiiDZeO.cjs} +2 -2
- package/dist/peginInput-CAiiDZeO.cjs.map +1 -0
- package/dist/primeVpAuth-CF4cH5_e.cjs +2 -0
- package/dist/primeVpAuth-CF4cH5_e.cjs.map +1 -0
- package/dist/{primeVpAuth-DxMuWQCi.js → primeVpAuth-l-5x_2UV.js} +91 -85
- package/dist/{primeVpAuth-yTddDmGy.cjs.map → primeVpAuth-l-5x_2UV.js.map} +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +8 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +190 -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 +10 -2
- 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/managers/pegin/signPsbtsWithFallback.d.ts +10 -6
- package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -1
- 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 +3 -3
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +40 -37
- package/dist/tbv/core/primitives/index.js.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +11 -0
- package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +11 -10
- 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 +17 -2
- 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/utils/fee/constants.d.ts +6 -14
- package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +35 -36
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +190 -188
- package/dist/tbv/index.js.map +1 -1
- package/dist/testing/MockBitcoinWallet.d.ts +1 -1
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +3 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-BDznSCOR.cjs.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js +658 -0
- package/dist/verifyScriptPathSchnorrSignature-DA4Z4yZ3.js.map +1 -0
- package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs} +2 -2
- package/dist/{waitForTransactionReceiptSmartAware-U706oKTc.cjs.map → waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs.map} +1 -1
- package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js → waitForTransactionReceiptSmartAware-lobLm0q0.js} +2 -2
- package/dist/{waitForTransactionReceiptSmartAware-Ckg_oZAo.js.map → waitForTransactionReceiptSmartAware-lobLm0q0.js.map} +1 -1
- package/package.json +2 -2
- package/dist/ApplicationRegistry.abi-BAPhJch3.cjs +0 -2
- package/dist/ApplicationRegistry.abi-BAPhJch3.cjs.map +0 -1
- package/dist/ApplicationRegistry.abi-Dn2qk6JG.js.map +0 -1
- package/dist/PayoutManager-BwrV3xFW.js +0 -241
- package/dist/PayoutManager-BwrV3xFW.js.map +0 -1
- package/dist/PayoutManager-CBfHfLfz.cjs +0 -2
- package/dist/PayoutManager-CBfHfLfz.cjs.map +0 -1
- package/dist/PeginManager-BGWNJYPk.js.map +0 -1
- package/dist/PeginManager-DDp-ZRIa.cjs +0 -2
- package/dist/PeginManager-DDp-ZRIa.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs +0 -2
- package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-BAT5A6MP.js.map +0 -1
- package/dist/constants-CSG2XeD8.cjs +0 -2
- package/dist/constants-CSG2XeD8.cjs.map +0 -1
- package/dist/constants-Cd_fN8VT.js +0 -12
- package/dist/constants-Cd_fN8VT.js.map +0 -1
- package/dist/fundPeginTransaction-96FxwYYJ.js.map +0 -1
- package/dist/fundPeginTransaction-DuMwnytD.cjs +0 -2
- package/dist/fundPeginTransaction-DuMwnytD.cjs.map +0 -1
- package/dist/mempoolApi-Dc1KSVNI.js.map +0 -1
- package/dist/mempoolApi-NMiYQAXI.cjs +0 -2
- package/dist/mempoolApi-NMiYQAXI.cjs.map +0 -1
- package/dist/noPayout-ChPNKTbm.cjs +0 -2
- package/dist/noPayout-ChPNKTbm.cjs.map +0 -1
- package/dist/noPayout-DVx3zxUz.js.map +0 -1
- package/dist/peginInput-B5XDDHpy.js.map +0 -1
- package/dist/peginInput-De0C6aSj.cjs.map +0 -1
- package/dist/primeVpAuth-DxMuWQCi.js.map +0 -1
- package/dist/primeVpAuth-yTddDmGy.cjs +0 -2
- package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts +0 -7
- package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts.map +0 -1
- package/dist/tbv/core/primitives/txGraphVersion.d.ts +0 -11
- package/dist/tbv/core/primitives/txGraphVersion.d.ts.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js +0 -572
- package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs.map +0 -1
|
@@ -1,146 +1,147 @@
|
|
|
1
1
|
var J = Object.defineProperty;
|
|
2
|
-
var Z = (e,
|
|
3
|
-
var
|
|
2
|
+
var Z = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var $ = (e, t, r) => Z(e, typeof t != "symbol" ? t + "" : t, r);
|
|
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,
|
|
7
|
-
import { D as w, c as
|
|
8
|
-
import { Transaction as
|
|
9
|
-
import { c as
|
|
10
|
-
import { c as de, a as pe, b as ge } from "./noPayout-
|
|
6
|
+
import { v as ne, s as oe, P as ae, f as se } from "./PayoutManager-BJmPnyRP.js";
|
|
7
|
+
import { D as w, c as ie, a as ue, R as le, d as z } from "./types-CQDRQvV-.js";
|
|
8
|
+
import { Transaction as S, Psbt as ce } from "bitcoinjs-lib";
|
|
9
|
+
import { c as he, d as I, e as N, f as H } from "./verifyScriptPathSchnorrSignature-DA4Z4yZ3.js";
|
|
10
|
+
import { c as de, a as pe, b as ge } from "./noPayout-CfBg3HzC.js";
|
|
11
11
|
import { c as O } from "./signing-DaLvGwQe.js";
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { a as fe } from "./constants-BhclpREj.js";
|
|
13
|
+
const me = /^0x[0-9a-fA-F]{64}$/, Pe = /^0x[0-9a-fA-F]{40}$/, be = /^0x([0-9a-fA-F]{2})*$/;
|
|
14
|
+
function V(e, t) {
|
|
14
15
|
if (e.length !== 66)
|
|
15
16
|
throw new Error(
|
|
16
|
-
`${
|
|
17
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
17
18
|
);
|
|
18
|
-
if (!
|
|
19
|
+
if (!me.test(e))
|
|
19
20
|
throw new Error(
|
|
20
|
-
`${
|
|
21
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
24
|
+
function ye(e, t) {
|
|
25
|
+
if (!Pe.test(e))
|
|
25
26
|
throw new Error(
|
|
26
|
-
`${
|
|
27
|
+
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
if (!
|
|
30
|
+
function we(e, t) {
|
|
31
|
+
if (!be.test(e))
|
|
31
32
|
throw new Error(
|
|
32
|
-
`${
|
|
33
|
+
`${t} 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
|
-
btcVaultRegistryAddress:
|
|
38
|
-
vaultId:
|
|
38
|
+
btcVaultRegistryAddress: t,
|
|
39
|
+
vaultId: r,
|
|
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(), ye(t, "btcVaultRegistryAddress"), V(r, "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
|
-
address:
|
|
51
|
+
return we(s, "activationMetadata"), l({
|
|
52
|
+
address: t,
|
|
52
53
|
abi: ee,
|
|
53
54
|
functionName: "activateVaultWithSecret",
|
|
54
|
-
args: [
|
|
55
|
+
args: [r, i, s]
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
+
const xe = 1e4;
|
|
58
59
|
async function G(e) {
|
|
59
60
|
const {
|
|
60
|
-
statusReader:
|
|
61
|
-
peginTxid:
|
|
61
|
+
statusReader: t,
|
|
62
|
+
peginTxid: r,
|
|
62
63
|
targetStatuses: n,
|
|
63
64
|
timeoutMs: s,
|
|
64
|
-
pollIntervalMs:
|
|
65
|
+
pollIntervalMs: l = xe,
|
|
65
66
|
signal: a
|
|
66
67
|
} = e, i = Date.now();
|
|
67
68
|
for (; ; ) {
|
|
68
69
|
if (a != null && a.aborted)
|
|
69
70
|
throw new Error(
|
|
70
|
-
`Polling aborted for pegin ${
|
|
71
|
+
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
71
72
|
);
|
|
72
73
|
if (Date.now() - i >= s)
|
|
73
74
|
throw new Error(
|
|
74
|
-
`Polling timeout after ${s}ms for pegin ${
|
|
75
|
+
`Polling timeout after ${s}ms for pegin ${r.slice(0, 8)}… (target: ${[...n].join(", ")})`
|
|
75
76
|
);
|
|
76
77
|
try {
|
|
77
|
-
const o = await
|
|
78
|
-
{ pegin_txid:
|
|
78
|
+
const o = await t.getPeginStatus(
|
|
79
|
+
{ pegin_txid: r },
|
|
79
80
|
a
|
|
80
81
|
);
|
|
81
|
-
if (o.pegin_txid.toLowerCase() !==
|
|
82
|
+
if (o.pegin_txid.toLowerCase() !== r.toLowerCase())
|
|
82
83
|
throw new Error(
|
|
83
|
-
`getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${
|
|
84
|
+
`getPeginStatus returned status for pegin ${o.pegin_txid.slice(0, 8)}…, requested ${r.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 || ie.has(u))
|
|
89
90
|
throw new Error(
|
|
90
|
-
`Pegin ${
|
|
91
|
+
`Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
|
|
91
92
|
);
|
|
92
93
|
} catch (o) {
|
|
93
|
-
if (!(o instanceof
|
|
94
|
+
if (!(o instanceof ue && o.code === le.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
|
-
`Polling aborted for pegin ${
|
|
101
|
+
`Polling aborted for pegin ${r.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 ve = 300 * 1e3, Ee = /* @__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
|
-
statusReader:
|
|
117
|
-
wotsSubmitter:
|
|
117
|
+
statusReader: t,
|
|
118
|
+
wotsSubmitter: r,
|
|
118
119
|
peginTxid: n,
|
|
119
120
|
depositorPk: s,
|
|
120
|
-
wotsPublicKeys:
|
|
121
|
-
timeoutMs: a =
|
|
121
|
+
wotsPublicKeys: l,
|
|
122
|
+
timeoutMs: a = ve,
|
|
122
123
|
signal: i
|
|
123
124
|
} = e;
|
|
124
125
|
i == null || i.throwIfAborted();
|
|
125
126
|
const o = await G({
|
|
126
|
-
statusReader:
|
|
127
|
+
statusReader: t,
|
|
127
128
|
peginTxid: n,
|
|
128
|
-
targetStatuses:
|
|
129
|
+
targetStatuses: Ee,
|
|
129
130
|
timeoutMs: a,
|
|
130
131
|
signal: i
|
|
131
132
|
});
|
|
132
|
-
z.has(o) || (i == null || i.throwIfAborted(), await
|
|
133
|
+
z.has(o) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
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
|
|
142
|
+
const K = 1, Te = 1;
|
|
143
|
+
function ke(e, t) {
|
|
144
|
+
const r = p(t).toLowerCase(), s = e.map((l) => p(l).toLowerCase()).filter((l) => l !== r);
|
|
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,155 +152,156 @@ function Te(e, r) {
|
|
|
151
152
|
);
|
|
152
153
|
return s;
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
-
const n =
|
|
155
|
+
function _e(e, t, r) {
|
|
156
|
+
const n = r.map(
|
|
156
157
|
(c) => p(c).toLowerCase()
|
|
157
|
-
), s =
|
|
158
|
+
), s = t.filter((c) => n.includes(c));
|
|
158
159
|
if (s.length > 0)
|
|
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 = [...t, ...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
|
-
const
|
|
177
|
-
return X(new Uint8Array(
|
|
176
|
+
function Ce(e, t) {
|
|
177
|
+
const r = e.ins[t];
|
|
178
|
+
return X(new Uint8Array(r.hash).slice().reverse());
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
180
|
+
function R(e, t, r, n, s) {
|
|
181
|
+
const l = e.ins[t];
|
|
182
|
+
if (l.index !== 0)
|
|
182
183
|
throw new Error(
|
|
183
|
-
`NoPayout (challenger ${s}) input ${
|
|
184
|
+
`NoPayout (challenger ${s}) input ${t} expected to spend ${n} vout 0, got vout ${l.index}`
|
|
184
185
|
);
|
|
185
|
-
const a =
|
|
186
|
+
const a = r.getId(), i = Ce(e, t);
|
|
186
187
|
if (i !== a)
|
|
187
188
|
throw new Error(
|
|
188
|
-
`NoPayout (challenger ${s}) input ${
|
|
189
|
+
`NoPayout (challenger ${s}) input ${t} does not reference ${n} (expected txid ${a}, got ${i})`
|
|
189
190
|
);
|
|
190
191
|
}
|
|
191
|
-
async function Se(e,
|
|
192
|
-
const n = [], s = [],
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
async function Se(e, t, r) {
|
|
193
|
+
const n = [], s = [], l = [], a = ke(
|
|
194
|
+
r.vaultKeeperBtcPubkeys,
|
|
195
|
+
r.depositorBtcPubkey
|
|
195
196
|
);
|
|
196
|
-
|
|
197
|
+
_e(
|
|
197
198
|
e.challenger_presign_data,
|
|
198
199
|
a,
|
|
199
|
-
|
|
200
|
+
r.universalChallengerBtcPubkeys
|
|
200
201
|
);
|
|
201
|
-
const i = await
|
|
202
|
+
const i = await he({
|
|
203
|
+
vaultCoreVersion: r.vaultCoreVersion,
|
|
202
204
|
payoutTxHex: e.payout_tx.tx_hex,
|
|
203
|
-
peginTxHex:
|
|
205
|
+
peginTxHex: r.peginTxHex,
|
|
204
206
|
assertTxHex: e.assert_tx.tx_hex,
|
|
205
|
-
depositorBtcPubkey:
|
|
206
|
-
vaultProviderBtcPubkey:
|
|
207
|
-
vaultKeeperBtcPubkeys:
|
|
208
|
-
universalChallengerBtcPubkeys:
|
|
209
|
-
timelockPegin:
|
|
210
|
-
network:
|
|
211
|
-
claimerBtcPubkey:
|
|
212
|
-
registeredPayoutScriptPubKey:
|
|
213
|
-
commissionBps:
|
|
207
|
+
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
208
|
+
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
209
|
+
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
|
|
210
|
+
universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
|
|
211
|
+
timelockPegin: r.timelockPegin,
|
|
212
|
+
network: r.network,
|
|
213
|
+
claimerBtcPubkey: r.depositorBtcPubkey,
|
|
214
|
+
registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
|
|
215
|
+
commissionBps: Te
|
|
214
216
|
});
|
|
215
217
|
n.push(i.psbtHex), s.push(
|
|
216
218
|
O(
|
|
217
|
-
|
|
219
|
+
t,
|
|
218
220
|
K
|
|
219
221
|
)
|
|
220
222
|
);
|
|
221
|
-
const o = p(
|
|
223
|
+
const o = p(r.depositorBtcPubkey), u = S.fromHex(
|
|
222
224
|
p(e.assert_tx.tx_hex)
|
|
223
225
|
);
|
|
224
226
|
for (const h of e.challenger_presign_data) {
|
|
225
|
-
const c = p(h.challenger_pubkey), d = n.length, P = await
|
|
227
|
+
const c = p(h.challenger_pubkey), d = n.length, P = await Ae({
|
|
226
228
|
challenger: h,
|
|
227
229
|
challengerPubkey: c,
|
|
228
230
|
claimerPubkey: o,
|
|
229
231
|
localChallengers: a,
|
|
230
|
-
assertTxParsed:
|
|
231
|
-
ctx:
|
|
232
|
+
assertTxParsed: u,
|
|
233
|
+
ctx: r
|
|
232
234
|
});
|
|
233
235
|
n.push(P), s.push(
|
|
234
236
|
O(
|
|
235
|
-
|
|
237
|
+
t,
|
|
236
238
|
K
|
|
237
239
|
)
|
|
238
|
-
),
|
|
240
|
+
), l.push({
|
|
239
241
|
challengerPubkey: c,
|
|
240
242
|
noPayoutIdx: d
|
|
241
243
|
});
|
|
242
244
|
}
|
|
243
|
-
return { psbtHexes: n, signOptions: s, challengerEntries:
|
|
245
|
+
return { psbtHexes: n, signOptions: s, challengerEntries: l };
|
|
244
246
|
}
|
|
245
|
-
async function
|
|
247
|
+
async function Ae(e) {
|
|
246
248
|
const {
|
|
247
|
-
challenger:
|
|
248
|
-
challengerPubkey:
|
|
249
|
+
challenger: t,
|
|
250
|
+
challengerPubkey: r,
|
|
249
251
|
claimerPubkey: n,
|
|
250
252
|
localChallengers: s,
|
|
251
|
-
assertTxParsed:
|
|
253
|
+
assertTxParsed: l,
|
|
252
254
|
ctx: a
|
|
253
255
|
} = e;
|
|
254
256
|
de(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
t.nopayout_tx.tx_hex,
|
|
258
|
+
r,
|
|
257
259
|
a.network
|
|
258
260
|
);
|
|
259
|
-
const i =
|
|
260
|
-
p(
|
|
261
|
-
), o =
|
|
262
|
-
p(
|
|
263
|
-
),
|
|
264
|
-
p(
|
|
261
|
+
const i = S.fromHex(
|
|
262
|
+
p(t.nopayout_tx.tx_hex)
|
|
263
|
+
), o = S.fromHex(
|
|
264
|
+
p(t.challenge_assert_x_tx.tx_hex)
|
|
265
|
+
), u = S.fromHex(
|
|
266
|
+
p(t.challenge_assert_y_tx.tx_hex)
|
|
265
267
|
);
|
|
266
268
|
if (i.ins.length !== 3)
|
|
267
269
|
throw new Error(
|
|
268
|
-
`NoPayout (challenger ${
|
|
270
|
+
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
|
|
269
271
|
);
|
|
270
|
-
|
|
272
|
+
R(
|
|
271
273
|
i,
|
|
272
274
|
0,
|
|
273
|
-
|
|
275
|
+
l,
|
|
274
276
|
"Assert",
|
|
275
|
-
|
|
276
|
-
),
|
|
277
|
+
r
|
|
278
|
+
), R(
|
|
277
279
|
i,
|
|
278
280
|
1,
|
|
279
281
|
o,
|
|
280
282
|
"ChallengeAssertX",
|
|
281
|
-
|
|
282
|
-
),
|
|
283
|
+
r
|
|
284
|
+
), R(
|
|
283
285
|
i,
|
|
284
286
|
2,
|
|
285
|
-
|
|
287
|
+
u,
|
|
286
288
|
"ChallengeAssertY",
|
|
287
|
-
|
|
289
|
+
r
|
|
288
290
|
);
|
|
289
291
|
const h = [
|
|
290
|
-
|
|
292
|
+
l.outs[0],
|
|
291
293
|
o.outs[0],
|
|
292
|
-
|
|
294
|
+
u.outs[0]
|
|
293
295
|
].map((c) => ({
|
|
294
296
|
script_pubkey: X(new Uint8Array(c.script)),
|
|
295
297
|
value: c.value
|
|
296
298
|
}));
|
|
297
299
|
return pe({
|
|
298
|
-
noPayoutTxHex:
|
|
299
|
-
challengerPubkey:
|
|
300
|
+
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
301
|
+
challengerPubkey: r,
|
|
300
302
|
prevouts: h,
|
|
301
303
|
connectorParams: {
|
|
302
|
-
txGraphVersion:
|
|
304
|
+
txGraphVersion: a.vaultCoreVersion,
|
|
303
305
|
claimer: n,
|
|
304
306
|
localChallengers: s,
|
|
305
307
|
universalChallengers: a.universalChallengerBtcPubkeys,
|
|
@@ -309,31 +311,31 @@ async function Ce(e) {
|
|
|
309
311
|
}
|
|
310
312
|
});
|
|
311
313
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
+
function $e(e, t, r) {
|
|
315
|
+
I(e[0]);
|
|
314
316
|
const s = N(
|
|
315
317
|
e[0].returnedPsbtHex,
|
|
316
|
-
|
|
318
|
+
r
|
|
317
319
|
);
|
|
318
320
|
H({
|
|
319
321
|
requestedPsbtHex: e[0].requestedPsbtHex,
|
|
320
322
|
signatureHex: s,
|
|
321
|
-
signerXOnlyPubkeyHex:
|
|
323
|
+
signerXOnlyPubkeyHex: r,
|
|
322
324
|
inputIndex: 0
|
|
323
325
|
});
|
|
324
|
-
const
|
|
325
|
-
for (const a of
|
|
326
|
-
|
|
326
|
+
const l = {};
|
|
327
|
+
for (const a of t) {
|
|
328
|
+
I(e[a.noPayoutIdx]);
|
|
327
329
|
const i = N(
|
|
328
330
|
e[a.noPayoutIdx].returnedPsbtHex,
|
|
329
|
-
|
|
331
|
+
r
|
|
330
332
|
);
|
|
331
333
|
H({
|
|
332
334
|
requestedPsbtHex: e[a.noPayoutIdx].requestedPsbtHex,
|
|
333
335
|
signatureHex: i,
|
|
334
|
-
signerXOnlyPubkeyHex:
|
|
336
|
+
signerXOnlyPubkeyHex: r,
|
|
335
337
|
inputIndex: 0
|
|
336
|
-
}),
|
|
338
|
+
}), l[a.challengerPubkey] = {
|
|
337
339
|
nopayout_signature: i
|
|
338
340
|
};
|
|
339
341
|
}
|
|
@@ -341,69 +343,56 @@ function Ae(e, r, t) {
|
|
|
341
343
|
payout_signatures: {
|
|
342
344
|
payout_signature: s
|
|
343
345
|
},
|
|
344
|
-
per_challenger:
|
|
346
|
+
per_challenger: l
|
|
345
347
|
};
|
|
346
348
|
}
|
|
347
|
-
async function
|
|
348
|
-
|
|
349
|
-
return e.signPsbts(r, t);
|
|
350
|
-
const n = [];
|
|
351
|
-
for (let s = 0; s < r.length; s++)
|
|
352
|
-
n.push(await e.signPsbt(r[s], t == null ? void 0 : t[s]));
|
|
353
|
-
return n;
|
|
354
|
-
}
|
|
355
|
-
async function $e(e) {
|
|
356
|
-
const { depositorGraph: r, btcWallet: t, signingContext: n } = e, s = await t.getPublicKeyHex(), { depositorPubkey: u } = re(
|
|
349
|
+
async function Ve(e) {
|
|
350
|
+
const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = re(
|
|
357
351
|
s,
|
|
358
352
|
p(n.depositorBtcPubkey)
|
|
359
353
|
), { psbtHexes: a, signOptions: i, challengerEntries: o } = await Se(
|
|
360
|
-
|
|
354
|
+
t,
|
|
361
355
|
s,
|
|
362
356
|
n
|
|
363
|
-
),
|
|
364
|
-
|
|
357
|
+
), u = await oe(
|
|
358
|
+
r,
|
|
365
359
|
a,
|
|
366
360
|
i
|
|
367
|
-
)
|
|
368
|
-
if (l.length !== a.length)
|
|
369
|
-
throw new Error(
|
|
370
|
-
`Wallet returned ${l.length} signed PSBTs, expected ${a.length}`
|
|
371
|
-
);
|
|
372
|
-
const h = a.map((c, d) => ({
|
|
361
|
+
), h = a.map((c, d) => ({
|
|
373
362
|
requestedPsbtHex: c,
|
|
374
|
-
returnedPsbtHex:
|
|
363
|
+
returnedPsbtHex: u[d]
|
|
375
364
|
}));
|
|
376
|
-
return
|
|
365
|
+
return $e(
|
|
377
366
|
h,
|
|
378
367
|
o,
|
|
379
|
-
|
|
368
|
+
l
|
|
380
369
|
);
|
|
381
370
|
}
|
|
382
|
-
const
|
|
371
|
+
const Re = 1200 * 1e3, q = /* @__PURE__ */ new Set([
|
|
383
372
|
w.PENDING_ACKS,
|
|
384
373
|
w.PENDING_ACTIVATION,
|
|
385
374
|
w.ACTIVATED_PENDING_BROADCAST,
|
|
386
375
|
w.ACTIVATED
|
|
387
|
-
]),
|
|
376
|
+
]), Be = /* @__PURE__ */ new Set([
|
|
388
377
|
w.PENDING_DEPOSITOR_SIGNATURES,
|
|
389
378
|
...q
|
|
390
379
|
]);
|
|
391
|
-
function
|
|
392
|
-
return e.map((
|
|
393
|
-
claimerPubkeyXOnly: A(
|
|
394
|
-
payoutTxHex:
|
|
395
|
-
assertTxHex:
|
|
380
|
+
function Ie(e) {
|
|
381
|
+
return e.map((t) => ({
|
|
382
|
+
claimerPubkeyXOnly: A(t.claimer_pubkey),
|
|
383
|
+
payoutTxHex: t.payout_tx.tx_hex,
|
|
384
|
+
assertTxHex: t.assert_tx.tx_hex
|
|
396
385
|
}));
|
|
397
386
|
}
|
|
398
387
|
function _(e) {
|
|
399
388
|
return A(e).toLowerCase();
|
|
400
389
|
}
|
|
401
|
-
function Ne(e,
|
|
402
|
-
const s = _(n),
|
|
403
|
-
_(
|
|
404
|
-
...
|
|
405
|
-
], a = new Set(
|
|
406
|
-
if (a.size !==
|
|
390
|
+
function Ne(e, t, r, n) {
|
|
391
|
+
const s = _(n), l = [
|
|
392
|
+
_(t),
|
|
393
|
+
...r.map(_)
|
|
394
|
+
], a = new Set(l);
|
|
395
|
+
if (a.size !== l.length)
|
|
407
396
|
throw new Error(
|
|
408
397
|
"Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
|
|
409
398
|
);
|
|
@@ -418,106 +407,108 @@ function Ne(e, r, t, n) {
|
|
|
418
407
|
throw new Error(
|
|
419
408
|
"Presign response contains duplicate claimer entries"
|
|
420
409
|
);
|
|
421
|
-
const o = i.filter((d) => d !== s),
|
|
410
|
+
const o = i.filter((d) => d !== s), u = new Set(o), h = l.filter((d) => !u.has(d)), c = o.filter((d) => !a.has(d));
|
|
422
411
|
if (h.length > 0 || c.length > 0)
|
|
423
412
|
throw new Error(
|
|
424
413
|
"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
414
|
);
|
|
426
415
|
}
|
|
427
|
-
function U(e,
|
|
416
|
+
function U(e, t) {
|
|
428
417
|
return {
|
|
418
|
+
vaultCoreVersion: t.vaultCoreVersion,
|
|
429
419
|
payoutTxHex: e.payoutTxHex,
|
|
430
|
-
peginTxHex:
|
|
420
|
+
peginTxHex: t.peginTxHex,
|
|
431
421
|
assertTxHex: e.assertTxHex,
|
|
432
|
-
vaultProviderBtcPubkey:
|
|
433
|
-
vaultKeeperBtcPubkeys:
|
|
434
|
-
universalChallengerBtcPubkeys:
|
|
435
|
-
depositorBtcPubkey:
|
|
436
|
-
timelockPegin:
|
|
437
|
-
registeredPayoutScriptPubKey:
|
|
422
|
+
vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
|
|
423
|
+
vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
|
|
424
|
+
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
425
|
+
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
426
|
+
timelockPegin: t.timelockPegin,
|
|
427
|
+
registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
|
|
438
428
|
claimerBtcPubkey: e.claimerPubkeyXOnly,
|
|
439
|
-
commissionBps:
|
|
429
|
+
commissionBps: t.commissionBps
|
|
440
430
|
};
|
|
441
431
|
}
|
|
442
|
-
async function He(e,
|
|
443
|
-
const s = new
|
|
444
|
-
network:
|
|
432
|
+
async function He(e, t, r, n) {
|
|
433
|
+
const s = new ae({
|
|
434
|
+
network: t.network,
|
|
445
435
|
btcWallet: e
|
|
446
|
-
}),
|
|
447
|
-
n == null || n(0,
|
|
436
|
+
}), l = r.length;
|
|
437
|
+
n == null || n(0, l);
|
|
448
438
|
let a;
|
|
449
439
|
if (s.supportsBatchSigning())
|
|
450
440
|
a = (await s.signPayoutTransactionsBatch(
|
|
451
|
-
|
|
452
|
-
)).map((
|
|
441
|
+
r.map((u) => U(u, t))
|
|
442
|
+
)).map((u) => u.payoutSignature);
|
|
453
443
|
else {
|
|
454
444
|
a = [];
|
|
455
|
-
for (let o = 0; o <
|
|
456
|
-
n == null || n(o,
|
|
457
|
-
const
|
|
458
|
-
U(
|
|
445
|
+
for (let o = 0; o < r.length; o++) {
|
|
446
|
+
n == null || n(o, l);
|
|
447
|
+
const u = await s.signPayoutTransaction(
|
|
448
|
+
U(r[o], t)
|
|
459
449
|
);
|
|
460
|
-
a.push(
|
|
450
|
+
a.push(u.signature);
|
|
461
451
|
}
|
|
462
452
|
}
|
|
463
453
|
const i = {};
|
|
464
|
-
for (let o = 0; o <
|
|
465
|
-
i[
|
|
454
|
+
for (let o = 0; o < r.length; o++)
|
|
455
|
+
i[r[o].claimerPubkeyXOnly] = {
|
|
466
456
|
payout_signature: a[o]
|
|
467
457
|
};
|
|
468
|
-
return n == null || n(
|
|
458
|
+
return n == null || n(l, l), i;
|
|
469
459
|
}
|
|
470
|
-
async function
|
|
460
|
+
async function ct(e) {
|
|
471
461
|
const {
|
|
472
|
-
statusReader:
|
|
473
|
-
presignClient:
|
|
462
|
+
statusReader: t,
|
|
463
|
+
presignClient: r,
|
|
474
464
|
btcWallet: n,
|
|
475
465
|
peginTxid: s,
|
|
476
|
-
depositorPk:
|
|
466
|
+
depositorPk: l,
|
|
477
467
|
signingContext: a,
|
|
478
|
-
timeoutMs: i =
|
|
468
|
+
timeoutMs: i = Re,
|
|
479
469
|
signal: o,
|
|
480
|
-
onProgress:
|
|
470
|
+
onProgress: u
|
|
481
471
|
} = e, h = await G({
|
|
482
|
-
statusReader:
|
|
472
|
+
statusReader: t,
|
|
483
473
|
peginTxid: s,
|
|
484
|
-
targetStatuses:
|
|
474
|
+
targetStatuses: Be,
|
|
485
475
|
timeoutMs: i,
|
|
486
476
|
signal: o
|
|
487
477
|
});
|
|
488
478
|
if (q.has(h))
|
|
489
479
|
return;
|
|
490
480
|
o == null || o.throwIfAborted();
|
|
491
|
-
const c = await
|
|
481
|
+
const c = await r.requestDepositorPresignTransactions(
|
|
492
482
|
{
|
|
493
483
|
pegin_txid: s,
|
|
494
|
-
depositor_pk:
|
|
484
|
+
depositor_pk: l
|
|
495
485
|
},
|
|
496
486
|
o
|
|
497
487
|
);
|
|
498
488
|
o == null || o.throwIfAborted();
|
|
499
|
-
const d = _(
|
|
489
|
+
const d = _(l);
|
|
500
490
|
Ne(
|
|
501
491
|
c.txs,
|
|
502
492
|
a.vaultProviderBtcPubkey,
|
|
503
493
|
a.vaultKeeperBtcPubkeys,
|
|
504
|
-
|
|
494
|
+
l
|
|
505
495
|
);
|
|
506
496
|
const P = c.txs.filter(
|
|
507
497
|
(v) => _(v.claimer_pubkey) !== d
|
|
508
|
-
), m =
|
|
498
|
+
), m = Ie(P), y = await He(
|
|
509
499
|
n,
|
|
510
500
|
a,
|
|
511
501
|
m,
|
|
512
|
-
|
|
502
|
+
u
|
|
513
503
|
);
|
|
514
504
|
o == null || o.throwIfAborted();
|
|
515
|
-
const x = await
|
|
505
|
+
const x = await Ve({
|
|
516
506
|
depositorGraph: c.depositor_graph,
|
|
517
507
|
btcWallet: n,
|
|
518
508
|
signingContext: {
|
|
509
|
+
vaultCoreVersion: a.vaultCoreVersion,
|
|
519
510
|
peginTxHex: a.peginTxHex,
|
|
520
|
-
depositorBtcPubkey:
|
|
511
|
+
depositorBtcPubkey: l,
|
|
521
512
|
vaultProviderBtcPubkey: a.vaultProviderBtcPubkey,
|
|
522
513
|
vaultKeeperBtcPubkeys: a.vaultKeeperBtcPubkeys,
|
|
523
514
|
universalChallengerBtcPubkeys: a.universalChallengerBtcPubkeys,
|
|
@@ -531,10 +522,10 @@ async function lt(e) {
|
|
|
531
522
|
});
|
|
532
523
|
o == null || o.throwIfAborted();
|
|
533
524
|
const b = { ...y };
|
|
534
|
-
b[p(
|
|
525
|
+
b[p(l)] = x.payout_signatures, await r.submitDepositorPresignatures(
|
|
535
526
|
{
|
|
536
527
|
pegin_txid: s,
|
|
537
|
-
depositor_pk:
|
|
528
|
+
depositor_pk: l,
|
|
538
529
|
signatures: b,
|
|
539
530
|
depositor_claimer_presignatures: x
|
|
540
531
|
},
|
|
@@ -544,56 +535,56 @@ async function lt(e) {
|
|
|
544
535
|
function Oe(e) {
|
|
545
536
|
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
546
537
|
}
|
|
547
|
-
function
|
|
538
|
+
function ht(e) {
|
|
548
539
|
const {
|
|
549
|
-
amountSats:
|
|
550
|
-
minDeposit:
|
|
540
|
+
amountSats: t,
|
|
541
|
+
minDeposit: r,
|
|
551
542
|
maxDeposit: n,
|
|
552
543
|
btcBalance: s,
|
|
553
|
-
estimatedFeeSats:
|
|
544
|
+
estimatedFeeSats: l,
|
|
554
545
|
depositorClaimValue: a
|
|
555
546
|
} = e;
|
|
556
|
-
return !(
|
|
547
|
+
return !(t <= 0n || t < r || n && n > 0n && t > n || l == null || a == null || t + l + a > s);
|
|
557
548
|
}
|
|
558
|
-
function
|
|
549
|
+
function dt(e, t, r) {
|
|
559
550
|
return e <= 0n ? {
|
|
560
551
|
valid: !1,
|
|
561
552
|
error: "Deposit amount must be greater than zero"
|
|
562
|
-
} : e <
|
|
553
|
+
} : e < t ? {
|
|
563
554
|
valid: !1,
|
|
564
|
-
error: `Minimum deposit is ${E(
|
|
565
|
-
} :
|
|
555
|
+
error: `Minimum deposit is ${E(t)} BTC`
|
|
556
|
+
} : r && r > 0n && e > r ? {
|
|
566
557
|
valid: !1,
|
|
567
|
-
error: `Maximum deposit is ${E(
|
|
558
|
+
error: `Maximum deposit is ${E(r)} BTC`
|
|
568
559
|
} : { valid: !0 };
|
|
569
560
|
}
|
|
570
|
-
function
|
|
571
|
-
const { amount:
|
|
572
|
-
return
|
|
561
|
+
function pt(e) {
|
|
562
|
+
const { amount: t, effectiveRemaining: r } = e;
|
|
563
|
+
return r === null ? { valid: !0 } : r === 0n ? {
|
|
573
564
|
valid: !1,
|
|
574
565
|
error: "Supply cap reached — deposits temporarily paused"
|
|
575
|
-
} :
|
|
566
|
+
} : t > r ? {
|
|
576
567
|
valid: !1,
|
|
577
|
-
error: `Vault size exceeds remaining capacity (${E(
|
|
568
|
+
error: `Vault size exceeds remaining capacity (${E(r)} BTC)`
|
|
578
569
|
} : { valid: !0 };
|
|
579
570
|
}
|
|
580
|
-
function
|
|
571
|
+
function gt(e, t) {
|
|
581
572
|
if (!e || e.length === 0)
|
|
582
573
|
return {
|
|
583
574
|
valid: !1,
|
|
584
575
|
error: "At least one vault provider must be selected"
|
|
585
576
|
};
|
|
586
|
-
const
|
|
577
|
+
const r = t.map(
|
|
587
578
|
(s) => s.toLowerCase()
|
|
588
579
|
);
|
|
589
580
|
return e.filter(
|
|
590
|
-
(s) => !
|
|
581
|
+
(s) => !r.includes(s.toLowerCase())
|
|
591
582
|
).length > 0 ? {
|
|
592
583
|
valid: !1,
|
|
593
584
|
error: "Invalid vault provider selected"
|
|
594
585
|
} : { valid: !0 };
|
|
595
586
|
}
|
|
596
|
-
function De(e,
|
|
587
|
+
function De(e, t, r) {
|
|
597
588
|
if (!e || e.length === 0)
|
|
598
589
|
return {
|
|
599
590
|
valid: !1,
|
|
@@ -606,22 +597,22 @@ function De(e, r, t) {
|
|
|
606
597
|
valid: !1,
|
|
607
598
|
error: `Vault ${n + 1} amount must be positive`
|
|
608
599
|
};
|
|
609
|
-
if (
|
|
600
|
+
if (t && s < t)
|
|
610
601
|
return {
|
|
611
602
|
valid: !1,
|
|
612
|
-
error: `Vault ${n + 1} amount ${E(s)} BTC is below minimum deposit ${E(
|
|
603
|
+
error: `Vault ${n + 1} amount ${E(s)} BTC is below minimum deposit ${E(t)} BTC`
|
|
613
604
|
};
|
|
614
|
-
if (
|
|
605
|
+
if (r && s > r)
|
|
615
606
|
return {
|
|
616
607
|
valid: !1,
|
|
617
|
-
error: `Vault ${n + 1} amount ${E(s)} BTC exceeds maximum deposit ${E(
|
|
608
|
+
error: `Vault ${n + 1} amount ${E(s)} BTC exceeds maximum deposit ${E(r)} BTC`
|
|
618
609
|
};
|
|
619
610
|
}
|
|
620
611
|
return { valid: !0 };
|
|
621
612
|
}
|
|
622
613
|
function Ke(e) {
|
|
623
|
-
const
|
|
624
|
-
return Oe(
|
|
614
|
+
const t = p(e);
|
|
615
|
+
return Oe(t) ? { valid: !0 } : {
|
|
625
616
|
valid: !1,
|
|
626
617
|
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
627
618
|
};
|
|
@@ -642,74 +633,74 @@ function Me(e) {
|
|
|
642
633
|
if (e.length === 0)
|
|
643
634
|
throw new Error("No spendable UTXOs available");
|
|
644
635
|
}
|
|
645
|
-
function
|
|
636
|
+
function ft(e) {
|
|
646
637
|
const {
|
|
647
|
-
vaultAmounts:
|
|
648
|
-
confirmedUTXOs:
|
|
638
|
+
vaultAmounts: t,
|
|
639
|
+
confirmedUTXOs: r,
|
|
649
640
|
vaultProviderBtcPubkey: n,
|
|
650
641
|
vaultKeeperBtcPubkeys: s,
|
|
651
|
-
universalChallengerBtcPubkeys:
|
|
642
|
+
universalChallengerBtcPubkeys: l,
|
|
652
643
|
minDeposit: a,
|
|
653
644
|
maxDeposit: i
|
|
654
645
|
} = e, o = De(
|
|
655
|
-
|
|
646
|
+
t,
|
|
656
647
|
a,
|
|
657
648
|
i
|
|
658
649
|
);
|
|
659
650
|
if (!o.valid)
|
|
660
651
|
throw new Error(o.error);
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
663
|
-
throw new Error(
|
|
664
|
-
Ue(s), Fe(
|
|
652
|
+
const u = Ke(n);
|
|
653
|
+
if (!u.valid)
|
|
654
|
+
throw new Error(u.error);
|
|
655
|
+
Ue(s), Fe(l), Me(r);
|
|
665
656
|
}
|
|
666
|
-
async function
|
|
657
|
+
async function mt(e) {
|
|
667
658
|
const {
|
|
668
|
-
vaultRegistryReader:
|
|
669
|
-
vaultKeeperReader:
|
|
659
|
+
vaultRegistryReader: t,
|
|
660
|
+
vaultKeeperReader: r,
|
|
670
661
|
universalChallengerReader: n,
|
|
671
662
|
vaultProviderEthAddress: s,
|
|
672
|
-
applicationEntryPoint:
|
|
663
|
+
applicationEntryPoint: l,
|
|
673
664
|
expectedVaultProviderBtcPubkey: a,
|
|
674
665
|
expectedVaultKeeperBtcPubkeys: i,
|
|
675
666
|
expectedUniversalChallengerBtcPubkeys: o
|
|
676
667
|
} = e, [
|
|
677
|
-
|
|
668
|
+
u,
|
|
678
669
|
h,
|
|
679
670
|
c
|
|
680
671
|
] = await Promise.all([
|
|
681
|
-
|
|
682
|
-
|
|
672
|
+
t.getVaultProviderBtcPubKey(s),
|
|
673
|
+
r.getCurrentVaultKeepersVersion(l),
|
|
683
674
|
n.getLatestUniversalChallengersVersion()
|
|
684
675
|
]), [d, P] = await Promise.all([
|
|
685
|
-
|
|
686
|
-
|
|
676
|
+
r.getVaultKeepersByVersion(
|
|
677
|
+
l,
|
|
687
678
|
h
|
|
688
679
|
),
|
|
689
680
|
n.getUniversalChallengersByVersion(
|
|
690
681
|
c
|
|
691
682
|
)
|
|
692
683
|
]), m = (g) => A(g).toLowerCase(), y = (g) => g.map(m).sort();
|
|
693
|
-
if (m(a) !==
|
|
684
|
+
if (m(a) !== u)
|
|
694
685
|
throw new Error(
|
|
695
686
|
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
|
|
696
687
|
);
|
|
697
688
|
const b = y(i), v = y(
|
|
698
689
|
d.map((g) => g.btcPubKey)
|
|
699
690
|
);
|
|
700
|
-
if (b.length !== v.length || b.some((g,
|
|
691
|
+
if (b.length !== v.length || b.some((g, C) => g !== v[C]))
|
|
701
692
|
throw new Error(
|
|
702
693
|
`Vault keeper BTC pubkeys (v${h}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
703
694
|
);
|
|
704
695
|
const T = y(o), k = y(
|
|
705
696
|
P.map((g) => g.btcPubKey)
|
|
706
697
|
);
|
|
707
|
-
if (T.length !== k.length || T.some((g,
|
|
698
|
+
if (T.length !== k.length || T.some((g, C) => g !== k[C]))
|
|
708
699
|
throw new Error(
|
|
709
700
|
`Universal challenger BTC pubkeys (v${c}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
710
701
|
);
|
|
711
702
|
return {
|
|
712
|
-
vaultProviderBtcPubkeyXOnly:
|
|
703
|
+
vaultProviderBtcPubkeyXOnly: u,
|
|
713
704
|
vaultKeeperBtcPubkeysSorted: v,
|
|
714
705
|
universalChallengerBtcPubkeysSorted: k,
|
|
715
706
|
expectedAppVaultKeepersVersion: h,
|
|
@@ -717,33 +708,36 @@ async function ft(e) {
|
|
|
717
708
|
};
|
|
718
709
|
}
|
|
719
710
|
class j extends Error {
|
|
720
|
-
constructor(
|
|
721
|
-
super(
|
|
711
|
+
constructor(t) {
|
|
712
|
+
super(t), this.name = "RegisteredVaultVersionMismatchError";
|
|
722
713
|
}
|
|
723
714
|
}
|
|
724
|
-
function
|
|
715
|
+
function Pt(e) {
|
|
725
716
|
return e instanceof j || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
726
717
|
}
|
|
727
|
-
async function
|
|
718
|
+
async function bt(e) {
|
|
728
719
|
const {
|
|
729
|
-
vaultRegistryReader:
|
|
730
|
-
vaultIds:
|
|
720
|
+
vaultRegistryReader: t,
|
|
721
|
+
vaultIds: r,
|
|
731
722
|
expectedOffchainParamsVersion: n,
|
|
732
723
|
expectedAppVaultKeepersVersion: s,
|
|
733
|
-
expectedUniversalChallengersVersion:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
724
|
+
expectedUniversalChallengersVersion: l,
|
|
725
|
+
expectedVaultCoreVersion: a
|
|
726
|
+
} = e, i = await t.getProtocolInfoBatch(r), o = [];
|
|
727
|
+
if (i.forEach((u, h) => {
|
|
728
|
+
const c = r[h];
|
|
729
|
+
u.offchainParamsVersion !== n && o.push(
|
|
730
|
+
`vault ${c}: offchainParams expected v${n}, got v${u.offchainParamsVersion}`
|
|
731
|
+
), u.appVaultKeepersVersion !== s && o.push(
|
|
732
|
+
`vault ${c}: appVaultKeepers expected v${s}, got v${u.appVaultKeepersVersion}`
|
|
733
|
+
), u.universalChallengersVersion !== l && o.push(
|
|
734
|
+
`vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
|
|
735
|
+
), u.vaultCoreVersion !== a && o.push(
|
|
736
|
+
`vault ${c}: vaultCoreVersion expected v${a} (build-time active), got v${u.vaultCoreVersion}`
|
|
737
|
+
);
|
|
738
|
+
}), o.length > 0)
|
|
745
739
|
throw new j(
|
|
746
|
-
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${
|
|
740
|
+
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${o.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
747
741
|
);
|
|
748
742
|
}
|
|
749
743
|
var Q = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(Q || {});
|
|
@@ -752,44 +746,44 @@ const Le = /* @__PURE__ */ new Set([
|
|
|
752
746
|
"PayoutBlocked"
|
|
753
747
|
/* PAYOUT_BLOCKED */
|
|
754
748
|
]);
|
|
755
|
-
function
|
|
749
|
+
function yt(e) {
|
|
756
750
|
return Object.values(Q).includes(
|
|
757
751
|
e
|
|
758
752
|
);
|
|
759
753
|
}
|
|
760
|
-
function
|
|
754
|
+
function wt(e) {
|
|
761
755
|
return !!e && Le.has(e);
|
|
762
756
|
}
|
|
763
757
|
class Xe extends Error {
|
|
764
|
-
constructor(
|
|
758
|
+
constructor(r, n) {
|
|
765
759
|
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
this.name = "BIP68NotMatureError", this.vaultId =
|
|
760
|
+
$(this, "vaultId");
|
|
761
|
+
$(this, "cause");
|
|
762
|
+
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
|
|
769
763
|
}
|
|
770
764
|
}
|
|
771
|
-
const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/,
|
|
772
|
-
function
|
|
765
|
+
const ze = /^0x[0-9a-fA-F]{64}$/, Ge = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Y = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, W = 160, F = 2e3, M = 10n, L = 100n;
|
|
766
|
+
function xt(e) {
|
|
773
767
|
if (!Number.isFinite(e) || e <= 0)
|
|
774
768
|
throw new Error(
|
|
775
769
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
776
770
|
);
|
|
777
|
-
return BigInt(Math.ceil(e *
|
|
771
|
+
return BigInt(Math.ceil(e * W));
|
|
778
772
|
}
|
|
779
773
|
const qe = 1, je = /non-BIP68-final/i;
|
|
780
|
-
function D(e,
|
|
774
|
+
function D(e, t) {
|
|
781
775
|
if (e.length !== 66)
|
|
782
776
|
throw new Error(
|
|
783
|
-
`${
|
|
777
|
+
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
784
778
|
);
|
|
785
779
|
if (!ze.test(e))
|
|
786
780
|
throw new Error(
|
|
787
|
-
`${
|
|
781
|
+
`${t} must contain only hex characters after the 0x prefix`
|
|
788
782
|
);
|
|
789
783
|
}
|
|
790
|
-
function
|
|
784
|
+
function B(e, t) {
|
|
791
785
|
if (!Number.isInteger(e) || e < 0)
|
|
792
|
-
throw new Error(`${
|
|
786
|
+
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
793
787
|
}
|
|
794
788
|
function Qe(e) {
|
|
795
789
|
if (D(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
|
|
@@ -802,44 +796,47 @@ function Qe(e) {
|
|
|
802
796
|
throw new Error(
|
|
803
797
|
`htlcVout ${e.htlcVout} is out of range for batch of size ${e.batch.length}`
|
|
804
798
|
);
|
|
805
|
-
for (let
|
|
806
|
-
const n = e.batch[
|
|
807
|
-
if (D(n.hashlock, `batch[${
|
|
799
|
+
for (let r = 0; r < e.batch.length; r++) {
|
|
800
|
+
const n = e.batch[r];
|
|
801
|
+
if (D(n.hashlock, `batch[${r}].hashlock`), !Number.isInteger(n.htlcVout) || n.htlcVout !== r)
|
|
808
802
|
throw new Error(
|
|
809
|
-
`batch[${
|
|
803
|
+
`batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${n.htlcVout}`
|
|
810
804
|
);
|
|
811
805
|
if (typeof n.amount != "bigint" || n.amount <= 0n)
|
|
812
806
|
throw new Error(
|
|
813
|
-
`batch[${
|
|
807
|
+
`batch[${r}].amount must be a positive bigint, got ${n.amount}`
|
|
814
808
|
);
|
|
815
809
|
}
|
|
816
|
-
const
|
|
817
|
-
if (
|
|
810
|
+
const t = e.batch[e.htlcVout];
|
|
811
|
+
if (t.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
|
|
818
812
|
throw new Error(
|
|
819
|
-
`batch[${e.htlcVout}].hashlock (${
|
|
813
|
+
`batch[${e.htlcVout}].hashlock (${t.hashlock}) does not match target hashlock (${e.hashlock})`
|
|
820
814
|
);
|
|
821
|
-
if (
|
|
815
|
+
if (t.amount !== e.amount)
|
|
822
816
|
throw new Error(
|
|
823
|
-
`batch[${e.htlcVout}].amount (${
|
|
817
|
+
`batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
|
|
824
818
|
);
|
|
825
|
-
if (
|
|
819
|
+
if (B(e.offchainParamsVersion, "offchainParamsVersion"), B(e.appVaultKeepersVersion, "appVaultKeepersVersion"), B(
|
|
826
820
|
e.universalChallengersVersion,
|
|
827
821
|
"universalChallengersVersion"
|
|
822
|
+
), fe(
|
|
823
|
+
e.vaultCoreVersion,
|
|
824
|
+
"VaultRefundData.vaultCoreVersion"
|
|
828
825
|
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
829
826
|
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
830
827
|
if (!Ge.test(e.unsignedPrePeginTxHex))
|
|
831
828
|
throw new Error(
|
|
832
829
|
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
833
830
|
);
|
|
834
|
-
if (!e.depositorBtcPubkey || !
|
|
831
|
+
if (!e.depositorBtcPubkey || !Y.test(e.depositorBtcPubkey))
|
|
835
832
|
throw new Error(
|
|
836
833
|
"depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
|
|
837
834
|
);
|
|
838
835
|
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
839
836
|
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
840
837
|
}
|
|
841
|
-
function
|
|
842
|
-
if (!e.vaultProviderPubkey || !
|
|
838
|
+
function Ye(e) {
|
|
839
|
+
if (!e.vaultProviderPubkey || !Y.test(e.vaultProviderPubkey))
|
|
843
840
|
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
844
841
|
if (e.vaultKeeperPubkeys.length === 0)
|
|
845
842
|
throw new Error("vaultKeeperPubkeys must be non-empty");
|
|
@@ -864,38 +861,38 @@ function We(e) {
|
|
|
864
861
|
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
865
862
|
);
|
|
866
863
|
}
|
|
867
|
-
function
|
|
868
|
-
const
|
|
864
|
+
function We(e) {
|
|
865
|
+
const t = ce.fromHex(e);
|
|
869
866
|
try {
|
|
870
|
-
|
|
871
|
-
} catch (
|
|
872
|
-
const n =
|
|
867
|
+
t.finalizeAllInputs();
|
|
868
|
+
} catch (r) {
|
|
869
|
+
const n = r instanceof Error ? r.message : String(r);
|
|
873
870
|
if (!n.includes("already finalized"))
|
|
874
871
|
throw new Error(`Failed to finalize refund PSBT: ${n}`);
|
|
875
872
|
}
|
|
876
|
-
return
|
|
873
|
+
return t.extractTransaction().toHex();
|
|
877
874
|
}
|
|
878
|
-
async function
|
|
875
|
+
async function vt(e) {
|
|
879
876
|
const {
|
|
880
|
-
vaultId:
|
|
881
|
-
readVault:
|
|
877
|
+
vaultId: t,
|
|
878
|
+
readVault: r,
|
|
882
879
|
readPrePeginContext: n,
|
|
883
880
|
feeRate: s,
|
|
884
|
-
signPsbt:
|
|
881
|
+
signPsbt: l,
|
|
885
882
|
broadcastTx: a,
|
|
886
883
|
signal: i
|
|
887
884
|
} = e;
|
|
888
|
-
i == null || i.throwIfAborted(), D(
|
|
889
|
-
const o = await
|
|
885
|
+
i == null || i.throwIfAborted(), D(t, "vaultId");
|
|
886
|
+
const o = await r();
|
|
890
887
|
Qe(o), i == null || i.throwIfAborted();
|
|
891
|
-
const
|
|
892
|
-
if (
|
|
888
|
+
const u = await n(o);
|
|
889
|
+
if (Ye(u), i == null || i.throwIfAborted(), !Number.isFinite(s) || s <= 0)
|
|
893
890
|
throw new Error(`feeRate must be a positive number, got ${s}`);
|
|
894
891
|
if (s > F)
|
|
895
892
|
throw new Error(
|
|
896
893
|
`feeRate ${s} sat/vB exceeds refund safety cap ${F} sat/vB; refusing to sign refund.`
|
|
897
894
|
);
|
|
898
|
-
const h = BigInt(Math.ceil(s *
|
|
895
|
+
const h = BigInt(Math.ceil(s * W)), c = o.amount * M / L;
|
|
899
896
|
if (h > c)
|
|
900
897
|
throw new Error(
|
|
901
898
|
`Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${M}/${L} of vault.amount=${o.amount}); refusing to sign refund.`
|
|
@@ -903,7 +900,7 @@ async function xt(e) {
|
|
|
903
900
|
i == null || i.throwIfAborted();
|
|
904
901
|
const d = A(
|
|
905
902
|
o.depositorBtcPubkey
|
|
906
|
-
), P = p(o.unsignedPrePeginTxHex), m =
|
|
903
|
+
), P = p(o.unsignedPrePeginTxHex), m = se(P);
|
|
907
904
|
if (m !== void 0 && m.vout !== o.batch.length)
|
|
908
905
|
throw new Error(
|
|
909
906
|
`Auth-anchor OP_RETURN at vout ${m.vout} does not match batch size (${o.batch.length} HTLC outputs expect the anchor at vout ${o.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
|
|
@@ -911,7 +908,7 @@ async function xt(e) {
|
|
|
911
908
|
const y = m == null ? void 0 : m.hash;
|
|
912
909
|
let x;
|
|
913
910
|
try {
|
|
914
|
-
x =
|
|
911
|
+
x = S.fromHex(P);
|
|
915
912
|
} catch (f) {
|
|
916
913
|
throw new Error(
|
|
917
914
|
`Failed to parse funded Pre-PegIn transaction hex: ${f instanceof Error ? f.message : String(f)}`
|
|
@@ -923,12 +920,13 @@ async function xt(e) {
|
|
|
923
920
|
);
|
|
924
921
|
const { psbtHex: b } = await ge({
|
|
925
922
|
prePeginParams: {
|
|
923
|
+
vaultCoreVersion: o.vaultCoreVersion,
|
|
926
924
|
depositorPubkey: d,
|
|
927
|
-
vaultProviderPubkey: p(
|
|
928
|
-
vaultKeeperPubkeys:
|
|
929
|
-
universalChallengerPubkeys:
|
|
925
|
+
vaultProviderPubkey: p(u.vaultProviderPubkey),
|
|
926
|
+
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(p),
|
|
927
|
+
universalChallengerPubkeys: u.universalChallengerPubkeys.map(p),
|
|
930
928
|
hashlocks: o.batch.map((f) => p(f.hashlock)),
|
|
931
|
-
timelockRefund:
|
|
929
|
+
timelockRefund: u.timelockRefund,
|
|
932
930
|
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
933
931
|
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
934
932
|
// reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
|
|
@@ -936,12 +934,12 @@ async function xt(e) {
|
|
|
936
934
|
// to the funded tx bytes, refusing the refund if the template's HTLC value
|
|
937
935
|
// disagrees with the on-chain commitment.
|
|
938
936
|
pegInAmounts: o.batch.map((f) => f.amount),
|
|
939
|
-
feeRate:
|
|
940
|
-
minPeginFeeRate:
|
|
941
|
-
numLocalChallengers:
|
|
942
|
-
councilQuorum:
|
|
943
|
-
councilSize:
|
|
944
|
-
network:
|
|
937
|
+
feeRate: u.feeRate,
|
|
938
|
+
minPeginFeeRate: u.minPeginFeeRate,
|
|
939
|
+
numLocalChallengers: u.numLocalChallengers,
|
|
940
|
+
councilQuorum: u.councilQuorum,
|
|
941
|
+
councilSize: u.councilSize,
|
|
942
|
+
network: u.network,
|
|
945
943
|
authAnchorHash: y
|
|
946
944
|
},
|
|
947
945
|
fundedPrePeginTxHex: P,
|
|
@@ -957,8 +955,8 @@ async function xt(e) {
|
|
|
957
955
|
const v = O(
|
|
958
956
|
o.depositorBtcPubkey,
|
|
959
957
|
qe
|
|
960
|
-
), T = await
|
|
961
|
-
|
|
958
|
+
), T = await l(b, v);
|
|
959
|
+
I({
|
|
962
960
|
requestedPsbtHex: b,
|
|
963
961
|
returnedPsbtHex: T
|
|
964
962
|
});
|
|
@@ -973,40 +971,40 @@ async function xt(e) {
|
|
|
973
971
|
signerXOnlyPubkeyHex: d,
|
|
974
972
|
inputIndex: k
|
|
975
973
|
});
|
|
976
|
-
const
|
|
974
|
+
const C = We(T);
|
|
977
975
|
i == null || i.throwIfAborted();
|
|
978
976
|
try {
|
|
979
|
-
return await a(
|
|
977
|
+
return await a(C);
|
|
980
978
|
} catch (f) {
|
|
981
|
-
throw f instanceof Error && je.test(f.message) ? new Xe(
|
|
979
|
+
throw f instanceof Error && je.test(f.message) ? new Xe(t, f) : f;
|
|
982
980
|
}
|
|
983
981
|
}
|
|
984
982
|
export {
|
|
985
983
|
Xe as B,
|
|
986
984
|
Q as C,
|
|
987
985
|
j as R,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
986
|
+
ut as a,
|
|
987
|
+
Ve as b,
|
|
988
|
+
pt as c,
|
|
989
|
+
gt as d,
|
|
992
990
|
De as e,
|
|
993
991
|
Ke as f,
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
992
|
+
ft as g,
|
|
993
|
+
mt as h,
|
|
994
|
+
ht as i,
|
|
995
|
+
Pt as j,
|
|
996
|
+
bt as k,
|
|
997
|
+
yt as l,
|
|
998
|
+
wt as m,
|
|
999
|
+
vt as n,
|
|
1000
|
+
xt as o,
|
|
1003
1001
|
L as p,
|
|
1004
1002
|
M as q,
|
|
1005
|
-
|
|
1006
|
-
|
|
1003
|
+
ct as r,
|
|
1004
|
+
lt as s,
|
|
1007
1005
|
F as t,
|
|
1008
|
-
|
|
1009
|
-
|
|
1006
|
+
W as u,
|
|
1007
|
+
dt as v,
|
|
1010
1008
|
G as w
|
|
1011
1009
|
};
|
|
1012
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
1010
|
+
//# sourceMappingURL=buildAndBroadcastRefund-BiSO4zg2.js.map
|