@babylonlabs-io/ts-sdk 5.0.0 → 5.1.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/{PayoutManager-BXzFIZK6.cjs → PayoutManager-B5nR0x1t.cjs} +2 -2
- package/dist/{PayoutManager-BXzFIZK6.cjs.map → PayoutManager-B5nR0x1t.cjs.map} +1 -1
- package/dist/{PayoutManager-Cjkozmnn.js → PayoutManager-BHeiLQ1j.js} +2 -2
- package/dist/{PayoutManager-Cjkozmnn.js.map → PayoutManager-BHeiLQ1j.js.map} +1 -1
- package/dist/{PeginManager-BipOU_e4.cjs → PeginManager-6ghglb4r.cjs} +2 -2
- package/dist/{PeginManager-BipOU_e4.cjs.map → PeginManager-6ghglb4r.cjs.map} +1 -1
- package/dist/{PeginManager-Cd5pHNTO.js → PeginManager-CXNqbgA4.js} +5 -5
- package/dist/{PeginManager-Cd5pHNTO.js.map → PeginManager-CXNqbgA4.js.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-DU8iOtbn.js → buildAndBroadcastReclaim-Acz637Vf.js} +634 -576
- package/dist/{buildAndBroadcastReclaim-DU8iOtbn.js.map → buildAndBroadcastReclaim-Acz637Vf.js.map} +1 -1
- package/dist/{buildAndBroadcastReclaim-B00roO6R.cjs → buildAndBroadcastReclaim-Cf05JFP-.cjs} +2 -2
- package/dist/{buildAndBroadcastReclaim-B00roO6R.cjs.map → buildAndBroadcastReclaim-Cf05JFP-.cjs.map} +1 -1
- package/dist/{challengeAssert-eUMgmpMk.cjs → challengeAssert-CuX_8Twt.cjs} +2 -2
- package/dist/{challengeAssert-eUMgmpMk.cjs.map → challengeAssert-CuX_8Twt.cjs.map} +1 -1
- package/dist/{challengeAssert-pJP7MKhG.js → challengeAssert-D_lRvsO0.js} +2 -2
- package/dist/{challengeAssert-pJP7MKhG.js.map → challengeAssert-D_lRvsO0.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +90 -87
- package/dist/{pegin-registration-client-ZI0k10_3.js → pegin-registration-client-BlrXyZpF.js} +67 -70
- package/dist/pegin-registration-client-BlrXyZpF.js.map +1 -0
- package/dist/pegin-registration-client-DOb-Iznp.cjs +2 -0
- package/dist/pegin-registration-client-DOb-Iznp.cjs.map +1 -0
- package/dist/peginState-B4t_PDgj.cjs +2 -0
- package/dist/peginState-B4t_PDgj.cjs.map +1 -0
- package/dist/{peginState-CIibG9S_.js → peginState-CXdbSit3.js} +7 -7
- package/dist/peginState-CXdbSit3.js.map +1 -0
- package/dist/{reservation-BZQABu4g.js → reservation-BAj5n-H_.js} +2 -2
- package/dist/{reservation-BZQABu4g.js.map → reservation-BAj5n-H_.js.map} +1 -1
- package/dist/{reservation-CA5knoQ0.cjs → reservation-D9ftyiwP.cjs} +2 -2
- package/dist/{reservation-CA5knoQ0.cjs.map → reservation-D9ftyiwP.cjs.map} +1 -1
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +92 -89
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.js +3 -3
- package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/index.d.ts +1 -1
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts +9 -2
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts +27 -1
- package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +85 -82
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +92 -89
- package/dist/{toRefundInputs-CR7vtHMa.cjs → toRefundInputs-BzyN0zvj.cjs} +2 -2
- package/dist/{toRefundInputs-CR7vtHMa.cjs.map → toRefundInputs-BzyN0zvj.cjs.map} +1 -1
- package/dist/{toRefundInputs-BrJrmOvY.js → toRefundInputs-DwXpKQxN.js} +4 -4
- package/dist/{toRefundInputs-BrJrmOvY.js.map → toRefundInputs-DwXpKQxN.js.map} +1 -1
- package/dist/types-BnZIbDHb.cjs.map +1 -1
- package/dist/types-K_aM5GZO.js.map +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-DcxCojp0.cjs → verifyKeyPathSchnorrSignature-BVrAmVL3.cjs} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-DcxCojp0.cjs.map → verifyKeyPathSchnorrSignature-BVrAmVL3.cjs.map} +1 -1
- package/dist/{verifyKeyPathSchnorrSignature-DPXOFOol.js → verifyKeyPathSchnorrSignature-CIE3jlVt.js} +2 -2
- package/dist/{verifyKeyPathSchnorrSignature-DPXOFOol.js.map → verifyKeyPathSchnorrSignature-CIE3jlVt.js.map} +1 -1
- package/dist/verifyScriptPathSchnorrSignature-BHskbJJx.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-BHskbJJx.cjs.map +1 -0
- package/dist/{verifyScriptPathSchnorrSignature-D-fdi-sG.js → verifyScriptPathSchnorrSignature-DLNGgm4j.js} +181 -173
- package/dist/verifyScriptPathSchnorrSignature-DLNGgm4j.js.map +1 -0
- package/package.json +3 -3
- package/dist/pegin-registration-client-DLlaZbsZ.cjs +0 -2
- package/dist/pegin-registration-client-DLlaZbsZ.cjs.map +0 -1
- package/dist/pegin-registration-client-ZI0k10_3.js.map +0 -1
- package/dist/peginState-CIibG9S_.js.map +0 -1
- package/dist/peginState-IyE22wWh.cjs +0 -2
- package/dist/peginState-IyE22wWh.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-D-fdi-sG.js.map +0 -1
package/dist/tbv/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { P as s, h as r, i as t, j as i, f as o, b as n, a as l, c as p, k as P, d as E, e as c, g as
|
|
1
|
+
import { P as s, h as r, i as t, j as i, f as o, b as n, a as l, c as p, k as P, d as E, e as c, g as u } from "../verifyScriptPathSchnorrSignature-DLNGgm4j.js";
|
|
2
2
|
import { a as g } from "../secp256k1-BuxBFUHm.js";
|
|
3
3
|
import { attachFinalizedAssert as R, computeMinClaimValue as A, computeMinPeginFee as _, deriveVaultId as S, expandAuthAnchor as T, expandHashlockSecret as C, expandWotsSeed as I, finalizePayout as f, finalizeWronglyChallenged as h, peginP2aAnchorOutput as V, pinPegoutProof as O, supportedTxGraphVersions as x, validatePeginP2aAnchor as b } from "./core/wasm/index.js";
|
|
4
|
-
import { a as N, c as
|
|
5
|
-
import { d as U, c as H, a as L, b as K, e as X, f as G, r as k } from "../challengeAssert-
|
|
4
|
+
import { a as N, c as y, b as M, e as v, f as D } from "../verifyKeyPathSchnorrSignature-CIE3jlVt.js";
|
|
5
|
+
import { d as U, c as H, a as L, b as K, e as X, f as G, r as k } from "../challengeAssert-D_lRvsO0.js";
|
|
6
6
|
import { c as w, d as z, a as Y, b as j, e as J, f as Z, k as q, g as Q, h as $, i as aa, j as ea, p as sa, s as ra, t as ta, u as ia, v as oa } from "../bitcoin-C-TuHb-v.js";
|
|
7
7
|
import { c as la } from "../abortSignals-BPpAUL1Z.js";
|
|
8
8
|
import { c as Pa, a as Ea } from "../signing-C1rR4tqs.js";
|
|
9
|
-
import { B as
|
|
9
|
+
import { B as ua, C as da, H as ga, K as ma, M as Ra, T as Aa, X as _a } from "../validation-OSC0xTHB.js";
|
|
10
10
|
import { waitForTransactionReceiptSmartAware as Ta } from "./core/utils/eth/index.js";
|
|
11
|
-
import { P as Ia, b as fa, c as ha, d as Va, e as Oa } from "../PeginManager-
|
|
12
|
-
import { P as ba, c as Fa, f as Na, r as
|
|
11
|
+
import { P as Ia, b as fa, c as ha, d as Va, e as Oa } from "../PeginManager-CXNqbgA4.js";
|
|
12
|
+
import { P as ba, c as Fa, f as Na, r as ya, s as Ma, v as va } from "../PayoutManager-BHeiLQ1j.js";
|
|
13
13
|
import { MEMPOOL_API_URLS as Ba, MempoolNotFoundError as Ua, getAddressTxs as Ha, getAddressUtxos as La, getMempoolApiUrl as Ka, getNetworkFees as Xa, getOutspend as Ga, getTipHeight as ka, getTxHex as Wa, getTxInfo as wa, getUtxoInfo as za, pushTx as Ya } from "./core/clients/mempool/index.js";
|
|
14
14
|
import { R as Ja, V as Za, a as qa, f as Qa, d as $a, g as ae, e as ee, i as se, r as re, v as te, b as ie, c as oe } from "../registration-records-D39ApuHS.js";
|
|
15
15
|
import { V as le, a as pe, b as Pe, r as Ee } from "../signer-set-reader-DiwLeqik.js";
|
|
16
|
-
import { C as
|
|
16
|
+
import { C as ue, M as de, V as ge, a as me, c as Re } from "../pegin-registration-client-BlrXyZpF.js";
|
|
17
17
|
import { O as _e, V as Se } from "../types-K_aM5GZO.js";
|
|
18
18
|
import { A as Ce } from "../ApplicationRegistry.abi-s8cQ1ooR.js";
|
|
19
19
|
import { B as fe } from "../BTCVaultRegistry.abi-DnP4UkB5.js";
|
|
20
|
-
import { B as Ve, C as Oe, E as xe, P as be, a as Fe, e as Ne, g as
|
|
20
|
+
import { B as Ve, C as Oe, E as xe, P as be, a as Fe, e as Ne, g as ye, h as Me, i as ve, b as De } from "../BTCVaultRegistryKeyEpochs.abi-Btg0nBz1.js";
|
|
21
21
|
import { P as Ue } from "../ProtocolParams.abi-CuDl7AuC.js";
|
|
22
22
|
import { V as Le } from "../VaultErrors.abi-Dc3UnB_h.js";
|
|
23
23
|
import { b as Xe } from "../buildVaultContextInputForClaim-DhBoQKyN.js";
|
|
@@ -25,14 +25,14 @@ import { V as ke, b as We, a as we, d as ze, f as Ye } from "../deriveVaultRoot-
|
|
|
25
25
|
import { p as Je } from "../parseFundingOutpoints-GSM-IaaK.js";
|
|
26
26
|
import { c as qe } from "../btcTxHash-BRZ8_EZq.js";
|
|
27
27
|
import { B as $e, a as as, c as es, b as ss, d as rs, g as ts, h as is, f as os, s as ns, e as ls } from "../psbtInputFields-CCVyaQMi.js";
|
|
28
|
-
import { B as Ps, D as Es, L as cs, M as
|
|
29
|
-
import { U as Vs, a as Os, e as xs, f as bs, v as Fs } from "../reservation-
|
|
30
|
-
import { V as
|
|
28
|
+
import { B as Ps, D as Es, L as cs, M as us, c as ds, P as gs, b as ms, a as Rs, S as As, T as _s, W as Ss, f as Ts, d as Cs, p as Is, r as fs } from "../fundPeginTransaction-CwhRbCQC.js";
|
|
29
|
+
import { U as Vs, a as Os, e as xs, f as bs, v as Fs } from "../reservation-BAj5n-H_.js";
|
|
30
|
+
import { V as ys, a as Ms, b as vs, i as Ds, v as Bs } from "../index-B-9aXMxk.js";
|
|
31
31
|
import { A as Hs, C as Ls, D as Ks, J as Xs, a as Gs, b as ks, d as Ws, P as ws, R as zs, e as Ys, c as js, V as Js, i as Zs, g as qs, f as Qs } from "../state-CFn1rT74.js";
|
|
32
32
|
import { S as ar, V as er, c as sr, p as rr, v as tr, a as ir } from "../primeVpAuth-B0noJdcy.js";
|
|
33
|
-
import { D as nr, g as lr, P as pr, a as Pr, b as Er, u as cr, v as
|
|
34
|
-
import { J as Br, l as Ur, A as Hr,
|
|
35
|
-
import { C as
|
|
33
|
+
import { D as nr, g as lr, P as pr, a as Pr, b as Er, u as cr, v as ur, t as dr, w as gr, U as mr, V as Rr, f as Ar, m as _r, j as Sr, c as Tr, l as Cr, p as Ir, n as fr, e as hr, h as Vr, d as Or, i as xr, o as br, r as Fr, k as Nr, q as yr, s as Mr, x as vr } from "../toRefundInputs-DwXpKQxN.js";
|
|
34
|
+
import { J as Br, l as Ur, A as Hr, ab as Lr, C as Kr, D as Xr, n as Gr, G as kr, u as Wr, W as wr, P as zr, j as Yr, v as jr, w as Jr, al as Zr, am as qr, an as Qr, ao as $r, ae as at, af as et, ag as st, ah as rt, aj as tt, a0 as it, S as ot, X as nt, V as lt, a as pt, b as Pt, d as Et, e as ct, m as ut, f as dt, g as gt, t as mt, i as Rt, B as At, Y as _t, o as St, a4 as Tt, ak as Ct, ac as It, c as ft, k as ht, h as Vt, ad as Ot, E as xt, K as bt, M as Ft, a5 as Nt, Z as yt, x as Mt, y as vt, a1 as Dt, _ as Bt, a6 as Ut, a7 as Ht, p as Lt, r as Kt, ai as Xt, a8 as Gt, a9 as kt, aa as Wt, F as wt, q as zt, H as Yt, I as jt, s as Jt, N as Zt, O as qt, L as Qt, Q as $t, R as ai, T as ei, U as si, $ as ri, a2 as ti, z as ii, a3 as oi } from "../buildAndBroadcastReclaim-Acz637Vf.js";
|
|
35
|
+
import { C as li, P as pi, a as Pi, c as Ei, g as ci, i as ui } from "../peginState-CXdbSit3.js";
|
|
36
36
|
export {
|
|
37
37
|
Hs as AUTH_REJECTED_RPC_CODE,
|
|
38
38
|
Br as ApplicationEntryPointMismatchError,
|
|
@@ -40,17 +40,17 @@ export {
|
|
|
40
40
|
Ur as ArtifactsVaultMismatchError,
|
|
41
41
|
Hr as AssertBindingError,
|
|
42
42
|
Lr as BIP68NotMatureError,
|
|
43
|
-
|
|
43
|
+
ua as BITCOIN_ADDRESS_RE,
|
|
44
44
|
fe as BTCVaultRegistryABI,
|
|
45
45
|
Ve as BTCVaultRegistryKeyEpochsABI,
|
|
46
46
|
Ps as BTC_DUST_SAT,
|
|
47
47
|
$e as BitcoinScriptType,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
ue as COMMISSION_BPS_HEADROOM,
|
|
49
|
+
da as COMPRESSED_PUBKEY_HEX_LEN,
|
|
50
50
|
Oe as CONTRACT_ERRORS,
|
|
51
51
|
Kr as ChallengerSetMismatchError,
|
|
52
52
|
Ls as ClaimerPegoutStatusValue,
|
|
53
|
-
|
|
53
|
+
li as ContractStatus,
|
|
54
54
|
Xr as DELEGATED_CLAIM_TX_GRAPH_VERSION,
|
|
55
55
|
nr as DEPOSIT_TERMS_REJECTED_ERROR_NAME,
|
|
56
56
|
Es as DUST_THRESHOLD,
|
|
@@ -65,10 +65,10 @@ export {
|
|
|
65
65
|
ks as JsonRpcError,
|
|
66
66
|
ma as KNOWN_SCRIPT_PREFIXES,
|
|
67
67
|
cs as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
de as MAX_ACCEPTABLE_COMMISSION_BPS_CAP,
|
|
69
|
+
us as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
70
70
|
Ra as MAX_REASONABLE_FEE_SATS,
|
|
71
|
-
|
|
71
|
+
ds as MAX_REASONABLE_PEGIN_VBYTES,
|
|
72
72
|
Ba as MEMPOOL_API_URLS,
|
|
73
73
|
Ua as MempoolNotFoundError,
|
|
74
74
|
_e as OnChainBtcVaultStatus,
|
|
@@ -86,13 +86,13 @@ export {
|
|
|
86
86
|
zr as PayoutDestinationError,
|
|
87
87
|
Yr as PayoutInputLeafError,
|
|
88
88
|
ba as PayoutManager,
|
|
89
|
-
|
|
89
|
+
pi as PeginAction,
|
|
90
90
|
Fe as PeginFingerprintChangedError,
|
|
91
91
|
Er as PeginFingerprintInputError,
|
|
92
92
|
Ia as PeginManager,
|
|
93
93
|
cr as PeginParamsAmbiguousError,
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
ur as PeginParamsIncompleteSpaceError,
|
|
95
|
+
dr as PeginParamsNotFoundError,
|
|
96
96
|
jr as PeginRegistrationMissingError,
|
|
97
97
|
Jr as PeginRegistrationNotFinalError,
|
|
98
98
|
gr as PeginSizingIntegrityError,
|
|
@@ -116,6 +116,7 @@ export {
|
|
|
116
116
|
Aa as TXID_RE,
|
|
117
117
|
_s as TX_BUFFER_SIZE_OVERHEAD,
|
|
118
118
|
mr as UnanchoredPrePeginError,
|
|
119
|
+
nt as UnsupportedPayoutScriptError,
|
|
119
120
|
Vs as UtxoNotAvailableError,
|
|
120
121
|
ke as VAULT_APP_NAME,
|
|
121
122
|
Le as VAULT_ERROR_ABI,
|
|
@@ -123,8 +124,8 @@ export {
|
|
|
123
124
|
js as VP_TERMINAL_FAILURE_STATUSES,
|
|
124
125
|
Js as VP_TRANSIENT_STATUSES,
|
|
125
126
|
Za as VaultClaimableByNotFoundError,
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
lt as VaultIdBindingError,
|
|
128
|
+
ys as VaultProviderRpcClient,
|
|
128
129
|
Rr as VaultRootMismatchError,
|
|
129
130
|
le as ViemOperationKeyReader,
|
|
130
131
|
ge as ViemPeginRegistrationClient,
|
|
@@ -132,43 +133,44 @@ export {
|
|
|
132
133
|
pe as ViemUniversalChallengerReader,
|
|
133
134
|
Pe as ViemVaultKeeperReader,
|
|
134
135
|
me as ViemVaultRegistryReader,
|
|
135
|
-
|
|
136
|
+
Ms as VpResponseValidationError,
|
|
136
137
|
er as VpTokenRegistry,
|
|
137
138
|
Ss as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
138
139
|
_a as X_ONLY_PUBKEY_HEX_LEN,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
pt as activateVault,
|
|
141
|
+
Pt as activateVaultAndRedeem,
|
|
142
|
+
Pi as activationDeadlineBlocksRemaining,
|
|
142
143
|
as as applyChangeOutputPolicy,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
Et as assembleWatchtowerArtifacts,
|
|
145
|
+
ct as assembleWatchtowerArtifactsFromSignatures,
|
|
146
|
+
ut as assertArtifactsUsableForVault,
|
|
146
147
|
dt as assertAssertBindsClaimAndPayout,
|
|
147
|
-
|
|
148
|
+
gt as assertChallengerSetMatchesVault,
|
|
148
149
|
Ar as assertClaimBatchHomogeneous,
|
|
149
|
-
|
|
150
|
+
mt as assertClaimSpendsVault,
|
|
150
151
|
N as assertKeyPathSchnorrSignature,
|
|
151
152
|
qa as assertOnChainBtcPubkey,
|
|
152
|
-
|
|
153
|
+
Rt as assertPayoutPaysRegisteredScript,
|
|
153
154
|
t as assertPsbtUnsignedTxMatches,
|
|
154
155
|
Qa as assertRegisteredPayoutScriptBounds,
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
At as assertReturnedGraphMatchesFingerprint,
|
|
157
|
+
y as assertReturnedKeyPathSignatures,
|
|
157
158
|
i as assertScriptPathSchnorrSignature,
|
|
158
|
-
|
|
159
|
+
_t as assertStandardPayoutScriptsAtEpochs,
|
|
160
|
+
St as assertTermsMatchVault,
|
|
159
161
|
Os as assertUtxosAvailable,
|
|
160
162
|
g as assertValidVaultCoreVersion,
|
|
161
|
-
|
|
163
|
+
Tt as assertVaultProviderHintAccepted,
|
|
162
164
|
R as attachFinalizedAssert,
|
|
163
165
|
vs as batchPollByProvider,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
Ct as buildAndBroadcastReclaim,
|
|
167
|
+
It as buildAndBroadcastRefund,
|
|
166
168
|
U as buildChallengeAssertPsbt,
|
|
167
169
|
fa as buildDepositTerms,
|
|
168
170
|
We as buildFundingOutpointsCommitment,
|
|
169
171
|
H as buildNoPayoutPsbt,
|
|
170
172
|
o as buildPayoutPsbt,
|
|
171
|
-
|
|
173
|
+
M as buildPeginInputPsbt,
|
|
172
174
|
_r as buildPeginParamsCandidates,
|
|
173
175
|
n as buildPeginTxFromFundedPrePegin,
|
|
174
176
|
l as buildPrePeginPsbt,
|
|
@@ -177,10 +179,10 @@ export {
|
|
|
177
179
|
we as buildVaultContext,
|
|
178
180
|
Xe as buildVaultContextInputForClaim,
|
|
179
181
|
qe as calculateBtcTxHash,
|
|
180
|
-
|
|
182
|
+
Ei as canPerformAction,
|
|
181
183
|
w as canonicalizeBtcPubkey,
|
|
182
184
|
Re as capMaxAcceptableCommissionBps,
|
|
183
|
-
|
|
185
|
+
ft as claimExpiredVault,
|
|
184
186
|
la as combineAbortSignals,
|
|
185
187
|
es as computeChangeOutputFeeSats,
|
|
186
188
|
Sr as computeFundedPrePeginFee,
|
|
@@ -192,13 +194,13 @@ export {
|
|
|
192
194
|
rs as computePeginBaseFeeSats,
|
|
193
195
|
Tr as computePeginFingerprint,
|
|
194
196
|
ha as computeWotsBlockPublicKeysHash,
|
|
195
|
-
|
|
197
|
+
ht as copyAssertConnectorLeaf,
|
|
196
198
|
sr as createAuthenticatedVpClient,
|
|
197
199
|
P as createPayoutScript,
|
|
198
200
|
Pa as createTaprootScriptPathSignOptions,
|
|
199
201
|
Ea as createTaprootScriptPathSignOptionsForInput,
|
|
200
202
|
z as deriveBip86ScriptPubKeyHex,
|
|
201
|
-
|
|
203
|
+
Vt as deriveClaimerWotsKeypair,
|
|
202
204
|
E as deriveDepositorClaimDescriptor,
|
|
203
205
|
c as deriveDepositorClaimScriptPubKey,
|
|
204
206
|
Cr as deriveHashlocksFromPrePegin,
|
|
@@ -214,13 +216,13 @@ export {
|
|
|
214
216
|
J as ensureHexPrefix,
|
|
215
217
|
Oa as ensurePrePeginTermsApproval,
|
|
216
218
|
X as estimateReclaimFeeSats,
|
|
217
|
-
|
|
219
|
+
Ot as estimateRefundFeeSats,
|
|
218
220
|
T as expandAuthAnchor,
|
|
219
221
|
C as expandHashlockSecret,
|
|
220
222
|
I as expandWotsSeed,
|
|
221
223
|
Ne as extractErrorData,
|
|
222
224
|
xs as extractInputsFromTransaction,
|
|
223
|
-
|
|
225
|
+
u as extractPayoutSignature,
|
|
224
226
|
v as extractPeginInputSignature,
|
|
225
227
|
f as finalizePayout,
|
|
226
228
|
D as finalizePeginInputPsbt,
|
|
@@ -228,20 +230,20 @@ export {
|
|
|
228
230
|
h as finalizeWronglyChallenged,
|
|
229
231
|
bs as findOverlappingPendingVaults,
|
|
230
232
|
ae as findRegistrationRecord,
|
|
231
|
-
|
|
233
|
+
xt as fingerprintReturnedGraph,
|
|
232
234
|
Z as formatSatoshisToBtc,
|
|
233
235
|
Na as forwardDepositApproval,
|
|
234
236
|
Ye as forwardDeriveContextHash,
|
|
235
237
|
Ts as fundPeginTransaction,
|
|
236
238
|
Ha as getAddressTxs,
|
|
237
239
|
La as getAddressUtxos,
|
|
238
|
-
|
|
240
|
+
ye as getContractErrorMessage,
|
|
239
241
|
ts as getDustThreshold,
|
|
240
242
|
Ka as getMempoolApiUrl,
|
|
241
243
|
q as getNetwork,
|
|
242
244
|
Xa as getNetworkFees,
|
|
243
245
|
Ga as getOutspend,
|
|
244
|
-
|
|
246
|
+
ci as getPeginProtocolState,
|
|
245
247
|
is as getPsbtInputFields,
|
|
246
248
|
os as getScriptType,
|
|
247
249
|
Q as getSortedXOnlyPubkeys,
|
|
@@ -249,89 +251,90 @@ export {
|
|
|
249
251
|
Wa as getTxHex,
|
|
250
252
|
wa as getTxInfo,
|
|
251
253
|
za as getUtxoInfo,
|
|
252
|
-
|
|
254
|
+
Me as handleContractError,
|
|
253
255
|
$ as hexToUint8Array,
|
|
254
|
-
|
|
256
|
+
ui as isActivationDeadlinePassedOnChain,
|
|
255
257
|
aa as isAddressFromPublicKey,
|
|
256
|
-
|
|
258
|
+
bt as isApplicationEntryPointMismatchError,
|
|
257
259
|
Zs as isAuthRejectedError,
|
|
258
|
-
|
|
260
|
+
Ft as isDepositAmountValid,
|
|
259
261
|
Vr as isDepositTermsRejectedError,
|
|
260
|
-
|
|
262
|
+
Nt as isHintAccepted,
|
|
261
263
|
ve as isKnownContractError,
|
|
262
|
-
|
|
264
|
+
yt as isParticipantKeyDriftError,
|
|
263
265
|
De as isPeginFingerprintChangedError,
|
|
264
266
|
Or as isPeginFingerprintInputError,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
+
Mt as isPeginRegistrationMissingError,
|
|
268
|
+
vt as isPeginRegistrationNotFinalError,
|
|
267
269
|
qs as isPegoutTerminalStatus,
|
|
268
270
|
Qs as isRecognizedPegoutStatus,
|
|
269
|
-
|
|
271
|
+
Dt as isRegisteredVaultVersionMismatchError,
|
|
270
272
|
ee as isRegistrationLogsUnavailableError,
|
|
271
273
|
Ds as isUnrecognizedDaemonStatusError,
|
|
274
|
+
Bt as isUnsupportedPayoutScriptError,
|
|
272
275
|
ea as isValidHex,
|
|
273
276
|
se as isVaultClaimableByNotFoundError,
|
|
274
277
|
xr as isWotsMismatchError,
|
|
275
|
-
|
|
276
|
-
|
|
278
|
+
Ut as matchKeyHint,
|
|
279
|
+
Ht as matchKeySetHint,
|
|
277
280
|
br as orderClaimBatchByHtlcVout,
|
|
278
281
|
Je as parseFundingOutpointsFromTx,
|
|
279
282
|
Cs as parseUnfundedWasmTransaction,
|
|
280
283
|
Is as peginOutputCount,
|
|
281
284
|
V as peginP2aAnchorOutput,
|
|
282
285
|
O as pinPegoutProof,
|
|
283
|
-
|
|
286
|
+
Lt as planDelegatedClaimSigning,
|
|
284
287
|
rr as primeVpTokenRegistry,
|
|
285
288
|
sa as processPublicKeyToXOnly,
|
|
286
289
|
Ya as pushTx,
|
|
287
290
|
fs as rateBasedTxBufferFee,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
Kt as readDelegatedClaimVaultContext,
|
|
292
|
+
Xt as readRefundPrePeginContext,
|
|
293
|
+
Gt as readStampedParticipantKeys,
|
|
291
294
|
Fr as rebuildDepositTermsCore,
|
|
292
295
|
Nr as rebuildDepositTermsForClaim,
|
|
293
296
|
k as reclaimVsize,
|
|
294
|
-
|
|
297
|
+
yr as reconstructPeginParams,
|
|
295
298
|
re as registrationPrePeginTxHash,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
+
ya as requireChangeAddress,
|
|
300
|
+
kt as resolveCurrentParticipantKeys,
|
|
301
|
+
Wt as resolveParticipantKeysAtEpochs,
|
|
299
302
|
Ee as resolveProtocolAddresses,
|
|
300
|
-
|
|
301
|
-
|
|
303
|
+
wt as runDepositorPresignFlow,
|
|
304
|
+
Mr as selectSiblingRegistrations,
|
|
302
305
|
ns as selectUtxosForPegin,
|
|
303
306
|
ls as shouldAddChangeOutput,
|
|
304
|
-
|
|
305
|
-
|
|
307
|
+
zt as signDelegatedClaimPlan,
|
|
308
|
+
Yt as signDepositorGraph,
|
|
306
309
|
ra as stripHexPrefix,
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
jt as submitWotsPublicKey,
|
|
311
|
+
Jt as summarizeWatchtowerArtifacts,
|
|
309
312
|
x as supportedTxGraphVersions,
|
|
310
|
-
|
|
313
|
+
Ma as supportsDepositApproval,
|
|
311
314
|
vr as toRefundInputs,
|
|
312
315
|
ta as toXOnly,
|
|
313
316
|
ia as uint8ArrayToHex,
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
Zt as validateDepositAmount,
|
|
318
|
+
qt as validateMultiVaultDepositInputs,
|
|
316
319
|
te as validateOffchainParams,
|
|
317
|
-
|
|
320
|
+
Qt as validateOnChainParticipantKeys,
|
|
318
321
|
ie as validatePegInConfiguration,
|
|
319
322
|
b as validatePeginP2aAnchor,
|
|
320
|
-
|
|
321
|
-
|
|
323
|
+
$t as validateProviderSelection,
|
|
324
|
+
ai as validateRemainingCapacity,
|
|
322
325
|
Bs as validateRequestDepositorClaimerArtifactsResponse,
|
|
323
326
|
va as validateSecretAgainstHashlock,
|
|
324
327
|
oe as validateTBVProtocolParams,
|
|
325
328
|
Fs as validateUtxosAvailable,
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
ei as validateVaultAmounts,
|
|
330
|
+
si as validateVaultProviderPubkey,
|
|
328
331
|
oa as validateWalletPubkey,
|
|
329
|
-
|
|
330
|
-
|
|
332
|
+
ri as verifyRegisteredParticipantKeys,
|
|
333
|
+
ti as verifyRegisteredVaultVersions,
|
|
331
334
|
tr as verifyServerIdentity,
|
|
332
335
|
ir as vpTokenRegistry,
|
|
333
|
-
|
|
334
|
-
|
|
336
|
+
ii as waitForPeginRegistrationDepth,
|
|
337
|
+
oi as waitForPeginStatus,
|
|
335
338
|
Ta as waitForTransactionReceiptSmartAware
|
|
336
339
|
};
|
|
337
340
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Pe=Object.defineProperty;var fe=(e,t,r)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var j=(e,t,r)=>fe(e,typeof t!="symbol"?t+"":t,r);const M=require("./registration-records-CKc0OVuK.cjs"),d=require("./bitcoin-D-O2GjbC.cjs"),N=require("./btcTxHash-CGb5BqFL.cjs"),O=require("bitcoinjs-lib"),ve=require("buffer"),be=require("./tbv/core/clients/mempool/index.cjs"),X=require("./validation-C6XTfZak.cjs"),y=require("viem"),Ee=require("./sha2-Ce6KewYx.cjs"),D=require("./PayoutManager-BXzFIZK6.cjs"),ee=require("./PeginManager-BipOU_e4.cjs"),b=require("./tbv/core/wasm/index.cjs"),xe=require("./deriveVaultRoot-C3uqnJto.cjs"),we=require("./parseFundingOutpoints-C_-PT9BT.cjs"),K=require("./verifyScriptPathSchnorrSignature-CgDa9Rcg.cjs"),Q=require("./fundPeginTransaction-54-Rwb2k.cjs"),ye=["vaultCoreVersion","offchainParamsVersion","appVaultKeepersVersion","universalChallengersVersion"],Ce=["applicationEntryPoint","vaultProvider"];function te(e,t){const r=t.depositor.toLowerCase(),n=M.registrationPrePeginTxHash(t).toLowerCase();return e.filter(o=>o.vaultId!==t.vaultId&&o.depositor.toLowerCase()===r&&M.registrationPrePeginTxHash(o).toLowerCase()===n)}function re(e,t){for(const r of t){for(const n of ye)if(r.vault.protocol[n]!==e.vault.protocol[n])throw new Error(`Sibling vaults of this Pre-PegIn disagree on ${n} (${r.vault.protocol[n]} vs ${e.vault.protocol[n]}); the batch cannot be described by one set of deposit terms.`);if(r.maxAcceptableCommissionBps!==e.maxAcceptableCommissionBps)throw new Error(`Sibling vaults of this Pre-PegIn disagree on maxAcceptableCommissionBps (${r.maxAcceptableCommissionBps} vs ${e.maxAcceptableCommissionBps}); the batch cannot be described by one set of deposit terms.`);for(const n of Ce)if(r.vault.basic[n].toLowerCase()!==e.vault.basic[n].toLowerCase())throw new Error(`Sibling vaults of this Pre-PegIn disagree on ${n} (${r.vault.basic[n]} vs ${e.vault.basic[n]}); the batch cannot be described by one set of deposit terms.`)}}function ne(e){const t=[...e].sort((r,n)=>r.vault.protocol.htlcVout-n.vault.protocol.htlcVout);return t.forEach((r,n)=>{if(r.vault.protocol.htlcVout!==n)throw new Error(`Sibling discovery produced a non-contiguous HTLC vector (${t.map(o=>o.vault.protocol.htlcVout).join(", ")}).`)}),t.map(r=>({hashlock:r.vault.protocol.hashlock,amount:r.vault.basic.amount}))}const L="DepositTermsRejectedError";class oe extends Error{constructor(r,n="device-envelope"){super(r);j(this,"reason");this.name=L,this.reason=n}}function Re(e){if(e instanceof oe)return!0;if(typeof e!="object"||e===null)return!1;const t=e;return t.name===L&&t.reason==="device-envelope"}async function se(e,t){const r=O.Transaction.fromHex(d.stripHexPrefix(e)),o=(await Promise.all(r.ins.map(a=>be.getUtxoInfo(ve.Buffer.from(a.hash).reverse().toString("hex"),a.index,t)))).reduce((a,i)=>a+BigInt(i.value),0n),c=r.outs.reduce((a,i)=>a+BigInt(i.value),0n),s=o-c;if(s<=0n)throw new Error(`The funded Pre-PegIn transaction's inputs do not cover its outputs plus a fee (computed fee: ${s} sats).`);if(s>X.MAX_REASONABLE_FEE_SATS)throw new Error(`The funded Pre-PegIn transaction's computed fee (${s} sats) exceeds the maximum reasonable fee (${X.MAX_REASONABLE_FEE_SATS} sats); the mempool API may have returned manipulated prevout data.`);return s}async function z(e){const t=e.siblings.length;if(t===0)throw new Error("rebuildDepositTermsCore: at least one sibling is required");for(const[m,p]of e.siblings.entries())if(p.amount<=0n)throw new Error(`rebuildDepositTermsCore: sibling[${m}] has non-positive on-chain pegin amount ${p.amount}; the chain-read vault record is invalid. Resume refused.`);if(e.prepeginMaxFee<=0n)throw new Error(`rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`);const r=d.stripHexPrefix(e.prepeginTxid).toLowerCase(),n=d.stripHexPrefix(N.calculateBtcTxHash(e.fundedPrePeginTxHex)).toLowerCase();if(n!==r)throw new Error(`Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prepeginTxid). Resume refused.`);const o=D.findAuthAnchorOpReturn(d.stripHexPrefix(e.fundedPrePeginTxHex));if(o===void 0)throw new Error("Funded Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN commitment — it either predates auth anchoring or is malformed. The intent resume path requires the anchor to prove sibling completeness. Resume refused.");if(o.vout!==t)throw new Error(`Auth-anchor OP_RETURN at vout ${o.vout} does not match the discovered sibling count ${t}; the discovered sibling set does not cover this transaction's HTLC outputs (a lagging index can cause this — retry later). Resume refused.`);const c=e.vaultKeeperBtcPubkeys.length,s=e.universalChallengerBtcPubkeys.length,a=await b.computeMinClaimValue(e.vaultCoreVersion,c,s,e.councilQuorum,e.councilSize,e.protocolFeeRate),i=await b.computeMinPeginFee(e.vaultCoreVersion,c,s,e.minPeginFeeRate),{value:l}=await b.peginP2aAnchorOutput(e.vaultCoreVersion);if(a<=0n)throw new Error(`WASM returned non-positive depositorClaimValue ${a}; expected > 0. Resume refused.`);if(i<=0n)throw new Error(`WASM returned non-positive peginMaxFee ${i}; expected > 0. Resume refused.`);if(l<0n)throw new Error(`WASM returned negative P2A anchor value ${l}. Resume refused.`);const u=i+l,h=e.minPeginFeeRate*Q.MAX_REASONABLE_PEGIN_VBYTES;if(u<=0n||u>h)throw new Error(`WASM implied PegIn reserve ${u} sat is outside (0, ${h}] (minPeginFeeRate=${e.minPeginFeeRate} × ${Q.MAX_REASONABLE_PEGIN_VBYTES} vbytes). Resume refused.`);const x=e.siblings.map(m=>m.amount+a+i+l),w=await Promise.all(e.siblings.map(async m=>(await b.getPrePeginHtlcConnectorInfo({txGraphVersion:e.vaultCoreVersion,depositorPubkey:e.depositorBtcPubkey,vaultProviderPubkey:e.vaultProviderBtcPubkey,vaultKeeperPubkeys:[...e.vaultKeeperBtcPubkeys],universalChallengerPubkeys:[...e.universalChallengerBtcPubkeys],hashlock:d.stripHexPrefix(m.hashlock),timelockRefund:e.timelockRefund,network:e.network})).scriptPubKey)),C=O.Transaction.fromHex(d.stripHexPrefix(e.fundedPrePeginTxHex)).outs.map(m=>({value:m.value,script:m.script}));return K.assertEncodedHtlcOutputsMatch(C,x,w),ee.buildDepositTerms({vaultCoreVersion:e.vaultCoreVersion,protocolFeeRate:e.protocolFeeRate,timelockPegin:e.timelockPegin,timelockAssert:e.timelockAssert,timelockRefund:e.timelockRefund,prepeginTxid:e.prepeginTxid,prepeginMaxFee:e.prepeginMaxFee,vaultProviderBtcPubkey:e.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:e.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:e.universalChallengerBtcPubkeys,maxAcceptableCommissionBps:e.maxAcceptableCommissionBps,peginAmounts:e.siblings.map(m=>m.amount),depositorClaimValue:a,peginMaxFee:i})}async function ke(e){const{read:t}=e,r=d.canonicalizeBtcPubkey(e.depositorBtcPubkey);if(r!==t.context.depositorBtcPubkey)throw new Error("Connected wallet key is not the vault's depositor key; select the account that made the deposit.");const n=d.stripHexPrefix(t.prePeginTxHash).toLowerCase(),o=d.stripHexPrefix(N.calculateBtcTxHash(e.fundedPrePeginTxHex)).toLowerCase();if(o!==n)throw new Error(`Funded Pre-PegIn tx hashes to ${o}, expected ${n} (on-chain prePeginTxHash).`);const c=await Promise.all(te(t.registrationRecords,t.registrationRecord).map(async l=>{const u=await e.siblingReader.getVaultData(l.vaultId);if(u.protocol.prePeginTxHash.toLowerCase()!==M.registrationPrePeginTxHash(l).toLowerCase())throw new Error(`Sibling ${l.vaultId} is registered against a different Pre-PegIn on chain than its registration log records; refusing an inconsistent node.`);return{vault:u,maxAcceptableCommissionBps:l.maxAcceptableCommissionBps}})),s={vault:t.vault,maxAcceptableCommissionBps:t.registrationRecord.maxAcceptableCommissionBps};re(s,c);const a=ne([s,...c]),i=await se(e.fundedPrePeginTxHex,e.mempoolApiUrl);return z({vaultCoreVersion:t.vault.protocol.vaultCoreVersion,siblings:a,fundedPrePeginTxHex:e.fundedPrePeginTxHex,depositorBtcPubkey:r,vaultProviderBtcPubkey:t.participantKeys.vaultProvider.operationBtcPubkey,vaultKeeperBtcPubkeys:t.participantKeys.vaultKeeperOperationKeysSorted,universalChallengerBtcPubkeys:t.participantKeys.universalChallengerOperationKeysSorted,protocolFeeRate:t.offchainParams.feeRate,minPeginFeeRate:t.offchainParams.minPeginFeeRate,councilQuorum:t.offchainParams.councilQuorum,councilSize:t.offchainParams.securityCouncilKeys.length,timelockPegin:t.context.timelockPegin,timelockAssert:t.context.timelockAssert,timelockRefund:t.offchainParams.tRefund,prepeginTxid:n,prepeginMaxFee:i,maxAcceptableCommissionBps:t.registrationRecord.maxAcceptableCommissionBps,network:e.network})}function Te(e){const t=(e instanceof Error?e.message:typeof e=="string"?e:"").toLowerCase();return t.includes("wots")&&t.includes("hash")&&t.includes("does not match")}const ie="TBV.PeginFingerprint.v1",ae=y.keccak256(y.toHex(ie)),W=65535,J=2n**64n-1n,Ae=2n**256n-1n,Ve=/^0x[0-9a-fA-F]{64}$/,Y=1;class f extends Error{constructor(t){super(t),this.name="PeginFingerprintInputError"}}function Ie(e){return e instanceof f||e instanceof Error&&e.name==="PeginFingerprintInputError"}function _(e,t,r,n){if(typeof t!="bigint")throw new f(`${e} must be a bigint (Solidity ${n}), got ${typeof t}`);if(t<0n||t>r)throw new f(`${e} must fit Solidity ${n} (0..${r}), got ${t}`)}function I(e,t){if(!Number.isInteger(t)||t<0||t>W)throw new f(`${e} must be an integer fitting Solidity uint16 (0..${W}), got ${t}`)}function $e(e,t){if(!Ve.test(t))throw new f(`${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`);return t.toLowerCase()}function Be(e){if(!y.isAddress(e,{strict:!1}))throw new f(`registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`);const t=e.toLowerCase();if(t===y.zeroAddress)throw new f("registryAddress must not be the zero address; a zero here means the registry address was never resolved");return t}const Fe=[{name:"domain",type:"bytes32"},{name:"chainId",type:"uint256"},{name:"registry",type:"address"},{name:"vaultProviderBtcKey",type:"bytes32"},{name:"appKeeperKeyEpoch",type:"uint64"},{name:"ucKeyEpoch",type:"uint64"},{name:"appVaultKeepersVersion",type:"uint16"},{name:"universalChallengersVersion",type:"uint16"},{name:"offchainParamsVersion",type:"uint16"},{name:"vaultCoreVersion",type:"uint16"}];function ce(e){if(_("chainId",e.chainId,Ae,"uint256"),e.chainId===0n)throw new f("chainId must not be 0; a zero here means the chain id was never resolved");const t=Be(e.registryAddress),r=$e("vaultProviderBtcKey",e.vaultProviderBtcKey);if(_("appKeeperKeyEpoch",e.appKeeperKeyEpoch,J,"uint64"),_("ucKeyEpoch",e.ucKeyEpoch,J,"uint64"),I("appVaultKeepersVersion",e.appVaultKeepersVersion),I("universalChallengersVersion",e.universalChallengersVersion),I("offchainParamsVersion",e.offchainParamsVersion),I("vaultCoreVersion",e.vaultCoreVersion),e.vaultCoreVersion<Y)throw new f(`vaultCoreVersion must be at least ${Y}; ${e.vaultCoreVersion} means the version was never resolved`);return y.encodeAbiParameters(Fe,[ae,e.chainId,t,r,e.appKeeperKeyEpoch,e.ucKeyEpoch,e.appVaultKeepersVersion,e.universalChallengersVersion,e.offchainParamsVersion,e.vaultCoreVersion])}function Se(e){return y.keccak256(ce(e))}class ue extends Error{constructor(t,r){super(`Re-derived vault root does not match this Pre-PegIn: derived auth-anchor hash ${t}, transaction commits to ${r}. Connect the same wallet, on the same account and the same network, that created the deposit.`),this.derivedAuthAnchorHash=t,this.onChainAuthAnchorHash=r,this.name="VaultRootMismatchError"}}class B extends Error{constructor(t){super(t),this.name="UnanchoredPrePeginError"}}class le extends Error{constructor(t,r,n=[]){super(`No candidate parameter set reproduces this Pre-PegIn's HTLC outputs (${t} candidate(s) tried). `+(n.length>0?`${n.length} version(s) could not be resolved and may hold the answer: ${n.join(" | ")}. `:"")+`Sample rejections: ${r.join(" | ")}`),this.candidatesTried=t,this.sampleRejections=r,this.unresolvedLabels=n,this.name="PeginParamsNotFoundError"}}class he extends Error{constructor(t){super(`${t.length} candidate parameter sets reproduce this Pre-PegIn's HTLC outputs, so the vault's stamped versions cannot be determined: ${t.join(" | ")}. Reconstruction refused.`),this.survivorLabels=t,this.name="PeginParamsAmbiguousError"}}class de extends Error{constructor(t,r){super(`A candidate matched this Pre-PegIn (${t}), but ${r.length} version(s) could not be resolved, so the search space did not provably contain the true parameters: ${r.join(" | ")}. A version sharing the matched timelockRefund and participants is indistinguishable from the true one, so the match cannot be trusted. Reconstruction refused.`),this.matchedLabel=t,this.unresolvedLabels=r,this.name="PeginParamsIncompleteSpaceError"}}class A extends Error{constructor(t){super(`${t}. Reconstruction refused.`),this.name="PeginSizingIntegrityError"}}async function He(e){const{wallet:t,depositorBtcPubkey:r,fundedPrePeginTxHex:n}=e,o=d.stripHexPrefix(n),c=D.findAuthAnchorOpReturn(o);if(c===void 0)throw new B("Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path.");const s=c.vout;if(s===0)throw new B("Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover.");const a=we.parseFundingOutpointsFromTx(o),i=await xe.deriveVaultRoot(t,{depositorBtcPubkey:d.hexToUint8Array(d.processPublicKeyToXOnly(r)),fundingOutpoints:a});try{const u=await b.expandAuthAnchor(i);let h;try{h=d.uint8ArrayToHex(Ee.sha256(u))}finally{u.fill(0)}if(h!==c.hash)throw new ue(h,c.hash)}catch(u){throw i.fill(0),u}const{hashlocks:l}=await ee.expandPerVaultSecrets(i,s);return{vaultCount:s,hashlocks:l,authAnchorHash:c.hash}}function _e(e){const{vaultCoreVersion:t,offchainParams:r,participantKeySets:n}=e;if(!Number.isInteger(t)||t<1)throw new Error(`buildPeginParamsCandidates: vaultCoreVersion must be a positive integer, got ${t}`);if(r.length===0)throw new Error("buildPeginParamsCandidates: at least one offchain-params version is required");if(n.length===0)throw new Error("buildPeginParamsCandidates: at least one participant key set is required");const o=[];for(const c of r)for(const s of n)o.push({vaultCoreVersion:t,offchainParams:c,participants:s});return o}function pe(e){return`${e.axis} v${e.version} (${e.reason})`}function $(e){const{participants:t}=e;return`core=${e.vaultCoreVersion} offchain=${e.offchainParams.version} keepers=${t.appVaultKeepersVersion} challengers=${t.universalChallengersVersion} vp=${t.vaultProvider}`}const Z=5;function Me(e,t){return JSON.stringify({terms:e,peginAmounts:t},(r,n)=>typeof n=="bigint"?`${n}`:n)}function Ke(e){const{offchainParams:t,participants:r}=e;return[e.vaultCoreVersion,r.vaultKeeperBtcPubkeys.length,r.universalChallengerBtcPubkeys.length,t.councilQuorum,t.councilSize,t.protocolFeeRate,t.minPeginFeeRate].join("|")}async function Ne(e){const{offchainParams:t,participants:r}=e,n=r.vaultKeeperBtcPubkeys.length,o=r.universalChallengerBtcPubkeys.length,[c,s,a]=await Promise.all([b.computeMinClaimValue(e.vaultCoreVersion,n,o,t.councilQuorum,t.councilSize,t.protocolFeeRate),b.computeMinPeginFee(e.vaultCoreVersion,n,o,t.minPeginFeeRate),b.peginP2aAnchorOutput(e.vaultCoreVersion)]),i=a.value;if(c<=0n)throw new A(`WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`);if(s<=0n)throw new A(`WASM returned non-positive peginMaxFee ${s} for graph version ${e.vaultCoreVersion}`);if(i<0n)throw new A(`WASM returned negative P2A anchor value ${i} for graph version ${e.vaultCoreVersion}`);return{depositorClaimValue:c,peginMaxFee:s,p2aAnchorValue:i}}async function Oe(e){const{hashlocks:t,fundedPrePeginTxHex:r,depositorBtcPubkey:n,prepeginMaxFee:o,maxAcceptableCommissionBps:c,network:s,candidates:a,unresolvedVersions:i}=e;if(t.length===0)throw new Error("reconstructPeginParams: at least one hashlock is required");if(a.length===0)throw new Error("reconstructPeginParams: candidate space is empty");const l=d.processPublicKeyToXOnly(n),u=d.stripHexPrefix(r),h=D.findAuthAnchorOpReturn(u);if(h===void 0)throw new B("Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused.");if(h.vout!==t.length)throw new Error(`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${h.vout}, so the transaction funds ${h.vout} HTLC output(s). Reconstruction refused.`);const x=O.Transaction.fromHex(u).outs,w=t.map((g,P)=>BigInt(x[P].value)),C=d.stripHexPrefix(N.calculateBtcTxHash(u)).toLowerCase(),m=new Map,p=[],F=[],S=[];let U=0;for(const g of a)try{const P=Ke(g);let v=m.get(P);v===void 0&&(v=await Ne(g),m.set(P,v));const R=v.depositorClaimValue+v.peginMaxFee+v.p2aAnchorValue,k=w.map(T=>T-R),V=k.findIndex(T=>T<=0n);if(V!==-1)throw new K.HtlcOutputMismatchError(`HTLC output[${V}] value ${w[V]} is not above this candidate's reserve ${R}, so it implies a non-positive pegin amount ${k[V]}.`);const{offchainParams:E,participants:H}=g,G=await z({vaultCoreVersion:g.vaultCoreVersion,siblings:t.map((T,ge)=>({hashlock:T,amount:k[ge]})),fundedPrePeginTxHex:u,depositorBtcPubkey:l,vaultProviderBtcPubkey:H.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:H.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:H.universalChallengerBtcPubkeys,protocolFeeRate:E.protocolFeeRate,minPeginFeeRate:E.minPeginFeeRate,councilQuorum:E.councilQuorum,councilSize:E.councilSize,timelockPegin:E.timelockPegin,timelockAssert:E.timelockAssert,timelockRefund:E.timelockRefund,prepeginTxid:C,prepeginMaxFee:o,maxAcceptableCommissionBps:c,network:s});p.push({candidate:g,terms:G,peginAmounts:k,fingerprint:Me(G,k)})}catch(P){if(P instanceof A)throw P;const v=$(g),R=P instanceof Error?P.message:String(P);P instanceof K.HtlcOutputMismatchError?F.length<Z&&F.push(`[${v}] ${R}`):(U++,S.length<Z&&S.push(`${v} (${R})`))}const me=i.length+U,q=[...i.map(pe),...S];if(p.length===0)throw new le(a.length,F,q);if(new Set(p.map(g=>g.fingerprint)).size>1)throw new he(p.map(g=>$(g.candidate)));if(me>0)throw new de($(p[0].candidate),q);return{candidate:p[0].candidate,terms:p[0].terms,peginAmounts:p[0].peginAmounts,authAnchorHash:h.hash,candidatesTried:a.length,matchedCandidates:p.map(g=>g.candidate)}}function De(e,t){const{htlcVout:r,depositorBtcPubkey:n,applicationEntryPoint:o,fundedPrePeginTxHex:c,hashlocks:s,network:a}=t,{candidate:i,peginAmounts:l}=e,{offchainParams:u,participants:h}=i;if(s.length!==l.length)throw new Error(`toRefundInputs: ${s.length} hashlock(s) but ${l.length} reconstructed amount(s); the reconstruction and the hashlock vector describe different transactions.`);if(!Number.isInteger(r)||r<0||r>=l.length)throw new Error(`toRefundInputs: htlcVout ${r} is outside the reconstructed batch of ${l.length} vault(s).`);const x=l.map((m,p)=>({hashlock:d.ensureHexPrefix(s[p]),amount:m,htlcVout:p})),w={vaultCoreVersion:i.vaultCoreVersion,hashlock:x[r].hashlock,htlcVout:r,offchainParamsVersion:u.version,appVaultKeepersVersion:h.appVaultKeepersVersion,universalChallengersVersion:h.universalChallengersVersion,vaultProvider:h.vaultProvider,applicationEntryPoint:o,amount:l[r],unsignedPrePeginTxHex:c,depositorBtcPubkey:n,batch:x},C={vaultProviderPubkey:h.vaultProviderBtcPubkey,vaultKeeperPubkeys:h.vaultKeeperBtcPubkeys,universalChallengerPubkeys:h.universalChallengerBtcPubkeys,timelockRefund:u.timelockRefund,feeRate:u.protocolFeeRate,minPeginFeeRate:u.minPeginFeeRate,numLocalChallengers:h.vaultKeeperBtcPubkeys.length,councilQuorum:u.councilQuorum,councilSize:u.councilSize,network:a};return{vault:w,context:C}}exports.DEPOSIT_TERMS_REJECTED_ERROR_NAME=L;exports.DepositTermsRejectedError=oe;exports.PEGIN_FINGERPRINT_DOMAIN=ae;exports.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE=ie;exports.PeginFingerprintInputError=f;exports.PeginParamsAmbiguousError=he;exports.PeginParamsIncompleteSpaceError=de;exports.PeginParamsNotFoundError=le;exports.PeginSizingIntegrityError=A;exports.UnanchoredPrePeginError=B;exports.VaultRootMismatchError=ue;exports.assertClaimBatchHomogeneous=re;exports.buildPeginParamsCandidates=_e;exports.computeFundedPrePeginFee=se;exports.computePeginFingerprint=Se;exports.deriveHashlocksFromPrePegin=He;exports.describePeginParamsCandidate=$;exports.describeUnresolvedVersion=pe;exports.encodePeginFingerprintPreimage=ce;exports.isDepositTermsRejectedError=Re;exports.isPeginFingerprintInputError=Ie;exports.isWotsMismatchError=Te;exports.orderClaimBatchByHtlcVout=ne;exports.rebuildDepositTermsCore=z;exports.rebuildDepositTermsForClaim=ke;exports.reconstructPeginParams=Oe;exports.selectSiblingRegistrations=te;exports.toRefundInputs=De;
|
|
2
|
-
//# sourceMappingURL=toRefundInputs-
|
|
1
|
+
"use strict";var Pe=Object.defineProperty;var fe=(e,t,r)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var j=(e,t,r)=>fe(e,typeof t!="symbol"?t+"":t,r);const M=require("./registration-records-CKc0OVuK.cjs"),d=require("./bitcoin-D-O2GjbC.cjs"),N=require("./btcTxHash-CGb5BqFL.cjs"),O=require("bitcoinjs-lib"),ve=require("buffer"),be=require("./tbv/core/clients/mempool/index.cjs"),X=require("./validation-C6XTfZak.cjs"),y=require("viem"),Ee=require("./sha2-Ce6KewYx.cjs"),D=require("./PayoutManager-B5nR0x1t.cjs"),ee=require("./PeginManager-6ghglb4r.cjs"),b=require("./tbv/core/wasm/index.cjs"),xe=require("./deriveVaultRoot-C3uqnJto.cjs"),we=require("./parseFundingOutpoints-C_-PT9BT.cjs"),K=require("./verifyScriptPathSchnorrSignature-BHskbJJx.cjs"),Q=require("./fundPeginTransaction-54-Rwb2k.cjs"),ye=["vaultCoreVersion","offchainParamsVersion","appVaultKeepersVersion","universalChallengersVersion"],Ce=["applicationEntryPoint","vaultProvider"];function te(e,t){const r=t.depositor.toLowerCase(),n=M.registrationPrePeginTxHash(t).toLowerCase();return e.filter(o=>o.vaultId!==t.vaultId&&o.depositor.toLowerCase()===r&&M.registrationPrePeginTxHash(o).toLowerCase()===n)}function re(e,t){for(const r of t){for(const n of ye)if(r.vault.protocol[n]!==e.vault.protocol[n])throw new Error(`Sibling vaults of this Pre-PegIn disagree on ${n} (${r.vault.protocol[n]} vs ${e.vault.protocol[n]}); the batch cannot be described by one set of deposit terms.`);if(r.maxAcceptableCommissionBps!==e.maxAcceptableCommissionBps)throw new Error(`Sibling vaults of this Pre-PegIn disagree on maxAcceptableCommissionBps (${r.maxAcceptableCommissionBps} vs ${e.maxAcceptableCommissionBps}); the batch cannot be described by one set of deposit terms.`);for(const n of Ce)if(r.vault.basic[n].toLowerCase()!==e.vault.basic[n].toLowerCase())throw new Error(`Sibling vaults of this Pre-PegIn disagree on ${n} (${r.vault.basic[n]} vs ${e.vault.basic[n]}); the batch cannot be described by one set of deposit terms.`)}}function ne(e){const t=[...e].sort((r,n)=>r.vault.protocol.htlcVout-n.vault.protocol.htlcVout);return t.forEach((r,n)=>{if(r.vault.protocol.htlcVout!==n)throw new Error(`Sibling discovery produced a non-contiguous HTLC vector (${t.map(o=>o.vault.protocol.htlcVout).join(", ")}).`)}),t.map(r=>({hashlock:r.vault.protocol.hashlock,amount:r.vault.basic.amount}))}const L="DepositTermsRejectedError";class oe extends Error{constructor(r,n="device-envelope"){super(r);j(this,"reason");this.name=L,this.reason=n}}function Re(e){if(e instanceof oe)return!0;if(typeof e!="object"||e===null)return!1;const t=e;return t.name===L&&t.reason==="device-envelope"}async function se(e,t){const r=O.Transaction.fromHex(d.stripHexPrefix(e)),o=(await Promise.all(r.ins.map(a=>be.getUtxoInfo(ve.Buffer.from(a.hash).reverse().toString("hex"),a.index,t)))).reduce((a,i)=>a+BigInt(i.value),0n),c=r.outs.reduce((a,i)=>a+BigInt(i.value),0n),s=o-c;if(s<=0n)throw new Error(`The funded Pre-PegIn transaction's inputs do not cover its outputs plus a fee (computed fee: ${s} sats).`);if(s>X.MAX_REASONABLE_FEE_SATS)throw new Error(`The funded Pre-PegIn transaction's computed fee (${s} sats) exceeds the maximum reasonable fee (${X.MAX_REASONABLE_FEE_SATS} sats); the mempool API may have returned manipulated prevout data.`);return s}async function z(e){const t=e.siblings.length;if(t===0)throw new Error("rebuildDepositTermsCore: at least one sibling is required");for(const[m,p]of e.siblings.entries())if(p.amount<=0n)throw new Error(`rebuildDepositTermsCore: sibling[${m}] has non-positive on-chain pegin amount ${p.amount}; the chain-read vault record is invalid. Resume refused.`);if(e.prepeginMaxFee<=0n)throw new Error(`rebuildDepositTermsCore: prepeginMaxFee must be > 0, got ${e.prepeginMaxFee}`);const r=d.stripHexPrefix(e.prepeginTxid).toLowerCase(),n=d.stripHexPrefix(N.calculateBtcTxHash(e.fundedPrePeginTxHex)).toLowerCase();if(n!==r)throw new Error(`Funded Pre-PegIn tx hashes to ${n}, expected ${r} (on-chain prepeginTxid). Resume refused.`);const o=D.findAuthAnchorOpReturn(d.stripHexPrefix(e.fundedPrePeginTxHex));if(o===void 0)throw new Error("Funded Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN commitment — it either predates auth anchoring or is malformed. The intent resume path requires the anchor to prove sibling completeness. Resume refused.");if(o.vout!==t)throw new Error(`Auth-anchor OP_RETURN at vout ${o.vout} does not match the discovered sibling count ${t}; the discovered sibling set does not cover this transaction's HTLC outputs (a lagging index can cause this — retry later). Resume refused.`);const c=e.vaultKeeperBtcPubkeys.length,s=e.universalChallengerBtcPubkeys.length,a=await b.computeMinClaimValue(e.vaultCoreVersion,c,s,e.councilQuorum,e.councilSize,e.protocolFeeRate),i=await b.computeMinPeginFee(e.vaultCoreVersion,c,s,e.minPeginFeeRate),{value:l}=await b.peginP2aAnchorOutput(e.vaultCoreVersion);if(a<=0n)throw new Error(`WASM returned non-positive depositorClaimValue ${a}; expected > 0. Resume refused.`);if(i<=0n)throw new Error(`WASM returned non-positive peginMaxFee ${i}; expected > 0. Resume refused.`);if(l<0n)throw new Error(`WASM returned negative P2A anchor value ${l}. Resume refused.`);const u=i+l,h=e.minPeginFeeRate*Q.MAX_REASONABLE_PEGIN_VBYTES;if(u<=0n||u>h)throw new Error(`WASM implied PegIn reserve ${u} sat is outside (0, ${h}] (minPeginFeeRate=${e.minPeginFeeRate} × ${Q.MAX_REASONABLE_PEGIN_VBYTES} vbytes). Resume refused.`);const x=e.siblings.map(m=>m.amount+a+i+l),w=await Promise.all(e.siblings.map(async m=>(await b.getPrePeginHtlcConnectorInfo({txGraphVersion:e.vaultCoreVersion,depositorPubkey:e.depositorBtcPubkey,vaultProviderPubkey:e.vaultProviderBtcPubkey,vaultKeeperPubkeys:[...e.vaultKeeperBtcPubkeys],universalChallengerPubkeys:[...e.universalChallengerBtcPubkeys],hashlock:d.stripHexPrefix(m.hashlock),timelockRefund:e.timelockRefund,network:e.network})).scriptPubKey)),C=O.Transaction.fromHex(d.stripHexPrefix(e.fundedPrePeginTxHex)).outs.map(m=>({value:m.value,script:m.script}));return K.assertEncodedHtlcOutputsMatch(C,x,w),ee.buildDepositTerms({vaultCoreVersion:e.vaultCoreVersion,protocolFeeRate:e.protocolFeeRate,timelockPegin:e.timelockPegin,timelockAssert:e.timelockAssert,timelockRefund:e.timelockRefund,prepeginTxid:e.prepeginTxid,prepeginMaxFee:e.prepeginMaxFee,vaultProviderBtcPubkey:e.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:e.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:e.universalChallengerBtcPubkeys,maxAcceptableCommissionBps:e.maxAcceptableCommissionBps,peginAmounts:e.siblings.map(m=>m.amount),depositorClaimValue:a,peginMaxFee:i})}async function ke(e){const{read:t}=e,r=d.canonicalizeBtcPubkey(e.depositorBtcPubkey);if(r!==t.context.depositorBtcPubkey)throw new Error("Connected wallet key is not the vault's depositor key; select the account that made the deposit.");const n=d.stripHexPrefix(t.prePeginTxHash).toLowerCase(),o=d.stripHexPrefix(N.calculateBtcTxHash(e.fundedPrePeginTxHex)).toLowerCase();if(o!==n)throw new Error(`Funded Pre-PegIn tx hashes to ${o}, expected ${n} (on-chain prePeginTxHash).`);const c=await Promise.all(te(t.registrationRecords,t.registrationRecord).map(async l=>{const u=await e.siblingReader.getVaultData(l.vaultId);if(u.protocol.prePeginTxHash.toLowerCase()!==M.registrationPrePeginTxHash(l).toLowerCase())throw new Error(`Sibling ${l.vaultId} is registered against a different Pre-PegIn on chain than its registration log records; refusing an inconsistent node.`);return{vault:u,maxAcceptableCommissionBps:l.maxAcceptableCommissionBps}})),s={vault:t.vault,maxAcceptableCommissionBps:t.registrationRecord.maxAcceptableCommissionBps};re(s,c);const a=ne([s,...c]),i=await se(e.fundedPrePeginTxHex,e.mempoolApiUrl);return z({vaultCoreVersion:t.vault.protocol.vaultCoreVersion,siblings:a,fundedPrePeginTxHex:e.fundedPrePeginTxHex,depositorBtcPubkey:r,vaultProviderBtcPubkey:t.participantKeys.vaultProvider.operationBtcPubkey,vaultKeeperBtcPubkeys:t.participantKeys.vaultKeeperOperationKeysSorted,universalChallengerBtcPubkeys:t.participantKeys.universalChallengerOperationKeysSorted,protocolFeeRate:t.offchainParams.feeRate,minPeginFeeRate:t.offchainParams.minPeginFeeRate,councilQuorum:t.offchainParams.councilQuorum,councilSize:t.offchainParams.securityCouncilKeys.length,timelockPegin:t.context.timelockPegin,timelockAssert:t.context.timelockAssert,timelockRefund:t.offchainParams.tRefund,prepeginTxid:n,prepeginMaxFee:i,maxAcceptableCommissionBps:t.registrationRecord.maxAcceptableCommissionBps,network:e.network})}function Te(e){const t=(e instanceof Error?e.message:typeof e=="string"?e:"").toLowerCase();return t.includes("wots")&&t.includes("hash")&&t.includes("does not match")}const ie="TBV.PeginFingerprint.v1",ae=y.keccak256(y.toHex(ie)),W=65535,J=2n**64n-1n,Ae=2n**256n-1n,Ve=/^0x[0-9a-fA-F]{64}$/,Y=1;class f extends Error{constructor(t){super(t),this.name="PeginFingerprintInputError"}}function Ie(e){return e instanceof f||e instanceof Error&&e.name==="PeginFingerprintInputError"}function _(e,t,r,n){if(typeof t!="bigint")throw new f(`${e} must be a bigint (Solidity ${n}), got ${typeof t}`);if(t<0n||t>r)throw new f(`${e} must fit Solidity ${n} (0..${r}), got ${t}`)}function I(e,t){if(!Number.isInteger(t)||t<0||t>W)throw new f(`${e} must be an integer fitting Solidity uint16 (0..${W}), got ${t}`)}function $e(e,t){if(!Ve.test(t))throw new f(`${e} must be 32 bytes as 0x-prefixed hex (66 characters), got "${t}"`);return t.toLowerCase()}function Be(e){if(!y.isAddress(e,{strict:!1}))throw new f(`registryAddress must be a 20-byte 0x-prefixed address, got "${e}"`);const t=e.toLowerCase();if(t===y.zeroAddress)throw new f("registryAddress must not be the zero address; a zero here means the registry address was never resolved");return t}const Fe=[{name:"domain",type:"bytes32"},{name:"chainId",type:"uint256"},{name:"registry",type:"address"},{name:"vaultProviderBtcKey",type:"bytes32"},{name:"appKeeperKeyEpoch",type:"uint64"},{name:"ucKeyEpoch",type:"uint64"},{name:"appVaultKeepersVersion",type:"uint16"},{name:"universalChallengersVersion",type:"uint16"},{name:"offchainParamsVersion",type:"uint16"},{name:"vaultCoreVersion",type:"uint16"}];function ce(e){if(_("chainId",e.chainId,Ae,"uint256"),e.chainId===0n)throw new f("chainId must not be 0; a zero here means the chain id was never resolved");const t=Be(e.registryAddress),r=$e("vaultProviderBtcKey",e.vaultProviderBtcKey);if(_("appKeeperKeyEpoch",e.appKeeperKeyEpoch,J,"uint64"),_("ucKeyEpoch",e.ucKeyEpoch,J,"uint64"),I("appVaultKeepersVersion",e.appVaultKeepersVersion),I("universalChallengersVersion",e.universalChallengersVersion),I("offchainParamsVersion",e.offchainParamsVersion),I("vaultCoreVersion",e.vaultCoreVersion),e.vaultCoreVersion<Y)throw new f(`vaultCoreVersion must be at least ${Y}; ${e.vaultCoreVersion} means the version was never resolved`);return y.encodeAbiParameters(Fe,[ae,e.chainId,t,r,e.appKeeperKeyEpoch,e.ucKeyEpoch,e.appVaultKeepersVersion,e.universalChallengersVersion,e.offchainParamsVersion,e.vaultCoreVersion])}function Se(e){return y.keccak256(ce(e))}class ue extends Error{constructor(t,r){super(`Re-derived vault root does not match this Pre-PegIn: derived auth-anchor hash ${t}, transaction commits to ${r}. Connect the same wallet, on the same account and the same network, that created the deposit.`),this.derivedAuthAnchorHash=t,this.onChainAuthAnchorHash=r,this.name="VaultRootMismatchError"}}class B extends Error{constructor(t){super(t),this.name="UnanchoredPrePeginError"}}class le extends Error{constructor(t,r,n=[]){super(`No candidate parameter set reproduces this Pre-PegIn's HTLC outputs (${t} candidate(s) tried). `+(n.length>0?`${n.length} version(s) could not be resolved and may hold the answer: ${n.join(" | ")}. `:"")+`Sample rejections: ${r.join(" | ")}`),this.candidatesTried=t,this.sampleRejections=r,this.unresolvedLabels=n,this.name="PeginParamsNotFoundError"}}class he extends Error{constructor(t){super(`${t.length} candidate parameter sets reproduce this Pre-PegIn's HTLC outputs, so the vault's stamped versions cannot be determined: ${t.join(" | ")}. Reconstruction refused.`),this.survivorLabels=t,this.name="PeginParamsAmbiguousError"}}class de extends Error{constructor(t,r){super(`A candidate matched this Pre-PegIn (${t}), but ${r.length} version(s) could not be resolved, so the search space did not provably contain the true parameters: ${r.join(" | ")}. A version sharing the matched timelockRefund and participants is indistinguishable from the true one, so the match cannot be trusted. Reconstruction refused.`),this.matchedLabel=t,this.unresolvedLabels=r,this.name="PeginParamsIncompleteSpaceError"}}class A extends Error{constructor(t){super(`${t}. Reconstruction refused.`),this.name="PeginSizingIntegrityError"}}async function He(e){const{wallet:t,depositorBtcPubkey:r,fundedPrePeginTxHex:n}=e,o=d.stripHexPrefix(n),c=D.findAuthAnchorOpReturn(o);if(c===void 0)throw new B("Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN, so the number of HTLC outputs it funds cannot be determined. Legacy pre-anchor deposits are not recoverable by this path.");const s=c.vout;if(s===0)throw new B("Pre-PegIn's auth-anchor OP_RETURN is at vout 0, implying zero HTLC outputs; there is nothing to recover.");const a=we.parseFundingOutpointsFromTx(o),i=await xe.deriveVaultRoot(t,{depositorBtcPubkey:d.hexToUint8Array(d.processPublicKeyToXOnly(r)),fundingOutpoints:a});try{const u=await b.expandAuthAnchor(i);let h;try{h=d.uint8ArrayToHex(Ee.sha256(u))}finally{u.fill(0)}if(h!==c.hash)throw new ue(h,c.hash)}catch(u){throw i.fill(0),u}const{hashlocks:l}=await ee.expandPerVaultSecrets(i,s);return{vaultCount:s,hashlocks:l,authAnchorHash:c.hash}}function _e(e){const{vaultCoreVersion:t,offchainParams:r,participantKeySets:n}=e;if(!Number.isInteger(t)||t<1)throw new Error(`buildPeginParamsCandidates: vaultCoreVersion must be a positive integer, got ${t}`);if(r.length===0)throw new Error("buildPeginParamsCandidates: at least one offchain-params version is required");if(n.length===0)throw new Error("buildPeginParamsCandidates: at least one participant key set is required");const o=[];for(const c of r)for(const s of n)o.push({vaultCoreVersion:t,offchainParams:c,participants:s});return o}function pe(e){return`${e.axis} v${e.version} (${e.reason})`}function $(e){const{participants:t}=e;return`core=${e.vaultCoreVersion} offchain=${e.offchainParams.version} keepers=${t.appVaultKeepersVersion} challengers=${t.universalChallengersVersion} vp=${t.vaultProvider}`}const Z=5;function Me(e,t){return JSON.stringify({terms:e,peginAmounts:t},(r,n)=>typeof n=="bigint"?`${n}`:n)}function Ke(e){const{offchainParams:t,participants:r}=e;return[e.vaultCoreVersion,r.vaultKeeperBtcPubkeys.length,r.universalChallengerBtcPubkeys.length,t.councilQuorum,t.councilSize,t.protocolFeeRate,t.minPeginFeeRate].join("|")}async function Ne(e){const{offchainParams:t,participants:r}=e,n=r.vaultKeeperBtcPubkeys.length,o=r.universalChallengerBtcPubkeys.length,[c,s,a]=await Promise.all([b.computeMinClaimValue(e.vaultCoreVersion,n,o,t.councilQuorum,t.councilSize,t.protocolFeeRate),b.computeMinPeginFee(e.vaultCoreVersion,n,o,t.minPeginFeeRate),b.peginP2aAnchorOutput(e.vaultCoreVersion)]),i=a.value;if(c<=0n)throw new A(`WASM returned non-positive depositorClaimValue ${c} for graph version ${e.vaultCoreVersion}`);if(s<=0n)throw new A(`WASM returned non-positive peginMaxFee ${s} for graph version ${e.vaultCoreVersion}`);if(i<0n)throw new A(`WASM returned negative P2A anchor value ${i} for graph version ${e.vaultCoreVersion}`);return{depositorClaimValue:c,peginMaxFee:s,p2aAnchorValue:i}}async function Oe(e){const{hashlocks:t,fundedPrePeginTxHex:r,depositorBtcPubkey:n,prepeginMaxFee:o,maxAcceptableCommissionBps:c,network:s,candidates:a,unresolvedVersions:i}=e;if(t.length===0)throw new Error("reconstructPeginParams: at least one hashlock is required");if(a.length===0)throw new Error("reconstructPeginParams: candidate space is empty");const l=d.processPublicKeyToXOnly(n),u=d.stripHexPrefix(r),h=D.findAuthAnchorOpReturn(u);if(h===void 0)throw new B("Pre-PegIn carries no single, unambiguous auth-anchor OP_RETURN; the sibling set cannot be proven complete. Reconstruction refused.");if(h.vout!==t.length)throw new Error(`reconstructPeginParams: ${t.length} hashlock(s) supplied but the auth-anchor OP_RETURN sits at vout ${h.vout}, so the transaction funds ${h.vout} HTLC output(s). Reconstruction refused.`);const x=O.Transaction.fromHex(u).outs,w=t.map((g,P)=>BigInt(x[P].value)),C=d.stripHexPrefix(N.calculateBtcTxHash(u)).toLowerCase(),m=new Map,p=[],F=[],S=[];let U=0;for(const g of a)try{const P=Ke(g);let v=m.get(P);v===void 0&&(v=await Ne(g),m.set(P,v));const R=v.depositorClaimValue+v.peginMaxFee+v.p2aAnchorValue,k=w.map(T=>T-R),V=k.findIndex(T=>T<=0n);if(V!==-1)throw new K.HtlcOutputMismatchError(`HTLC output[${V}] value ${w[V]} is not above this candidate's reserve ${R}, so it implies a non-positive pegin amount ${k[V]}.`);const{offchainParams:E,participants:H}=g,G=await z({vaultCoreVersion:g.vaultCoreVersion,siblings:t.map((T,ge)=>({hashlock:T,amount:k[ge]})),fundedPrePeginTxHex:u,depositorBtcPubkey:l,vaultProviderBtcPubkey:H.vaultProviderBtcPubkey,vaultKeeperBtcPubkeys:H.vaultKeeperBtcPubkeys,universalChallengerBtcPubkeys:H.universalChallengerBtcPubkeys,protocolFeeRate:E.protocolFeeRate,minPeginFeeRate:E.minPeginFeeRate,councilQuorum:E.councilQuorum,councilSize:E.councilSize,timelockPegin:E.timelockPegin,timelockAssert:E.timelockAssert,timelockRefund:E.timelockRefund,prepeginTxid:C,prepeginMaxFee:o,maxAcceptableCommissionBps:c,network:s});p.push({candidate:g,terms:G,peginAmounts:k,fingerprint:Me(G,k)})}catch(P){if(P instanceof A)throw P;const v=$(g),R=P instanceof Error?P.message:String(P);P instanceof K.HtlcOutputMismatchError?F.length<Z&&F.push(`[${v}] ${R}`):(U++,S.length<Z&&S.push(`${v} (${R})`))}const me=i.length+U,q=[...i.map(pe),...S];if(p.length===0)throw new le(a.length,F,q);if(new Set(p.map(g=>g.fingerprint)).size>1)throw new he(p.map(g=>$(g.candidate)));if(me>0)throw new de($(p[0].candidate),q);return{candidate:p[0].candidate,terms:p[0].terms,peginAmounts:p[0].peginAmounts,authAnchorHash:h.hash,candidatesTried:a.length,matchedCandidates:p.map(g=>g.candidate)}}function De(e,t){const{htlcVout:r,depositorBtcPubkey:n,applicationEntryPoint:o,fundedPrePeginTxHex:c,hashlocks:s,network:a}=t,{candidate:i,peginAmounts:l}=e,{offchainParams:u,participants:h}=i;if(s.length!==l.length)throw new Error(`toRefundInputs: ${s.length} hashlock(s) but ${l.length} reconstructed amount(s); the reconstruction and the hashlock vector describe different transactions.`);if(!Number.isInteger(r)||r<0||r>=l.length)throw new Error(`toRefundInputs: htlcVout ${r} is outside the reconstructed batch of ${l.length} vault(s).`);const x=l.map((m,p)=>({hashlock:d.ensureHexPrefix(s[p]),amount:m,htlcVout:p})),w={vaultCoreVersion:i.vaultCoreVersion,hashlock:x[r].hashlock,htlcVout:r,offchainParamsVersion:u.version,appVaultKeepersVersion:h.appVaultKeepersVersion,universalChallengersVersion:h.universalChallengersVersion,vaultProvider:h.vaultProvider,applicationEntryPoint:o,amount:l[r],unsignedPrePeginTxHex:c,depositorBtcPubkey:n,batch:x},C={vaultProviderPubkey:h.vaultProviderBtcPubkey,vaultKeeperPubkeys:h.vaultKeeperBtcPubkeys,universalChallengerPubkeys:h.universalChallengerBtcPubkeys,timelockRefund:u.timelockRefund,feeRate:u.protocolFeeRate,minPeginFeeRate:u.minPeginFeeRate,numLocalChallengers:h.vaultKeeperBtcPubkeys.length,councilQuorum:u.councilQuorum,councilSize:u.councilSize,network:a};return{vault:w,context:C}}exports.DEPOSIT_TERMS_REJECTED_ERROR_NAME=L;exports.DepositTermsRejectedError=oe;exports.PEGIN_FINGERPRINT_DOMAIN=ae;exports.PEGIN_FINGERPRINT_DOMAIN_PREIMAGE=ie;exports.PeginFingerprintInputError=f;exports.PeginParamsAmbiguousError=he;exports.PeginParamsIncompleteSpaceError=de;exports.PeginParamsNotFoundError=le;exports.PeginSizingIntegrityError=A;exports.UnanchoredPrePeginError=B;exports.VaultRootMismatchError=ue;exports.assertClaimBatchHomogeneous=re;exports.buildPeginParamsCandidates=_e;exports.computeFundedPrePeginFee=se;exports.computePeginFingerprint=Se;exports.deriveHashlocksFromPrePegin=He;exports.describePeginParamsCandidate=$;exports.describeUnresolvedVersion=pe;exports.encodePeginFingerprintPreimage=ce;exports.isDepositTermsRejectedError=Re;exports.isPeginFingerprintInputError=Ie;exports.isWotsMismatchError=Te;exports.orderClaimBatchByHtlcVout=ne;exports.rebuildDepositTermsCore=z;exports.rebuildDepositTermsForClaim=ke;exports.reconstructPeginParams=Oe;exports.selectSiblingRegistrations=te;exports.toRefundInputs=De;
|
|
2
|
+
//# sourceMappingURL=toRefundInputs-BzyN0zvj.cjs.map
|