@babylonlabs-io/ts-sdk 0.6.0 → 0.7.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 +1 -1
- package/dist/{PayoutManager-CgS9Y0KB.js → PayoutManager-BVmU4UsM.js} +202 -159
- package/dist/PayoutManager-BVmU4UsM.js.map +1 -0
- package/dist/PayoutManager-Ba6cNgHC.cjs +2 -0
- package/dist/PayoutManager-Ba6cNgHC.cjs.map +1 -0
- package/dist/{challengeAssert-BpX9FQ-i.js → challengeAssert-D50t_Qyo.js} +102 -101
- package/dist/challengeAssert-D50t_Qyo.js.map +1 -0
- package/dist/challengeAssert-DDceAi0r.cjs +2 -0
- package/dist/challengeAssert-DDceAi0r.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +36 -35
- package/dist/tbv/core/contracts/abis/{BTCVaultsManager.abi.d.ts → BTCVaultRegistry.abi.d.ts} +41 -9
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -0
- package/dist/tbv/core/contracts/index.d.ts +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +38 -37
- package/dist/tbv/core/managers/PeginManager.d.ts +21 -20
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/__tests__/PeginManager.test.d.ts +1 -1
- package/dist/tbv/core/managers/index.d.ts +4 -4
- package/dist/tbv/core/managers/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +1 -1
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +10 -9
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +11 -8
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
- package/dist/tbv/core/utils/transaction/btcTxHash.d.ts +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +38 -37
- package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationController.abi.json.d.ts +7 -2
- 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.js +3 -3
- package/package.json +3 -3
- package/dist/PayoutManager-AJJ-3vvu.cjs +0 -2
- package/dist/PayoutManager-AJJ-3vvu.cjs.map +0 -1
- package/dist/PayoutManager-CgS9Y0KB.js.map +0 -1
- package/dist/challengeAssert-BMSvVtzu.cjs +0 -2
- package/dist/challengeAssert-BMSvVtzu.cjs.map +0 -1
- package/dist/challengeAssert-BpX9FQ-i.js.map +0 -1
- package/dist/tbv/core/contracts/abis/BTCVaultsManager.abi.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createPrePeginTransaction as R, buildPeginTxFromPrePegin as W, getPrePeginHtlcConnectorInfo as K, tapInternalPubkey as
|
|
1
|
+
import { createPrePeginTransaction as R, buildPeginTxFromPrePegin as W, getPrePeginHtlcConnectorInfo as K, tapInternalPubkey as w, createPayoutConnector as N, getPeginPayoutScript as q, getAssertNoPayoutScriptInfo as z, getChallengeAssertScriptInfo as M } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
2
2
|
import * as U from "bitcoinjs-lib";
|
|
3
|
-
import { payments as b, networks as T, initEccLib as H, Transaction as P, Psbt as
|
|
3
|
+
import { payments as b, networks as T, initEccLib as H, Transaction as P, Psbt as k } from "bitcoinjs-lib";
|
|
4
4
|
import { Buffer as a } from "buffer";
|
|
5
5
|
import * as A from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
6
6
|
function h(t) {
|
|
@@ -14,8 +14,8 @@ function d(t) {
|
|
|
14
14
|
if (!B(n))
|
|
15
15
|
throw new Error(`Invalid hex string: ${t}`);
|
|
16
16
|
const e = new Uint8Array(n.length / 2);
|
|
17
|
-
for (let
|
|
18
|
-
e[
|
|
17
|
+
for (let o = 0; o < n.length; o += 2)
|
|
18
|
+
e[o / 2] = parseInt(n.slice(o, o + 2), 16);
|
|
19
19
|
return e;
|
|
20
20
|
}
|
|
21
21
|
function x(t) {
|
|
@@ -45,12 +45,12 @@ function at(t) {
|
|
|
45
45
|
return B(n);
|
|
46
46
|
}
|
|
47
47
|
function lt(t, n) {
|
|
48
|
-
const e = $(t),
|
|
49
|
-
if (e.toLowerCase() !==
|
|
48
|
+
const e = $(t), o = n ?? e;
|
|
49
|
+
if (e.toLowerCase() !== o.toLowerCase())
|
|
50
50
|
throw new Error(
|
|
51
|
-
`Wallet public key does not match vault depositor. Expected: ${
|
|
51
|
+
`Wallet public key does not match vault depositor. Expected: ${o}, Got: ${e}. Please connect the wallet that was used to create this vault.`
|
|
52
52
|
);
|
|
53
|
-
return { walletPubkeyRaw: t, walletPubkeyXOnly: e, depositorPubkey:
|
|
53
|
+
return { walletPubkeyRaw: t, walletPubkeyXOnly: e, depositorPubkey: o };
|
|
54
54
|
}
|
|
55
55
|
let _ = !1;
|
|
56
56
|
function X() {
|
|
@@ -71,13 +71,13 @@ function V(t) {
|
|
|
71
71
|
}
|
|
72
72
|
function G(t, n) {
|
|
73
73
|
X();
|
|
74
|
-
const e = d($(t)), { address:
|
|
74
|
+
const e = d($(t)), { address: o } = b.p2tr({
|
|
75
75
|
internalPubkey: a.from(e),
|
|
76
76
|
network: V(n)
|
|
77
77
|
});
|
|
78
|
-
if (!
|
|
78
|
+
if (!o)
|
|
79
79
|
throw new Error("Failed to derive taproot address from public key");
|
|
80
|
-
return
|
|
80
|
+
return o;
|
|
81
81
|
}
|
|
82
82
|
function Y(t, n) {
|
|
83
83
|
const e = h(t);
|
|
@@ -85,26 +85,26 @@ function Y(t, n) {
|
|
|
85
85
|
throw new Error(
|
|
86
86
|
`Native SegWit requires a compressed public key (66 hex chars), got ${e.length}`
|
|
87
87
|
);
|
|
88
|
-
const { address:
|
|
88
|
+
const { address: o } = b.p2wpkh({
|
|
89
89
|
pubkey: a.from(d(e)),
|
|
90
90
|
network: V(n)
|
|
91
91
|
});
|
|
92
|
-
if (!
|
|
92
|
+
if (!o)
|
|
93
93
|
throw new Error(
|
|
94
94
|
"Failed to derive native segwit address from public key"
|
|
95
95
|
);
|
|
96
|
-
return
|
|
96
|
+
return o;
|
|
97
97
|
}
|
|
98
98
|
function pt(t, n, e) {
|
|
99
|
-
const
|
|
99
|
+
const o = h(n);
|
|
100
100
|
try {
|
|
101
|
-
if (t === G(
|
|
101
|
+
if (t === G(o, e))
|
|
102
102
|
return !0;
|
|
103
103
|
} catch {
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
for (const s of
|
|
105
|
+
const r = [];
|
|
106
|
+
o.length === 66 ? r.push(o) : o.length === 64 && r.push(`02${o}`, `03${o}`);
|
|
107
|
+
for (const s of r)
|
|
108
108
|
try {
|
|
109
109
|
if (t === Y(s, e))
|
|
110
110
|
return !0;
|
|
@@ -116,11 +116,11 @@ function I(t) {
|
|
|
116
116
|
return $(t).toLowerCase();
|
|
117
117
|
}
|
|
118
118
|
function ft(t, n, e) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
for (const
|
|
122
|
-
|
|
123
|
-
return
|
|
119
|
+
const o = /* @__PURE__ */ new Set();
|
|
120
|
+
o.add(I(t));
|
|
121
|
+
for (const r of n)
|
|
122
|
+
o.add(I(r));
|
|
123
|
+
return o.delete(I(e)), o.size;
|
|
124
124
|
}
|
|
125
125
|
const ht = 58, dt = 43, gt = 11, Q = 546, Z = BigInt(Q), j = 30, J = 2, Pt = 1.1;
|
|
126
126
|
function yt(t) {
|
|
@@ -128,23 +128,23 @@ function yt(t) {
|
|
|
128
128
|
}
|
|
129
129
|
const xt = 5;
|
|
130
130
|
function F(t) {
|
|
131
|
-
const e = t.substring(8, 12) === "0001" ? 12 : 8,
|
|
131
|
+
const e = t.substring(8, 12) === "0001" ? 12 : 8, o = parseInt(
|
|
132
132
|
t.substring(e, e + 2),
|
|
133
133
|
16
|
|
134
|
-
),
|
|
134
|
+
), r = parseInt(
|
|
135
135
|
t.substring(e + 2, e + 4),
|
|
136
136
|
16
|
|
137
137
|
);
|
|
138
|
-
if (
|
|
139
|
-
throw new Error(`Expected 0 inputs from WASM, got ${
|
|
140
|
-
if (
|
|
138
|
+
if (o !== 0)
|
|
139
|
+
throw new Error(`Expected 0 inputs from WASM, got ${o}`);
|
|
140
|
+
if (r === 0)
|
|
141
141
|
throw new Error("Expected at least 1 output from WASM, got 0");
|
|
142
142
|
const s = a.from(t.substring(0, 8), "hex").readUInt32LE(0), u = a.from(
|
|
143
143
|
t.substring(t.length - 8),
|
|
144
144
|
"hex"
|
|
145
145
|
).readUInt32LE(0), c = [];
|
|
146
146
|
let i = e + 4;
|
|
147
|
-
for (let p = 0; p <
|
|
147
|
+
for (let p = 0; p < r; p++) {
|
|
148
148
|
const l = t.substring(i, i + 16), f = Number(a.from(l, "hex").readBigUInt64LE(0));
|
|
149
149
|
i += 16;
|
|
150
150
|
const g = parseInt(t.substring(i, i + 2), 16);
|
|
@@ -154,8 +154,8 @@ function F(t) {
|
|
|
154
154
|
}
|
|
155
155
|
return { version: s, locktime: u, outputs: c };
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
const { unfundedTxHex: n, selectedUTXOs: e, changeAddress:
|
|
157
|
+
function kt(t) {
|
|
158
|
+
const { unfundedTxHex: n, selectedUTXOs: e, changeAddress: o, changeAmount: r, network: s } = t, { version: u, locktime: c, outputs: i } = F(n), p = new U.Transaction();
|
|
159
159
|
p.version = u, p.locktime = c;
|
|
160
160
|
for (const l of e) {
|
|
161
161
|
const f = a.from(l.txid, "hex").reverse();
|
|
@@ -163,19 +163,19 @@ function wt(t) {
|
|
|
163
163
|
}
|
|
164
164
|
for (const l of i)
|
|
165
165
|
p.addOutput(l.script, l.value);
|
|
166
|
-
if (
|
|
167
|
-
const l = U.address.toOutputScript(
|
|
168
|
-
p.addOutput(l, Number(
|
|
166
|
+
if (r > Z) {
|
|
167
|
+
const l = U.address.toOutputScript(o, s);
|
|
168
|
+
p.addOutput(l, Number(r));
|
|
169
169
|
}
|
|
170
170
|
return p.toHex();
|
|
171
171
|
}
|
|
172
|
-
async function
|
|
172
|
+
async function wt(t) {
|
|
173
173
|
const n = await R({
|
|
174
174
|
depositorPubkey: t.depositorPubkey,
|
|
175
175
|
vaultProviderPubkey: t.vaultProviderPubkey,
|
|
176
176
|
vaultKeeperPubkeys: t.vaultKeeperPubkeys,
|
|
177
177
|
universalChallengerPubkeys: t.universalChallengerPubkeys,
|
|
178
|
-
|
|
178
|
+
hashlocks: [...t.hashlocks],
|
|
179
179
|
timelockRefund: t.timelockRefund,
|
|
180
180
|
pegInAmount: t.pegInAmount,
|
|
181
181
|
feeRate: t.feeRate,
|
|
@@ -183,13 +183,13 @@ async function kt(t) {
|
|
|
183
183
|
councilQuorum: t.councilQuorum,
|
|
184
184
|
councilSize: t.councilSize,
|
|
185
185
|
network: t.network
|
|
186
|
-
}),
|
|
187
|
-
(
|
|
186
|
+
}), o = F(n.txHex).outputs.reduce(
|
|
187
|
+
(r, s) => r + BigInt(s.value),
|
|
188
188
|
0n
|
|
189
189
|
);
|
|
190
190
|
return {
|
|
191
191
|
psbtHex: n.txHex,
|
|
192
|
-
totalOutputValue:
|
|
192
|
+
totalOutputValue: o,
|
|
193
193
|
htlcValue: n.htlcValue,
|
|
194
194
|
htlcScriptPubKey: n.htlcScriptPubKey,
|
|
195
195
|
htlcAddress: n.htlcAddress,
|
|
@@ -204,7 +204,7 @@ async function vt(t) {
|
|
|
204
204
|
vaultProviderPubkey: t.prePeginParams.vaultProviderPubkey,
|
|
205
205
|
vaultKeeperPubkeys: t.prePeginParams.vaultKeeperPubkeys,
|
|
206
206
|
universalChallengerPubkeys: t.prePeginParams.universalChallengerPubkeys,
|
|
207
|
-
|
|
207
|
+
hashlocks: [...t.prePeginParams.hashlocks],
|
|
208
208
|
timelockRefund: t.prePeginParams.timelockRefund,
|
|
209
209
|
pegInAmount: t.prePeginParams.pegInAmount,
|
|
210
210
|
feeRate: t.prePeginParams.feeRate,
|
|
@@ -214,7 +214,8 @@ async function vt(t) {
|
|
|
214
214
|
network: t.prePeginParams.network
|
|
215
215
|
},
|
|
216
216
|
t.timelockPegin,
|
|
217
|
-
t.
|
|
217
|
+
t.fundedPrePeginTxHex,
|
|
218
|
+
t.htlcVout
|
|
218
219
|
);
|
|
219
220
|
return {
|
|
220
221
|
txHex: n.txHex,
|
|
@@ -224,20 +225,20 @@ async function vt(t) {
|
|
|
224
225
|
};
|
|
225
226
|
}
|
|
226
227
|
async function bt(t) {
|
|
227
|
-
const n = h(t.peginTxHex), e = h(t.fundedPrePeginTxHex),
|
|
228
|
+
const n = h(t.peginTxHex), e = h(t.fundedPrePeginTxHex), o = await K({
|
|
228
229
|
depositorPubkey: t.depositorPubkey,
|
|
229
230
|
vaultProviderPubkey: t.vaultProviderPubkey,
|
|
230
231
|
vaultKeeperPubkeys: t.vaultKeeperPubkeys,
|
|
231
232
|
universalChallengerPubkeys: t.universalChallengerPubkeys,
|
|
232
|
-
|
|
233
|
+
hashlock: t.hashlock,
|
|
233
234
|
timelockRefund: t.timelockRefund,
|
|
234
235
|
network: t.network
|
|
235
|
-
}),
|
|
236
|
-
if (
|
|
236
|
+
}), r = P.fromHex(n), s = P.fromHex(e);
|
|
237
|
+
if (r.ins.length !== 1)
|
|
237
238
|
throw new Error(
|
|
238
|
-
`PegIn transaction must have exactly 1 input, got ${
|
|
239
|
+
`PegIn transaction must have exactly 1 input, got ${r.ins.length}`
|
|
239
240
|
);
|
|
240
|
-
const u =
|
|
241
|
+
const u = r.ins[0], c = s.getId(), i = x(
|
|
241
242
|
new Uint8Array(u.hash).slice().reverse()
|
|
242
243
|
);
|
|
243
244
|
if (i !== c)
|
|
@@ -249,8 +250,8 @@ async function bt(t) {
|
|
|
249
250
|
throw new Error(
|
|
250
251
|
`Pre-PegIn output ${u.index} not found (Pre-PegIn has ${s.outs.length} outputs)`
|
|
251
252
|
);
|
|
252
|
-
const l = d(
|
|
253
|
-
g.setVersion(
|
|
253
|
+
const l = d(o.hashlockScript), f = d(o.hashlockControlBlock), g = new k();
|
|
254
|
+
g.setVersion(r.version), g.setLocktime(r.locktime), g.addInput({
|
|
254
255
|
hash: u.hash,
|
|
255
256
|
index: u.index,
|
|
256
257
|
sequence: u.sequence,
|
|
@@ -265,10 +266,10 @@ async function bt(t) {
|
|
|
265
266
|
controlBlock: a.from(f)
|
|
266
267
|
}
|
|
267
268
|
],
|
|
268
|
-
tapInternalKey: a.from(
|
|
269
|
+
tapInternalKey: a.from(w)
|
|
269
270
|
// sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot
|
|
270
271
|
});
|
|
271
|
-
for (const y of
|
|
272
|
+
for (const y of r.outs)
|
|
272
273
|
g.addOutput({
|
|
273
274
|
script: y.script,
|
|
274
275
|
value: y.value
|
|
@@ -276,33 +277,33 @@ async function bt(t) {
|
|
|
276
277
|
return { psbtHex: g.toHex() };
|
|
277
278
|
}
|
|
278
279
|
function St(t, n) {
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
280
|
+
const o = k.fromHex(t).data.inputs[0];
|
|
281
|
+
if (!o)
|
|
281
282
|
throw new Error("PegIn PSBT has no inputs");
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
283
|
+
if (o.tapScriptSig && o.tapScriptSig.length > 0) {
|
|
284
|
+
const r = a.from(
|
|
284
285
|
d(n)
|
|
285
286
|
);
|
|
286
|
-
for (const s of
|
|
287
|
-
if (s.pubkey.equals(
|
|
287
|
+
for (const s of o.tapScriptSig)
|
|
288
|
+
if (s.pubkey.equals(r))
|
|
288
289
|
return tt(s.signature);
|
|
289
290
|
throw new Error(
|
|
290
291
|
`No PegIn input signature found for depositor pubkey: ${n}`
|
|
291
292
|
);
|
|
292
293
|
}
|
|
293
|
-
throw
|
|
294
|
+
throw o.finalScriptWitness && o.finalScriptWitness.length > 0 ? new Error(
|
|
294
295
|
"PegIn input PSBT is already finalized. Cannot reliably extract the depositor signature from the witness stack. Ensure the wallet returns a non-finalized PSBT with tapScriptSig entries."
|
|
295
296
|
) : new Error(
|
|
296
297
|
"No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT"
|
|
297
298
|
);
|
|
298
299
|
}
|
|
299
300
|
function mt(t) {
|
|
300
|
-
const n =
|
|
301
|
+
const n = k.fromHex(t);
|
|
301
302
|
try {
|
|
302
303
|
n.finalizeAllInputs();
|
|
303
304
|
} catch (e) {
|
|
304
305
|
if (!n.data.inputs.every(
|
|
305
|
-
(
|
|
306
|
+
(r) => r.finalScriptWitness || r.finalScriptSig
|
|
306
307
|
))
|
|
307
308
|
throw new Error(
|
|
308
309
|
`PSBT finalization failed and wallet did not auto-finalize: ${e}`
|
|
@@ -337,14 +338,14 @@ async function et(t) {
|
|
|
337
338
|
}
|
|
338
339
|
H(A);
|
|
339
340
|
async function Et(t) {
|
|
340
|
-
const n = h(t.payoutTxHex), e = h(t.peginTxHex),
|
|
341
|
+
const n = h(t.payoutTxHex), e = h(t.peginTxHex), o = h(t.assertTxHex), r = await et({
|
|
341
342
|
depositor: t.depositorBtcPubkey,
|
|
342
343
|
vaultProvider: t.vaultProviderBtcPubkey,
|
|
343
344
|
vaultKeepers: t.vaultKeeperBtcPubkeys,
|
|
344
345
|
universalChallengers: t.universalChallengerBtcPubkeys,
|
|
345
346
|
timelockPegin: t.timelockPegin,
|
|
346
347
|
network: t.network
|
|
347
|
-
}), s = d(
|
|
348
|
+
}), s = d(r.payoutScript), u = ot(w, s), c = P.fromHex(n), i = P.fromHex(e), p = P.fromHex(o), l = new k();
|
|
348
349
|
if (l.setVersion(c.version), l.setLocktime(c.locktime), c.ins.length !== 2)
|
|
349
350
|
throw new Error(
|
|
350
351
|
`Payout transaction must have exactly 2 inputs, got ${c.ins.length}`
|
|
@@ -388,7 +389,7 @@ async function Et(t) {
|
|
|
388
389
|
controlBlock: a.from(u)
|
|
389
390
|
}
|
|
390
391
|
],
|
|
391
|
-
tapInternalKey: a.from(
|
|
392
|
+
tapInternalKey: a.from(w)
|
|
392
393
|
// sighashType omitted - defaults to SIGHASH_DEFAULT (0x00) for Taproot
|
|
393
394
|
}), l.addInput({
|
|
394
395
|
hash: g.hash,
|
|
@@ -410,23 +411,23 @@ async function Et(t) {
|
|
|
410
411
|
};
|
|
411
412
|
}
|
|
412
413
|
function Tt(t, n, e = 0) {
|
|
413
|
-
const
|
|
414
|
-
if (e >=
|
|
414
|
+
const o = k.fromHex(t);
|
|
415
|
+
if (e >= o.data.inputs.length)
|
|
415
416
|
throw new Error(
|
|
416
|
-
`Input index ${e} out of range (${
|
|
417
|
+
`Input index ${e} out of range (${o.data.inputs.length} inputs)`
|
|
417
418
|
);
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
419
|
+
const r = o.data.inputs[e];
|
|
420
|
+
if (r.tapScriptSig && r.tapScriptSig.length > 0) {
|
|
420
421
|
const s = d(n);
|
|
421
|
-
for (const u of
|
|
422
|
+
for (const u of r.tapScriptSig)
|
|
422
423
|
if (u.pubkey.equals(a.from(s)))
|
|
423
424
|
return O(u.signature, e);
|
|
424
425
|
throw new Error(
|
|
425
426
|
`No signature found for depositor pubkey: ${n} at input ${e}`
|
|
426
427
|
);
|
|
427
428
|
}
|
|
428
|
-
if (
|
|
429
|
-
const s = nt(
|
|
429
|
+
if (r.finalScriptWitness && r.finalScriptWitness.length > 0) {
|
|
430
|
+
const s = nt(r.finalScriptWitness);
|
|
430
431
|
if (s.length >= 1)
|
|
431
432
|
return O(s[0], e);
|
|
432
433
|
}
|
|
@@ -452,7 +453,7 @@ function O(t, n) {
|
|
|
452
453
|
function nt(t) {
|
|
453
454
|
const n = [];
|
|
454
455
|
let e = 0;
|
|
455
|
-
const
|
|
456
|
+
const o = () => {
|
|
456
457
|
const s = t[e++];
|
|
457
458
|
if (s < 253) return s;
|
|
458
459
|
if (s === 253) {
|
|
@@ -464,26 +465,26 @@ function nt(t) {
|
|
|
464
465
|
return e += 4, u;
|
|
465
466
|
}
|
|
466
467
|
return e += 8, 0;
|
|
467
|
-
},
|
|
468
|
-
for (let s = 0; s <
|
|
469
|
-
const u =
|
|
468
|
+
}, r = o();
|
|
469
|
+
for (let s = 0; s < r; s++) {
|
|
470
|
+
const u = o();
|
|
470
471
|
n.push(t.subarray(e, e + u)), e += u;
|
|
471
472
|
}
|
|
472
473
|
return n;
|
|
473
474
|
}
|
|
474
|
-
function
|
|
475
|
-
const e = { output: a.from(n) },
|
|
475
|
+
function ot(t, n) {
|
|
476
|
+
const e = { output: a.from(n) }, r = b.p2tr({
|
|
476
477
|
internalPubkey: a.from(t),
|
|
477
478
|
scriptTree: e
|
|
478
479
|
}).pubkey;
|
|
479
|
-
if (!
|
|
480
|
+
if (!r)
|
|
480
481
|
throw new Error("Failed to compute output key");
|
|
481
|
-
const s = 192, u =
|
|
482
|
+
const s = 192, u = r[0] === 3 ? 1 : 0, c = s | u, i = new Uint8Array(1 + t.length);
|
|
482
483
|
return i[0] = c, i.set(t, 1), i;
|
|
483
484
|
}
|
|
484
485
|
H(A);
|
|
485
486
|
async function It(t) {
|
|
486
|
-
const n = h(t.payoutTxHex), e = P.fromHex(n),
|
|
487
|
+
const n = h(t.payoutTxHex), e = P.fromHex(n), o = await q(t.connectorParams), r = d(o), s = rt(w, r), u = new k();
|
|
487
488
|
u.setVersion(e.version), u.setLocktime(e.locktime);
|
|
488
489
|
for (let c = 0; c < e.ins.length; c++) {
|
|
489
490
|
const i = e.ins[c], p = t.prevouts[c];
|
|
@@ -501,10 +502,10 @@ async function It(t) {
|
|
|
501
502
|
c === 0 && (l.tapLeafScript = [
|
|
502
503
|
{
|
|
503
504
|
leafVersion: 192,
|
|
504
|
-
script: a.from(
|
|
505
|
+
script: a.from(r),
|
|
505
506
|
controlBlock: a.from(s)
|
|
506
507
|
}
|
|
507
|
-
], l.tapInternalKey = a.from(
|
|
508
|
+
], l.tapInternalKey = a.from(w)), u.addInput(l);
|
|
508
509
|
}
|
|
509
510
|
for (const c of e.outs)
|
|
510
511
|
u.addOutput({
|
|
@@ -513,21 +514,21 @@ async function It(t) {
|
|
|
513
514
|
});
|
|
514
515
|
return u.toHex();
|
|
515
516
|
}
|
|
516
|
-
function
|
|
517
|
-
const e = { output: a.from(n) },
|
|
517
|
+
function rt(t, n) {
|
|
518
|
+
const e = { output: a.from(n) }, r = b.p2tr({
|
|
518
519
|
internalPubkey: a.from(t),
|
|
519
520
|
scriptTree: e
|
|
520
521
|
}).pubkey;
|
|
521
|
-
if (!
|
|
522
|
+
if (!r)
|
|
522
523
|
throw new Error("Failed to compute output key");
|
|
523
|
-
const s = 192, u =
|
|
524
|
+
const s = 192, u = r[0] === 3 ? 1 : 0, c = s | u, i = new Uint8Array(1 + t.length);
|
|
524
525
|
return i[0] = c, i.set(t, 1), i;
|
|
525
526
|
}
|
|
526
527
|
async function Ht(t) {
|
|
527
|
-
const n = h(t.noPayoutTxHex), e = P.fromHex(n), { noPayoutScript:
|
|
528
|
+
const n = h(t.noPayoutTxHex), e = P.fromHex(n), { noPayoutScript: o, noPayoutControlBlock: r } = await z(
|
|
528
529
|
t.connectorParams,
|
|
529
530
|
t.challengerPubkey
|
|
530
|
-
), s = d(
|
|
531
|
+
), s = d(o), u = d(r), c = new k();
|
|
531
532
|
c.setVersion(e.version), c.setLocktime(e.locktime);
|
|
532
533
|
for (let i = 0; i < e.ins.length; i++) {
|
|
533
534
|
const p = e.ins[i], l = t.prevouts[i];
|
|
@@ -548,7 +549,7 @@ async function Ht(t) {
|
|
|
548
549
|
script: a.from(s),
|
|
549
550
|
controlBlock: a.from(u)
|
|
550
551
|
}
|
|
551
|
-
], f.tapInternalKey = a.from(
|
|
552
|
+
], f.tapInternalKey = a.from(w)), c.addInput(f);
|
|
552
553
|
}
|
|
553
554
|
for (const i of e.outs)
|
|
554
555
|
c.addOutput({
|
|
@@ -563,16 +564,16 @@ async function At(t) {
|
|
|
563
564
|
throw new Error(
|
|
564
565
|
`Expected ${e.ins.length} connector params, got ${t.connectorParamsPerInput.length}`
|
|
565
566
|
);
|
|
566
|
-
const
|
|
567
|
+
const o = await Promise.all(
|
|
567
568
|
t.connectorParamsPerInput.map((s) => M(s))
|
|
568
|
-
),
|
|
569
|
-
|
|
569
|
+
), r = new k();
|
|
570
|
+
r.setVersion(e.version), r.setLocktime(e.locktime);
|
|
570
571
|
for (let s = 0; s < e.ins.length; s++) {
|
|
571
572
|
const u = e.ins[s], c = t.prevouts[s];
|
|
572
573
|
if (!c)
|
|
573
574
|
throw new Error(`Missing prevout data for input ${s}`);
|
|
574
|
-
const { script: i, controlBlock: p } =
|
|
575
|
-
|
|
575
|
+
const { script: i, controlBlock: p } = o[s], l = d(i), f = d(p);
|
|
576
|
+
r.addInput({
|
|
576
577
|
hash: u.hash,
|
|
577
578
|
index: u.index,
|
|
578
579
|
sequence: u.sequence,
|
|
@@ -587,15 +588,15 @@ async function At(t) {
|
|
|
587
588
|
controlBlock: a.from(f)
|
|
588
589
|
}
|
|
589
590
|
],
|
|
590
|
-
tapInternalKey: a.from(
|
|
591
|
+
tapInternalKey: a.from(w)
|
|
591
592
|
});
|
|
592
593
|
}
|
|
593
594
|
for (const s of e.outs)
|
|
594
|
-
|
|
595
|
+
r.addOutput({
|
|
595
596
|
script: s.script,
|
|
596
597
|
value: s.value
|
|
597
598
|
});
|
|
598
|
-
return
|
|
599
|
+
return r.toHex();
|
|
599
600
|
}
|
|
600
601
|
export {
|
|
601
602
|
V as A,
|
|
@@ -609,7 +610,7 @@ export {
|
|
|
609
610
|
gt as T,
|
|
610
611
|
J as W,
|
|
611
612
|
vt as a,
|
|
612
|
-
|
|
613
|
+
wt as b,
|
|
613
614
|
ft as c,
|
|
614
615
|
bt as d,
|
|
615
616
|
St as e,
|
|
@@ -633,6 +634,6 @@ export {
|
|
|
633
634
|
lt as w,
|
|
634
635
|
yt as x,
|
|
635
636
|
F as y,
|
|
636
|
-
|
|
637
|
+
kt as z
|
|
637
638
|
};
|
|
638
|
-
//# sourceMappingURL=challengeAssert-
|
|
639
|
+
//# sourceMappingURL=challengeAssert-D50t_Qyo.js.map
|