@babylonlabs-io/ts-sdk 0.37.3 → 0.38.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 (135) hide show
  1. package/dist/BTCVaultRegistry.abi-CHFGevwa.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-CHFGevwa.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-DbJ5lsFJ.js → BTCVaultRegistry.abi-Cq9-JlqT.js} +38 -2
  4. package/dist/BTCVaultRegistry.abi-Cq9-JlqT.js.map +1 -0
  5. package/dist/PayoutManager-D29D-K-V.js +250 -0
  6. package/dist/PayoutManager-D29D-K-V.js.map +1 -0
  7. package/dist/PayoutManager-DERMRuUU.cjs +2 -0
  8. package/dist/PayoutManager-DERMRuUU.cjs.map +1 -0
  9. package/dist/{PeginManager-HCYTUzh6.js → PeginManager-Cp2Tn5sH.js} +444 -406
  10. package/dist/PeginManager-Cp2Tn5sH.js.map +1 -0
  11. package/dist/PeginManager-DaDs-bGr.cjs +2 -0
  12. package/dist/PeginManager-DaDs-bGr.cjs.map +1 -0
  13. package/dist/{ProtocolParams.abi-DXu8L0Fn.js → ProtocolParams.abi-C2brDWTI.js} +8 -3
  14. package/dist/ProtocolParams.abi-C2brDWTI.js.map +1 -0
  15. package/dist/ProtocolParams.abi-DQhcqsNr.cjs +2 -0
  16. package/dist/ProtocolParams.abi-DQhcqsNr.cjs.map +1 -0
  17. package/dist/assertPsbtUnsignedTxMatches-fNkAaZZm.cjs +2 -0
  18. package/dist/assertPsbtUnsignedTxMatches-fNkAaZZm.cjs.map +1 -0
  19. package/dist/assertPsbtUnsignedTxMatches-mTAnLhCz.js +340 -0
  20. package/dist/assertPsbtUnsignedTxMatches-mTAnLhCz.js.map +1 -0
  21. package/dist/{buildAndBroadcastRefund-CI_x6OtX.js → buildAndBroadcastRefund-B5cOyUzj.js} +234 -227
  22. package/dist/buildAndBroadcastRefund-B5cOyUzj.js.map +1 -0
  23. package/dist/buildAndBroadcastRefund-DVMT-pXQ.cjs +2 -0
  24. package/dist/buildAndBroadcastRefund-DVMT-pXQ.cjs.map +1 -0
  25. package/dist/{challengeAssert-D7OCrDIc.js → challengeAssert-CBp4mEs0.js} +2 -2
  26. package/dist/{challengeAssert-D7OCrDIc.js.map → challengeAssert-CBp4mEs0.js.map} +1 -1
  27. package/dist/{challengeAssert-CMb7r-je.cjs → challengeAssert-CNRdpCzm.cjs} +2 -2
  28. package/dist/{challengeAssert-CMb7r-je.cjs.map → challengeAssert-CNRdpCzm.cjs.map} +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +38 -38
  31. package/dist/noPayout-jtZsoOzY.cjs +2 -0
  32. package/dist/noPayout-jtZsoOzY.cjs.map +1 -0
  33. package/dist/noPayout-qbaSEKGC.js +145 -0
  34. package/dist/noPayout-qbaSEKGC.js.map +1 -0
  35. package/dist/peginInput-BPRB9tUi.js +104 -0
  36. package/dist/peginInput-BPRB9tUi.js.map +1 -0
  37. package/dist/peginInput-DH6X4ITS.cjs +2 -0
  38. package/dist/peginInput-DH6X4ITS.cjs.map +1 -0
  39. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
  40. package/dist/tbv/core/clients/eth/protocol-params-validation.d.ts.map +1 -1
  41. package/dist/tbv/core/clients/eth/types.d.ts +12 -1
  42. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  43. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  44. package/dist/tbv/core/clients/index.cjs +1 -1
  45. package/dist/tbv/core/clients/index.js +9 -9
  46. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +0 -9
  47. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  48. package/dist/tbv/core/clients/vault-provider/types.d.ts +38 -21
  49. package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
  50. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  51. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +36 -2
  52. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  53. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +6 -2
  54. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  55. package/dist/tbv/core/contracts/index.cjs +1 -1
  56. package/dist/tbv/core/contracts/index.js +2 -2
  57. package/dist/tbv/core/index.cjs +1 -1
  58. package/dist/tbv/core/index.js +25 -25
  59. package/dist/tbv/core/managers/PeginManager.d.ts +5 -0
  60. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  61. package/dist/tbv/core/managers/index.cjs +1 -1
  62. package/dist/tbv/core/managers/index.js +2 -2
  63. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts +37 -0
  64. package/dist/tbv/core/managers/pegin/assertAuthAnchorOpReturn.d.ts.map +1 -1
  65. package/dist/tbv/core/managers/pegin/index.d.ts +1 -1
  66. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
  67. package/dist/tbv/core/primitives/index.cjs +1 -1
  68. package/dist/tbv/core/primitives/index.js +17 -17
  69. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts +12 -0
  70. package/dist/tbv/core/primitives/psbt/__tests__/refund.test.d.ts.map +1 -0
  71. package/dist/tbv/core/primitives/psbt/pegin.d.ts +5 -0
  72. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  73. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  74. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  75. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  76. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts +4 -2
  77. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
  78. package/dist/tbv/core/services/index.cjs +1 -1
  79. package/dist/tbv/core/services/index.js +2 -2
  80. package/dist/tbv/core/services/pegout/state.d.ts +5 -8
  81. package/dist/tbv/core/services/pegout/state.d.ts.map +1 -1
  82. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  83. package/dist/tbv/index.cjs +1 -1
  84. package/dist/tbv/index.js +25 -25
  85. package/dist/tbv/integrations/aave/clients/query.d.ts.map +1 -1
  86. package/dist/tbv/integrations/aave/index.cjs +1 -1
  87. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  88. package/dist/tbv/integrations/aave/index.js +23 -22
  89. package/dist/tbv/integrations/aave/index.js.map +1 -1
  90. package/dist/tbv/integrations/aave/types.d.ts +6 -0
  91. package/dist/tbv/integrations/aave/types.d.ts.map +1 -1
  92. package/dist/types-D2jcXfm7.cjs +2 -0
  93. package/dist/types-D2jcXfm7.cjs.map +1 -0
  94. package/dist/types-TOmEvvRy.js +322 -0
  95. package/dist/types-TOmEvvRy.js.map +1 -0
  96. package/dist/{vault-registry-reader-Blhu9FW2.js → vault-registry-reader-BrARgFre.js} +207 -202
  97. package/dist/vault-registry-reader-BrARgFre.js.map +1 -0
  98. package/dist/vault-registry-reader-CbJHSxVe.cjs +2 -0
  99. package/dist/vault-registry-reader-CbJHSxVe.cjs.map +1 -0
  100. package/package.json +1 -1
  101. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +0 -1
  102. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +0 -2
  103. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +0 -1
  104. package/dist/PayoutManager-BfT0V-tm.cjs +0 -2
  105. package/dist/PayoutManager-BfT0V-tm.cjs.map +0 -1
  106. package/dist/PayoutManager-Cf51DBcu.js +0 -208
  107. package/dist/PayoutManager-Cf51DBcu.js.map +0 -1
  108. package/dist/PeginManager-CTznAVPT.cjs +0 -2
  109. package/dist/PeginManager-CTznAVPT.cjs.map +0 -1
  110. package/dist/PeginManager-HCYTUzh6.js.map +0 -1
  111. package/dist/ProtocolParams.abi-BmvHwQJV.cjs +0 -2
  112. package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +0 -1
  113. package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +0 -1
  114. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs +0 -2
  115. package/dist/assertPsbtUnsignedTxMatches-CagW7XqW.cjs.map +0 -1
  116. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js +0 -266
  117. package/dist/assertPsbtUnsignedTxMatches-Dry5dTfl.js.map +0 -1
  118. package/dist/buildAndBroadcastRefund-Bj2e94CC.cjs +0 -2
  119. package/dist/buildAndBroadcastRefund-Bj2e94CC.cjs.map +0 -1
  120. package/dist/buildAndBroadcastRefund-CI_x6OtX.js.map +0 -1
  121. package/dist/noPayout-B6s8vrW6.cjs +0 -2
  122. package/dist/noPayout-B6s8vrW6.cjs.map +0 -1
  123. package/dist/noPayout-BhgknZBx.js +0 -141
  124. package/dist/noPayout-BhgknZBx.js.map +0 -1
  125. package/dist/peginInput-57FK2O99.cjs +0 -2
  126. package/dist/peginInput-57FK2O99.cjs.map +0 -1
  127. package/dist/peginInput-CYJzbuwA.js +0 -177
  128. package/dist/peginInput-CYJzbuwA.js.map +0 -1
  129. package/dist/types-DnyyBNcC.cjs +0 -2
  130. package/dist/types-DnyyBNcC.cjs.map +0 -1
  131. package/dist/types-TiIjyo2b.js +0 -320
  132. package/dist/types-TiIjyo2b.js.map +0 -1
  133. package/dist/vault-registry-reader-7gOYnrQD.cjs +0 -2
  134. package/dist/vault-registry-reader-7gOYnrQD.cjs.map +0 -1
  135. package/dist/vault-registry-reader-Blhu9FW2.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
- import { a as s, b as t, c as r } from "./challengeAssert-D7OCrDIc.js";
1
+ import { a as s, b as t, c as r } from "./challengeAssert-CBp4mEs0.js";
2
2
  import { computeMinClaimValue as i, deriveVaultId as n, expandAuthAnchor as u, expandHashlockSecret as l, expandWotsSeed as p } from "@babylonlabs-io/babylon-tbv-rust-wasm";
3
- import { c, a as P, b as T, e as S, f as g } from "./peginInput-CYJzbuwA.js";
4
- import { a as E, b as R } from "./noPayout-BhgknZBx.js";
5
- import { P as _, a as x, c as f, b, d as v, e as I } from "./assertPsbtUnsignedTxMatches-Dry5dTfl.js";
3
+ import { P, c, f as T, d as S, a as g, b as E, g as m, e as R } from "./assertPsbtUnsignedTxMatches-mTAnLhCz.js";
4
+ import { b as _, e as x, f } from "./peginInput-BPRB9tUi.js";
5
+ import { a as v, b as I } from "./noPayout-qbaSEKGC.js";
6
6
  import { d as V, a as y, b as O, e as h, f as U, j as F, g as B, h as N, i as D, c as M, p as H, s as L, t as k, u as W, v as X } from "./bitcoin-B5aNKtsk.js";
7
7
  import { c as K } from "./signing-DaLvGwQe.js";
8
8
  import { B as Y, H as Z, K as J, M as j, T as z } from "./validation-CxqROCno.js";
9
- import { P as Q, V as $, b as aa, a as ea, c as sa, e as ta, d as ra } from "./PeginManager-HCYTUzh6.js";
10
- import { P as ia, c as na, v as ua } from "./PayoutManager-Cf51DBcu.js";
11
- import { A as pa, P as da } from "./ProtocolParams.abi-DXu8L0Fn.js";
12
- import { B as Pa } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
13
- import { C as Sa, e as ga, g as ma, h as Ea, i as Ra } from "./errors-CznAK5NB.js";
9
+ import { P as Q, V as $, b as aa, a as ea, c as sa, e as ta, d as ra } from "./PeginManager-Cp2Tn5sH.js";
10
+ import { P as ia, c as na, v as ua } from "./PayoutManager-D29D-K-V.js";
11
+ import { A as pa, P as da } from "./ProtocolParams.abi-C2brDWTI.js";
12
+ import { B as ca } from "./BTCVaultRegistry.abi-Cq9-JlqT.js";
13
+ import { C as Sa, e as ga, g as Ea, h as ma, i as Ra } from "./errors-CznAK5NB.js";
14
14
  import { BitcoinNetworks as _a } from "./shared/index.js";
15
15
  import { B as fa, a as ba, f as va, c as Ia, b as Ca, d as Va, g as ya, i as Oa, h as ha, s as Ua, e as Fa, w as Ba } from "./waitForTransactionReceiptSmartAware-CmgFXFza.js";
16
16
  import { B as Da, D as Ma, F as Ha, L as La, M as ka, P as Wa, b as Xa, a as wa, S as Ka, T as Ga, W as Ya, f as Za, c as Ja, p as ja, r as za } from "./fundPeginTransaction-t-6TsHAY.js";
17
17
  import { U as Qa, a as $a, c as ae, e as ee, s as se, v as te } from "./reservation-CB-4FBPk.js";
