@babylonlabs-io/ts-sdk 0.0.0-semantic-release.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +124 -6
  3. package/dist/MockEthereumWallet-CKQlH2AM.cjs +2 -0
  4. package/dist/MockEthereumWallet-CKQlH2AM.cjs.map +1 -0
  5. package/dist/MockEthereumWallet-ibdry7pZ.js +127 -0
  6. package/dist/MockEthereumWallet-ibdry7pZ.js.map +1 -0
  7. package/dist/PayoutManager-Dg_i_S7w.cjs +2 -0
  8. package/dist/PayoutManager-Dg_i_S7w.cjs.map +1 -0
  9. package/dist/PayoutManager-rMj54HDh.js +1112 -0
  10. package/dist/PayoutManager-rMj54HDh.js.map +1 -0
  11. package/dist/challengeAssert-34HqeVFH.cjs +2 -0
  12. package/dist/challengeAssert-34HqeVFH.cjs.map +1 -0
  13. package/dist/challengeAssert-DVErOd8l.js +423 -0
  14. package/dist/challengeAssert-DVErOd8l.js.map +1 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +62 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/shared/index.cjs +1 -1
  19. package/dist/shared/index.d.ts +3 -1
  20. package/dist/shared/index.d.ts.map +1 -1
  21. package/dist/shared/index.js +5 -1
  22. package/dist/shared/index.js.map +1 -1
  23. package/dist/shared/wallets/__tests__/BitcoinWallet.test.d.ts +2 -0
  24. package/dist/shared/wallets/__tests__/BitcoinWallet.test.d.ts.map +1 -0
  25. package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts +2 -0
  26. package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts.map +1 -0
  27. package/dist/shared/wallets/index.d.ts +4 -0
  28. package/dist/shared/wallets/index.d.ts.map +1 -0
  29. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +106 -0
  30. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -0
  31. package/dist/shared/wallets/interfaces/EthereumWallet.d.ts +6 -0
  32. package/dist/shared/wallets/interfaces/EthereumWallet.d.ts.map +1 -0
  33. package/dist/shared/wallets/interfaces/index.d.ts +4 -0
  34. package/dist/shared/wallets/interfaces/index.d.ts.map +1 -0
  35. package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts +29 -0
  36. package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts.map +1 -0
  37. package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts +51 -0
  38. package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts.map +1 -0
  39. package/dist/shared/wallets/mocks/index.d.ts +5 -0
  40. package/dist/shared/wallets/mocks/index.d.ts.map +1 -0
  41. package/dist/tbv/core/clients/index.d.ts +9 -0
  42. package/dist/tbv/core/clients/index.d.ts.map +1 -0
  43. package/dist/tbv/core/clients/mempool/index.d.ts +11 -0
  44. package/dist/tbv/core/clients/mempool/index.d.ts.map +1 -0
  45. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +94 -0
  46. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -0
  47. package/dist/tbv/core/clients/mempool/types.d.ts +98 -0
  48. package/dist/tbv/core/clients/mempool/types.d.ts.map +1 -0
  49. package/dist/tbv/core/contracts/abis/BTCVaultsManager.abi.d.ts +187 -0
  50. package/dist/tbv/core/contracts/abis/BTCVaultsManager.abi.d.ts.map +1 -0
  51. package/dist/tbv/core/contracts/errors.d.ts +50 -0
  52. package/dist/tbv/core/contracts/errors.d.ts.map +1 -0
  53. package/dist/tbv/core/contracts/index.d.ts +11 -0
  54. package/dist/tbv/core/contracts/index.d.ts.map +1 -0
  55. package/dist/tbv/core/index.cjs +1 -1
  56. package/dist/tbv/core/index.d.ts +17 -1
  57. package/dist/tbv/core/index.d.ts.map +1 -1
  58. package/dist/tbv/core/index.js +59 -1
  59. package/dist/tbv/core/index.js.map +1 -1
  60. package/dist/tbv/core/managers/PayoutManager.d.ts +158 -0
  61. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -0
  62. package/dist/tbv/core/managers/PeginManager.d.ts +327 -0
  63. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -0
  64. package/dist/tbv/core/managers/__tests__/PayoutManager.test.d.ts +8 -0
  65. package/dist/tbv/core/managers/__tests__/PayoutManager.test.d.ts.map +1 -0
  66. package/dist/tbv/core/managers/__tests__/PeginManager.test.d.ts +8 -0
  67. package/dist/tbv/core/managers/__tests__/PeginManager.test.d.ts.map +1 -0
  68. package/dist/tbv/core/managers/index.d.ts +75 -0
  69. package/dist/tbv/core/managers/index.d.ts.map +1 -0
  70. package/dist/tbv/core/primitives/index.cjs +2 -0
  71. package/dist/tbv/core/primitives/index.d.ts +77 -0
  72. package/dist/tbv/core/primitives/index.d.ts.map +1 -0
  73. package/dist/tbv/core/primitives/index.js +21 -0
  74. package/dist/tbv/{integrations/morpho → core/primitives}/index.js.map +1 -1
  75. package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts +137 -0
  76. package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts.map +1 -0
  77. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +71 -0
  78. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -0
  79. package/dist/tbv/core/primitives/psbt/__tests__/payout.test.d.ts +8 -0
  80. package/dist/tbv/core/primitives/psbt/__tests__/payout.test.d.ts.map +1 -0
  81. package/dist/tbv/core/primitives/psbt/__tests__/pegin.test.d.ts +5 -0
  82. package/dist/tbv/core/primitives/psbt/__tests__/pegin.test.d.ts.map +1 -0
  83. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +27 -0
  84. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -0
  85. package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts +27 -0
  86. package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts.map +1 -0
  87. package/dist/tbv/core/primitives/psbt/index.d.ts +27 -0
  88. package/dist/tbv/core/primitives/psbt/index.d.ts.map +1 -0
  89. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +28 -0
  90. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -0
  91. package/dist/tbv/core/primitives/psbt/payout.d.ts +99 -0
  92. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -0
  93. package/dist/tbv/core/primitives/psbt/pegin.d.ts +88 -0
  94. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -0
  95. package/dist/tbv/core/primitives/scripts/__tests__/payout.test.d.ts +5 -0
  96. package/dist/tbv/core/primitives/scripts/__tests__/payout.test.d.ts.map +1 -0
  97. package/dist/tbv/core/primitives/scripts/index.d.ts +10 -0
  98. package/dist/tbv/core/primitives/scripts/index.d.ts.map +1 -0
  99. package/dist/tbv/core/primitives/scripts/payout.d.ts +102 -0
  100. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -0
  101. package/dist/tbv/core/primitives/utils/__tests__/bitcoin.test.d.ts +5 -0
  102. package/dist/tbv/core/primitives/utils/__tests__/bitcoin.test.d.ts.map +1 -0
  103. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +132 -0
  104. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -0
  105. package/dist/tbv/core/primitives/utils/index.d.ts +9 -0
  106. package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -0
  107. package/dist/tbv/core/utils/btc/index.d.ts +10 -0
  108. package/dist/tbv/core/utils/btc/index.d.ts.map +1 -0
  109. package/dist/tbv/core/utils/btc/psbtInputFields.d.ts +41 -0
  110. package/dist/tbv/core/utils/btc/psbtInputFields.d.ts.map +1 -0
  111. package/dist/tbv/core/utils/btc/scriptType.d.ts +34 -0
  112. package/dist/tbv/core/utils/btc/scriptType.d.ts.map +1 -0
  113. package/dist/tbv/core/utils/fee/constants.d.ts +25 -0
  114. package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -0
  115. package/dist/tbv/core/utils/fee/index.d.ts +7 -0
  116. package/dist/tbv/core/utils/fee/index.d.ts.map +1 -0
  117. package/dist/tbv/core/utils/index.d.ts +16 -0
  118. package/dist/tbv/core/utils/index.d.ts.map +1 -0
  119. package/dist/tbv/core/utils/transaction/__tests__/btcTxHash.test.d.ts +5 -0
  120. package/dist/tbv/core/utils/transaction/__tests__/btcTxHash.test.d.ts.map +1 -0
  121. package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts +5 -0
  122. package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts.map +1 -0
  123. package/dist/tbv/core/utils/transaction/__tests__/fundPeginTransaction.test.d.ts +5 -0
  124. package/dist/tbv/core/utils/transaction/__tests__/fundPeginTransaction.test.d.ts.map +1 -0
  125. package/dist/tbv/core/utils/transaction/btcTxHash.d.ts +15 -0
  126. package/dist/tbv/core/utils/transaction/btcTxHash.d.ts.map +1 -0
  127. package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts +106 -0
  128. package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts.map +1 -0
  129. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts +70 -0
  130. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -0
  131. package/dist/tbv/core/utils/transaction/index.d.ts +9 -0
  132. package/dist/tbv/core/utils/transaction/index.d.ts.map +1 -0
  133. package/dist/tbv/core/utils/utxo/__tests__/selectUtxos.test.d.ts +5 -0
  134. package/dist/tbv/core/utils/utxo/__tests__/selectUtxos.test.d.ts.map +1 -0
  135. package/dist/tbv/core/utils/utxo/index.d.ts +7 -0
  136. package/dist/tbv/core/utils/utxo/index.d.ts.map +1 -0
  137. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts +65 -0
  138. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts.map +1 -0
  139. package/dist/tbv/index.cjs +1 -1
  140. package/dist/tbv/index.js +59 -1
  141. package/dist/tbv/index.js.map +1 -1
  142. package/dist/tbv/integrations/aave/clients/__tests__/spoke.test.d.ts +2 -0
  143. package/dist/tbv/integrations/aave/clients/__tests__/spoke.test.d.ts.map +1 -0
  144. package/dist/tbv/integrations/aave/clients/__tests__/transaction.test.d.ts +2 -0
  145. package/dist/tbv/integrations/aave/clients/__tests__/transaction.test.d.ts.map +1 -0
  146. package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationController.abi.json.d.ts +1879 -0
  147. package/dist/tbv/integrations/aave/clients/abis/AaveSpoke.abi.json.d.ts +1262 -0
  148. package/dist/tbv/integrations/aave/clients/index.d.ts +4 -0
  149. package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -0
  150. package/dist/tbv/integrations/aave/clients/query.d.ts +27 -0
  151. package/dist/tbv/integrations/aave/clients/query.d.ts.map +1 -0
  152. package/dist/tbv/integrations/aave/clients/spoke.d.ts +161 -0
  153. package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -0
  154. package/dist/tbv/integrations/aave/clients/transaction.d.ts +110 -0
  155. package/dist/tbv/integrations/aave/clients/transaction.d.ts.map +1 -0
  156. package/dist/tbv/integrations/aave/config.d.ts +7 -0
  157. package/dist/tbv/integrations/aave/config.d.ts.map +1 -0
  158. package/dist/tbv/integrations/aave/constants.d.ts +113 -0
  159. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -0
  160. package/dist/tbv/integrations/aave/index.cjs +2 -0
  161. package/dist/tbv/integrations/aave/index.cjs.map +1 -0
  162. package/dist/tbv/integrations/aave/index.d.ts +53 -0
  163. package/dist/tbv/integrations/aave/index.d.ts.map +1 -0
  164. package/dist/tbv/integrations/aave/index.js +307 -0
  165. package/dist/tbv/integrations/aave/index.js.map +1 -0
  166. package/dist/tbv/integrations/aave/types.d.ts +66 -0
  167. package/dist/tbv/integrations/aave/types.d.ts.map +1 -0
  168. package/dist/tbv/integrations/aave/utils/__tests__/aaveConversions.test.d.ts +5 -0
  169. package/dist/tbv/integrations/aave/utils/__tests__/aaveConversions.test.d.ts.map +1 -0
  170. package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts +5 -0
  171. package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts.map +1 -0
  172. package/dist/tbv/integrations/aave/utils/__tests__/debtUtils.test.d.ts +5 -0
  173. package/dist/tbv/integrations/aave/utils/__tests__/debtUtils.test.d.ts.map +1 -0
  174. package/dist/tbv/integrations/aave/utils/__tests__/healthFactor.test.d.ts +5 -0
  175. package/dist/tbv/integrations/aave/utils/__tests__/healthFactor.test.d.ts.map +1 -0
  176. package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts +2 -0
  177. package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts.map +1 -0
  178. package/dist/tbv/integrations/aave/utils/__tests__/vaultSplit.test.d.ts +5 -0
  179. package/dist/tbv/integrations/aave/utils/__tests__/vaultSplit.test.d.ts.map +1 -0
  180. package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts +24 -0
  181. package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts.map +1 -0
  182. package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts +15 -0
  183. package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts.map +1 -0
  184. package/dist/tbv/integrations/aave/utils/debtUtils.d.ts +14 -0
  185. package/dist/tbv/integrations/aave/utils/debtUtils.d.ts.map +1 -0
  186. package/dist/tbv/integrations/aave/utils/healthFactor.d.ts +108 -0
  187. package/dist/tbv/integrations/aave/utils/healthFactor.d.ts.map +1 -0
  188. package/dist/tbv/integrations/aave/utils/index.d.ts +10 -0
  189. package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -0
  190. package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts +33 -0
  191. package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts.map +1 -0
  192. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts +191 -0
  193. package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts.map +1 -0
  194. package/package.json +37 -7
  195. package/dist/shared/__tests__/example.test.d.ts +0 -6
  196. package/dist/shared/__tests__/example.test.d.ts.map +0 -1
  197. package/dist/tbv/core/__tests__/example.test.d.ts +0 -6
  198. package/dist/tbv/core/__tests__/example.test.d.ts.map +0 -1
  199. package/dist/tbv/integrations/morpho/index.cjs +0 -2
  200. package/dist/tbv/integrations/morpho/index.d.ts +0 -2
  201. package/dist/tbv/integrations/morpho/index.d.ts.map +0 -1
  202. package/dist/tbv/integrations/morpho/index.js +0 -2
  203. /package/dist/tbv/{integrations/morpho → core/primitives}/index.cjs.map +0 -0
