@babylonlabs-io/ts-sdk 0.44.0 → 0.46.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/README.md +0 -1
- package/dist/{BTCVaultRegistry.abi-Cq9-JlqT.js → BTCVaultRegistry.abi-Chs4AFBj.js} +125 -2
- package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +1 -0
- package/dist/{BTCVaultRegistry.abi-CHFGevwa.cjs → BTCVaultRegistry.abi-JdeqLz4x.cjs} +2 -2
- package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +1 -0
- package/dist/{PeginManager-D-8vmqzq.cjs → PeginManager-CeloRUHV.cjs} +2 -2
- package/dist/{PeginManager-D-8vmqzq.cjs.map → PeginManager-CeloRUHV.cjs.map} +1 -1
- package/dist/{PeginManager-BezsAEDe.js → PeginManager-CxSbzoYs.js} +4 -4
- package/dist/{PeginManager-BezsAEDe.js.map → PeginManager-CxSbzoYs.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-37Bs7-V1.js → buildAndBroadcastRefund-CZj2z7PJ.js} +2 -2
- package/dist/{buildAndBroadcastRefund-37Bs7-V1.js.map → buildAndBroadcastRefund-CZj2z7PJ.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-DbcNEsOv.cjs → buildAndBroadcastRefund-Ux587SFf.cjs} +2 -2
- package/dist/{buildAndBroadcastRefund-DbcNEsOv.cjs.map → buildAndBroadcastRefund-Ux587SFf.cjs.map} +1 -1
- package/dist/{errors-CznAK5NB.js → errors-Blc-JWnI.js} +71 -46
- package/dist/errors-Blc-JWnI.js.map +1 -0
- package/dist/errors-CGcNP0rV.cjs +2 -0
- package/dist/errors-CGcNP0rV.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +106 -107
- package/dist/mempoolApi-BxT89SAq.js +471 -0
- package/dist/mempoolApi-BxT89SAq.js.map +1 -0
- package/dist/mempoolApi-C_9JhjCI.cjs +2 -0
- package/dist/mempoolApi-C_9JhjCI.cjs.map +1 -0
- package/dist/primeVpAuth-7EYTPSTj.cjs +2 -0
- package/dist/{primeVpAuth-Duds3vAO.cjs.map → primeVpAuth-7EYTPSTj.cjs.map} +1 -1
- package/dist/{primeVpAuth-qEC9TTO_.js → primeVpAuth-DZlsu0di.js} +369 -341
- package/dist/{primeVpAuth-qEC9TTO_.js.map → primeVpAuth-DZlsu0di.js.map} +1 -1
- package/dist/reservation-BxvKbQH2.js +107 -0
- package/dist/reservation-BxvKbQH2.js.map +1 -0
- package/dist/reservation-xTL2a9Q-.cjs +2 -0
- package/dist/reservation-xTL2a9Q-.cjs.map +1 -0
- 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 +2 -2
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts +6 -0
- package/dist/tbv/core/clients/vault-provider/auth/createAuthenticatedVpClient.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts +12 -0
- package/dist/tbv/core/clients/vault-provider/auth/gatedMethods.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/auth/innerTokenClient.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts +8 -0
- package/dist/tbv/core/clients/vault-provider/auth/primeVpAuth.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts +42 -13
- package/dist/tbv/core/clients/vault-provider/auth/tokenProvider.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts +14 -4
- package/dist/tbv/core/clients/vault-provider/auth/tokenRegistry.d.ts.map +1 -1
- package/dist/tbv/core/contracts/__tests__/errors.test.d.ts +2 -0
- package/dist/tbv/core/contracts/__tests__/errors.test.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +292 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +102 -103
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +32 -33
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts +0 -1
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts.map +1 -1
- package/dist/tbv/core/utils/utxo/availability.d.ts +22 -1
- package/dist/tbv/core/utils/utxo/availability.d.ts.map +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +11 -86
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +102 -103
- package/dist/tbv/integrations/aave/clients/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/clients/oracle.d.ts +8 -1
- package/dist/tbv/integrations/aave/clients/oracle.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/clients/spoke.d.ts +27 -0
- package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/constants.d.ts +3 -3
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +1 -1
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +276 -212
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/BTCVaultRegistry.abi-CHFGevwa.cjs.map +0 -1
- package/dist/BTCVaultRegistry.abi-Cq9-JlqT.js.map +0 -1
- package/dist/errors-BP73_stm.cjs +0 -2
- package/dist/errors-BP73_stm.cjs.map +0 -1
- package/dist/errors-CznAK5NB.js.map +0 -1
- package/dist/mempoolApi-CknccHKg.cjs +0 -2
- package/dist/mempoolApi-CknccHKg.cjs.map +0 -1
- package/dist/mempoolApi-DI9HISqi.js +0 -451
- package/dist/mempoolApi-DI9HISqi.js.map +0 -1
- package/dist/primeVpAuth-Duds3vAO.cjs +0 -2
- package/dist/reservation-Cwf2u4vu.cjs +0 -2
- package/dist/reservation-Cwf2u4vu.cjs.map +0 -1
- package/dist/reservation-DNOGLBt4.js +0 -143
- package/dist/reservation-DNOGLBt4.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const i = {
|
|
2
2
|
// VaultAlreadyExists()
|
|
3
3
|
"0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
|
|
4
4
|
// ScriptPubKeyMismatch() - taproot output doesn't match expected script
|
|
@@ -30,67 +30,92 @@ const o = {
|
|
|
30
30
|
// PrePeginOutputAlreadyUsed()
|
|
31
31
|
"0x5fad9694": "This pre-pegin output has already been used to activate another vault.",
|
|
32
32
|
// PeginTransactionAlreadyUsed()
|
|
33
|
-
"0x7ed061c9": "This pegin transaction has already been used to activate another vault."
|
|
33
|
+
"0x7ed061c9": "This pegin transaction has already been used to activate another vault.",
|
|
34
|
+
// DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))
|
|
35
|
+
// collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived
|
|
36
|
+
// deterministically from the depositor's BTC wallet + selected UTXOs, so
|
|
37
|
+
// reusing the same UTXOs from the same wallet (even after a previous
|
|
38
|
+
// vault expires) produces the same hashlock and reverts here.
|
|
39
|
+
"0x70f7d5e2": "Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit."
|
|
34
40
|
};
|
|
35
|
-
function s(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
function s(e) {
|
|
42
|
+
return n(e, 0);
|
|
43
|
+
}
|
|
44
|
+
function n(e, r) {
|
|
45
|
+
if (r > 10 || !e || typeof e != "object") return;
|
|
46
|
+
const t = e;
|
|
47
|
+
if (typeof t.data == "string" && t.data.startsWith("0x"))
|
|
48
|
+
return t.data;
|
|
49
|
+
if (typeof t.revertData == "string" && t.revertData.startsWith("0x"))
|
|
50
|
+
return t.revertData;
|
|
51
|
+
if (typeof t.signature == "string" && t.signature.startsWith("0x"))
|
|
52
|
+
return t.signature;
|
|
53
|
+
if (typeof t.details == "string" && t.details.startsWith("0x"))
|
|
54
|
+
return t.details;
|
|
55
|
+
if (t.error && typeof t.error == "object") {
|
|
56
|
+
const a = t.error.data;
|
|
57
|
+
if (typeof a == "string" && a.startsWith("0x"))
|
|
58
|
+
return a;
|
|
59
|
+
}
|
|
60
|
+
if (t.cause) {
|
|
61
|
+
const a = n(t.cause, r + 1);
|
|
62
|
+
if (a) return a;
|
|
63
|
+
}
|
|
64
|
+
if (typeof t.walk == "function")
|
|
65
|
+
try {
|
|
66
|
+
let a;
|
|
67
|
+
if (t.walk((o) => {
|
|
68
|
+
if (o === e) return !1;
|
|
69
|
+
const c = n(o, r + 1);
|
|
70
|
+
return c ? (a = c, !0) : !1;
|
|
71
|
+
}), a) return a;
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
if (r === 0) {
|
|
75
|
+
const o = (typeof t.message == "string" ? t.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
|
|
76
|
+
if (o) return o[1];
|
|
49
77
|
}
|
|
50
|
-
const c = (typeof e.message == "string" ? e.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
|
|
51
|
-
if (c)
|
|
52
|
-
return c[1];
|
|
53
78
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
return
|
|
79
|
+
function d(e) {
|
|
80
|
+
const r = s(e);
|
|
81
|
+
if (r) {
|
|
82
|
+
const t = r.substring(0, 10);
|
|
83
|
+
return i[r] ?? i[t];
|
|
59
84
|
}
|
|
60
85
|
}
|
|
61
|
-
function u(
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
const
|
|
65
|
-
return
|
|
86
|
+
function u(e) {
|
|
87
|
+
const r = s(e);
|
|
88
|
+
if (r === void 0) return !1;
|
|
89
|
+
const t = r.substring(0, 10);
|
|
90
|
+
return r in i || t in i;
|
|
66
91
|
}
|
|
67
|
-
function
|
|
68
|
-
console.error("[Contract Error] Raw error:",
|
|
69
|
-
const
|
|
70
|
-
if (console.error("[Contract Error] Extracted error data:",
|
|
71
|
-
const a =
|
|
72
|
-
if (
|
|
73
|
-
throw console.error("[Contract Error] Known error:",
|
|
92
|
+
function l(e) {
|
|
93
|
+
console.error("[Contract Error] Raw error:", e);
|
|
94
|
+
const r = s(e);
|
|
95
|
+
if (console.error("[Contract Error] Extracted error data:", r), r) {
|
|
96
|
+
const a = r.substring(0, 10), o = i[r] ?? i[a];
|
|
97
|
+
if (o)
|
|
98
|
+
throw console.error("[Contract Error] Known error:", o), new Error(o);
|
|
74
99
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
const a =
|
|
100
|
+
const t = (e == null ? void 0 : e.message) || "";
|
|
101
|
+
if (t.includes("gas limit too high") || t.includes("21000000") || t.includes("Internal JSON-RPC error")) {
|
|
102
|
+
const a = r ? ` (error code: ${r})` : "";
|
|
78
103
|
throw console.error(
|
|
79
104
|
"[Contract Error] Transaction rejected. Error code:",
|
|
80
|
-
|
|
105
|
+
r,
|
|
81
106
|
"Message:",
|
|
82
|
-
|
|
107
|
+
t
|
|
83
108
|
), new Error(
|
|
84
109
|
`Transaction failed: The contract rejected this transaction${a}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`
|
|
85
110
|
);
|
|
86
111
|
}
|
|
87
|
-
throw
|
|
112
|
+
throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
|
|
88
113
|
}
|
|
89
114
|
export {
|
|
90
|
-
|
|
115
|
+
i as C,
|
|
91
116
|
s as e,
|
|
92
|
-
|
|
93
|
-
h,
|
|
117
|
+
d as g,
|
|
118
|
+
l as h,
|
|
94
119
|
u as i
|
|
95
120
|
};
|
|
96
|
-
//# sourceMappingURL=errors-
|
|
121
|
+
//# sourceMappingURL=errors-Blc-JWnI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-Blc-JWnI.js","sources":["../src/tbv/core/contracts/errors.ts"],"sourcesContent":["/**\n * Contract Error Handling Utilities\n *\n * Provides utilities for extracting and handling contract revert errors.\n * Maps known error selectors to user-friendly messages.\n *\n * @module contracts/errors\n */\n\n/**\n * Known contract error signatures mapped to user-friendly messages.\n *\n * Error selectors are the first 4 bytes of keccak256(error signature).\n * Example: keccak256(\"VaultAlreadyExists()\") = 0x04aabf33...\n */\nexport const CONTRACT_ERRORS: Record<string, string> = {\n // VaultAlreadyExists()\n \"0x04aabf33\":\n \"Vault already exists: This Bitcoin transaction has already been registered. \" +\n \"Please select different UTXOs or use a different amount to create a unique transaction.\",\n // ScriptPubKeyMismatch() - taproot output doesn't match expected script\n \"0x4fec082d\":\n \"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. \" +\n \"This may be caused by incorrect vault participants or key configuration.\",\n // InvalidBTCProofOfPossession()\n \"0x6cc363a5\":\n \"Invalid BTC proof of possession: The signature could not be verified. \" +\n \"Please ensure you're signing with the correct Bitcoin wallet.\",\n // InvalidBTCPublicKey()\n \"0x6c3f2bf6\":\n \"Invalid BTC public key: The Bitcoin public key format is invalid.\",\n // InvalidAmount()\n \"0x2c5211c6\":\n \"Invalid amount: The deposit amount is invalid or below the minimum required.\",\n // ApplicationNotRegistered()\n \"0x0405f772\":\n \"Application not registered: The application controller is not registered in the system.\",\n // InvalidProviderStatus()\n \"0x24e165cc\":\n \"Invalid provider status: The vault provider is not in a valid state to accept deposits.\",\n // ZeroAddress()\n \"0xd92e233d\":\n \"Zero address: One of the required addresses is the zero address.\",\n // BtcKeyMismatch()\n \"0x65aa7007\":\n \"BTC key mismatch: The Bitcoin public key does not match the expected key.\",\n // Unauthorized()\n \"0x82b42900\":\n \"Unauthorized: You must be the depositor or vault provider to submit this transaction.\",\n // InvalidSignature() - common signature verification error\n \"0x8baa579f\":\n \"Invalid signature: The BTC proof of possession signature could not be verified.\",\n // InvalidBtcTransaction()\n \"0x2f9d01e9\":\n \"Invalid BTC transaction: The Bitcoin transaction format is invalid.\",\n // VaultProviderNotRegistered()\n \"0x5a3c6b3e\":\n \"Vault provider not registered: The selected vault provider is not registered.\",\n // InvalidPeginFee(uint256,uint256)\n \"0x979f4518\":\n \"Invalid pegin fee: The ETH fee sent does not match the required amount. \" +\n \"This may indicate a fee rate change during the transaction.\",\n // PrePeginOutputAlreadyUsed()\n \"0x5fad9694\":\n \"This pre-pegin output has already been used to activate another vault.\",\n // PeginTransactionAlreadyUsed()\n \"0x7ed061c9\":\n \"This pegin transaction has already been used to activate another vault.\",\n // DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))\n // collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived\n // deterministically from the depositor's BTC wallet + selected UTXOs, so\n // reusing the same UTXOs from the same wallet (even after a previous\n // vault expires) produces the same hashlock and reverts here.\n \"0x70f7d5e2\":\n \"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit.\",\n};\n\n/**\n * Extract error data from various error formats.\n *\n * Viem and wallet providers wrap errors in multiple levels. This function\n * searches through the error chain to find the revert data.\n *\n * @param error - The error object to extract data from\n * @returns The error data (e.g., \"0x04aabf33\") or undefined\n */\nexport function extractErrorData(error: unknown): string | undefined {\n return walkForErrorData(error, 0);\n}\n\n/**\n * Walk an error chain looking for revert data in any of viem 2.x's known\n * shapes. Covers:\n * - `.data: \"0x...\"` — raw revert hex (most common with `estimateGas`)\n * - `.revertData: \"0x...\"` — alternate viem shape\n * - `.signature: \"0x...\"` — 4-byte selector from a *decoded*\n * ContractFunctionRevertedError (set when the ABI included the error def)\n * - `.error.data: \"0x...\"` — RPC-level error shape from some providers\n * - `.walk(fn)` — viem's chainable error walker (BaseError.walk)\n * - `.cause` chain — viem wraps errors many layers deep\n *\n * Depth-limited (10) and walk-result-deduplicated so a cycle can't loop.\n */\nfunction walkForErrorData(\n error: unknown,\n depth: number,\n): string | undefined {\n if (depth > 10 || !error || typeof error !== \"object\") return undefined;\n\n const err = error as Record<string, unknown>;\n\n if (typeof err.data === \"string\" && err.data.startsWith(\"0x\")) {\n return err.data;\n }\n if (typeof err.revertData === \"string\" && err.revertData.startsWith(\"0x\")) {\n return err.revertData;\n }\n if (typeof err.signature === \"string\" && err.signature.startsWith(\"0x\")) {\n return err.signature;\n }\n if (typeof err.details === \"string\" && err.details.startsWith(\"0x\")) {\n return err.details;\n }\n\n // RPC-level error shape (`{ error: { data: \"0x...\" } }`)\n if (err.error && typeof err.error === \"object\") {\n const inner = (err.error as Record<string, unknown>).data;\n if (typeof inner === \"string\" && inner.startsWith(\"0x\")) {\n return inner;\n }\n }\n\n // Recurse through `.cause`\n if (err.cause) {\n const fromCause = walkForErrorData(err.cause, depth + 1);\n if (fromCause) return fromCause;\n }\n\n // Use viem's `.walk()` if available\n if (typeof err.walk === \"function\") {\n try {\n let found: string | undefined;\n (err.walk as (fn: (e: unknown) => boolean) => unknown)((e) => {\n if (e === error) return false; // avoid self-cycle\n const data = walkForErrorData(e, depth + 1);\n if (data) {\n found = data;\n return true;\n }\n return false;\n });\n if (found) return found;\n } catch {\n // walk failed; ignore\n }\n }\n\n // Last resort: regex an embedded hex selector out of the message\n if (depth === 0) {\n const message = typeof err.message === \"string\" ? err.message : \"\";\n const hexMatch = message.match(/\\b(0x[a-fA-F0-9]{8})\\b/);\n if (hexMatch) return hexMatch[1];\n }\n\n return undefined;\n}\n\n/**\n * Get a user-friendly error message for a contract error.\n *\n * @param error - The error object from a contract call\n * @returns A user-friendly error message, or undefined if error is not recognized\n */\nexport function getContractErrorMessage(error: unknown): string | undefined {\n const errorData = extractErrorData(error);\n if (errorData) {\n // Check exact match first, then match by 4-byte selector prefix.\n // Parametric errors (e.g. InvalidPeginFee(uint256,uint256)) return\n // the selector + ABI-encoded args, so the full string won't match.\n const selector = errorData.substring(0, 10); // \"0x\" + 4 bytes\n return CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n }\n return undefined;\n}\n\n/**\n * Check if an error is a known contract error.\n *\n * @param error - The error object to check\n * @returns True if the error is a known contract error\n */\nexport function isKnownContractError(error: unknown): boolean {\n const errorData = extractErrorData(error);\n if (errorData === undefined) return false;\n const selector = errorData.substring(0, 10);\n return errorData in CONTRACT_ERRORS || selector in CONTRACT_ERRORS;\n}\n\n/**\n * Handle a contract error by throwing a user-friendly error.\n *\n * This function extracts error data, maps it to a user-friendly message,\n * and throws an appropriate error. Use this in catch blocks after contract calls.\n *\n * @param error - The error from a contract call\n * @throws Always throws an error with a descriptive message\n */\nexport function handleContractError(error: unknown): never {\n // Log full error for debugging\n console.error(\"[Contract Error] Raw error:\", error);\n\n // Extract error data from the error chain\n const errorData = extractErrorData(error);\n console.error(\"[Contract Error] Extracted error data:\", errorData);\n\n // Check for known contract error signatures (exact match or 4-byte selector prefix)\n if (errorData) {\n const selector = errorData.substring(0, 10);\n const knownError = CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n if (knownError) {\n console.error(\"[Contract Error] Known error:\", knownError);\n throw new Error(knownError);\n }\n }\n\n // Check for gas estimation errors or internal JSON-RPC errors\n const errorMsg = (error as Error)?.message || \"\";\n if (\n errorMsg.includes(\"gas limit too high\") ||\n errorMsg.includes(\"21000000\") ||\n errorMsg.includes(\"Internal JSON-RPC error\")\n ) {\n // If we found error data but it's not in our known list, include it\n const errorHint = errorData ? ` (error code: ${errorData})` : \"\";\n console.error(\n \"[Contract Error] Transaction rejected. Error code:\",\n errorData,\n \"Message:\",\n errorMsg,\n );\n throw new Error(\n `Transaction failed: The contract rejected this transaction${errorHint}. ` +\n \"Possible causes: (1) Vault already exists for this transaction, \" +\n \"(2) Invalid signature, (3) Unauthorized caller. \" +\n \"Please check your transaction parameters and try again.\",\n );\n }\n\n // Default: re-throw original error with better context\n if (error instanceof Error) {\n console.error(\"[Contract Error] Unhandled error:\", error.message);\n throw error;\n }\n throw new Error(`Contract call failed: ${String(error)}`);\n}\n"],"names":["CONTRACT_ERRORS","extractErrorData","error","walkForErrorData","depth","err","inner","fromCause","found","e","data","hexMatch","getContractErrorMessage","errorData","selector","isKnownContractError","handleContractError","knownError","errorMsg","errorHint"],"mappings":"AAeO,MAAMA,IAA0C;AAAA;AAAA,EAErD,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA;A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,0 +1,2 @@
|
|
|
1
|
+
"use strict";const n={"0x04aabf33":"Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.","0x4fec082d":"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. This may be caused by incorrect vault participants or key configuration.","0x6cc363a5":"Invalid BTC proof of possession: The signature could not be verified. Please ensure you're signing with the correct Bitcoin wallet.","0x6c3f2bf6":"Invalid BTC public key: The Bitcoin public key format is invalid.","0x2c5211c6":"Invalid amount: The deposit amount is invalid or below the minimum required.","0x0405f772":"Application not registered: The application controller is not registered in the system.","0x24e165cc":"Invalid provider status: The vault provider is not in a valid state to accept deposits.","0xd92e233d":"Zero address: One of the required addresses is the zero address.","0x65aa7007":"BTC key mismatch: The Bitcoin public key does not match the expected key.","0x82b42900":"Unauthorized: You must be the depositor or vault provider to submit this transaction.","0x8baa579f":"Invalid signature: The BTC proof of possession signature could not be verified.","0x2f9d01e9":"Invalid BTC transaction: The Bitcoin transaction format is invalid.","0x5a3c6b3e":"Vault provider not registered: The selected vault provider is not registered.","0x979f4518":"Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction.","0x5fad9694":"This pre-pegin output has already been used to activate another vault.","0x7ed061c9":"This pegin transaction has already been used to activate another vault.","0x70f7d5e2":"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit."};function i(e){return s(e,0)}function s(e,r){if(r>10||!e||typeof e!="object")return;const t=e;if(typeof t.data=="string"&&t.data.startsWith("0x"))return t.data;if(typeof t.revertData=="string"&&t.revertData.startsWith("0x"))return t.revertData;if(typeof t.signature=="string"&&t.signature.startsWith("0x"))return t.signature;if(typeof t.details=="string"&&t.details.startsWith("0x"))return t.details;if(t.error&&typeof t.error=="object"){const a=t.error.data;if(typeof a=="string"&&a.startsWith("0x"))return a}if(t.cause){const a=s(t.cause,r+1);if(a)return a}if(typeof t.walk=="function")try{let a;if(t.walk(o=>{if(o===e)return!1;const c=s(o,r+1);return c?(a=c,!0):!1}),a)return a}catch{}if(r===0){const o=(typeof t.message=="string"?t.message:"").match(/\b(0x[a-fA-F0-9]{8})\b/);if(o)return o[1]}}function d(e){const r=i(e);if(r){const t=r.substring(0,10);return n[r]??n[t]}}function u(e){const r=i(e);if(r===void 0)return!1;const t=r.substring(0,10);return r in n||t in n}function l(e){console.error("[Contract Error] Raw error:",e);const r=i(e);if(console.error("[Contract Error] Extracted error data:",r),r){const a=r.substring(0,10),o=n[r]??n[a];if(o)throw console.error("[Contract Error] Known error:",o),new Error(o)}const t=(e==null?void 0:e.message)||"";if(t.includes("gas limit too high")||t.includes("21000000")||t.includes("Internal JSON-RPC error")){const a=r?` (error code: ${r})`:"";throw console.error("[Contract Error] Transaction rejected. Error code:",r,"Message:",t),new Error(`Transaction failed: The contract rejected this transaction${a}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`)}throw e instanceof Error?(console.error("[Contract Error] Unhandled error:",e.message),e):new Error(`Contract call failed: ${String(e)}`)}exports.CONTRACT_ERRORS=n;exports.extractErrorData=i;exports.getContractErrorMessage=d;exports.handleContractError=l;exports.isKnownContractError=u;
|
|
2
|
+
//# sourceMappingURL=errors-CGcNP0rV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CGcNP0rV.cjs","sources":["../src/tbv/core/contracts/errors.ts"],"sourcesContent":["/**\n * Contract Error Handling Utilities\n *\n * Provides utilities for extracting and handling contract revert errors.\n * Maps known error selectors to user-friendly messages.\n *\n * @module contracts/errors\n */\n\n/**\n * Known contract error signatures mapped to user-friendly messages.\n *\n * Error selectors are the first 4 bytes of keccak256(error signature).\n * Example: keccak256(\"VaultAlreadyExists()\") = 0x04aabf33...\n */\nexport const CONTRACT_ERRORS: Record<string, string> = {\n // VaultAlreadyExists()\n \"0x04aabf33\":\n \"Vault already exists: This Bitcoin transaction has already been registered. \" +\n \"Please select different UTXOs or use a different amount to create a unique transaction.\",\n // ScriptPubKeyMismatch() - taproot output doesn't match expected script\n \"0x4fec082d\":\n \"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. \" +\n \"This may be caused by incorrect vault participants or key configuration.\",\n // InvalidBTCProofOfPossession()\n \"0x6cc363a5\":\n \"Invalid BTC proof of possession: The signature could not be verified. \" +\n \"Please ensure you're signing with the correct Bitcoin wallet.\",\n // InvalidBTCPublicKey()\n \"0x6c3f2bf6\":\n \"Invalid BTC public key: The Bitcoin public key format is invalid.\",\n // InvalidAmount()\n \"0x2c5211c6\":\n \"Invalid amount: The deposit amount is invalid or below the minimum required.\",\n // ApplicationNotRegistered()\n \"0x0405f772\":\n \"Application not registered: The application controller is not registered in the system.\",\n // InvalidProviderStatus()\n \"0x24e165cc\":\n \"Invalid provider status: The vault provider is not in a valid state to accept deposits.\",\n // ZeroAddress()\n \"0xd92e233d\":\n \"Zero address: One of the required addresses is the zero address.\",\n // BtcKeyMismatch()\n \"0x65aa7007\":\n \"BTC key mismatch: The Bitcoin public key does not match the expected key.\",\n // Unauthorized()\n \"0x82b42900\":\n \"Unauthorized: You must be the depositor or vault provider to submit this transaction.\",\n // InvalidSignature() - common signature verification error\n \"0x8baa579f\":\n \"Invalid signature: The BTC proof of possession signature could not be verified.\",\n // InvalidBtcTransaction()\n \"0x2f9d01e9\":\n \"Invalid BTC transaction: The Bitcoin transaction format is invalid.\",\n // VaultProviderNotRegistered()\n \"0x5a3c6b3e\":\n \"Vault provider not registered: The selected vault provider is not registered.\",\n // InvalidPeginFee(uint256,uint256)\n \"0x979f4518\":\n \"Invalid pegin fee: The ETH fee sent does not match the required amount. \" +\n \"This may indicate a fee rate change during the transaction.\",\n // PrePeginOutputAlreadyUsed()\n \"0x5fad9694\":\n \"This pre-pegin output has already been used to activate another vault.\",\n // PeginTransactionAlreadyUsed()\n \"0x7ed061c9\":\n \"This pegin transaction has already been used to activate another vault.\",\n // DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))\n // collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived\n // deterministically from the depositor's BTC wallet + selected UTXOs, so\n // reusing the same UTXOs from the same wallet (even after a previous\n // vault expires) produces the same hashlock and reverts here.\n \"0x70f7d5e2\":\n \"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit.\",\n};\n\n/**\n * Extract error data from various error formats.\n *\n * Viem and wallet providers wrap errors in multiple levels. This function\n * searches through the error chain to find the revert data.\n *\n * @param error - The error object to extract data from\n * @returns The error data (e.g., \"0x04aabf33\") or undefined\n */\nexport function extractErrorData(error: unknown): string | undefined {\n return walkForErrorData(error, 0);\n}\n\n/**\n * Walk an error chain looking for revert data in any of viem 2.x's known\n * shapes. Covers:\n * - `.data: \"0x...\"` — raw revert hex (most common with `estimateGas`)\n * - `.revertData: \"0x...\"` — alternate viem shape\n * - `.signature: \"0x...\"` — 4-byte selector from a *decoded*\n * ContractFunctionRevertedError (set when the ABI included the error def)\n * - `.error.data: \"0x...\"` — RPC-level error shape from some providers\n * - `.walk(fn)` — viem's chainable error walker (BaseError.walk)\n * - `.cause` chain — viem wraps errors many layers deep\n *\n * Depth-limited (10) and walk-result-deduplicated so a cycle can't loop.\n */\nfunction walkForErrorData(\n error: unknown,\n depth: number,\n): string | undefined {\n if (depth > 10 || !error || typeof error !== \"object\") return undefined;\n\n const err = error as Record<string, unknown>;\n\n if (typeof err.data === \"string\" && err.data.startsWith(\"0x\")) {\n return err.data;\n }\n if (typeof err.revertData === \"string\" && err.revertData.startsWith(\"0x\")) {\n return err.revertData;\n }\n if (typeof err.signature === \"string\" && err.signature.startsWith(\"0x\")) {\n return err.signature;\n }\n if (typeof err.details === \"string\" && err.details.startsWith(\"0x\")) {\n return err.details;\n }\n\n // RPC-level error shape (`{ error: { data: \"0x...\" } }`)\n if (err.error && typeof err.error === \"object\") {\n const inner = (err.error as Record<string, unknown>).data;\n if (typeof inner === \"string\" && inner.startsWith(\"0x\")) {\n return inner;\n }\n }\n\n // Recurse through `.cause`\n if (err.cause) {\n const fromCause = walkForErrorData(err.cause, depth + 1);\n if (fromCause) return fromCause;\n }\n\n // Use viem's `.walk()` if available\n if (typeof err.walk === \"function\") {\n try {\n let found: string | undefined;\n (err.walk as (fn: (e: unknown) => boolean) => unknown)((e) => {\n if (e === error) return false; // avoid self-cycle\n const data = walkForErrorData(e, depth + 1);\n if (data) {\n found = data;\n return true;\n }\n return false;\n });\n if (found) return found;\n } catch {\n // walk failed; ignore\n }\n }\n\n // Last resort: regex an embedded hex selector out of the message\n if (depth === 0) {\n const message = typeof err.message === \"string\" ? err.message : \"\";\n const hexMatch = message.match(/\\b(0x[a-fA-F0-9]{8})\\b/);\n if (hexMatch) return hexMatch[1];\n }\n\n return undefined;\n}\n\n/**\n * Get a user-friendly error message for a contract error.\n *\n * @param error - The error object from a contract call\n * @returns A user-friendly error message, or undefined if error is not recognized\n */\nexport function getContractErrorMessage(error: unknown): string | undefined {\n const errorData = extractErrorData(error);\n if (errorData) {\n // Check exact match first, then match by 4-byte selector prefix.\n // Parametric errors (e.g. InvalidPeginFee(uint256,uint256)) return\n // the selector + ABI-encoded args, so the full string won't match.\n const selector = errorData.substring(0, 10); // \"0x\" + 4 bytes\n return CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n }\n return undefined;\n}\n\n/**\n * Check if an error is a known contract error.\n *\n * @param error - The error object to check\n * @returns True if the error is a known contract error\n */\nexport function isKnownContractError(error: unknown): boolean {\n const errorData = extractErrorData(error);\n if (errorData === undefined) return false;\n const selector = errorData.substring(0, 10);\n return errorData in CONTRACT_ERRORS || selector in CONTRACT_ERRORS;\n}\n\n/**\n * Handle a contract error by throwing a user-friendly error.\n *\n * This function extracts error data, maps it to a user-friendly message,\n * and throws an appropriate error. Use this in catch blocks after contract calls.\n *\n * @param error - The error from a contract call\n * @throws Always throws an error with a descriptive message\n */\nexport function handleContractError(error: unknown): never {\n // Log full error for debugging\n console.error(\"[Contract Error] Raw error:\", error);\n\n // Extract error data from the error chain\n const errorData = extractErrorData(error);\n console.error(\"[Contract Error] Extracted error data:\", errorData);\n\n // Check for known contract error signatures (exact match or 4-byte selector prefix)\n if (errorData) {\n const selector = errorData.substring(0, 10);\n const knownError = CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n if (knownError) {\n console.error(\"[Contract Error] Known error:\", knownError);\n throw new Error(knownError);\n }\n }\n\n // Check for gas estimation errors or internal JSON-RPC errors\n const errorMsg = (error as Error)?.message || \"\";\n if (\n errorMsg.includes(\"gas limit too high\") ||\n errorMsg.includes(\"21000000\") ||\n errorMsg.includes(\"Internal JSON-RPC error\")\n ) {\n // If we found error data but it's not in our known list, include it\n const errorHint = errorData ? ` (error code: ${errorData})` : \"\";\n console.error(\n \"[Contract Error] Transaction rejected. Error code:\",\n errorData,\n \"Message:\",\n errorMsg,\n );\n throw new Error(\n `Transaction failed: The contract rejected this transaction${errorHint}. ` +\n \"Possible causes: (1) Vault already exists for this transaction, \" +\n \"(2) Invalid signature, (3) Unauthorized caller. \" +\n \"Please check your transaction parameters and try again.\",\n );\n }\n\n // Default: re-throw original error with better context\n if (error instanceof Error) {\n console.error(\"[Contract Error] Unhandled error:\", error.message);\n throw error;\n }\n throw new Error(`Contract call failed: ${String(error)}`);\n}\n"],"names":["CONTRACT_ERRORS","extractErrorData","error","walkForErrorData","depth","err","inner","fromCause","found","e","data","hexMatch","getContractErrorMessage","errorData","selector","isKnownContractError","handleContractError","knownError","errorMsg","errorHint"],"mappings":"aAeO,MAAMA,EAA0C,CAErD,aACE,sKAGF,aACE,+KAGF,aACE,sIAGF,aACE,oEAEF,aACE,+EAEF,aACE,0FAEF,aACE,0FAEF,aACE,mEAEF,aACE,4EAEF,aACE,wFAEF,aACE,kFAEF,aACE,sEAEF,aACE,gFAEF,aACE,sIAGF,aACE,yEAEF,aACE,0EAMF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@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./assertPsbtUnsignedTxMatches-CABhEADu.cjs"),p=require("./peginInput-DH6X4ITS.cjs"),S=require("./noPayout-DliaHuc6.cjs"),t=require("./bitcoin-CHfKAhcI.cjs"),g=require("./signing-Bnsro0hE.cjs"),d=require("./validation-u8W7Lp2x.cjs"),n=require("./PeginManager-D-8vmqzq.cjs"),A=require("./PayoutManager-BwYlPF2C.cjs"),_=require("./ApplicationRegistry.abi-BAPhJch3.cjs"),m=require("./BTCVaultRegistry.abi-CHFGevwa.cjs"),P=require("./errors-BP73_stm.cjs"),b=require("./shared/index.cjs"),o=require("./waitForTransactionReceiptSmartAware-BFMQFEzj.cjs"),r=require("./fundPeginTransaction-C8qsXxNV.cjs"),c=require("./reservation-Cwf2u4vu.cjs"),a=require("./mempoolApi-CknccHKg.cjs"),i=require("./primeVpAuth-Duds3vAO.cjs"),s=require("./types-eYlq0p1o.cjs"),R=require("./errors-Bu0H-dZD.cjs"),e=require("./buildAndBroadcastRefund-DbcNEsOv.cjs"),T=require("./peginState-BijNNT15.cjs");exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=E.buildDepositorPayoutPsbt;exports.computeNumLocalChallengers=E.computeNumLocalChallengers;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>l.computeMinClaimValue});Object.defineProperty(exports,"computeMinPeginFee",{enumerable:!0,get:()=>l.computeMinPeginFee});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>l.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>l.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>l.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>l.expandWotsSeed});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=p.buildPeginInputPsbt;exports.extractPeginInputSignature=p.extractPeginInputSignature;exports.finalizePeginInputPsbt=p.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=S.buildNoPayoutPsbt;exports.buildRefundPsbt=S.buildRefundPsbt;exports.deriveBip86ScriptPubKeyHex=t.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=t.deriveNativeSegwitAddress;exports.deriveTaprootAddress=t.deriveTaprootAddress;exports.ensureHexPrefix=t.ensureHexPrefix;exports.formatSatoshisToBtc=t.formatSatoshisToBtc;exports.getNetwork=t.getNetwork;exports.getSortedXOnlyPubkeys=t.getSortedXOnlyPubkeys;exports.hexToUint8Array=t.hexToUint8Array;exports.isAddressFromPublicKey=t.isAddressFromPublicKey;exports.isValidHex=t.isValidHex;exports.processPublicKeyToXOnly=t.processPublicKeyToXOnly;exports.stripHexPrefix=t.stripHexPrefix;exports.toXOnly=t.toXOnly;exports.uint8ArrayToHex=t.uint8ArrayToHex;exports.validateWalletPubkey=t.validateWalletPubkey;exports.createTaprootScriptPathSignOptions=g.createTaprootScriptPathSignOptions;exports.BITCOIN_ADDRESS_RE=d.BITCOIN_ADDRESS_RE;exports.HEX_RE=d.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=d.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=d.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=d.TXID_RE;exports.PeginManager=n.PeginManager;exports.VAULT_APP_NAME=n.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=n.buildFundingOutpointsCommitment;exports.buildVaultContext=n.buildVaultContext;exports.computeWotsBlockPublicKeysHash=n.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=n.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=n.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=n.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=A.PayoutManager;exports.computeHashlock=A.computeHashlock;exports.validateSecretAgainstHashlock=A.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=_.ApplicationRegistryABI;exports.ProtocolParamsABI=_.ProtocolParamsABI;exports.BTCVaultRegistryABI=m.BTCVaultRegistryABI;exports.CONTRACT_ERRORS=P.CONTRACT_ERRORS;exports.extractErrorData=P.extractErrorData;exports.getContractErrorMessage=P.getContractErrorMessage;exports.handleContractError=P.handleContractError;exports.isKnownContractError=P.isKnownContractError;exports.BitcoinNetworks=b.BitcoinNetworks;exports.BitcoinScriptType=o.BitcoinScriptType;exports.applyChangeOutputPolicy=o.applyChangeOutputPolicy;exports.calculateBtcTxHash=o.calculateBtcTxHash;exports.computeChangeOutputFeeSats=o.computeChangeOutputFeeSats;exports.computeMaxDeposit=o.computeMaxDeposit;exports.computePeginBaseFeeSats=o.computePeginBaseFeeSats;exports.getDustThreshold=o.getDustThreshold;exports.getPsbtInputFields=o.getPsbtInputFields;exports.getScriptType=o.getScriptType;exports.selectUtxosForPegin=o.selectUtxosForPegin;exports.shouldAddChangeOutput=o.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=o.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=r.BTC_DUST_SAT;exports.DUST_THRESHOLD=r.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=r.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=r.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=r.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=r.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=r.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=r.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=r.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=r.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=r.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=r.fundPeginTransaction;exports.parseUnfundedWasmTransaction=r.parseUnfundedWasmTransaction;exports.peginOutputCount=r.peginOutputCount;exports.rateBasedTxBufferFee=r.rateBasedTxBufferFee;exports.UtxoNotAvailableError=c.UtxoNotAvailableError;exports.assertUtxosAvailable=c.assertUtxosAvailable;exports.collectReservedUtxoRefs=c.collectReservedUtxoRefs;exports.extractInputsFromTransaction=c.extractInputsFromTransaction;exports.selectUtxosForDeposit=c.selectUtxosForDeposit;exports.validateUtxosAvailable=c.validateUtxosAvailable;exports.MEMPOOL_API_URLS=a.MEMPOOL_API_URLS;exports.ViemVaultRegistryReader=a.ViemVaultRegistryReader;exports.getAddressTxs=a.getAddressTxs;exports.getAddressUtxos=a.getAddressUtxos;exports.getMempoolApiUrl=a.getMempoolApiUrl;exports.getNetworkFees=a.getNetworkFees;exports.getTipHeight=a.getTipHeight;exports.getTxHex=a.getTxHex;exports.getTxInfo=a.getTxInfo;exports.getUtxoInfo=a.getUtxoInfo;exports.pushTx=a.pushTx;exports.validateOffchainParams=a.validateOffchainParams;exports.validatePegInConfiguration=a.validatePegInConfiguration;exports.validateTBVProtocolParams=a.validateTBVProtocolParams;exports.OnChainBtcVaultStatus=i.OnChainBtcVaultStatus;exports.ServerIdentityError=i.ServerIdentityError;exports.VaultProviderRpcClient=i.VaultProviderRpcClient;exports.ViemProtocolParamsReader=i.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=i.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=i.ViemVaultKeeperReader;exports.VpResponseValidationError=i.VpResponseValidationError;exports.VpTokenRegistry=i.VpTokenRegistry;exports.batchPollByProvider=i.batchPollByProvider;exports.createAuthenticatedVpClient=i.createAuthenticatedVpClient;exports.primeVpTokenRegistry=i.primeVpTokenRegistry;exports.resolveProtocolAddresses=i.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=i.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=i.verifyServerIdentity;exports.vpTokenRegistry=i.vpTokenRegistry;exports.AUTH_EXPIRED_DATA_KIND=s.AUTH_EXPIRED_DATA_KIND;exports.DaemonStatus=s.DaemonStatus;exports.JSON_RPC_ERROR_CODES=s.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=s.JsonRpcClient;exports.JsonRpcError=s.JsonRpcError;exports.POST_WOTS_STATUSES=s.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=s.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=s.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=s.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=s.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;exports.isWotsMismatchError=R.isWotsMismatchError;exports.parseFundingOutpointsFromTx=R.parseFundingOutpointsFromTx;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=T.ContractStatus;exports.PeginAction=T.PeginAction;exports.canPerformAction=T.canPerformAction;exports.getPeginProtocolState=T.getPeginProtocolState;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./challengeAssert-Cmj_OG6V.cjs"),l=require("@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./assertPsbtUnsignedTxMatches-CABhEADu.cjs"),p=require("./peginInput-DH6X4ITS.cjs"),S=require("./noPayout-DliaHuc6.cjs"),t=require("./bitcoin-CHfKAhcI.cjs"),R=require("./signing-Bnsro0hE.cjs"),c=require("./validation-u8W7Lp2x.cjs"),n=require("./PeginManager-CeloRUHV.cjs"),A=require("./PayoutManager-BwYlPF2C.cjs"),_=require("./ApplicationRegistry.abi-BAPhJch3.cjs"),m=require("./BTCVaultRegistry.abi-JdeqLz4x.cjs"),d=require("./errors-CGcNP0rV.cjs"),b=require("./shared/index.cjs"),o=require("./waitForTransactionReceiptSmartAware-BFMQFEzj.cjs"),r=require("./fundPeginTransaction-C8qsXxNV.cjs"),P=require("./reservation-xTL2a9Q-.cjs"),a=require("./mempoolApi-C_9JhjCI.cjs"),i=require("./primeVpAuth-7EYTPSTj.cjs"),s=require("./types-eYlq0p1o.cjs"),g=require("./errors-Bu0H-dZD.cjs"),e=require("./buildAndBroadcastRefund-Ux587SFf.cjs"),T=require("./peginState-BijNNT15.cjs");exports.buildChallengeAssertPsbt=E.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=E.buildDepositorPayoutPsbt;exports.computeNumLocalChallengers=E.computeNumLocalChallengers;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>l.computeMinClaimValue});Object.defineProperty(exports,"computeMinPeginFee",{enumerable:!0,get:()=>l.computeMinPeginFee});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>l.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>l.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>l.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>l.expandWotsSeed});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=p.buildPeginInputPsbt;exports.extractPeginInputSignature=p.extractPeginInputSignature;exports.finalizePeginInputPsbt=p.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=S.buildNoPayoutPsbt;exports.buildRefundPsbt=S.buildRefundPsbt;exports.deriveBip86ScriptPubKeyHex=t.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=t.deriveNativeSegwitAddress;exports.deriveTaprootAddress=t.deriveTaprootAddress;exports.ensureHexPrefix=t.ensureHexPrefix;exports.formatSatoshisToBtc=t.formatSatoshisToBtc;exports.getNetwork=t.getNetwork;exports.getSortedXOnlyPubkeys=t.getSortedXOnlyPubkeys;exports.hexToUint8Array=t.hexToUint8Array;exports.isAddressFromPublicKey=t.isAddressFromPublicKey;exports.isValidHex=t.isValidHex;exports.processPublicKeyToXOnly=t.processPublicKeyToXOnly;exports.stripHexPrefix=t.stripHexPrefix;exports.toXOnly=t.toXOnly;exports.uint8ArrayToHex=t.uint8ArrayToHex;exports.validateWalletPubkey=t.validateWalletPubkey;exports.createTaprootScriptPathSignOptions=R.createTaprootScriptPathSignOptions;exports.BITCOIN_ADDRESS_RE=c.BITCOIN_ADDRESS_RE;exports.HEX_RE=c.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=c.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=c.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=c.TXID_RE;exports.PeginManager=n.PeginManager;exports.VAULT_APP_NAME=n.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=n.buildFundingOutpointsCommitment;exports.buildVaultContext=n.buildVaultContext;exports.computeWotsBlockPublicKeysHash=n.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=n.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=n.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=n.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=A.PayoutManager;exports.computeHashlock=A.computeHashlock;exports.validateSecretAgainstHashlock=A.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=_.ApplicationRegistryABI;exports.ProtocolParamsABI=_.ProtocolParamsABI;exports.BTCVaultRegistryABI=m.BTCVaultRegistryABI;exports.CONTRACT_ERRORS=d.CONTRACT_ERRORS;exports.extractErrorData=d.extractErrorData;exports.getContractErrorMessage=d.getContractErrorMessage;exports.handleContractError=d.handleContractError;exports.isKnownContractError=d.isKnownContractError;exports.BitcoinNetworks=b.BitcoinNetworks;exports.BitcoinScriptType=o.BitcoinScriptType;exports.applyChangeOutputPolicy=o.applyChangeOutputPolicy;exports.calculateBtcTxHash=o.calculateBtcTxHash;exports.computeChangeOutputFeeSats=o.computeChangeOutputFeeSats;exports.computeMaxDeposit=o.computeMaxDeposit;exports.computePeginBaseFeeSats=o.computePeginBaseFeeSats;exports.getDustThreshold=o.getDustThreshold;exports.getPsbtInputFields=o.getPsbtInputFields;exports.getScriptType=o.getScriptType;exports.selectUtxosForPegin=o.selectUtxosForPegin;exports.shouldAddChangeOutput=o.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=o.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=r.BTC_DUST_SAT;exports.DUST_THRESHOLD=r.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=r.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=r.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=r.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=r.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=r.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=r.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=r.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=r.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=r.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=r.fundPeginTransaction;exports.parseUnfundedWasmTransaction=r.parseUnfundedWasmTransaction;exports.peginOutputCount=r.peginOutputCount;exports.rateBasedTxBufferFee=r.rateBasedTxBufferFee;exports.UtxoNotAvailableError=P.UtxoNotAvailableError;exports.assertUtxosAvailable=P.assertUtxosAvailable;exports.extractInputsFromTransaction=P.extractInputsFromTransaction;exports.findOverlappingPendingVaults=P.findOverlappingPendingVaults;exports.validateUtxosAvailable=P.validateUtxosAvailable;exports.MEMPOOL_API_URLS=a.MEMPOOL_API_URLS;exports.ViemVaultRegistryReader=a.ViemVaultRegistryReader;exports.getAddressTxs=a.getAddressTxs;exports.getAddressUtxos=a.getAddressUtxos;exports.getMempoolApiUrl=a.getMempoolApiUrl;exports.getNetworkFees=a.getNetworkFees;exports.getTipHeight=a.getTipHeight;exports.getTxHex=a.getTxHex;exports.getTxInfo=a.getTxInfo;exports.getUtxoInfo=a.getUtxoInfo;exports.pushTx=a.pushTx;exports.validateOffchainParams=a.validateOffchainParams;exports.validatePegInConfiguration=a.validatePegInConfiguration;exports.validateTBVProtocolParams=a.validateTBVProtocolParams;exports.OnChainBtcVaultStatus=i.OnChainBtcVaultStatus;exports.ServerIdentityError=i.ServerIdentityError;exports.VaultProviderRpcClient=i.VaultProviderRpcClient;exports.ViemProtocolParamsReader=i.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=i.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=i.ViemVaultKeeperReader;exports.VpResponseValidationError=i.VpResponseValidationError;exports.VpTokenRegistry=i.VpTokenRegistry;exports.batchPollByProvider=i.batchPollByProvider;exports.createAuthenticatedVpClient=i.createAuthenticatedVpClient;exports.primeVpTokenRegistry=i.primeVpTokenRegistry;exports.resolveProtocolAddresses=i.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=i.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=i.verifyServerIdentity;exports.vpTokenRegistry=i.vpTokenRegistry;exports.AUTH_EXPIRED_DATA_KIND=s.AUTH_EXPIRED_DATA_KIND;exports.DaemonStatus=s.DaemonStatus;exports.JSON_RPC_ERROR_CODES=s.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=s.JsonRpcClient;exports.JsonRpcError=s.JsonRpcError;exports.POST_WOTS_STATUSES=s.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=s.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=s.RpcErrorCode;exports.VP_BATCH_MAX_SIZE=s.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=s.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;exports.isWotsMismatchError=g.isWotsMismatchError;exports.parseFundingOutpointsFromTx=g.parseFundingOutpointsFromTx;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=T.ContractStatus;exports.PeginAction=T.PeginAction;exports.canPerformAction=T.canPerformAction;exports.getPeginProtocolState=T.getPeginProtocolState;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
1
|
import { a as s, b as t, c as r } from "./challengeAssert-ChqnvtRg.js";
|
|
2
2
|
import { computeMinClaimValue as i, computeMinPeginFee as n, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as p, expandWotsSeed as d } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
3
|
-
import { P as c, d as T, c as E, a as A, b as S, f as
|
|
3
|
+
import { P as c, d as T, c as E, a as A, b as S, f as _, e as g } from "./assertPsbtUnsignedTxMatches-GHobJP-d.js";
|
|
4
4
|
import { b as m, e as x, f } from "./peginInput-BPRB9tUi.js";
|
|
5
|
-
import { a as I, b as
|
|
6
|
-
import { d as
|
|
5
|
+
import { a as I, b as O } from "./noPayout-BtP-R-b-.js";
|
|
6
|
+
import { d as v, a as C, b as F, e as h, f as U, j as N, g as y, h as B, i as D, c as M, p as H, s as L, t as X, u as k, v as W } from "./bitcoin-B5aNKtsk.js";
|
|
7
7
|
import { c as K } from "./signing-DaLvGwQe.js";
|
|
8
8
|
import { B as Y, H as Z, K as J, M as j, T as q } from "./validation-CxqROCno.js";
|
|
9
|
-
import { P as Q, V as $, b as aa, a as ea, c as sa, f as ta, d as ra, e as oa } from "./PeginManager-
|
|
9
|
+
import { P as Q, V as $, b as aa, a as ea, c as sa, f as ta, d as ra, e as oa } from "./PeginManager-CxSbzoYs.js";
|
|
10
10
|
import { P as na, c as ua, v as la } from "./PayoutManager-CXDccwDN.js";
|
|
11
11
|
import { A as da, P as Pa } from "./ApplicationRegistry.abi-Dn2qk6JG.js";
|
|
12
|
-
import { B as Ta } from "./BTCVaultRegistry.abi-
|
|
13
|
-
import { C as Aa, e as Sa, g as
|
|
12
|
+
import { B as Ta } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
|
|
13
|
+
import { C as Aa, e as Sa, g as _a, h as ga, i as Ra } from "./errors-Blc-JWnI.js";
|
|
14
14
|
import { BitcoinNetworks as xa } from "./shared/index.js";
|
|
15
|
-
import { B as ba, a as Ia, f as
|
|
15
|
+
import { B as ba, a as Ia, f as Oa, c as Va, b as va, d as Ca, g as Fa, i as ha, h as Ua, s as Na, e as ya, w as Ba } from "./waitForTransactionReceiptSmartAware-Dt5VcMK0.js";
|
|
16
16
|
import { B as Ma, D as Ha, F as La, L as Xa, M as ka, P as Wa, b as wa, a as Ka, S as Ga, T as Ya, W as Za, f as Ja, c as ja, p as qa, r as za } from "./fundPeginTransaction-C11tYf6I.js";
|
|
17
|
-
import { U as $a, a as ae,
|
|
18
|
-
import { M as
|
|
19
|
-
import { O as
|
|
20
|
-
import { A as
|
|
21
|
-
import { i as
|
|
22
|
-
import { B as
|
|
23
|
-
import { C as
|
|
17
|
+
import { U as $a, a as ae, e as ee, f as se, v as te } from "./reservation-BxvKbQH2.js";
|
|
18
|
+
import { M as oe, V as ie, g as ne, a as ue, b as le, c as pe, d as de, e as Pe, f as ce, h as Te, p as Ee, v as Ae, i as Se, j as _e } from "./mempoolApi-BxT89SAq.js";
|
|
19
|
+
import { O as Re, S as me, V as xe, g as fe, h as be, i as Ie, a as Oe, d as Ve, b as ve, f as Ce, p as Fe, r as he, v as Ue, c as Ne, e as ye } from "./primeVpAuth-DZlsu0di.js";
|
|
20
|
+
import { A as De, D as Me, b as He, J as Le, a as Xe, d as ke, P as We, R as we, e as Ke, c as Ge, V as Ye } from "./types-BqGAMOZM.js";
|
|
21
|
+
import { i as Je, p as je } from "./errors-9AkghWyk.js";
|
|
22
|
+
import { B as ze, C as Qe, p as $e, q as as, t as es, u as ss, R as ts, a as rs, n as os, o as is, i as ns, m as us, l as ls, j as ps, r as ds, b as Ps, s as cs, v as Ts, g as Es, h as As, d as Ss, c as _s, e as gs, f as Rs, k as ms, w as xs } from "./buildAndBroadcastRefund-CZj2z7PJ.js";
|
|
23
|
+
import { C as bs, P as Is, c as Os, g as Vs } from "./peginState-CBAlxgXk.js";
|
|
24
24
|
export {
|
|
25
|
-
|
|
25
|
+
De as AUTH_EXPIRED_DATA_KIND,
|
|
26
26
|
da as ApplicationRegistryABI,
|
|
27
|
-
|
|
27
|
+
ze as BIP68NotMatureError,
|
|
28
28
|
Y as BITCOIN_ADDRESS_RE,
|
|
29
29
|
Ta as BTCVaultRegistryABI,
|
|
30
30
|
Ma as BTC_DUST_SAT,
|
|
31
31
|
xa as BitcoinNetworks,
|
|
32
32
|
ba as BitcoinScriptType,
|
|
33
33
|
Aa as CONTRACT_ERRORS,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
Qe as ClaimerPegoutStatusValue,
|
|
35
|
+
bs as ContractStatus,
|
|
36
36
|
Ha as DUST_THRESHOLD,
|
|
37
|
-
|
|
37
|
+
Me as DaemonStatus,
|
|
38
38
|
La as FEE_SAFETY_MARGIN,
|
|
39
39
|
Z as HEX_RE,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
He as JSON_RPC_ERROR_CODES,
|
|
41
|
+
Le as JsonRpcClient,
|
|
42
|
+
Xe as JsonRpcError,
|
|
43
43
|
J as KNOWN_SCRIPT_PREFIXES,
|
|
44
44
|
Xa as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
45
45
|
ka as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
46
46
|
j as MAX_REASONABLE_FEE_SATS,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
oe as MEMPOOL_API_URLS,
|
|
48
|
+
Re as OnChainBtcVaultStatus,
|
|
49
49
|
Wa as P2TR_INPUT_SIZE,
|
|
50
50
|
wa as PEGIN_AUTH_ANCHOR_OUTPUTS,
|
|
51
51
|
Ka as PEGIN_FIXED_OUTPUTS,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
ke as POST_WOTS_STATUSES,
|
|
53
|
+
We as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
54
54
|
na as PayoutManager,
|
|
55
|
-
|
|
55
|
+
Is as PeginAction,
|
|
56
56
|
Q as PeginManager,
|
|
57
57
|
Pa as ProtocolParamsABI,
|
|
58
58
|
c as PsbtSubstitutionError,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
$e as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
|
|
60
|
+
as as REFUND_MAX_FEE_FRACTION_NUMERATOR,
|
|
61
|
+
es as REFUND_MAX_FEE_RATE_SATS_VB,
|
|
62
|
+
ss as REFUND_VSIZE,
|
|
63
|
+
ts as RegisteredVaultVersionMismatchError,
|
|
64
|
+
we as RpcErrorCode,
|
|
65
65
|
Ga as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
|
|
66
|
-
|
|
66
|
+
me as ServerIdentityError,
|
|
67
67
|
q as TXID_RE,
|
|
68
68
|
Ya as TX_BUFFER_SIZE_OVERHEAD,
|
|
69
69
|
$a as UtxoNotAvailableError,
|
|
70
70
|
$ as VAULT_APP_NAME,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
Ke as VP_BATCH_MAX_SIZE,
|
|
72
|
+
Ge as VP_TERMINAL_FAILURE_STATUSES,
|
|
73
|
+
Ye as VP_TRANSIENT_STATUSES,
|
|
74
|
+
xe as VaultProviderRpcClient,
|
|
75
|
+
fe as ViemProtocolParamsReader,
|
|
76
|
+
be as ViemUniversalChallengerReader,
|
|
77
|
+
Ie as ViemVaultKeeperReader,
|
|
78
|
+
ie as ViemVaultRegistryReader,
|
|
79
|
+
Oe as VpResponseValidationError,
|
|
80
|
+
Ve as VpTokenRegistry,
|
|
81
81
|
Za as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
82
|
-
|
|
82
|
+
rs as activateVault,
|
|
83
83
|
Ia as applyChangeOutputPolicy,
|
|
84
84
|
T as assertPsbtUnsignedTxMatches,
|
|
85
85
|
ae as assertUtxosAvailable,
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
ve as batchPollByProvider,
|
|
87
|
+
os as buildAndBroadcastRefund,
|
|
88
88
|
s as buildChallengeAssertPsbt,
|
|
89
89
|
t as buildDepositorPayoutPsbt,
|
|
90
90
|
aa as buildFundingOutpointsCommitment,
|
|
@@ -93,101 +93,100 @@ export {
|
|
|
93
93
|
m as buildPeginInputPsbt,
|
|
94
94
|
A as buildPeginTxFromFundedPrePegin,
|
|
95
95
|
S as buildPrePeginPsbt,
|
|
96
|
-
|
|
96
|
+
O as buildRefundPsbt,
|
|
97
97
|
ea as buildVaultContext,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Ca as computeChangeOutputFeeSats,
|
|
98
|
+
Oa as calculateBtcTxHash,
|
|
99
|
+
Os as canPerformAction,
|
|
100
|
+
Va as computeChangeOutputFeeSats,
|
|
102
101
|
ua as computeHashlock,
|
|
103
|
-
|
|
102
|
+
va as computeMaxDeposit,
|
|
104
103
|
i as computeMinClaimValue,
|
|
105
104
|
n as computeMinPeginFee,
|
|
106
105
|
r as computeNumLocalChallengers,
|
|
107
|
-
|
|
106
|
+
Ca as computePeginBaseFeeSats,
|
|
108
107
|
sa as computeWotsBlockPublicKeysHash,
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
Ce as createAuthenticatedVpClient,
|
|
109
|
+
_ as createPayoutScript,
|
|
111
110
|
K as createTaprootScriptPathSignOptions,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
v as deriveBip86ScriptPubKeyHex,
|
|
112
|
+
C as deriveNativeSegwitAddress,
|
|
113
|
+
F as deriveTaprootAddress,
|
|
115
114
|
u as deriveVaultId,
|
|
116
115
|
ta as deriveVaultRoot,
|
|
117
116
|
ra as deriveWotsBlocksFromSeed,
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
h as ensureHexPrefix,
|
|
118
|
+
is as estimateRefundFeeSats,
|
|
120
119
|
oa as estimateSubmitPeginRequestBatchGas,
|
|
121
120
|
l as expandAuthAnchor,
|
|
122
121
|
p as expandHashlockSecret,
|
|
123
122
|
d as expandWotsSeed,
|
|
124
123
|
Sa as extractErrorData,
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
ee as extractInputsFromTransaction,
|
|
125
|
+
g as extractPayoutSignature,
|
|
127
126
|
x as extractPeginInputSignature,
|
|
128
127
|
f as finalizePeginInputPsbt,
|
|
129
|
-
|
|
128
|
+
se as findOverlappingPendingVaults,
|
|
129
|
+
U as formatSatoshisToBtc,
|
|
130
130
|
Ja as fundPeginTransaction,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
ne as getAddressTxs,
|
|
132
|
+
ue as getAddressUtxos,
|
|
133
|
+
_a as getContractErrorMessage,
|
|
134
|
+
Fa as getDustThreshold,
|
|
135
|
+
le as getMempoolApiUrl,
|
|
136
136
|
N as getNetwork,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
pe as getNetworkFees,
|
|
138
|
+
Vs as getPeginProtocolState,
|
|
139
|
+
ha as getPsbtInputFields,
|
|
140
|
+
Ua as getScriptType,
|
|
141
141
|
y as getSortedXOnlyPubkeys,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
de as getTipHeight,
|
|
143
|
+
Pe as getTxHex,
|
|
144
|
+
ce as getTxInfo,
|
|
145
|
+
Te as getUtxoInfo,
|
|
146
|
+
ga as handleContractError,
|
|
147
|
+
B as hexToUint8Array,
|
|
148
|
+
D as isAddressFromPublicKey,
|
|
149
|
+
ns as isDepositAmountValid,
|
|
150
|
+
Ra as isKnownContractError,
|
|
151
|
+
us as isPegoutTerminalStatus,
|
|
152
|
+
ls as isRecognizedPegoutStatus,
|
|
153
|
+
ps as isRegisteredVaultVersionMismatchError,
|
|
154
154
|
M as isValidHex,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
Je as isWotsMismatchError,
|
|
156
|
+
je as parseFundingOutpointsFromTx,
|
|
157
157
|
ja as parseUnfundedWasmTransaction,
|
|
158
158
|
qa as peginOutputCount,
|
|
159
|
-
|
|
159
|
+
Fe as primeVpTokenRegistry,
|
|
160
160
|
H as processPublicKeyToXOnly,
|
|
161
|
-
|
|
161
|
+
Ee as pushTx,
|
|
162
162
|
za as rateBasedTxBufferFee,
|
|
163
163
|
he as resolveProtocolAddresses,
|
|
164
|
-
|
|
165
|
-
te as selectUtxosForDeposit,
|
|
164
|
+
ds as runDepositorPresignFlow,
|
|
166
165
|
Na as selectUtxosForPegin,
|
|
167
166
|
ya as shouldAddChangeOutput,
|
|
168
|
-
|
|
167
|
+
Ps as signDepositorGraph,
|
|
169
168
|
L as stripHexPrefix,
|
|
170
|
-
|
|
169
|
+
cs as submitWotsPublicKey,
|
|
171
170
|
X as toXOnly,
|
|
172
171
|
k as uint8ArrayToHex,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
Ts as validateDepositAmount,
|
|
173
|
+
Es as validateMultiVaultDepositInputs,
|
|
174
|
+
Ae as validateOffchainParams,
|
|
175
|
+
As as validateOnChainParticipantKeys,
|
|
176
|
+
Se as validatePegInConfiguration,
|
|
177
|
+
Ss as validateProviderSelection,
|
|
179
178
|
_s as validateRemainingCapacity,
|
|
180
|
-
|
|
179
|
+
Ue as validateRequestDepositorClaimerArtifactsResponse,
|
|
181
180
|
la as validateSecretAgainstHashlock,
|
|
182
181
|
_e as validateTBVProtocolParams,
|
|
183
|
-
|
|
182
|
+
te as validateUtxosAvailable,
|
|
184
183
|
gs as validateVaultAmounts,
|
|
185
|
-
|
|
184
|
+
Rs as validateVaultProviderPubkey,
|
|
186
185
|
W as validateWalletPubkey,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
ms as verifyRegisteredVaultVersions,
|
|
187
|
+
Ne as verifyServerIdentity,
|
|
188
|
+
ye as vpTokenRegistry,
|
|
189
|
+
xs as waitForPeginStatus,
|
|
190
|
+
Ba as waitForTransactionReceiptSmartAware
|
|
192
191
|
};
|
|
193
192
|
//# sourceMappingURL=index.js.map
|