@babylonlabs-io/ts-sdk 2.0.1 → 3.0.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-CpfQjtL0.cjs → PayoutManager-B6GFbG3X.cjs} +2 -2
- package/dist/{PayoutManager-CpfQjtL0.cjs.map → PayoutManager-B6GFbG3X.cjs.map} +1 -1
- package/dist/{PayoutManager-CHTOwj0E.js → PayoutManager-BSwbUQeF.js} +2 -2
- package/dist/{PayoutManager-CHTOwj0E.js.map → PayoutManager-BSwbUQeF.js.map} +1 -1
- package/dist/{PeginManager-DEldv_Ro.js → PeginManager-CKf7Bjmj.js} +6 -6
- package/dist/PeginManager-CKf7Bjmj.js.map +1 -0
- package/dist/{PeginManager-6tjlGd0t.cjs → PeginManager-Dt2Z5ljw.cjs} +2 -2
- package/dist/PeginManager-Dt2Z5ljw.cjs.map +1 -0
- package/dist/{bip322Verify-DSco3Yhl.js → bip322Verify-BXYrHBh8.js} +2 -2
- package/dist/{bip322Verify-DSco3Yhl.js.map → bip322Verify-BXYrHBh8.js.map} +1 -1
- package/dist/{bip322Verify-B7_gIhRk.cjs → bip322Verify-DLxJR9CQ.cjs} +2 -2
- package/dist/{bip322Verify-B7_gIhRk.cjs.map → bip322Verify-DLxJR9CQ.cjs.map} +1 -1
- package/dist/buildAndBroadcastReclaim-BDc-SK9i.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-BDc-SK9i.cjs.map +1 -0
- package/dist/{buildAndBroadcastReclaim-CqO2DoP8.js → buildAndBroadcastReclaim-T5ZFPUpM.js} +943 -732
- package/dist/buildAndBroadcastReclaim-T5ZFPUpM.js.map +1 -0
- package/dist/{deriveVaultRoot-BwbXmN0x.js → deriveVaultRoot-BcvmER1E.js} +2 -2
- package/dist/{deriveVaultRoot-BwbXmN0x.js.map → deriveVaultRoot-BcvmER1E.js.map} +1 -1
- package/dist/{deriveVaultRoot-DvhkHzNb.cjs → deriveVaultRoot-C3uqnJto.cjs} +2 -2
- package/dist/{deriveVaultRoot-DvhkHzNb.cjs.map → deriveVaultRoot-C3uqnJto.cjs.map} +1 -1
- package/dist/{index-DQ5bfoT3.js → index-B6w5MM-8.js} +147 -124
- package/dist/index-B6w5MM-8.js.map +1 -0
- package/dist/index-EHLYplSd.cjs +2 -0
- package/dist/index-EHLYplSd.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +163 -158
- package/dist/{onChainBtcPubkey-BXry_CM4.cjs → onChainBtcPubkey-BlzxYImF.cjs} +2 -2
- package/dist/{onChainBtcPubkey-BXry_CM4.cjs.map → onChainBtcPubkey-BlzxYImF.cjs.map} +1 -1
- package/dist/{onChainBtcPubkey-C1WqyxPM.js → onChainBtcPubkey-CCTdl53s.js} +2 -2
- package/dist/{onChainBtcPubkey-C1WqyxPM.js.map → onChainBtcPubkey-CCTdl53s.js.map} +1 -1
- package/dist/{pegin-registration-client-BNV44jzw.cjs → pegin-registration-client-BdJ6c7si.cjs} +2 -2
- package/dist/{pegin-registration-client-BNV44jzw.cjs.map → pegin-registration-client-BdJ6c7si.cjs.map} +1 -1
- package/dist/{pegin-registration-client-1sZ-74UC.js → pegin-registration-client-C5Hktrja.js} +3 -3
- package/dist/{pegin-registration-client-1sZ-74UC.js.map → pegin-registration-client-C5Hktrja.js.map} +1 -1
- package/dist/peginState-BU2ONFXF.js +68 -0
- package/dist/{peginState-CxDiaKuk.js.map → peginState-BU2ONFXF.js.map} +1 -1
- package/dist/peginState-DUv10EJR.cjs +2 -0
- package/dist/{peginState-eaQ4IO_R.cjs.map → peginState-DUv10EJR.cjs.map} +1 -1
- package/dist/{primeVpAuth-DdfHSC53.js → primeVpAuth-Bdy_B_Sq.js} +5 -5
- package/dist/{primeVpAuth-DdfHSC53.js.map → primeVpAuth-Bdy_B_Sq.js.map} +1 -1
- package/dist/primeVpAuth-CQRsu6VB.cjs +2 -0
- package/dist/{primeVpAuth-BOGKniTl.cjs.map → primeVpAuth-CQRsu6VB.cjs.map} +1 -1
- package/dist/{reservation-Cj9F0rP9.js → reservation-DOAHVT3B.js} +2 -2
- package/dist/{reservation-Cj9F0rP9.js.map → reservation-DOAHVT3B.js.map} +1 -1
- package/dist/{reservation-Dr2HLCxx.cjs → reservation-ECxjZi5t.cjs} +2 -2
- package/dist/{reservation-Dr2HLCxx.cjs.map → reservation-ECxjZi5t.cjs.map} +1 -1
- package/dist/sha2-Ce6KewYx.cjs +2 -0
- package/dist/{sha2-DI0-0SHr.cjs.map → sha2-Ce6KewYx.cjs.map} +1 -1
- package/dist/{sha2-CLpQd0Rd.js → sha2-YqVHJiFj.js} +91 -77
- package/dist/{sha2-CLpQd0Rd.js.map → sha2-YqVHJiFj.js.map} +1 -1
- package/dist/state-DMFlvLL3.cjs +2 -0
- package/dist/state-DMFlvLL3.cjs.map +1 -0
- package/dist/{json-rpc-client-DuUARJvV.js → state-mE-QfITd.js} +91 -69
- package/dist/state-mE-QfITd.js.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +1 -1
- package/dist/tbv/core/clients/eth/index.js +3 -3
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +27 -26
- package/dist/tbv/core/clients/vault-provider/api.d.ts +2 -1
- package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/index.d.ts +1 -1
- package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.d.ts +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/status/index.js +10 -9
- package/dist/tbv/core/clients/vault-provider/types.d.ts +7 -3
- package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/validators.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +163 -158
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/services/deposit/__tests__/graphFingerprint.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/graphFingerprint.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/graphFingerprint.d.ts +115 -0
- package/dist/tbv/core/services/deposit/graphFingerprint.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +2 -1
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts +23 -0
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +11 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +52 -47
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/services/pegout/state.d.ts +8 -3
- package/dist/tbv/core/services/pegout/state.d.ts.map +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +163 -158
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{toRefundInputs-BaN9XluU.cjs → toRefundInputs-B_GlIXjk.cjs} +2 -2
- package/dist/{toRefundInputs-BaN9XluU.cjs.map → toRefundInputs-B_GlIXjk.cjs.map} +1 -1
- package/dist/{toRefundInputs-mtuuYezp.js → toRefundInputs-DIIdhjvu.js} +5 -5
- package/dist/{toRefundInputs-mtuuYezp.js.map → toRefundInputs-DIIdhjvu.js.map} +1 -1
- package/dist/{types-BuxreSq4.cjs → types-DJxOEU3P.cjs} +2 -2
- package/dist/{types-BuxreSq4.cjs.map → types-DJxOEU3P.cjs.map} +1 -1
- package/dist/{types-BdCEoANP.js → types-Dz1kVqn6.js} +2 -2
- package/dist/{types-BdCEoANP.js.map → types-Dz1kVqn6.js.map} +1 -1
- package/package.json +1 -1
- package/dist/PeginManager-6tjlGd0t.cjs.map +0 -1
- package/dist/PeginManager-DEldv_Ro.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-CqO2DoP8.js.map +0 -1
- package/dist/index-CK1Xvq4K.cjs +0 -2
- package/dist/index-CK1Xvq4K.cjs.map +0 -1
- package/dist/index-DQ5bfoT3.js.map +0 -1
- package/dist/json-rpc-client-BiAmg_ho.cjs +0 -2
- package/dist/json-rpc-client-BiAmg_ho.cjs.map +0 -1
- package/dist/json-rpc-client-DuUARJvV.js.map +0 -1
- package/dist/peginState-CxDiaKuk.js +0 -63
- package/dist/peginState-eaQ4IO_R.cjs +0 -2
- package/dist/primeVpAuth-BOGKniTl.cjs +0 -2
- package/dist/sha2-DI0-0SHr.cjs +0 -2
package/dist/index.js
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import { P as s, h as r, i as t, j as i, f as o, b as n, a as
|
|
1
|
+
import { P as s, h as r, i as t, j as i, f as o, b as n, a as p, c as P, k as E, d as l, e as c, g as u } from "./verifyScriptPathSchnorrSignature-CpjSTfMj.js";
|
|
2
2
|
import { a as g } from "./secp256k1-D-H9jmd7.js";
|
|
3
|
-
import { attachFinalizedAssert as
|
|
3
|
+
import { attachFinalizedAssert as A, computeMinClaimValue as _, computeMinPeginFee as m, deriveVaultId as T, expandAuthAnchor as S, expandHashlockSecret as C, expandWotsSeed as I, finalizePayout as f, finalizeWronglyChallenged as h, peginP2aAnchorOutput as O, pinPegoutProof as N, supportedTxGraphVersions as b, validatePeginP2aAnchor as V } from "./tbv/core/wasm/index.js";
|
|
4
4
|
import { a as F, c as M, b as v, e as y, f as D } from "./verifyKeyPathSchnorrSignature-BQHNhRj6.js";
|
|
5
|
-
import { c as B, a as H, b as L, e as K, f as X, r as
|
|
5
|
+
import { c as B, a as H, b as L, e as K, f as X, r as G } from "./noPayout-qBXWKwav.js";
|
|
6
6
|
import { b as W } from "./challengeAssert-Cp_GeRg8.js";
|
|
7
7
|
import { c as z, d as Y, a as j, b as J, e as Z, f as q, k as Q, g as $, h as aa, i as ea, j as sa, p as ra, s as ta, t as ia, u as oa, v as na } from "./bitcoin-C-TuHb-v.js";
|
|
8
|
-
import { c as
|
|
8
|
+
import { c as Pa } from "./abortSignals-BPpAUL1Z.js";
|
|
9
9
|
import { c as la, a as ca, b as ua } from "./signing-Dhr2t0Z6.js";
|
|
10
|
-
import { B as ga, C as
|
|
10
|
+
import { B as ga, C as Ra, H as Aa, K as _a, M as ma, T as Ta, X as Sa } from "./validation-OSC0xTHB.js";
|
|
11
11
|
import { waitForTransactionReceiptSmartAware as Ia } from "./tbv/core/utils/eth/index.js";
|
|
12
|
-
import { P as
|
|
13
|
-
import { P as Fa, c as Ma, f as va, r as ya, s as Da, v as Ua } from "./PayoutManager-
|
|
14
|
-
import { MEMPOOL_API_URLS as Ha, getAddressTxs as La, getAddressUtxos as Ka, getMempoolApiUrl as Xa, getNetworkFees as
|
|
15
|
-
import { O as Za, V as qa, a as Qa, b as $a, c as ae, r as ee } from "./types-
|
|
16
|
-
import { a as re, d as te } from "./onChainBtcPubkey-
|
|
17
|
-
import { C as oe, M as ne, R as
|
|
18
|
-
import { A as
|
|
12
|
+
import { P as ha, b as Oa, c as Na, d as ba, e as Va } from "./PeginManager-CKf7Bjmj.js";
|
|
13
|
+
import { P as Fa, c as Ma, f as va, r as ya, s as Da, v as Ua } from "./PayoutManager-BSwbUQeF.js";
|
|
14
|
+
import { MEMPOOL_API_URLS as Ha, getAddressTxs as La, getAddressUtxos as Ka, getMempoolApiUrl as Xa, getNetworkFees as Ga, getOutspend as ka, getTipHeight as Wa, getTxHex as wa, getTxInfo as za, getUtxoInfo as Ya, pushTx as ja } from "./tbv/core/clients/mempool/index.js";
|
|
15
|
+
import { O as Za, V as qa, a as Qa, b as $a, c as ae, r as ee } from "./types-Dz1kVqn6.js";
|
|
16
|
+
import { a as re, d as te } from "./onChainBtcPubkey-CCTdl53s.js";
|
|
17
|
+
import { C as oe, M as ne, R as pe, V as Pe, c as Ee, d as le, i as ce, v as ue, a as de, b as ge } from "./pegin-registration-client-C5Hktrja.js";
|
|
18
|
+
import { A as Ae, P as _e } from "./ProtocolParams.abi-q0AidvYX.js";
|
|
19
19
|
import { B as Te } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
|
|
20
|
-
import { B as Ce, C as Ie, P as
|
|
21
|
-
import { V as Me, b as ve, a as ye, d as De, f as Ue } from "./deriveVaultRoot-
|
|
20
|
+
import { B as Ce, C as Ie, P as fe, a as he, e as Oe, g as Ne, h as be, i as Ve, b as xe } from "./BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js";
|
|
21
|
+
import { V as Me, b as ve, a as ye, d as De, f as Ue } from "./deriveVaultRoot-BcvmER1E.js";
|
|
22
22
|
import { p as He } from "./parseFundingOutpoints-GSM-IaaK.js";
|
|
23
23
|
import { BitcoinNetworks as Ke } from "./shared/index.js";
|
|
24
|
-
import { B as
|
|
25
|
-
import { B as $e, D as as, L as es, M as ss, c as rs, P as ts, b as is, a as os, S as ns, T as
|
|
26
|
-
import { U as gs, a as
|
|
27
|
-
import { V as Ss, a as Cs, b as Is, v as
|
|
28
|
-
import { A as
|
|
29
|
-
import { S as
|
|
30
|
-
import { D as
|
|
31
|
-
import {
|
|
32
|
-
import { C as
|
|
24
|
+
import { B as Ge, a as ke, c as We, b as we, d as ze, g as Ye, h as je, f as Je, s as Ze, e as qe } from "./psbtInputFields-CCVyaQMi.js";
|
|
25
|
+
import { B as $e, D as as, L as es, M as ss, c as rs, P as ts, b as is, a as os, S as ns, T as ps, W as Ps, f as Es, d as ls, p as cs, r as us } from "./fundPeginTransaction-CwhRbCQC.js";
|
|
26
|
+
import { U as gs, a as Rs, e as As, f as _s, v as ms } from "./reservation-DOAHVT3B.js";
|
|
27
|
+
import { V as Ss, a as Cs, b as Is, i as fs, v as hs } from "./index-B6w5MM-8.js";
|
|
28
|
+
import { A as Ns, C as bs, D as Vs, J as xs, a as Fs, b as Ms, d as vs, P as ys, R as Ds, e as Us, c as Bs, V as Hs, i as Ls, g as Ks, f as Xs } from "./state-mE-QfITd.js";
|
|
29
|
+
import { S as ks, V as Ws, c as ws, p as zs, v as Ys, a as js } from "./primeVpAuth-Bdy_B_Sq.js";
|
|
30
|
+
import { D as Zs, f as qs, P as Qs, a as $s, b as ar, o as er, p as sr, n as rr, q as tr, U as ir, V as or, j as nr, c as pr, h as Pr, l as Er, k as lr, e as cr, g as ur, d as dr, i as gr, r as Rr, m as Ar, t as _r } from "./toRefundInputs-DIIdhjvu.js";
|
|
31
|
+
import { t as Tr, A as Sr, X as Cr, C as Ir, D as fr, G as hr, i as Or, I as Nr, P as br, j as Vr, k as xr, a4 as Fr, a5 as Mr, a6 as vr, a7 as yr, _ as Dr, $ as Ur, a0 as Br, a1 as Hr, a2 as Lr, R as Kr, V as Xr, a as Gr, b as kr, c as Wr, e as wr, f as zr, h as Yr, g as jr, n as Jr, O as Zr, a3 as qr, Y as Qr, d as $r, Z as at, o as et, u as st, x as rt, Q as tt, J as it, l as ot, m as nt, L as pt, S as Pt, T as Et, U as lt, W as ct, r as ut, p as dt, q as gt, s as Rt, y as At, z as _t, v as mt, B as Tt, E as St, F as Ct, H as It, K as ft, M as ht, w as Ot, N as Nt } from "./buildAndBroadcastReclaim-T5ZFPUpM.js";
|
|
32
|
+
import { C as Vt, P as xt, a as Ft, c as Mt, g as vt, i as yt } from "./peginState-BU2ONFXF.js";
|
|
33
33
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
Ns as AUTH_REJECTED_RPC_CODE,
|
|
35
|
+
Tr as ApplicationEntryPointMismatchError,
|
|
36
|
+
Ae as ApplicationRegistryABI,
|
|
37
|
+
Sr as ArtifactsVaultMismatchError,
|
|
38
|
+
Cr as BIP68NotMatureError,
|
|
39
39
|
ga as BITCOIN_ADDRESS_RE,
|
|
40
40
|
Te as BTCVaultRegistryABI,
|
|
41
41
|
Ce as BTCVaultRegistryKeyEpochsABI,
|
|
42
42
|
$e as BTC_DUST_SAT,
|
|
43
43
|
Ke as BitcoinNetworks,
|
|
44
|
-
|
|
44
|
+
Ge as BitcoinScriptType,
|
|
45
45
|
oe as COMMISSION_BPS_HEADROOM,
|
|
46
|
-
|
|
46
|
+
Ra as COMPRESSED_PUBKEY_HEX_LEN,
|
|
47
47
|
Ie as CONTRACT_ERRORS,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
Ir as ChallengerSetMismatchError,
|
|
49
|
+
bs as ClaimerPegoutStatusValue,
|
|
50
|
+
Vt as ContractStatus,
|
|
51
|
+
fr as DELEGATED_CLAIM_TX_GRAPH_VERSION,
|
|
52
|
+
Zs as DEPOSIT_TERMS_REJECTED_ERROR_NAME,
|
|
53
53
|
as as DUST_THRESHOLD,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
Vs as DaemonStatus,
|
|
55
|
+
qs as DepositTermsRejectedError,
|
|
56
|
+
hr as GraphFingerprintError,
|
|
57
|
+
Aa as HEX_RE,
|
|
58
|
+
xs as JSON_RPC_ERROR_CODES,
|
|
59
|
+
Fs as JsonRpcClient,
|
|
60
|
+
Ms as JsonRpcError,
|
|
60
61
|
_a as KNOWN_SCRIPT_PREFIXES,
|
|
61
62
|
es as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
62
63
|
ne as MAX_ACCEPTABLE_COMMISSION_BPS_CAP,
|
|
@@ -68,143 +69,146 @@ export {
|
|
|
68
69
|
ts as P2TR_INPUT_SIZE,
|
|
69
70
|
is as PEGIN_AUTH_ANCHOR_OUTPUTS,
|
|
70
71
|
s as PEGIN_DEPOSITOR_CLAIM_VOUT,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Or as PEGIN_ETH_CONFIRMATIONS,
|
|
73
|
+
fe as PEGIN_FINGERPRINT_CHANGED_SELECTOR,
|
|
74
|
+
Qs as PEGIN_FINGERPRINT_DOMAIN,
|
|
75
|
+
$s as PEGIN_FINGERPRINT_DOMAIN_PREIMAGE,
|
|
75
76
|
os as PEGIN_FIXED_OUTPUTS,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
vs as POST_WOTS_STATUSES,
|
|
78
|
+
ys as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
79
|
+
Nr as ParticipantKeyDriftError,
|
|
80
|
+
br as PayoutDestinationError,
|
|
80
81
|
Fa as PayoutManager,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
xt as PeginAction,
|
|
83
|
+
he as PeginFingerprintChangedError,
|
|
84
|
+
ar as PeginFingerprintInputError,
|
|
85
|
+
ha as PeginManager,
|
|
86
|
+
er as PeginParamsAmbiguousError,
|
|
87
|
+
sr as PeginParamsIncompleteSpaceError,
|
|
88
|
+
rr as PeginParamsNotFoundError,
|
|
89
|
+
Vr as PeginRegistrationMissingError,
|
|
90
|
+
xr as PeginRegistrationNotFinalError,
|
|
91
|
+
tr as PeginSizingIntegrityError,
|
|
91
92
|
_e as ProtocolParamsABI,
|
|
92
93
|
r as PsbtSubstitutionError,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
Fr as RECLAIM_MAX_FEE_FRACTION_DENOMINATOR,
|
|
95
|
+
Mr as RECLAIM_MAX_FEE_FRACTION_NUMERATOR,
|
|
96
|
+
vr as RECLAIM_MAX_FEE_RATE_SATS_VB,
|
|
97
|
+
yr as RECLAIM_WARN_FEE_FRACTION_NUMERATOR,
|
|
98
|
+
Dr as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
|
|
99
|
+
Ur as REFUND_MAX_FEE_FRACTION_NUMERATOR,
|
|
100
|
+
Br as REFUND_MAX_FEE_RATE_SATS_VB,
|
|
101
|
+
Hr as REFUND_VSIZE,
|
|
102
|
+
Lr as ReclaimUneconomicalError,
|
|
103
|
+
Kr as RegisteredVaultVersionMismatchError,
|
|
104
|
+
pe as RegistrationLogsUnavailableError,
|
|
105
|
+
Ds as RpcErrorCode,
|
|
105
106
|
ns as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
|
|
106
|
-
|
|
107
|
+
ks as ServerIdentityError,
|
|
107
108
|
Ta as TXID_RE,
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
ps as TX_BUFFER_SIZE_OVERHEAD,
|
|
110
|
+
ir as UnanchoredPrePeginError,
|
|
110
111
|
gs as UtxoNotAvailableError,
|
|
111
112
|
Me as VAULT_APP_NAME,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
Us as VP_BATCH_MAX_SIZE,
|
|
114
|
+
Bs as VP_TERMINAL_FAILURE_STATUSES,
|
|
115
|
+
Hs as VP_TRANSIENT_STATUSES,
|
|
116
|
+
Xr as VaultIdBindingError,
|
|
116
117
|
Ss as VaultProviderRpcClient,
|
|
117
|
-
|
|
118
|
+
or as VaultRootMismatchError,
|
|
118
119
|
qa as ViemOperationKeyReader,
|
|
119
|
-
|
|
120
|
+
Pe as ViemPeginRegistrationClient,
|
|
120
121
|
Qa as ViemProtocolParamsReader,
|
|
121
122
|
$a as ViemUniversalChallengerReader,
|
|
122
123
|
ae as ViemVaultKeeperReader,
|
|
123
124
|
Ee as ViemVaultRegistryReader,
|
|
124
125
|
Cs as VpResponseValidationError,
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
Ws as VpTokenRegistry,
|
|
127
|
+
Ps as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
127
128
|
Sa as X_ONLY_PUBKEY_HEX_LEN,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
Gr as activateVault,
|
|
130
|
+
kr as activateVaultAndRedeem,
|
|
131
|
+
Ft as activationDeadlineBlocksRemaining,
|
|
132
|
+
ke as applyChangeOutputPolicy,
|
|
133
|
+
Wr as assembleWatchtowerArtifacts,
|
|
134
|
+
wr as assertArtifactsUsableForVault,
|
|
135
|
+
zr as assertChallengerSetMatchesVault,
|
|
136
|
+
Yr as assertClaimSpendsVault,
|
|
135
137
|
F as assertKeyPathSchnorrSignature,
|
|
136
138
|
re as assertOnChainBtcPubkey,
|
|
137
|
-
|
|
139
|
+
jr as assertPayoutPaysRegisteredScript,
|
|
138
140
|
t as assertPsbtUnsignedTxMatches,
|
|
141
|
+
Jr as assertReturnedGraphMatchesFingerprint,
|
|
139
142
|
M as assertReturnedKeyPathSignatures,
|
|
140
143
|
i as assertScriptPathSchnorrSignature,
|
|
141
|
-
|
|
144
|
+
Rs as assertUtxosAvailable,
|
|
142
145
|
g as assertValidVaultCoreVersion,
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
Zr as assertVaultProviderHintAccepted,
|
|
147
|
+
A as attachFinalizedAssert,
|
|
145
148
|
Is as batchPollByProvider,
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
qr as buildAndBroadcastReclaim,
|
|
150
|
+
Qr as buildAndBroadcastRefund,
|
|
148
151
|
W as buildChallengeAssertPsbt,
|
|
149
|
-
|
|
152
|
+
Oa as buildDepositTerms,
|
|
150
153
|
ve as buildFundingOutpointsCommitment,
|
|
151
154
|
B as buildNoPayoutPsbt,
|
|
152
155
|
o as buildPayoutPsbt,
|
|
153
156
|
v as buildPeginInputPsbt,
|
|
154
|
-
|
|
157
|
+
nr as buildPeginParamsCandidates,
|
|
155
158
|
n as buildPeginTxFromFundedPrePegin,
|
|
156
|
-
|
|
159
|
+
p as buildPrePeginPsbt,
|
|
157
160
|
H as buildReclaimPsbt,
|
|
158
161
|
L as buildRefundPsbt,
|
|
159
162
|
ye as buildVaultContext,
|
|
160
163
|
la as calculateBtcTxHash,
|
|
161
|
-
|
|
164
|
+
Mt as canPerformAction,
|
|
162
165
|
z as canonicalizeBtcPubkey,
|
|
163
166
|
le as capMaxAcceptableCommissionBps,
|
|
164
|
-
|
|
167
|
+
Pa as combineAbortSignals,
|
|
165
168
|
We as computeChangeOutputFeeSats,
|
|
166
169
|
Ma as computeHashlock,
|
|
167
170
|
we as computeMaxDeposit,
|
|
168
171
|
_ as computeMinClaimValue,
|
|
169
172
|
m as computeMinPeginFee,
|
|
170
|
-
|
|
173
|
+
P as computeNumLocalChallengers,
|
|
171
174
|
ze as computePeginBaseFeeSats,
|
|
172
|
-
|
|
175
|
+
pr as computePeginFingerprint,
|
|
173
176
|
Na as computeWotsBlockPublicKeysHash,
|
|
174
|
-
|
|
177
|
+
ws as createAuthenticatedVpClient,
|
|
175
178
|
E as createPayoutScript,
|
|
176
179
|
ca as createTaprootScriptPathSignOptions,
|
|
177
180
|
ua as createTaprootScriptPathSignOptionsForInput,
|
|
178
181
|
Y as deriveBip86ScriptPubKeyHex,
|
|
179
|
-
|
|
182
|
+
$r as deriveClaimerWotsKeypair,
|
|
180
183
|
l as deriveDepositorClaimDescriptor,
|
|
181
184
|
c as deriveDepositorClaimScriptPubKey,
|
|
182
|
-
|
|
185
|
+
Pr as deriveHashlocksFromPrePegin,
|
|
183
186
|
j as deriveNativeSegwitAddress,
|
|
184
187
|
te as derivePeginVaultId,
|
|
185
188
|
J as deriveTaprootAddress,
|
|
186
189
|
T as deriveVaultId,
|
|
187
190
|
De as deriveVaultRoot,
|
|
188
191
|
ba as deriveWotsBlocksFromSeed,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
Er as describePeginParamsCandidate,
|
|
193
|
+
lr as describeUnresolvedVersion,
|
|
194
|
+
cr as encodePeginFingerprintPreimage,
|
|
192
195
|
Z as ensureHexPrefix,
|
|
193
196
|
Va as ensurePrePeginTermsApproval,
|
|
194
197
|
K as estimateReclaimFeeSats,
|
|
195
|
-
|
|
198
|
+
at as estimateRefundFeeSats,
|
|
196
199
|
S as expandAuthAnchor,
|
|
197
200
|
C as expandHashlockSecret,
|
|
198
201
|
I as expandWotsSeed,
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
Oe as extractErrorData,
|
|
203
|
+
As as extractInputsFromTransaction,
|
|
201
204
|
u as extractPayoutSignature,
|
|
202
205
|
y as extractPeginInputSignature,
|
|
203
|
-
|
|
206
|
+
f as finalizePayout,
|
|
204
207
|
D as finalizePeginInputPsbt,
|
|
205
208
|
X as finalizeScriptPathWithSignatures,
|
|
206
|
-
|
|
209
|
+
h as finalizeWronglyChallenged,
|
|
207
210
|
_s as findOverlappingPendingVaults,
|
|
211
|
+
et as fingerprintReturnedGraph,
|
|
208
212
|
q as formatSatoshisToBtc,
|
|
209
213
|
va as forwardDepositApproval,
|
|
210
214
|
Ue as forwardDeriveContextHash,
|
|
@@ -215,9 +219,9 @@ export {
|
|
|
215
219
|
Ye as getDustThreshold,
|
|
216
220
|
Xa as getMempoolApiUrl,
|
|
217
221
|
Q as getNetwork,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
Ga as getNetworkFees,
|
|
223
|
+
ka as getOutspend,
|
|
224
|
+
vt as getPeginProtocolState,
|
|
221
225
|
je as getPsbtInputFields,
|
|
222
226
|
Je as getScriptType,
|
|
223
227
|
$ as getSortedXOnlyPubkeys,
|
|
@@ -227,76 +231,77 @@ export {
|
|
|
227
231
|
Ya as getUtxoInfo,
|
|
228
232
|
be as handleContractError,
|
|
229
233
|
aa as hexToUint8Array,
|
|
230
|
-
|
|
234
|
+
yt as isActivationDeadlinePassedOnChain,
|
|
231
235
|
ea as isAddressFromPublicKey,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
st as isApplicationEntryPointMismatchError,
|
|
237
|
+
Ls as isAuthRejectedError,
|
|
238
|
+
rt as isDepositAmountValid,
|
|
239
|
+
ur as isDepositTermsRejectedError,
|
|
240
|
+
tt as isHintAccepted,
|
|
237
241
|
Ve as isKnownContractError,
|
|
238
|
-
|
|
242
|
+
it as isParticipantKeyDriftError,
|
|
239
243
|
xe as isPeginFingerprintChangedError,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
dr as isPeginFingerprintInputError,
|
|
245
|
+
ot as isPeginRegistrationMissingError,
|
|
246
|
+
nt as isPeginRegistrationNotFinalError,
|
|
247
|
+
Ks as isPegoutTerminalStatus,
|
|
248
|
+
Xs as isRecognizedPegoutStatus,
|
|
249
|
+
pt as isRegisteredVaultVersionMismatchError,
|
|
246
250
|
ce as isRegistrationLogsUnavailableError,
|
|
251
|
+
fs as isUnrecognizedDaemonStatusError,
|
|
247
252
|
sa as isValidHex,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
gr as isWotsMismatchError,
|
|
254
|
+
Pt as matchKeyHint,
|
|
255
|
+
Et as matchKeySetHint,
|
|
251
256
|
He as parseFundingOutpointsFromTx,
|
|
252
257
|
ls as parseUnfundedWasmTransaction,
|
|
253
258
|
cs as peginOutputCount,
|
|
254
|
-
|
|
259
|
+
O as peginP2aAnchorOutput,
|
|
255
260
|
N as pinPegoutProof,
|
|
256
|
-
|
|
261
|
+
zs as primeVpTokenRegistry,
|
|
257
262
|
ra as processPublicKeyToXOnly,
|
|
258
263
|
ja as pushTx,
|
|
259
264
|
us as rateBasedTxBufferFee,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
265
|
+
Rr as rebuildDepositTermsCore,
|
|
266
|
+
G as reclaimVsize,
|
|
267
|
+
Ar as reconstructPeginParams,
|
|
263
268
|
ya as requireChangeAddress,
|
|
264
|
-
|
|
265
|
-
|
|
269
|
+
lt as resolveCurrentParticipantKeys,
|
|
270
|
+
ct as resolveParticipantKeysAtEpochs,
|
|
266
271
|
ee as resolveProtocolAddresses,
|
|
267
|
-
|
|
272
|
+
ut as runDepositorPresignFlow,
|
|
268
273
|
Ze as selectUtxosForPegin,
|
|
269
274
|
qe as shouldAddChangeOutput,
|
|
270
|
-
|
|
275
|
+
dt as signDepositorGraph,
|
|
271
276
|
ta as stripHexPrefix,
|
|
272
|
-
|
|
273
|
-
|
|
277
|
+
gt as submitWotsPublicKey,
|
|
278
|
+
Rt as summarizeWatchtowerArtifacts,
|
|
274
279
|
b as supportedTxGraphVersions,
|
|
275
280
|
Da as supportsDepositApproval,
|
|
276
|
-
|
|
281
|
+
_r as toRefundInputs,
|
|
277
282
|
ia as toXOnly,
|
|
278
283
|
oa as uint8ArrayToHex,
|
|
279
|
-
|
|
280
|
-
|
|
284
|
+
At as validateDepositAmount,
|
|
285
|
+
_t as validateMultiVaultDepositInputs,
|
|
281
286
|
ue as validateOffchainParams,
|
|
282
|
-
|
|
287
|
+
mt as validateOnChainParticipantKeys,
|
|
283
288
|
de as validatePegInConfiguration,
|
|
284
289
|
V as validatePeginP2aAnchor,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
290
|
+
Tt as validateProviderSelection,
|
|
291
|
+
St as validateRemainingCapacity,
|
|
292
|
+
hs as validateRequestDepositorClaimerArtifactsResponse,
|
|
288
293
|
Ua as validateSecretAgainstHashlock,
|
|
289
294
|
ge as validateTBVProtocolParams,
|
|
290
295
|
ms as validateUtxosAvailable,
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
Ct as validateVaultAmounts,
|
|
297
|
+
It as validateVaultProviderPubkey,
|
|
293
298
|
na as validateWalletPubkey,
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
299
|
+
ft as verifyRegisteredParticipantKeys,
|
|
300
|
+
ht as verifyRegisteredVaultVersions,
|
|
301
|
+
Ys as verifyServerIdentity,
|
|
302
|
+
js as vpTokenRegistry,
|
|
303
|
+
Ot as waitForPeginRegistrationDepth,
|
|
304
|
+
Nt as waitForPeginStatus,
|
|
300
305
|
Ia as waitForTransactionReceiptSmartAware
|
|
301
306
|
};
|
|
302
307
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const x=require("./sha2-
|
|
2
|
-
//# sourceMappingURL=onChainBtcPubkey-
|
|
1
|
+
"use strict";const x=require("./sha2-Ce6KewYx.cjs"),d=require("viem");function E(r,t){const e=r.startsWith("0x")?r.slice(2):r;if(e.length===0||e.length%2!==0)throw new Error(`${t} must be non-empty, even-length hex`);if(!/^[0-9a-fA-F]+$/.test(e))throw new Error(`${t} contains non-hex characters`);const s=new Uint8Array(e.length/2);for(let i=0;i<s.length;i++)s[i]=Number.parseInt(e.slice(i*2,i*2+2),16);return s}function m(r){return Array.from(r,t=>t.toString(16).padStart(2,"0")).join("")}function y(r){const t=new Uint8Array(r.reduce((s,i)=>s+i.length,0));let e=0;for(const s of r)t.set(s,e),e+=s.length;return t}function B(r){let t=0;const e=(n,f)=>{if(!Number.isSafeInteger(n)||n<0)throw new Error(`Invalid ${f} length ${n}`);if(t+n>r.length)throw new Error(`Truncated Bitcoin transaction while reading ${f}`);const c=r.slice(t,t+n);return t+=n,c},s=(n,f)=>{const c=e(n,f);let o=0n;for(let l=c.length-1;l>=0;l--)o=o<<8n|BigInt(c[l]);return o},i=n=>{const f=t,c=e(1,n)[0];let o;if(c<253)o=BigInt(c);else if(c===253){if(o=s(2,n),o<0xfdn)throw new Error(`Non-canonical ${n}`)}else if(c===254){if(o=s(4,n),o<=0xffffn)throw new Error(`Non-canonical ${n}`)}else if(o=s(8,n),o<=0xffffffffn)throw new Error(`Non-canonical ${n}`);if(o>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`${n} exceeds JavaScript's safe integer range`);return{encoded:r.slice(f,t),value:Number(o)}},a=e(4,"version"),p=r[t]===0&&r[t+1]===1;p&&(t+=2);const h=i("input count"),w=[];for(let n=0;n<h.value;n++){const f=t;e(32,`input ${n} previous transaction hash`),e(4,`input ${n} previous output index`);const c=i(`input ${n} script length`);e(c.value,`input ${n} script`),e(4,`input ${n} sequence`),w.push(r.slice(f,t))}const $=i("output count"),g=[];for(let n=0;n<$.value;n++){const f=t;e(8,`output ${n} value`);const c=i(`output ${n} script length`);e(c.value,`output ${n} script`),g.push(r.slice(f,t))}if(p){let n=!1;for(let f=0;f<h.value;f++){const c=i(`input ${f} witness item count`);n||(n=c.value>0);for(let o=0;o<c.value;o++){const l=i(`input ${f} witness item ${o} length`);e(l.value,`input ${f} witness item ${o}`)}}if(!n)throw new Error("Bitcoin transaction has superfluous witness marker")}const v=e(4,"locktime");if(t!==r.length)throw new Error(`Bitcoin transaction has ${r.length-t} trailing byte(s)`);return y([a,h.encoded,...w,$.encoded,...g,v])}function C(r){const t=B(E(r,"transactionHex")),e=x.sha256(x.sha256(t));return e.reverse(),`0x${m(e)}`}function I(r,t){const e=r.startsWith("0x")?r:`0x${r}`;if(!/^0x[0-9a-fA-F]{64}$/.test(e))throw new Error("peginTxHash must be a 32-byte hex value");const s=t.startsWith("0x")?t:`0x${t}`;if(!d.isAddress(s,{strict:!0}))throw new Error(`Invalid depositor Ethereum address: ${t}`);return d.keccak256(d.encodeAbiParameters([{type:"bytes32"},{type:"address"}],[e,s])).slice(2)}const u=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,k=7n;function P(r,t,e){let s=1n,i=r%e,a=t;for(;a>0n;)(a&1n)===1n&&(s=s*i%e),i=i*i%e,a>>=1n;return s}function A(r){const t=BigInt(`0x${r}`);if(t>=u)return!1;const s=(t*t%u*t%u+k)%u,i=P(s,u+1n>>2n,u);return i*i%u===s}function S(r,t){const e=r.toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(e))throw new Error(`${t} returned an unexpected value (length ${e.length}, prefix "${e.slice(0,2)}")`);const s=e.slice(2);if(!A(s))throw new Error(`${t} returned a value that is not on the secp256k1 curve`);return s}exports.assertOnChainBtcPubkey=S;exports.calculateBtcTxHash=C;exports.derivePeginVaultId=I;
|
|
2
|
+
//# sourceMappingURL=onChainBtcPubkey-BlzxYImF.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onChainBtcPubkey-BXry_CM4.cjs","sources":["../src/tbv/core/clients/eth/pegin-transaction.ts","../src/tbv/core/clients/eth/onChainBtcPubkey.ts"],"sourcesContent":["/**\n * Dependency-free Bitcoin txid and vault-ID helpers for Ethereum-only clients.\n * Transaction hex and vault-ID inputs accept an optional `0x` prefix.\n * Depositor addresses use strict EIP-55 validation.\n * Txids use a `0x` prefix. Vault IDs use no prefix. Both use lowercase hex.\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n encodeAbiParameters,\n isAddress,\n keccak256,\n type Address,\n type Hex,\n} from \"viem\";\n\n/** Decode an optional-prefixed, even-length hex string. */\nfunction decodeHex(value: string, label: string): Uint8Array {\n const clean = value.startsWith(\"0x\") ? value.slice(2) : value;\n if (clean.length === 0 || clean.length % 2 !== 0) {\n throw new Error(`${label} must be non-empty, even-length hex`);\n }\n if (!/^[0-9a-fA-F]+$/.test(clean)) {\n throw new Error(`${label} contains non-hex characters`);\n }\n\n const bytes = new Uint8Array(clean.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n}\n\n/** Encode bytes as lowercase hex without a prefix. */\nfunction encodeHex(bytes: Uint8Array): string {\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n}\n\n/** Concatenate byte chunks without a buffer dependency. */\nfunction concatBytes(chunks: readonly Uint8Array[]): Uint8Array {\n const result = new Uint8Array(\n chunks.reduce((length, chunk) => length + chunk.length, 0),\n );\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\n/**\n * Parse enough of Bitcoin's consensus transaction encoding to serialize the\n * no-witness form used for txid calculation. Every length is bounds-checked;\n * malformed/trailing data is rejected rather than hashed as an opaque blob.\n */\nfunction serializeWithoutWitness(transaction: Uint8Array): Uint8Array {\n let offset = 0;\n\n const take = (length: number, label: string): Uint8Array => {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new Error(`Invalid ${label} length ${length}`);\n }\n if (offset + length > transaction.length) {\n throw new Error(`Truncated Bitcoin transaction while reading ${label}`);\n }\n const value = transaction.slice(offset, offset + length);\n offset += length;\n return value;\n };\n\n const readLittleEndian = (length: number, label: string): bigint => {\n const bytes = take(length, label);\n let value = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) {\n value = (value << 8n) | BigInt(bytes[i]);\n }\n return value;\n };\n\n const readCompactSize = (\n label: string,\n ): { encoded: Uint8Array; value: number } => {\n const start = offset;\n const prefix = take(1, label)[0];\n let value: bigint;\n if (prefix < 0xfd) {\n value = BigInt(prefix);\n } else if (prefix === 0xfd) {\n value = readLittleEndian(2, label);\n if (value < 0xfdn) throw new Error(`Non-canonical ${label}`);\n } else if (prefix === 0xfe) {\n value = readLittleEndian(4, label);\n if (value <= 0xffffn) throw new Error(`Non-canonical ${label}`);\n } else {\n value = readLittleEndian(8, label);\n if (value <= 0xffffffffn) throw new Error(`Non-canonical ${label}`);\n }\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new Error(`${label} exceeds JavaScript's safe integer range`);\n }\n return {\n encoded: transaction.slice(start, offset),\n value: Number(value),\n };\n };\n\n const version = take(4, \"version\");\n const hasWitness =\n transaction[offset] === 0x00 && transaction[offset + 1] === 0x01;\n if (hasWitness) offset += 2;\n\n const inputCount = readCompactSize(\"input count\");\n const inputs: Uint8Array[] = [];\n for (let i = 0; i < inputCount.value; i++) {\n const start = offset;\n take(32, `input ${i} previous transaction hash`);\n take(4, `input ${i} previous output index`);\n const scriptLength = readCompactSize(`input ${i} script length`);\n take(scriptLength.value, `input ${i} script`);\n take(4, `input ${i} sequence`);\n inputs.push(transaction.slice(start, offset));\n }\n\n const outputCount = readCompactSize(\"output count\");\n const outputs: Uint8Array[] = [];\n for (let i = 0; i < outputCount.value; i++) {\n const start = offset;\n take(8, `output ${i} value`);\n const scriptLength = readCompactSize(`output ${i} script length`);\n take(scriptLength.value, `output ${i} script`);\n outputs.push(transaction.slice(start, offset));\n }\n\n if (hasWitness) {\n let hasWitnessData = false;\n for (let i = 0; i < inputCount.value; i++) {\n const itemCount = readCompactSize(`input ${i} witness item count`);\n hasWitnessData ||= itemCount.value > 0;\n for (let j = 0; j < itemCount.value; j++) {\n const itemLength = readCompactSize(\n `input ${i} witness item ${j} length`,\n );\n take(itemLength.value, `input ${i} witness item ${j}`);\n }\n }\n if (!hasWitnessData) {\n throw new Error(\"Bitcoin transaction has superfluous witness marker\");\n }\n }\n\n const locktime = take(4, \"locktime\");\n if (offset !== transaction.length) {\n throw new Error(\n `Bitcoin transaction has ${transaction.length - offset} trailing byte(s)`,\n );\n }\n\n return concatBytes([\n version,\n inputCount.encoded,\n ...inputs,\n outputCount.encoded,\n ...outputs,\n locktime,\n ]);\n}\n\n/** Calculate a Bitcoin txid without importing bitcoinjs-lib. */\nexport function calculateBtcTxHash(transactionHex: string): Hex {\n const serialized = serializeWithoutWitness(\n decodeHex(transactionHex, \"transactionHex\"),\n );\n const digest = sha256(sha256(serialized));\n digest.reverse();\n return `0x${encodeHex(digest)}`;\n}\n\n/**\n * Derive the Solidity vault ID without loading the Rust/WASM package.\n *\n * Inputs accept an optional `0x` prefix to match the current PeginManager\n * call sites. Address validation stays strict: lowercase and valid EIP-55\n * addresses pass, while uppercase and incorrectly checksummed mixed-case\n * addresses fail. The synchronous result is lowercase hex without a prefix,\n * matching the WASM helper that this function replaces.\n */\nexport function derivePeginVaultId(\n peginTxHash: string,\n depositor: string,\n): string {\n const normalizedPeginTxHash = peginTxHash.startsWith(\"0x\")\n ? peginTxHash\n : `0x${peginTxHash}`;\n if (!/^0x[0-9a-fA-F]{64}$/.test(normalizedPeginTxHash)) {\n throw new Error(\"peginTxHash must be a 32-byte hex value\");\n }\n const normalizedDepositor = depositor.startsWith(\"0x\")\n ? depositor\n : `0x${depositor}`;\n if (!isAddress(normalizedDepositor, { strict: true })) {\n throw new Error(`Invalid depositor Ethereum address: ${depositor}`);\n }\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }],\n [normalizedPeginTxHash as Hex, normalizedDepositor as Address],\n ),\n ).slice(2);\n}\n","/**\n * The single validator that mints {@link OnChainBtcPubkey}.\n *\n * Extracted from `ViemVaultRegistryReader.getVaultProviderGenesisBtcPubKey` so that\n * RFC-006 operation-key resolution can produce branded keys through exactly\n * the same checks, rather than casting past the brand. Every producer of an\n * `OnChainBtcPubkey` must go through here.\n */\n\nimport type { Hex } from \"viem\";\n\nimport type { OnChainBtcPubkey } from \"./types\";\n\n/** secp256k1's base-field prime, `2^256 - 2^32 - 977`. */\nconst SECP256K1_FIELD_PRIME =\n 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;\n\n/** secp256k1's curve coefficient `b`, from `y^2 = x^3 + b`. */\nconst SECP256K1_CURVE_B = 7n;\n\n/** Modular exponentiation without a crypto-library dependency. */\nfunction modPow(base: bigint, exponent: bigint, modulus: bigint): bigint {\n let result = 1n;\n let factor = base % modulus;\n let remaining = exponent;\n\n while (remaining > 0n) {\n if ((remaining & 1n) === 1n) {\n result = (result * factor) % modulus;\n }\n factor = (factor * factor) % modulus;\n remaining >>= 1n;\n }\n\n return result;\n}\n\n/**\n * secp256k1's field prime is congruent to 3 mod 4, so an x-coordinate is on\n * the curve iff `(x^3 + 7)^((p + 1) / 4)` squares back to `x^3 + 7` modulo\n * p. This is the same curve-membership condition used by x-only key parsers;\n * it deliberately does not merely validate length/range.\n * `x^3 + 7` cannot be zero because `-7` is not a cubic residue in this field,\n * so the zero square-root edge case is unreachable.\n */\nfunction isSecp256k1XCoordinate(value: string): boolean {\n const x = BigInt(`0x${value}`);\n if (x >= SECP256K1_FIELD_PRIME) return false;\n\n const xCubed =\n (((x * x) % SECP256K1_FIELD_PRIME) * x) % SECP256K1_FIELD_PRIME;\n const curveValue = (xCubed + SECP256K1_CURVE_B) % SECP256K1_FIELD_PRIME;\n const y = modPow(\n curveValue,\n (SECP256K1_FIELD_PRIME + 1n) >> 2n,\n SECP256K1_FIELD_PRIME,\n );\n\n return (y * y) % SECP256K1_FIELD_PRIME === curveValue;\n}\n\n/**\n * Validate a registry-returned `bytes32` as an x-only BTC pubkey and mint the\n * brand. Checks length, hex form, and secp256k1 curve membership. Returns\n * 64-char lowercase hex without the `0x` prefix.\n *\n * `label` identifies the read site in error messages (e.g.\n * `getOperationBtcKeyAtEpoch (vp=0x…, epoch=0)`), so a failure names which\n * participant and which getter produced it.\n *\n * A zero hash fails the curve check, so an unregistered operator or an epoch\n * with no bonded key surfaces as an error rather than a silent all-zero key.\n */\nexport function assertOnChainBtcPubkey(\n value: Hex,\n label: string,\n): OnChainBtcPubkey {\n const lowered = value.toLowerCase();\n if (!/^0x[0-9a-f]{64}$/.test(lowered)) {\n throw new Error(\n `${label} returned an unexpected value (length ${lowered.length}, prefix \"${lowered.slice(0, 2)}\")`,\n );\n }\n const stripped = lowered.slice(2);\n if (!isSecp256k1XCoordinate(stripped)) {\n throw new Error(\n `${label} returned a value that is not on the secp256k1 curve`,\n );\n }\n return stripped as OnChainBtcPubkey;\n}\n"],"names":["decodeHex","value","label","clean","bytes","encodeHex","byte","concatBytes","chunks","result","length","chunk","offset","serializeWithoutWitness","transaction","take","readLittleEndian","i","readCompactSize","start","prefix","version","hasWitness","inputCount","inputs","scriptLength","outputCount","outputs","hasWitnessData","itemCount","j","itemLength","locktime","calculateBtcTxHash","transactionHex","serialized","digest","sha256","derivePeginVaultId","peginTxHash","depositor","normalizedPeginTxHash","normalizedDepositor","isAddress","keccak256","encodeAbiParameters","SECP256K1_FIELD_PRIME","SECP256K1_CURVE_B","modPow","base","exponent","modulus","factor","remaining","isSecp256k1XCoordinate","x","curveValue","y","assertOnChainBtcPubkey","lowered","stripped"],"mappings":"sEAiBA,SAASA,EAAUC,EAAeC,EAA2B,CAC3D,MAAMC,EAAQF,EAAM,WAAW,IAAI,EAAIA,EAAM,MAAM,CAAC,EAAIA,EACxD,GAAIE,EAAM,SAAW,GAAKA,EAAM,OAAS,IAAM,EAC7C,MAAM,IAAI,MAAM,GAAGD,CAAK,qCAAqC,EAE/D,GAAI,CAAC,iBAAiB,KAAKC,CAAK,EAC9B,MAAM,IAAI,MAAM,GAAGD,CAAK,8BAA8B,EAGxD,MAAME,EAAQ,IAAI,WAAWD,EAAM,OAAS,CAAC,EAC7C,QAAS,EAAI,EAAG,EAAIC,EAAM,OAAQ,IAChCA,EAAM,CAAC,EAAI,OAAO,SAASD,EAAM,MAAM,EAAI,EAAG,EAAI,EAAI,CAAC,EAAG,EAAE,EAE9D,OAAOC,CACT,CAGA,SAASC,EAAUD,EAA2B,CAC5C,OAAO,MAAM,KAAKA,EAAQE,GAASA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAAE,KACrE,EAAA,CAEJ,CAGA,SAASC,EAAYC,EAA2C,CAC9D,MAAMC,EAAS,IAAI,WACjBD,EAAO,OAAO,CAACE,EAAQC,IAAUD,EAASC,EAAM,OAAQ,CAAC,CAAA,EAE3D,IAAIC,EAAS,EACb,UAAWD,KAASH,EAClBC,EAAO,IAAIE,EAAOC,CAAM,EACxBA,GAAUD,EAAM,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OAAO5C,CACT,CAUA,SAAS6C,EAAuBrD,EAAwB,CACtD,MAAMsD,EAAI,OAAO,KAAKtD,CAAK,EAAE,EAC7B,GAAIsD,GAAKT,EAAuB,MAAO,GAIvC,MAAMU,GADDD,EAAIA,EAAKT,EAAyBS,EAAKT,EACfC,GAAqBD,EAC5CW,EAAIT,EACRQ,EACCV,EAAwB,IAAO,GAChCA,CAAA,EAGF,OAAQW,EAAIA,EAAKX,IAA0BU,CAC7C,CAcO,SAASE,EACdzD,EACAC,EACkB,CAClB,MAAMyD,EAAU1D,EAAM,YAAA,EACtB,GAAI,CAAC,mBAAmB,KAAK0D,CAAO,EAClC,MAAM,IAAI,MACR,GAAGzD,CAAK,yCAAyCyD,EAAQ,MAAM,aAAaA,EAAQ,MAAM,EAAG,CAAC,CAAC,IAAA,EAGnG,MAAMC,EAAWD,EAAQ,MAAM,CAAC,EAChC,GAAI,CAACL,EAAuBM,CAAQ,EAClC,MAAM,IAAI,MACR,GAAG1D,CAAK,sDAAA,EAGZ,OAAO0D,CACT"}
|
|
1
|
+
{"version":3,"file":"onChainBtcPubkey-BlzxYImF.cjs","sources":["../src/tbv/core/clients/eth/pegin-transaction.ts","../src/tbv/core/clients/eth/onChainBtcPubkey.ts"],"sourcesContent":["/**\n * Dependency-free Bitcoin txid and vault-ID helpers for Ethereum-only clients.\n * Transaction hex and vault-ID inputs accept an optional `0x` prefix.\n * Depositor addresses use strict EIP-55 validation.\n * Txids use a `0x` prefix. Vault IDs use no prefix. Both use lowercase hex.\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n encodeAbiParameters,\n isAddress,\n keccak256,\n type Address,\n type Hex,\n} from \"viem\";\n\n/** Decode an optional-prefixed, even-length hex string. */\nfunction decodeHex(value: string, label: string): Uint8Array {\n const clean = value.startsWith(\"0x\") ? value.slice(2) : value;\n if (clean.length === 0 || clean.length % 2 !== 0) {\n throw new Error(`${label} must be non-empty, even-length hex`);\n }\n if (!/^[0-9a-fA-F]+$/.test(clean)) {\n throw new Error(`${label} contains non-hex characters`);\n }\n\n const bytes = new Uint8Array(clean.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n}\n\n/** Encode bytes as lowercase hex without a prefix. */\nfunction encodeHex(bytes: Uint8Array): string {\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n}\n\n/** Concatenate byte chunks without a buffer dependency. */\nfunction concatBytes(chunks: readonly Uint8Array[]): Uint8Array {\n const result = new Uint8Array(\n chunks.reduce((length, chunk) => length + chunk.length, 0),\n );\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\n/**\n * Parse enough of Bitcoin's consensus transaction encoding to serialize the\n * no-witness form used for txid calculation. Every length is bounds-checked;\n * malformed/trailing data is rejected rather than hashed as an opaque blob.\n */\nfunction serializeWithoutWitness(transaction: Uint8Array): Uint8Array {\n let offset = 0;\n\n const take = (length: number, label: string): Uint8Array => {\n if (!Number.isSafeInteger(length) || length < 0) {\n throw new Error(`Invalid ${label} length ${length}`);\n }\n if (offset + length > transaction.length) {\n throw new Error(`Truncated Bitcoin transaction while reading ${label}`);\n }\n const value = transaction.slice(offset, offset + length);\n offset += length;\n return value;\n };\n\n const readLittleEndian = (length: number, label: string): bigint => {\n const bytes = take(length, label);\n let value = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) {\n value = (value << 8n) | BigInt(bytes[i]);\n }\n return value;\n };\n\n const readCompactSize = (\n label: string,\n ): { encoded: Uint8Array; value: number } => {\n const start = offset;\n const prefix = take(1, label)[0];\n let value: bigint;\n if (prefix < 0xfd) {\n value = BigInt(prefix);\n } else if (prefix === 0xfd) {\n value = readLittleEndian(2, label);\n if (value < 0xfdn) throw new Error(`Non-canonical ${label}`);\n } else if (prefix === 0xfe) {\n value = readLittleEndian(4, label);\n if (value <= 0xffffn) throw new Error(`Non-canonical ${label}`);\n } else {\n value = readLittleEndian(8, label);\n if (value <= 0xffffffffn) throw new Error(`Non-canonical ${label}`);\n }\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new Error(`${label} exceeds JavaScript's safe integer range`);\n }\n return {\n encoded: transaction.slice(start, offset),\n value: Number(value),\n };\n };\n\n const version = take(4, \"version\");\n const hasWitness =\n transaction[offset] === 0x00 && transaction[offset + 1] === 0x01;\n if (hasWitness) offset += 2;\n\n const inputCount = readCompactSize(\"input count\");\n const inputs: Uint8Array[] = [];\n for (let i = 0; i < inputCount.value; i++) {\n const start = offset;\n take(32, `input ${i} previous transaction hash`);\n take(4, `input ${i} previous output index`);\n const scriptLength = readCompactSize(`input ${i} script length`);\n take(scriptLength.value, `input ${i} script`);\n take(4, `input ${i} sequence`);\n inputs.push(transaction.slice(start, offset));\n }\n\n const outputCount = readCompactSize(\"output count\");\n const outputs: Uint8Array[] = [];\n for (let i = 0; i < outputCount.value; i++) {\n const start = offset;\n take(8, `output ${i} value`);\n const scriptLength = readCompactSize(`output ${i} script length`);\n take(scriptLength.value, `output ${i} script`);\n outputs.push(transaction.slice(start, offset));\n }\n\n if (hasWitness) {\n let hasWitnessData = false;\n for (let i = 0; i < inputCount.value; i++) {\n const itemCount = readCompactSize(`input ${i} witness item count`);\n hasWitnessData ||= itemCount.value > 0;\n for (let j = 0; j < itemCount.value; j++) {\n const itemLength = readCompactSize(\n `input ${i} witness item ${j} length`,\n );\n take(itemLength.value, `input ${i} witness item ${j}`);\n }\n }\n if (!hasWitnessData) {\n throw new Error(\"Bitcoin transaction has superfluous witness marker\");\n }\n }\n\n const locktime = take(4, \"locktime\");\n if (offset !== transaction.length) {\n throw new Error(\n `Bitcoin transaction has ${transaction.length - offset} trailing byte(s)`,\n );\n }\n\n return concatBytes([\n version,\n inputCount.encoded,\n ...inputs,\n outputCount.encoded,\n ...outputs,\n locktime,\n ]);\n}\n\n/** Calculate a Bitcoin txid without importing bitcoinjs-lib. */\nexport function calculateBtcTxHash(transactionHex: string): Hex {\n const serialized = serializeWithoutWitness(\n decodeHex(transactionHex, \"transactionHex\"),\n );\n const digest = sha256(sha256(serialized));\n digest.reverse();\n return `0x${encodeHex(digest)}`;\n}\n\n/**\n * Derive the Solidity vault ID without loading the Rust/WASM package.\n *\n * Inputs accept an optional `0x` prefix to match the current PeginManager\n * call sites. Address validation stays strict: lowercase and valid EIP-55\n * addresses pass, while uppercase and incorrectly checksummed mixed-case\n * addresses fail. The synchronous result is lowercase hex without a prefix,\n * matching the WASM helper that this function replaces.\n */\nexport function derivePeginVaultId(\n peginTxHash: string,\n depositor: string,\n): string {\n const normalizedPeginTxHash = peginTxHash.startsWith(\"0x\")\n ? peginTxHash\n : `0x${peginTxHash}`;\n if (!/^0x[0-9a-fA-F]{64}$/.test(normalizedPeginTxHash)) {\n throw new Error(\"peginTxHash must be a 32-byte hex value\");\n }\n const normalizedDepositor = depositor.startsWith(\"0x\")\n ? depositor\n : `0x${depositor}`;\n if (!isAddress(normalizedDepositor, { strict: true })) {\n throw new Error(`Invalid depositor Ethereum address: ${depositor}`);\n }\n return keccak256(\n encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }],\n [normalizedPeginTxHash as Hex, normalizedDepositor as Address],\n ),\n ).slice(2);\n}\n","/**\n * The single validator that mints {@link OnChainBtcPubkey}.\n *\n * Extracted from `ViemVaultRegistryReader.getVaultProviderGenesisBtcPubKey` so that\n * RFC-006 operation-key resolution can produce branded keys through exactly\n * the same checks, rather than casting past the brand. Every producer of an\n * `OnChainBtcPubkey` must go through here.\n */\n\nimport type { Hex } from \"viem\";\n\nimport type { OnChainBtcPubkey } from \"./types\";\n\n/** secp256k1's base-field prime, `2^256 - 2^32 - 977`. */\nconst SECP256K1_FIELD_PRIME =\n 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;\n\n/** secp256k1's curve coefficient `b`, from `y^2 = x^3 + b`. */\nconst SECP256K1_CURVE_B = 7n;\n\n/** Modular exponentiation without a crypto-library dependency. */\nfunction modPow(base: bigint, exponent: bigint, modulus: bigint): bigint {\n let result = 1n;\n let factor = base % modulus;\n let remaining = exponent;\n\n while (remaining > 0n) {\n if ((remaining & 1n) === 1n) {\n result = (result * factor) % modulus;\n }\n factor = (factor * factor) % modulus;\n remaining >>= 1n;\n }\n\n return result;\n}\n\n/**\n * secp256k1's field prime is congruent to 3 mod 4, so an x-coordinate is on\n * the curve iff `(x^3 + 7)^((p + 1) / 4)` squares back to `x^3 + 7` modulo\n * p. This is the same curve-membership condition used by x-only key parsers;\n * it deliberately does not merely validate length/range.\n * `x^3 + 7` cannot be zero because `-7` is not a cubic residue in this field,\n * so the zero square-root edge case is unreachable.\n */\nfunction isSecp256k1XCoordinate(value: string): boolean {\n const x = BigInt(`0x${value}`);\n if (x >= SECP256K1_FIELD_PRIME) return false;\n\n const xCubed =\n (((x * x) % SECP256K1_FIELD_PRIME) * x) % SECP256K1_FIELD_PRIME;\n const curveValue = (xCubed + SECP256K1_CURVE_B) % SECP256K1_FIELD_PRIME;\n const y = modPow(\n curveValue,\n (SECP256K1_FIELD_PRIME + 1n) >> 2n,\n SECP256K1_FIELD_PRIME,\n );\n\n return (y * y) % SECP256K1_FIELD_PRIME === curveValue;\n}\n\n/**\n * Validate a registry-returned `bytes32` as an x-only BTC pubkey and mint the\n * brand. Checks length, hex form, and secp256k1 curve membership. Returns\n * 64-char lowercase hex without the `0x` prefix.\n *\n * `label` identifies the read site in error messages (e.g.\n * `getOperationBtcKeyAtEpoch (vp=0x…, epoch=0)`), so a failure names which\n * participant and which getter produced it.\n *\n * A zero hash fails the curve check, so an unregistered operator or an epoch\n * with no bonded key surfaces as an error rather than a silent all-zero key.\n */\nexport function assertOnChainBtcPubkey(\n value: Hex,\n label: string,\n): OnChainBtcPubkey {\n const lowered = value.toLowerCase();\n if (!/^0x[0-9a-f]{64}$/.test(lowered)) {\n throw new Error(\n `${label} returned an unexpected value (length ${lowered.length}, prefix \"${lowered.slice(0, 2)}\")`,\n );\n }\n const stripped = lowered.slice(2);\n if (!isSecp256k1XCoordinate(stripped)) {\n throw new Error(\n `${label} returned a value that is not on the secp256k1 curve`,\n );\n }\n return stripped as OnChainBtcPubkey;\n}\n"],"names":["decodeHex","value","label","clean","bytes","encodeHex","byte","concatBytes","chunks","result","length","chunk","offset","serializeWithoutWitness","transaction","take","readLittleEndian","i","readCompactSize","start","prefix","version","hasWitness","inputCount","inputs","scriptLength","outputCount","outputs","hasWitnessData","itemCount","j","itemLength","locktime","calculateBtcTxHash","transactionHex","serialized","digest","sha256","derivePeginVaultId","peginTxHash","depositor","normalizedPeginTxHash","normalizedDepositor","isAddress","keccak256","encodeAbiParameters","SECP256K1_FIELD_PRIME","SECP256K1_CURVE_B","modPow","base","exponent","modulus","factor","remaining","isSecp256k1XCoordinate","x","curveValue","y","assertOnChainBtcPubkey","lowered","stripped"],"mappings":"sEAiBA,SAASA,EAAUC,EAAeC,EAA2B,CAC3D,MAAMC,EAAQF,EAAM,WAAW,IAAI,EAAIA,EAAM,MAAM,CAAC,EAAIA,EACxD,GAAIE,EAAM,SAAW,GAAKA,EAAM,OAAS,IAAM,EAC7C,MAAM,IAAI,MAAM,GAAGD,CAAK,qCAAqC,EAE/D,GAAI,CAAC,iBAAiB,KAAKC,CAAK,EAC9B,MAAM,IAAI,MAAM,GAAGD,CAAK,8BAA8B,EAGxD,MAAME,EAAQ,IAAI,WAAWD,EAAM,OAAS,CAAC,EAC7C,QAAS,EAAI,EAAG,EAAIC,EAAM,OAAQ,IAChCA,EAAM,CAAC,EAAI,OAAO,SAASD,EAAM,MAAM,EAAI,EAAG,EAAI,EAAI,CAAC,EAAG,EAAE,EAE9D,OAAOC,CACT,CAGA,SAASC,EAAUD,EAA2B,CAC5C,OAAO,MAAM,KAAKA,EAAQE,GAASA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAAE,KACrE,EAAA,CAEJ,CAGA,SAASC,EAAYC,EAA2C,C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kBC,EAAyB,CACvE,IAAI1C,EAAS,GACT2C,EAASH,EAAOE,EAChBE,EAAYH,EAEhB,KAAOG,EAAY,KACZA,EAAY,MAAQ,KACvB5C,EAAUA,EAAS2C,EAAUD,GAE/BC,EAAUA,EAASA,EAAUD,EAC7BE,IAAc,GAGhB,OAAO5C,CACT,CAUA,SAAS6C,EAAuBrD,EAAwB,CACtD,MAAMsD,EAAI,OAAO,KAAKtD,CAAK,EAAE,EAC7B,GAAIsD,GAAKT,EAAuB,MAAO,GAIvC,MAAMU,GADDD,EAAIA,EAAKT,EAAyBS,EAAKT,EACfC,GAAqBD,EAC5CW,EAAIT,EACRQ,EACCV,EAAwB,IAAO,GAChCA,CAAA,EAGF,OAAQW,EAAIA,EAAKX,IAA0BU,CAC7C,CAcO,SAASE,EACdzD,EACAC,EACkB,CAClB,MAAMyD,EAAU1D,EAAM,YAAA,EACtB,GAAI,CAAC,mBAAmB,KAAK0D,CAAO,EAClC,MAAM,IAAI,MACR,GAAGzD,CAAK,yCAAyCyD,EAAQ,MAAM,aAAaA,EAAQ,MAAM,EAAG,CAAC,CAAC,IAAA,EAGnG,MAAMC,EAAWD,EAAQ,MAAM,CAAC,EAChC,GAAI,CAACL,EAAuBM,CAAQ,EAClC,MAAM,IAAI,MACR,GAAG1D,CAAK,sDAAA,EAGZ,OAAO0D,CACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as x } from "./sha2-
|
|
1
|
+
import { s as x } from "./sha2-YqVHJiFj.js";
|
|
2
2
|
import { isAddress as v, keccak256 as m, encodeAbiParameters as E } from "viem";
|
|
3
3
|
function y(r, t) {
|
|
4
4
|
const e = r.startsWith("0x") ? r.slice(2) : r;
|
|
@@ -156,4 +156,4 @@ export {
|
|
|
156
156
|
W as c,
|
|
157
157
|
L as d
|
|
158
158
|
};
|
|
159
|
-
//# sourceMappingURL=onChainBtcPubkey-
|
|
159
|
+
//# sourceMappingURL=onChainBtcPubkey-CCTdl53s.js.map
|