18
- import { M as oe, g as ie, a as ne, b as ue, c as le, d as pe, e as de, f as ce, p as Pe } from "./mempoolApi-CAIge7Nj.js";
19
- import { S as Se, V as ge, j as me, k as Ee, l as Re, m as Ae, a as _e, d as xe, b as fe, f as be, p as ve, r as Ie, g as Ce, h as Ve, v as ye, i as Oe, c as he, e as Ue } from "./vault-registry-reader-Blhu9FW2.js";
20
- import { D as Be, b as Ne, J as De, a as Me, d as He, P as Le, R as ke, e as We, c as Xe, V as we } from "./types-TiIjyo2b.js";
18
+ import { M as oe, g as ie, a as ne, b as ue, c as le, d as pe, e as de, f as Pe, p as ce } from "./mempoolApi-CAIge7Nj.js";
19
+ import { S as Se, V as ge, j as Ee, k as me, l as Re, m as Ae, a as _e, d as xe, b as fe, f as be, p as ve, r as Ie, g as Ce, h as Ve, v as ye, i as Oe, c as he, e as Ue } from "./vault-registry-reader-BrARgFre.js";
20
+ import { D as Be, b as Ne, J as De, a as Me, d as He, P as Le, R as ke, e as We, c as Xe, V as we } from "./types-TOmEvvRy.js";
21
21
  import { i as Ge, p as Ye } from "./errors-9AkghWyk.js";
