@babylonlabs-io/ts-sdk 0.67.0 → 0.68.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.
Files changed (149) hide show
  1. package/dist/PeginManager--2R3T2S8.js +1458 -0
  2. package/dist/PeginManager--2R3T2S8.js.map +1 -0
  3. package/dist/PeginManager-CKWq8ouZ.cjs +2 -0
  4. package/dist/PeginManager-CKWq8ouZ.cjs.map +1 -0
  5. package/dist/{batchPoll-cIxrSLLJ.js → batchPoll-Cjj1du0i.js} +372 -421
  6. package/dist/batchPoll-Cjj1du0i.js.map +1 -0
  7. package/dist/batchPoll-REVZiE-M.cjs +2 -0
  8. package/dist/batchPoll-REVZiE-M.cjs.map +1 -0
  9. package/dist/{bitcoin-d9eaaZB_.js → bitcoin-Ch_jxnDa.js} +3 -3
  10. package/dist/{bitcoin-d9eaaZB_.js.map → bitcoin-Ch_jxnDa.js.map} +1 -1
  11. package/dist/{buildAndBroadcastRefund-C4LiPATK.js → buildAndBroadcastRefund-CpMDJ8up.js} +142 -150
  12. package/dist/buildAndBroadcastRefund-CpMDJ8up.js.map +1 -0
  13. package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs +2 -0
  14. package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs.map +1 -0
  15. package/dist/challengeAssert-BNQ8sToz.js +64 -0
  16. package/dist/challengeAssert-BNQ8sToz.js.map +1 -0
  17. package/dist/challengeAssert-BrpC3-cQ.cjs +2 -0
  18. package/dist/challengeAssert-BrpC3-cQ.cjs.map +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +246 -243
  21. package/dist/mempoolApi-EU1La9wk.cjs +2 -0
  22. package/dist/{mempoolApi-CXfr-L6x.cjs.map → mempoolApi-EU1La9wk.cjs.map} +1 -1
  23. package/dist/{mempoolApi-BxSINXIB.js → mempoolApi-_D-jvtj_.js} +191 -117
  24. package/dist/{mempoolApi-BxSINXIB.js.map → mempoolApi-_D-jvtj_.js.map} +1 -1
  25. package/dist/{noPayout-BaZGRLD2.js → noPayout-CXn-geIS.js} +3 -3
  26. package/dist/{noPayout-BaZGRLD2.js.map → noPayout-CXn-geIS.js.map} +1 -1
  27. package/dist/{noPayout-CnQ1WLtr.cjs → noPayout-Ox27Td9x.cjs} +2 -2
  28. package/dist/{noPayout-CnQ1WLtr.cjs.map → noPayout-Ox27Td9x.cjs.map} +1 -1
  29. package/dist/{onChainBtcPubkey-DeF4cKoO.js → onChainBtcPubkey-BAHZyKQL.js} +2 -2
  30. package/dist/{onChainBtcPubkey-DeF4cKoO.js.map → onChainBtcPubkey-BAHZyKQL.js.map} +1 -1
  31. package/dist/{parseFundingOutpoints-pBRE11Hr.js → parseFundingOutpoints-CO-f6IHK.js} +2 -2
  32. package/dist/{parseFundingOutpoints-pBRE11Hr.js.map → parseFundingOutpoints-CO-f6IHK.js.map} +1 -1
  33. package/dist/{reservation-B4i_PQhY.js → reservation-CBAvoF3U.js} +2 -2
  34. package/dist/{reservation-B4i_PQhY.js.map → reservation-CBAvoF3U.js.map} +1 -1
  35. package/dist/{signPsbtsWithFallback-Bb66DfY5.js → signPsbtsWithFallback-Bv79gLFe.js} +122 -100
  36. package/dist/signPsbtsWithFallback-Bv79gLFe.js.map +1 -0
  37. package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs +2 -0
  38. package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs.map +1 -0
  39. package/dist/tbv/core/clients/index.cjs +1 -1
  40. package/dist/tbv/core/clients/index.js +3 -3
  41. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts +32 -0
  42. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts.map +1 -0
  43. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts +9 -6
  44. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts.map +1 -1
  45. package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts +45 -20
  46. package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts.map +1 -1
  47. package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts +2 -0
  48. package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts.map +1 -0
  49. package/dist/tbv/core/deposit-terms/depositTerms.d.ts +41 -4
  50. package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
  51. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts +10 -5
  52. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts.map +1 -1
  53. package/dist/tbv/core/index.cjs +1 -1
  54. package/dist/tbv/core/index.js +244 -241
  55. package/dist/tbv/core/managers/PayoutManager.d.ts +8 -2
  56. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  57. package/dist/tbv/core/managers/PeginManager.d.ts +7 -0
  58. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  59. package/dist/tbv/core/managers/index.cjs +1 -1
  60. package/dist/tbv/core/managers/index.js +2 -2
  61. package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts +11 -0
  62. package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts.map +1 -0
  63. package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts.map +1 -1
  64. package/dist/tbv/core/managers/pegin/index.d.ts +1 -0
  65. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
  66. package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts +21 -0
  67. package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts.map +1 -0
  68. package/dist/tbv/core/primitives/challengers.d.ts +31 -5
  69. package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
  70. package/dist/tbv/core/primitives/index.cjs +1 -1
  71. package/dist/tbv/core/primitives/index.d.ts +2 -0
  72. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  73. package/dist/tbv/core/primitives/index.js +43 -41
  74. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +5 -0
  75. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -1
  76. package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts +12 -0
  77. package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts.map +1 -0
  78. package/dist/tbv/core/primitives/psbt/payout.d.ts +19 -7
  79. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  80. package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts +64 -0
  81. package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts.map +1 -0
  82. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts +40 -0
  83. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts.map +1 -0
  84. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts +2 -1
  85. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts.map +1 -1
  86. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts +13 -0
  87. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts.map +1 -0
  88. package/dist/tbv/core/primitives/utils/taproot.d.ts +29 -0
  89. package/dist/tbv/core/primitives/utils/taproot.d.ts.map +1 -0
  90. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +2 -2
  91. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  92. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  93. package/dist/tbv/core/services/index.cjs +1 -1
  94. package/dist/tbv/core/services/index.js +2 -2
  95. package/dist/tbv/core/utils/index.js +2 -2
  96. package/dist/tbv/core/utils/witness/witnessStack.d.ts +24 -0
  97. package/dist/tbv/core/utils/witness/witnessStack.d.ts.map +1 -0
  98. package/dist/tbv/core/vault-secrets/index.js +1 -1
  99. package/dist/tbv/index.cjs +1 -1
  100. package/dist/tbv/index.js +244 -241
  101. package/dist/testing/MockBitcoinWallet.d.ts +10 -1
  102. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  103. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts +2 -0
  104. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts.map +1 -0
  105. package/dist/testing/index.cjs +1 -1
  106. package/dist/testing/index.cjs.map +1 -1
  107. package/dist/testing/index.js +134 -47
  108. package/dist/testing/index.js.map +1 -1
  109. package/dist/testing/signBip322P2wpkhWitness.d.ts +20 -0
  110. package/dist/testing/signBip322P2wpkhWitness.d.ts.map +1 -0
  111. package/dist/{toRefundInputs-BY_fcvrv.js → toRefundInputs-9hv_6k0E.js} +6 -6
  112. package/dist/{toRefundInputs-BY_fcvrv.js.map → toRefundInputs-9hv_6k0E.js.map} +1 -1
  113. package/dist/{toRefundInputs-DYL9C-aG.cjs → toRefundInputs-D8sFs44p.cjs} +2 -2
  114. package/dist/{toRefundInputs-DYL9C-aG.cjs.map → toRefundInputs-D8sFs44p.cjs.map} +1 -1
  115. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs +2 -0
  116. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs.map +1 -0
  117. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js +363 -0
  118. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js.map +1 -0
  119. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js +931 -0
  120. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +1 -0
  121. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +2 -0
  122. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +1 -0
  123. package/package.json +1 -1
  124. package/dist/PeginManager-BBl4xkWz.js +0 -1359
  125. package/dist/PeginManager-BBl4xkWz.js.map +0 -1
  126. package/dist/PeginManager-p-ajwSxG.cjs +0 -2
  127. package/dist/PeginManager-p-ajwSxG.cjs.map +0 -1
  128. package/dist/batchPoll-6L5oToGr.cjs +0 -2
  129. package/dist/batchPoll-6L5oToGr.cjs.map +0 -1
  130. package/dist/batchPoll-cIxrSLLJ.js.map +0 -1
  131. package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +0 -1
  132. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +0 -2
  133. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +0 -1
  134. package/dist/challengeAssert-BFRE2DM-.cjs +0 -2
  135. package/dist/challengeAssert-BFRE2DM-.cjs.map +0 -1
  136. package/dist/challengeAssert-C7PzyJ7g.js +0 -75
  137. package/dist/challengeAssert-C7PzyJ7g.js.map +0 -1
  138. package/dist/mempoolApi-CXfr-L6x.cjs +0 -2
  139. package/dist/peginInput-Ci921gTl.cjs +0 -2
  140. package/dist/peginInput-Ci921gTl.cjs.map +0 -1
  141. package/dist/peginInput-HQPWZfly.js +0 -123
  142. package/dist/peginInput-HQPWZfly.js.map +0 -1
  143. package/dist/signPsbtsWithFallback-Bb66DfY5.js.map +0 -1
  144. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs +0 -2
  145. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs.map +0 -1
  146. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs +0 -2
  147. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs.map +0 -1
  148. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js +0 -817
  149. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js.map +0 -1
