@babylonlabs-io/ts-sdk 3.1.2 → 3.2.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.
Files changed (168) hide show
  1. package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-BH2-LHxN.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-BmHpMUWD.js → BTCVaultRegistry.abi-BzNTa_EU.js} +19 -1
  4. package/dist/BTCVaultRegistry.abi-BzNTa_EU.js.map +1 -0
  5. package/dist/{PayoutManager-DOdsgcUR.cjs → PayoutManager-B1Ev0r7o.cjs} +2 -2
  6. package/dist/{PayoutManager-DOdsgcUR.cjs.map → PayoutManager-B1Ev0r7o.cjs.map} +1 -1
  7. package/dist/{PayoutManager-BZ212yml.js → PayoutManager-xEGvTbhL.js} +3 -3
  8. package/dist/{PayoutManager-BZ212yml.js.map → PayoutManager-xEGvTbhL.js.map} +1 -1
  9. package/dist/{PeginManager-PyKbfy5q.cjs → PeginManager-BCRtUqyX.cjs} +2 -2
  10. package/dist/{PeginManager-PyKbfy5q.cjs.map → PeginManager-BCRtUqyX.cjs.map} +1 -1
  11. package/dist/{PeginManager-Dfr5Qe1g.js → PeginManager-sizm3dlw.js} +7 -7
  12. package/dist/{PeginManager-Dfr5Qe1g.js.map → PeginManager-sizm3dlw.js.map} +1 -1
  13. package/dist/buildAndBroadcastReclaim-CE77jzTp.cjs +2 -0
  14. package/dist/buildAndBroadcastReclaim-CE77jzTp.cjs.map +1 -0
  15. package/dist/{buildAndBroadcastReclaim-R0HNpLMD.js → buildAndBroadcastReclaim-rQyAiAUS.js} +901 -867
  16. package/dist/buildAndBroadcastReclaim-rQyAiAUS.js.map +1 -0
  17. package/dist/challengeAssert-B2otuf7y.js +509 -0
  18. package/dist/challengeAssert-B2otuf7y.js.map +1 -0
  19. package/dist/challengeAssert-C3eMcM5Y.cjs +2 -0
  20. package/dist/challengeAssert-C3eMcM5Y.cjs.map +1 -0
  21. package/dist/constants-CAm10Qwp.cjs +2 -0
  22. package/dist/constants-CAm10Qwp.cjs.map +1 -0
  23. package/dist/constants-CvQZuxKv.js +48 -0
  24. package/dist/constants-CvQZuxKv.js.map +1 -0
  25. package/dist/{index-CVBtBjQ5.js → index-BRsWXDlv.js} +6 -6
  26. package/dist/{index-CVBtBjQ5.js.map → index-BRsWXDlv.js.map} +1 -1
  27. package/dist/{index-DpjYs5yr.cjs → index-C6avwx1s.cjs} +2 -2
  28. package/dist/{index-DpjYs5yr.cjs.map → index-C6avwx1s.cjs.map} +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +297 -298
  31. package/dist/index.js.map +1 -1
  32. package/dist/{pegin-registration-client-kdz4fT5_.js → pegin-registration-client-8tzSRDaq.js} +46 -45
  33. package/dist/pegin-registration-client-8tzSRDaq.js.map +1 -0
  34. package/dist/pegin-registration-client-Bmkh1OZ9.cjs +2 -0
  35. package/dist/pegin-registration-client-Bmkh1OZ9.cjs.map +1 -0
  36. package/dist/peginState-CIibG9S_.js +75 -0
  37. package/dist/peginState-CIibG9S_.js.map +1 -0
  38. package/dist/peginState-IyE22wWh.cjs +2 -0
  39. package/dist/peginState-IyE22wWh.cjs.map +1 -0
  40. package/dist/{primeVpAuth-BPj2TPdD.cjs → primeVpAuth-CXNXYKrh.cjs} +2 -2
  41. package/dist/{primeVpAuth-BPj2TPdD.cjs.map → primeVpAuth-CXNXYKrh.cjs.map} +1 -1
  42. package/dist/{primeVpAuth-CiCdRNGf.js → primeVpAuth-D4UWXQ76.js} +2 -2
  43. package/dist/{primeVpAuth-CiCdRNGf.js.map → primeVpAuth-D4UWXQ76.js.map} +1 -1
  44. package/dist/{registration-records-CKLAv3gw.js → registration-records-BBOz21Dm.js} +15 -15
  45. package/dist/{registration-records-CKLAv3gw.js.map → registration-records-BBOz21Dm.js.map} +1 -1
  46. package/dist/{registration-records-DFQgBaYi.cjs → registration-records-DaBufozs.cjs} +2 -2
  47. package/dist/{registration-records-DFQgBaYi.cjs.map → registration-records-DaBufozs.cjs.map} +1 -1
  48. package/dist/{reservation-DOAHVT3B.js → reservation-BZQABu4g.js} +2 -2
  49. package/dist/{reservation-DOAHVT3B.js.map → reservation-BZQABu4g.js.map} +1 -1
  50. package/dist/{reservation-ECxjZi5t.cjs → reservation-CA5knoQ0.cjs} +2 -2
  51. package/dist/{reservation-ECxjZi5t.cjs.map → reservation-CA5knoQ0.cjs.map} +1 -1
  52. package/dist/{signer-set-reader-DFAu6I-v.cjs → signer-set-reader-D-CyIYR5.cjs} +2 -2
  53. package/dist/{signer-set-reader-DFAu6I-v.cjs.map → signer-set-reader-D-CyIYR5.cjs.map} +1 -1
  54. package/dist/{signer-set-reader-BCtmSKUM.js → signer-set-reader-DFF9MgQN.js} +2 -2
  55. package/dist/{signer-set-reader-BCtmSKUM.js.map → signer-set-reader-DFF9MgQN.js.map} +1 -1
  56. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  57. package/dist/tbv/core/clients/eth/index.js +4 -4
  58. package/dist/tbv/core/clients/eth/types.d.ts +8 -0
  59. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  60. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  61. package/dist/tbv/core/clients/index.cjs +1 -1
  62. package/dist/tbv/core/clients/index.js +6 -6
  63. package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
  64. package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
  65. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +14 -0
  66. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  67. package/dist/tbv/core/contracts/index.cjs +1 -1
  68. package/dist/tbv/core/contracts/index.js +1 -1
  69. package/dist/tbv/core/index.cjs +1 -1
  70. package/dist/tbv/core/index.js +293 -294
  71. package/dist/tbv/core/index.js.map +1 -1
  72. package/dist/tbv/core/managers/index.cjs +1 -1
  73. package/dist/tbv/core/managers/index.js +2 -2
  74. package/dist/tbv/core/primitives/index.cjs +1 -1
  75. package/dist/tbv/core/primitives/index.js +29 -30
  76. package/dist/tbv/core/primitives/index.js.map +1 -1
  77. package/dist/tbv/core/primitives/psbt/__tests__/challengeAssert.test.d.ts +2 -0
  78. package/dist/tbv/core/primitives/psbt/__tests__/challengeAssert.test.d.ts.map +1 -0
  79. package/dist/tbv/core/primitives/psbt/__tests__/noPayout.test.d.ts +2 -0
  80. package/dist/tbv/core/primitives/psbt/__tests__/noPayout.test.d.ts.map +1 -0
  81. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +43 -0
  82. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  83. package/dist/tbv/core/primitives/psbt/constants.d.ts +50 -2
  84. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  85. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +42 -0
  86. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  87. package/dist/tbv/core/services/activation/activateVault.d.ts +50 -0
  88. package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -1
  89. package/dist/tbv/core/services/activation/index.d.ts +1 -1
  90. package/dist/tbv/core/services/activation/index.d.ts.map +1 -1
  91. package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts +9 -0
  92. package/dist/tbv/core/services/delegated-claim/__tests__/realWasmWatchtowerArtifacts.test.d.ts.map +1 -0
  93. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +5 -7
  94. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -1
  95. package/dist/tbv/core/services/delegated-claim/index.d.ts +3 -4
  96. package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -1
  97. package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts.map +1 -1
  98. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +14 -8
  99. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -1
  100. package/dist/tbv/core/services/delegated-claim/types.d.ts +32 -19
  101. package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
  102. package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts +12 -0
  103. package/dist/tbv/core/services/deposit/__tests__/signDepositorGraph.realGraph.test.d.ts.map +1 -0
  104. package/dist/tbv/core/services/deposit/peginState.d.ts +20 -1
  105. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  106. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +7 -0
  107. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  108. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +46 -1
  109. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  110. package/dist/tbv/core/services/index.cjs +1 -1
  111. package/dist/tbv/core/services/index.js +59 -59
  112. package/dist/tbv/core/utils/index.cjs +1 -1
  113. package/dist/tbv/core/utils/index.js +1 -1
  114. package/dist/tbv/core/wasm/__tests__/challengeAssertOutputConnector.test.d.ts +2 -0
  115. package/dist/tbv/core/wasm/__tests__/challengeAssertOutputConnector.test.d.ts.map +1 -0
  116. package/dist/tbv/core/wasm/index.cjs +1 -1
  117. package/dist/tbv/core/wasm/index.cjs.map +1 -1
  118. package/dist/tbv/core/wasm/index.d.ts +14 -2
  119. package/dist/tbv/core/wasm/index.d.ts.map +1 -1
  120. package/dist/tbv/core/wasm/index.js +81 -77
  121. package/dist/tbv/core/wasm/index.js.map +1 -1
  122. package/dist/tbv/index.cjs +1 -1
  123. package/dist/tbv/index.js +293 -294
  124. package/dist/tbv/index.js.map +1 -1
  125. package/dist/{toRefundInputs-BbAOOUg6.cjs → toRefundInputs-DOCLxqC1.cjs} +2 -2
  126. package/dist/{toRefundInputs-BbAOOUg6.cjs.map → toRefundInputs-DOCLxqC1.cjs.map} +1 -1
  127. package/dist/{toRefundInputs-DW14g6wH.js → toRefundInputs-Dso_QEr-.js} +5 -5
  128. package/dist/{toRefundInputs-DW14g6wH.js.map → toRefundInputs-Dso_QEr-.js.map} +1 -1
  129. package/dist/{types-Bda75Od0.cjs → types-DGr5HWwD.cjs} +2 -2
  130. package/dist/types-DGr5HWwD.cjs.map +1 -0
  131. package/dist/{types-C5jj3Cc-.js → types-Dbs--c2M.js} +2 -2
  132. package/dist/types-Dbs--c2M.js.map +1 -0
  133. package/dist/{verifyKeyPathSchnorrSignature-CQUut2-O.cjs → verifyKeyPathSchnorrSignature-BRTpEH9X.cjs} +2 -2
  134. package/dist/{verifyKeyPathSchnorrSignature-CQUut2-O.cjs.map → verifyKeyPathSchnorrSignature-BRTpEH9X.cjs.map} +1 -1
  135. package/dist/{verifyKeyPathSchnorrSignature-DxPbeSdQ.js → verifyKeyPathSchnorrSignature-IIj3Z2se.js} +2 -2
  136. package/dist/{verifyKeyPathSchnorrSignature-DxPbeSdQ.js.map → verifyKeyPathSchnorrSignature-IIj3Z2se.js.map} +1 -1
  137. package/dist/{verifyScriptPathSchnorrSignature-D2t1yACC.cjs → verifyScriptPathSchnorrSignature-CahYx5Td.cjs} +2 -2
  138. package/dist/{verifyScriptPathSchnorrSignature-D2t1yACC.cjs.map → verifyScriptPathSchnorrSignature-CahYx5Td.cjs.map} +1 -1
  139. package/dist/{verifyScriptPathSchnorrSignature-B3-VkvnK.js → verifyScriptPathSchnorrSignature-owu3BfyT.js} +2 -2
  140. package/dist/{verifyScriptPathSchnorrSignature-B3-VkvnK.js.map → verifyScriptPathSchnorrSignature-owu3BfyT.js.map} +1 -1
  141. package/package.json +3 -3
  142. package/dist/BTCVaultRegistry.abi-BmHpMUWD.js.map +0 -1
  143. package/dist/BTCVaultRegistry.abi-DffWFdpA.cjs +0 -2
  144. package/dist/BTCVaultRegistry.abi-DffWFdpA.cjs.map +0 -1
  145. package/dist/buildAndBroadcastReclaim-Da8rD5Z7.cjs +0 -2
  146. package/dist/buildAndBroadcastReclaim-Da8rD5Z7.cjs.map +0 -1
  147. package/dist/buildAndBroadcastReclaim-R0HNpLMD.js.map +0 -1
  148. package/dist/challengeAssert-Cp_GeRg8.js +0 -64
  149. package/dist/challengeAssert-Cp_GeRg8.js.map +0 -1
  150. package/dist/challengeAssert-Z7_YULBb.cjs +0 -2
  151. package/dist/challengeAssert-Z7_YULBb.cjs.map +0 -1
  152. package/dist/constants-BeYquVd-.js +0 -36
  153. package/dist/constants-BeYquVd-.js.map +0 -1
  154. package/dist/constants-BwCg5K6R.cjs +0 -2
  155. package/dist/constants-BwCg5K6R.cjs.map +0 -1
  156. package/dist/noPayout-B-vGXJ-V.js +0 -361
  157. package/dist/noPayout-B-vGXJ-V.js.map +0 -1
  158. package/dist/noPayout-DOHak0ui.cjs +0 -2
  159. package/dist/noPayout-DOHak0ui.cjs.map +0 -1
  160. package/dist/pegin-registration-client-C-abxMWq.cjs +0 -2
  161. package/dist/pegin-registration-client-C-abxMWq.cjs.map +0 -1
  162. package/dist/pegin-registration-client-kdz4fT5_.js.map +0 -1
  163. package/dist/peginState-BU2ONFXF.js +0 -68
  164. package/dist/peginState-BU2ONFXF.js.map +0 -1
  165. package/dist/peginState-DUv10EJR.cjs +0 -2
  166. package/dist/peginState-DUv10EJR.cjs.map +0 -1
  167. package/dist/types-Bda75Od0.cjs.map +0 -1
  168. package/dist/types-C5jj3Cc-.js.map +0 -1