@@ -0,0 +1,102 @@
1
+ import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for creating a payout script.
4
+ *
5
+ * These parameters define the participants in a vault and are used to generate
6
+ * the taproot script that controls how funds can be spent from the vault.
7
+ */
8
+ export interface PayoutScriptParams {
9
+ /**
10
+ * Depositor's BTC public key (x-only, 64-char hex without 0x prefix).
11
+ *
12
+ * This is the user depositing BTC into the vault. The depositor must sign
13
+ * payout transactions to authorize fund distribution.
14
+ */
15
+ depositor: string;
16
+ /**
17
+ * Vault provider's BTC public key (x-only, 64-char hex without 0x prefix).
18
+ *
19
+ * The service provider managing vault operations. Also referred to as
20
+ * "claimer" in the WASM layer.
21
+ */
22
+ vaultProvider: string;
23
+ /**
24
+ * Array of vault keeper BTC public keys (x-only, 64-char hex without 0x prefix).
25
+ *
26
+ * Vault keepers participate in vault operations and script spending conditions.
27
+ */
28
+ vaultKeepers: string[];
29
+ /**
30
+ * Array of universal challenger BTC public keys (x-only, 64-char hex without 0x prefix).
31
+ *
32
+ * These parties can challenge the vault under certain conditions.
33
+ */
34
+ universalChallengers: string[];
35
+ /**
36
+ * CSV timelock in blocks for the PegIn output.
37
+ */
38
+ timelockPegin: number;
39
+ /**
40
+ * Bitcoin network for script generation.
41
+ *
42
+ * Must match the network used for all other vault operations to ensure
43
+ * address encoding compatibility.
44
+ */
45
+ network: Network;
46
+ }
47
+ /**
48
+ * Result of creating a payout script.
49
+ *
50
+ * Contains all the taproot-related data needed for constructing and signing
51
+ * payout transactions from the vault.
52
+ */
53
+ export interface PayoutScriptResult {
54
+ /**
55
+ * The payout script hex used in taproot script path spending.
56
+ *
57
+ * This is the raw script bytes that define the spending conditions,
58
+ * encoded as a hexadecimal string. Used when constructing the
59
+ * tapLeafScript for PSBT signing.
60
+ */
61
+ payoutScript: string;
62
+ /**
63
+ * The taproot script hash (leaf hash) for the payout script.
64
+ *
65
+ * This is the tagged hash of the script used in taproot tree construction.
66
+ * Required for computing the control block during script path spending.
67
+ */
68
+ taprootScriptHash: string;
69
+ /**
70
+ * The full scriptPubKey for the vault output address.
71
+ *
72
+ * This is the complete output script (OP_1 <32-byte-key>) that should be
73
+ * used when creating the vault output in a peg-in transaction.
74
+ */
75
+ scriptPubKey: string;
76
+ /**
77
+ * The vault Bitcoin address derived from the script.
78
+ *
79
+ * A human-readable bech32m address (bc1p... for mainnet, tb1p... for testnet/signet)
80
+ * that can be used to receive funds into the vault.
81
+ */
82
+ address: string;
83
+ }
84
+ /**
85
+ * Create payout script and taproot information using WASM.
86
+ *
87
+ * This is a pure function that wraps the Rust WASM implementation.
88
+ * The payout connector generates the necessary taproot scripts and information
89
+ * required for signing payout transactions.
90
+ *
91
+ * @remarks
92
+ * The generated script encodes spending conditions that require signatures from
93
+ * the depositor and vault provider (or liquidators in challenge scenarios).
94
+ * This script is used internally by {@link buildPayoutPsbt}.
95
+ *
96
+ * @param params - Payout script parameters defining vault participants and network
97
+ * @returns Payout script and taproot information for PSBT construction
98
+ *
99
+ * @see {@link buildPayoutPsbt} - Use this for building complete payout PSBTs
100
+ */
101
+ export declare function createPayoutScript(params: PayoutScriptParams): Promise<PayoutScriptResult>;
102
+ //# sourceMappingURL=payout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/scripts/payout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,KAAK,OAAO,EACb,MAAM,uCAAuC,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAmB7B"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for Bitcoin utility functions
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=bitcoin.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/utils/__tests__/bitcoin.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,132 @@
1
+ import { networks } from 'bitcoinjs-lib';
2
+ import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm';
3
+ /**
4
+ * Strip "0x" prefix from hex string if present.
5
+ *
6
+ * Bitcoin expects plain hex (no "0x" prefix), but frontend often uses
7
+ * Ethereum-style "0x"-prefixed hex.
8
+ *
9
+ * @param hex - Hex string with or without "0x" prefix
10
+ * @returns Hex string without "0x" prefix
11
+ */
12
+ export declare function stripHexPrefix(hex: string): string;
13
+ /**
14
+ * Convert hex string to Uint8Array.
15
+ *
16
+ * @param hex - Hex string (with or without 0x prefix)
17
+ * @returns Uint8Array
18
+ * @throws If hex is invalid
19
+ */
20
+ export declare function hexToUint8Array(hex: string): Uint8Array;
21
+ /**
22
+ * Convert Uint8Array to hex string (without 0x prefix).
23
+ *
24
+ * @param bytes - Uint8Array to convert
25
+ * @returns Hex string without 0x prefix
26
+ */
27
+ export declare function uint8ArrayToHex(bytes: Uint8Array): string;
28
+ /**
29
+ * Convert a 33-byte public key to 32-byte x-only format (removes first byte).
30
+ *
31
+ * Used for Taproot/Schnorr signatures which only need the x-coordinate.
32
+ * If the input is already 32 bytes, returns it unchanged.
33
+ *
34
+ * @param pubKey - 33-byte or 32-byte public key
35
+ * @returns 32-byte x-only public key
36
+ */
37
+ export declare function toXOnly(pubKey: Uint8Array): Uint8Array;
38
+ /**
39
+ * Process and convert a public key to x-only format (32 bytes hex).
40
+ *
41
+ * Handles:
42
+ * - 0x prefix removal
43
+ * - Hex character validation
44
+ * - Length validation
45
+ * - Conversion to x-only format
46
+ *
47
+ * Accepts:
48
+ * - 64 hex chars (32 bytes) - already x-only
49
+ * - 66 hex chars (33 bytes) - compressed pubkey
50
+ * - 130 hex chars (65 bytes) - uncompressed pubkey
51
+ *
52
+ * @param publicKeyHex - Public key in hex format (with or without 0x prefix)
53
+ * @returns X-only public key as 32 bytes hex string (without 0x prefix)
54
+ * @throws If public key format is invalid or contains invalid hex characters
55
+ */
56
+ export declare function processPublicKeyToXOnly(publicKeyHex: string): string;
57
+ /**
58
+ * Validate hex string format.
59
+ *
60
+ * Checks that the string contains only valid hexadecimal characters (0-9, a-f, A-F)
61
+ * and has an even length (since each byte is represented by 2 hex characters).
62
+ *
63
+ * @param hex - String to validate (with or without 0x prefix)
64
+ * @returns true if valid hex string
65
+ */
66
+ export declare function isValidHex(hex: string): boolean;
67
+ /**
68
+ * Result of validating a wallet public key against an expected depositor public key.
69
+ */
70
+ export interface WalletPubkeyValidationResult {
71
+ /** Wallet's raw public key (as returned by wallet, may be compressed) */
72
+ walletPubkeyRaw: string;
73
+ /** Wallet's public key in x-only format (32 bytes, 64 hex chars) */
74
+ walletPubkeyXOnly: string;
75
+ /** The validated depositor public key (x-only format) */
76
+ depositorPubkey: string;
77
+ }
78
+ /**
79
+ * Validate that a wallet's public key matches the expected depositor public key.
80
+ *
81
+ * This function:
82
+ * 1. Converts the wallet pubkey to x-only format
83
+ * 2. Uses the expected depositor pubkey if provided, otherwise falls back to wallet pubkey
84
+ * 3. Validates they match (case-insensitive)
85
+ *
86
+ * @param walletPubkeyRaw - Raw public key from wallet (may be compressed 66 chars or x-only 64 chars)
87
+ * @param expectedDepositorPubkey - Expected depositor public key (x-only, optional)
88
+ * @returns Validation result with both pubkey formats
89
+ * @throws If wallet pubkey doesn't match expected depositor pubkey
90
+ */
91
+ export declare function validateWalletPubkey(walletPubkeyRaw: string, expectedDepositorPubkey?: string): WalletPubkeyValidationResult;
92
+ /**
93
+ * Map SDK network type to bitcoinjs-lib Network object.
94
+ *
95
+ * @param network - Network type ("bitcoin", "testnet", "signet", "regtest")
96
+ * @returns bitcoinjs-lib Network object
97
+ */
98
+ export declare function getNetwork(network: Network): networks.Network;
99
+ /**
100
+ * Derive a Taproot (P2TR) address from a public key.
101
+ *
102
+ * @param publicKeyHex - Compressed (66 hex) or x-only (64 hex) public key
103
+ * @param network - Bitcoin network
104
+ * @returns Taproot address (bc1p... / tb1p... / bcrt1p...)
105
+ */
106
+ export declare function deriveTaprootAddress(publicKeyHex: string, network: Network): string;
107
+ /**
108
+ * Derive a Native SegWit (P2WPKH) address from a compressed public key.
109
+ *
110
+ * @param publicKeyHex - Compressed public key (66 hex chars, with or without 0x prefix)
111
+ * @param network - Bitcoin network
112
+ * @returns Native SegWit address (bc1q... / tb1q... / bcrt1q...)
113
+ * @throws If publicKeyHex is not a compressed public key (66 hex chars)
114
+ */
115
+ export declare function deriveNativeSegwitAddress(publicKeyHex: string, network: Network): string;
116
+ /**
117
+ * Validate that a BTC address was derived from the given public key.
118
+ *
119
+ * Derives Taproot (P2TR) and Native SegWit (P2WPKH) addresses from the
120
+ * public key and checks if the provided address matches any of them.
121
+ *
122
+ * When the input is an x-only key (64 hex chars), both possible compressed
123
+ * keys (`02` + x and `03` + x) are tried for Native SegWit derivation,
124
+ * since the y-parity is unknown.
125
+ *
126
+ * @param address - BTC address to validate
127
+ * @param publicKeyHex - Public key from the wallet (x-only 64 or compressed 66 hex chars)
128
+ * @param network - Bitcoin network
129
+ * @returns true if the address matches the public key
130
+ */
131
+ export declare function isAddressFromPublicKey(address: string, publicKeyHex: string, network: Network): boolean;
132
+ //# sourceMappingURL=bitcoin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/utils/bitcoin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAc,QAAQ,EAAY,MAAM,eAAe,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAErE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAUvD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAEtD;AAaD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAuBpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,4BAA4B,CAa9B;AAeD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAY7D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,GACf,MAAM,CAWR;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,GACf,MAAM,CAiBR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAgCT"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility Functions
3
+ *
4
+ * Pure utility functions for Bitcoin operations
5
+ *
6
+ * @module primitives/utils
7
+ */
8
+ export { hexToUint8Array, isValidHex, processPublicKeyToXOnly, stripHexPrefix, toXOnly, uint8ArrayToHex, validateWalletPubkey, type WalletPubkeyValidationResult, } from './bitcoin';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,UAAU,EACV,uBAAuB,EACvB,cAAc,EACd,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,KAAK,4BAA4B,GAClC,MAAM,WAAW,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Bitcoin Utilities
3
+ *
4
+ * Utilities for Bitcoin script detection and PSBT construction.
5
+ *
6
+ * @module utils/btc
7
+ */
8
+ export { BitcoinScriptType, getScriptType } from './scriptType';
9
+ export { getPsbtInputFields, type PsbtInputFields, type UtxoForPsbt, } from './psbtInputFields';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/btc/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Buffer } from 'buffer';
2
+ /**
3
+ * PSBT input fields for supported script types (P2TR, P2WPKH, P2WSH).
4
+ */
5
+ export interface PsbtInputFields {
6
+ witnessUtxo?: {
7
+ script: Buffer;
8
+ value: number;
9
+ };
10
+ witnessScript?: Buffer;
11
+ tapInternalKey?: Buffer;
12
+ }
13
+ /**
14
+ * UTXO information for PSBT construction.
15
+ *
16
+ * Only supports Taproot (P2TR) and native SegWit (P2WPKH, P2WSH) script types.
17
+ */
18
+ export interface UtxoForPsbt {
19
+ /** Transaction ID of the UTXO */
20
+ txid: string;
21
+ /** Output index (vout) of the UTXO */
22
+ vout: number;
23
+ /** Value of the UTXO in satoshis */
24
+ value: number;
25
+ /** ScriptPubKey of the UTXO (hex string) */
26
+ scriptPubKey: string;
27
+ /** Witness script (required for P2WSH) */
28
+ witnessScript?: string;
29
+ }
30
+ /**
31
+ * Get PSBT input fields for a given UTXO based on its script type.
32
+ *
33
+ * Only supports Taproot (P2TR) and native SegWit (P2WPKH, P2WSH) script types.
34
+ *
35
+ * @param utxo - The unspent transaction output to process
36
+ * @param publicKeyNoCoord - The x-only public key (32 bytes) for Taproot signing
37
+ * @returns PSBT input fields object containing the necessary data
38
+ * @throws Error if required input data is missing or unsupported script type
39
+ */
40
+ export declare function getPsbtInputFields(utxo: UtxoForPsbt, publicKeyNoCoord?: Buffer): PsbtInputFields;
41
+ //# sourceMappingURL=psbtInputFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbtInputFields.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/btc/psbtInputFields.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,gBAAgB,CAAC,EAAE,MAAM,GACxB,eAAe,CA8CjB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Bitcoin Script Type Detection
3
+ *
4
+ * Utilities to detect Bitcoin script types for proper PSBT input construction.
5
+ *
6
+ * @module utils/btc/scriptType
7
+ */
8
+ /**
9
+ * Bitcoin script types.
10
+ */
11
+ export declare enum BitcoinScriptType {
12
+ P2PKH = "P2PKH",
13
+ P2SH = "P2SH",
14
+ P2WPKH = "P2WPKH",
15
+ P2WSH = "P2WSH",
16
+ P2TR = "P2TR",
17
+ UNKNOWN = "UNKNOWN"
18
+ }
19
+ /**
20
+ * Detect the type of a Bitcoin script.
21
+ *
22
+ * @param scriptPubKey - The script public key buffer
23
+ * @returns The detected script type
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const scriptType = getScriptType(Buffer.from(scriptPubKeyHex, 'hex'));
28
+ * if (scriptType === BitcoinScriptType.P2TR) {
29
+ * // Handle Taproot input
30
+ * }
31
+ * ```
32
+ */
33
+ export declare function getScriptType(scriptPubKey: Buffer): BitcoinScriptType;
34
+ //# sourceMappingURL=scriptType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scriptType.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/btc/scriptType.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB,CAqDrE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Fee calculation constants for Bitcoin transactions.
3
+ * Based on btc-staking-ts values, adapted for vault peg-in transactions.
4
+ */
5
+ export declare const P2TR_INPUT_SIZE = 58;
6
+ export declare const MAX_NON_LEGACY_OUTPUT_SIZE = 43;
7
+ export declare const TX_BUFFER_SIZE_OVERHEAD = 11;
8
+ export declare const BTC_DUST_SAT = 546;
9
+ /** Pre-computed BigInt dust threshold to avoid repeated conversions in hot paths */
10
+ export declare const DUST_THRESHOLD: bigint;
11
+ export declare const LOW_RATE_ESTIMATION_ACCURACY_BUFFER = 30;
12
+ export declare const WALLET_RELAY_FEE_RATE_THRESHOLD = 2;
13
+ export declare const FEE_SAFETY_MARGIN = 1.1;
14
+ /**
15
+ * Adds a buffer to the transaction fee calculation if the fee rate is low.
16
+ *
17
+ * Some wallets have a relayer fee requirement. If the fee rate is <= 2 sat/vbyte,
18
+ * there's a risk the fee might not be sufficient for transaction relay.
19
+ * We add a buffer to ensure the transaction can be relayed.
20
+ *
21
+ * @param feeRate - Fee rate in satoshis per vbyte
22
+ * @returns Buffer amount in satoshis to add to the transaction fee
23
+ */
24
+ export declare function rateBasedTxBufferFee(feeRate: number): number;
25
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/fee/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,eAAe,KAAK,CAAC;AAGlC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAG1C,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,oFAAoF;AACpF,eAAO,MAAM,cAAc,QAAuB,CAAC;AAGnD,eAAO,MAAM,mCAAmC,KAAK,CAAC;AAGtD,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAGjD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI5D"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Fee calculation utilities and constants
3
+ *
4
+ * @module utils/fee
5
+ */
6
+ export * from './constants';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/fee/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * SDK Level 2 Utilities
3
+ *
4
+ * Transaction building utilities including:
5
+ * - Fee calculation constants
6
+ * - UTXO selection
7
+ * - Transaction funding
8
+ * - Bitcoin script utilities
9
+ *
10
+ * @module utils
11
+ */
12
+ export * from './fee';
13
+ export * from './utxo';
14
+ export * from './transaction';
15
+ export * from './btc';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for calculateBtcTxHash
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=btcTxHash.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btcTxHash.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/utils/transaction/__tests__/btcTxHash.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for UTXO split transaction builder
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=createSplitTransaction.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSplitTransaction.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for transaction funding utilities
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=fundPeginTransaction.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fundPeginTransaction.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/utils/transaction/__tests__/fundPeginTransaction.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,15 @@
1
+ import { Hex } from 'viem';
2
+ /**
3
+ * Calculate Bitcoin transaction hash
4
+ *
5
+ * This matches the contract's BtcUtils.hashBtcTx() implementation:
6
+ * 1. Double SHA256 the transaction bytes
7
+ * 2. Reverse the byte order (Bitcoin convention)
8
+ *
9
+ * The resulting hash is used as the unique vault identifier in the BTCVaultsManager contract.
10
+ *
11
+ * @param txHex - Transaction hex (with or without 0x prefix)
12
+ * @returns The transaction hash as Hex (with 0x prefix)
13
+ */
14
+ export declare function calculateBtcTxHash(txHex: string): Hex;
15
+ //# sourceMappingURL=btcTxHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btcTxHash.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/transaction/btcTxHash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAUrD"}
@@ -0,0 +1,106 @@
1
+ import { Buffer } from 'buffer';
2
+ import { Network } from '../../primitives';
3
+ import { UTXO } from '../utxo/selectUtxos';
4
+ /**
5
+ * Output specification for split transaction.
6
+ */
7
+ export interface SplitOutput {
8
+ /** Amount in satoshis */
9
+ amount: bigint;
10
+ /** Bitcoin address to send to */
11
+ address: string;
12
+ }
13
+ /**
14
+ * Result of creating a split transaction.
15
+ */
16
+ export interface SplitTransactionResult {
17
+ /** Unsigned transaction hex */
18
+ txHex: string;
19
+ /** Transaction ID (deterministic, calculated before signing) */
20
+ txid: string;
21
+ /** Output UTXOs that will be created when transaction is broadcast */
22
+ outputs: Array<{
23
+ /** Transaction ID of this output */
24
+ txid: string;
25
+ /** Output index */
26
+ vout: number;
27
+ /** Amount in satoshis */
28
+ value: number;
29
+ /** Script pubkey hex */
30
+ scriptPubKey: string;
31
+ }>;
32
+ }
33
+ /**
34
+ * Create a UTXO split transaction.
35
+ *
36
+ * This function creates a Bitcoin transaction that takes input UTXOs
37
+ * and splits them into multiple outputs with specified amounts.
38
+ *
39
+ * The transaction is returned unsigned. The caller must:
40
+ * 1. Sign the transaction using a Bitcoin wallet
41
+ * 2. Broadcast it to the Bitcoin network
42
+ * 3. Use the output UTXOs for subsequent peg-in transactions
43
+ *
44
+ * @param inputs - Input UTXOs to split
45
+ * @param outputs - Desired output amounts and addresses
46
+ * @param network - Bitcoin network (mainnet, testnet, signet, regtest)
47
+ * @returns Unsigned transaction hex, txid, and output UTXO references
48
+ * @throws Error if inputs or outputs are empty
49
+ * @throws Error if address decoding fails (invalid address for network)
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const result = createSplitTransaction(
54
+ * [{ txid: "abc...", vout: 0, value: 100000, scriptPubKey: "..." }],
55
+ * [
56
+ * { amount: 50000n, address: "tb1p..." },
57
+ * { amount: 45000n, address: "tb1p..." }
58
+ * ],
59
+ * "testnet"
60
+ * );
61
+ * // result.txHex → unsigned transaction
62
+ * // result.txid → deterministic transaction ID
63
+ * // result.outputs → UTXO references for pegin creation
64
+ * ```
65
+ */
66
+ export declare function createSplitTransaction(inputs: UTXO[], outputs: SplitOutput[], network: Network): SplitTransactionResult;
67
+ /**
68
+ * Create a PSBT for signing a split transaction with Taproot inputs.
69
+ *
70
+ * IMPORTANT: This function assumes ALL inputs are P2TR (Taproot) addresses.
71
+ * It unconditionally adds tapInternalKey for Taproot signing. Using non-P2TR
72
+ * inputs will cause wallet signing failures.
73
+ *
74
+ * This function takes an unsigned split transaction and creates a PSBT
75
+ * that is intended to be signed by a Bitcoin wallet; this function does not
76
+ * perform any signing itself.
77
+ *
78
+ * The PSBT includes:
79
+ * - witnessUtxo: Script and value for each input (required for segwit)
80
+ * - tapInternalKey: Depositor's x-only pubkey (required for P2TR signing)
81
+ *
82
+ * Technical Note:
83
+ * For P2TR (Taproot) inputs, we need the witnessUtxo and tapInternalKey.
84
+ * This is different from legacy inputs which would need the full previous transaction.
85
+ *
86
+ * @param unsignedTxHex - Unsigned transaction hex from createSplitTransaction
87
+ * @param inputs - Input UTXOs with full data for PSBT
88
+ * @param publicKeyNoCoord - Depositor's public key (x-only, 32 bytes) for P2TR signing
89
+ * @returns PSBT hex ready for wallet signing
90
+ * @throws Error if publicKeyNoCoord is not a 32-byte Buffer
91
+ * @throws Error if UTXO count doesn't match transaction inputs
92
+ * @throws Error if any input is not P2TR format
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const psbtHex = createSplitTransactionPsbt(
97
+ * result.txHex,
98
+ * inputUtxos,
99
+ * Buffer.from(depositorPubkeyXOnly, "hex")
100
+ * );
101
+ * // Sign via wallet
102
+ * const signedPsbtHex = await wallet.signPsbt(psbtHex);
103
+ * ```
104
+ */
105
+ export declare function createSplitTransactionPsbt(unsignedTxHex: string, inputs: UTXO[], publicKeyNoCoord: Buffer): string;
106
+ //# sourceMappingURL=createSplitTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSplitTransaction.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/transaction/createSplitTransaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,OAAO,EAAE,KAAK,CAAC;QACb,oCAAoC;QACpC,IAAI,EAAE,MAAM,CAAC;QACb,mBAAmB;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,yBAAyB;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,wBAAwB;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,IAAI,EAAE,EACd,OAAO,EAAE,WAAW,EAAE,EACtB,OAAO,EAAE,OAAO,GACf,sBAAsB,CA8ExB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,IAAI,EAAE,EACd,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAyFR"}