@@ -1,817 +0,0 @@
1
- import { computeMinClaimValue as ee, peginP2aAnchorOutput as te, computeMinPeginFee as ie, buildPeginTxFromPrePegin as se, createPrePeginTransaction as ue, validatePeginP2aAnchor as ce, tapInternalPubkey as ne, createPayoutConnector as ae, computePayoutFeeFloor as le } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
- import { Buffer as p } from "buffer";
3
- import { Transaction as x, script as he, opcodes as de, payments as pe, Psbt as C, crypto as Pe } from "bitcoinjs-lib";
4
- import { c as T, d as ge } from "./fundPeginTransaction-B2wyjqp0.js";
5
- import { s as g, u as k, h as y, j as fe, T as I, d as we, S as H, X as O } from "./bitcoin-d9eaaZB_.js";
6
- import { D as L, P as R, b as U, c as K, M as N, d as F, e as ve, A as $e, B as me, V as Se, N as q } from "./constants-GjWXdaqV.js";
7
- import * as xe from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- async function ye(e, t) {
9
- const n = t.pegInAmounts.length;
10
- if (e.htlcValues.length !== n)
11
- throw new Error(
12
- `WASM Pre-PegIn returned ${e.htlcValues.length} HTLC value(s), expected ${n} (one per requested deposit).`
13
- );
14
- if (e.peginAmounts.length !== n || e.htlcScriptPubKeys.length !== n || e.htlcAddresses.length !== n)
15
- throw new Error(
16
- `WASM Pre-PegIn returned mismatched array lengths (htlcValues=${e.htlcValues.length}, peginAmounts=${e.peginAmounts.length}, htlcScriptPubKeys=${e.htlcScriptPubKeys.length}, htlcAddresses=${e.htlcAddresses.length}); expected ${n} each.`
17
- );
18
- if (e.depositorClaimValue <= 0n)
19
- throw new Error(
20
- `WASM Pre-PegIn returned non-positive depositorClaimValue ${e.depositorClaimValue}; expected > 0.`
21
- );
22
- const o = await ee(
23
- // Must price the same graph version the builder constructed.
24
- t.vaultCoreVersion,
25
- t.numLocalChallengers,
26
- t.universalChallengerPubkeys.length,
27
- t.councilQuorum,
28
- t.councilSize,
29
- t.feeRate
30
- );
31
- if (e.depositorClaimValue !== o)
32
- throw new Error(
33
- `WASM Pre-PegIn depositorClaimValue ${e.depositorClaimValue} does not match the independently computed minimum claim value ${o} (vaultCoreVersion=${t.vaultCoreVersion}, numLocalChallengers=${t.numLocalChallengers}, numUniversalChallengers=${t.universalChallengerPubkeys.length}, councilQuorum=${t.councilQuorum}, councilSize=${t.councilSize}, feeRate=${t.feeRate}).`
34
- );
35
- const r = await te(t.vaultCoreVersion), i = (r == null ? void 0 : r.value) ?? 0n, s = await ie(
36
- t.vaultCoreVersion,
37
- t.vaultKeeperPubkeys.length,
38
- t.universalChallengerPubkeys.length,
39
- t.minPeginFeeRate
40
- ), u = s + i, h = t.minPeginFeeRate * T;
41
- for (let c = 0; c < n; c++) {
42
- const l = t.pegInAmounts[c], a = e.peginAmounts[c], f = e.htlcValues[c];
43
- if (a !== l)
44
- throw new Error(
45
- `WASM Pre-PegIn peginAmount[${c}] ${a} does not match the requested amount ${l}; refusing to build a tx whose recorded amount differs from the depositor's request.`
46
- );
47
- if (a <= 0n)
48
- throw new Error(
49
- `WASM Pre-PegIn peginAmount[${c}] is non-positive (${a}); expected > 0.`
50
- );
51
- if (f <= 0n)
52
- throw new Error(
53
- `WASM Pre-PegIn htlcValue[${c}] is non-positive (${f}); expected > 0.`
54
- );
55
- const d = f - a - e.depositorClaimValue;
56
- if (d <= 0n)
57
- throw new Error(
58
- `WASM Pre-PegIn htlcValue[${c}] ${f} does not strictly cover peginAmount ${a} + depositorClaimValue ${e.depositorClaimValue} + a PegIn reserve (implied reserve ${d}).`
59
- );
60
- if (d > h)
61
- throw new Error(
62
- `WASM Pre-PegIn implied reserve for HTLC[${c}] (${d} sat) exceeds the plausibility cap ${h} sat (minPeginFeeRate=${t.minPeginFeeRate} × ${T} vbytes); htlcValue ${f} appears grossly inflated.`
63
- );
64
- if (d !== u)
65
- throw new Error(
66
- `WASM Pre-PegIn htlcValue[${c}] ${f} implies a PegIn fee+anchor reserve of ${d} sat, expected exactly ${u} sat (minPeginFee ${s} + p2aAnchor ${i} for vaultCoreVersion ${t.vaultCoreVersion}, vaultKeepers=${t.vaultKeeperPubkeys.length}, universalChallengers=${t.universalChallengerPubkeys.length}, minPeginFeeRate=${t.minPeginFeeRate}).`
67
- );
68
- }
69
- return s;
70
- }
71
- class b extends Error {
72
- constructor(t) {
73
- super(t), this.name = "HtlcOutputMismatchError";
74
- }
75
- }
76
- function Ee(e, t, n) {
77
- if (e.length < t.length)
78
- throw new b(
79
- `Encoded Pre-PegIn tx has ${e.length} output(s), fewer than the ${t.length} HTLC output(s) the cross-check validated.`
80
- );
81
- for (let o = 0; o < t.length; o++) {
82
- const r = BigInt(e[o].value);
83
- if (r !== t[o])
84
- throw new b(
85
- `Encoded Pre-PegIn HTLC output[${o}] value ${r} does not match the cross-checked htlcValue ${t[o]}; the funded/signed tx would not pay the validated amount.`
86
- );
87
- const i = e[o].script.toString("hex").toLowerCase(), s = n[o].toLowerCase();
88
- if (i !== s)
89
- throw new b(
90
- `Encoded Pre-PegIn HTLC output[${o}] scriptPubKey ${i} does not match the cross-checked htlcScriptPubKey ${s}.`
91
- );
92
- }
93
- }
94
- const M = 64, Ce = /^[0-9a-fA-F]+$/;
95
- async function lt(e) {
96
- const t = oe(e.authAnchorHash), n = await ue({
97
- txGraphVersion: e.vaultCoreVersion,
98
- depositorPubkey: e.depositorPubkey,
99
- vaultProviderPubkey: e.vaultProviderPubkey,
100
- vaultKeeperPubkeys: e.vaultKeeperPubkeys,
101
- universalChallengerPubkeys: e.universalChallengerPubkeys,
102
- hashlocks: [...e.hashlocks],
103
- timelockRefund: e.timelockRefund,
104
- pegInAmounts: [...e.pegInAmounts],
105
- feeRate: e.feeRate,
106
- minPeginFeeRate: e.minPeginFeeRate,
107
- numLocalChallengers: e.numLocalChallengers,
108
- councilQuorum: e.councilQuorum,
109
- councilSize: e.councilSize,
110
- network: e.network,
111
- authAnchorHash: t
112
- }), o = await ye(n, e), r = ge(n.txHex);
113
- Ee(
114
- r.outputs,
115
- n.htlcValues,
116
- n.htlcScriptPubKeys
117
- );
118
- const i = r.outputs.reduce(
119
- (u, h) => u + BigInt(h.value),
120
- 0n
121
- ), s = t !== void 0 ? n.htlcValues.length : null;
122
- return {
123
- psbtHex: n.txHex,
124
- totalOutputValue: i,
125
- htlcValues: n.htlcValues,
126
- htlcScriptPubKeys: n.htlcScriptPubKeys,
127
- htlcAddresses: n.htlcAddresses,
128
- peginAmounts: n.peginAmounts,
129
- depositorClaimValue: n.depositorClaimValue,
130
- authAnchorVout: s,
131
- minPeginFee: o
132
- };
133
- }
134
- function oe(e) {
135
- if (e === void 0) return;
136
- const t = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e;
137
- if (t.length !== M || !Ce.test(t))
138
- throw new Error(
139
- `authAnchorHash must be 32-byte hex (${M} chars, no 0x prefix); got length ${t.length}`
140
- );
141
- return t.toLowerCase();
142
- }
143
- async function ht(e) {
144
- const t = await se(
145
- {
146
- txGraphVersion: e.prePeginParams.vaultCoreVersion,
147
- depositorPubkey: e.prePeginParams.depositorPubkey,
148
- vaultProviderPubkey: e.prePeginParams.vaultProviderPubkey,
149
- vaultKeeperPubkeys: e.prePeginParams.vaultKeeperPubkeys,
150
- universalChallengerPubkeys: e.prePeginParams.universalChallengerPubkeys,
151
- hashlocks: [...e.prePeginParams.hashlocks],
152
- timelockRefund: e.prePeginParams.timelockRefund,
153
- pegInAmounts: [...e.prePeginParams.pegInAmounts],
154
- feeRate: e.prePeginParams.feeRate,
155
- minPeginFeeRate: e.prePeginParams.minPeginFeeRate,
156
- numLocalChallengers: e.prePeginParams.numLocalChallengers,
157
- councilQuorum: e.prePeginParams.councilQuorum,
158
- councilSize: e.prePeginParams.councilSize,
159
- network: e.prePeginParams.network,
160
- authAnchorHash: oe(
161
- e.prePeginParams.authAnchorHash
162
- )
163
- },
164
- e.timelockPegin,
165
- e.fundedPrePeginTxHex,
166
- e.htlcVout
167
- );
168
- return await Ie(t, e), {
169
- txHex: t.txHex,
170
- txid: t.txid,
171
- vaultScriptPubKey: t.vaultScriptPubKey,
172
- vaultValue: t.vaultValue
173
- };
174
- }
175
- const Ae = 2, be = 1;
176
- async function Ie(e, t) {
177
- const n = t.prePeginParams.vaultCoreVersion;
178
- await ce(n, e.txHex);
179
- const o = await te(n), r = Ae + (o ? 1 : 0), i = x.fromHex(g(e.txHex));
180
- if (i.ins.length !== 1)
181
- throw new Error(
182
- `PegIn tx has ${i.ins.length} input(s), expected exactly 1 (the Pre-PegIn HTLC outpoint).`
183
- );
184
- const s = x.fromHex(
185
- g(t.fundedPrePeginTxHex)
186
- ).getId(), u = k(
187
- new Uint8Array(i.ins[0].hash).slice().reverse()
188
- );
189
- if (u !== s)
190
- throw new Error(
191
- `PegIn input spends txid ${u}, expected the funded Pre-PegIn ${s}.`
192
- );
193
- if (i.ins[0].index !== t.htlcVout)
194
- throw new Error(
195
- `PegIn input spends Pre-PegIn output ${i.ins[0].index}, expected the requested HTLC vout ${t.htlcVout}.`
196
- );
197
- if (i.outs.length !== r)
198
- throw new Error(
199
- `PegIn tx has ${i.outs.length} output(s), expected exactly ${r} for vaultCoreVersion ${n} (vault + depositor claim${o ? " + P2A anchor" : ""}).`
200
- );
201
- const h = t.prePeginParams.pegInAmounts[t.htlcVout];
202
- if (e.vaultValue !== h)
203
- throw new Error(
204
- `PegIn vault output value ${e.vaultValue} does not match the requested peg-in amount ${h} for HTLC ${t.htlcVout}; refusing to sign a vault that locks a different amount than requested.`
205
- );
206
- const c = i.outs[0];
207
- if (BigInt(c.value) !== e.vaultValue)
208
- throw new Error(
209
- `Encoded PegIn vault output value ${c.value} does not match the WASM-reported vaultValue ${e.vaultValue}.`
210
- );
211
- const l = c.script.toString("hex"), a = g(
212
- e.vaultScriptPubKey
213
- ).toLowerCase();
214
- if (l.toLowerCase() !== a)
215
- throw new Error(
216
- `Encoded PegIn vault output scriptPubKey ${l} does not match the WASM-reported vaultScriptPubKey ${e.vaultScriptPubKey}.`
217
- );
218
- const f = i.getId();
219
- if (f !== g(e.txid).toLowerCase())
220
- throw new Error(
221
- `Encoded PegIn txid ${f} does not match the WASM-reported txid ${e.txid}.`
222
- );
223
- const d = await ee(
224
- n,
225
- t.prePeginParams.numLocalChallengers,
226
- t.prePeginParams.universalChallengerPubkeys.length,
227
- t.prePeginParams.councilQuorum,
228
- t.prePeginParams.councilSize,
229
- t.prePeginParams.feeRate
230
- ), m = i.outs[be];
231
- if (BigInt(m.value) !== d)
232
- throw new Error(
233
- `Encoded PegIn depositor-claim output value ${m.value} does not match the independently computed claim value ${d} for vaultCoreVersion ${n}.`
234
- );
235
- const w = _e(
236
- t.prePeginParams.depositorPubkey
237
- );
238
- if (!m.script.equals(w))
239
- throw new Error(
240
- `Encoded PegIn depositor-claim output scriptPubKey ${m.script.toString("hex")} does not pay to the depositor's claim script (expected ${w.toString("hex")}).`
241
- );
242
- }
243
- function _e(e) {
244
- const t = he.compile([
245
- p.from(y(e)),
246
- de.OP_CHECKSIG
247
- ]), { output: n } = pe.p2tr({
248
- internalPubkey: p.from(ne),
249
- scriptTree: { output: t }
250
- });
251
- if (!n)
252
- throw new Error(
253
- "Failed to derive the depositor-claim P2TR scriptPubKey for PegIn output validation"
254
- );
255
- return n;
256
- }
257
- async function ke(e) {
258
- const t = await ae(
259
- {
260
- txGraphVersion: e.vaultCoreVersion,
261
- depositor: e.depositor,
262
- vaultProvider: e.vaultProvider,
263
- vaultKeepers: e.vaultKeepers,
264
- universalChallengers: e.universalChallengers,
265
- timelockPegin: e.timelockPegin
266
- },
267
- e.network
268
- );
269
- return {
270
- payoutScript: t.payoutScript,
271
- taprootScriptHash: t.taprootScriptHash,
272
- scriptPubKey: t.scriptPubKey,
273
- address: t.address,
274
- payoutControlBlock: t.payoutControlBlock
275
- };
276
- }
277
- const Ve = 256, Te = 1500, B = 256, W = 0xffffffffn, He = 500, Oe = 55, Le = 34;
278
- function Re(e) {
279
- if (typeof e.protocolFeeRate != "bigint" || e.protocolFeeRate <= 0n || e.protocolFeeRate > W)
280
- throw new Error(
281
- `protocolFeeRate must be in [1, ${W}] sat/vB, got ${e.protocolFeeRate}`
282
- );
283
- for (const [t, n, o, r] of [
284
- [
285
- "keepers",
286
- e.numVaultKeepers,
287
- Ve,
288
- "fee-floor model limit"
289
- ],
290
- [
291
- "challengers",
292
- e.numUniversalChallengers,
293
- Te,
294
- "protocol maximum"
295
- ]
296
- ])
297
- if (!Number.isInteger(n) || n < 1 || n > o)
298
- throw new Error(
299
- `Participant count for ${t} (${n}) is outside the supported range [1, ${o}]${n > o ? ` (${r})` : ""}.`
300
- );
301
- if (!Number.isInteger(e.councilSize) || e.councilSize < 1 || e.councilSize > B)
302
- throw new Error(
303
- `councilSize must be an integer in [1, ${B}], got ${e.councilSize}`
304
- );
305
- }
306
- async function Ue(e, t) {
307
- const { implicitFeeSats: n, out0Len: o, out1Len: r } = t, i = e.numVaultKeepers + e.numUniversalChallengers, s = BigInt(n), u = Math.max(0, o - Le), h = He + Oe * i + u, c = e.protocolFeeRate * BigInt(h);
308
- if (s > c)
309
- throw new Error(
310
- `Payout implicit fee ${n} sats exceeds the safety cap of ${c} sats (${e.protocolFeeRate} sat/vB x ${h} vB for ${i} participants); refusing to sign payout.`
311
- );
312
- const l = await le(
313
- e.vaultCoreVersion,
314
- e.numVaultKeepers,
315
- e.numUniversalChallengers,
316
- e.numVaultKeepers,
317
- e.councilSize,
318
- o,
319
- r,
320
- e.protocolFeeRate
321
- );
322
- if (s < l)
323
- throw new Error(
324
- `Payout implicit fee ${n} sats is below the floor of ${l} sats (the smallest fee any known vault-provider build produces for this shape); refusing to sign payout.`
325
- );
326
- }
327
- const Ke = 22, Ne = 34, Fe = 34, qe = 25, Me = 23;
328
- function Be(e) {
329
- return e.length === Ke * 2 && e.startsWith("0014");
330
- }
331
- function We(e) {
332
- return e.length === Ne * 2 && e.startsWith("0020");
333
- }
334
- function Xe(e) {
335
- return e.length === Fe * 2 && e.startsWith("5120");
336
- }
337
- function ze(e) {
338
- return e.length === qe * 2 && e.startsWith("76a914") && e.endsWith("88ac");
339
- }
340
- function De(e) {
341
- return e.length === Me * 2 && e.startsWith("a914") && e.endsWith("87");
342
- }
343
- function X(e, t) {
344
- const n = g(e).toLowerCase();
345
- if (n.length === 0)
346
- throw new Error(`${t} is empty`);
347
- if (!/^[0-9a-f]+$/.test(n) || n.length % 2 !== 0)
348
- throw new Error(`${t} is not valid hex`);
349
- if (n.startsWith("6a"))
350
- throw new Error(
351
- `${t} is an OP_RETURN output, which is provably unspendable`
352
- );
353
- if (!Xe(n) && !Be(n) && !We(n) && !ze(n) && !De(n))
354
- throw new Error(
355
- `${t} is not a standard scriptPubKey (expected P2TR, P2WPKH, P2WSH, P2PKH, or P2SH; got ${n.length / 2} bytes: ${n})`
356
- );
357
- }
358
- const z = 3;
359
- async function dt(e) {
360
- const t = {
361
- vaultCoreVersion: e.vaultCoreVersion,
362
- numVaultKeepers: e.vaultKeeperBtcPubkeys.length,
363
- numUniversalChallengers: e.universalChallengerBtcPubkeys.length,
364
- councilSize: e.councilSize,
365
- protocolFeeRate: e.protocolFeeRate
366
- };
367
- Re(t);
368
- const n = x.fromHex(g(e.payoutTxHex)), o = x.fromHex(g(e.peginTxHex)), r = x.fromHex(g(e.assertTxHex));
369
- if (n.ins.length !== L)
370
- throw new Error(
371
- `Payout transaction must have exactly ${L} inputs, got ${n.ins.length}`
372
- );
373
- if (n.version !== R)
374
- throw new Error(
375
- `Payout transaction version ${n.version} must be ${R}; refusing to sign payout.`
376
- );
377
- if (n.locktime !== U)
378
- throw new Error(
379
- `Payout transaction locktime ${n.locktime} must be ${U}; refusing to sign payout.`
380
- );
381
- const i = D(
382
- n.ins[0],
383
- 0,
384
- o,
385
- "PegIn",
386
- ve
387
- );
388
- if (n.ins[0].sequence !== e.timelockPegin)
389
- throw new Error(
390
- `Payout input 0 sequence ${n.ins[0].sequence} must equal the PegIn CSV timelock ${e.timelockPegin}; refusing to sign payout.`
391
- );
392
- const s = D(
393
- n.ins[1],
394
- 1,
395
- r,
396
- "Assert",
397
- $e
398
- );
399
- if (n.ins[1].sequence !== e.timelockAssert)
400
- throw new Error(
401
- `Payout input 1 sequence ${n.ins[1].sequence} must equal the Assert CSV timelock ${e.timelockAssert}; refusing to sign payout.`
402
- );
403
- const { out0Len: u, out1Len: h } = Ye(
404
- n,
405
- i.value,
406
- e
407
- ), c = i.value + s.value;
408
- let l = 0;
409
- for (const d of n.outs) l += d.value;
410
- if (l > c)
411
- throw new Error(
412
- `Payout outputs (${l} sats) exceed inputs (${c} sats); invalid transaction.`
413
- );
414
- const a = c - l;
415
- await Ue(t, {
416
- implicitFeeSats: a,
417
- out0Len: u,
418
- out1Len: h
419
- });
420
- const f = await ke({
421
- vaultCoreVersion: e.vaultCoreVersion,
422
- depositor: e.depositorBtcPubkey,
423
- vaultProvider: e.vaultProviderBtcPubkey,
424
- vaultKeepers: e.vaultKeeperBtcPubkeys,
425
- universalChallengers: e.universalChallengerBtcPubkeys,
426
- timelockPegin: e.timelockPegin,
427
- network: e.network
428
- });
429
- return {
430
- psbtHex: Ge(
431
- n,
432
- i,
433
- s,
434
- f
435
- )
436
- };
437
- }
438
- function D(e, t, n, o, r) {
439
- const i = k(
440
- new Uint8Array(e.hash).slice().reverse()
441
- ), s = n.getId();
442
- if (i !== s || e.index !== r)
443
- throw new Error(
444
- `Input ${t} must spend ${o}:${r}. Expected ${s}:${r}, got ${i}:${e.index}`
445
- );
446
- const u = n.outs[e.index];
447
- if (!u)
448
- throw new Error(
449
- `Previous output not found for input ${t} (txid: ${i}, index: ${e.index})`
450
- );
451
- return u;
452
- }
453
- function Ge(e, t, n, o) {
454
- const r = new C();
455
- r.setVersion(e.version), r.setLocktime(e.locktime);
456
- const [i, s] = e.ins;
457
- r.addInput({
458
- hash: i.hash,
459
- index: i.index,
460
- sequence: i.sequence,
461
- witnessUtxo: {
462
- script: t.script,
463
- value: t.value
464
- },
465
- tapLeafScript: [
466
- {
467
- leafVersion: I,
468
- script: p.from(y(o.payoutScript)),
469
- controlBlock: p.from(
470
- y(o.payoutControlBlock)
471
- )
472
- }
473
- ],
474
- tapInternalKey: p.from(ne)
475
- // sighashType omitted - defaults to SIGHASH_DEFAULT (0x00) for Taproot
476
- }), r.addInput({
477
- hash: s.hash,
478
- index: s.index,
479
- sequence: s.sequence,
480
- witnessUtxo: {
481
- script: n.script,
482
- value: n.value
483
- }
484
- });
485
- for (const u of e.outs)
486
- r.addOutput({
487
- script: u.script,
488
- value: u.value
489
- });
490
- return r.toHex();
491
- }
492
- function G(e, t) {
493
- const n = g(e).toLowerCase(), o = g(
494
- we(t)
495
- ).toLowerCase();
496
- return n === o ? [n] : [n, o];
497
- }
498
- function Y(e, t) {
499
- return t.some((n) => e.equals(p.from(n, "hex")));
500
- }
501
- function Ye(e, t, n) {
502
- const {
503
- claimerBtcPubkey: o,
504
- vaultProviderBtcPubkey: r,
505
- depositorBtcPubkey: i,
506
- vaultKeeperBtcPubkeys: s,
507
- registeredPayoutScriptPubKey: u,
508
- commissionBps: h,
509
- vkClaimerPayoutScriptPubKeys: c,
510
- vpCommissionScriptPubKey: l
511
- } = n;
512
- if (!fe(u))
513
- throw new Error("Invalid registeredPayoutScriptPubKey: not valid hex");
514
- const a = g(o).toLowerCase(), f = g(r).toLowerCase(), d = g(i).toLowerCase(), m = s.map(
515
- (S) => g(S).toLowerCase()
516
- );
517
- let w, P, v;
518
- if (a === f)
519
- w = "vp-claimer", P = Se, v = [g(u)];
520
- else if (a === d)
521
- w = "depositor-as-claimer", P = q, v = [g(u)];
522
- else if (m.includes(a)) {
523
- w = "vk-claimer", P = q;
524
- const S = c[a];
525
- if (S === void 0)
526
- throw new Error(
527
- `No registered payout script resolved for vault keeper claimer ${a}`
528
- );
529
- X(
530
- S,
531
- `Vault keeper payout script for claimer ${a}`
532
- ), v = G(S, a);
533
- } else
534
- throw new Error(
535
- `Unknown claimer pubkey ${a}: not VP, depositor, or a registered vault keeper`
536
- );
537
- if (e.outs.length !== P)
538
- throw new Error(
539
- `Payout transaction has ${e.outs.length} output(s), expected exactly ${P} for role ${w}.`
540
- );
541
- if (!Y(e.outs[0].script, v))
542
- throw new Error(
543
- `Payout transaction output 0 does not pay the expected scriptPubKey for role ${w}. Accepted: ${v.join(" or ")}; got ${e.outs[0].script.toString("hex")}`
544
- );
545
- const A = P - 1;
546
- if (e.outs[A].value !== K)
547
- throw new Error(
548
- `Payout CPFP anchor (out ${A}) value ${e.outs[A].value} sats must equal ${K} sats`
549
- );
550
- if (w === "vp-claimer") {
551
- X(
552
- l,
553
- "Vault provider commission payout script"
554
- );
555
- const S = G(
556
- l,
557
- f
558
- );
559
- if (!Y(e.outs[1].script, S))
560
- throw new Error(
561
- `Payout transaction output 1 does not pay the vault provider's commission scriptPubKey. Accepted: ${S.join(" or ")}; got ${e.outs[1].script.toString("hex")}`
562
- );
563
- if (!Number.isInteger(h) || h < 0 || h >= N)
564
- throw new Error(
565
- `commissionBps must be an integer in [0, ${N}), got ${h}`
566
- );
567
- const V = Math.floor(
568
- t * h / me
569
- );
570
- if (e.outs[1].value > V)
571
- throw new Error(
572
- `Payout VP commission (out 1) value ${e.outs[1].value} sats exceeds cap ${V} sats (${h} bps of peginValue=${t})`
573
- );
574
- }
575
- const E = e.outs[0].script.length;
576
- if (E === 0 || E > F)
577
- throw new Error(
578
- `Payout receiver scriptPubKey length ${E} is outside the contract's registration cap [1, ${F}]; refusing to sign payout.`
579
- );
580
- const re = w === "vp-claimer" ? e.outs[1].script.length : void 0;
581
- return { out0Len: E, out1Len: re };
582
- }
583
- function pt(e, t, n = 0) {
584
- const o = C.fromHex(e);
585
- if (n >= o.data.inputs.length)
586
- throw new Error(
587
- `Input index ${n} out of range (${o.data.inputs.length} inputs)`
588
- );
589
- const r = o.data.inputs[n];
590
- if (r.tapScriptSig && r.tapScriptSig.length > 0) {
591
- const i = y(t);
592
- for (const s of r.tapScriptSig)
593
- if (s.pubkey.equals(p.from(i)))
594
- return Q(s.signature, n);
595
- throw new Error(
596
- `No signature found for depositor pubkey: ${t} at input ${n}`
597
- );
598
- }
599
- if (r.finalScriptWitness && r.finalScriptWitness.length > 0) {
600
- const i = Qe(r.finalScriptWitness);
601
- if (i.length !== z)
602
- throw new Error(
603
- `Unexpected finalized witness stack size at input ${n}: expected ${z} items (signature, script, controlBlock), got ${i.length}`
604
- );
605
- return Q(i[0], n);
606
- }
607
- throw new Error(
608
- `No tapScriptSig or finalScriptWitness found in signed PSBT at input ${n}`
609
- );
610
- }
611
- function Q(e, t) {
612
- if (e.length === 64)
613
- return k(new Uint8Array(e));
614
- throw e.length === 65 ? new Error(
615
- `Unexpected sighash byte 0x${e[64].toString(16).padStart(2, "0")} at input ${t}. Expected implicit SIGHASH_DEFAULT as a 64-byte signature.`
616
- ) : new Error(
617
- `Unexpected signature length at input ${t}: ${e.length}`
618
- );
619
- }
620
- function Qe(e) {
621
- const t = [];
622
- let n = 0;
623
- const o = (s) => {
624
- if (n + s > e.length)
625
- throw new Error(
626
- `Malformed witness data: need ${s} byte(s) at offset ${n}, only ${e.length - n} remaining`
627
- );
628
- }, r = () => {
629
- o(1);
630
- const s = e[n++];
631
- if (s < 253) return s;
632
- if (s === 253) {
633
- o(2);
634
- const u = (e[n] | e[n + 1] << 8) >>> 0;
635
- return n += 2, u;
636
- }
637
- if (s === 254) {
638
- o(4);
639
- const u = (e[n] | e[n + 1] << 8 | e[n + 2] << 16 | e[n + 3] << 24) >>> 0;
640
- return n += 4, u;
641
- }
642
- throw new Error(
643
- `Malformed witness data: 8-byte varint (0xff) not supported at offset ${n - 1}`
644
- );
645
- }, i = r();
646
- for (let s = 0; s < i; s++) {
647
- const u = r();
648
- o(u), t.push(p.from(e.subarray(n, n + u))), n += u;
649
- }
650
- if (n !== e.length)
651
- throw new Error(
652
- `Malformed witness data: ${e.length - n} trailing byte(s) after parsing ${i} item(s)`
653
- );
654
- return t;
655
- }
656
- class $ extends Error {
657
- constructor(t) {
658
- super(
659
- `Wallet returned a PSBT for a different transaction: ${t}`
660
- ), this.name = "PsbtSubstitutionError";
661
- }
662
- }
663
- function Z(e, t) {
664
- try {
665
- return C.fromHex(t);
666
- } catch (n) {
667
- const o = n instanceof Error ? n.message : String(n);
668
- throw new Error(`Failed to parse ${e} PSBT: ${o}`);
669
- }
670
- }
671
- const Ze = 8;
672
- function _(e) {
673
- return `${e.toString("hex").slice(0, Ze)}…`;
674
- }
675
- function j(e) {
676
- const t = p.from(e).reverse();
677
- return _(t);
678
- }
679
- function Pt(e) {
680
- const t = Z("requested", e.requestedPsbtHex), n = Z("returned", e.returnedPsbtHex);
681
- if (t.version !== n.version)
682
- throw new $(
683
- `tx version differs (requested=${t.version}, returned=${n.version})`
684
- );
685
- if (t.locktime !== n.locktime)
686
- throw new $(
687
- `tx locktime differs (requested=${t.locktime}, returned=${n.locktime})`
688
- );
689
- if (t.txInputs.length !== n.txInputs.length)
690
- throw new $(
691
- `input count differs (requested=${t.txInputs.length}, returned=${n.txInputs.length})`
692
- );
693
- if (t.txOutputs.length !== n.txOutputs.length)
694
- throw new $(
695
- `output count differs (requested=${t.txOutputs.length}, returned=${n.txOutputs.length})`
696
- );
697
- for (let o = 0; o < t.txInputs.length; o++) {
698
- const r = t.txInputs[o], i = n.txInputs[o];
699
- if (!r.hash.equals(i.hash))
700
- throw new $(
701
- `input ${o} prevout txid differs (requested=${j(r.hash)}, returned=${j(i.hash)})`
702
- );
703
- if (r.index !== i.index)
704
- throw new $(
705
- `input ${o} prevout vout differs (requested=${r.index}, returned=${i.index})`
706
- );
707
- if (r.sequence !== i.sequence)
708
- throw new $(
709
- `input ${o} sequence differs (requested=${r.sequence}, returned=${i.sequence})`
710
- );
711
- }
712
- for (let o = 0; o < t.txOutputs.length; o++) {
713
- const r = t.txOutputs[o], i = n.txOutputs[o];
714
- if (!r.script.equals(i.script))
715
- throw new $(
716
- `output ${o} scriptPubKey differs (requested=${_(r.script)}, returned=${_(i.script)})`
717
- );
718
- if (r.value !== i.value)
719
- throw new $(
720
- `output ${o} value differs (requested=${r.value}, returned=${i.value})`
721
- );
722
- }
723
- }
724
- const J = 253, je = 254, Je = 65535, et = 4294967295;
725
- function tt(e) {
726
- if (e < J)
727
- return p.from([e]);
728
- if (e <= Je) {
729
- const t = p.alloc(2);
730
- return t.writeUInt16LE(e), p.concat([p.from([J]), t]);
731
- }
732
- if (e <= et) {
733
- const t = p.alloc(4);
734
- return t.writeUInt32LE(e), p.concat([p.from([je]), t]);
735
- }
736
- throw new Error(`Script too large to encode as CompactSize: ${e} bytes`);
737
- }
738
- const nt = "TapLeaf";
739
- function ot(e, t) {
740
- const n = p.concat([
741
- p.from([e]),
742
- tt(t.length),
743
- p.from(t)
744
- ]);
745
- return Pe.taggedHash(nt, n);
746
- }
747
- function gt(e) {
748
- const { requestedPsbtHex: t, signatureHex: n, signerXOnlyPubkeyHex: o, inputIndex: r } = e, i = g(n);
749
- if (i.length !== H)
750
- throw new Error(
751
- `Schnorr signature for input ${r} must be ${H} hex chars (64 bytes), got ${i.length}.`
752
- );
753
- const s = g(o);
754
- if (s.length !== O)
755
- throw new Error(
756
- `Signer x-only pubkey for input ${r} must be ${O} hex chars (32 bytes), got ${s.length}.`
757
- );
758
- const u = C.fromHex(t);
759
- if (r < 0 || r >= u.data.inputs.length)
760
- throw new Error(
761
- `Input index ${r} out of range (${u.data.inputs.length} inputs).`
762
- );
763
- const h = [], c = [];
764
- for (let P = 0; P < u.data.inputs.length; P++) {
765
- const v = u.data.inputs[P].witnessUtxo;
766
- if (!v)
767
- throw new Error(
768
- `Cannot verify signature: input ${P} of the requested PSBT has no witnessUtxo (required to recompute the Taproot sighash).`
769
- );
770
- h.push(v.script), c.push(v.value);
771
- }
772
- const l = u.data.inputs[r].tapLeafScript;
773
- if (!l || l.length !== 1)
774
- throw new Error(
775
- `Cannot verify signature: input ${r} of the requested PSBT must have exactly one tapLeafScript, got ${(l == null ? void 0 : l.length) ?? 0}.`
776
- );
777
- const a = l[0];
778
- if (a.leafVersion !== I)
779
- throw new Error(
780
- `Cannot verify signature: input ${r} tapLeafScript has leaf version 0x${a.leafVersion.toString(16)}, expected 0x${I.toString(16)}.`
781
- );
782
- const f = ot(a.leafVersion, a.script), d = new x();
783
- d.version = u.version, d.locktime = u.locktime;
784
- for (const P of u.txInputs)
785
- d.addInput(P.hash, P.index, P.sequence);
786
- for (const P of u.txOutputs)
787
- d.addOutput(P.script, P.value);
788
- const m = d.hashForWitnessV1(
789
- r,
790
- h,
791
- c,
792
- x.SIGHASH_DEFAULT,
793
- f
794
- );
795
- if (!xe.verifySchnorr(
796
- m,
797
- y(s),
798
- y(i)
799
- ))
800
- throw new Error(
801
- `Schnorr signature for input ${r} (signer ${s}) does not verify against the expected Taproot script-path sighash. The wallet may have signed with the tweaked key, signed a different transaction, or returned an invalid signature.`
802
- );
803
- }
804
- export {
805
- b as H,
806
- $ as P,
807
- lt as a,
808
- ht as b,
809
- dt as c,
810
- Pt as d,
811
- pt as e,
812
- gt as f,
813
- ke as g,
814
- Ee as h,
815
- oe as n
816
- };
817
- //# sourceMappingURL=verifyScriptPathSchnorrSignature-i-koT139.js.map