@babylonlabs-io/ts-sdk 0.67.0 → 0.68.1
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/PeginManager-Bsv6caG3.js +1466 -0
- package/dist/PeginManager-Bsv6caG3.js.map +1 -0
- package/dist/PeginManager-C5NWzGT7.cjs +2 -0
- package/dist/PeginManager-C5NWzGT7.cjs.map +1 -0
- package/dist/{batchPoll-cIxrSLLJ.js → batchPoll-Bc_UKaTz.js} +372 -421
- package/dist/batchPoll-Bc_UKaTz.js.map +1 -0
- package/dist/batchPoll-C9cZ5usJ.cjs +2 -0
- package/dist/batchPoll-C9cZ5usJ.cjs.map +1 -0
- package/dist/{bitcoin-d9eaaZB_.js → bitcoin-Ch_jxnDa.js} +3 -3
- package/dist/{bitcoin-d9eaaZB_.js.map → bitcoin-Ch_jxnDa.js.map} +1 -1
- package/dist/{buildAndBroadcastRefund-C4LiPATK.js → buildAndBroadcastRefund-CpMDJ8up.js} +142 -150
- package/dist/buildAndBroadcastRefund-CpMDJ8up.js.map +1 -0
- package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs +2 -0
- package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs.map +1 -0
- package/dist/challengeAssert-BNQ8sToz.js +64 -0
- package/dist/challengeAssert-BNQ8sToz.js.map +1 -0
- package/dist/challengeAssert-BrpC3-cQ.cjs +2 -0
- package/dist/challengeAssert-BrpC3-cQ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +246 -243
- package/dist/{mempoolApi-BxSINXIB.js → mempoolApi-71R_CNZa.js} +193 -117
- package/dist/mempoolApi-71R_CNZa.js.map +1 -0
- package/dist/mempoolApi-BJN9fGEd.cjs +2 -0
- package/dist/mempoolApi-BJN9fGEd.cjs.map +1 -0
- package/dist/{noPayout-BaZGRLD2.js → noPayout-CXn-geIS.js} +3 -3
- package/dist/{noPayout-BaZGRLD2.js.map → noPayout-CXn-geIS.js.map} +1 -1
- package/dist/{noPayout-CnQ1WLtr.cjs → noPayout-Ox27Td9x.cjs} +2 -2
- package/dist/{noPayout-CnQ1WLtr.cjs.map → noPayout-Ox27Td9x.cjs.map} +1 -1
- package/dist/{onChainBtcPubkey-DeF4cKoO.js → onChainBtcPubkey-BAHZyKQL.js} +2 -2
- package/dist/{onChainBtcPubkey-DeF4cKoO.js.map → onChainBtcPubkey-BAHZyKQL.js.map} +1 -1
- package/dist/{parseFundingOutpoints-pBRE11Hr.js → parseFundingOutpoints-CO-f6IHK.js} +2 -2
- package/dist/{parseFundingOutpoints-pBRE11Hr.js.map → parseFundingOutpoints-CO-f6IHK.js.map} +1 -1
- package/dist/{reservation-B4i_PQhY.js → reservation-CBAvoF3U.js} +2 -2
- package/dist/{reservation-B4i_PQhY.js.map → reservation-CBAvoF3U.js.map} +1 -1
- package/dist/{signPsbtsWithFallback-Bb66DfY5.js → signPsbtsWithFallback-Bv79gLFe.js} +122 -100
- package/dist/signPsbtsWithFallback-Bv79gLFe.js.map +1 -0
- package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs +2 -0
- package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs.map +1 -0
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +3 -3
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts +32 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts.map +1 -0
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts +9 -6
- package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts.map +1 -1
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts +54 -20
- package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts +2 -0
- package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts.map +1 -0
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts +41 -4
- package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
- package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts +10 -5
- package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +244 -241
- package/dist/tbv/core/managers/PayoutManager.d.ts +8 -2
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +7 -0
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts +11 -0
- package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts.map +1 -0
- package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts.map +1 -1
- package/dist/tbv/core/managers/pegin/index.d.ts +1 -0
- package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
- package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts +21 -0
- package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts.map +1 -0
- package/dist/tbv/core/primitives/challengers.d.ts +31 -5
- package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +2 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +43 -41
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +5 -0
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts +12 -0
- package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts +19 -7
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts +65 -0
- package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts +40 -0
- package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts +2 -1
- package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts +13 -0
- package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/utils/taproot.d.ts +29 -0
- package/dist/tbv/core/primitives/utils/taproot.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +2 -2
- package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +2 -2
- package/dist/tbv/core/utils/index.js +2 -2
- package/dist/tbv/core/utils/witness/witnessStack.d.ts +24 -0
- package/dist/tbv/core/utils/witness/witnessStack.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +244 -241
- package/dist/testing/MockBitcoinWallet.d.ts +9 -0
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
- package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts +2 -0
- package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts.map +1 -0
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +136 -45
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/signBip322P2wpkhWitness.d.ts +25 -0
- package/dist/testing/signBip322P2wpkhWitness.d.ts.map +1 -0
- package/dist/{toRefundInputs-BY_fcvrv.js → toRefundInputs-4UJfSVEz.js} +6 -6
- package/dist/{toRefundInputs-BY_fcvrv.js.map → toRefundInputs-4UJfSVEz.js.map} +1 -1
- package/dist/{toRefundInputs-DYL9C-aG.cjs → toRefundInputs-DgDhx_Ut.cjs} +2 -2
- package/dist/{toRefundInputs-DYL9C-aG.cjs.map → toRefundInputs-DgDhx_Ut.cjs.map} +1 -1
- package/dist/verifyKeyPathSchnorrSignature-C6Cmk0R1.js +372 -0
- package/dist/verifyKeyPathSchnorrSignature-C6Cmk0R1.js.map +1 -0
- package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs +2 -0
- package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js +931 -0
- package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +1 -0
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +2 -0
- package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/PeginManager-BBl4xkWz.js +0 -1359
- package/dist/PeginManager-BBl4xkWz.js.map +0 -1
- package/dist/PeginManager-p-ajwSxG.cjs +0 -2
- package/dist/PeginManager-p-ajwSxG.cjs.map +0 -1
- package/dist/batchPoll-6L5oToGr.cjs +0 -2
- package/dist/batchPoll-6L5oToGr.cjs.map +0 -1
- package/dist/batchPoll-cIxrSLLJ.js.map +0 -1
- package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +0 -1
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +0 -2
- package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +0 -1
- package/dist/challengeAssert-BFRE2DM-.cjs +0 -2
- package/dist/challengeAssert-BFRE2DM-.cjs.map +0 -1
- package/dist/challengeAssert-C7PzyJ7g.js +0 -75
- package/dist/challengeAssert-C7PzyJ7g.js.map +0 -1
- package/dist/mempoolApi-BxSINXIB.js.map +0 -1
- package/dist/mempoolApi-CXfr-L6x.cjs +0 -2
- package/dist/mempoolApi-CXfr-L6x.cjs.map +0 -1
- package/dist/peginInput-Ci921gTl.cjs +0 -2
- package/dist/peginInput-Ci921gTl.cjs.map +0 -1
- package/dist/peginInput-HQPWZfly.js +0 -123
- package/dist/peginInput-HQPWZfly.js.map +0 -1
- package/dist/signPsbtsWithFallback-Bb66DfY5.js.map +0 -1
- package/dist/signPsbtsWithFallback-PTgWxsG3.cjs +0 -2
- package/dist/signPsbtsWithFallback-PTgWxsG3.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs +0 -2
- package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs.map +0 -1
- package/dist/verifyScriptPathSchnorrSignature-i-koT139.js +0 -817
- package/dist/verifyScriptPathSchnorrSignature-i-koT139.js.map +0 -1
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
var me = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var ve = (e, t, r) => t in e ? me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var _ = (e, t, r) => ve(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { B as re } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
|
|
5
|
-
import { e as ye, v as be, s as
|
|
6
|
-
import { v as we, d as ke, s as Ee, P as xe, a as Te } from "./signPsbtsWithFallback-
|
|
5
|
+
import { e as ye, v as be, s as m, u as ne, p as L, c as x, f as C } from "./bitcoin-Ch_jxnDa.js";
|
|
6
|
+
import { v as we, d as ke, s as Ee, P as xe, a as Te } from "./signPsbtsWithFallback-Bv79gLFe.js";
|
|
7
7
|
import { zeroAddress as Ce } from "viem";
|
|
8
|
-
import { D as T, c as Se, b as Ae, R as
|
|
9
|
-
import { Transaction as A, Psbt as
|
|
10
|
-
import {
|
|
11
|
-
import { c as
|
|
8
|
+
import { D as T, c as Se, b as Ae, R as Be, d as oe } from "./json-rpc-client-DuUARJvV.js";
|
|
9
|
+
import { Transaction as A, Psbt as Re } from "bitcoinjs-lib";
|
|
10
|
+
import { j as _e, d as $e, f as H, e as D, g as F } from "./verifyScriptPathSchnorrSignature-Dy9gF5RF.js";
|
|
11
|
+
import { c as Ie, a as Ve, b as Ke } from "./noPayout-CXn-geIS.js";
|
|
12
12
|
import { c as M } from "./signing-DaLvGwQe.js";
|
|
13
|
-
import { a as X } from "./onChainBtcPubkey-
|
|
14
|
-
import { a as
|
|
15
|
-
const
|
|
16
|
-
function
|
|
13
|
+
import { a as X } from "./onChainBtcPubkey-BAHZyKQL.js";
|
|
14
|
+
import { a as Ne } from "./constants-GjWXdaqV.js";
|
|
15
|
+
const Oe = /^0x[0-9a-fA-F]{64}$/, He = /^0x[0-9a-fA-F]{40}$/, De = /^0x([0-9a-fA-F]{2})*$/;
|
|
16
|
+
function $(e, t) {
|
|
17
17
|
if (e.length !== 66)
|
|
18
18
|
throw new Error(
|
|
19
19
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
20
20
|
);
|
|
21
|
-
if (!
|
|
21
|
+
if (!Oe.test(e))
|
|
22
22
|
throw new Error(
|
|
23
23
|
`${t} must contain only hex characters after the 0x prefix`
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
if (!
|
|
26
|
+
function Fe(e, t) {
|
|
27
|
+
if (!He.test(e))
|
|
28
28
|
throw new Error(
|
|
29
29
|
`${t} must be a 20-byte 0x-prefixed hex address (42 chars)`
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
if (!
|
|
32
|
+
function Me(e, t) {
|
|
33
|
+
if (!De.test(e))
|
|
34
34
|
throw new Error(
|
|
35
35
|
`${t} must be a 0x-prefixed hex string with an even number of hex chars`
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
38
|
+
function ae(e) {
|
|
39
|
+
Fe(e.btcVaultRegistryAddress, "btcVaultRegistryAddress"), $(e.vaultId, "vaultId");
|
|
40
40
|
const t = ye(e.secret);
|
|
41
|
-
if (
|
|
41
|
+
if ($(t, "secret"), e.hashlock !== void 0 && ($(e.hashlock, "hashlock"), !we(t, e.hashlock)))
|
|
42
42
|
throw new Error(
|
|
43
43
|
"Invalid secret: SHA256(secret) does not match the provided hashlock"
|
|
44
44
|
);
|
|
@@ -54,13 +54,13 @@ async function Ft(e) {
|
|
|
54
54
|
signal: o
|
|
55
55
|
} = e;
|
|
56
56
|
o == null || o.throwIfAborted();
|
|
57
|
-
const a =
|
|
57
|
+
const a = ae({
|
|
58
58
|
btcVaultRegistryAddress: t,
|
|
59
59
|
vaultId: r,
|
|
60
60
|
secret: e.secret,
|
|
61
61
|
hashlock: n
|
|
62
62
|
});
|
|
63
|
-
return
|
|
63
|
+
return Me(s, "activationMetadata"), l({
|
|
64
64
|
address: t,
|
|
65
65
|
abi: re,
|
|
66
66
|
functionName: "activateVaultWithSecret",
|
|
@@ -70,7 +70,7 @@ async function Ft(e) {
|
|
|
70
70
|
async function Mt(e) {
|
|
71
71
|
const { btcVaultRegistryAddress: t, vaultId: r, hashlock: n, writeContract: s, signal: l } = e;
|
|
72
72
|
l == null || l.throwIfAborted();
|
|
73
|
-
const o =
|
|
73
|
+
const o = ae({
|
|
74
74
|
btcVaultRegistryAddress: t,
|
|
75
75
|
vaultId: r,
|
|
76
76
|
secret: e.secret,
|
|
@@ -83,8 +83,8 @@ async function Mt(e) {
|
|
|
83
83
|
args: [r, o]
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
class
|
|
86
|
+
const Ue = 8, Le = 6e3, ze = 10 * 6e4, Xe = 10;
|
|
87
|
+
class se extends Error {
|
|
88
88
|
constructor(t) {
|
|
89
89
|
super(t), this.name = "PeginRegistrationMissingError";
|
|
90
90
|
}
|
|
@@ -94,24 +94,24 @@ class ie extends Error {
|
|
|
94
94
|
super(t), this.name = "PeginRegistrationNotFinalError";
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return e instanceof
|
|
97
|
+
function Ge(e) {
|
|
98
|
+
return e instanceof se || e instanceof Error && e.name === "PeginRegistrationMissingError";
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function Ut(e) {
|
|
101
101
|
return e instanceof ie || e instanceof Error && e.name === "PeginRegistrationNotFinalError";
|
|
102
102
|
}
|
|
103
103
|
function G(e) {
|
|
104
104
|
const { currentBlock: t, createdAtBlock: r } = e, n = t - r + 1n;
|
|
105
105
|
return n < 0n ? 0 : Number(n);
|
|
106
106
|
}
|
|
107
|
-
async function
|
|
107
|
+
async function Lt(e) {
|
|
108
108
|
const {
|
|
109
109
|
vaultRegistryReader: t,
|
|
110
110
|
getBlockNumber: r,
|
|
111
111
|
vaultIds: n,
|
|
112
|
-
required: s =
|
|
112
|
+
required: s = Ue,
|
|
113
113
|
pollIntervalMs: l = Le,
|
|
114
|
-
timeoutMs: o =
|
|
114
|
+
timeoutMs: o = ze,
|
|
115
115
|
signal: a,
|
|
116
116
|
onProgress: i
|
|
117
117
|
} = e;
|
|
@@ -132,13 +132,13 @@ async function Ut(e) {
|
|
|
132
132
|
);
|
|
133
133
|
try {
|
|
134
134
|
const d = await r(), g = await Promise.all(
|
|
135
|
-
n.map((
|
|
135
|
+
n.map((f) => t.getVaultBasicInfo(f))
|
|
136
136
|
), b = g.findIndex(
|
|
137
|
-
(
|
|
137
|
+
(f) => f.depositor === Ce || f.createdAt === 0n
|
|
138
138
|
);
|
|
139
139
|
if (b !== -1) {
|
|
140
|
-
if (c += 1, !h && c >
|
|
141
|
-
throw new
|
|
140
|
+
if (c += 1, !h && c > Xe)
|
|
141
|
+
throw new se(
|
|
142
142
|
`Vault ${n[b]} is still not visible on-chain after ${c} reads — the registration does not exist.`
|
|
143
143
|
);
|
|
144
144
|
console.warn(
|
|
@@ -146,22 +146,22 @@ async function Ut(e) {
|
|
|
146
146
|
), i == null || i({ confirmations: 0, required: s });
|
|
147
147
|
} else {
|
|
148
148
|
h = !0, c = 0, p = void 0;
|
|
149
|
-
let
|
|
149
|
+
let f = g[0], P = G({
|
|
150
150
|
currentBlock: d,
|
|
151
151
|
createdAtBlock: g[0].createdAt
|
|
152
152
|
});
|
|
153
153
|
for (const w of g.slice(1)) {
|
|
154
|
-
const
|
|
154
|
+
const v = G({
|
|
155
155
|
currentBlock: d,
|
|
156
156
|
createdAtBlock: w.createdAt
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
v < P && (P = v, f = w);
|
|
159
159
|
}
|
|
160
|
-
if (i == null || i({ confirmations:
|
|
161
|
-
return { confirmations:
|
|
160
|
+
if (i == null || i({ confirmations: P, required: s }), P >= s)
|
|
161
|
+
return { confirmations: P, basicInfo: f };
|
|
162
162
|
}
|
|
163
163
|
} catch (d) {
|
|
164
|
-
if (
|
|
164
|
+
if (Ge(d))
|
|
165
165
|
throw d;
|
|
166
166
|
console.warn(
|
|
167
167
|
`Registration-depth read failed (retrying in ${l}ms): ` + (d instanceof Error ? d.message : String(d))
|
|
@@ -169,41 +169,29 @@ async function Ut(e) {
|
|
|
169
169
|
}
|
|
170
170
|
await new Promise((d, g) => {
|
|
171
171
|
const b = () => {
|
|
172
|
-
clearTimeout(
|
|
172
|
+
clearTimeout(f), g(
|
|
173
173
|
new Error(
|
|
174
174
|
`Aborted while waiting for peg-in registration depth (${n.length} vault(s))`
|
|
175
175
|
)
|
|
176
176
|
);
|
|
177
|
-
},
|
|
177
|
+
}, f = setTimeout(() => {
|
|
178
178
|
a == null || a.removeEventListener("abort", b), d();
|
|
179
179
|
}, l);
|
|
180
180
|
a == null || a.addEventListener("abort", b, { once: !0 });
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const j = 1,
|
|
185
|
-
function je(e, t) {
|
|
186
|
-
const r = f(t).toLowerCase(), s = e.map((l) => f(l).toLowerCase()).filter((l) => l !== r);
|
|
187
|
-
if (s.length === 0)
|
|
188
|
-
throw new Error(
|
|
189
|
-
"Cannot derive localChallengers: vault keeper set is empty (or contains only the depositor)"
|
|
190
|
-
);
|
|
191
|
-
if (new Set(s).size !== s.length)
|
|
192
|
-
throw new Error(
|
|
193
|
-
"Cannot derive localChallengers: duplicate vaultKeeper key — signing context is misconfigured"
|
|
194
|
-
);
|
|
195
|
-
return s;
|
|
196
|
-
}
|
|
184
|
+
const j = 1, je = 1;
|
|
197
185
|
function qe(e, t, r) {
|
|
198
186
|
const n = r.map(
|
|
199
|
-
(c) =>
|
|
187
|
+
(c) => m(c).toLowerCase()
|
|
200
188
|
), s = t.filter((c) => n.includes(c));
|
|
201
189
|
if (s.length > 0)
|
|
202
190
|
throw new Error(
|
|
203
191
|
`Cannot validate challenger set: vault keepers and universal challengers overlap (${s.join(", ")})`
|
|
204
192
|
);
|
|
205
193
|
const l = [...t, ...n], o = e.map(
|
|
206
|
-
(c) =>
|
|
194
|
+
(c) => m(c.challenger_pubkey).toLowerCase()
|
|
207
195
|
), a = new Set(o);
|
|
208
196
|
if (a.size !== o.length)
|
|
209
197
|
throw new Error(
|
|
@@ -232,10 +220,12 @@ function I(e, t, r, n, s) {
|
|
|
232
220
|
);
|
|
233
221
|
}
|
|
234
222
|
async function We(e, t, r) {
|
|
235
|
-
const n = [], s = [], l = [], o =
|
|
236
|
-
r.
|
|
237
|
-
r.depositorBtcPubkey
|
|
238
|
-
|
|
223
|
+
const n = [], s = [], l = [], o = _e({
|
|
224
|
+
claimerBtcPubkey: r.depositorBtcPubkey,
|
|
225
|
+
depositorBtcPubkey: r.depositorBtcPubkey,
|
|
226
|
+
vaultProviderBtcPubkey: r.vaultProviderBtcPubkey,
|
|
227
|
+
vaultKeeperBtcPubkeys: r.vaultKeeperBtcPubkeys
|
|
228
|
+
});
|
|
239
229
|
qe(
|
|
240
230
|
e.challenger_presign_data,
|
|
241
231
|
o,
|
|
@@ -257,9 +247,10 @@ async function We(e, t, r) {
|
|
|
257
247
|
network: r.network,
|
|
258
248
|
claimerBtcPubkey: r.depositorBtcPubkey,
|
|
259
249
|
registeredPayoutScriptPubKey: r.registeredPayoutScriptPubKey,
|
|
260
|
-
commissionBps:
|
|
250
|
+
commissionBps: je,
|
|
261
251
|
protocolFeeRate: r.protocolFeeRate,
|
|
262
|
-
|
|
252
|
+
councilMembers: r.councilMembers,
|
|
253
|
+
councilQuorum: r.councilQuorum
|
|
263
254
|
});
|
|
264
255
|
n.push(a.psbtHex), s.push(
|
|
265
256
|
M(
|
|
@@ -267,11 +258,11 @@ async function We(e, t, r) {
|
|
|
267
258
|
j
|
|
268
259
|
)
|
|
269
260
|
);
|
|
270
|
-
const i =
|
|
271
|
-
|
|
261
|
+
const i = m(r.depositorBtcPubkey), u = A.fromHex(
|
|
262
|
+
m(e.assert_tx.tx_hex)
|
|
272
263
|
);
|
|
273
264
|
for (const h of e.challenger_presign_data) {
|
|
274
|
-
const c =
|
|
265
|
+
const c = m(h.challenger_pubkey), p = n.length, d = await Ye({
|
|
275
266
|
challenger: h,
|
|
276
267
|
challengerPubkey: c,
|
|
277
268
|
claimerPubkey: i,
|
|
@@ -300,17 +291,17 @@ async function Ye(e) {
|
|
|
300
291
|
assertTxParsed: l,
|
|
301
292
|
ctx: o
|
|
302
293
|
} = e;
|
|
303
|
-
|
|
294
|
+
Ie(
|
|
304
295
|
t.nopayout_tx.tx_hex,
|
|
305
296
|
r,
|
|
306
297
|
o.network
|
|
307
298
|
);
|
|
308
299
|
const a = A.fromHex(
|
|
309
|
-
|
|
300
|
+
m(t.nopayout_tx.tx_hex)
|
|
310
301
|
), i = A.fromHex(
|
|
311
|
-
|
|
302
|
+
m(t.challenge_assert_x_tx.tx_hex)
|
|
312
303
|
), u = A.fromHex(
|
|
313
|
-
|
|
304
|
+
m(t.challenge_assert_y_tx.tx_hex)
|
|
314
305
|
);
|
|
315
306
|
if (a.ins.length !== 3)
|
|
316
307
|
throw new Error(
|
|
@@ -343,7 +334,7 @@ async function Ye(e) {
|
|
|
343
334
|
script_pubkey: ne(new Uint8Array(c.script)),
|
|
344
335
|
value: c.value
|
|
345
336
|
}));
|
|
346
|
-
return
|
|
337
|
+
return Ve({
|
|
347
338
|
noPayoutTxHex: t.nopayout_tx.tx_hex,
|
|
348
339
|
challengerPubkey: r,
|
|
349
340
|
prevouts: h,
|
|
@@ -396,7 +387,7 @@ function Je(e, t, r) {
|
|
|
396
387
|
async function Ze(e) {
|
|
397
388
|
const { depositorGraph: t, btcWallet: r, signingContext: n } = e, s = await r.getPublicKeyHex(), { depositorPubkey: l } = be(
|
|
398
389
|
s,
|
|
399
|
-
|
|
390
|
+
m(n.depositorBtcPubkey)
|
|
400
391
|
), { psbtHexes: o, signOptions: a, challengerEntries: i } = await We(
|
|
401
392
|
t,
|
|
402
393
|
s,
|
|
@@ -451,7 +442,7 @@ async function ue(e) {
|
|
|
451
442
|
`Pegin ${r.slice(0, 8)}… reached terminal status "${u}" while waiting for ${[...n].join(", ")}`
|
|
452
443
|
);
|
|
453
444
|
} catch (i) {
|
|
454
|
-
if (!(i instanceof Ae && i.code ===
|
|
445
|
+
if (!(i instanceof Ae && i.code === Be.PEGIN_NOT_FOUND))
|
|
455
446
|
throw i;
|
|
456
447
|
}
|
|
457
448
|
await new Promise((i, u) => {
|
|
@@ -479,13 +470,13 @@ const tt = 1200 * 1e3, le = /* @__PURE__ */ new Set([
|
|
|
479
470
|
]);
|
|
480
471
|
function nt(e) {
|
|
481
472
|
return e.map((t) => ({
|
|
482
|
-
claimerPubkeyXOnly:
|
|
473
|
+
claimerPubkeyXOnly: L(t.claimer_pubkey),
|
|
483
474
|
payoutTxHex: t.payout_tx.tx_hex,
|
|
484
475
|
assertTxHex: t.assert_tx.tx_hex
|
|
485
476
|
}));
|
|
486
477
|
}
|
|
487
478
|
function E(e) {
|
|
488
|
-
return
|
|
479
|
+
return L(e).toLowerCase();
|
|
489
480
|
}
|
|
490
481
|
function ot(e, t) {
|
|
491
482
|
const r = (i, u, h) => {
|
|
@@ -525,7 +516,7 @@ function ot(e, t) {
|
|
|
525
516
|
t.vaultProviderBtcPubkey
|
|
526
517
|
);
|
|
527
518
|
}
|
|
528
|
-
function
|
|
519
|
+
function at(e, t, r, n) {
|
|
529
520
|
const s = E(n), l = [
|
|
530
521
|
E(t),
|
|
531
522
|
...r.map(E)
|
|
@@ -565,12 +556,13 @@ function q(e, t) {
|
|
|
565
556
|
claimerBtcPubkey: e.claimerPubkeyXOnly,
|
|
566
557
|
commissionBps: t.commissionBps,
|
|
567
558
|
protocolFeeRate: t.protocolFeeRate,
|
|
568
|
-
|
|
559
|
+
councilMembers: t.councilMembers,
|
|
560
|
+
councilQuorum: t.councilQuorum,
|
|
569
561
|
vkClaimerPayoutScriptPubKeys: t.vkClaimerPayoutScriptPubKeys,
|
|
570
562
|
vpCommissionScriptPubKey: t.vpCommissionScriptPubKey
|
|
571
563
|
};
|
|
572
564
|
}
|
|
573
|
-
async function
|
|
565
|
+
async function st(e, t, r, n) {
|
|
574
566
|
const s = new xe({
|
|
575
567
|
network: t.network,
|
|
576
568
|
btcWallet: e
|
|
@@ -635,22 +627,22 @@ async function zt(e) {
|
|
|
635
627
|
);
|
|
636
628
|
u == null || u.throwIfAborted();
|
|
637
629
|
const d = E(l);
|
|
638
|
-
|
|
630
|
+
at(
|
|
639
631
|
p.txs,
|
|
640
632
|
o.vaultProviderBtcPubkey,
|
|
641
633
|
o.vaultKeeperBtcPubkeys,
|
|
642
634
|
l
|
|
643
635
|
);
|
|
644
636
|
const g = p.txs.filter(
|
|
645
|
-
(
|
|
646
|
-
), b = nt(g),
|
|
637
|
+
(v) => E(v.claimer_pubkey) !== d
|
|
638
|
+
), b = nt(g), f = await st(
|
|
647
639
|
n,
|
|
648
640
|
o,
|
|
649
641
|
b,
|
|
650
642
|
h
|
|
651
643
|
);
|
|
652
644
|
u == null || u.throwIfAborted();
|
|
653
|
-
const
|
|
645
|
+
const P = await Ze({
|
|
654
646
|
depositorGraph: p.depositor_graph,
|
|
655
647
|
btcWallet: n,
|
|
656
648
|
signingContext: {
|
|
@@ -672,13 +664,13 @@ async function zt(e) {
|
|
|
672
664
|
}
|
|
673
665
|
});
|
|
674
666
|
u == null || u.throwIfAborted();
|
|
675
|
-
const w = { ...
|
|
676
|
-
w[
|
|
667
|
+
const w = { ...f };
|
|
668
|
+
w[m(l)] = P.payout_signatures, await r.submitDepositorPresignatures(
|
|
677
669
|
{
|
|
678
670
|
pegin_txid: s,
|
|
679
671
|
depositor_pk: l,
|
|
680
672
|
signatures: w,
|
|
681
|
-
depositor_claimer_presignatures:
|
|
673
|
+
depositor_claimer_presignatures: P
|
|
682
674
|
},
|
|
683
675
|
u
|
|
684
676
|
);
|
|
@@ -851,7 +843,7 @@ async function jt(e) {
|
|
|
851
843
|
),
|
|
852
844
|
r.getCurrentVaultKeepersVersion(l),
|
|
853
845
|
n.getLatestUniversalChallengersVersion()
|
|
854
|
-
]), [b,
|
|
846
|
+
]), [b, f] = await Promise.all([
|
|
855
847
|
r.getVaultKeepersByVersion(
|
|
856
848
|
l,
|
|
857
849
|
d
|
|
@@ -859,10 +851,10 @@ async function jt(e) {
|
|
|
859
851
|
n.getUniversalChallengersByVersion(
|
|
860
852
|
g
|
|
861
853
|
)
|
|
862
|
-
]),
|
|
854
|
+
]), P = {
|
|
863
855
|
vaultProvider: x(p),
|
|
864
856
|
vaultKeepers: Y(b.map((k) => k.btcPubKey)),
|
|
865
|
-
universalChallengers: Y(
|
|
857
|
+
universalChallengers: Y(f.map((k) => k.btcPubKey))
|
|
866
858
|
}, w = await ht({
|
|
867
859
|
operationKeyReader: u,
|
|
868
860
|
query: {
|
|
@@ -870,9 +862,9 @@ async function jt(e) {
|
|
|
870
862
|
vaultProviderGenesisBtcPubkey: `0x${p}`,
|
|
871
863
|
applicationEntryPoint: l,
|
|
872
864
|
vaultKeepers: b,
|
|
873
|
-
universalChallengers:
|
|
865
|
+
universalChallengers: f
|
|
874
866
|
}
|
|
875
|
-
}),
|
|
867
|
+
}), v = {
|
|
876
868
|
vaultProvider: w.vaultProvider.operationBtcPubkey,
|
|
877
869
|
vaultKeepers: [...w.vaultKeeperOperationKeysSorted],
|
|
878
870
|
universalChallengers: [
|
|
@@ -880,43 +872,43 @@ async function jt(e) {
|
|
|
880
872
|
]
|
|
881
873
|
}, S = lt(
|
|
882
874
|
o,
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
),
|
|
875
|
+
P.vaultProvider,
|
|
876
|
+
v.vaultProvider
|
|
877
|
+
), B = Q(
|
|
886
878
|
a,
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
),
|
|
879
|
+
P.vaultKeepers,
|
|
880
|
+
v.vaultKeepers
|
|
881
|
+
), R = Q(
|
|
890
882
|
i,
|
|
891
|
-
|
|
892
|
-
|
|
883
|
+
P.universalChallengers,
|
|
884
|
+
v.universalChallengers
|
|
893
885
|
);
|
|
894
886
|
if (!V(S))
|
|
895
887
|
throw new Error(
|
|
896
888
|
`Vault provider BTC pubkey indexer hint does not match BTCVaultRegistry for ${s}. Refresh and try again.`
|
|
897
889
|
);
|
|
898
|
-
if (!V(
|
|
890
|
+
if (!V(B))
|
|
899
891
|
throw new Error(
|
|
900
892
|
`Vault keeper BTC pubkeys (v${d}) indexer set does not match ApplicationRegistry on-chain set. Refresh and try again.`
|
|
901
893
|
);
|
|
902
|
-
if (!V(
|
|
894
|
+
if (!V(R))
|
|
903
895
|
throw new Error(
|
|
904
896
|
`Universal challenger BTC pubkeys (v${g}) indexer set does not match ProtocolParams on-chain set. Refresh and try again.`
|
|
905
897
|
);
|
|
906
|
-
const y = [S,
|
|
907
|
-
if (
|
|
898
|
+
const y = [S, B, R], Pe = y.some((k) => k.registration && !k.operation), z = y.some((k) => k.operation && !k.registration);
|
|
899
|
+
if (Pe && z) {
|
|
908
900
|
const k = `Indexer participant hints are internally inconsistent for vault provider ${s}: some roles match the registration keys while others match the rotated operation keys.`;
|
|
909
901
|
throw c == null || c(k), new Error(`${k} Refresh and try again.`);
|
|
910
902
|
}
|
|
911
903
|
return z && (h == null || h(
|
|
912
904
|
`Indexer is serving rotated operation keys for vault provider ${s}`
|
|
913
905
|
)), {
|
|
914
|
-
vaultProviderBtcPubkeyXOnly:
|
|
915
|
-
vaultKeeperBtcPubkeysSorted:
|
|
916
|
-
universalChallengerBtcPubkeysSorted:
|
|
906
|
+
vaultProviderBtcPubkeyXOnly: v.vaultProvider,
|
|
907
|
+
vaultKeeperBtcPubkeysSorted: v.vaultKeepers,
|
|
908
|
+
universalChallengerBtcPubkeysSorted: v.universalChallengers,
|
|
917
909
|
expectedAppVaultKeepersVersion: d,
|
|
918
910
|
expectedUniversalChallengersVersion: g,
|
|
919
|
-
registrationKeys:
|
|
911
|
+
registrationKeys: P,
|
|
920
912
|
participantKeys: w
|
|
921
913
|
};
|
|
922
914
|
}
|
|
@@ -999,13 +991,13 @@ function gt(e, t, r) {
|
|
|
999
991
|
return { valid: !0 };
|
|
1000
992
|
}
|
|
1001
993
|
function ft(e) {
|
|
1002
|
-
const t =
|
|
994
|
+
const t = m(e);
|
|
1003
995
|
return dt(t) ? { valid: !0 } : {
|
|
1004
996
|
valid: !1,
|
|
1005
997
|
error: "Invalid pubkey format: must be 64 hex characters (32-byte x-only public key, no 0x prefix)"
|
|
1006
998
|
};
|
|
1007
999
|
}
|
|
1008
|
-
function
|
|
1000
|
+
function Pt(e) {
|
|
1009
1001
|
if (!e || e.length === 0)
|
|
1010
1002
|
throw new Error(
|
|
1011
1003
|
"No vault keepers available. The system requires at least one vault keeper to create a deposit."
|
|
@@ -1017,7 +1009,7 @@ function mt(e) {
|
|
|
1017
1009
|
"No universal challengers available. The system requires at least one universal challenger to create a deposit."
|
|
1018
1010
|
);
|
|
1019
1011
|
}
|
|
1020
|
-
function
|
|
1012
|
+
function vt(e) {
|
|
1021
1013
|
if (e.length === 0)
|
|
1022
1014
|
throw new Error("No spendable UTXOs available");
|
|
1023
1015
|
}
|
|
@@ -1040,7 +1032,7 @@ function Jt(e) {
|
|
|
1040
1032
|
const u = ft(n);
|
|
1041
1033
|
if (!u.valid)
|
|
1042
1034
|
throw new Error(u.error);
|
|
1043
|
-
|
|
1035
|
+
Pt(s), mt(l), vt(r);
|
|
1044
1036
|
}
|
|
1045
1037
|
class he extends Error {
|
|
1046
1038
|
constructor(t) {
|
|
@@ -1143,13 +1135,13 @@ function or(e) {
|
|
|
1143
1135
|
class bt extends Error {
|
|
1144
1136
|
constructor(r, n) {
|
|
1145
1137
|
super(`Refund not yet mature (BIP68 not final): ${n.message}`);
|
|
1146
|
-
|
|
1147
|
-
|
|
1138
|
+
_(this, "vaultId");
|
|
1139
|
+
_(this, "cause");
|
|
1148
1140
|
this.name = "BIP68NotMatureError", this.vaultId = r, this.cause = n;
|
|
1149
1141
|
}
|
|
1150
1142
|
}
|
|
1151
1143
|
const wt = /^0x[0-9a-fA-F]{64}$/, kt = /^(?:0x)?(?:[0-9a-fA-F]{2})+$/, ge = /^(?:0x)?(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{66})$/, fe = 160, Z = 2e3, ee = 10n, te = 100n;
|
|
1152
|
-
function
|
|
1144
|
+
function ar(e) {
|
|
1153
1145
|
if (!Number.isFinite(e) || e <= 0)
|
|
1154
1146
|
throw new Error(
|
|
1155
1147
|
`feeRateSatsVb must be a positive finite number, got ${e}`
|
|
@@ -1157,7 +1149,7 @@ function sr(e) {
|
|
|
1157
1149
|
return BigInt(Math.ceil(e * fe));
|
|
1158
1150
|
}
|
|
1159
1151
|
const Et = 1, xt = /non-BIP68-final/i;
|
|
1160
|
-
function
|
|
1152
|
+
function U(e, t) {
|
|
1161
1153
|
if (e.length !== 66)
|
|
1162
1154
|
throw new Error(
|
|
1163
1155
|
`${t} must be 32 bytes (66 hex chars with 0x prefix), got length ${e.length}`
|
|
@@ -1172,7 +1164,7 @@ function O(e, t) {
|
|
|
1172
1164
|
throw new Error(`${t} must be a non-negative integer, got ${e}`);
|
|
1173
1165
|
}
|
|
1174
1166
|
function Tt(e) {
|
|
1175
|
-
if (
|
|
1167
|
+
if (U(e.hashlock, "hashlock"), !Number.isInteger(e.htlcVout) || e.htlcVout < 0)
|
|
1176
1168
|
throw new Error(
|
|
1177
1169
|
`htlcVout must be a non-negative integer, got ${e.htlcVout}`
|
|
1178
1170
|
);
|
|
@@ -1184,7 +1176,7 @@ function Tt(e) {
|
|
|
1184
1176
|
);
|
|
1185
1177
|
for (let r = 0; r < e.batch.length; r++) {
|
|
1186
1178
|
const n = e.batch[r];
|
|
1187
|
-
if (
|
|
1179
|
+
if (U(n.hashlock, `batch[${r}].hashlock`), !Number.isInteger(n.htlcVout) || n.htlcVout !== r)
|
|
1188
1180
|
throw new Error(
|
|
1189
1181
|
`batch[${r}].htlcVout must equal ${r} (contiguous vout-ordered vector), got ${n.htlcVout}`
|
|
1190
1182
|
);
|
|
@@ -1205,7 +1197,7 @@ function Tt(e) {
|
|
|
1205
1197
|
if (O(e.offchainParamsVersion, "offchainParamsVersion"), O(e.appVaultKeepersVersion, "appVaultKeepersVersion"), O(
|
|
1206
1198
|
e.universalChallengersVersion,
|
|
1207
1199
|
"universalChallengersVersion"
|
|
1208
|
-
),
|
|
1200
|
+
), Ne(
|
|
1209
1201
|
e.vaultCoreVersion,
|
|
1210
1202
|
"VaultRefundData.vaultCoreVersion"
|
|
1211
1203
|
), typeof e.unsignedPrePeginTxHex != "string" || e.unsignedPrePeginTxHex.length === 0)
|
|
@@ -1248,7 +1240,7 @@ function Ct(e) {
|
|
|
1248
1240
|
);
|
|
1249
1241
|
}
|
|
1250
1242
|
function St(e) {
|
|
1251
|
-
const t =
|
|
1243
|
+
const t = Re.fromHex(e);
|
|
1252
1244
|
try {
|
|
1253
1245
|
t.finalizeAllInputs();
|
|
1254
1246
|
} catch (r) {
|
|
@@ -1258,7 +1250,7 @@ function St(e) {
|
|
|
1258
1250
|
}
|
|
1259
1251
|
return t.extractTransaction().toHex();
|
|
1260
1252
|
}
|
|
1261
|
-
async function
|
|
1253
|
+
async function sr(e) {
|
|
1262
1254
|
const {
|
|
1263
1255
|
vaultId: t,
|
|
1264
1256
|
readVault: r,
|
|
@@ -1268,7 +1260,7 @@ async function ar(e) {
|
|
|
1268
1260
|
broadcastTx: o,
|
|
1269
1261
|
signal: a
|
|
1270
1262
|
} = e;
|
|
1271
|
-
a == null || a.throwIfAborted(),
|
|
1263
|
+
a == null || a.throwIfAborted(), U(t, "vaultId");
|
|
1272
1264
|
const i = await r();
|
|
1273
1265
|
Tt(i), a == null || a.throwIfAborted();
|
|
1274
1266
|
const u = await n(i);
|
|
@@ -1284,34 +1276,34 @@ async function ar(e) {
|
|
|
1284
1276
|
`Refund fee ${h} sats exceeds the per-vault safety cap of ${c} sats (${ee}/${te} of vault.amount=${i.amount}); refusing to sign refund.`
|
|
1285
1277
|
);
|
|
1286
1278
|
a == null || a.throwIfAborted();
|
|
1287
|
-
const p =
|
|
1279
|
+
const p = L(
|
|
1288
1280
|
i.depositorBtcPubkey
|
|
1289
|
-
), d =
|
|
1281
|
+
), d = m(i.unsignedPrePeginTxHex), g = Te(d);
|
|
1290
1282
|
if (g !== void 0 && g.vout !== i.batch.length)
|
|
1291
1283
|
throw new Error(
|
|
1292
1284
|
`Auth-anchor OP_RETURN at vout ${g.vout} does not match batch size (${i.batch.length} HTLC outputs expect the anchor at vout ${i.batch.length}). Refund refused — sibling HTLC vector is incomplete.`
|
|
1293
1285
|
);
|
|
1294
1286
|
const b = g == null ? void 0 : g.hash;
|
|
1295
|
-
let
|
|
1287
|
+
let f;
|
|
1296
1288
|
try {
|
|
1297
|
-
|
|
1289
|
+
f = A.fromHex(d);
|
|
1298
1290
|
} catch (y) {
|
|
1299
1291
|
throw new Error(
|
|
1300
1292
|
`Failed to parse funded Pre-PegIn transaction hex: ${y instanceof Error ? y.message : String(y)}`
|
|
1301
1293
|
);
|
|
1302
1294
|
}
|
|
1303
|
-
if (
|
|
1295
|
+
if (f.outs.length < i.batch.length)
|
|
1304
1296
|
throw new Error(
|
|
1305
|
-
`Funded Pre-PegIn tx has ${
|
|
1297
|
+
`Funded Pre-PegIn tx has ${f.outs.length} outputs but batch requires at least ${i.batch.length} HTLC outputs. Refund refused — funded tx shape disagrees with sibling vector.`
|
|
1306
1298
|
);
|
|
1307
|
-
const { psbtHex:
|
|
1299
|
+
const { psbtHex: P } = await Ke({
|
|
1308
1300
|
prePeginParams: {
|
|
1309
1301
|
vaultCoreVersion: i.vaultCoreVersion,
|
|
1310
1302
|
depositorPubkey: p,
|
|
1311
|
-
vaultProviderPubkey:
|
|
1312
|
-
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(
|
|
1313
|
-
universalChallengerPubkeys: u.universalChallengerPubkeys.map(
|
|
1314
|
-
hashlocks: i.batch.map((y) =>
|
|
1303
|
+
vaultProviderPubkey: m(u.vaultProviderPubkey),
|
|
1304
|
+
vaultKeeperPubkeys: u.vaultKeeperPubkeys.map(m),
|
|
1305
|
+
universalChallengerPubkeys: u.universalChallengerPubkeys.map(m),
|
|
1306
|
+
hashlocks: i.batch.map((y) => m(y.hashlock)),
|
|
1315
1307
|
timelockRefund: u.timelockRefund,
|
|
1316
1308
|
// `batch[i].amount` is the on-chain vault deposit (peg-in) amount, which
|
|
1317
1309
|
// is exactly what WASM's `pegInAmounts` expects — it re-adds the protocol
|
|
@@ -1335,32 +1327,32 @@ async function ar(e) {
|
|
|
1335
1327
|
// prefix" and flows into the WASM HTLC connector derivation; a prefixed
|
|
1336
1328
|
// value would derive the wrong refund script leaf and yield an
|
|
1337
1329
|
// unspendable PSBT. Match the `hashlocks` array handling above.
|
|
1338
|
-
hashlock:
|
|
1330
|
+
hashlock: m(i.hashlock)
|
|
1339
1331
|
});
|
|
1340
1332
|
a == null || a.throwIfAborted();
|
|
1341
1333
|
const w = M(
|
|
1342
1334
|
i.depositorBtcPubkey,
|
|
1343
1335
|
Et
|
|
1344
|
-
),
|
|
1336
|
+
), v = await l(P, w);
|
|
1345
1337
|
H({
|
|
1346
|
-
requestedPsbtHex:
|
|
1347
|
-
returnedPsbtHex:
|
|
1338
|
+
requestedPsbtHex: P,
|
|
1339
|
+
returnedPsbtHex: v
|
|
1348
1340
|
});
|
|
1349
|
-
const S = 0,
|
|
1350
|
-
|
|
1341
|
+
const S = 0, B = D(
|
|
1342
|
+
v,
|
|
1351
1343
|
p,
|
|
1352
1344
|
S
|
|
1353
1345
|
);
|
|
1354
1346
|
F({
|
|
1355
|
-
requestedPsbtHex:
|
|
1356
|
-
signatureHex:
|
|
1347
|
+
requestedPsbtHex: P,
|
|
1348
|
+
signatureHex: B,
|
|
1357
1349
|
signerXOnlyPubkeyHex: p,
|
|
1358
1350
|
inputIndex: S
|
|
1359
1351
|
});
|
|
1360
|
-
const
|
|
1352
|
+
const R = St(v);
|
|
1361
1353
|
a == null || a.throwIfAborted();
|
|
1362
1354
|
try {
|
|
1363
|
-
return await o(
|
|
1355
|
+
return await o(R);
|
|
1364
1356
|
} catch (y) {
|
|
1365
1357
|
throw y instanceof Error && xt.test(y.message) ? new bt(t, y) : y;
|
|
1366
1358
|
}
|
|
@@ -1374,23 +1366,23 @@ export {
|
|
|
1374
1366
|
nr as F,
|
|
1375
1367
|
or as G,
|
|
1376
1368
|
bt as H,
|
|
1377
|
-
|
|
1378
|
-
|
|
1369
|
+
sr as I,
|
|
1370
|
+
ar as J,
|
|
1379
1371
|
te as K,
|
|
1380
1372
|
ee as L,
|
|
1381
1373
|
Z as M,
|
|
1382
1374
|
fe as N,
|
|
1383
|
-
|
|
1375
|
+
Ue as P,
|
|
1384
1376
|
pe as R,
|
|
1385
1377
|
Ft as a,
|
|
1386
1378
|
Mt as b,
|
|
1387
|
-
|
|
1379
|
+
se as c,
|
|
1388
1380
|
ie as d,
|
|
1389
|
-
|
|
1381
|
+
Ut as e,
|
|
1390
1382
|
Xt as f,
|
|
1391
1383
|
qt as g,
|
|
1392
1384
|
Qt as h,
|
|
1393
|
-
|
|
1385
|
+
Ge as i,
|
|
1394
1386
|
Jt as j,
|
|
1395
1387
|
Yt as k,
|
|
1396
1388
|
Wt as l,
|
|
@@ -1404,9 +1396,9 @@ export {
|
|
|
1404
1396
|
tr as t,
|
|
1405
1397
|
rr as u,
|
|
1406
1398
|
jt as v,
|
|
1407
|
-
|
|
1399
|
+
Lt as w,
|
|
1408
1400
|
ue as x,
|
|
1409
1401
|
Gt as y,
|
|
1410
1402
|
V as z
|
|
1411
1403
|
};
|
|
1412
|
-
//# sourceMappingURL=buildAndBroadcastRefund-
|
|
1404
|
+
//# sourceMappingURL=buildAndBroadcastRefund-CpMDJ8up.js.map
|