22
- import { B as Je, C as je, p as ze, R as qe, a as Qe, n as $e, o as as, i as es, m as ss, l as ts, j as rs, r as os, b as is, s as ns, v as us, g as ls, h as ps, d as ds, c as cs, e as Ps, f as Ts, k as Ss, w as gs } from "./buildAndBroadcastRefund-CI_x6OtX.js";
23
- import { C as Es, P as Rs, c as As, g as _s } from "./peginState-CBAlxgXk.js";
22
+ import { B as Je, C as je, p as ze, R as qe, a as Qe, n as $e, o as as, i as es, m as ss, l as ts, j as rs, r as os, b as is, s as ns, v as us, g as ls, h as ps, d as ds, c as Ps, e as cs, f as Ts, k as Ss, w as gs } from "./buildAndBroadcastRefund-B5cOyUzj.js";
23
+ import { C as ms, P as Rs, c as As, g as _s } from "./peginState-CBAlxgXk.js";
24
24
  export {
25
25
  pa as ApplicationRegistryABI,
26
26
  Je as BIP68NotMatureError,
27
27
  Y as BITCOIN_ADDRESS_RE,
28
- Pa as BTCVaultRegistryABI,
28
+ ca as BTCVaultRegistryABI,
29
29
  Da as BTC_DUST_SAT,
30
30
  _a as BitcoinNetworks,
31
31
  fa as BitcoinScriptType,
32
32
  Sa as CONTRACT_ERRORS,
33
33
  je as ClaimerPegoutStatusValue,
34
- Es as ContractStatus,
34
+ ms as ContractStatus,
35
35
  Ma as DUST_THRESHOLD,
36
36
  Be as DaemonStatus,
37
37
  Ha as FEE_SAFETY_MARGIN,
@@ -53,7 +53,7 @@ export {
53
53
  Rs as PeginAction,
54
54
  Q as PeginManager,
55
55
  da as ProtocolParamsABI,
56
- _ as PsbtSubstitutionError,
56
+ P as PsbtSubstitutionError,
57
57
  ze as REFUND_VSIZE,
58
58
  qe as RegisteredVaultVersionMismatchError,
59
59
  ke as RpcErrorCode,
@@ -64,11 +64,11 @@ export {
64
64
  Qa as UtxoNotAvailableError,
65
65
  $ as VAULT_APP_NAME,
66
66
  We as VP_BATCH_MAX_SIZE,
67
- Xe as VP_TERMINAL_STATUSES,
67
+ Xe as VP_TERMINAL_FAILURE_STATUSES,
68
68
  we as VP_TRANSIENT_STATUSES,
69
69
  ge as VaultProviderRpcClient,
70
- me as ViemProtocolParamsReader,
71
- Ee as ViemUniversalChallengerReader,
70
+ Ee as ViemProtocolParamsReader,
71
+ me as ViemUniversalChallengerReader,
72
72
  Re as ViemVaultKeeperReader,
73
73
  Ae as ViemVaultRegistryReader,
74
74
  _e as VpResponseValidationError,
@@ -76,20 +76,20 @@ export {
76
76
  Ya as WALLET_RELAY_FEE_RATE_THRESHOLD,
77
77
  Qe as activateVault,
78
78
  ba as applyChangeOutputPolicy,
79
- x as assertPayoutOutputMatchesRegistered,
80
- f as assertPsbtUnsignedTxMatches,
79
+ c as assertPayoutOutputMatchesRegistered,
80
+ T as assertPsbtUnsignedTxMatches,
81
81
  $a as assertUtxosAvailable,
82
82
  fe as batchPollByProvider,
83
83
  $e as buildAndBroadcastRefund,
84
84
  s as buildChallengeAssertPsbt,
85
85
  t as buildDepositorPayoutPsbt,
86
86
  aa as buildFundingOutpointsCommitment,
87
- E as buildNoPayoutPsbt,
88
- b as buildPayoutPsbt,
89
- c as buildPeginInputPsbt,
90
- P as buildPeginTxFromFundedPrePegin,
91
- T as buildPrePeginPsbt,
92
- R as buildRefundPsbt,
87
+ v as buildNoPayoutPsbt,
88
+ S as buildPayoutPsbt,
89
+ _ as buildPeginInputPsbt,
90
+ g as buildPeginTxFromFundedPrePegin,
91
+ E as buildPrePeginPsbt,
92
+ I as buildRefundPsbt,
93
93
  ea as buildVaultContext,
94
94
  va as calculateBtcTxHash,
95
95
  As as canPerformAction,
@@ -102,7 +102,7 @@ export {
102
102
  Va as computePeginBaseFeeSats,
103
103
  sa as computeWotsBlockPublicKeysHash,
104
104
  be as createAuthenticatedVpClient,
105
- v as createPayoutScript,
105
+ m as createPayoutScript,
106
106
  K as createTaprootScriptPathSignOptions,
107
107
  V as deriveBip86ScriptPubKeyHex,
108
108
  y as deriveNativeSegwitAddress,
@@ -117,14 +117,14 @@ export {
117
117
  p as expandWotsSeed,
118
118
  ga as extractErrorData,
119
119
  ee as extractInputsFromTransaction,
120
- I as extractPayoutSignature,
121
- S as extractPeginInputSignature,
122
- g as finalizePeginInputPsbt,
120
+ R as extractPayoutSignature,
121
+ x as extractPeginInputSignature,
122
+ f as finalizePeginInputPsbt,
123
123
  U as formatSatoshisToBtc,
124
124
  Za as fundPeginTransaction,
125
125
  ie as getAddressTxs,
126
126
  ne as getAddressUtxos,
127
- ma as getContractErrorMessage,
127
+ Ea as getContractErrorMessage,
128
128
  ya as getDustThreshold,
129
129
  ue as getMempoolApiUrl,
130
130
  F as getNetwork,
@@ -135,8 +135,8 @@ export {
135
135
  B as getSortedXOnlyPubkeys,
136
136
  pe as getTxHex,
137
137
  de as getTxInfo,
138
- ce as getUtxoInfo,
139
- Ea as handleContractError,
138
+ Pe as getUtxoInfo,
139
+ ma as handleContractError,
140
140
  N as hexToUint8Array,
141
141
  D as isAddressFromPublicKey,
142
142
  es as isDepositAmountValid,
@@ -151,7 +151,7 @@ export {
151
151
  ja as peginOutputCount,
152
152
  ve as primeVpTokenRegistry,
153
153
  H as processPublicKeyToXOnly,
154
- Pe as pushTx,
154
+ ce as pushTx,
155
155
  za as rateBasedTxBufferFee,
156
156
  Ie as resolveProtocolAddresses,
157
157
  os as runDepositorPresignFlow,
@@ -169,12 +169,12 @@ export {
169
169
  ps as validateOnChainParticipantKeys,
170
170
  Ve as validatePegInConfiguration,
171
171
  ds as validateProviderSelection,
172
- cs as validateRemainingCapacity,
172
+ Ps as validateRemainingCapacity,
173
173
  ye as validateRequestDepositorClaimerArtifactsResponse,
174
174
  ua as validateSecretAgainstHashlock,
175
175
  Oe as validateTBVProtocolParams,
176
176
  te as validateUtxosAvailable,
177
- Ps as validateVaultAmounts,
177
+ cs as validateVaultAmounts,
178
178
  Ts as validateVaultProviderPubkey,
179
179
  X as validateWalletPubkey,
180
180
  Ss as verifyRegisteredVaultVersions,
@@ -0,0 +1,2 @@
1
+ "use strict";const P=require("@babylonlabs-io/babylon-tbv-rust-wasm"),i=require("buffer"),a=require("bitcoinjs-lib"),n=require("./bitcoin-CHfKAhcI.cjs"),w=require("./assertPsbtUnsignedTxMatches-fNkAaZZm.cjs");async function H(s){await P.initWasm();const{prePeginParams:e,fundedPrePeginTxHex:o,htlcVout:r,refundFee:d,hashlock:c}=s,b=w.normalizeAuthAnchorHash(e.authAnchorHash),u=new P.WasmPrePeginTx(e.depositorPubkey,e.vaultProviderPubkey,e.vaultKeeperPubkeys,e.universalChallengerPubkeys,[...e.hashlocks],new BigUint64Array(e.pegInAmounts),e.timelockRefund,e.feeRate,e.numLocalChallengers,e.councilQuorum,e.councilSize,e.network,b);let t=null;try{t=u.fromFundedTransaction(o);const h=t.buildRefundTx(d,r),l=await P.getPrePeginHtlcConnectorInfo({depositorPubkey:e.depositorPubkey,vaultProviderPubkey:e.vaultProviderPubkey,vaultKeeperPubkeys:e.vaultKeeperPubkeys,universalChallengerPubkeys:e.universalChallengerPubkeys,hashlock:c,timelockRefund:e.timelockRefund,network:e.network}),x=o.startsWith("0x")?o.slice(2):o,k=a.Transaction.fromHex(x),g=k.outs[r];if(!g)throw new Error(`HTLC output at vout ${r} not found in funded Pre-PegIn tx (tx has ${k.outs.length} outputs)`);const f=a.Transaction.fromHex(h);if(f.ins.length!==1)throw new Error(`Refund transaction must have exactly 1 input, got ${f.ins.length}`);const p=f.ins[0],T=k.getId(),v=n.uint8ArrayToHex(new Uint8Array(p.hash).slice().reverse());if(v!==T)throw new Error(`Refund input does not reference the Pre-PegIn transaction. Expected ${T}, got ${v}`);if(p.index!==r)throw new Error(`Refund input index ${p.index} does not match expected htlcVout ${r}`);const y=new a.Psbt;y.setVersion(f.version),y.setLocktime(f.locktime),y.addInput({hash:p.hash,index:p.index,sequence:p.sequence,witnessUtxo:{script:g.script,value:g.value},tapLeafScript:[{leafVersion:n.TAPSCRIPT_LEAF_VERSION,script:i.Buffer.from(n.hexToUint8Array(l.refundScript)),controlBlock:i.Buffer.from(n.hexToUint8Array(l.refundControlBlock))}],tapInternalKey:i.Buffer.from(P.tapInternalPubkey)});for(const m of f.outs)y.addOutput({script:m.script,value:m.value});return{psbtHex:y.toHex()}}finally{t==null||t.free(),u.free()}}async function A(s){const e=n.stripHexPrefix(s.noPayoutTxHex),o=a.Transaction.fromHex(e),{noPayoutScript:r,noPayoutControlBlock:d}=await P.getAssertNoPayoutScriptInfo(s.connectorParams,s.challengerPubkey),c=n.hexToUint8Array(r),b=n.hexToUint8Array(d),u=new a.Psbt;u.setVersion(o.version),u.setLocktime(o.locktime);for(let t=0;t<o.ins.length;t++){const h=o.ins[t],l=s.prevouts[t];if(!l)throw new Error(`Missing prevout data for input ${t}`);const x={hash:h.hash,index:h.index,sequence:h.sequence,witnessUtxo:{script:i.Buffer.from(n.hexToUint8Array(n.stripHexPrefix(l.script_pubkey))),value:l.value}};t===0&&(x.tapLeafScript=[{leafVersion:n.TAPSCRIPT_LEAF_VERSION,script:i.Buffer.from(c),controlBlock:i.Buffer.from(b)}],x.tapInternalKey=i.Buffer.from(P.tapInternalPubkey)),u.addInput(x)}for(const t of o.outs)u.addOutput({script:t.script,value:t.value});return u.toHex()}function I(s,e,o){const r=a.Transaction.fromHex(n.stripHexPrefix(s));if(r.outs.length!==1)throw new Error(`NoPayout transaction must have exactly 1 output, got ${r.outs.length}`);const d=n.hexToUint8Array(n.processPublicKeyToXOnly(e)),{output:c}=a.payments.p2tr({internalPubkey:i.Buffer.from(d),network:n.getNetwork(o)});if(!c)throw new Error("Failed to derive challenger BIP-86 P2TR scriptPubKey for NoPayout output validation");if(!r.outs[0].script.equals(c))throw new Error("NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address")}exports.assertNoPayoutOutputMatchesChallenger=I;exports.buildNoPayoutPsbt=A;exports.buildRefundPsbt=H;
2
+ //# sourceMappingURL=noPayout-jtZsoOzY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noPayout-jtZsoOzY.cjs","sources":["../src/tbv/core/primitives/psbt/refund.ts","../src/tbv/core/primitives/psbt/noPayout.ts"],"sourcesContent":["/**\n * Refund PSBT Builder Primitive\n *\n * Builds an unsigned refund PSBT for a depositor to reclaim BTC from\n * a timed-out Pre-PegIn HTLC output via the refund script (leaf 1).\n *\n * The refund script enforces a CSV timelock (timelockRefund blocks) and\n * requires only the depositor's Schnorr signature — no vault provider or\n * keeper involvement.\n *\n * @module primitives/psbt/refund\n */\n\nimport {\n getPrePeginHtlcConnectorInfo,\n initWasm,\n tapInternalPubkey,\n WasmPrePeginTx,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\n\nimport { TAPSCRIPT_LEAF_VERSION, hexToUint8Array, uint8ArrayToHex } from \"../utils/bitcoin\";\nimport { normalizeAuthAnchorHash, type PrePeginParams } from \"./pegin\";\n\n/**\n * Parameters for building a refund PSBT\n */\nexport interface BuildRefundPsbtParams {\n /** Same PrePeginParams used when the original Pre-PegIn tx was created */\n prePeginParams: PrePeginParams;\n /** Funded Pre-PegIn transaction hex (the tx whose HTLC output is being refunded) */\n fundedPrePeginTxHex: string;\n /** Index of the HTLC output in the Pre-PegIn transaction */\n htlcVout: number;\n /** Transaction fee in satoshis for the refund transaction */\n refundFee: bigint;\n /** SHA256 hash commitment for the HTLC (64 hex chars, no 0x prefix) */\n hashlock: string;\n}\n\n/**\n * Result of building a refund PSBT\n */\nexport interface BuildRefundPsbtResult {\n /** PSBT hex ready for depositor signing */\n psbtHex: string;\n}\n\n/**\n * Build a PSBT for signing the refund transaction.\n *\n * The refund transaction spends the Pre-PegIn HTLC output via leaf 1\n * (the refund script: `<timelockRefund> CSV DROP <depositorPubkey> CHECKSIG`).\n * The PSBT includes the tapLeafScript entry so the depositor's wallet can\n * sign using Taproot script-path spending.\n *\n * The input's sequence is set to `timelockRefund` by the WASM, enforcing\n * the Bitcoin CSV timelock. The refund broadcast will be rejected by the\n * network if the timelock has not yet expired.\n *\n * @param params - Refund PSBT parameters\n * @returns PSBT hex for depositor signing\n * @throws If the HTLC output at htlcVout is not found\n * @throws If the refund transaction does not have exactly 1 input\n */\nexport async function buildRefundPsbt(\n params: BuildRefundPsbtParams,\n): Promise<BuildRefundPsbtResult> {\n await initWasm();\n\n const { prePeginParams, fundedPrePeginTxHex, htlcVout, refundFee, hashlock } =\n params;\n\n // The 13th positional arg `auth_anchor_hash` is `Option<String>` in\n // the Rust WASM constructor. Production peg-ins (PeginManager) always\n // commit an OP_RETURN <PUSH32 SHA256(authAnchor)> output at\n // `vout = hashlocks.length`; the unfunded template must include it so\n // `fromFundedTransaction` aligns with the funded tx's output shape.\n // Normalize identically to the peg-in primitives (`0x` strip,\n // lowercase, length/charset validation) so a direct primitive caller\n // reusing successful peg-in params doesn't hand unnormalized bytes to\n // WASM. Pass `undefined` for legacy non-auth-anchored Pre-PegIns.\n const normalizedAuthAnchorHash = normalizeAuthAnchorHash(\n prePeginParams.authAnchorHash,\n );\n const unfundedTx = new (WasmPrePeginTx as unknown as new (\n depositor: string,\n vault_provider: string,\n vault_keepers: string[],\n universal_challengers: string[],\n hashlocks: string[],\n pegin_amounts: BigUint64Array,\n timelock_refund: number,\n fee_rate: bigint,\n num_local_challengers: number,\n council_quorum: number,\n council_size: number,\n network: string,\n auth_anchor_hash?: string,\n ) => typeof WasmPrePeginTx.prototype)(\n prePeginParams.depositorPubkey,\n prePeginParams.vaultProviderPubkey,\n prePeginParams.vaultKeeperPubkeys,\n prePeginParams.universalChallengerPubkeys,\n [...prePeginParams.hashlocks],\n new BigUint64Array(prePeginParams.pegInAmounts),\n prePeginParams.timelockRefund,\n prePeginParams.feeRate,\n prePeginParams.numLocalChallengers,\n prePeginParams.councilQuorum,\n prePeginParams.councilSize,\n prePeginParams.network,\n normalizedAuthAnchorHash,\n );\n\n let fundedTx: WasmPrePeginTx | null = null;\n try {\n fundedTx = unfundedTx.fromFundedTransaction(fundedPrePeginTxHex);\n\n const refundTxHex = fundedTx.buildRefundTx(refundFee, htlcVout);\n\n const htlcConnector = await getPrePeginHtlcConnectorInfo({\n depositorPubkey: prePeginParams.depositorPubkey,\n vaultProviderPubkey: prePeginParams.vaultProviderPubkey,\n vaultKeeperPubkeys: prePeginParams.vaultKeeperPubkeys,\n universalChallengerPubkeys: prePeginParams.universalChallengerPubkeys,\n hashlock,\n timelockRefund: prePeginParams.timelockRefund,\n network: prePeginParams.network,\n });\n\n const cleanPrePeginHex = fundedPrePeginTxHex.startsWith(\"0x\")\n ? fundedPrePeginTxHex.slice(2)\n : fundedPrePeginTxHex;\n const prePeginTx = Transaction.fromHex(cleanPrePeginHex);\n\n const htlcOutput = prePeginTx.outs[htlcVout];\n if (!htlcOutput) {\n throw new Error(\n `HTLC output at vout ${htlcVout} not found in funded Pre-PegIn tx ` +\n `(tx has ${prePeginTx.outs.length} outputs)`,\n );\n }\n\n const refundTx = Transaction.fromHex(refundTxHex);\n\n if (refundTx.ins.length !== 1) {\n throw new Error(\n `Refund transaction must have exactly 1 input, got ${refundTx.ins.length}`,\n );\n }\n\n const refundInput = refundTx.ins[0];\n\n // Verify the refund input spends the correct Pre-PegIn HTLC output\n const prePeginTxid = prePeginTx.getId();\n const refundInputTxid = uint8ArrayToHex(\n new Uint8Array(refundInput.hash).slice().reverse(),\n );\n if (refundInputTxid !== prePeginTxid) {\n throw new Error(\n `Refund input does not reference the Pre-PegIn transaction. ` +\n `Expected ${prePeginTxid}, got ${refundInputTxid}`,\n );\n }\n if (refundInput.index !== htlcVout) {\n throw new Error(\n `Refund input index ${refundInput.index} does not match expected htlcVout ${htlcVout}`,\n );\n }\n\n const psbt = new Psbt();\n psbt.setVersion(refundTx.version);\n psbt.setLocktime(refundTx.locktime);\n\n psbt.addInput({\n hash: refundInput.hash,\n index: refundInput.index,\n sequence: refundInput.sequence,\n witnessUtxo: {\n script: htlcOutput.script,\n value: htlcOutput.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(hexToUint8Array(htlcConnector.refundScript)),\n controlBlock: Buffer.from(\n hexToUint8Array(htlcConnector.refundControlBlock),\n ),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n });\n\n for (const output of refundTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return { psbtHex: psbt.toHex() };\n } finally {\n fundedTx?.free();\n unfundedTx.free();\n }\n}\n","/**\n * NoPayout PSBT Builder\n *\n * Builds unsigned PSBTs for the depositor's NoPayout transaction\n * (depositor-as-claimer path, per challenger). The depositor signs input 0\n * using the NoPayout taproot script from WasmAssertPayoutNoPayoutConnector.\n *\n * @module primitives/psbt/noPayout\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md — Assert output 0 NoPayout connector\n */\n\nimport {\n type AssertPayoutNoPayoutConnectorParams,\n type Network,\n getAssertNoPayoutScriptInfo,\n tapInternalPubkey,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction, payments } from \"bitcoinjs-lib\";\n\nimport {\n TAPSCRIPT_LEAF_VERSION,\n getNetwork,\n hexToUint8Array,\n processPublicKeyToXOnly,\n stripHexPrefix,\n} from \"../utils/bitcoin\";\n\n/**\n * Parameters for building a NoPayout PSBT\n */\nexport interface NoPayoutParams {\n /** NoPayout transaction hex (unsigned) from VP */\n noPayoutTxHex: string;\n /** Challenger's x-only public key (hex encoded) */\n challengerPubkey: string;\n /** Prevouts for all inputs [{script_pubkey, value}] from VP */\n prevouts: Array<{ script_pubkey: string; value: number }>;\n /** Parameters for the Assert Payout/NoPayout connector */\n connectorParams: AssertPayoutNoPayoutConnectorParams;\n}\n\n/**\n * Build unsigned NoPayout PSBT.\n *\n * The NoPayout transaction is specific to each challenger.\n * Input 0 is the one the depositor signs using the NoPayout taproot script path.\n *\n * @param params - NoPayout parameters\n * @returns Unsigned PSBT hex ready for signing\n */\nexport async function buildNoPayoutPsbt(\n params: NoPayoutParams,\n): Promise<string> {\n const noPayoutTxHex = stripHexPrefix(params.noPayoutTxHex);\n const noPayoutTx = Transaction.fromHex(noPayoutTxHex);\n\n // Get NoPayout script and control block for this challenger\n const { noPayoutScript, noPayoutControlBlock } =\n await getAssertNoPayoutScriptInfo(\n params.connectorParams,\n params.challengerPubkey,\n );\n\n const scriptBytes = hexToUint8Array(noPayoutScript);\n const controlBlockBytes = hexToUint8Array(noPayoutControlBlock);\n\n const psbt = new Psbt();\n psbt.setVersion(noPayoutTx.version);\n psbt.setLocktime(noPayoutTx.locktime);\n\n // Add all inputs - depositor signs input 0 only\n for (let i = 0; i < noPayoutTx.ins.length; i++) {\n const input = noPayoutTx.ins[i];\n const prevout = params.prevouts[i];\n\n if (!prevout) {\n throw new Error(`Missing prevout data for input ${i}`);\n }\n\n const inputData: Parameters<typeof psbt.addInput>[0] = {\n hash: input.hash,\n index: input.index,\n sequence: input.sequence,\n witnessUtxo: {\n script: Buffer.from(hexToUint8Array(stripHexPrefix(prevout.script_pubkey))),\n value: prevout.value,\n },\n };\n\n // Input 0: depositor signs using taproot script path\n if (i === 0) {\n inputData.tapLeafScript = [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(scriptBytes),\n controlBlock: Buffer.from(controlBlockBytes),\n },\n ];\n inputData.tapInternalKey = Buffer.from(tapInternalPubkey);\n }\n\n psbt.addInput(inputData);\n }\n\n // Add outputs\n for (const output of noPayoutTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return psbt.toHex();\n}\n\n/**\n * Validate that a NoPayout transaction pays to the challenger via the\n * protocol-defined output structure: a single BIP-86 P2TR output derived from\n * the challenger's x-only pubkey.\n *\n * Mirrors `assertPayoutOutputMatchesRegistered` for the NoPayout path, where\n * the sink is fixed by the protocol rather than read from on-chain registration\n * (see `crates/vault/src/transactions/nopayout.rs::NoPayoutTx::new`).\n *\n * @param noPayoutTxHex - Raw NoPayout transaction hex\n * @param challengerPubkey - Challenger's x-only public key (hex)\n * @param network - Bitcoin network used to derive the P2TR scriptPubKey\n * @throws If the transaction does not have exactly one output\n * @throws If the single output's scriptPubKey does not equal the BIP-86 P2TR\n * scriptPubKey for the challenger\n */\nexport function assertNoPayoutOutputMatchesChallenger(\n noPayoutTxHex: string,\n challengerPubkey: string,\n network: Network,\n): void {\n const tx = Transaction.fromHex(stripHexPrefix(noPayoutTxHex));\n\n if (tx.outs.length !== 1) {\n throw new Error(\n `NoPayout transaction must have exactly 1 output, got ${tx.outs.length}`,\n );\n }\n\n const xOnly = hexToUint8Array(processPublicKeyToXOnly(challengerPubkey));\n const { output: expectedScript } = payments.p2tr({\n internalPubkey: Buffer.from(xOnly),\n network: getNetwork(network),\n });\n if (!expectedScript) {\n throw new Error(\n \"Failed to derive challenger BIP-86 P2TR scriptPubKey for NoPayout output validation\",\n );\n }\n\n if (!tx.outs[0].script.equals(expectedScript)) {\n throw new Error(\n \"NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address\",\n );\n }\n}\n"],"names":["buildRefundPsbt","params","initWasm","prePeginParams","fundedPrePeginTxHex","htlcVout","refundFee","hashlock","normalizedAuthAnchorHash","normalizeAuthAnchorHash","unfundedTx","WasmPrePeginTx","fundedTx","refundTxHex","htlcConnector","getPrePeginHtlcConnectorInfo","cleanPrePeginHex","prePeginTx","Transaction","htlcOutput","refundTx","refundInput","prePeginTxid","refundInputTxid","uint8ArrayToHex","psbt","Psbt","TAPSCRIPT_LEAF_VERSION","Buffer","hexToUint8Array","tapInternalPubkey","output","buildNoPayoutPsbt","noPayoutTxHex","stripHexPrefix","noPayoutTx","noPayoutScript","noPayoutControlBlock","getAssertNoPayoutScriptInfo","scriptBytes","controlBlockBytes","i","input","prevout","inputData","assertNoPayoutOutputMatchesChallenger","challengerPubkey","network","tx","xOnly","processPublicKeyToXOnly","expectedScript","payments","getNetwork"],"mappings":"iNAkEA,eAAsBA,EACpBC,EACgC,CAChC,MAAMC,WAAA,EAEN,KAAM,CAAE,eAAAC,EAAgB,oBAAAC,EAAqB,SAAAC,EAAU,UAAAC,EAAW,SAAAC,GAChEN,EAWIO,EAA2BC,EAAAA,wBAC/BN,EAAe,cAAA,EAEXO,EAAa,IAAKC,EAAAA,eAetBR,EAAe,gBACfA,EAAe,oBACfA,EAAe,mBACfA,EAAe,2BACf,CAAC,GAAGA,EAAe,SAAS,EAC5B,IAAI,eAAeA,EAAe,YAAY,EAC9CA,EAAe,eACfA,EAAe,QACfA,EAAe,oBACfA,EAAe,cACfA,EAAe,YACfA,EAAe,QACfK,CA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C1E,MAAOA,EAAQ,KAAA,CACjB,EAIEF,IAAM,IACRG,EAAU,cAAgB,CACxB,CACE,YAAajB,EAAAA,uBACb,OAAQC,EAAAA,OAAO,KAAKW,CAAW,EAC/B,aAAcX,EAAAA,OAAO,KAAKY,CAAiB,CAAA,CAC7C,EAEFI,EAAU,eAAiBhB,SAAO,KAAKE,EAAAA,iBAAiB,GAG1DL,EAAK,SAASmB,CAAS,CACzB,CAGA,UAAWb,KAAUI,EAAW,KAC9BV,EAAK,UAAU,CACb,OAAQM,EAAO,OACf,MAAOA,EAAO,KAAA,CACf,EAGH,OAAON,EAAK,MAAA,CACd,CAkBO,SAASoB,EACdZ,EACAa,EACAC,EACM,CACN,MAAMC,EAAK9B,EAAAA,YAAY,QAAQgB,EAAAA,eAAeD,CAAa,CAAC,EAE5D,GAAIe,EAAG,KAAK,SAAW,EACrB,MAAM,IAAI,MACR,wDAAwDA,EAAG,KAAK,MAAM,EAAA,EAI1E,MAAMC,EAAQpB,EAAAA,gBAAgBqB,EAAAA,wBAAwBJ,CAAgB,CAAC,EACjE,CAAE,OAAQK,GAAmBC,EAAAA,SAAS,KAAK,CAC/C,eAAgBxB,EAAAA,OAAO,KAAKqB,CAAK,EACjC,QAASI,EAAAA,WAAWN,CAAO,CAAA,CAC5B,EACD,GAAI,CAACI,EACH,MAAM,IAAI,MACR,qFAAA,EAIJ,GAAI,CAACH,EAAG,KAAK,CAAC,EAAE,OAAO,OAAOG,CAAc,EAC1C,MAAM,IAAI,MACR,kFAAA,CAGN"}
@@ -0,0 +1,145 @@
1
+ import { initWasm as A, WasmPrePeginTx as R, getPrePeginHtlcConnectorInfo as B, tapInternalPubkey as T, getAssertNoPayoutScriptInfo as C } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
+ import { Buffer as u } from "buffer";
3
+ import { Transaction as x, Psbt as H, payments as E } from "bitcoinjs-lib";
4
+ import { u as S, T as I, h as p, s as g, p as $, j as N } from "./bitcoin-B5aNKtsk.js";
5
+ import { n as K } from "./assertPsbtUnsignedTxMatches-mTAnLhCz.js";
6
+ async function F(r) {
7
+ await A();
8
+ const { prePeginParams: e, fundedPrePeginTxHex: o, htlcVout: n, refundFee: f, hashlock: i } = r, y = K(
9
+ e.authAnchorHash
10
+ ), s = new R(
11
+ e.depositorPubkey,
12
+ e.vaultProviderPubkey,
13
+ e.vaultKeeperPubkeys,
14
+ e.universalChallengerPubkeys,
15
+ [...e.hashlocks],
16
+ new BigUint64Array(e.pegInAmounts),
17
+ e.timelockRefund,
18
+ e.feeRate,
19
+ e.numLocalChallengers,
20
+ e.councilQuorum,
21
+ e.councilSize,
22
+ e.network,
23
+ y
24
+ );
25
+ let t = null;
26
+ try {
27
+ t = s.fromFundedTransaction(o);
28
+ const d = t.buildRefundTx(f, n), a = await B({
29
+ depositorPubkey: e.depositorPubkey,
30
+ vaultProviderPubkey: e.vaultProviderPubkey,
31
+ vaultKeeperPubkeys: e.vaultKeeperPubkeys,
32
+ universalChallengerPubkeys: e.universalChallengerPubkeys,
33
+ hashlock: i,
34
+ timelockRefund: e.timelockRefund,
35
+ network: e.network
36
+ }), h = o.startsWith("0x") ? o.slice(2) : o, m = x.fromHex(h), k = m.outs[n];
37
+ if (!k)
38
+ throw new Error(
39
+ `HTLC output at vout ${n} not found in funded Pre-PegIn tx (tx has ${m.outs.length} outputs)`
40
+ );
41
+ const c = x.fromHex(d);
42
+ if (c.ins.length !== 1)
43
+ throw new Error(
44
+ `Refund transaction must have exactly 1 input, got ${c.ins.length}`
45
+ );
46
+ const l = c.ins[0], v = m.getId(), w = S(
47
+ new Uint8Array(l.hash).slice().reverse()
48
+ );
49
+ if (w !== v)
50
+ throw new Error(
51
+ `Refund input does not reference the Pre-PegIn transaction. Expected ${v}, got ${w}`
52
+ );
53
+ if (l.index !== n)
54
+ throw new Error(
55
+ `Refund input index ${l.index} does not match expected htlcVout ${n}`
56
+ );
57
+ const P = new H();
58
+ P.setVersion(c.version), P.setLocktime(c.locktime), P.addInput({
59
+ hash: l.hash,
60
+ index: l.index,
61
+ sequence: l.sequence,
62
+ witnessUtxo: {
63
+ script: k.script,
64
+ value: k.value
65
+ },
66
+ tapLeafScript: [
67
+ {
68
+ leafVersion: I,
69
+ script: u.from(p(a.refundScript)),
70
+ controlBlock: u.from(
71
+ p(a.refundControlBlock)
72
+ )
73
+ }
74
+ ],
75
+ tapInternalKey: u.from(T)
76
+ });
77
+ for (const b of c.outs)
78
+ P.addOutput({
79
+ script: b.script,
80
+ value: b.value
81
+ });
82
+ return { psbtHex: P.toHex() };
83
+ } finally {
84
+ t == null || t.free(), s.free();
85
+ }
86
+ }
87
+ async function z(r) {
88
+ const e = g(r.noPayoutTxHex), o = x.fromHex(e), { noPayoutScript: n, noPayoutControlBlock: f } = await C(
89
+ r.connectorParams,
90
+ r.challengerPubkey
91
+ ), i = p(n), y = p(f), s = new H();
92
+ s.setVersion(o.version), s.setLocktime(o.locktime);
93
+ for (let t = 0; t < o.ins.length; t++) {
94
+ const d = o.ins[t], a = r.prevouts[t];
95
+ if (!a)
96
+ throw new Error(`Missing prevout data for input ${t}`);
97
+ const h = {
98
+ hash: d.hash,
99
+ index: d.index,
100
+ sequence: d.sequence,
101
+ witnessUtxo: {
102
+ script: u.from(p(g(a.script_pubkey))),
103
+ value: a.value
104
+ }
105
+ };
106
+ t === 0 && (h.tapLeafScript = [
107
+ {
108
+ leafVersion: I,
109
+ script: u.from(i),
110
+ controlBlock: u.from(y)
111
+ }
112
+ ], h.tapInternalKey = u.from(T)), s.addInput(h);
113
+ }
114
+ for (const t of o.outs)
115
+ s.addOutput({
116
+ script: t.script,
117
+ value: t.value
118
+ });
119
+ return s.toHex();
120
+ }
121
+ function W(r, e, o) {
122
+ const n = x.fromHex(g(r));
123
+ if (n.outs.length !== 1)
124
+ throw new Error(
125
+ `NoPayout transaction must have exactly 1 output, got ${n.outs.length}`
126
+ );
127
+ const f = p($(e)), { output: i } = E.p2tr({
128
+ internalPubkey: u.from(f),
129
+ network: N(o)
130
+ });
131
+ if (!i)
132
+ throw new Error(
133
+ "Failed to derive challenger BIP-86 P2TR scriptPubKey for NoPayout output validation"
134
+ );
135
+ if (!n.outs[0].script.equals(i))
136
+ throw new Error(
137
+ "NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address"
138
+ );
139
+ }
140
+ export {
141
+ z as a,
142
+ F as b,
143
+ W as c
144
+ };
145
+ //# sourceMappingURL=noPayout-qbaSEKGC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noPayout-qbaSEKGC.js","sources":["../src/tbv/core/primitives/psbt/refund.ts","../src/tbv/core/primitives/psbt/noPayout.ts"],"sourcesContent":["/**\n * Refund PSBT Builder Primitive\n *\n * Builds an unsigned refund PSBT for a depositor to reclaim BTC from\n * a timed-out Pre-PegIn HTLC output via the refund script (leaf 1).\n *\n * The refund script enforces a CSV timelock (timelockRefund blocks) and\n * requires only the depositor's Schnorr signature — no vault provider or\n * keeper involvement.\n *\n * @module primitives/psbt/refund\n */\n\nimport {\n getPrePeginHtlcConnectorInfo,\n initWasm,\n tapInternalPubkey,\n WasmPrePeginTx,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\n\nimport { TAPSCRIPT_LEAF_VERSION, hexToUint8Array, uint8ArrayToHex } from \"../utils/bitcoin\";\nimport { normalizeAuthAnchorHash, type PrePeginParams } from \"./pegin\";\n\n/**\n * Parameters for building a refund PSBT\n */\nexport interface BuildRefundPsbtParams {\n /** Same PrePeginParams used when the original Pre-PegIn tx was created */\n prePeginParams: PrePeginParams;\n /** Funded Pre-PegIn transaction hex (the tx whose HTLC output is being refunded) */\n fundedPrePeginTxHex: string;\n /** Index of the HTLC output in the Pre-PegIn transaction */\n htlcVout: number;\n /** Transaction fee in satoshis for the refund transaction */\n refundFee: bigint;\n /** SHA256 hash commitment for the HTLC (64 hex chars, no 0x prefix) */\n hashlock: string;\n}\n\n/**\n * Result of building a refund PSBT\n */\nexport interface BuildRefundPsbtResult {\n /** PSBT hex ready for depositor signing */\n psbtHex: string;\n}\n\n/**\n * Build a PSBT for signing the refund transaction.\n *\n * The refund transaction spends the Pre-PegIn HTLC output via leaf 1\n * (the refund script: `<timelockRefund> CSV DROP <depositorPubkey> CHECKSIG`).\n * The PSBT includes the tapLeafScript entry so the depositor's wallet can\n * sign using Taproot script-path spending.\n *\n * The input's sequence is set to `timelockRefund` by the WASM, enforcing\n * the Bitcoin CSV timelock. The refund broadcast will be rejected by the\n * network if the timelock has not yet expired.\n *\n * @param params - Refund PSBT parameters\n * @returns PSBT hex for depositor signing\n * @throws If the HTLC output at htlcVout is not found\n * @throws If the refund transaction does not have exactly 1 input\n */\nexport async function buildRefundPsbt(\n params: BuildRefundPsbtParams,\n): Promise<BuildRefundPsbtResult> {\n await initWasm();\n\n const { prePeginParams, fundedPrePeginTxHex, htlcVout, refundFee, hashlock } =\n params;\n\n // The 13th positional arg `auth_anchor_hash` is `Option<String>` in\n // the Rust WASM constructor. Production peg-ins (PeginManager) always\n // commit an OP_RETURN <PUSH32 SHA256(authAnchor)> output at\n // `vout = hashlocks.length`; the unfunded template must include it so\n // `fromFundedTransaction` aligns with the funded tx's output shape.\n // Normalize identically to the peg-in primitives (`0x` strip,\n // lowercase, length/charset validation) so a direct primitive caller\n // reusing successful peg-in params doesn't hand unnormalized bytes to\n // WASM. Pass `undefined` for legacy non-auth-anchored Pre-PegIns.\n const normalizedAuthAnchorHash = normalizeAuthAnchorHash(\n prePeginParams.authAnchorHash,\n );\n const unfundedTx = new (WasmPrePeginTx as unknown as new (\n depositor: string,\n vault_provider: string,\n vault_keepers: string[],\n universal_challengers: string[],\n hashlocks: string[],\n pegin_amounts: BigUint64Array,\n timelock_refund: number,\n fee_rate: bigint,\n num_local_challengers: number,\n council_quorum: number,\n council_size: number,\n network: string,\n auth_anchor_hash?: string,\n ) => typeof WasmPrePeginTx.prototype)(\n prePeginParams.depositorPubkey,\n prePeginParams.vaultProviderPubkey,\n prePeginParams.vaultKeeperPubkeys,\n prePeginParams.universalChallengerPubkeys,\n [...prePeginParams.hashlocks],\n new BigUint64Array(prePeginParams.pegInAmounts),\n prePeginParams.timelockRefund,\n prePeginParams.feeRate,\n prePeginParams.numLocalChallengers,\n prePeginParams.councilQuorum,\n prePeginParams.councilSize,\n prePeginParams.network,\n normalizedAuthAnchorHash,\n );\n\n let fundedTx: WasmPrePeginTx | null = null;\n try {\n fundedTx = unfundedTx.fromFundedTransaction(fundedPrePeginTxHex);\n\n const refundTxHex = fundedTx.buildRefundTx(refundFee, htlcVout);\n\n const htlcConnector = await getPrePeginHtlcConnectorInfo({\n depositorPubkey: prePeginParams.depositorPubkey,\n vaultProviderPubkey: prePeginParams.vaultProviderPubkey,\n vaultKeeperPubkeys: prePeginParams.vaultKeeperPubkeys,\n universalChallengerPubkeys: prePeginParams.universalChallengerPubkeys,\n hashlock,\n timelockRefund: prePeginParams.timelockRefund,\n network: prePeginParams.network,\n });\n\n const cleanPrePeginHex = fundedPrePeginTxHex.startsWith(\"0x\")\n ? fundedPrePeginTxHex.slice(2)\n : fundedPrePeginTxHex;\n const prePeginTx = Transaction.fromHex(cleanPrePeginHex);\n\n const htlcOutput = prePeginTx.outs[htlcVout];\n if (!htlcOutput) {\n throw new Error(\n `HTLC output at vout ${htlcVout} not found in funded Pre-PegIn tx ` +\n `(tx has ${prePeginTx.outs.length} outputs)`,\n );\n }\n\n const refundTx = Transaction.fromHex(refundTxHex);\n\n if (refundTx.ins.length !== 1) {\n throw new Error(\n `Refund transaction must have exactly 1 input, got ${refundTx.ins.length}`,\n );\n }\n\n const refundInput = refundTx.ins[0];\n\n // Verify the refund input spends the correct Pre-PegIn HTLC output\n const prePeginTxid = prePeginTx.getId();\n const refundInputTxid = uint8ArrayToHex(\n new Uint8Array(refundInput.hash).slice().reverse(),\n );\n if (refundInputTxid !== prePeginTxid) {\n throw new Error(\n `Refund input does not reference the Pre-PegIn transaction. ` +\n `Expected ${prePeginTxid}, got ${refundInputTxid}`,\n );\n }\n if (refundInput.index !== htlcVout) {\n throw new Error(\n `Refund input index ${refundInput.index} does not match expected htlcVout ${htlcVout}`,\n );\n }\n\n const psbt = new Psbt();\n psbt.setVersion(refundTx.version);\n psbt.setLocktime(refundTx.locktime);\n\n psbt.addInput({\n hash: refundInput.hash,\n index: refundInput.index,\n sequence: refundInput.sequence,\n witnessUtxo: {\n script: htlcOutput.script,\n value: htlcOutput.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(hexToUint8Array(htlcConnector.refundScript)),\n controlBlock: Buffer.from(\n hexToUint8Array(htlcConnector.refundControlBlock),\n ),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n });\n\n for (const output of refundTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return { psbtHex: psbt.toHex() };\n } finally {\n fundedTx?.free();\n unfundedTx.free();\n }\n}\n","/**\n * NoPayout PSBT Builder\n *\n * Builds unsigned PSBTs for the depositor's NoPayout transaction\n * (depositor-as-claimer path, per challenger). The depositor signs input 0\n * using the NoPayout taproot script from WasmAssertPayoutNoPayoutConnector.\n *\n * @module primitives/psbt/noPayout\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md — Assert output 0 NoPayout connector\n */\n\nimport {\n type AssertPayoutNoPayoutConnectorParams,\n type Network,\n getAssertNoPayoutScriptInfo,\n tapInternalPubkey,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction, payments } from \"bitcoinjs-lib\";\n\nimport {\n TAPSCRIPT_LEAF_VERSION,\n getNetwork,\n hexToUint8Array,\n processPublicKeyToXOnly,\n stripHexPrefix,\n} from \"../utils/bitcoin\";\n\n/**\n * Parameters for building a NoPayout PSBT\n */\nexport interface NoPayoutParams {\n /** NoPayout transaction hex (unsigned) from VP */\n noPayoutTxHex: string;\n /** Challenger's x-only public key (hex encoded) */\n challengerPubkey: string;\n /** Prevouts for all inputs [{script_pubkey, value}] from VP */\n prevouts: Array<{ script_pubkey: string; value: number }>;\n /** Parameters for the Assert Payout/NoPayout connector */\n connectorParams: AssertPayoutNoPayoutConnectorParams;\n}\n\n/**\n * Build unsigned NoPayout PSBT.\n *\n * The NoPayout transaction is specific to each challenger.\n * Input 0 is the one the depositor signs using the NoPayout taproot script path.\n *\n * @param params - NoPayout parameters\n * @returns Unsigned PSBT hex ready for signing\n */\nexport async function buildNoPayoutPsbt(\n params: NoPayoutParams,\n): Promise<string> {\n const noPayoutTxHex = stripHexPrefix(params.noPayoutTxHex);\n const noPayoutTx = Transaction.fromHex(noPayoutTxHex);\n\n // Get NoPayout script and control block for this challenger\n const { noPayoutScript, noPayoutControlBlock } =\n await getAssertNoPayoutScriptInfo(\n params.connectorParams,\n params.challengerPubkey,\n );\n\n const scriptBytes = hexToUint8Array(noPayoutScript);\n const controlBlockBytes = hexToUint8Array(noPayoutControlBlock);\n\n const psbt = new Psbt();\n psbt.setVersion(noPayoutTx.version);\n psbt.setLocktime(noPayoutTx.locktime);\n\n // Add all inputs - depositor signs input 0 only\n for (let i = 0; i < noPayoutTx.ins.length; i++) {\n const input = noPayoutTx.ins[i];\n const prevout = params.prevouts[i];\n\n if (!prevout) {\n throw new Error(`Missing prevout data for input ${i}`);\n }\n\n const inputData: Parameters<typeof psbt.addInput>[0] = {\n hash: input.hash,\n index: input.index,\n sequence: input.sequence,\n witnessUtxo: {\n script: Buffer.from(hexToUint8Array(stripHexPrefix(prevout.script_pubkey))),\n value: prevout.value,\n },\n };\n\n // Input 0: depositor signs using taproot script path\n if (i === 0) {\n inputData.tapLeafScript = [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(scriptBytes),\n controlBlock: Buffer.from(controlBlockBytes),\n },\n ];\n inputData.tapInternalKey = Buffer.from(tapInternalPubkey);\n }\n\n psbt.addInput(inputData);\n }\n\n // Add outputs\n for (const output of noPayoutTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return psbt.toHex();\n}\n\n/**\n * Validate that a NoPayout transaction pays to the challenger via the\n * protocol-defined output structure: a single BIP-86 P2TR output derived from\n * the challenger's x-only pubkey.\n *\n * Mirrors `assertPayoutOutputMatchesRegistered` for the NoPayout path, where\n * the sink is fixed by the protocol rather than read from on-chain registration\n * (see `crates/vault/src/transactions/nopayout.rs::NoPayoutTx::new`).\n *\n * @param noPayoutTxHex - Raw NoPayout transaction hex\n * @param challengerPubkey - Challenger's x-only public key (hex)\n * @param network - Bitcoin network used to derive the P2TR scriptPubKey\n * @throws If the transaction does not have exactly one output\n * @throws If the single output's scriptPubKey does not equal the BIP-86 P2TR\n * scriptPubKey for the challenger\n */\nexport function assertNoPayoutOutputMatchesChallenger(\n noPayoutTxHex: string,\n challengerPubkey: string,\n network: Network,\n): void {\n const tx = Transaction.fromHex(stripHexPrefix(noPayoutTxHex));\n\n if (tx.outs.length !== 1) {\n throw new Error(\n `NoPayout transaction must have exactly 1 output, got ${tx.outs.length}`,\n );\n }\n\n const xOnly = hexToUint8Array(processPublicKeyToXOnly(challengerPubkey));\n const { output: expectedScript } = payments.p2tr({\n internalPubkey: Buffer.from(xOnly),\n network: getNetwork(network),\n });\n if (!expectedScript) {\n throw new Error(\n \"Failed to derive challenger BIP-86 P2TR scriptPubKey for NoPayout output validation\",\n );\n }\n\n if (!tx.outs[0].script.equals(expectedScript)) {\n throw new Error(\n \"NoPayout transaction does not pay to the expected challenger BIP-86 P2TR address\",\n );\n }\n}\n"],"names":["buildRefundPsbt","params","initWasm","prePeginParams","fundedPrePeginTxHex","htlcVout","refundFee","hashlock","normalizedAuthAnchorHash","normalizeAuthAnchorHash","unfundedTx","WasmPrePeginTx","fundedTx","refundTxHex","htlcConnector","getPrePeginHtlcConnectorInfo","cleanPrePeginHex","prePeginTx","Transaction","htlcOutput","refundTx","refundInput","prePeginTxid","refundInputTxid","uint8ArrayToHex","psbt","Psbt","TAPSCRIPT_LEAF_VERSION","Buffer","hexToUint8Array","tapInternalPubkey","output","buildNoPayoutPsbt","noPayoutTxHex","stripHexPrefix","noPayoutTx","noPayoutScript","noPayoutControlBlock","getAssertNoPayoutScriptInfo","scriptBytes","controlBlockBytes","i","input","prevout","inputData","assertNoPayoutOutputMatchesChallenger","challengerPubkey","network","tx","xOnly","processPublicKeyToXOnly","expectedScript","payments","getNetwork"],"mappings":";;;;;AAkEA,eAAsBA,EACpBC,GACgC;AAChC,QAAMC,EAAA;AAEN,QAAM,EAAE,gBAAAC,GAAgB,qBAAAC,GAAqB,UAAAC,GAAU,WAAAC,GAAW,UAAAC,MAChEN,GAWIO,IAA2BC;AAAA,IAC/BN,EAAe;AAAA,EAAA,GAEXO,IAAa,IAAKC;AAAA,IAetBR,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACf,CAAC,GAAGA,EAAe,SAAS;AAAA,IAC5B,IAAI,eAAeA,EAAe,YAAY;AAAA,IAC9CA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfA,EAAe;AAAA,IACfK;AAAA,EAAA;AAGF,MAAII,IAAkC;AACtC,MAAI;AACF,IAAAA,IAAWF,EAAW,sBAAsBN,CAAmB;AAE/D,UAAMS,IAAcD,EAAS,cAAcN,GAAWD,CAAQ,GAExDS,IAAgB,MAAMC,EAA6B;AAAA,MACvD,iBAAiBZ,EAAe;AAAA,MAChC,qBAAqBA,EAAe;AAAA,MACpC,oBAAoBA,EAAe;AAAA,MACnC,4BAA4BA,EAAe;AAAA,MAC3C,UAAAI;AAAA,MACA,gBAAgBJ,EAAe;AAAA,MAC/B,SAASA,EAAe;AAAA,IAAA,CACzB,GAEKa,IAAmBZ,EAAoB,WAAW,IAAI,IACxDA,EAAoB,MAAM,CAAC,IAC3BA,GACEa,IAAaC,EAAY,QAAQF,CAAgB,GAEjDG,IAAaF,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,CAAS;AAAA,EACzB;AAGA,aAAWb,KAAUI,EAAW;AAC9B,IAAAV,EAAK,UAAU;AAAA,MACb,QAAQM,EAAO;AAAA,MACf,OAAOA,EAAO;AAAA,IAAA,CACf;AAGH,SAAON,EAAK,MAAA;AACd;AAkBO,SAASoB,EACdZ,GACAa,GACAC,GACM;AACN,QAAMC,IAAK9B,EAAY,QAAQgB,EAAeD,CAAa,CAAC;AAE5D,MAAIe,EAAG,KAAK,WAAW;AACrB,UAAM,IAAI;AAAA,MACR,wDAAwDA,EAAG,KAAK,MAAM;AAAA,IAAA;AAI1E,QAAMC,IAAQpB,EAAgBqB,EAAwBJ,CAAgB,CAAC,GACjE,EAAE,QAAQK,MAAmBC,EAAS,KAAK;AAAA,IAC/C,gBAAgBxB,EAAO,KAAKqB,CAAK;AAAA,IACjC,SAASI,EAAWN,CAAO;AAAA,EAAA,CAC5B;AACD,MAAI,CAACI;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIJ,MAAI,CAACH,EAAG,KAAK,CAAC,EAAE,OAAO,OAAOG,CAAc;AAC1C,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAGN;"}
@@ -0,0 +1,104 @@
1
+ import { getPrePeginHtlcConnectorInfo as k, tapInternalPubkey as y } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
+ import { Buffer as u } from "buffer";
3
+ import { Transaction as P, Psbt as p } from "bitcoinjs-lib";
4
+ import { s as d, u as x, h as l, T as I } from "./bitcoin-B5aNKtsk.js";
5
+ async function m(t) {
6
+ const r = d(t.peginTxHex), a = d(t.fundedPrePeginTxHex), n = await k({
7
+ depositorPubkey: t.depositorPubkey,
8
+ vaultProviderPubkey: t.vaultProviderPubkey,
9
+ vaultKeeperPubkeys: t.vaultKeeperPubkeys,
10
+ universalChallengerPubkeys: t.universalChallengerPubkeys,
11
+ hashlock: t.hashlock,
12
+ timelockRefund: t.timelockRefund,
13
+ network: t.network
14
+ }), e = P.fromHex(r), i = P.fromHex(a);
15
+ if (e.ins.length !== 1)
16
+ throw new Error(
17
+ `PegIn transaction must have exactly 1 input, got ${e.ins.length}`
18
+ );
19
+ const o = e.ins[0], f = i.getId(), g = x(
20
+ new Uint8Array(o.hash).slice().reverse()
21
+ );
22
+ if (g !== f)
23
+ throw new Error(
24
+ `PegIn input does not reference the Pre-PegIn transaction. Expected ${f}, got ${g}`
25
+ );
26
+ const c = i.outs[o.index];
27
+ if (!c)
28
+ throw new Error(
29
+ `Pre-PegIn output ${o.index} not found (Pre-PegIn has ${i.outs.length} outputs)`
30
+ );
31
+ const S = l(n.hashlockScript), w = l(n.hashlockControlBlock), s = new p();
32
+ s.setVersion(e.version), s.setLocktime(e.locktime), s.addInput({
33
+ hash: o.hash,
34
+ index: o.index,
35
+ sequence: o.sequence,
36
+ witnessUtxo: {
37
+ script: c.script,
38
+ value: c.value
39
+ },
40
+ tapLeafScript: [
41
+ {
42
+ leafVersion: I,
43
+ script: u.from(S),
44
+ controlBlock: u.from(w)
45
+ }
46
+ ],
47
+ tapInternalKey: u.from(y)
48
+ // sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot
49
+ });
50
+ for (const h of e.outs)
51
+ s.addOutput({
52
+ script: h.script,
53
+ value: h.value
54
+ });
55
+ return { psbtHex: s.toHex() };
56
+ }
57
+ function B(t, r) {
58
+ const n = p.fromHex(t).data.inputs[0];
59
+ if (!n)
60
+ throw new Error("PegIn PSBT has no inputs");
61
+ if (n.tapScriptSig && n.tapScriptSig.length > 0) {
62
+ const e = u.from(
63
+ l(r)
64
+ );
65
+ for (const i of n.tapScriptSig)
66
+ if (i.pubkey.equals(e))
67
+ return b(i.signature);
68
+ throw new Error(
69
+ `No PegIn input signature found for depositor pubkey: ${r}`
70
+ );
71
+ }
72
+ throw n.finalScriptWitness && n.finalScriptWitness.length > 0 ? new Error(
73
+ "PegIn input PSBT is already finalized. Cannot reliably extract the depositor signature from the witness stack. Ensure the wallet returns a non-finalized PSBT with tapScriptSig entries."
74
+ ) : new Error(
75
+ "No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT"
76
+ );
77
+ }
78
+ function A(t) {
79
+ const r = p.fromHex(t);
80
+ try {
81
+ r.finalizeAllInputs();
82
+ } catch (a) {
83
+ if (!r.data.inputs.every(
84
+ (e) => e.finalScriptWitness || e.finalScriptSig
85
+ ))
86
+ throw new Error(
87
+ `PSBT finalization failed and wallet did not auto-finalize: ${a}`
88
+ );
89
+ }
90
+ return r.extractTransaction().toHex();
91
+ }
92
+ function b(t) {
93
+ if (t.length === 64)
94
+ return x(new Uint8Array(t));
95
+ throw t.length === 65 ? new Error(
96
+ `Unexpected sighash byte 0x${t[64].toString(16).padStart(2, "0")} in PegIn input signature. Expected implicit SIGHASH_DEFAULT as a 64-byte signature.`
97
+ ) : new Error(`Unexpected PegIn input signature length: ${t.length}`);
98
+ }
99
+ export {
100
+ m as b,
101
+ B as e,
102
+ A as f
103
+ };
104
+ //# sourceMappingURL=peginInput-BPRB9tUi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peginInput-BPRB9tUi.js","sources":["../src/tbv/core/primitives/psbt/peginInput.ts"],"sourcesContent":["/**\n * PegIn Input PSBT Builder\n *\n * Builds the PSBT for the depositor to sign the PegIn transaction's HTLC input\n * (Pre-PegIn HTLC leaf 0 — the hashlock + all-party script).\n *\n * This is the \"Sign Pegin transaction HTLC leaf 0 input\" step in the pre-pegin\n * flow. The depositor signs input 0 of the PegIn transaction,\n * which spends output 0 of the funded Pre-PegIn transaction via script-path.\n *\n * @module primitives/psbt/peginInput\n */\n\nimport {\n getPrePeginHtlcConnectorInfo,\n tapInternalPubkey,\n type Network,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\nimport { TAPSCRIPT_LEAF_VERSION, hexToUint8Array, stripHexPrefix, uint8ArrayToHex } from \"../utils/bitcoin\";\n\n/**\n * Parameters for building the PegIn input PSBT\n */\nexport interface BuildPeginInputPsbtParams {\n /**\n * PegIn transaction hex (1 input spending Pre-PegIn HTLC output 0).\n * Returned by buildPeginTxFromFundedPrePegin().\n */\n peginTxHex: string;\n /**\n * Funded Pre-PegIn transaction hex.\n * Used to look up the HTLC output that the PegIn input spends.\n */\n fundedPrePeginTxHex: string;\n /** Depositor's BTC public key (x-only, 64-char hex) */\n depositorPubkey: string;\n /** Vault provider's BTC public key (x-only, 64-char hex) */\n vaultProviderPubkey: string;\n /** Vault keeper BTC public keys (x-only, 64-char hex) */\n vaultKeeperPubkeys: string[];\n /** Universal challenger BTC public keys (x-only, 64-char hex) */\n universalChallengerPubkeys: string[];\n /** SHA256 hash commitment (64 hex chars = 32 bytes) */\n hashlock: string;\n /** CSV timelock in blocks for the HTLC refund path */\n timelockRefund: number;\n /** Bitcoin network */\n network: Network;\n}\n\n/**\n * Result of building the PegIn input PSBT\n */\nexport interface BuildPeginInputPsbtResult {\n /** PSBT hex for the depositor to sign */\n psbtHex: string;\n}\n\n/**\n * Build PSBT for depositor to sign the PegIn transaction's HTLC leaf 0 input.\n *\n * The PegIn transaction spends the Pre-PegIn HTLC output (output 0) via the\n * hashlock + all-party script (leaf 0). The depositor provides one of the required\n * signatures; the vault provider and keepers provide theirs separately via the\n * signPeginInput RPC.\n *\n * The PSBT uses Taproot script-path spending:\n * - witnessUtxo: the Pre-PegIn HTLC output\n * - tapLeafScript: hashlock leaf script + control block\n * - tapInternalKey: NUMS unspendable key (BIP-341 nothing-up-my-sleeve)\n *\n * @param params - PegIn input PSBT parameters\n * @returns PSBT hex ready for depositor signing\n * @throws If PegIn tx does not have exactly 1 input\n * @throws If PegIn input does not reference the Pre-PegIn HTLC output\n * @throws If Pre-PegIn tx output 0 is not found\n */\nexport async function buildPeginInputPsbt(\n params: BuildPeginInputPsbtParams,\n): Promise<BuildPeginInputPsbtResult> {\n const peginTxHex = stripHexPrefix(params.peginTxHex);\n const fundedPrePeginTxHex = stripHexPrefix(params.fundedPrePeginTxHex);\n\n const htlcConnector = await getPrePeginHtlcConnectorInfo({\n depositorPubkey: params.depositorPubkey,\n vaultProviderPubkey: params.vaultProviderPubkey,\n vaultKeeperPubkeys: params.vaultKeeperPubkeys,\n universalChallengerPubkeys: params.universalChallengerPubkeys,\n hashlock: params.hashlock,\n timelockRefund: params.timelockRefund,\n network: params.network,\n });\n\n const peginTx = Transaction.fromHex(peginTxHex);\n const prePeginTx = Transaction.fromHex(fundedPrePeginTxHex);\n\n if (peginTx.ins.length !== 1) {\n throw new Error(\n `PegIn transaction must have exactly 1 input, got ${peginTx.ins.length}`,\n );\n }\n\n const peginInput = peginTx.ins[0];\n\n // Verify PegIn input 0 spends Pre-PegIn output 0\n const prePeginTxid = prePeginTx.getId();\n const peginInputTxid = uint8ArrayToHex(\n new Uint8Array(peginInput.hash).slice().reverse(),\n );\n\n if (peginInputTxid !== prePeginTxid) {\n throw new Error(\n `PegIn input does not reference the Pre-PegIn transaction. ` +\n `Expected ${prePeginTxid}, got ${peginInputTxid}`,\n );\n }\n\n const htlcOutput = prePeginTx.outs[peginInput.index];\n if (!htlcOutput) {\n throw new Error(\n `Pre-PegIn output ${peginInput.index} not found ` +\n `(Pre-PegIn has ${prePeginTx.outs.length} outputs)`,\n );\n }\n\n const hashlockScript = hexToUint8Array(htlcConnector.hashlockScript);\n const hashlockControlBlock = hexToUint8Array(htlcConnector.hashlockControlBlock);\n\n const psbt = new Psbt();\n psbt.setVersion(peginTx.version);\n psbt.setLocktime(peginTx.locktime);\n\n // Input 0: PegIn input spending Pre-PegIn HTLC output 0 via hashlock leaf (leaf 0).\n // The depositor signs using Taproot script-path spending.\n psbt.addInput({\n hash: peginInput.hash,\n index: peginInput.index,\n sequence: peginInput.sequence,\n witnessUtxo: {\n script: htlcOutput.script,\n value: htlcOutput.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(hashlockScript),\n controlBlock: Buffer.from(hashlockControlBlock),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n // sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot\n });\n\n for (const output of peginTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return { psbtHex: psbt.toHex() };\n}\n\n/**\n * Extract the depositor's Schnorr signature from a signed PegIn input PSBT.\n *\n * Supports non-finalized PSBTs with tapScriptSig entries. Finalized PSBTs are\n * rejected because the witness stack does not reliably identify the depositor\n * signature by public key.\n *\n * PegIn input signatures must use implicit Taproot SIGHASH_DEFAULT, which is\n * encoded by omitting the sighash byte. Signatures with an appended sighash byte\n * are rejected rather than stripped.\n *\n * @param signedPsbtHex - Signed PSBT hex\n * @param depositorPubkey - Depositor's x-only public key (64-char hex)\n * @returns 64-byte Schnorr signature (128 hex chars, no sighash flag)\n * @throws If no signature is found for the depositor's key\n */\nexport function extractPeginInputSignature(\n signedPsbtHex: string,\n depositorPubkey: string,\n): string {\n const signedPsbt = Psbt.fromHex(signedPsbtHex);\n const input = signedPsbt.data.inputs[0];\n\n if (!input) {\n throw new Error(\"PegIn PSBT has no inputs\");\n }\n\n // Non-finalized PSBT — extract from tapScriptSig\n if (input.tapScriptSig && input.tapScriptSig.length > 0) {\n const depositorPubkeyBytes = Buffer.from(\n hexToUint8Array(depositorPubkey),\n );\n\n for (const sigEntry of input.tapScriptSig) {\n if (sigEntry.pubkey.equals(depositorPubkeyBytes)) {\n return extractSchnorrSig(sigEntry.signature);\n }\n }\n\n throw new Error(\n `No PegIn input signature found for depositor pubkey: ${depositorPubkey}`,\n );\n }\n\n // Finalized PSBT — the witness stack order depends on the wallet's finalizer,\n // so we cannot reliably pick the depositor's signature by position. Require\n // the non-finalized tapScriptSig path which identifies signatures by pubkey.\n if (input.finalScriptWitness && input.finalScriptWitness.length > 0) {\n throw new Error(\n \"PegIn input PSBT is already finalized. Cannot reliably extract the \" +\n \"depositor signature from the witness stack. Ensure the wallet returns \" +\n \"a non-finalized PSBT with tapScriptSig entries.\",\n );\n }\n\n throw new Error(\n \"No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT\",\n );\n}\n\n/**\n * Finalize a signed PegIn input PSBT and return the depositor-signed transaction hex.\n *\n * The default tapscript finalizer builds the full witness stack [sig, script, controlBlock]\n * that vaultd requires when verifying the depositor signature on-chain.\n *\n * @param signedPsbtHex - Non-finalized signed PSBT hex (returned by wallet with autoFinalized: false)\n * @returns Depositor-signed PegIn transaction hex with full taproot witness stack\n */\nexport function finalizePeginInputPsbt(signedPsbtHex: string): string {\n const psbt = Psbt.fromHex(signedPsbtHex);\n\n // Some wallets (UniSat, OKX) ignore autoFinalized: false and return\n // already-finalized PSBTs. finalizeAllInputs() throws in that case,\n // so fall back to verifying the wallet already finalized all inputs.\n try {\n psbt.finalizeAllInputs();\n } catch (e) {\n const allFinalized = psbt.data.inputs.every(\n (inp) => inp.finalScriptWitness || inp.finalScriptSig,\n );\n if (!allFinalized) {\n throw new Error(\n `PSBT finalization failed and wallet did not auto-finalize: ${e}`,\n );\n }\n }\n\n return psbt.extractTransaction().toHex();\n}\n\n/**\n * Extract and validate a 64-byte Schnorr signature.\n * PegIn input signatures must use implicit Taproot SIGHASH_DEFAULT, which is\n * encoded by omitting the sighash byte. Reject 65-byte signatures instead of\n * stripping the sighash byte because it changes the signed Taproot message.\n * @internal\n */\nexport function extractSchnorrSig(sig: Uint8Array): string {\n if (sig.length === 64) {\n return uint8ArrayToHex(new Uint8Array(sig));\n }\n if (sig.length === 65) {\n throw new Error(\n `Unexpected sighash byte 0x${sig[64].toString(16).padStart(2, \"0\")} in PegIn input signature. ` +\n \"Expected implicit SIGHASH_DEFAULT as a 64-byte signature.\",\n );\n }\n throw new Error(`Unexpected PegIn input signature length: ${sig.length}`);\n}\n"],"names":["buildPeginInputPsbt","params","peginTxHex","stripHexPrefix","fundedPrePeginTxHex","htlcConnector","getPrePeginHtlcConnectorInfo","peginTx","Transaction","prePeginTx","peginInput","prePeginTxid","peginInputTxid","uint8ArrayToHex","htlcOutput","hashlockScript","hexToUint8Array","hashlockControlBlock","psbt","Psbt","TAPSCRIPT_LEAF_VERSION","Buffer","tapInternalPubkey","output","extractPeginInputSignature","signedPsbtHex","depositorPubkey","input","depositorPubkeyBytes","sigEntry","extractSchnorrSig","finalizePeginInputPsbt","e","inp","sig"],"mappings":";;;;AA+EA,eAAsBA,EACpBC,GACoC;AACpC,QAAMC,IAAaC,EAAeF,EAAO,UAAU,GAC7CG,IAAsBD,EAAeF,EAAO,mBAAmB,GAE/DI,IAAgB,MAAMC,EAA6B;AAAA,IACvD,iBAAiBL,EAAO;AAAA,IACxB,qBAAqBA,EAAO;AAAA,IAC5B,oBAAoBA,EAAO;AAAA,IAC3B,4BAA4BA,EAAO;AAAA,IACnC,UAAUA,EAAO;AAAA,IACjB,gBAAgBA,EAAO;AAAA,IACvB,SAASA,EAAO;AAAA,EAAA,CACjB,GAEKM,IAAUC,EAAY,QAAQN,CAAU,GACxCO,IAAaD,EAAY,QAAQJ,CAAmB;AAE1D,MAAIG,EAAQ,IAAI,WAAW;AACzB,UAAM,IAAI;AAAA,MACR,oDAAoDA,EAAQ,IAAI,MAAM;AAAA,IAAA;AAI1E,QAAMG,IAAaH,EAAQ,IAAI,CAAC,GAG1BI,IAAeF,EAAW,MAAA,GAC1BG,IAAiBC;AAAA,IACrB,IAAI,WAAWH,EAAW,IAAI,EAAE,MAAA,EAAQ,QAAA;AAAA,EAAQ;AAGlD,MAAIE,MAAmBD;AACrB,UAAM,IAAI;AAAA,MACR,sEACcA,CAAY,SAASC,CAAc;AAAA,IAAA;AAIrD,QAAME,IAAaL,EAAW,KAAKC,EAAW,KAAK;AACnD,MAAI,CAACI;AACH,UAAM,IAAI;AAAA,MACR,oBAAoBJ,EAAW,KAAK,6BAChBD,EAAW,KAAK,MAAM;AAAA,IAAA;AAI9C,QAAMM,IAAiBC,EAAgBX,EAAc,cAAc,GAC7DY,IAAuBD,EAAgBX,EAAc,oBAAoB,GAEzEa,IAAO,IAAIC,EAAA;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AAMP,IAAOC,EAAK,QAAQM,CAAa;AAKvC,MAAI;AACF,IAAAP,EAAK,kBAAA;AAAA,EACP,SAASc,GAAG;AAIV,QAAI,CAHiBd,EAAK,KAAK,OAAO;AAAA,MACpC,CAACe,MAAQA,EAAI,sBAAsBA,EAAI;AAAA,IAAA;AAGvC,YAAM,IAAI;AAAA,QACR,8DAA8DD,CAAC;AAAA,MAAA;AAAA,EAGrE;AAEA,SAAOd,EAAK,mBAAA,EAAqB,MAAA;AACnC;AASO,SAASY,EAAkBI,GAAyB;AACzD,MAAIA,EAAI,WAAW;AACjB,WAAOrB,EAAgB,IAAI,WAAWqB,CAAG,CAAC;AAE5C,QAAIA,EAAI,WAAW,KACX,IAAI;AAAA,IACR,6BAA6BA,EAAI,EAAE,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAAA,IAIhE,IAAI,MAAM,4CAA4CA,EAAI,MAAM,EAAE;AAC1E;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const h=require("@babylonlabs-io/babylon-tbv-rust-wasm"),l=require("buffer"),a=require("bitcoinjs-lib"),i=require("./bitcoin-CHfKAhcI.cjs");async function b(t){const r=i.stripHexPrefix(t.peginTxHex),c=i.stripHexPrefix(t.fundedPrePeginTxHex),n=await h.getPrePeginHtlcConnectorInfo({depositorPubkey:t.depositorPubkey,vaultProviderPubkey:t.vaultProviderPubkey,vaultKeeperPubkeys:t.vaultKeeperPubkeys,universalChallengerPubkeys:t.universalChallengerPubkeys,hashlock:t.hashlock,timelockRefund:t.timelockRefund,network:t.network}),e=a.Transaction.fromHex(r),o=a.Transaction.fromHex(c);if(e.ins.length!==1)throw new Error(`PegIn transaction must have exactly 1 input, got ${e.ins.length}`);const s=e.ins[0],f=o.getId(),g=i.uint8ArrayToHex(new Uint8Array(s.hash).slice().reverse());if(g!==f)throw new Error(`PegIn input does not reference the Pre-PegIn transaction. Expected ${f}, got ${g}`);const p=o.outs[s.index];if(!p)throw new Error(`Pre-PegIn output ${s.index} not found (Pre-PegIn has ${o.outs.length} outputs)`);const d=i.hexToUint8Array(n.hashlockScript),x=i.hexToUint8Array(n.hashlockControlBlock),u=new a.Psbt;u.setVersion(e.version),u.setLocktime(e.locktime),u.addInput({hash:s.hash,index:s.index,sequence:s.sequence,witnessUtxo:{script:p.script,value:p.value},tapLeafScript:[{leafVersion:i.TAPSCRIPT_LEAF_VERSION,script:l.Buffer.from(d),controlBlock:l.Buffer.from(x)}],tapInternalKey:l.Buffer.from(h.tapInternalPubkey)});for(const P of e.outs)u.addOutput({script:P.script,value:P.value});return{psbtHex:u.toHex()}}function S(t,r){const n=a.Psbt.fromHex(t).data.inputs[0];if(!n)throw new Error("PegIn PSBT has no inputs");if(n.tapScriptSig&&n.tapScriptSig.length>0){const e=l.Buffer.from(i.hexToUint8Array(r));for(const o of n.tapScriptSig)if(o.pubkey.equals(e))return y(o.signature);throw new Error(`No PegIn input signature found for depositor pubkey: ${r}`)}throw n.finalScriptWitness&&n.finalScriptWitness.length>0?new Error("PegIn input PSBT is already finalized. Cannot reliably extract the depositor signature from the witness stack. Ensure the wallet returns a non-finalized PSBT with tapScriptSig entries."):new Error("No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT")}function w(t){const r=a.Psbt.fromHex(t);try{r.finalizeAllInputs()}catch(c){if(!r.data.inputs.every(e=>e.finalScriptWitness||e.finalScriptSig))throw new Error(`PSBT finalization failed and wallet did not auto-finalize: ${c}`)}return r.extractTransaction().toHex()}function y(t){if(t.length===64)return i.uint8ArrayToHex(new Uint8Array(t));throw t.length===65?new Error(`Unexpected sighash byte 0x${t[64].toString(16).padStart(2,"0")} in PegIn input signature. Expected implicit SIGHASH_DEFAULT as a 64-byte signature.`):new Error(`Unexpected PegIn input signature length: ${t.length}`)}exports.buildPeginInputPsbt=b;exports.extractPeginInputSignature=S;exports.finalizePeginInputPsbt=w;
2
+ //# sourceMappingURL=peginInput-DH6X4ITS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peginInput-DH6X4ITS.cjs","sources":["../src/tbv/core/primitives/psbt/peginInput.ts"],"sourcesContent":["/**\n * PegIn Input PSBT Builder\n *\n * Builds the PSBT for the depositor to sign the PegIn transaction's HTLC input\n * (Pre-PegIn HTLC leaf 0 — the hashlock + all-party script).\n *\n * This is the \"Sign Pegin transaction HTLC leaf 0 input\" step in the pre-pegin\n * flow. The depositor signs input 0 of the PegIn transaction,\n * which spends output 0 of the funded Pre-PegIn transaction via script-path.\n *\n * @module primitives/psbt/peginInput\n */\n\nimport {\n getPrePeginHtlcConnectorInfo,\n tapInternalPubkey,\n type Network,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\nimport { Buffer } from \"buffer\";\nimport { Psbt, Transaction } from \"bitcoinjs-lib\";\nimport { TAPSCRIPT_LEAF_VERSION, hexToUint8Array, stripHexPrefix, uint8ArrayToHex } from \"../utils/bitcoin\";\n\n/**\n * Parameters for building the PegIn input PSBT\n */\nexport interface BuildPeginInputPsbtParams {\n /**\n * PegIn transaction hex (1 input spending Pre-PegIn HTLC output 0).\n * Returned by buildPeginTxFromFundedPrePegin().\n */\n peginTxHex: string;\n /**\n * Funded Pre-PegIn transaction hex.\n * Used to look up the HTLC output that the PegIn input spends.\n */\n fundedPrePeginTxHex: string;\n /** Depositor's BTC public key (x-only, 64-char hex) */\n depositorPubkey: string;\n /** Vault provider's BTC public key (x-only, 64-char hex) */\n vaultProviderPubkey: string;\n /** Vault keeper BTC public keys (x-only, 64-char hex) */\n vaultKeeperPubkeys: string[];\n /** Universal challenger BTC public keys (x-only, 64-char hex) */\n universalChallengerPubkeys: string[];\n /** SHA256 hash commitment (64 hex chars = 32 bytes) */\n hashlock: string;\n /** CSV timelock in blocks for the HTLC refund path */\n timelockRefund: number;\n /** Bitcoin network */\n network: Network;\n}\n\n/**\n * Result of building the PegIn input PSBT\n */\nexport interface BuildPeginInputPsbtResult {\n /** PSBT hex for the depositor to sign */\n psbtHex: string;\n}\n\n/**\n * Build PSBT for depositor to sign the PegIn transaction's HTLC leaf 0 input.\n *\n * The PegIn transaction spends the Pre-PegIn HTLC output (output 0) via the\n * hashlock + all-party script (leaf 0). The depositor provides one of the required\n * signatures; the vault provider and keepers provide theirs separately via the\n * signPeginInput RPC.\n *\n * The PSBT uses Taproot script-path spending:\n * - witnessUtxo: the Pre-PegIn HTLC output\n * - tapLeafScript: hashlock leaf script + control block\n * - tapInternalKey: NUMS unspendable key (BIP-341 nothing-up-my-sleeve)\n *\n * @param params - PegIn input PSBT parameters\n * @returns PSBT hex ready for depositor signing\n * @throws If PegIn tx does not have exactly 1 input\n * @throws If PegIn input does not reference the Pre-PegIn HTLC output\n * @throws If Pre-PegIn tx output 0 is not found\n */\nexport async function buildPeginInputPsbt(\n params: BuildPeginInputPsbtParams,\n): Promise<BuildPeginInputPsbtResult> {\n const peginTxHex = stripHexPrefix(params.peginTxHex);\n const fundedPrePeginTxHex = stripHexPrefix(params.fundedPrePeginTxHex);\n\n const htlcConnector = await getPrePeginHtlcConnectorInfo({\n depositorPubkey: params.depositorPubkey,\n vaultProviderPubkey: params.vaultProviderPubkey,\n vaultKeeperPubkeys: params.vaultKeeperPubkeys,\n universalChallengerPubkeys: params.universalChallengerPubkeys,\n hashlock: params.hashlock,\n timelockRefund: params.timelockRefund,\n network: params.network,\n });\n\n const peginTx = Transaction.fromHex(peginTxHex);\n const prePeginTx = Transaction.fromHex(fundedPrePeginTxHex);\n\n if (peginTx.ins.length !== 1) {\n throw new Error(\n `PegIn transaction must have exactly 1 input, got ${peginTx.ins.length}`,\n );\n }\n\n const peginInput = peginTx.ins[0];\n\n // Verify PegIn input 0 spends Pre-PegIn output 0\n const prePeginTxid = prePeginTx.getId();\n const peginInputTxid = uint8ArrayToHex(\n new Uint8Array(peginInput.hash).slice().reverse(),\n );\n\n if (peginInputTxid !== prePeginTxid) {\n throw new Error(\n `PegIn input does not reference the Pre-PegIn transaction. ` +\n `Expected ${prePeginTxid}, got ${peginInputTxid}`,\n );\n }\n\n const htlcOutput = prePeginTx.outs[peginInput.index];\n if (!htlcOutput) {\n throw new Error(\n `Pre-PegIn output ${peginInput.index} not found ` +\n `(Pre-PegIn has ${prePeginTx.outs.length} outputs)`,\n );\n }\n\n const hashlockScript = hexToUint8Array(htlcConnector.hashlockScript);\n const hashlockControlBlock = hexToUint8Array(htlcConnector.hashlockControlBlock);\n\n const psbt = new Psbt();\n psbt.setVersion(peginTx.version);\n psbt.setLocktime(peginTx.locktime);\n\n // Input 0: PegIn input spending Pre-PegIn HTLC output 0 via hashlock leaf (leaf 0).\n // The depositor signs using Taproot script-path spending.\n psbt.addInput({\n hash: peginInput.hash,\n index: peginInput.index,\n sequence: peginInput.sequence,\n witnessUtxo: {\n script: htlcOutput.script,\n value: htlcOutput.value,\n },\n tapLeafScript: [\n {\n leafVersion: TAPSCRIPT_LEAF_VERSION,\n script: Buffer.from(hashlockScript),\n controlBlock: Buffer.from(hashlockControlBlock),\n },\n ],\n tapInternalKey: Buffer.from(tapInternalPubkey),\n // sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot\n });\n\n for (const output of peginTx.outs) {\n psbt.addOutput({\n script: output.script,\n value: output.value,\n });\n }\n\n return { psbtHex: psbt.toHex() };\n}\n\n/**\n * Extract the depositor's Schnorr signature from a signed PegIn input PSBT.\n *\n * Supports non-finalized PSBTs with tapScriptSig entries. Finalized PSBTs are\n * rejected because the witness stack does not reliably identify the depositor\n * signature by public key.\n *\n * PegIn input signatures must use implicit Taproot SIGHASH_DEFAULT, which is\n * encoded by omitting the sighash byte. Signatures with an appended sighash byte\n * are rejected rather than stripped.\n *\n * @param signedPsbtHex - Signed PSBT hex\n * @param depositorPubkey - Depositor's x-only public key (64-char hex)\n * @returns 64-byte Schnorr signature (128 hex chars, no sighash flag)\n * @throws If no signature is found for the depositor's key\n */\nexport function extractPeginInputSignature(\n signedPsbtHex: string,\n depositorPubkey: string,\n): string {\n const signedPsbt = Psbt.fromHex(signedPsbtHex);\n const input = signedPsbt.data.inputs[0];\n\n if (!input) {\n throw new Error(\"PegIn PSBT has no inputs\");\n }\n\n // Non-finalized PSBT — extract from tapScriptSig\n if (input.tapScriptSig && input.tapScriptSig.length > 0) {\n const depositorPubkeyBytes = Buffer.from(\n hexToUint8Array(depositorPubkey),\n );\n\n for (const sigEntry of input.tapScriptSig) {\n if (sigEntry.pubkey.equals(depositorPubkeyBytes)) {\n return extractSchnorrSig(sigEntry.signature);\n }\n }\n\n throw new Error(\n `No PegIn input signature found for depositor pubkey: ${depositorPubkey}`,\n );\n }\n\n // Finalized PSBT — the witness stack order depends on the wallet's finalizer,\n // so we cannot reliably pick the depositor's signature by position. Require\n // the non-finalized tapScriptSig path which identifies signatures by pubkey.\n if (input.finalScriptWitness && input.finalScriptWitness.length > 0) {\n throw new Error(\n \"PegIn input PSBT is already finalized. Cannot reliably extract the \" +\n \"depositor signature from the witness stack. Ensure the wallet returns \" +\n \"a non-finalized PSBT with tapScriptSig entries.\",\n );\n }\n\n throw new Error(\n \"No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT\",\n );\n}\n\n/**\n * Finalize a signed PegIn input PSBT and return the depositor-signed transaction hex.\n *\n * The default tapscript finalizer builds the full witness stack [sig, script, controlBlock]\n * that vaultd requires when verifying the depositor signature on-chain.\n *\n * @param signedPsbtHex - Non-finalized signed PSBT hex (returned by wallet with autoFinalized: false)\n * @returns Depositor-signed PegIn transaction hex with full taproot witness stack\n */\nexport function finalizePeginInputPsbt(signedPsbtHex: string): string {\n const psbt = Psbt.fromHex(signedPsbtHex);\n\n // Some wallets (UniSat, OKX) ignore autoFinalized: false and return\n // already-finalized PSBTs. finalizeAllInputs() throws in that case,\n // so fall back to verifying the wallet already finalized all inputs.\n try {\n psbt.finalizeAllInputs();\n } catch (e) {\n const allFinalized = psbt.data.inputs.every(\n (inp) => inp.finalScriptWitness || inp.finalScriptSig,\n );\n if (!allFinalized) {\n throw new Error(\n `PSBT finalization failed and wallet did not auto-finalize: ${e}`,\n );\n }\n }\n\n return psbt.extractTransaction().toHex();\n}\n\n/**\n * Extract and validate a 64-byte Schnorr signature.\n * PegIn input signatures must use implicit Taproot SIGHASH_DEFAULT, which is\n * encoded by omitting the sighash byte. Reject 65-byte signatures instead of\n * stripping the sighash byte because it changes the signed Taproot message.\n * @internal\n */\nexport function extractSchnorrSig(sig: Uint8Array): string {\n if (sig.length === 64) {\n return uint8ArrayToHex(new Uint8Array(sig));\n }\n if (sig.length === 65) {\n throw new Error(\n `Unexpected sighash byte 0x${sig[64].toString(16).padStart(2, \"0\")} in PegIn input signature. ` +\n \"Expected implicit SIGHASH_DEFAULT as a 64-byte signature.\",\n );\n }\n throw new Error(`Unexpected PegIn input signature length: ${sig.length}`);\n}\n"],"names":["buildPeginInputPsbt","params","peginTxHex","stripHexPrefix","fundedPrePeginTxHex","htlcConnector","getPrePeginHtlcConnectorInfo","peginTx","Transaction","prePeginTx","peginInput","prePeginTxid","peginInputTxid","uint8ArrayToHex","htlcOutput","hashlockScript","hexToUint8Array","hashlockControlBlock","psbt","Psbt","TAPSCRIPT_LEAF_VERSION","Buffer","tapInternalPubkey","output","extractPeginInputSignature","signedPsbtHex","depositorPubkey","input","depositorPubkeyBytes","sigEntry","extractSchnorrSig","finalizePeginInputPsbt","e","inp","sig"],"mappings":"yJA+EA,eAAsBA,EACpBC,EACoC,CACpC,MAAMC,EAAaC,EAAAA,eAAeF,EAAO,UAAU,EAC7CG,EAAsBD,EAAAA,eAAeF,EAAO,mBAAmB,EAE/DI,EAAgB,MAAMC,+BAA6B,CACvD,gBAAiBL,EAAO,gBACxB,oBAAqBA,EAAO,oBAC5B,mBAAoBA,EAAO,mBAC3B,2BAA4BA,EAAO,2BACnC,SAAUA,EAAO,SACjB,eAAgBA,EAAO,eACvB,QAASA,EAAO,OAAA,CACjB,EAEKM,EAAUC,EAAAA,YAAY,QAAQN,CAAU,EACxCO,EAAaD,EAAAA,YAAY,QAAQJ,CAAmB,EAE1D,GAAIG,EAAQ,IAAI,SAAW,EACzB,MA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,EAI5C,GAAIA,EAAM,cAAgBA,EAAM,aAAa,OAAS,EAAG,CACvD,MAAMC,EAAuBP,EAAAA,OAAO,KAClCL,EAAAA,gBAAgBU,CAAe,CAAA,EAGjC,UAAWG,KAAYF,EAAM,aAC3B,GAAIE,EAAS,OAAO,OAAOD,CAAoB,EAC7C,OAAOE,EAAkBD,EAAS,SAAS,EAI/C,MAAM,IAAI,MACR,wDAAwDH,CAAe,EAAA,CAE3E,CAKA,MAAIC,EAAM,oBAAsBA,EAAM,mBAAmB,OAAS,EAC1D,IAAI,MACR,0LAAA,EAME,IAAI,MACR,wEAAA,CAEJ,CAWO,SAASI,EAAuBN,EAA+B,CACpE,MAAMP,EAAOC,EAAAA,KAAK,QAAQM,CAAa,EAKvC,GAAI,CACFP,EAAK,kBAAA,CACP,OAASc,EAAG,CAIV,GAAI,CAHiBd,EAAK,KAAK,OAAO,MACnCe,GAAQA,EAAI,oBAAsBA,EAAI,cAAA,EAGvC,MAAM,IAAI,MACR,8DAA8DD,CAAC,EAAA,CAGrE,CAEA,OAAOd,EAAK,mBAAA,EAAqB,MAAA,CACnC,CASO,SAASY,EAAkBI,EAAyB,CACzD,GAAIA,EAAI,SAAW,GACjB,OAAOrB,kBAAgB,IAAI,WAAWqB,CAAG,CAAC,EAE5C,MAAIA,EAAI,SAAW,GACX,IAAI,MACR,6BAA6BA,EAAI,EAAE,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,sFAAA,EAIhE,IAAI,MAAM,4CAA4CA,EAAI,MAAM,EAAE,CAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-params-reader.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/clients/eth/protocol-params-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAO,OAAO,EAAO,YAAY,EAAE,MAAM,MAAM,CAAC;AAS5D,OAAO,KAAK,EACV,qBAAqB,EACrB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAuFjB;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IAEjE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;gBADf,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,OAAO;IAG5B,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAYlD,uBAAuB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAY3D,0BAA0B,CAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IAa7B,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC;IAWjD,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKjE;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA2C1D;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,gBAAgB,CAAC,EAAE,8BAA8B,GAChD,OAAO,CAAC,qBAAqB,CAAC;CAqClC"}
1
+ {"version":3,"file":"protocol-params-reader.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/clients/eth/protocol-params-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAO,OAAO,EAAO,YAAY,EAAE,MAAM,MAAM,CAAC;AAS5D,OAAO,KAAK,EACV,qBAAqB,EACrB,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAyFjB;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IAEjE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;gBADf,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,OAAO;IAG5B,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAYlD,uBAAuB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAY3D,0BAA0B,CAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IAa7B,8BAA8B,IAAI,OAAO,CAAC,MAAM,CAAC;IAWjD,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKjE;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA4C1D;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,gBAAgB,CAAC,EAAE,8BAA8B,GAChD,OAAO,CAAC,qBAAqB,CAAC;CAqClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-params-validation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/clients/eth/protocol-params-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAiBjB;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAUtE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAqG5E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAwCzE;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAa3E"}
1
+ {"version":3,"file":"protocol-params-validation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/clients/eth/protocol-params-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAiBjB;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAUtE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAqG5E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAiDzE;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAa3E"}