@babylonlabs-io/ts-sdk 1.0.0 → 1.2.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/{signPsbtsWithFallback-DoRbHHua.js → PayoutManager-CHTOwj0E.js} +25 -25
- package/dist/PayoutManager-CHTOwj0E.js.map +1 -0
- package/dist/PayoutManager-CpfQjtL0.cjs +2 -0
- package/dist/PayoutManager-CpfQjtL0.cjs.map +1 -0
- package/dist/PeginManager-6tjlGd0t.cjs +2 -0
- package/dist/PeginManager-6tjlGd0t.cjs.map +1 -0
- package/dist/{PeginManager-BH_AKu4l.js → PeginManager-DEldv_Ro.js} +21 -20
- package/dist/PeginManager-DEldv_Ro.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs.map +1 -0
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js +1919 -0
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js.map +1 -0
- package/dist/challengeAssert-Cp_GeRg8.js.map +1 -1
- package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -1
- package/dist/deriveVaultRoot-BwbXmN0x.js +79 -0
- package/dist/{parseFundingOutpoints-BwC3foxS.cjs.map → deriveVaultRoot-BwbXmN0x.js.map} +1 -1
- package/dist/deriveVaultRoot-DvhkHzNb.cjs +2 -0
- package/dist/deriveVaultRoot-DvhkHzNb.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +286 -268
- package/dist/index.js.map +1 -1
- package/dist/noPayout-DAWBQ0eG.cjs.map +1 -1
- package/dist/noPayout-qBXWKwav.js.map +1 -1
- package/dist/onChainBtcPubkey-BXry_CM4.cjs +2 -0
- package/dist/onChainBtcPubkey-BXry_CM4.cjs.map +1 -0
- package/dist/onChainBtcPubkey-C1WqyxPM.js +159 -0
- package/dist/onChainBtcPubkey-C1WqyxPM.js.map +1 -0
- package/dist/parseFundingOutpoints-C_-PT9BT.cjs +2 -0
- package/dist/parseFundingOutpoints-C_-PT9BT.cjs.map +1 -0
- package/dist/parseFundingOutpoints-GSM-IaaK.js +17 -0
- package/dist/parseFundingOutpoints-GSM-IaaK.js.map +1 -0
- package/dist/{pegin-registration-client-pcczkzMg.js → pegin-registration-client-1sZ-74UC.js} +260 -383
- package/dist/pegin-registration-client-1sZ-74UC.js.map +1 -0
- package/dist/pegin-registration-client-BNV44jzw.cjs +2 -0
- package/dist/pegin-registration-client-BNV44jzw.cjs.map +1 -0
- package/dist/signing-3l5Aqd-H.cjs +2 -0
- package/dist/signing-3l5Aqd-H.cjs.map +1 -0
- package/dist/signing-Dhr2t0Z6.js +39 -0
- package/dist/signing-Dhr2t0Z6.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +8 -8
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +8 -8
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +284 -266
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/index.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +2 -2
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts +13 -7
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts +15 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts +11 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts +10 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts +10 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts +11 -0
- package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +46 -0
- package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +72 -0
- package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts +63 -0
- package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/index.d.ts +55 -0
- package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts +65 -0
- package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +70 -0
- package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/types.d.ts +105 -0
- package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -0
- package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts +44 -0
- package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +1 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +73 -56
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +44 -43
- package/dist/tbv/core/utils/signing.d.ts +24 -0
- package/dist/tbv/core/utils/signing.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.js +9 -8
- package/dist/tbv/core/vault-secrets/index.js.map +1 -1
- package/dist/tbv/core/wasm/index.cjs +1 -1
- package/dist/tbv/core/wasm/index.cjs.map +1 -1
- package/dist/tbv/core/wasm/index.d.ts +102 -5
- package/dist/tbv/core/wasm/index.d.ts.map +1 -1
- package/dist/tbv/core/wasm/index.js +170 -73
- package/dist/tbv/core/wasm/index.js.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +284 -266
- package/dist/tbv/index.js.map +1 -1
- package/dist/tbv/integrations/aave/clients/abis/AaveSpoke.abi.json.d.ts +18 -0
- 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/spoke.d.ts +17 -0
- package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/constants.d.ts +8 -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 +2 -2
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +119 -110
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/tbv/integrations/aave/types.d.ts +1 -1
- package/dist/toRefundInputs-BaN9XluU.cjs +2 -0
- package/dist/{toRefundInputs-DEPXcrgO.cjs.map → toRefundInputs-BaN9XluU.cjs.map} +1 -1
- package/dist/{toRefundInputs-BEulLgN_.js → toRefundInputs-mtuuYezp.js} +23 -22
- package/dist/{toRefundInputs-BEulLgN_.js.map → toRefundInputs-mtuuYezp.js.map} +1 -1
- package/dist/{types-B9YhlXe8.js → types-BdCEoANP.js} +2 -2
- package/dist/{types-B9YhlXe8.js.map → types-BdCEoANP.js.map} +1 -1
- package/dist/{types-C1tpDycc.cjs → types-BuxreSq4.cjs} +2 -2
- package/dist/{types-C1tpDycc.cjs.map → types-BuxreSq4.cjs.map} +1 -1
- package/dist/verifyScriptPathSchnorrSignature-BKZihCjk.cjs.map +1 -1
- package/dist/verifyScriptPathSchnorrSignature-CpjSTfMj.js.map +1 -1
- package/package.json +3 -3
- package/dist/PeginManager-BCJWwV05.cjs +0 -2
- package/dist/PeginManager-BCJWwV05.cjs.map +0 -1
- package/dist/PeginManager-BH_AKu4l.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-DLsf5hjO.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-DLsf5hjO.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-OMvihzJg.js +0 -1545
- package/dist/buildAndBroadcastReclaim-OMvihzJg.js.map +0 -1
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs +0 -2
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs.map +0 -1
- package/dist/onChainBtcPubkey-C-6UWpD8.js +0 -34
- package/dist/onChainBtcPubkey-C-6UWpD8.js.map +0 -1
- package/dist/parseFundingOutpoints-BwC3foxS.cjs +0 -2
- package/dist/parseFundingOutpoints-CC4NKYz2.js +0 -93
- package/dist/parseFundingOutpoints-CC4NKYz2.js.map +0 -1
- package/dist/pegin-registration-client-CZgcU2_0.cjs +0 -2
- package/dist/pegin-registration-client-CZgcU2_0.cjs.map +0 -1
- package/dist/pegin-registration-client-pcczkzMg.js.map +0 -1
- package/dist/signPsbtsWithFallback-DoRbHHua.js.map +0 -1
- package/dist/signPsbtsWithFallback-FwrTYZS4.cjs +0 -2
- package/dist/signPsbtsWithFallback-FwrTYZS4.cjs.map +0 -1
- package/dist/signing-BJ3X66b-.cjs +0 -2
- package/dist/signing-BJ3X66b-.cjs.map +0 -1
- package/dist/signing-Cm-McVR2.js +0 -22
- package/dist/signing-Cm-McVR2.js.map +0 -1
- package/dist/toRefundInputs-DEPXcrgO.cjs +0 -2
|
@@ -1,1545 +0,0 @@
|
|
|
1
|
-
var Re = Object.defineProperty;
|
|
2
|
-
var _e = (e, t, r) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var S = (e, t, r) => _e(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { B as pe } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
|
|
5
|
-
import { e as he, v as Se, s as y, u as de, p as O, c as C, f as _ } from "./bitcoin-C-TuHb-v.js";
|
|
6
|
-
import { v as $e, d as Be, s as Ie, P as Ve, a as Ke } from "./signPsbtsWithFallback-DoRbHHua.js";
|
|
7
|
-
import { zeroAddress as Oe, isAddress as Ne, isAddressEqual as He } from "viem";
|
|
8
|
-
import { D as R, c as De, b as Me, R as Fe, d as ge } from "./json-rpc-client-DuUARJvV.js";
|
|
9
|
-
import { Transaction as $ } from "bitcoinjs-lib";
|
|
10
|
-
import { p as Ue, f as Le, i as B, g as I, j as V } from "./verifyScriptPathSchnorrSignature-CpjSTfMj.js";
|
|
11
|
-
import { D as W } from "./constants-D5vORbQE.js";
|
|
12
|
-
import { d as Xe, c as qe, b as Ge, f as fe, e as ze, a as je } from "./noPayout-qBXWKwav.js";
|
|
13
|
-
import { a as K, c as Qe } from "./signing-Cm-McVR2.js";
|
|
14
|
-
import { a as Y } from "./onChainBtcPubkey-C-6UWpD8.js";
|
|
15
|
-
import { a as We } from "./secp256k1-D-H9jmd7.js";
|
|
16
|
-
import { deriveVaultId as Ye } from "./tbv/core/wasm/index.js";
|
|
17
|
-
const Je = /^0x[0-9a-fA-F]{64}$/, Ze = /^0x[0-9a-fA-F]{40}$/, et = /^0x([0-9a-fA-F]{2})*$/;
|
|
18
|
-
function N(e, t) {
|
|
19
|
-
if (e.length !== 66)
|
|
20
|
-
throw new Error(
|
|
21
|
-
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
22
|
-
);
|
|
23
|
-
if (!Je.test(e))
|
|
24
|
-
throw new Error(
|
|
25
|
-
`${t} must contain only hex characters after the 0x prefix`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function tt(e, t) {
|
|
29
|
-
if (!Ze.test(e))
|
|
30
|
-
throw new Error(
|
|
31
|
-
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
function rt(e, t) {
|
|
35
|
-
if (!et.test(e))
|
|
36
|
-
throw new Error(
|
|
37
|
-
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
function me(e) {
|
|
41
|
-
tt(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), N(e.vaultId, "vaultId");
|
|
42
|
-
const t = he(e.secret);
|
|
43
|
-
if (N(t, "secret"), e.hashlock !== void 0 && (N(e.hashlock, "hashlock"), !$e(t, e.hashlock)))
|
|
44
|
-
throw new Error(
|
|
45
|
-
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
46
|
-
);
|
|
47
|
-
return t;
|
|
48
|
-
}
|
|
49
|
-
async function or(e) {
|
|
50
|
-
const {
|
|
51
|
-
btcVaultRegistryAddress: t,
|
|
52
|
-
vaultId: r,
|
|
53
|
-
hashlock: o,
|
|
54
|
-
activationMetadata: a,
|
|
55
|
-
writeContract: l,
|
|
56
|
-
signal: s
|
|
57
|
-
} = e;
|
|
58
|
-
s == null || s.throwIfAborted();
|
|
59
|
-
const i = me({
|
|
60
|
-
btcVaultRegistryAddress: t,
|
|
61
|
-
vaultId: r,
|
|
62
|
-
secret: e.secret,
|
|
63
|
-
hashlock: o
|
|
64
|
-
});
|
|
65
|
-
return rt(a, "activationMetadata"), l({
|
|
66
|
-
address: t,
|
|
67
|
-
abi: pe,
|
|
68
|
-
functionName: "activateVaultWithSecret",
|
|
69
|
-
args: [r, i, a]
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
async function nr(e) {
|
|
73
|
-
const { btcVaultRegistryAddress: t, vaultId: r, hashlock: o, writeContract: a, signal: l } = e;
|
|
74
|
-
l == null || l.throwIfAborted();
|
|
75
|
-
const s = me({
|
|
76
|
-
btcVaultRegistryAddress: t,
|
|
77
|
-
vaultId: r,
|
|
78
|
-
secret: e.secret,
|
|
79
|
-
hashlock: o
|
|
80
|
-
});
|
|
81
|
-
return a({
|
|
82
|
-
address: t,
|
|
83
|
-
abi: pe,
|
|
84
|
-
functionName: "activateVaultWithSecretAndRedeem",
|
|
85
|
-
args: [r, s]
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const ot = 8, nt = 6e3, st = 10 * 6e4, at = 10;
|
|
89
|
-
class Pe extends Error {
|
|
90
|
-
constructor(t) {
|
|
91
|
-
super(t), this.name = "PeginRegistrationMissingError";
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
class ve extends Error {
|
|
95
|
-
constructor(t) {
|
|
96
|
-
super(t), this.name = "PeginRegistrationNotFinalError";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function it(e) {
|
|
100
|
-
return e instanceof Pe || e instanceof Error && e.name === "PeginRegistrationMissingError";
|
|
101
|
-
}
|
|
102
|
-
function sr(e) {
|
|
103
|
-
return e instanceof ve || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
|
|
104
|
-
}
|
|
105
|
-
function J(e) {
|
|
106
|
-
const { currentBlock: t, createdAtBlock: r } = e, o = t - r + 1n;
|
|
107
|
-
return o < 0n ? 0 : Number(o);
|
|
108
|
-
}
|
|
109
|
-
async function ar(e) {
|
|
110
|
-
const {
|
|
111
|
-
vaultRegistryReader: t,
|
|
112
|
-
getBlockNumber: r,
|
|
113
|
-
vaultIds: o,
|
|
114
|
-
required: a = ot,
|
|
115
|
-
pollIntervalMs: l = nt,
|
|
116
|
-
timeoutMs: s = st,
|
|
117
|
-
signal: i,
|
|
118
|
-
onProgress: n
|
|
119
|
-
} = e;
|
|
120
|
-
if (o.length === 0)
|
|
121
|
-
throw new Error(
|
|
122
|
-
"waitForPeginRegistrationDepth requires at least one vault ID"
|
|
123
|
-
);
|
|
124
|
-
const u = Date.now();
|
|
125
|
-
let p = !1, c = 0, h;
|
|
126
|
-
for (; ; ) {
|
|
127
|
-
if (i != null && i.aborted)
|
|
128
|
-
throw new Error(
|
|
129
|
-
`Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
|
|
130
|
-
);
|
|
131
|
-
if (Date.now() - u >= s)
|
|
132
|
-
throw new ve(
|
|
133
|
-
`Peg-in registration did not reach ${a} Ethereum confirmations within ${s}ms. The registration transaction was submitted but is not yet final, so the Pre-PegIn Bitcoin transaction was never sent and no funds are at risk. Resume this deposit from the dashboard once the network settles.` + (h instanceof Error ? ` Last read error: ${h.message}` : "")
|
|
134
|
-
);
|
|
135
|
-
try {
|
|
136
|
-
const d = await r(), g = await Promise.all(
|
|
137
|
-
o.map((P) => t.getVaultBasicInfo(P))
|
|
138
|
-
), m = g.findIndex(
|
|
139
|
-
(P) => P.depositor === Oe || P.createdAt === 0n
|
|
140
|
-
);
|
|
141
|
-
if (m !== -1) {
|
|
142
|
-
if (c += 1, !p && c > at)
|
|
143
|
-
throw new Pe(
|
|
144
|
-
`Vault ${o[m]} is still not visible on-chain after ${c} reads — the registration does not exist.`
|
|
145
|
-
);
|
|
146
|
-
console.warn(
|
|
147
|
-
`Peg-in registration for vault ${o[m]} is not visible in chain state at block ${d} — a lagging RPC backend or an Ethereum reorg. Still polling.`
|
|
148
|
-
), n == null || n({ confirmations: 0, required: a });
|
|
149
|
-
} else {
|
|
150
|
-
p = !0, c = 0, h = void 0;
|
|
151
|
-
let P = g[0], f = J({
|
|
152
|
-
currentBlock: d,
|
|
153
|
-
createdAtBlock: g[0].createdAt
|
|
154
|
-
});
|
|
155
|
-
for (const x of g.slice(1)) {
|
|
156
|
-
const b = J({
|
|
157
|
-
currentBlock: d,
|
|
158
|
-
createdAtBlock: x.createdAt
|
|
159
|
-
});
|
|
160
|
-
b < f && (f = b, P = x);
|
|
161
|
-
}
|
|
162
|
-
if (n == null || n({ confirmations: f, required: a }), f >= a)
|
|
163
|
-
return { confirmations: f, basicInfo: P };
|
|
164
|
-
}
|
|
165
|
-
} catch (d) {
|
|
166
|
-
if (it(d))
|
|
167
|
-
throw d;
|
|
168
|
-
console.warn(
|
|
169
|
-
`Registration-depth read failed (retrying in ${l}ms): ` + (d instanceof Error ? d.message : String(d))
|
|
170
|
-
), h = d;
|
|
171
|
-
}
|
|
172
|
-
await new Promise((d, g) => {
|
|
173
|
-
const m = () => {
|
|
174
|
-
clearTimeout(P), g(
|
|
175
|
-
new Error(
|
|
176
|
-
`Aborted while waiting for peg-in registration depth (${o.length} vault(s))`
|
|
177
|
-
)
|
|
178
|
-
);
|
|
179
|
-
}, P = setTimeout(() => {
|
|
180
|
-
i == null || i.removeEventListener("abort", m), d();
|
|
181
|
-
}, l);
|
|
182
|
-
i == null || i.addEventListener("abort", m, { once: !0 });
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const ut = 1;
|
|
187
|
-
function lt(e, t, r) {
|
|
188
|
-
const o = r.map(
|
|
189
|
-
(c) => y(c).toLowerCase()
|
|
190
|
-
), a = t.filter((c) => o.includes(c));
|
|
191
|
-
if (a.length > 0)
|
|
192
|
-
throw new Error(
|
|
193
|
-
`Cannot validate challenger set: vault keepers and universal challengers overlap (${a.join(", ")})`
|
|
194
|
-
);
|
|
195
|
-
const l = [...t, ...o], s = e.map(
|
|
196
|
-
(c) => y(c.challenger_pubkey).toLowerCase()
|
|
197
|
-
), i = new Set(s);
|
|
198
|
-
if (i.size !== s.length)
|
|
199
|
-
throw new Error(
|
|
200
|
-
"Depositor graph contains duplicate challenger entries in challenger_presign_data"
|
|
201
|
-
);
|
|
202
|
-
const n = new Set(l), u = l.filter((c) => !i.has(c)), p = s.filter((c) => !n.has(c));
|
|
203
|
-
if (u.length > 0 || p.length > 0)
|
|
204
|
-
throw new Error(
|
|
205
|
-
"Depositor graph challenger set does not match expected (local ∪ universal)" + (u.length > 0 ? ` (missing: ${u.join(", ")})` : "") + (p.length > 0 ? ` (unexpected: ${p.join(", ")})` : "")
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
function ct(e, t) {
|
|
209
|
-
const r = e.ins[t];
|
|
210
|
-
return de(new Uint8Array(r.hash).slice().reverse());
|
|
211
|
-
}
|
|
212
|
-
function H(e, t, r, o, a) {
|
|
213
|
-
const l = e.ins[t];
|
|
214
|
-
if (l.index !== 0)
|
|
215
|
-
throw new Error(
|
|
216
|
-
`NoPayout (challenger ${a}) input ${t} expected to spend ${o} vout 0, got vout ${l.index}`
|
|
217
|
-
);
|
|
218
|
-
const s = r.getId(), i = ct(e, t);
|
|
219
|
-
if (i !== s)
|
|
220
|
-
throw new Error(
|
|
221
|
-
`NoPayout (challenger ${a}) input ${t} does not reference ${o} (expected txid ${s}, got ${i})`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
async function pt(e, t, r) {
|
|
225
|
-
const o = [], a = [], l = [], s = Ue({
|
|
226
|
-
claimerBtcPubkey: r.depositorBtcPubkey,
|
|
227
|
-
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
228
|
-
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
229
|
-
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
|
|
230
|
-
});
|
|
231
|
-
lt(
|
|
232
|
-
e.challenger_presign_data,
|
|
233
|
-
s,
|
|
234
|
-
r.universalChallengerBtcPubkeys
|
|
235
|
-
);
|
|
236
|
-
const i = await Le({
|
|
237
|
-
vaultCoreVersion: r.vaultCoreVersion,
|
|
238
|
-
vkClaimerPayoutScriptPubKeys: r.vkClaimerPayoutScriptPubKeys,
|
|
239
|
-
vpCommissionScriptPubKey: r.vpCommissionScriptPubKey,
|
|
240
|
-
payoutTxHex: e.payout_tx.tx_hex,
|
|
241
|
-
peginTxHex: r.peginTxHex,
|
|
242
|
-
assertTxHex: e.assert_tx.tx_hex,
|
|
243
|
-
timelockAssert: r.timelockAssert,
|
|
244
|
-
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
245
|
-
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
246
|
-
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys,
|
|
247
|
-
universalChallengerBtcPubkeys: r.universalChallengerBtcPubkeys,
|
|
248
|
-
timelockPegin: r.timelockPegin,
|
|
249
|
-
network: r.network,
|
|
250
|
-
claimerBtcPubkey: r.depositorBtcPubkey,
|
|
251
|
-
registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
|
|
252
|
-
commissionBps: ut,
|
|
253
|
-
protocolFeeRate: r.protocolFeeRate,
|
|
254
|
-
councilMembers: r.councilMembers,
|
|
255
|
-
councilQuorum: r.councilQuorum
|
|
256
|
-
});
|
|
257
|
-
o.push(i.psbtHex), a.push(
|
|
258
|
-
K(
|
|
259
|
-
t,
|
|
260
|
-
W
|
|
261
|
-
)
|
|
262
|
-
);
|
|
263
|
-
const n = y(r.depositorBtcPubkey), u = $.fromHex(
|
|
264
|
-
y(e.assert_tx.tx_hex)
|
|
265
|
-
);
|
|
266
|
-
for (const p of e.challenger_presign_data) {
|
|
267
|
-
const c = y(p.challenger_pubkey), h = o.length, d = await ht({
|
|
268
|
-
challenger: p,
|
|
269
|
-
challengerPubkey: c,
|
|
270
|
-
claimerPubkey: n,
|
|
271
|
-
localChallengers: s,
|
|
272
|
-
assertTxParsed: u,
|
|
273
|
-
ctx: r
|
|
274
|
-
});
|
|
275
|
-
o.push(d), a.push(
|
|
276
|
-
K(
|
|
277
|
-
t,
|
|
278
|
-
W
|
|
279
|
-
)
|
|
280
|
-
), l.push({
|
|
281
|
-
challengerPubkey: c,
|
|
282
|
-
noPayoutIdx: h
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
return { psbtHexes: o, signOptions: a, challengerEntries: l };
|
|
286
|
-
}
|
|
287
|
-
async function ht(e) {
|
|
288
|
-
const {
|
|
289
|
-
challenger: t,
|
|
290
|
-
challengerPubkey: r,
|
|
291
|
-
claimerPubkey: o,
|
|
292
|
-
localChallengers: a,
|
|
293
|
-
assertTxParsed: l,
|
|
294
|
-
ctx: s
|
|
295
|
-
} = e;
|
|
296
|
-
Xe(
|
|
297
|
-
t.nopayout_tx.tx_hex,
|
|
298
|
-
r,
|
|
299
|
-
s.network
|
|
300
|
-
);
|
|
301
|
-
const i = $.fromHex(
|
|
302
|
-
y(t.nopayout_tx.tx_hex)
|
|
303
|
-
), n = $.fromHex(
|
|
304
|
-
y(t.challenge_assert_x_tx.tx_hex)
|
|
305
|
-
), u = $.fromHex(
|
|
306
|
-
y(t.challenge_assert_y_tx.tx_hex)
|
|
307
|
-
);
|
|
308
|
-
if (i.ins.length !== 3)
|
|
309
|
-
throw new Error(
|
|
310
|
-
`NoPayout (challenger ${r}) must have exactly 3 inputs, got ${i.ins.length}`
|
|
311
|
-
);
|
|
312
|
-
H(
|
|
313
|
-
i,
|
|
314
|
-
0,
|
|
315
|
-
l,
|
|
316
|
-
"Assert",
|
|
317
|
-
r
|
|
318
|
-
), H(
|
|
319
|
-
i,
|
|
320
|
-
1,
|
|
321
|
-
n,
|
|
322
|
-
"ChallengeAssertX",
|
|
323
|
-
r
|
|
324
|
-
), H(
|
|
325
|
-
i,
|
|
326
|
-
2,
|
|
327
|
-
u,
|
|
328
|
-
"ChallengeAssertY",
|
|
329
|
-
r
|
|
330
|
-
);
|
|
331
|
-
const p = [
|
|
332
|
-
l.outs[0],
|
|
333
|
-
n.outs[0],
|
|
334
|
-
u.outs[0]
|
|
335
|
-
].map((c) => ({
|
|
336
|
-
script_pubkey: de(new Uint8Array(c.script)),
|
|
337
|
-
value: c.value
|
|
338
|
-
}));
|
|
339
|
-
return qe({
|
|
340
|
-
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
341
|
-
challengerPubkey: r,
|
|
342
|
-
prevouts: p,
|
|
343
|
-
connectorParams: {
|
|
344
|
-
txGraphVersion: s.vaultCoreVersion,
|
|
345
|
-
claimer: o,
|
|
346
|
-
localChallengers: a,
|
|
347
|
-
universalChallengers: s.universalChallengerBtcPubkeys,
|
|
348
|
-
timelockAssert: s.timelockAssert,
|
|
349
|
-
councilMembers: s.councilMembers,
|
|
350
|
-
councilQuorum: s.councilQuorum
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
function dt(e, t, r) {
|
|
355
|
-
B(e[0]);
|
|
356
|
-
const a = I(
|
|
357
|
-
e[0].returnedPsbtHex,
|
|
358
|
-
r
|
|
359
|
-
);
|
|
360
|
-
V({
|
|
361
|
-
requestedPsbtHex: e[0].requestedPsbtHex,
|
|
362
|
-
signatureHex: a,
|
|
363
|
-
signerXOnlyPubkeyHex: r,
|
|
364
|
-
inputIndex: 0
|
|
365
|
-
});
|
|
366
|
-
const l = {};
|
|
367
|
-
for (const s of t) {
|
|
368
|
-
B(e[s.noPayoutIdx]);
|
|
369
|
-
const i = I(
|
|
370
|
-
e[s.noPayoutIdx].returnedPsbtHex,
|
|
371
|
-
r
|
|
372
|
-
);
|
|
373
|
-
V({
|
|
374
|
-
requestedPsbtHex: e[s.noPayoutIdx].requestedPsbtHex,
|
|
375
|
-
signatureHex: i,
|
|
376
|
-
signerXOnlyPubkeyHex: r,
|
|
377
|
-
inputIndex: 0
|
|
378
|
-
}), l[s.challengerPubkey] = {
|
|
379
|
-
nopayout_signature: i
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
payout_signatures: {
|
|
384
|
-
payout_signature: a
|
|
385
|
-
},
|
|
386
|
-
per_challenger: l
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
async function gt(e) {
|
|
390
|
-
const { depositorGraph: t, btcWallet: r, signingContext: o } = e, a = await r.getPublicKeyHex(), { depositorPubkey: l } = Se(
|
|
391
|
-
a,
|
|
392
|
-
y(o.depositorBtcPubkey)
|
|
393
|
-
), { psbtHexes: s, signOptions: i, challengerEntries: n } = await pt(
|
|
394
|
-
t,
|
|
395
|
-
a,
|
|
396
|
-
o
|
|
397
|
-
), u = await Be(
|
|
398
|
-
r,
|
|
399
|
-
s,
|
|
400
|
-
i
|
|
401
|
-
), p = s.map((c, h) => ({
|
|
402
|
-
requestedPsbtHex: c,
|
|
403
|
-
returnedPsbtHex: u[h]
|
|
404
|
-
}));
|
|
405
|
-
return dt(
|
|
406
|
-
p,
|
|
407
|
-
n,
|
|
408
|
-
l
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
const ft = 1e4;
|
|
412
|
-
async function ye(e) {
|
|
413
|
-
const {
|
|
414
|
-
statusReader: t,
|
|
415
|
-
peginTxid: r,
|
|
416
|
-
targetStatuses: o,
|
|
417
|
-
timeoutMs: a,
|
|
418
|
-
pollIntervalMs: l = ft,
|
|
419
|
-
signal: s
|
|
420
|
-
} = e, i = Date.now();
|
|
421
|
-
for (; ; ) {
|
|
422
|
-
if (s != null && s.aborted)
|
|
423
|
-
throw new Error(
|
|
424
|
-
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
425
|
-
);
|
|
426
|
-
if (Date.now() - i >= a)
|
|
427
|
-
throw new Error(
|
|
428
|
-
`Polling timeout after ${a}ms for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
429
|
-
);
|
|
430
|
-
try {
|
|
431
|
-
const n = await t.getPeginStatus(
|
|
432
|
-
{ pegin_txid: r },
|
|
433
|
-
s
|
|
434
|
-
);
|
|
435
|
-
if (n.pegin_txid.toLowerCase() !== r.toLowerCase())
|
|
436
|
-
throw new Error(
|
|
437
|
-
`getPeginStatus returned status for pegin ${n.pegin_txid.slice(0, 8)}…, requested ${r.slice(0, 8)}…`
|
|
438
|
-
);
|
|
439
|
-
const u = n.status;
|
|
440
|
-
if (o.has(u) || u === R.ACTIVATED)
|
|
441
|
-
return u;
|
|
442
|
-
if (u === R.EXPIRED || De.has(u))
|
|
443
|
-
throw new Error(
|
|
444
|
-
`Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...o].join(", ")}`
|
|
445
|
-
);
|
|
446
|
-
} catch (n) {
|
|
447
|
-
if (!(n instanceof Me && n.code === Fe.PEGIN_NOT_FOUND))
|
|
448
|
-
throw n;
|
|
449
|
-
}
|
|
450
|
-
await new Promise((n, u) => {
|
|
451
|
-
const p = () => {
|
|
452
|
-
clearTimeout(c), u(
|
|
453
|
-
new Error(
|
|
454
|
-
`Polling aborted for pegin ${r.slice(0, 8)}… (target: ${[...o].join(", ")})`
|
|
455
|
-
)
|
|
456
|
-
);
|
|
457
|
-
}, c = setTimeout(() => {
|
|
458
|
-
s == null || s.removeEventListener("abort", p), n();
|
|
459
|
-
}, l);
|
|
460
|
-
s == null || s.addEventListener("abort", p, { once: !0 });
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
const mt = 1200 * 1e3, be = /* @__PURE__ */ new Set([
|
|
465
|
-
R.PENDING_ACKS,
|
|
466
|
-
R.PENDING_ACTIVATION,
|
|
467
|
-
R.ACTIVATED_PENDING_BROADCAST,
|
|
468
|
-
R.ACTIVATED
|
|
469
|
-
]), Pt = /* @__PURE__ */ new Set([
|
|
470
|
-
R.PENDING_DEPOSITOR_SIGNATURES,
|
|
471
|
-
...be
|
|
472
|
-
]);
|
|
473
|
-
function vt(e) {
|
|
474
|
-
return e.map((t) => ({
|
|
475
|
-
claimerPubkeyXOnly: O(t.claimer_pubkey),
|
|
476
|
-
payoutTxHex: t.payout_tx.tx_hex,
|
|
477
|
-
assertTxHex: t.assert_tx.tx_hex
|
|
478
|
-
}));
|
|
479
|
-
}
|
|
480
|
-
function A(e) {
|
|
481
|
-
return O(e).toLowerCase();
|
|
482
|
-
}
|
|
483
|
-
function yt(e, t) {
|
|
484
|
-
const r = (n, u, p) => {
|
|
485
|
-
throw new Error(
|
|
486
|
-
`Deposit terms ${n} (${String(u)}) does not match the vault's version-locked signing context (${String(p)}); refusing to sign payouts against terms that describe a different graph.`
|
|
487
|
-
);
|
|
488
|
-
}, o = [
|
|
489
|
-
["protocolFeeRate", e.protocolFeeRate, t.protocolFeeRate],
|
|
490
|
-
["vaultCoreVersion", e.vaultCoreVersion, t.vaultCoreVersion],
|
|
491
|
-
["timelockPegin", e.timelockPegin, t.timelockPegin],
|
|
492
|
-
["timelockAssert", e.timelockAssert, t.timelockAssert]
|
|
493
|
-
];
|
|
494
|
-
for (const [n, u, p] of o)
|
|
495
|
-
u !== p && r(n, u, p);
|
|
496
|
-
const a = (n) => n.map(A).sort(), l = (n, u) => {
|
|
497
|
-
const p = a(n), c = a(u);
|
|
498
|
-
return p.length === c.length && p.every((h, d) => h === c[d]);
|
|
499
|
-
};
|
|
500
|
-
l(e.vaultKeeperBtcPubkeys, t.vaultKeeperBtcPubkeys) || r(
|
|
501
|
-
"vaultKeeperBtcPubkeys",
|
|
502
|
-
e.vaultKeeperBtcPubkeys.join(","),
|
|
503
|
-
t.vaultKeeperBtcPubkeys.join(",")
|
|
504
|
-
), l(
|
|
505
|
-
e.universalChallengerBtcPubkeys,
|
|
506
|
-
t.universalChallengerBtcPubkeys
|
|
507
|
-
) || r(
|
|
508
|
-
"universalChallengerBtcPubkeys",
|
|
509
|
-
e.universalChallengerBtcPubkeys.join(","),
|
|
510
|
-
t.universalChallengerBtcPubkeys.join(",")
|
|
511
|
-
);
|
|
512
|
-
const s = A(t.vaultProviderBtcPubkey), i = e.vaults.map(
|
|
513
|
-
(n) => A(n.vaultProviderBtcPubkey)
|
|
514
|
-
);
|
|
515
|
-
i.includes(s) || r(
|
|
516
|
-
"vaults[].vaultProviderBtcPubkey",
|
|
517
|
-
i.join(",") || "<no vaults>",
|
|
518
|
-
t.vaultProviderBtcPubkey
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
function bt(e, t, r, o) {
|
|
522
|
-
const a = A(o), l = [
|
|
523
|
-
A(t),
|
|
524
|
-
...r.map(A)
|
|
525
|
-
], s = new Set(l);
|
|
526
|
-
if (s.size !== l.length)
|
|
527
|
-
throw new Error(
|
|
528
|
-
"Cannot validate claimer set: signing context contains duplicate vault provider or vault keeper key"
|
|
529
|
-
);
|
|
530
|
-
if (s.has(a))
|
|
531
|
-
throw new Error(
|
|
532
|
-
"Cannot validate claimer set: depositor key overlaps with vault provider or vault keeper set"
|
|
533
|
-
);
|
|
534
|
-
const i = e.map(
|
|
535
|
-
(h) => A(h.claimer_pubkey)
|
|
536
|
-
);
|
|
537
|
-
if (new Set(i).size !== i.length)
|
|
538
|
-
throw new Error("Presign response contains duplicate claimer entries");
|
|
539
|
-
const n = i.filter((h) => h !== a), u = new Set(n), p = l.filter((h) => !u.has(h)), c = n.filter((h) => !s.has(h));
|
|
540
|
-
if (p.length > 0 || c.length > 0)
|
|
541
|
-
throw new Error(
|
|
542
|
-
"Presign response claimer set does not match expected (vault provider ∪ vault keepers)" + (p.length > 0 ? ` (missing: ${p.join(", ")})` : "") + (c.length > 0 ? ` (unexpected: ${c.join(", ")})` : "")
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
function Z(e, t) {
|
|
546
|
-
return {
|
|
547
|
-
vaultCoreVersion: t.vaultCoreVersion,
|
|
548
|
-
payoutTxHex: e.payoutTxHex,
|
|
549
|
-
peginTxHex: t.peginTxHex,
|
|
550
|
-
assertTxHex: e.assertTxHex,
|
|
551
|
-
vaultProviderBtcPubkey: t.vaultProviderBtcPubkey,
|
|
552
|
-
vaultKeeperBtcPubkeys: t.vaultKeeperBtcPubkeys,
|
|
553
|
-
universalChallengerBtcPubkeys: t.universalChallengerBtcPubkeys,
|
|
554
|
-
depositorBtcPubkey: t.depositorBtcPubkey,
|
|
555
|
-
timelockPegin: t.timelockPegin,
|
|
556
|
-
timelockAssert: t.timelockAssert,
|
|
557
|
-
registeredPayoutScriptPubKey: t.registeredPayoutScriptPubKey,
|
|
558
|
-
claimerBtcPubkey: e.claimerPubkeyXOnly,
|
|
559
|
-
commissionBps: t.commissionBps,
|
|
560
|
-
protocolFeeRate: t.protocolFeeRate,
|
|
561
|
-
councilMembers: t.councilMembers,
|
|
562
|
-
councilQuorum: t.councilQuorum,
|
|
563
|
-
vkClaimerPayoutScriptPubKeys: t.vkClaimerPayoutScriptPubKeys,
|
|
564
|
-
vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
async function wt(e, t, r, o) {
|
|
568
|
-
const a = new Ve({
|
|
569
|
-
network: t.network,
|
|
570
|
-
btcWallet: e
|
|
571
|
-
}), l = r.length;
|
|
572
|
-
o == null || o(0, l);
|
|
573
|
-
let s;
|
|
574
|
-
if (a.supportsBatchSigning())
|
|
575
|
-
s = (await a.signPayoutTransactionsBatch(
|
|
576
|
-
r.map((u) => Z(u, t))
|
|
577
|
-
)).map((u) => u.payoutSignature);
|
|
578
|
-
else {
|
|
579
|
-
s = [];
|
|
580
|
-
for (let n = 0; n < r.length; n++) {
|
|
581
|
-
o == null || o(n, l);
|
|
582
|
-
const u = await a.signPayoutTransaction(
|
|
583
|
-
Z(r[n], t)
|
|
584
|
-
);
|
|
585
|
-
s.push(u.signature);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
const i = {};
|
|
589
|
-
for (let n = 0; n < r.length; n++)
|
|
590
|
-
i[r[n].claimerPubkeyXOnly] = {
|
|
591
|
-
payout_signature: s[n]
|
|
592
|
-
};
|
|
593
|
-
return o == null || o(l, l), i;
|
|
594
|
-
}
|
|
595
|
-
async function ir(e) {
|
|
596
|
-
const {
|
|
597
|
-
statusReader: t,
|
|
598
|
-
presignClient: r,
|
|
599
|
-
btcWallet: o,
|
|
600
|
-
peginTxid: a,
|
|
601
|
-
depositorPk: l,
|
|
602
|
-
signingContext: s,
|
|
603
|
-
depositTerms: i,
|
|
604
|
-
timeoutMs: n = mt,
|
|
605
|
-
signal: u,
|
|
606
|
-
onProgress: p
|
|
607
|
-
} = e, c = await ye({
|
|
608
|
-
statusReader: t,
|
|
609
|
-
peginTxid: a,
|
|
610
|
-
targetStatuses: Pt,
|
|
611
|
-
timeoutMs: n,
|
|
612
|
-
signal: u
|
|
613
|
-
});
|
|
614
|
-
if (be.has(c))
|
|
615
|
-
return;
|
|
616
|
-
if (u == null || u.throwIfAborted(), i !== void 0 && yt(i, s), Ie(o)) {
|
|
617
|
-
if (!i)
|
|
618
|
-
throw new Error(
|
|
619
|
-
"runDepositorPresignFlow: this wallet requires approved deposit terms but none were provided. Fresh deposits must pass PreparePeginResult.depositTerms; resume flows must rebuild them from on-chain state (the vault app's rebuildDepositTerms)."
|
|
620
|
-
);
|
|
621
|
-
typeof o.validateDepositTerms == "function" && await o.validateDepositTerms(i), await o.approveDepositTerms(i);
|
|
622
|
-
}
|
|
623
|
-
const h = await r.requestDepositorPresignTransactions(
|
|
624
|
-
{
|
|
625
|
-
pegin_txid: a,
|
|
626
|
-
depositor_pk: l
|
|
627
|
-
},
|
|
628
|
-
u
|
|
629
|
-
);
|
|
630
|
-
u == null || u.throwIfAborted();
|
|
631
|
-
const d = A(l);
|
|
632
|
-
bt(
|
|
633
|
-
h.txs,
|
|
634
|
-
s.vaultProviderBtcPubkey,
|
|
635
|
-
s.vaultKeeperBtcPubkeys,
|
|
636
|
-
l
|
|
637
|
-
);
|
|
638
|
-
const g = h.txs.filter(
|
|
639
|
-
(b) => A(b.claimer_pubkey) !== d
|
|
640
|
-
), m = vt(g), P = await wt(
|
|
641
|
-
o,
|
|
642
|
-
s,
|
|
643
|
-
m,
|
|
644
|
-
p
|
|
645
|
-
);
|
|
646
|
-
u == null || u.throwIfAborted();
|
|
647
|
-
const f = await gt({
|
|
648
|
-
depositorGraph: h.depositor_graph,
|
|
649
|
-
btcWallet: o,
|
|
650
|
-
signingContext: {
|
|
651
|
-
vaultCoreVersion: s.vaultCoreVersion,
|
|
652
|
-
peginTxHex: s.peginTxHex,
|
|
653
|
-
depositorBtcPubkey: l,
|
|
654
|
-
vaultProviderBtcPubkey: s.vaultProviderBtcPubkey,
|
|
655
|
-
vaultKeeperBtcPubkeys: s.vaultKeeperBtcPubkeys,
|
|
656
|
-
universalChallengerBtcPubkeys: s.universalChallengerBtcPubkeys,
|
|
657
|
-
timelockPegin: s.timelockPegin,
|
|
658
|
-
timelockAssert: s.timelockAssert,
|
|
659
|
-
councilMembers: s.councilMembers,
|
|
660
|
-
councilQuorum: s.councilQuorum,
|
|
661
|
-
network: s.network,
|
|
662
|
-
registeredPayoutScriptPubKey: s.registeredPayoutScriptPubKey,
|
|
663
|
-
protocolFeeRate: s.protocolFeeRate,
|
|
664
|
-
vkClaimerPayoutScriptPubKeys: s.vkClaimerPayoutScriptPubKeys,
|
|
665
|
-
vpCommissionScriptPubKey: s.vpCommissionScriptPubKey
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
u == null || u.throwIfAborted();
|
|
669
|
-
const x = { ...P };
|
|
670
|
-
x[y(l)] = f.payout_signatures, await r.submitDepositorPresignatures(
|
|
671
|
-
{
|
|
672
|
-
pegin_txid: a,
|
|
673
|
-
depositor_pk: l,
|
|
674
|
-
signatures: x,
|
|
675
|
-
depositor_claimer_presignatures: f
|
|
676
|
-
},
|
|
677
|
-
u
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
const Et = 300 * 1e3, kt = /* @__PURE__ */ new Set([
|
|
681
|
-
R.PENDING_DEPOSITOR_WOTS_PK,
|
|
682
|
-
...ge
|
|
683
|
-
]);
|
|
684
|
-
async function ur(e) {
|
|
685
|
-
const {
|
|
686
|
-
statusReader: t,
|
|
687
|
-
wotsSubmitter: r,
|
|
688
|
-
peginTxid: o,
|
|
689
|
-
depositorPk: a,
|
|
690
|
-
wotsPublicKeys: l,
|
|
691
|
-
timeoutMs: s = Et,
|
|
692
|
-
signal: i
|
|
693
|
-
} = e;
|
|
694
|
-
i == null || i.throwIfAborted();
|
|
695
|
-
const n = await ye({
|
|
696
|
-
statusReader: t,
|
|
697
|
-
peginTxid: o,
|
|
698
|
-
targetStatuses: kt,
|
|
699
|
-
timeoutMs: s,
|
|
700
|
-
signal: i
|
|
701
|
-
});
|
|
702
|
-
ge.has(n) || (i == null || i.throwIfAborted(), await r.submitDepositorWotsKey(
|
|
703
|
-
{
|
|
704
|
-
pegin_txid: o,
|
|
705
|
-
depositor_pk: a,
|
|
706
|
-
wots_public_keys: l
|
|
707
|
-
},
|
|
708
|
-
i
|
|
709
|
-
));
|
|
710
|
-
}
|
|
711
|
-
function D(e) {
|
|
712
|
-
return e.registration || e.operation;
|
|
713
|
-
}
|
|
714
|
-
function xt(e, t, r) {
|
|
715
|
-
const o = C(e);
|
|
716
|
-
return {
|
|
717
|
-
registration: o === C(t),
|
|
718
|
-
operation: o === C(r)
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
function ee(e, t, r) {
|
|
722
|
-
const o = M(e);
|
|
723
|
-
return {
|
|
724
|
-
registration: te(o, M(t)),
|
|
725
|
-
operation: te(o, M(r))
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
function M(e) {
|
|
729
|
-
return e.map(C).sort();
|
|
730
|
-
}
|
|
731
|
-
function te(e, t) {
|
|
732
|
-
return e.length === t.length && e.every((r, o) => r === t[o]);
|
|
733
|
-
}
|
|
734
|
-
async function lr(e) {
|
|
735
|
-
const {
|
|
736
|
-
vaultProviderEthAddress: t,
|
|
737
|
-
hintBtcPubkey: r,
|
|
738
|
-
registrationBtcPubkey: o,
|
|
739
|
-
readCurrentOperationBtcPubkey: a,
|
|
740
|
-
context: l
|
|
741
|
-
} = e;
|
|
742
|
-
if (!r) return;
|
|
743
|
-
const s = C(r);
|
|
744
|
-
if (s === C(o)) return;
|
|
745
|
-
const i = C(
|
|
746
|
-
await a()
|
|
747
|
-
);
|
|
748
|
-
if (s !== i)
|
|
749
|
-
throw new Error(
|
|
750
|
-
`Vault provider BTC pubkey mismatch for ${t}: indexer hint matches neither the registration key nor the current operation key on-chain.${l ? ` ${l}` : ""}`
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
function F(e, t, r) {
|
|
754
|
-
const o = `${e} operation key (admin=${t.ethAddress})`, a = Y(
|
|
755
|
-
t.btcPubKey,
|
|
756
|
-
`${e} roster key (admin=${t.ethAddress})`
|
|
757
|
-
), l = Y(r, o);
|
|
758
|
-
return {
|
|
759
|
-
adminAddress: t.ethAddress,
|
|
760
|
-
genesisBtcPubkey: a,
|
|
761
|
-
operationBtcPubkey: l,
|
|
762
|
-
rotated: l !== a
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
function Tt(e) {
|
|
766
|
-
const t = /* @__PURE__ */ new Map();
|
|
767
|
-
for (const r of e) {
|
|
768
|
-
const o = t.get(r.operationBtcPubkey);
|
|
769
|
-
if (o)
|
|
770
|
-
throw new Error(
|
|
771
|
-
`Participant operation key collision: ${o} and ${r.adminAddress} both resolve to operation key ${r.operationBtcPubkey}`
|
|
772
|
-
);
|
|
773
|
-
t.set(r.operationBtcPubkey, r.adminAddress);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
function we(e, t, r) {
|
|
777
|
-
if (t.vaultKeepers.length !== e.vaultKeepers.length || t.universalChallengers.length !== e.universalChallengers.length)
|
|
778
|
-
throw new Error(
|
|
779
|
-
`Operation-key resolution returned ${t.vaultKeepers.length} keeper and ${t.universalChallengers.length} challenger keys for a roster of ${e.vaultKeepers.length} keepers and ${e.universalChallengers.length} challengers`
|
|
780
|
-
);
|
|
781
|
-
const o = F(
|
|
782
|
-
"vault provider",
|
|
783
|
-
{
|
|
784
|
-
ethAddress: e.vaultProviderEthAddress,
|
|
785
|
-
btcPubKey: e.vaultProviderGenesisBtcPubkey
|
|
786
|
-
},
|
|
787
|
-
t.vaultProvider
|
|
788
|
-
), a = e.vaultKeepers.map(
|
|
789
|
-
(s, i) => F("vault keeper", s, t.vaultKeepers[i])
|
|
790
|
-
), l = e.universalChallengers.map(
|
|
791
|
-
(s, i) => F("universal challenger", s, t.universalChallengers[i])
|
|
792
|
-
);
|
|
793
|
-
return Tt([
|
|
794
|
-
o,
|
|
795
|
-
...a,
|
|
796
|
-
...l
|
|
797
|
-
]), {
|
|
798
|
-
vaultProvider: o,
|
|
799
|
-
vaultKeepers: a,
|
|
800
|
-
universalChallengers: l,
|
|
801
|
-
// Derived from the pairs, never the reverse — see ParticipantKeySet.
|
|
802
|
-
vaultKeeperOperationKeysSorted: a.map((s) => s.operationBtcPubkey).sort(),
|
|
803
|
-
universalChallengerOperationKeysSorted: l.map((s) => s.operationBtcPubkey).sort(),
|
|
804
|
-
resolvedAt: r,
|
|
805
|
-
query: e
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
async function At(e) {
|
|
809
|
-
const t = await e.operationKeyReader.getCurrentOperationKeys(
|
|
810
|
-
e.query,
|
|
811
|
-
e.blockNumber
|
|
812
|
-
);
|
|
813
|
-
return we(e.query, t, { mode: "current" });
|
|
814
|
-
}
|
|
815
|
-
async function Ct(e) {
|
|
816
|
-
const t = await e.operationKeyReader.getOperationKeysAtEpochs(
|
|
817
|
-
e.query,
|
|
818
|
-
e.epochs
|
|
819
|
-
);
|
|
820
|
-
return we(e.query, t, {
|
|
821
|
-
mode: "epochs",
|
|
822
|
-
epochs: e.epochs
|
|
823
|
-
});
|
|
824
|
-
}
|
|
825
|
-
class L extends Error {
|
|
826
|
-
constructor(t) {
|
|
827
|
-
super(t), this.name = "ApplicationEntryPointMismatchError";
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
function cr(e) {
|
|
831
|
-
return e instanceof L || e instanceof Error && e.name === "ApplicationEntryPointMismatchError";
|
|
832
|
-
}
|
|
833
|
-
const re = (e) => e.map(C).sort();
|
|
834
|
-
async function pr(e) {
|
|
835
|
-
const {
|
|
836
|
-
vaultRegistryReader: t,
|
|
837
|
-
vaultKeeperReader: r,
|
|
838
|
-
universalChallengerReader: o,
|
|
839
|
-
vaultProviderEthAddress: a,
|
|
840
|
-
applicationEntryPoint: l,
|
|
841
|
-
expectedVaultProviderBtcPubkey: s,
|
|
842
|
-
expectedVaultKeeperBtcPubkeys: i,
|
|
843
|
-
expectedUniversalChallengerBtcPubkeys: n,
|
|
844
|
-
operationKeyReader: u,
|
|
845
|
-
onIndexerServingOperationKeys: p,
|
|
846
|
-
onIndexerHintsInconsistent: c,
|
|
847
|
-
blockNumber: h
|
|
848
|
-
} = e, [
|
|
849
|
-
d,
|
|
850
|
-
g,
|
|
851
|
-
m,
|
|
852
|
-
P
|
|
853
|
-
] = await Promise.all([
|
|
854
|
-
t.getVaultProviderApplication(
|
|
855
|
-
a,
|
|
856
|
-
h
|
|
857
|
-
),
|
|
858
|
-
t.getVaultProviderGenesisBtcPubKey(
|
|
859
|
-
a,
|
|
860
|
-
h
|
|
861
|
-
),
|
|
862
|
-
o.getLatestUniversalChallengersVersion(h),
|
|
863
|
-
o.getCurrentUcKeyEpoch(h)
|
|
864
|
-
]);
|
|
865
|
-
if (!Ne(l, { strict: !1 }))
|
|
866
|
-
throw new L(
|
|
867
|
-
`The application entry point this deposit was prepared for is not a valid address: ${l}`
|
|
868
|
-
);
|
|
869
|
-
if (!He(d, l))
|
|
870
|
-
throw new L(
|
|
871
|
-
`Vault provider ${a} is registered to application ${d}, but this deposit was prepared for ${l}. Refusing to build: the vault keeper roster, its version, and the keeper key epoch would all resolve against a different application than the one selected.`
|
|
872
|
-
);
|
|
873
|
-
const [f, x] = await Promise.all(
|
|
874
|
-
[
|
|
875
|
-
r.getCurrentVaultKeepersVersion(
|
|
876
|
-
d,
|
|
877
|
-
h
|
|
878
|
-
),
|
|
879
|
-
r.getCurrentAppKeeperKeyEpoch(
|
|
880
|
-
d,
|
|
881
|
-
h
|
|
882
|
-
)
|
|
883
|
-
]
|
|
884
|
-
), [b, w] = await Promise.all([
|
|
885
|
-
r.getVaultKeepersByVersion(
|
|
886
|
-
d,
|
|
887
|
-
f,
|
|
888
|
-
h
|
|
889
|
-
),
|
|
890
|
-
o.getUniversalChallengersByVersion(
|
|
891
|
-
m,
|
|
892
|
-
h
|
|
893
|
-
)
|
|
894
|
-
]), E = {
|
|
895
|
-
vaultProvider: C(g),
|
|
896
|
-
vaultKeepers: re(b.map((k) => k.btcPubKey)),
|
|
897
|
-
universalChallengers: re(w.map((k) => k.btcPubKey))
|
|
898
|
-
}, T = await At({
|
|
899
|
-
operationKeyReader: u,
|
|
900
|
-
query: {
|
|
901
|
-
vaultProviderEthAddress: a,
|
|
902
|
-
vaultProviderGenesisBtcPubkey: `0x${g}`,
|
|
903
|
-
applicationEntryPoint: d,
|
|
904
|
-
vaultKeepers: b,
|
|
905
|
-
universalChallengers: w
|
|
906
|
-
},
|
|
907
|
-
blockNumber: h
|
|
908
|
-
}), v = {
|
|
909
|
-
vaultProvider: T.vaultProvider.operationBtcPubkey,
|
|
910
|
-
vaultKeepers: [...T.vaultKeeperOperationKeysSorted],
|
|
911
|
-
universalChallengers: [
|
|
912
|
-
...T.universalChallengerOperationKeysSorted
|
|
913
|
-
]
|
|
914
|
-
}, q = xt(
|
|
915
|
-
s,
|
|
916
|
-
E.vaultProvider,
|
|
917
|
-
v.vaultProvider
|
|
918
|
-
), G = ee(
|
|
919
|
-
i,
|
|
920
|
-
E.vaultKeepers,
|
|
921
|
-
v.vaultKeepers
|
|
922
|
-
), z = ee(
|
|
923
|
-
n,
|
|
924
|
-
E.universalChallengers,
|
|
925
|
-
v.universalChallengers
|
|
926
|
-
);
|
|
927
|
-
if (!D(q))
|
|
928
|
-
throw new Error(
|
|
929
|
-
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${a}. Refresh and try again.`
|
|
930
|
-
);
|
|
931
|
-
if (!D(G))
|
|
932
|
-
throw new Error(
|
|
933
|
-
`Vault keeper BTC pubkeys (v${f}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
934
|
-
);
|
|
935
|
-
if (!D(z))
|
|
936
|
-
throw new Error(
|
|
937
|
-
`Universal challenger BTC pubkeys (v${m}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
938
|
-
);
|
|
939
|
-
const j = [q, G, z], Ce = j.some((k) => k.registration && !k.operation), Q = j.some((k) => k.operation && !k.registration);
|
|
940
|
-
if (Ce && Q) {
|
|
941
|
-
const k = `Indexer participant hints are internally inconsistent for vault provider ${a}: some roles match the registration keys while others match the rotated operation keys.`;
|
|
942
|
-
throw c == null || c(k), new Error(`${k} Refresh and try again.`);
|
|
943
|
-
}
|
|
944
|
-
return Q && (p == null || p(
|
|
945
|
-
`Indexer is serving rotated operation keys for vault provider ${a}`
|
|
946
|
-
)), {
|
|
947
|
-
vaultProviderBtcPubkeyXOnly: v.vaultProvider,
|
|
948
|
-
vaultKeeperBtcPubkeysSorted: v.vaultKeepers,
|
|
949
|
-
universalChallengerBtcPubkeysSorted: v.universalChallengers,
|
|
950
|
-
expectedAppVaultKeepersVersion: f,
|
|
951
|
-
expectedUniversalChallengersVersion: m,
|
|
952
|
-
appKeeperKeyEpoch: x,
|
|
953
|
-
ucKeyEpoch: P,
|
|
954
|
-
registrationKeys: E,
|
|
955
|
-
participantKeys: T
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
function Rt(e) {
|
|
959
|
-
return /^[0-9a-fA-F]{64}$/.test(e);
|
|
960
|
-
}
|
|
961
|
-
function hr(e) {
|
|
962
|
-
const {
|
|
963
|
-
amountSats: t,
|
|
964
|
-
minDeposit: r,
|
|
965
|
-
maxDeposit: o,
|
|
966
|
-
btcBalance: a,
|
|
967
|
-
estimatedFeeSats: l,
|
|
968
|
-
depositorClaimValue: s
|
|
969
|
-
} = e;
|
|
970
|
-
return !(t <= 0n || t < r || o && o > 0n && t > o || l == null || s == null || t + l + s > a);
|
|
971
|
-
}
|
|
972
|
-
function dr(e, t, r) {
|
|
973
|
-
return e <= 0n ? {
|
|
974
|
-
valid: !1,
|
|
975
|
-
error: "Deposit amount must be greater than zero"
|
|
976
|
-
} : e < t ? {
|
|
977
|
-
valid: !1,
|
|
978
|
-
error: `Minimum deposit is ${_(t)} BTC`
|
|
979
|
-
} : r && r > 0n && e > r ? {
|
|
980
|
-
valid: !1,
|
|
981
|
-
error: `Maximum deposit is ${_(r)} BTC`
|
|
982
|
-
} : { valid: !0 };
|
|
983
|
-
}
|
|
984
|
-
function gr(e) {
|
|
985
|
-
const { amount: t, effectiveRemaining: r } = e;
|
|
986
|
-
return r === null ? { valid: !0 } : r === 0n ? {
|
|
987
|
-
valid: !1,
|
|
988
|
-
error: "Supply cap reached — deposits temporarily paused"
|
|
989
|
-
} : t > r ? {
|
|
990
|
-
valid: !1,
|
|
991
|
-
error: `Vault size exceeds remaining capacity (${_(r)} BTC)`
|
|
992
|
-
} : { valid: !0 };
|
|
993
|
-
}
|
|
994
|
-
function fr(e, t) {
|
|
995
|
-
if (!e || e.length === 0)
|
|
996
|
-
return {
|
|
997
|
-
valid: !1,
|
|
998
|
-
error: "At least one vault provider must be selected"
|
|
999
|
-
};
|
|
1000
|
-
const r = t.map(
|
|
1001
|
-
(a) => a.toLowerCase()
|
|
1002
|
-
);
|
|
1003
|
-
return e.filter(
|
|
1004
|
-
(a) => !r.includes(a.toLowerCase())
|
|
1005
|
-
).length > 0 ? {
|
|
1006
|
-
valid: !1,
|
|
1007
|
-
error: "Invalid vault provider selected"
|
|
1008
|
-
} : { valid: !0 };
|
|
1009
|
-
}
|
|
1010
|
-
function _t(e, t, r) {
|
|
1011
|
-
if (!e || e.length === 0)
|
|
1012
|
-
return {
|
|
1013
|
-
valid: !1,
|
|
1014
|
-
error: "At least one vault amount required"
|
|
1015
|
-
};
|
|
1016
|
-
for (let o = 0; o < e.length; o++) {
|
|
1017
|
-
const a = e[o];
|
|
1018
|
-
if (a <= 0n)
|
|
1019
|
-
return {
|
|
1020
|
-
valid: !1,
|
|
1021
|
-
error: `Vault ${o + 1} amount must be positive`
|
|
1022
|
-
};
|
|
1023
|
-
if (t && a < t)
|
|
1024
|
-
return {
|
|
1025
|
-
valid: !1,
|
|
1026
|
-
error: `Vault ${o + 1} amount ${_(a)} BTC is below minimum deposit ${_(t)} BTC`
|
|
1027
|
-
};
|
|
1028
|
-
if (r && a > r)
|
|
1029
|
-
return {
|
|
1030
|
-
valid: !1,
|
|
1031
|
-
error: `Vault ${o + 1} amount ${_(a)} BTC exceeds maximum deposit ${_(r)} BTC`
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
return { valid: !0 };
|
|
1035
|
-
}
|
|
1036
|
-
function St(e) {
|
|
1037
|
-
const t = y(e);
|
|
1038
|
-
return Rt(t) ? { valid: !0 } : {
|
|
1039
|
-
valid: !1,
|
|
1040
|
-
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
function $t(e) {
|
|
1044
|
-
if (!e || e.length === 0)
|
|
1045
|
-
throw new Error(
|
|
1046
|
-
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
1047
|
-
);
|
|
1048
|
-
}
|
|
1049
|
-
function Bt(e) {
|
|
1050
|
-
if (!e || e.length === 0)
|
|
1051
|
-
throw new Error(
|
|
1052
|
-
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
1053
|
-
);
|
|
1054
|
-
}
|
|
1055
|
-
function It(e) {
|
|
1056
|
-
if (e.length === 0)
|
|
1057
|
-
throw new Error("No spendable UTXOs available");
|
|
1058
|
-
}
|
|
1059
|
-
function mr(e) {
|
|
1060
|
-
const {
|
|
1061
|
-
vaultAmounts: t,
|
|
1062
|
-
confirmedUTXOs: r,
|
|
1063
|
-
vaultProviderBtcPubkey: o,
|
|
1064
|
-
vaultKeeperBtcPubkeys: a,
|
|
1065
|
-
universalChallengerBtcPubkeys: l,
|
|
1066
|
-
minDeposit: s,
|
|
1067
|
-
maxDeposit: i
|
|
1068
|
-
} = e, n = _t(
|
|
1069
|
-
t,
|
|
1070
|
-
s,
|
|
1071
|
-
i
|
|
1072
|
-
);
|
|
1073
|
-
if (!n.valid)
|
|
1074
|
-
throw new Error(n.error);
|
|
1075
|
-
const u = St(o);
|
|
1076
|
-
if (!u.valid)
|
|
1077
|
-
throw new Error(u.error);
|
|
1078
|
-
$t(a), Bt(l), It(r);
|
|
1079
|
-
}
|
|
1080
|
-
class Ee extends Error {
|
|
1081
|
-
constructor(t) {
|
|
1082
|
-
super(t), this.name = "ParticipantKeyDriftError";
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
function Pr(e) {
|
|
1086
|
-
return e instanceof Ee || e instanceof Error && e.name === "ParticipantKeyDriftError";
|
|
1087
|
-
}
|
|
1088
|
-
function oe(e, t, r) {
|
|
1089
|
-
return t.length === r.length && t.every((o, a) => o === r[a]) ? null : `${e} expected [${t.join(", ")}], got [${r.join(", ")}]`;
|
|
1090
|
-
}
|
|
1091
|
-
async function vr(e) {
|
|
1092
|
-
const { vaultRegistryReader: t, operationKeyReader: r, vaultIds: o, expected: a } = e, l = a.query;
|
|
1093
|
-
if (o.length === 0) return;
|
|
1094
|
-
const s = await t.getVaultKeyEpochsBatch(o), i = [];
|
|
1095
|
-
for (const [n, u] of s.entries()) {
|
|
1096
|
-
const p = o[n];
|
|
1097
|
-
let c;
|
|
1098
|
-
try {
|
|
1099
|
-
c = await Ct({
|
|
1100
|
-
operationKeyReader: r,
|
|
1101
|
-
query: l,
|
|
1102
|
-
epochs: u
|
|
1103
|
-
});
|
|
1104
|
-
} catch (g) {
|
|
1105
|
-
i.push(
|
|
1106
|
-
`vault ${p}: could not resolve participants at frozen epochs (vp=${u.vpKeyEpoch}, keeper=${u.appKeeperKeyEpoch}, uc=${u.ucKeyEpoch}): ${g.message}`
|
|
1107
|
-
);
|
|
1108
|
-
continue;
|
|
1109
|
-
}
|
|
1110
|
-
c.vaultProvider.operationBtcPubkey !== a.vaultProvider.operationBtcPubkey && i.push(
|
|
1111
|
-
`vault ${p}: vault provider key expected ${a.vaultProvider.operationBtcPubkey}, got ${c.vaultProvider.operationBtcPubkey}`
|
|
1112
|
-
);
|
|
1113
|
-
const h = oe(
|
|
1114
|
-
`vault ${p}: vault keeper keys`,
|
|
1115
|
-
a.vaultKeeperOperationKeysSorted,
|
|
1116
|
-
c.vaultKeeperOperationKeysSorted
|
|
1117
|
-
);
|
|
1118
|
-
h && i.push(h);
|
|
1119
|
-
const d = oe(
|
|
1120
|
-
`vault ${p}: universal challenger keys`,
|
|
1121
|
-
a.universalChallengerOperationKeysSorted,
|
|
1122
|
-
c.universalChallengerOperationKeysSorted
|
|
1123
|
-
);
|
|
1124
|
-
d && i.push(d);
|
|
1125
|
-
}
|
|
1126
|
-
if (i.length > 0)
|
|
1127
|
-
throw new Ee(
|
|
1128
|
-
`Aborting BTC broadcast: participant operation keys changed during registration (${i.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
|
-
class ke extends Error {
|
|
1132
|
-
constructor(t) {
|
|
1133
|
-
super(t), this.name = "RegisteredVaultVersionMismatchError";
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
function yr(e) {
|
|
1137
|
-
return e instanceof ke || e instanceof Error && e.name === "RegisteredVaultVersionMismatchError";
|
|
1138
|
-
}
|
|
1139
|
-
async function br(e) {
|
|
1140
|
-
const {
|
|
1141
|
-
vaultRegistryReader: t,
|
|
1142
|
-
vaultIds: r,
|
|
1143
|
-
expectedOffchainParamsVersion: o,
|
|
1144
|
-
expectedAppVaultKeepersVersion: a,
|
|
1145
|
-
expectedUniversalChallengersVersion: l,
|
|
1146
|
-
expectedVaultCoreVersion: s
|
|
1147
|
-
} = e, i = await t.getProtocolInfoBatch(r), n = [];
|
|
1148
|
-
if (i.forEach((u, p) => {
|
|
1149
|
-
const c = r[p];
|
|
1150
|
-
u.offchainParamsVersion !== o && n.push(
|
|
1151
|
-
`vault ${c}: offchainParams expected v${o}, got v${u.offchainParamsVersion}`
|
|
1152
|
-
), u.appVaultKeepersVersion !== a && n.push(
|
|
1153
|
-
`vault ${c}: appVaultKeepers expected v${a}, got v${u.appVaultKeepersVersion}`
|
|
1154
|
-
), u.universalChallengersVersion !== l && n.push(
|
|
1155
|
-
`vault ${c}: universalChallengers expected v${l}, got v${u.universalChallengersVersion}`
|
|
1156
|
-
), u.vaultCoreVersion !== s && n.push(
|
|
1157
|
-
`vault ${c}: vaultCoreVersion expected v${s} (build-time active), got v${u.vaultCoreVersion}`
|
|
1158
|
-
);
|
|
1159
|
-
}), n.length > 0)
|
|
1160
|
-
throw new ke(
|
|
1161
|
-
`Aborting BTC broadcast: signer-set or offchain-params versions changed during registration (${n.join("; ")}). The Pre-PegIn was not broadcast; the registered ETH vault will time out per protocol rules.`
|
|
1162
|
-
);
|
|
1163
|
-
}
|
|
1164
|
-
var xe = /* @__PURE__ */ ((e) => (e.CLAIM_EVENT_RECEIVED = "ClaimEventReceived", e.CLAIM_BROADCAST = "ClaimBroadcast", e.ASSERT_BROADCAST = "AssertBroadcast", e.PAYOUT_BROADCAST = "PayoutBroadcast", e.PAYOUT_BLOCKED = "PayoutBlocked", e))(xe || {});
|
|
1165
|
-
const Vt = /* @__PURE__ */ new Set([
|
|
1166
|
-
"PayoutBroadcast",
|
|
1167
|
-
"PayoutBlocked"
|
|
1168
|
-
/* PAYOUT_BLOCKED */
|
|
1169
|
-
]);
|
|
1170
|
-
function wr(e) {
|
|
1171
|
-
return Object.values(xe).includes(
|
|
1172
|
-
e
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
|
-
function Er(e) {
|
|
1176
|
-
return !!e && Vt.has(e);
|
|
1177
|
-
}
|
|
1178
|
-
class Kt extends Error {
|
|
1179
|
-
constructor(r, o) {
|
|
1180
|
-
super(`Refund not yet mature (BIP68 not final): ${o.message}`);
|
|
1181
|
-
S(this, "vaultId");
|
|
1182
|
-
S(this, "cause");
|
|
1183
|
-
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = o;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
const Ot = /^0x[0-9a-fA-F]{64}$/, Nt = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, Te = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, Ae = 160, ne = 2e3, se = 10n, ae = 100n;
|
|
1187
|
-
function kr(e) {
|
|
1188
|
-
if (!Number.isFinite(e) || e <= 0)
|
|
1189
|
-
throw new Error(
|
|
1190
|
-
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
1191
|
-
);
|
|
1192
|
-
return BigInt(Math.ceil(e * Ae));
|
|
1193
|
-
}
|
|
1194
|
-
const Ht = 1, Dt = /non-BIP68-final/i;
|
|
1195
|
-
function X(e, t) {
|
|
1196
|
-
if (e.length !== 66)
|
|
1197
|
-
throw new Error(
|
|
1198
|
-
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
1199
|
-
);
|
|
1200
|
-
if (!Ot.test(e))
|
|
1201
|
-
throw new Error(
|
|
1202
|
-
`${t} must contain only hex characters after the 0x prefix`
|
|
1203
|
-
);
|
|
1204
|
-
}
|
|
1205
|
-
function U(e, t) {
|
|
1206
|
-
if (!Number.isInteger(e) || e < 0)
|
|
1207
|
-
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
1208
|
-
}
|
|
1209
|
-
function Mt(e) {
|
|
1210
|
-
if (X(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
|
|
1211
|
-
throw new Error(
|
|
1212
|
-
`htlcVout must be a non-negative integer, got ${e.htlcVout}`
|
|
1213
|
-
);
|
|
1214
|
-
if (!Array.isArray(e.batch) || e.batch.length === 0)
|
|
1215
|
-
throw new Error("batch must be a non-empty array of HTLC entries");
|
|
1216
|
-
if (e.htlcVout >= e.batch.length)
|
|
1217
|
-
throw new Error(
|
|
1218
|
-
`htlcVout ${e.htlcVout} is out of range for batch of size ${e.batch.length}`
|
|
1219
|
-
);
|
|
1220
|
-
for (let r = 0; r < e.batch.length; r++) {
|
|
1221
|
-
const o = e.batch[r];
|
|
1222
|
-
if (X(o.hashlock, `batch[${r}].hashlock`), !Number.isInteger(o.htlcVout) || o.htlcVout !== r)
|
|
1223
|
-
throw new Error(
|
|
1224
|
-
`batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${o.htlcVout}`
|
|
1225
|
-
);
|
|
1226
|
-
if (typeof o.amount != "bigint" || o.amount <= 0n)
|
|
1227
|
-
throw new Error(
|
|
1228
|
-
`batch[${r}].amount must be a positive bigint, got ${o.amount}`
|
|
1229
|
-
);
|
|
1230
|
-
}
|
|
1231
|
-
const t = e.batch[e.htlcVout];
|
|
1232
|
-
if (t.hashlock.toLowerCase() !== e.hashlock.toLowerCase())
|
|
1233
|
-
throw new Error(
|
|
1234
|
-
`batch[${e.htlcVout}].hashlock (${t.hashlock}) does not match target hashlock (${e.hashlock})`
|
|
1235
|
-
);
|
|
1236
|
-
if (t.amount !== e.amount)
|
|
1237
|
-
throw new Error(
|
|
1238
|
-
`batch[${e.htlcVout}].amount (${t.amount}) does not match target amount (${e.amount})`
|
|
1239
|
-
);
|
|
1240
|
-
if (U(e.offchainParamsVersion, "offchainParamsVersion"), U(e.appVaultKeepersVersion, "appVaultKeepersVersion"), U(
|
|
1241
|
-
e.universalChallengersVersion,
|
|
1242
|
-
"universalChallengersVersion"
|
|
1243
|
-
), We(
|
|
1244
|
-
e.vaultCoreVersion,
|
|
1245
|
-
"VaultRefundData.vaultCoreVersion"
|
|
1246
|
-
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
1247
|
-
throw new Error("unsignedPrePeginTxHex must be a non-empty hex string");
|
|
1248
|
-
if (!Nt.test(e.unsignedPrePeginTxHex))
|
|
1249
|
-
throw new Error(
|
|
1250
|
-
"unsignedPrePeginTxHex must be a hex byte string (optional 0x prefix, even length)"
|
|
1251
|
-
);
|
|
1252
|
-
if (!e.depositorBtcPubkey || !Te.test(e.depositorBtcPubkey))
|
|
1253
|
-
throw new Error(
|
|
1254
|
-
"depositorBtcPubkey must be 32 or 33 bytes of hex (optional 0x prefix)"
|
|
1255
|
-
);
|
|
1256
|
-
if (typeof e.amount != "bigint" || e.amount <= 0n)
|
|
1257
|
-
throw new Error(`amount must be a positive bigint, got ${e.amount}`);
|
|
1258
|
-
}
|
|
1259
|
-
function Ft(e) {
|
|
1260
|
-
if (!e.vaultProviderPubkey || !Te.test(e.vaultProviderPubkey))
|
|
1261
|
-
throw new Error("vaultProviderPubkey must be 32 or 33 bytes of hex");
|
|
1262
|
-
if (e.vaultKeeperPubkeys.length === 0)
|
|
1263
|
-
throw new Error("vaultKeeperPubkeys must be non-empty");
|
|
1264
|
-
if (e.universalChallengerPubkeys.length === 0)
|
|
1265
|
-
throw new Error("universalChallengerPubkeys must be non-empty");
|
|
1266
|
-
if (!Number.isInteger(e.timelockRefund) || e.timelockRefund <= 0)
|
|
1267
|
-
throw new Error(
|
|
1268
|
-
`timelockRefund must be a positive integer, got ${e.timelockRefund}`
|
|
1269
|
-
);
|
|
1270
|
-
if (typeof e.feeRate != "bigint" || e.feeRate <= 0n)
|
|
1271
|
-
throw new Error(
|
|
1272
|
-
`protocol feeRate must be a positive bigint, got ${e.feeRate}`
|
|
1273
|
-
);
|
|
1274
|
-
if (typeof e.minPeginFeeRate != "bigint" || e.minPeginFeeRate <= 0n)
|
|
1275
|
-
throw new Error(
|
|
1276
|
-
`minPeginFeeRate must be a positive bigint, got ${e.minPeginFeeRate}`
|
|
1277
|
-
);
|
|
1278
|
-
if (!Number.isInteger(e.numLocalChallengers) || e.numLocalChallengers < 0)
|
|
1279
|
-
throw new Error("numLocalChallengers must be a non-negative integer");
|
|
1280
|
-
if (!Number.isInteger(e.councilQuorum) || !Number.isInteger(e.councilSize) || e.councilQuorum <= 0 || e.councilSize <= 0 || e.councilQuorum > e.councilSize)
|
|
1281
|
-
throw new Error(
|
|
1282
|
-
`councilQuorum (${e.councilQuorum}) must be in [1, councilSize=${e.councilSize}]`
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
async function xr(e) {
|
|
1286
|
-
const {
|
|
1287
|
-
vaultId: t,
|
|
1288
|
-
readVault: r,
|
|
1289
|
-
readPrePeginContext: o,
|
|
1290
|
-
feeRate: a,
|
|
1291
|
-
signPsbt: l,
|
|
1292
|
-
broadcastTx: s,
|
|
1293
|
-
signal: i
|
|
1294
|
-
} = e;
|
|
1295
|
-
i == null || i.throwIfAborted(), X(t, "vaultId");
|
|
1296
|
-
const n = await r();
|
|
1297
|
-
Mt(n), i == null || i.throwIfAborted();
|
|
1298
|
-
const u = await o(n);
|
|
1299
|
-
if (Ft(u), i == null || i.throwIfAborted(), !Number.isFinite(a) || a <= 0)
|
|
1300
|
-
throw new Error(`feeRate must be a positive number, got ${a}`);
|
|
1301
|
-
if (a > ne)
|
|
1302
|
-
throw new Error(
|
|
1303
|
-
`feeRate ${a} sat/vB exceeds refund safety cap ${ne} sat/vB; refusing to sign refund.`
|
|
1304
|
-
);
|
|
1305
|
-
const p = BigInt(Math.ceil(a * Ae)), c = n.amount * se / ae;
|
|
1306
|
-
if (p > c)
|
|
1307
|
-
throw new Error(
|
|
1308
|
-
`Refund fee ${p} sats exceeds the per-vault safety cap of ${c} sats (${se}/${ae} of vault.amount=${n.amount}); refusing to sign refund.`
|
|
1309
|
-
);
|
|
1310
|
-
i == null || i.throwIfAborted();
|
|
1311
|
-
const h = O(
|
|
1312
|
-
n.depositorBtcPubkey
|
|
1313
|
-
), d = y(n.unsignedPrePeginTxHex), g = Ke(d);
|
|
1314
|
-
if (g !== void 0 && g.vout !== n.batch.length)
|
|
1315
|
-
throw new Error(
|
|
1316
|
-
`Auth-anchor OP_RETURN at vout ${g.vout} does not match batch size (${n.batch.length} HTLC outputs expect the anchor at vout ${n.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
|
|
1317
|
-
);
|
|
1318
|
-
const m = g == null ? void 0 : g.hash;
|
|
1319
|
-
let P;
|
|
1320
|
-
try {
|
|
1321
|
-
P = $.fromHex(d);
|
|
1322
|
-
} catch (v) {
|
|
1323
|
-
throw new Error(
|
|
1324
|
-
`Failed to parse funded Pre-PegIn transaction hex: ${v instanceof Error ? v.message : String(v)}`
|
|
1325
|
-
);
|
|
1326
|
-
}
|
|
1327
|
-
if (P.outs.length < n.batch.length)
|
|
1328
|
-
throw new Error(
|
|
1329
|
-
`Funded Pre-PegIn tx has ${P.outs.length} outputs but batch requires at least ${n.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
|
|
1330
|
-
);
|
|
1331
|
-
const { psbtHex: f } = await Ge({
|
|
1332
|
-
prePeginParams: {
|
|
1333
|
-
vaultCoreVersion: n.vaultCoreVersion,
|
|
1334
|
-
depositorPubkey: h,
|
|
1335
|
-
vaultProviderPubkey: y(u.vaultProviderPubkey),
|
|
1336
|
-
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(y),
|
|
1337
|
-
universalChallengerPubkeys: u.universalChallengerPubkeys.map(y),
|
|
1338
|
-
hashlocks: n.batch.map((v) => y(v.hashlock)),
|
|
1339
|
-
timelockRefund: u.timelockRefund,
|
|
1340
|
-
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
1341
|
-
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
1342
|
-
// reserve (`depositorClaimValue + minPeginFee`) internally when sizing the
|
|
1343
|
-
// HTLC output. `buildRefundPsbt`'s value cross-check then binds the result
|
|
1344
|
-
// to the funded tx bytes, refusing the refund if the template's HTLC value
|
|
1345
|
-
// disagrees with the on-chain commitment.
|
|
1346
|
-
pegInAmounts: n.batch.map((v) => v.amount),
|
|
1347
|
-
feeRate: u.feeRate,
|
|
1348
|
-
minPeginFeeRate: u.minPeginFeeRate,
|
|
1349
|
-
numLocalChallengers: u.numLocalChallengers,
|
|
1350
|
-
councilQuorum: u.councilQuorum,
|
|
1351
|
-
councilSize: u.councilSize,
|
|
1352
|
-
network: u.network,
|
|
1353
|
-
authAnchorHash: m
|
|
1354
|
-
},
|
|
1355
|
-
fundedPrePeginTxHex: d,
|
|
1356
|
-
htlcVout: n.htlcVout,
|
|
1357
|
-
refundFee: p,
|
|
1358
|
-
// buildRefundPsbt's top-level `hashlock` param is documented as "no 0x
|
|
1359
|
-
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
1360
|
-
// value would derive the wrong refund script leaf and yield an
|
|
1361
|
-
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
1362
|
-
hashlock: y(n.hashlock)
|
|
1363
|
-
});
|
|
1364
|
-
i == null || i.throwIfAborted();
|
|
1365
|
-
const x = K(
|
|
1366
|
-
n.depositorBtcPubkey,
|
|
1367
|
-
Ht
|
|
1368
|
-
), b = await l(f, x);
|
|
1369
|
-
B({
|
|
1370
|
-
requestedPsbtHex: f,
|
|
1371
|
-
returnedPsbtHex: b
|
|
1372
|
-
});
|
|
1373
|
-
const w = 0, E = I(
|
|
1374
|
-
b,
|
|
1375
|
-
h,
|
|
1376
|
-
w
|
|
1377
|
-
);
|
|
1378
|
-
V({
|
|
1379
|
-
requestedPsbtHex: f,
|
|
1380
|
-
signatureHex: E,
|
|
1381
|
-
signerXOnlyPubkeyHex: h,
|
|
1382
|
-
inputIndex: w
|
|
1383
|
-
});
|
|
1384
|
-
const T = fe({
|
|
1385
|
-
requestedPsbtHex: f,
|
|
1386
|
-
signaturesHex: [E],
|
|
1387
|
-
signerXOnlyPubkeyHex: h
|
|
1388
|
-
});
|
|
1389
|
-
i == null || i.throwIfAborted();
|
|
1390
|
-
try {
|
|
1391
|
-
return await s(T);
|
|
1392
|
-
} catch (v) {
|
|
1393
|
-
throw v instanceof Error && Dt.test(v.message) ? new Kt(t, v) : v;
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
class ie extends Error {
|
|
1397
|
-
constructor(r, o, a) {
|
|
1398
|
-
super(r);
|
|
1399
|
-
/** Fee the reclaim would have paid, in satoshis. */
|
|
1400
|
-
S(this, "feeSats");
|
|
1401
|
-
/** Sum of the reserves the reclaim would have swept, in satoshis. */
|
|
1402
|
-
S(this, "sweptTotalSats");
|
|
1403
|
-
this.name = "ReclaimUneconomicalError", this.feeSats = o, this.sweptTotalSats = a;
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
const ue = 2e3, le = 25n, ce = 100n, Tr = 10n;
|
|
1407
|
-
async function Ut(e, t, r) {
|
|
1408
|
-
for (let o = 0; o < e.length; o++) {
|
|
1409
|
-
const a = Qe(e[o].depositorSignedPeginTxHex), l = he(
|
|
1410
|
-
await Ye(
|
|
1411
|
-
y(a),
|
|
1412
|
-
y(r)
|
|
1413
|
-
)
|
|
1414
|
-
).toLowerCase();
|
|
1415
|
-
if (l !== t[o].toLowerCase())
|
|
1416
|
-
throw new Error(
|
|
1417
|
-
`Reserve ${o} belongs to vault ${l}, not the requested ${t[o].toLowerCase()}. Refusing to sweep a reserve whose vault is not the one the caller asked for — the reserve funds that vault's claim transaction and cannot be replaced.`
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
async function Ar(e) {
|
|
1422
|
-
const {
|
|
1423
|
-
vaultIds: t,
|
|
1424
|
-
depositorEthAddress: r,
|
|
1425
|
-
depositorBtcPubkey: o,
|
|
1426
|
-
readVaults: a,
|
|
1427
|
-
feeRate: l,
|
|
1428
|
-
signPsbt: s,
|
|
1429
|
-
broadcastTx: i,
|
|
1430
|
-
signal: n
|
|
1431
|
-
} = e;
|
|
1432
|
-
if (n == null || n.throwIfAborted(), t.length === 0)
|
|
1433
|
-
throw new Error("Reclaim requires at least one vault id; got none.");
|
|
1434
|
-
if (!Number.isFinite(l) || l <= 0)
|
|
1435
|
-
throw new Error(`feeRate must be a positive number, got ${l}`);
|
|
1436
|
-
if (l > ue)
|
|
1437
|
-
throw new ie(
|
|
1438
|
-
`Fee rate ${l} sat/vB exceeds the reclaim safety cap of ${ue} sat/vB; refusing to sign.`,
|
|
1439
|
-
0n,
|
|
1440
|
-
0n
|
|
1441
|
-
);
|
|
1442
|
-
const u = await a();
|
|
1443
|
-
if (n == null || n.throwIfAborted(), u.length !== t.length)
|
|
1444
|
-
throw new Error(
|
|
1445
|
-
`readVaults returned ${u.length} reserves for ${t.length} vault id(s); refusing to sweep a set that does not match the request.`
|
|
1446
|
-
);
|
|
1447
|
-
await Ut(u, t, r), n == null || n.throwIfAborted();
|
|
1448
|
-
const p = O(o), c = u.map((w) => ({
|
|
1449
|
-
depositorSignedPeginTxHex: w.depositorSignedPeginTxHex,
|
|
1450
|
-
observed: w.observed,
|
|
1451
|
-
expectedValue: w.expectedClaimValue
|
|
1452
|
-
})), h = ze(l, c.length), d = c.reduce((w, E) => w + E.expectedValue, 0n), g = d * le / ce;
|
|
1453
|
-
if (h > g)
|
|
1454
|
-
throw new ie(
|
|
1455
|
-
`Reclaim fee ${h} sats exceeds ${le}/${ce} of the swept total (${d} sats, cap ${g} sats). The reserve is not at risk — it stays where it is until fee rates fall.`,
|
|
1456
|
-
h,
|
|
1457
|
-
d
|
|
1458
|
-
);
|
|
1459
|
-
n == null || n.throwIfAborted();
|
|
1460
|
-
const { psbtHex: m } = je({
|
|
1461
|
-
depositorPubkey: p,
|
|
1462
|
-
inputs: c,
|
|
1463
|
-
feeSats: h
|
|
1464
|
-
});
|
|
1465
|
-
n == null || n.throwIfAborted();
|
|
1466
|
-
const P = K(
|
|
1467
|
-
o,
|
|
1468
|
-
c.length
|
|
1469
|
-
), f = await s(m, P);
|
|
1470
|
-
B({
|
|
1471
|
-
requestedPsbtHex: m,
|
|
1472
|
-
returnedPsbtHex: f
|
|
1473
|
-
});
|
|
1474
|
-
const x = c.map((w, E) => {
|
|
1475
|
-
const T = I(
|
|
1476
|
-
f,
|
|
1477
|
-
p,
|
|
1478
|
-
E
|
|
1479
|
-
);
|
|
1480
|
-
return V({
|
|
1481
|
-
requestedPsbtHex: m,
|
|
1482
|
-
signatureHex: T,
|
|
1483
|
-
signerXOnlyPubkeyHex: p,
|
|
1484
|
-
inputIndex: E
|
|
1485
|
-
}), T;
|
|
1486
|
-
}), b = fe({
|
|
1487
|
-
requestedPsbtHex: m,
|
|
1488
|
-
signaturesHex: x,
|
|
1489
|
-
signerXOnlyPubkeyHex: p
|
|
1490
|
-
});
|
|
1491
|
-
return n == null || n.throwIfAborted(), i(b);
|
|
1492
|
-
}
|
|
1493
|
-
export {
|
|
1494
|
-
L as A,
|
|
1495
|
-
D as B,
|
|
1496
|
-
xt as C,
|
|
1497
|
-
ee as D,
|
|
1498
|
-
At as E,
|
|
1499
|
-
Ct as F,
|
|
1500
|
-
xe as G,
|
|
1501
|
-
wr as H,
|
|
1502
|
-
Er as I,
|
|
1503
|
-
Kt as J,
|
|
1504
|
-
xr as K,
|
|
1505
|
-
kr as L,
|
|
1506
|
-
ae as M,
|
|
1507
|
-
se as N,
|
|
1508
|
-
ne as O,
|
|
1509
|
-
ot as P,
|
|
1510
|
-
Ae as Q,
|
|
1511
|
-
ke as R,
|
|
1512
|
-
ie as S,
|
|
1513
|
-
Ar as T,
|
|
1514
|
-
ce as U,
|
|
1515
|
-
le as V,
|
|
1516
|
-
ue as W,
|
|
1517
|
-
Tr as X,
|
|
1518
|
-
or as a,
|
|
1519
|
-
nr as b,
|
|
1520
|
-
Pe as c,
|
|
1521
|
-
ve as d,
|
|
1522
|
-
sr as e,
|
|
1523
|
-
ur as f,
|
|
1524
|
-
cr as g,
|
|
1525
|
-
hr as h,
|
|
1526
|
-
it as i,
|
|
1527
|
-
dr as j,
|
|
1528
|
-
mr as k,
|
|
1529
|
-
fr as l,
|
|
1530
|
-
gr as m,
|
|
1531
|
-
_t as n,
|
|
1532
|
-
St as o,
|
|
1533
|
-
Ee as p,
|
|
1534
|
-
Pr as q,
|
|
1535
|
-
ir as r,
|
|
1536
|
-
gt as s,
|
|
1537
|
-
vr as t,
|
|
1538
|
-
yr as u,
|
|
1539
|
-
pr as v,
|
|
1540
|
-
ar as w,
|
|
1541
|
-
br as x,
|
|
1542
|
-
ye as y,
|
|
1543
|
-
lr as z
|
|
1544
|
-
};
|
|
1545
|
-
//# sourceMappingURL=buildAndBroadcastReclaim-OMvihzJg.js.map
|