@@ -1,64 +0,0 @@
1
- import { getChallengeAssertScriptInfo as A, tapInternalPubkey as P } from "./tbv/core/wasm/index.js";
2
- import { Buffer as a } from "buffer";
3
- import { Transaction as u, Psbt as w } from "bitcoinjs-lib";
4
- import { s as p, l as T, h as x, T as I } from "./bitcoin-C-TuHb-v.js";
5
- async function k(s) {
6
- const n = u.fromHex(
7
- p(s.challengeAssertTxHex)
8
- ), i = u.fromHex(p(s.assertTxHex)), c = i.getId();
9
- if (s.connectorParamsPerInput.length !== n.ins.length)
10
- throw new Error(
11
- `Expected ${n.ins.length} connector params, got ${s.connectorParamsPerInput.length}`
12
- );
13
- const l = /* @__PURE__ */ new Set();
14
- for (let t = 0; t < n.ins.length; t++) {
15
- const e = n.ins[t], o = T(e);
16
- if (o !== c)
17
- throw new Error(
18
- `ChallengeAssert input ${t} must spend an Assert output. Expected txid ${c}, got ${o}`
19
- );
20
- if (!i.outs[e.index])
21
- throw new Error(
22
- `Assert output ${e.index} not found for ChallengeAssert input ${t} (txid: ${c})`
23
- );
24
- if (l.has(e.index))
25
- throw new Error(
26
- `ChallengeAssert input ${t} duplicates Assert output index ${e.index}`
27
- );
28
- l.add(e.index);
29
- }
30
- const d = await Promise.all(
31
- s.connectorParamsPerInput.map((t) => A(t))
32
- ), r = new w();
33
- r.setVersion(n.version), r.setLocktime(n.locktime);
34
- for (let t = 0; t < n.ins.length; t++) {
35
- const e = n.ins[t], o = i.outs[e.index], { script: f, controlBlock: h } = d[t], m = x(f), g = x(h);
36
- r.addInput({
37
- hash: e.hash,
38
- index: e.index,
39
- sequence: e.sequence,
40
- witnessUtxo: {
41
- script: o.script,
42
- value: o.value
43
- },
44
- tapLeafScript: [
45
- {
46
- leafVersion: I,
47
- script: a.from(m),
48
- controlBlock: a.from(g)
49
- }
50
- ],
51
- tapInternalKey: a.from(P)
52
- });
53
- }
54
- for (const t of n.outs)
55
- r.addOutput({
56
- script: t.script,
57
- value: t.value
58
- });
59
- return r.toHex();
60
- }
61
- export {
62
- k as b
63
- };
64
- //# sourceMappingURL=challengeAssert-Cp_GeRg8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"challengeAssert-Cp_GeRg8.js","sources":["../src/tbv/core/primitives/psbt/challengeAssert.ts"],"sourcesContent":["/**\n * ChallengeAssert PSBT Builder\n *\n * Builds an unsigned PSBT for a ChallengeAssert transaction. ChallengeAssert\n * is split across two single-input transactions — ChallengeAssertX (spends the\n * challenger's ConnectorX Assert output) and ChallengeAssertY (spends\n * ConnectorY). This builder handles one such transaction.\n *\n * The protocol collects no claimer signature on ChallengeAssert — the\n * challenger signs it at broadcast (btc-vault `tx_graph/challenger.rs`). This\n * builder exists for tooling that reconstructs the graph; it is not on the\n * depositor presign path (`signDepositorGraph` signs Payout + NoPayout only).\n *\n * @module primitives/psbt/challengeAssert\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md — ChallengeAssertX / ChallengeAssertY\n */\n\nimport {\n type ChallengeAssertConnectorParams,\n getChallengeAssertScriptInfo,\n tapInternalPubkey,\n} from \"../../wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\n\nimport {\n TAPSCRIPT_LEAF_VERSION,\n hexToUint8Array,\n inputTxidHex,\n stripHexPrefix,\n} from \"../utils/bitcoin\";\n\n/**\n * Parameters for building a ChallengeAssert PSBT\n */\nexport interface ChallengeAssertParams {\n /** ChallengeAssert transaction hex (unsigned) */\n challengeAssertTxHex: string;\n /** Authoritative Assert transaction hex — every input must spend an Assert output */\n assertTxHex: string;\n /** Per-input connector params (one per input/segment, determines the taproot script) */\n connectorParamsPerInput: ChallengeAssertConnectorParams[];\n}\n\n/**\n * Build unsigned ChallengeAssert PSBT.\n *\n * Each input has its own taproot script derived from its connector params; the\n * number of connector params must match the transaction's input count.\n * Every prevout is derived from the authoritative\n * Assert transaction, never trusted from external input.\n *\n * @param params - ChallengeAssert parameters\n * @returns Unsigned PSBT hex ready for signing\n *\n * @throws If the number of connector params does not match the number of inputs\n * @throws If any input does not reference assertTxHex\n * @throws If any referenced Assert output is missing\n * @throws If two inputs reference the same Assert output index\n */\nexport async function buildChallengeAssertPsbt(\n params: ChallengeAssertParams,\n): Promise<string> {\n const challengeAssertTx = Transaction.fromHex(\n stripHexPrefix(params.challengeAssertTxHex),\n );\n const assertTx = Transaction.fromHex(stripHexPrefix(params.assertTxHex));\n const assertTxid = assertTx.getId();\n\n if (params.connectorParamsPerInput.length !== challengeAssertTx.ins.length) {\n throw new Error(\n `Expected ${challengeAssertTx.ins.length} connector params, got ${params.connectorParamsPerInput.length}`,\n );\n }\n\n const seenAssertOutputs = new Set<number>();\n for (let i = 0; i < challengeAssertTx.ins.length; i++) {\n const input = challengeAssertTx.ins[i];\n const inputTxid = inputTxidHex(input);\n if (inputTxid !== assertTxid) {\n throw new Error(\n `ChallengeAssert input ${i} must spend an Assert output. ` +\n `Expected txid ${assertTxid}, got ${inputTxid}`,\n );\n }\n if (!assertTx.outs[input.index]) {\n throw new Error(\n `Assert output ${input.index} not found for ChallengeAssert input ${i} (txid: ${assertTxid})`,\n );\n }\n if (seenAssertOutputs.has(input.index)) {\n throw new Error(\n `ChallengeAssert input ${i} duplicates Assert output index ${input.index}`,\n );\n }\n seenAssertOutputs.add(input.index);\n }\n\n const scriptInfos = await Promise.all(\n params.connectorParamsPerInput.map((cp) => getChallengeAssertScriptInfo(cp)),\n );\n\n const psbt = new Psbt();\n psbt.setVersion(challengeAssertTx.version);\n psbt.setLocktime(challengeAssertTx.locktime);\n\n for (let i = 0; i < challengeAssertTx.ins.length; i++) {\n const input = challengeAssertTx.ins[i];\n const assertPrevOut = assertTx.outs[input.index];\n\n const { script, controlBlock } = scriptInfos[i];\n const scriptBytes = hexToUint8Array(script);\n const controlBlockBytes = hexToUint8Array(controlBlock);\n\n psbt.addInput({\n hash: input.hash,\n index: input.index,\n sequence: input.sequence,\n witnessUtxo: {\n script: assertPrevOut.script,\n value: assertPrevOut.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(scriptBytes),\n controlBlock: Buffer.from(controlBlockBytes),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n });\n }\n\n for (const output of challengeAssertTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return psbt.toHex();\n}\n"],"names":["buildChallengeAssertPsbt","params","challengeAssertTx","Transaction","stripHexPrefix","assertTx","assertTxid","seenAssertOutputs","i","input","inputTxid","inputTxidHex","scriptInfos","cp","getChallengeAssertScriptInfo","psbt","Psbt","assertPrevOut","script","controlBlock","scriptBytes","hexToUint8Array","controlBlockBytes","TAPSCRIPT_LEAF_VERSION","Buffer","tapInternalPubkey","output"],"mappings":";;;;AA4DA,eAAsBA,EACpBC,GACiB;AACjB,QAAMC,IAAoBC,EAAY;AAAA,IACpCC,EAAeH,EAAO,oBAAoB;AAAA,EAAA,GAEtCI,IAAWF,EAAY,QAAQC,EAAeH,EAAO,WAAW,CAAC,GACjEK,IAAaD,EAAS,MAAA;AAE5B,MAAIJ,EAAO,wBAAwB,WAAWC,EAAkB,IAAI;AAClE,UAAM,IAAI;AAAA,MACR,YAAYA,EAAkB,IAAI,MAAM,0BAA0BD,EAAO,wBAAwB,MAAM;AAAA,IAAA;AAI3G,QAAMM,wBAAwB,IAAA;AAC9B,WAASC,IAAI,GAAGA,IAAIN,EAAkB,IAAI,QAAQM,KAAK;AACrD,UAAMC,IAAQP,EAAkB,IAAIM,CAAC,GAC/BE,IAAYC,EAAaF,CAAK;AACpC,QAAIC,MAAcJ;AAChB,YAAM,IAAI;AAAA,QACR,yBAAyBE,CAAC,+CACPF,CAAU,SAASI,CAAS;AAAA,MAAA;AAGnD,QAAI,CAACL,EAAS,KAAKI,EAAM,KAAK;AAC5B,YAAM,IAAI;AAAA,QACR,iBAAiBA,EAAM,KAAK,wCAAwCD,CAAC,WAAWF,CAAU;AAAA,MAAA;AAG9F,QAAIC,EAAkB,IAAIE,EAAM,KAAK;AACnC,YAAM,IAAI;AAAA,QACR,yBAAyBD,CAAC,mCAAmCC,EAAM,KAAK;AAAA,MAAA;AAG5E,IAAAF,EAAkB,IAAIE,EAAM,KAAK;AAAA,EACnC;AAEA,QAAMG,IAAc,MAAM,QAAQ;AAAA,IAChCX,EAAO,wBAAwB,IAAI,CAACY,MAAOC,EAA6BD,CAAE,CAAC;AAAA,EAAA,GAGvEE,IAAO,IAAIC,EAAA;AACjB,EAAAD,EAAK,WAAWb,EAAkB,OAAO,GACzCa,EAAK,YAAYb,EAAkB,QAAQ;AAE3C,WAASM,IAAI,GAAGA,IAAIN,EAAkB,IAAI,QAAQM,KAAK;AACrD,UAAMC,IAAQP,EAAkB,IAAIM,CAAC,GAC/BS,IAAgBZ,EAAS,KAAKI,EAAM,KAAK,GAEzC,EAAE,QAAAS,GAAQ,cAAAC,MAAiBP,EAAYJ,CAAC,GACxCY,IAAcC,EAAgBH,CAAM,GACpCI,IAAoBD,EAAgBF,CAAY;AAEtD,IAAAJ,EAAK,SAAS;AAAA,MACZ,MAAMN,EAAM;AAAA,MACZ,OAAOA,EAAM;AAAA,MACb,UAAUA,EAAM;AAAA,MAChB,aAAa;AAAA,QACX,QAAQQ,EAAc;AAAA,QACtB,OAAOA,EAAc;AAAA,MAAA;AAAA,MAEvB,eAAe;AAAA,QACb;AAAA,UACE,aAAaM;AAAA,UACb,QAAQC,EAAO,KAAKJ,CAAW;AAAA,UAC/B,cAAcI,EAAO,KAAKF,CAAiB;AAAA,QAAA;AAAA,MAC7C;AAAA,MAEF,gBAAgBE,EAAO,KAAKC,CAAiB;AAAA,IAAA,CAC9C;AAAA,EACH;AAEA,aAAWC,KAAUxB,EAAkB;AACrC,IAAAa,EAAK,UAAU;AAAA,MACb,QAAQW,EAAO;AAAA,MACf,OAAOA,EAAO;AAAA,IAAA,CACf;AAGH,SAAOX,EAAK,MAAA;AACd;"}
@@ -1,2 +0,0 @@
1
- "use strict";const x=require("./tbv/core/wasm/index.cjs"),a=require("buffer"),l=require("bitcoinjs-lib"),s=require("./bitcoin-D-O2GjbC.cjs");async function P(r){const n=l.Transaction.fromHex(s.stripHexPrefix(r.challengeAssertTxHex)),c=l.Transaction.fromHex(s.stripHexPrefix(r.assertTxHex)),u=c.getId();if(r.connectorParamsPerInput.length!==n.ins.length)throw new Error(`Expected ${n.ins.length} connector params, got ${r.connectorParamsPerInput.length}`);const p=new Set;for(let t=0;t<n.ins.length;t++){const e=n.ins[t],i=s.inputTxidHex(e);if(i!==u)throw new Error(`ChallengeAssert input ${t} must spend an Assert output. Expected txid ${u}, got ${i}`);if(!c.outs[e.index])throw new Error(`Assert output ${e.index} not found for ChallengeAssert input ${t} (txid: ${u})`);if(p.has(e.index))throw new Error(`ChallengeAssert input ${t} duplicates Assert output index ${e.index}`);p.add(e.index)}const f=await Promise.all(r.connectorParamsPerInput.map(t=>x.getChallengeAssertScriptInfo(t))),o=new l.Psbt;o.setVersion(n.version),o.setLocktime(n.locktime);for(let t=0;t<n.ins.length;t++){const e=n.ins[t],i=c.outs[e.index],{script:d,controlBlock:h}=f[t],g=s.hexToUint8Array(d),A=s.hexToUint8Array(h);o.addInput({hash:e.hash,index:e.index,sequence:e.sequence,witnessUtxo:{script:i.script,value:i.value},tapLeafScript:[{leafVersion:s.TAPSCRIPT_LEAF_VERSION,script:a.Buffer.from(g),controlBlock:a.Buffer.from(A)}],tapInternalKey:a.Buffer.from(x.tapInternalPubkey)})}for(const t of n.outs)o.addOutput({script:t.script,value:t.value});return o.toHex()}exports.buildChallengeAssertPsbt=P;
2
- //# sourceMappingURL=challengeAssert-Z7_YULBb.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"challengeAssert-Z7_YULBb.cjs","sources":["../src/tbv/core/primitives/psbt/challengeAssert.ts"],"sourcesContent":["/**\n * ChallengeAssert PSBT Builder\n *\n * Builds an unsigned PSBT for a ChallengeAssert transaction. ChallengeAssert\n * is split across two single-input transactions — ChallengeAssertX (spends the\n * challenger's ConnectorX Assert output) and ChallengeAssertY (spends\n * ConnectorY). This builder handles one such transaction.\n *\n * The protocol collects no claimer signature on ChallengeAssert — the\n * challenger signs it at broadcast (btc-vault `tx_graph/challenger.rs`). This\n * builder exists for tooling that reconstructs the graph; it is not on the\n * depositor presign path (`signDepositorGraph` signs Payout + NoPayout only).\n *\n * @module primitives/psbt/challengeAssert\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md — ChallengeAssertX / ChallengeAssertY\n */\n\nimport {\n type ChallengeAssertConnectorParams,\n getChallengeAssertScriptInfo,\n tapInternalPubkey,\n} from \"../../wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\n\nimport {\n TAPSCRIPT_LEAF_VERSION,\n hexToUint8Array,\n inputTxidHex,\n stripHexPrefix,\n} from \"../utils/bitcoin\";\n\n/**\n * Parameters for building a ChallengeAssert PSBT\n */\nexport interface ChallengeAssertParams {\n /** ChallengeAssert transaction hex (unsigned) */\n challengeAssertTxHex: string;\n /** Authoritative Assert transaction hex — every input must spend an Assert output */\n assertTxHex: string;\n /** Per-input connector params (one per input/segment, determines the taproot script) */\n connectorParamsPerInput: ChallengeAssertConnectorParams[];\n}\n\n/**\n * Build unsigned ChallengeAssert PSBT.\n *\n * Each input has its own taproot script derived from its connector params; the\n * number of connector params must match the transaction's input count.\n * Every prevout is derived from the authoritative\n * Assert transaction, never trusted from external input.\n *\n * @param params - ChallengeAssert parameters\n * @returns Unsigned PSBT hex ready for signing\n *\n * @throws If the number of connector params does not match the number of inputs\n * @throws If any input does not reference assertTxHex\n * @throws If any referenced Assert output is missing\n * @throws If two inputs reference the same Assert output index\n */\nexport async function buildChallengeAssertPsbt(\n params: ChallengeAssertParams,\n): Promise<string> {\n const challengeAssertTx = Transaction.fromHex(\n stripHexPrefix(params.challengeAssertTxHex),\n );\n const assertTx = Transaction.fromHex(stripHexPrefix(params.assertTxHex));\n const assertTxid = assertTx.getId();\n\n if (params.connectorParamsPerInput.length !== challengeAssertTx.ins.length) {\n throw new Error(\n `Expected ${challengeAssertTx.ins.length} connector params, got ${params.connectorParamsPerInput.length}`,\n );\n }\n\n const seenAssertOutputs = new Set<number>();\n for (let i = 0; i < challengeAssertTx.ins.length; i++) {\n const input = challengeAssertTx.ins[i];\n const inputTxid = inputTxidHex(input);\n if (inputTxid !== assertTxid) {\n throw new Error(\n `ChallengeAssert input ${i} must spend an Assert output. ` +\n `Expected txid ${assertTxid}, got ${inputTxid}`,\n );\n }\n if (!assertTx.outs[input.index]) {\n throw new Error(\n `Assert output ${input.index} not found for ChallengeAssert input ${i} (txid: ${assertTxid})`,\n );\n }\n if (seenAssertOutputs.has(input.index)) {\n throw new Error(\n `ChallengeAssert input ${i} duplicates Assert output index ${input.index}`,\n );\n }\n seenAssertOutputs.add(input.index);\n }\n\n const scriptInfos = await Promise.all(\n params.connectorParamsPerInput.map((cp) => getChallengeAssertScriptInfo(cp)),\n );\n\n const psbt = new Psbt();\n psbt.setVersion(challengeAssertTx.version);\n psbt.setLocktime(challengeAssertTx.locktime);\n\n for (let i = 0; i < challengeAssertTx.ins.length; i++) {\n const input = challengeAssertTx.ins[i];\n const assertPrevOut = assertTx.outs[input.index];\n\n const { script, controlBlock } = scriptInfos[i];\n const scriptBytes = hexToUint8Array(script);\n const controlBlockBytes = hexToUint8Array(controlBlock);\n\n psbt.addInput({\n hash: input.hash,\n index: input.index,\n sequence: input.sequence,\n witnessUtxo: {\n script: assertPrevOut.script,\n value: assertPrevOut.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(scriptBytes),\n controlBlock: Buffer.from(controlBlockBytes),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n });\n }\n\n for (const output of challengeAssertTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return psbt.toHex();\n}\n"],"names":["buildChallengeAssertPsbt","params","challengeAssertTx","Transaction","stripHexPrefix","assertTx","assertTxid","seenAssertOutputs","i","input","inputTxid","inputTxidHex","scriptInfos","cp","getChallengeAssertScriptInfo","psbt","Psbt","assertPrevOut","script","controlBlock","scriptBytes","hexToUint8Array","controlBlockBytes","TAPSCRIPT_LEAF_VERSION","Buffer","tapInternalPubkey","output"],"mappings":"6IA4DA,eAAsBA,EACpBC,EACiB,CACjB,MAAMC,EAAoBC,EAAAA,YAAY,QACpCC,EAAAA,eAAeH,EAAO,oBAAoB,CAAA,EAEtCI,EAAWF,EAAAA,YAAY,QAAQC,EAAAA,eAAeH,EAAO,WAAW,CAAC,EACjEK,EAAaD,EAAS,MAAA,EAE5B,GAAIJ,EAAO,wBAAwB,SAAWC,EAAkB,IAAI,OAClE,MAAM,IAAI,MACR,YAAYA,EAAkB,IAAI,MAAM,0BAA0BD,EAAO,wBAAwB,MAAM,EAAA,EAI3G,MAAMM,MAAwB,IAC9B,QAASC,EAAI,EAAGA,EAAIN,EAAkB,IAAI,OAAQM,IAAK,CACrD,MAAMC,EAAQP,EAAkB,IAAIM,CAAC,EAC/BE,EAAYC,EAAAA,aAAaF,CAAK,EACpC,GAAIC,IAAcJ,EAChB,MAAM,IAAI,MACR,yBAAyBE,CAAC,+CACPF,CAAU,SAASI,CAAS,EAAA,EAGnD,GAAI,CAACL,EAAS,KAAKI,EAAM,KAAK,EAC5B,MAAM,IAAI,MACR,iBAAiBA,EAAM,KAAK,wCAAwCD,CAAC,WAAWF,CAAU,GAAA,EAG9F,GAAIC,EAAkB,IAAIE,EAAM,KAAK,EACnC,MAAM,IAAI,MACR,yBAAyBD,CAAC,mCAAmCC,EAAM,KAAK,EAAA,EAG5EF,EAAkB,IAAIE,EAAM,KAAK,CACnC,CAEA,MAAMG,EAAc,MAAM,QAAQ,IAChCX,EAAO,wBAAwB,IAAKY,GAAOC,EAAAA,6BAA6BD,CAAE,CAAC,CAAA,EAGvEE,EAAO,IAAIC,OACjBD,EAAK,WAAWb,EAAkB,OAAO,EACzCa,EAAK,YAAYb,EAAkB,QAAQ,EAE3C,QAASM,EAAI,EAAGA,EAAIN,EAAkB,IAAI,OAAQM,IAAK,CACrD,MAAMC,EAAQP,EAAkB,IAAIM,CAAC,EAC/BS,EAAgBZ,EAAS,KAAKI,EAAM,KAAK,EAEzC,CAAE,OAAAS,EAAQ,aAAAC,GAAiBP,EAAYJ,CAAC,EACxCY,EAAcC,EAAAA,gBAAgBH,CAAM,EACpCI,EAAoBD,EAAAA,gBAAgBF,CAAY,EAEtDJ,EAAK,SAAS,CACZ,KAAMN,EAAM,KACZ,MAAOA,EAAM,MACb,SAAUA,EAAM,SAChB,YAAa,CACX,OAAQQ,EAAc,OACtB,MAAOA,EAAc,KAAA,EAEvB,cAAe,CACb,CACE,YAAaM,EAAAA,uBACb,OAAQC,EAAAA,OAAO,KAAKJ,CAAW,EAC/B,aAAcI,EAAAA,OAAO,KAAKF,CAAiB,CAAA,CAC7C,EAEF,eAAgBE,EAAAA,OAAO,KAAKC,EAAAA,iBAAiB,CAAA,CAC9C,CACH,CAEA,UAAWC,KAAUxB,EAAkB,KACrCa,EAAK,UAAU,CACb,OAAQW,EAAO,OACf,MAAOA,EAAO,KAAA,CACf,EAGH,OAAOX,EAAK,MAAA,CACd"}
@@ -1,36 +0,0 @@
1
- const _ = 2, T = 1, E = 0, s = 0, N = 0, P = 1, I = 0, O = 0, U = 0, A = 0, a = 546, o = 1, t = 0, R = "6a20", c = 546, n = 2, S = 0, C = 2, L = 3, X = 0, D = 4294967294, G = 2, M = 0, V = 2, Y = 0, H = 0, e = 3, F = 2, K = 2, B = 1e4, p = 1e4, r = 128;
2
- export {
3
- s as A,
4
- p as B,
5
- U as C,
6
- T as D,
7
- B as M,
8
- F as N,
9
- n as P,
10
- G as R,
11
- e as V,
12
- A as W,
13
- M as a,
14
- r as b,
15
- S as c,
16
- o as d,
17
- t as e,
18
- R as f,
19
- c as g,
20
- C as h,
21
- L as i,
22
- X as j,
23
- D as k,
24
- _ as l,
25
- V as m,
26
- Y as n,
27
- a as o,
28
- E as p,
29
- O as q,
30
- P as r,
31
- N as s,
32
- I as t,
33
- H as u,
34
- K as v
35
- };
36
- //# sourceMappingURL=constants-BeYquVd-.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-BeYquVd-.js","sources":["../src/tbv/core/primitives/psbt/constants.ts"],"sourcesContent":["/**\n * Protocol invariants for depositor graph transactions.\n *\n * These indices and counts encode the on-chain vault protocol layout\n * (which output of PegIn/Assert each child transaction spends, and how\n * many inputs each transaction has). Consumed by the PSBT builders and\n * the depositor graph signing service; a drift between copies of these\n * values would silently change validation behaviour.\n *\n * @module primitives/psbt/constants\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md\n */\n\n/**\n * Depositor Payout transaction input count.\n * Input 0: PegIn:0 ({@link PAYOUT_PEGIN_INPUT_INDEX}). Input 1: Assert:0\n * ({@link PAYOUT_ASSERT_INPUT_INDEX} carries the signing regimes).\n */\nexport const DEPOSITOR_PAYOUT_INPUT_COUNT = 2;\n\n/**\n * Inputs the depositor signs per Payout / NoPayout PSBT at deposit time:\n * input 0 only. The other inputs are in the SIGHASH_DEFAULT sighash but carry\n * no depositor signature there — the Ledger host expects exactly this many\n * yields, so a drift here re-arms an input the device never signs at deposit\n * time.\n */\nexport const DEPOSITOR_SIGNED_INPUT_COUNT = 1;\n\n/** PegIn vault output index spent by the depositor's Payout input 0. */\nexport const PEGIN_VAULT_OUTPUT_INDEX = 0;\n\n/**\n * Assert output index spent by the Payout's input 1\n * ({@link PAYOUT_ASSERT_INPUT_INDEX} carries the signing regimes).\n */\nexport const ASSERT_PAYOUT_OUTPUT_INDEX = 0;\n\n/** Payout input that spends the Vault UTXO (PegIn:{@link PEGIN_VAULT_OUTPUT_INDEX}); the depositor signs it in both regimes. */\nexport const PAYOUT_PEGIN_INPUT_INDEX = 0;\n\n/** Payout input that spends the Assert connector (Assert:{@link ASSERT_PAYOUT_OUTPUT_INDEX}); the claimer signs it, which is the depositor only in a delegated claim. */\nexport const PAYOUT_ASSERT_INPUT_INDEX = 1;\n\n/**\n * Claim input that spends the vault's PegIn. A depositor-as-claimer recovery\n * Claim is funded by exactly the PegIn's depositor-claim output\n * (`DEPOSITOR_CLAIM_VOUT = 1` in btc-vault `crates/vault/src/lib.rs:272`, used by\n * `depositor_claim_funding_outpoint` in `crates/vault/src/transactions/claim.rs:119-121`\n * @ ac4954e7); the depositor signs it.\n */\nexport const CLAIM_PEGIN_INPUT_INDEX = 0;\n\n/**\n * Assert input that spends the Claim connector\n * (Claim:{@link CLAIM_CONNECTOR_OUTPUT_INDEX}); the claimer signs it. Matches\n * `CLAIM_ASSERT_INPUT` in btc-vault `crates/vault/src/transactions/assert.rs:56` @ ac4954e7.\n */\nexport const ASSERT_CLAIM_INPUT_INDEX = 0;\n\n/**\n * Claim output the Assert spends. Matches `CLAIM_ASSERT_OUTPUT_INDEX` in\n * btc-vault `crates/vault/src/transactions/claim.rs:25` @ ac4954e7.\n */\nexport const CLAIM_CONNECTOR_OUTPUT_INDEX = 0;\n\n/**\n * WronglyChallenged input that spends the ChallengeAssert connector; the\n * claimer signs it, which is the depositor only in a delegated claim. Matches\n * `CHALLENGE_ASSERT_INPUT` in btc-vault\n * `crates/vault/src/transactions/wrongly_challenged.rs:35`, the input\n * `claimer_signing_psbt` hands the external signer (`:187`) and `sign_claimer`\n * signs natively (`:243`) @ ac4954e7.\n */\nexport const WRONGLY_CHALLENGED_INPUT_INDEX = 0;\n\n/**\n * Dust amount (sats) for the payout CPFP anchor output. Matches `DUST_AMOUNT`\n * in `btc-vault crates/vault/src/lib.rs`.\n */\nexport const PAYOUT_ANCHOR_DUST_SATS = 546;\n\n/** Minimum number of HTLC outputs in a Pre-PegIn transaction. */\nexport const PRE_PEGIN_MIN_HTLC_OUTPUT_COUNT = 1;\n\n/** Canonical value in sats for the optional Pre-PegIn auth output. */\nexport const PRE_PEGIN_AUTH_OUTPUT_VALUE_SATS = 0;\n\n/**\n * Hex prefix for `OP_RETURN PUSH32`. This matches\n * `ScriptBuf::new_op_return(hash)` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_AUTH_SCRIPT_PREFIX = \"6a20\";\n\n/**\n * Value in sats for the Pre-PegIn CPFP anchor output. Matches `DUST_AMOUNT`\n * in `btc-vault crates/vault/src/lib.rs`.\n */\nexport const PRE_PEGIN_CPFP_VALUE_SATS = 546;\n\n/**\n * Canonical Pre-PegIn transaction version. Matches `Version::TWO` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_TX_VERSION = 2;\n\n/**\n * Canonical Pre-PegIn transaction locktime. Matches `LockTime::ZERO` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_TX_LOCKTIME = 0;\n\n/** Vault Core 1 PegIn nVersion from `PegInTx::expected_tx_version`. */\nexport const PEGIN_TX_VERSION_CORE_1 = 2;\n\n/** Vault Core 2 and 3 PegIn nVersion from `PegInTx::expected_tx_version`. */\nexport const PEGIN_TX_VERSION_CORE_2_AND_3 = 3;\n\n/** PegIn locktime from `PegInTx::new_from_prepegin` (`LockTime::ZERO`). */\nexport const PEGIN_TX_LOCKTIME = 0;\n\n/** PegIn input sequence from `PegInTx::new_from_prepegin`. */\nexport const PEGIN_INPUT_SEQUENCE = 0xfffffffe;\n\n/**\n * Refund version and locktime match `WasmPrePeginTx::build_refund_tx`\n * (`Version::TWO`, `LockTime::ZERO`) in `btc-vault crates/vault/src/wasm/api.rs`.\n */\nexport const REFUND_TX_VERSION = 2;\nexport const REFUND_TX_LOCKTIME = 0;\n\n/**\n * Payout transaction literals btc-vault builds deterministically\n * (`crates/vault/src/transactions/payout.rs`: `Version::TWO`,\n * `LockTime::ZERO`). The depositor's signature commits to both, so a\n * VP-supplied payout that deviates would produce a signature over a\n * transaction the protocol never constructs.\n */\nexport const PAYOUT_TX_VERSION = 2;\nexport const PAYOUT_TX_LOCKTIME = 0;\n\n/**\n * Payout output that pays the payout receiver, resolved per claimer role (the\n * depositor's registered script for a VP or depositor claimer, the keeper's\n * for an AVK claimer — btc-vault `tx_graph/graph.rs:100-106` @ ac4954e7).\n * btc-vault has no named constant for the index itself:\n * `build_payout_outputs` (`crates/vault/src/transactions/mod.rs:206`)\n * returns the destination as `output0` in both layouts — `:246`/`:256` with a\n * VP commission, `:266`/`:270` without — and `transactions/payout.rs:153`\n * pushes the CPFP anchor after them @ ac4954e7.\n */\nexport const PAYOUT_DESTINATION_OUTPUT_INDEX = 0;\n\n/** VP-claimer payout output count: [depositor payout, VP commission, CPFP anchor]. */\nexport const VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 3;\n\n/** Depositor/VK-claimer payout output count: [claimer payout, CPFP anchor]. */\nexport const NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 2;\n\n/**\n * ChallengeAssert connectors the VP returns per challenger: one for the\n * ChallengeAssertX transaction and one for ChallengeAssertY — two single-input\n * transactions, not a single multi-input one. This is a per-challenger array\n * cardinality, NOT a count of inputs in one transaction.\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md (ChallengeAssertX / ChallengeAssertY)\n */\nexport const CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER = 2;\n\n/**\n * Exclusive upper bound on VP commission (bps). Matches\n * `VPKeyRegistryLogic.sol` (`commissionBps >= 10000` reverts).\n * The minimum is version-locked (`minVpCommissionBps`) and enforced upstream,\n * not here.\n */\nexport const MAX_VP_COMMISSION_BPS_EXCLUSIVE = 10_000;\n\n/**\n * Basis-points denominator for commission math:\n * `floor(value * bps / BPS_DENOMINATOR)`. Numerically equal to\n * {@link MAX_VP_COMMISSION_BPS_EXCLUSIVE} but a distinct concept — tightening\n * the accepted bps range must never change the arithmetic.\n */\nexport const BPS_DENOMINATOR = 10_000;\n\n/**\n * Contract cap on a registered payout/commission scriptPubKey's byte length\n * (`MAX_PAYOUT_ADDRESS_LENGTH`, Constants.sol; empty scripts are rejected at\n * registration, so valid lengths are `[1, 128]`). A measured length outside\n * this range is provably not a registered script.\n */\nexport const MAX_PAYOUT_SCRIPT_LEN = 128;\n"],"names":["DEPOSITOR_PAYOUT_INPUT_COUNT","DEPOSITOR_SIGNED_INPUT_COUNT","PEGIN_VAULT_OUTPUT_INDEX","ASSERT_PAYOUT_OUTPUT_INDEX","PAYOUT_PEGIN_INPUT_INDEX","PAYOUT_ASSERT_INPUT_INDEX","CLAIM_PEGIN_INPUT_INDEX","ASSERT_CLAIM_INPUT_INDEX","CLAIM_CONNECTOR_OUTPUT_INDEX","WRONGLY_CHALLENGED_INPUT_INDEX","PAYOUT_ANCHOR_DUST_SATS","PRE_PEGIN_MIN_HTLC_OUTPUT_COUNT","PRE_PEGIN_AUTH_OUTPUT_VALUE_SATS","PRE_PEGIN_AUTH_SCRIPT_PREFIX","PRE_PEGIN_CPFP_VALUE_SATS","PRE_PEGIN_TX_VERSION","PRE_PEGIN_TX_LOCKTIME","PEGIN_TX_VERSION_CORE_1","PEGIN_TX_VERSION_CORE_2_AND_3","PEGIN_TX_LOCKTIME","PEGIN_INPUT_SEQUENCE","REFUND_TX_VERSION","REFUND_TX_LOCKTIME","PAYOUT_TX_VERSION","PAYOUT_TX_LOCKTIME","PAYOUT_DESTINATION_OUTPUT_INDEX","VP_CLAIMER_PAYOUT_OUTPUT_COUNT","NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT","CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER","MAX_VP_COMMISSION_BPS_EXCLUSIVE","BPS_DENOMINATOR","MAX_PAYOUT_SCRIPT_LEN"],"mappings":"AAkBO,MAAMA,IAA+B,GAS/BC,IAA+B,GAG/BC,IAA2B,GAM3BC,IAA6B,GAG7BC,IAA2B,GAG3BC,IAA4B,GAS5BC,IAA0B,GAO1BC,IAA2B,GAM3BC,IAA+B,GAU/BC,IAAiC,GAMjCC,IAA0B,KAG1BC,IAAkC,GAGlCC,IAAmC,GAOnCC,IAA+B,QAM/BC,IAA4B,KAM5BC,IAAuB,GAMvBC,IAAwB,GAGxBC,IAA0B,GAG1BC,IAAgC,GAGhCC,IAAoB,GAGpBC,IAAuB,YAMvBC,IAAoB,GACpBC,IAAqB,GASrBC,IAAoB,GACpBC,IAAqB,GAYrBC,IAAkC,GAGlCC,IAAiC,GAGjCC,IAAqC,GASrCC,IAA6C,GAQ7CC,IAAkC,KAQlCC,IAAkB,KAQlBC,IAAwB;"}
@@ -1,2 +0,0 @@
1
- "use strict";const _="6a20";exports.ASSERT_CLAIM_INPUT_INDEX=0;exports.ASSERT_PAYOUT_OUTPUT_INDEX=0;exports.BPS_DENOMINATOR=1e4;exports.CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER=2;exports.CLAIM_CONNECTOR_OUTPUT_INDEX=0;exports.CLAIM_PEGIN_INPUT_INDEX=0;exports.DEPOSITOR_PAYOUT_INPUT_COUNT=2;exports.DEPOSITOR_SIGNED_INPUT_COUNT=1;exports.MAX_PAYOUT_SCRIPT_LEN=128;exports.MAX_VP_COMMISSION_BPS_EXCLUSIVE=1e4;exports.NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT=2;exports.PAYOUT_ANCHOR_DUST_SATS=546;exports.PAYOUT_ASSERT_INPUT_INDEX=1;exports.PAYOUT_DESTINATION_OUTPUT_INDEX=0;exports.PAYOUT_PEGIN_INPUT_INDEX=0;exports.PAYOUT_TX_LOCKTIME=0;exports.PAYOUT_TX_VERSION=2;exports.PEGIN_INPUT_SEQUENCE=4294967294;exports.PEGIN_TX_LOCKTIME=0;exports.PEGIN_TX_VERSION_CORE_1=2;exports.PEGIN_TX_VERSION_CORE_2_AND_3=3;exports.PEGIN_VAULT_OUTPUT_INDEX=0;exports.PRE_PEGIN_AUTH_OUTPUT_VALUE_SATS=0;exports.PRE_PEGIN_AUTH_SCRIPT_PREFIX=_;exports.PRE_PEGIN_CPFP_VALUE_SATS=546;exports.PRE_PEGIN_MIN_HTLC_OUTPUT_COUNT=1;exports.PRE_PEGIN_TX_LOCKTIME=0;exports.PRE_PEGIN_TX_VERSION=2;exports.REFUND_TX_LOCKTIME=0;exports.REFUND_TX_VERSION=2;exports.VP_CLAIMER_PAYOUT_OUTPUT_COUNT=3;exports.WRONGLY_CHALLENGED_INPUT_INDEX=0;
2
- //# sourceMappingURL=constants-BwCg5K6R.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-BwCg5K6R.cjs","sources":["../src/tbv/core/primitives/psbt/constants.ts"],"sourcesContent":["/**\n * Protocol invariants for depositor graph transactions.\n *\n * These indices and counts encode the on-chain vault protocol layout\n * (which output of PegIn/Assert each child transaction spends, and how\n * many inputs each transaction has). Consumed by the PSBT builders and\n * the depositor graph signing service; a drift between copies of these\n * values would silently change validation behaviour.\n *\n * @module primitives/psbt/constants\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md\n */\n\n/**\n * Depositor Payout transaction input count.\n * Input 0: PegIn:0 ({@link PAYOUT_PEGIN_INPUT_INDEX}). Input 1: Assert:0\n * ({@link PAYOUT_ASSERT_INPUT_INDEX} carries the signing regimes).\n */\nexport const DEPOSITOR_PAYOUT_INPUT_COUNT = 2;\n\n/**\n * Inputs the depositor signs per Payout / NoPayout PSBT at deposit time:\n * input 0 only. The other inputs are in the SIGHASH_DEFAULT sighash but carry\n * no depositor signature there — the Ledger host expects exactly this many\n * yields, so a drift here re-arms an input the device never signs at deposit\n * time.\n */\nexport const DEPOSITOR_SIGNED_INPUT_COUNT = 1;\n\n/** PegIn vault output index spent by the depositor's Payout input 0. */\nexport const PEGIN_VAULT_OUTPUT_INDEX = 0;\n\n/**\n * Assert output index spent by the Payout's input 1\n * ({@link PAYOUT_ASSERT_INPUT_INDEX} carries the signing regimes).\n */\nexport const ASSERT_PAYOUT_OUTPUT_INDEX = 0;\n\n/** Payout input that spends the Vault UTXO (PegIn:{@link PEGIN_VAULT_OUTPUT_INDEX}); the depositor signs it in both regimes. */\nexport const PAYOUT_PEGIN_INPUT_INDEX = 0;\n\n/** Payout input that spends the Assert connector (Assert:{@link ASSERT_PAYOUT_OUTPUT_INDEX}); the claimer signs it, which is the depositor only in a delegated claim. */\nexport const PAYOUT_ASSERT_INPUT_INDEX = 1;\n\n/**\n * Claim input that spends the vault's PegIn. A depositor-as-claimer recovery\n * Claim is funded by exactly the PegIn's depositor-claim output\n * (`DEPOSITOR_CLAIM_VOUT = 1` in btc-vault `crates/vault/src/lib.rs:272`, used by\n * `depositor_claim_funding_outpoint` in `crates/vault/src/transactions/claim.rs:119-121`\n * @ ac4954e7); the depositor signs it.\n */\nexport const CLAIM_PEGIN_INPUT_INDEX = 0;\n\n/**\n * Assert input that spends the Claim connector\n * (Claim:{@link CLAIM_CONNECTOR_OUTPUT_INDEX}); the claimer signs it. Matches\n * `CLAIM_ASSERT_INPUT` in btc-vault `crates/vault/src/transactions/assert.rs:56` @ ac4954e7.\n */\nexport const ASSERT_CLAIM_INPUT_INDEX = 0;\n\n/**\n * Claim output the Assert spends. Matches `CLAIM_ASSERT_OUTPUT_INDEX` in\n * btc-vault `crates/vault/src/transactions/claim.rs:25` @ ac4954e7.\n */\nexport const CLAIM_CONNECTOR_OUTPUT_INDEX = 0;\n\n/**\n * WronglyChallenged input that spends the ChallengeAssert connector; the\n * claimer signs it, which is the depositor only in a delegated claim. Matches\n * `CHALLENGE_ASSERT_INPUT` in btc-vault\n * `crates/vault/src/transactions/wrongly_challenged.rs:35`, the input\n * `claimer_signing_psbt` hands the external signer (`:187`) and `sign_claimer`\n * signs natively (`:243`) @ ac4954e7.\n */\nexport const WRONGLY_CHALLENGED_INPUT_INDEX = 0;\n\n/**\n * Dust amount (sats) for the payout CPFP anchor output. Matches `DUST_AMOUNT`\n * in `btc-vault crates/vault/src/lib.rs`.\n */\nexport const PAYOUT_ANCHOR_DUST_SATS = 546;\n\n/** Minimum number of HTLC outputs in a Pre-PegIn transaction. */\nexport const PRE_PEGIN_MIN_HTLC_OUTPUT_COUNT = 1;\n\n/** Canonical value in sats for the optional Pre-PegIn auth output. */\nexport const PRE_PEGIN_AUTH_OUTPUT_VALUE_SATS = 0;\n\n/**\n * Hex prefix for `OP_RETURN PUSH32`. This matches\n * `ScriptBuf::new_op_return(hash)` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_AUTH_SCRIPT_PREFIX = \"6a20\";\n\n/**\n * Value in sats for the Pre-PegIn CPFP anchor output. Matches `DUST_AMOUNT`\n * in `btc-vault crates/vault/src/lib.rs`.\n */\nexport const PRE_PEGIN_CPFP_VALUE_SATS = 546;\n\n/**\n * Canonical Pre-PegIn transaction version. Matches `Version::TWO` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_TX_VERSION = 2;\n\n/**\n * Canonical Pre-PegIn transaction locktime. Matches `LockTime::ZERO` in\n * `btc-vault crates/vault/src/transactions/prepegin.rs`.\n */\nexport const PRE_PEGIN_TX_LOCKTIME = 0;\n\n/** Vault Core 1 PegIn nVersion from `PegInTx::expected_tx_version`. */\nexport const PEGIN_TX_VERSION_CORE_1 = 2;\n\n/** Vault Core 2 and 3 PegIn nVersion from `PegInTx::expected_tx_version`. */\nexport const PEGIN_TX_VERSION_CORE_2_AND_3 = 3;\n\n/** PegIn locktime from `PegInTx::new_from_prepegin` (`LockTime::ZERO`). */\nexport const PEGIN_TX_LOCKTIME = 0;\n\n/** PegIn input sequence from `PegInTx::new_from_prepegin`. */\nexport const PEGIN_INPUT_SEQUENCE = 0xfffffffe;\n\n/**\n * Refund version and locktime match `WasmPrePeginTx::build_refund_tx`\n * (`Version::TWO`, `LockTime::ZERO`) in `btc-vault crates/vault/src/wasm/api.rs`.\n */\nexport const REFUND_TX_VERSION = 2;\nexport const REFUND_TX_LOCKTIME = 0;\n\n/**\n * Payout transaction literals btc-vault builds deterministically\n * (`crates/vault/src/transactions/payout.rs`: `Version::TWO`,\n * `LockTime::ZERO`). The depositor's signature commits to both, so a\n * VP-supplied payout that deviates would produce a signature over a\n * transaction the protocol never constructs.\n */\nexport const PAYOUT_TX_VERSION = 2;\nexport const PAYOUT_TX_LOCKTIME = 0;\n\n/**\n * Payout output that pays the payout receiver, resolved per claimer role (the\n * depositor's registered script for a VP or depositor claimer, the keeper's\n * for an AVK claimer — btc-vault `tx_graph/graph.rs:100-106` @ ac4954e7).\n * btc-vault has no named constant for the index itself:\n * `build_payout_outputs` (`crates/vault/src/transactions/mod.rs:206`)\n * returns the destination as `output0` in both layouts — `:246`/`:256` with a\n * VP commission, `:266`/`:270` without — and `transactions/payout.rs:153`\n * pushes the CPFP anchor after them @ ac4954e7.\n */\nexport const PAYOUT_DESTINATION_OUTPUT_INDEX = 0;\n\n/** VP-claimer payout output count: [depositor payout, VP commission, CPFP anchor]. */\nexport const VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 3;\n\n/** Depositor/VK-claimer payout output count: [claimer payout, CPFP anchor]. */\nexport const NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 2;\n\n/**\n * ChallengeAssert connectors the VP returns per challenger: one for the\n * ChallengeAssertX transaction and one for ChallengeAssertY — two single-input\n * transactions, not a single multi-input one. This is a per-challenger array\n * cardinality, NOT a count of inputs in one transaction.\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md (ChallengeAssertX / ChallengeAssertY)\n */\nexport const CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER = 2;\n\n/**\n * Exclusive upper bound on VP commission (bps). Matches\n * `VPKeyRegistryLogic.sol` (`commissionBps >= 10000` reverts).\n * The minimum is version-locked (`minVpCommissionBps`) and enforced upstream,\n * not here.\n */\nexport const MAX_VP_COMMISSION_BPS_EXCLUSIVE = 10_000;\n\n/**\n * Basis-points denominator for commission math:\n * `floor(value * bps / BPS_DENOMINATOR)`. Numerically equal to\n * {@link MAX_VP_COMMISSION_BPS_EXCLUSIVE} but a distinct concept — tightening\n * the accepted bps range must never change the arithmetic.\n */\nexport const BPS_DENOMINATOR = 10_000;\n\n/**\n * Contract cap on a registered payout/commission scriptPubKey's byte length\n * (`MAX_PAYOUT_ADDRESS_LENGTH`, Constants.sol; empty scripts are rejected at\n * registration, so valid lengths are `[1, 128]`). A measured length outside\n * this range is provably not a registered script.\n */\nexport const MAX_PAYOUT_SCRIPT_LEN = 128;\n"],"names":["PRE_PEGIN_AUTH_SCRIPT_PREFIX"],"mappings":"aA6FO,MAAMA,EAA+B"}
@@ -1,361 +0,0 @@
1
- import { Transaction as S, Psbt as L, payments as z } from "bitcoinjs-lib";
2
- import { Buffer as y } from "buffer";
3
- import { loadTbvWasm as D, tapInternalPubkey as q, getAssertNoPayoutScriptInfo as F } from "./tbv/core/wasm/index.js";
4
- import { u as H, T as k, s as g, d as X, h as x, S as O, p as W, k as G } from "./bitcoin-C-TuHb-v.js";
5
- import { n as Y, l as Q, d as j, P as w, m as J } from "./verifyScriptPathSchnorrSignature-B3-VkvnK.js";
6
- import { R as B, a as U } from "./constants-BeYquVd-.js";
7
- import { D as V } from "./fundPeginTransaction-CwhRbCQC.js";
8
- import { X as M } from "./validation-OSC0xTHB.js";
9
- const Z = (1n << 64n) - 1n;
10
- function tt(e, a) {
11
- if (!Array.isArray(e))
12
- throw new Error(
13
- `${a} must be an array of positive bigints (got ${typeof e}).`
14
- );
15
- if (e.length === 0)
16
- throw new Error(`${a} must not be empty.`);
17
- return e.forEach((t, r) => {
18
- if (typeof t != "bigint")
19
- throw new Error(
20
- `${a}[${r}] must be a bigint (got ${typeof t}); refusing to feed it into satoshi math.`
21
- );
22
- if (t <= 0n)
23
- throw new Error(`${a}[${r}] must be > 0 (got ${t}).`);
24
- if (t > Z)
25
- throw new Error(
26
- `${a}[${r}] must fit in a u64 (got ${t}); refusing to feed it into satoshi math.`
27
- );
28
- }), e;
29
- }
30
- async function mt(e) {
31
- const { WasmPrePeginTx: a } = await D(), { prePeginParams: t, fundedPrePeginTxHex: r, htlcVout: n, refundFee: p, hashlock: u } = e, c = Y(
32
- t.authAnchorHash
33
- ), o = new a(
34
- t.vaultCoreVersion,
35
- t.depositorPubkey,
36
- t.vaultProviderPubkey,
37
- t.vaultKeeperPubkeys,
38
- t.universalChallengerPubkeys,
39
- [...t.hashlocks],
40
- new BigUint64Array(
41
- tt(t.pegInAmounts, "pegInAmounts")
42
- ),
43
- t.timelockRefund,
44
- t.feeRate,
45
- t.minPeginFeeRate,
46
- t.numLocalChallengers,
47
- t.councilQuorum,
48
- t.councilSize,
49
- t.network,
50
- c
51
- );
52
- let i = null;
53
- try {
54
- const f = o.getHtlcScriptPubKey(n).toLowerCase(), s = Q(t, u), h = s.scriptPubKey.toString("hex");
55
- if (f !== h)
56
- throw new Error(
57
- `WASM HTLC scriptPubKey ${f} does not match the independently derived scriptPubKey ${h}.`
58
- );
59
- const E = o.getHtlcValue(n);
60
- i = o.fromFundedTransaction(r);
61
- const d = i.buildRefundTx(p, n), P = r.startsWith("0x") ? r.slice(2) : r, v = S.fromHex(P), $ = v.outs[n];
62
- if (!$)
63
- throw new Error(
64
- `HTLC output at vout ${n} not found in funded Pre-PegIn tx (tx has ${v.outs.length} outputs)`
65
- );
66
- const R = H(
67
- new Uint8Array($.script)
68
- ).toLowerCase();
69
- if (R !== h)
70
- throw new Error(
71
- `HTLC scriptPubKey mismatch at vout ${n}: reconstructed template expects ${h}, funded tx carries ${R}. Refund refused — the (hashlocks, pegInAmounts) vector does not match the on-chain commitment.`
72
- );
73
- const m = BigInt($.value);
74
- if (m !== E)
75
- throw new Error(
76
- `HTLC value mismatch at vout ${n}: reconstructed template expects ${E} sat, funded tx carries ${m} sat. Refund refused — the pegInAmounts vector does not match the on-chain commitment.`
77
- );
78
- const l = S.fromHex(d);
79
- if (l.version !== B)
80
- throw new Error(
81
- `Refund transaction version ${l.version} does not match protocol version ${B}.`
82
- );
83
- if (l.locktime !== U)
84
- throw new Error(
85
- `Refund transaction locktime ${l.locktime} does not match protocol locktime ${U}.`
86
- );
87
- if (l.ins.length !== 1)
88
- throw new Error(
89
- `Refund transaction must have exactly 1 input, got ${l.ins.length}`
90
- );
91
- const b = l.ins[0], C = v.getId(), _ = H(
92
- new Uint8Array(b.hash).slice().reverse()
93
- );
94
- if (_ !== C)
95
- throw new Error(
96
- `Refund input does not reference the Pre-PegIn transaction. Expected ${C}, got ${_}`
97
- );
98
- if (b.index !== n)
99
- throw new Error(
100
- `Refund input index ${b.index} does not match expected htlcVout ${n}`
101
- );
102
- if (b.sequence !== t.timelockRefund)
103
- throw new Error(
104
- `Refund input sequence ${b.sequence} does not match timelockRefund ${t.timelockRefund}.`
105
- );
106
- const I = new L();
107
- if (I.setVersion(l.version), I.setLocktime(l.locktime), I.addInput({
108
- hash: b.hash,
109
- index: b.index,
110
- sequence: b.sequence,
111
- witnessUtxo: {
112
- script: $.script,
113
- value: $.value
114
- },
115
- tapLeafScript: [
116
- {
117
- leafVersion: k,
118
- script: s.refundScript,
119
- controlBlock: s.refundControlBlock
120
- }
121
- ],
122
- tapInternalKey: y.from(q),
123
- tapMerkleRoot: s.tapMerkleRoot
124
- }), l.outs.length !== 1)
125
- throw new Error(
126
- `Refund transaction must have exactly 1 output, got ${l.outs.length}`
127
- );
128
- const T = l.outs[0], A = g(
129
- X(t.depositorPubkey)
130
- ).toLowerCase(), K = H(
131
- new Uint8Array(T.script)
132
- ).toLowerCase();
133
- if (K !== A)
134
- throw new Error(
135
- `Refund output scriptPubKey ${K} does not match the depositor's BIP-86 address ${A}. Refund refused — the reclaimed funds would not return to the depositor.`
136
- );
137
- const N = m - p;
138
- if (BigInt(T.value) !== N)
139
- throw new Error(
140
- `Refund output value ${BigInt(T.value)} sat does not equal the HTLC value ${m} sat minus the requested fee ${p} sat (expected ${N} sat). Refund refused — the reclaimed amount would be burned as excess fee.`
141
- );
142
- return I.addOutput({
143
- script: T.script,
144
- value: T.value
145
- }), { psbtHex: I.toHex() };
146
- } finally {
147
- i == null || i.free(), o.free();
148
- }
149
- }
150
- const et = 2, ot = 4294967293, rt = 214, nt = 299, st = 4;
151
- function it(e) {
152
- if (!Number.isInteger(e) || e < 1)
153
- throw new Error(
154
- `Reclaim input count must be a positive integer, got ${e}.`
155
- );
156
- return Math.ceil(
157
- (rt + nt * e) / st
158
- );
159
- }
160
- function wt(e, a) {
161
- if (!Number.isFinite(e) || e <= 0)
162
- throw new Error(
163
- `Reclaim fee rate must be a positive number, got ${e}.`
164
- );
165
- return BigInt(Math.ceil(e * it(a)));
166
- }
167
- function gt(e) {
168
- const { depositorPubkey: a, inputs: t, feeSats: r } = e;
169
- if (t.length === 0)
170
- throw new Error("Reclaim requires at least one input; got none.");
171
- if (r <= 0n)
172
- throw new Error(
173
- `Reclaim fee must be positive, got ${r} sat. Refusing to build a transaction that would not relay.`
174
- );
175
- const n = j(a), p = H(
176
- new Uint8Array(n.scriptPubKey)
177
- ).toLowerCase(), u = new L();
178
- u.setVersion(et), u.setLocktime(0);
179
- let c = 0n;
180
- const o = /* @__PURE__ */ new Set();
181
- if (t.forEach((s, h) => {
182
- const E = S.fromHex(
183
- g(s.depositorSignedPeginTxHex)
184
- ), d = E.getId(), P = E.outs[w];
185
- if (!P)
186
- throw new Error(
187
- `PegIn ${d} has no output at vout ${w} (tx has ${E.outs.length}); there is no depositor-claim reserve to reclaim.`
188
- );
189
- const v = g(s.observed.txid).toLowerCase();
190
- if (v !== d)
191
- throw new Error(
192
- `Input ${h}: the observation is of ${v}, but this input spends PegIn ${d}. Reclaim refused — the reserve that was looked up is not the one being swept.`
193
- );
194
- if (s.observed.vout !== w)
195
- throw new Error(
196
- `Input ${h}: the observation is of vout ${s.observed.vout}, but the depositor-claim reserve is at vout ${w}. Reclaim refused.`
197
- );
198
- const $ = H(
199
- new Uint8Array(P.script)
200
- ).toLowerCase();
201
- if ($ !== p)
202
- throw new Error(
203
- `Input ${h}: PegIn ${d} vout ${w} pays ${$}, but the connected wallet's depositor-claim script is ${p}. Reclaim refused — this reserve belongs to a different wallet.`
204
- );
205
- const R = g(
206
- s.observed.scriptPubKey
207
- ).toLowerCase();
208
- if (R !== p)
209
- throw new Error(
210
- `Input ${h}: the observed UTXO ${d}:${w} pays ${R}, expected ${p}. Reclaim refused — chain state disagrees with the contract's PegIn.`
211
- );
212
- const m = BigInt(P.value);
213
- if (m !== s.observed.value)
214
- throw new Error(
215
- `Input ${h}: PegIn ${d} vout ${w} carries ${m} sat, but the observed UTXO carries ${s.observed.value} sat. Reclaim refused.`
216
- );
217
- if (m !== s.expectedValue)
218
- throw new Error(
219
- `Input ${h}: PegIn ${d} vout ${w} carries ${m} sat, but this vault's parameters compute a depositor-claim value of ${s.expectedValue} sat. Reclaim refused.`
220
- );
221
- const l = `${d}:${w}`;
222
- if (o.has(l))
223
- throw new Error(
224
- `Input ${h} repeats outpoint ${l}, which is already being swept by an earlier input. Reclaim refused.`
225
- );
226
- o.add(l), c += m, u.addInput({
227
- hash: d,
228
- index: w,
229
- sequence: ot,
230
- witnessUtxo: { script: P.script, value: P.value },
231
- tapLeafScript: [
232
- {
233
- leafVersion: k,
234
- script: n.leafScript,
235
- controlBlock: n.controlBlock
236
- }
237
- ],
238
- tapInternalKey: n.internalKey
239
- });
240
- }), r >= c)
241
- throw new Error(
242
- `Reclaim fee ${r} sat is not less than the swept total ${c} sat. Refusing to build a transaction with no output.`
243
- );
244
- const i = c - r;
245
- if (i <= V)
246
- throw new Error(
247
- `Reclaim output ${i} sat is at or below the dust threshold ${V} sat. The reserve is not at risk — it stays where it is until fee rates fall.`
248
- );
249
- const f = g(
250
- X(a)
251
- );
252
- return u.addOutput({
253
- script: y.from(x(f)),
254
- value: Number(i)
255
- }), { psbtHex: u.toHex(), outputValue: i, totalInputValue: c };
256
- }
257
- function yt(e) {
258
- const { requestedPsbtHex: a, signaturesHex: t, signerXOnlyPubkeyHex: r } = e, n = g(r);
259
- if (n.length !== M)
260
- throw new Error(
261
- `Signer x-only pubkey must be ${M} hex chars (32 bytes), got ${n.length}.`
262
- );
263
- const p = y.from(x(n)), u = L.fromHex(a);
264
- if (t.length !== u.data.inputs.length)
265
- throw new Error(
266
- `Cannot finalize: got ${t.length} signature(s) for ${u.data.inputs.length} input(s). Every input must be signed — refusing to broadcast a partially signed transaction.`
267
- );
268
- return u.data.inputs.forEach((c, o) => {
269
- if (c.tapKeySig)
270
- throw new Error(
271
- `Cannot finalize: input ${o} of the locally built PSBT carries a key-path signature. These outputs are script-path only.`
272
- );
273
- const i = c.tapLeafScript;
274
- if (!i || i.length !== 1)
275
- throw new Error(
276
- `Cannot finalize: input ${o} must have exactly one tapLeafScript, got ${(i == null ? void 0 : i.length) ?? 0}.`
277
- );
278
- const f = i[0];
279
- if (f.leafVersion !== k)
280
- throw new Error(
281
- `Cannot finalize: input ${o} tapLeafScript has leaf version 0x${f.leafVersion.toString(16)}, expected 0x${k.toString(16)}.`
282
- );
283
- const s = g(t[o]);
284
- if (s.length !== O)
285
- throw new Error(
286
- `Signature for input ${o} must be ${O} hex chars (64 bytes), got ${s.length}.`
287
- );
288
- u.updateInput(o, {
289
- tapScriptSig: [
290
- {
291
- pubkey: p,
292
- leafHash: J(f.leafVersion, f.script),
293
- signature: y.from(x(s))
294
- }
295
- ]
296
- });
297
- }), u.finalizeAllInputs(), u.extractTransaction().toHex();
298
- }
299
- async function $t(e) {
300
- const a = g(e.noPayoutTxHex), t = S.fromHex(a), { noPayoutScript: r, noPayoutControlBlock: n } = await F(
301
- e.connectorParams,
302
- e.challengerPubkey
303
- ), p = x(r), u = x(n), c = new L();
304
- c.setVersion(t.version), c.setLocktime(t.locktime);
305
- for (let o = 0; o < t.ins.length; o++) {
306
- const i = t.ins[o], f = e.prevouts[o];
307
- if (!f)
308
- throw new Error(`Missing prevout data for input ${o}`);
309
- const s = {
310
- hash: i.hash,
311
- index: i.index,
312
- sequence: i.sequence,
313
- witnessUtxo: {
314
- script: y.from(x(g(f.script_pubkey))),
315
- value: f.value
316
- }
317
- };
318
- o === 0 && (s.tapLeafScript = [
319
- {
320
- leafVersion: k,
321
- script: y.from(p),
322
- controlBlock: y.from(u)
323
- }
324
- ], s.tapInternalKey = y.from(q)), c.addInput(s);
325
- }
326
- for (const o of t.outs)
327
- c.addOutput({
328
- script: o.script,
329
- value: o.value
330
- });
331
- return c.toHex();
332
- }
333
- function bt(e, a, t) {
334
- const r = S.fromHex(g(e));
335
- if (r.outs.length !== 1)
336
- throw new Error(
337
- `NoPayout transaction must have exactly 1 output, got ${r.outs.length}`
338
- );
339
- const n = x(W(a)), { output: p } = z.p2tr({
340
- internalPubkey: y.from(n),
341
- network: G(t)
342
- });
343
- if (!p)
344
- throw new Error(
345
- "Failed to derive challenger BIP-86 P2TR scriptPubKey for NoPayout output validation"
346
- );
347
- if (!r.outs[0].script.equals(p))
348
- throw new Error(
349
- "NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address"
350
- );
351
- }
352
- export {
353
- gt as a,
354
- mt as b,
355
- $t as c,
356
- bt as d,
357
- wt as e,
358
- yt as f,
359
- it as r
360
- };
361
- //# sourceMappingURL=noPayout-B-vGXJ-V.js.map