@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,137 @@
1
+ import { Buffer } from 'buffer';
2
+ /**
3
+ * Tapscript leaf version as defined in BIP-341.
4
+ *
5
+ * The value 0xc0 (binary: 11000000) represents:
6
+ * - Bit 0: Parity bit for output key y-coordinate
7
+ * - Bits 1-7: Leaf version (0xc0 >> 1 = 0x60)
8
+ *
9
+ * This is the standard leaf version for Tapscript execution.
10
+ *
11
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
12
+ * @see Rust: bitcoin::taproot::LeafVersion::TapScript
13
+ */
14
+ export declare const TAPSCRIPT_LEAF_VERSION = 192;
15
+ /**
16
+ * Maximum sequence value (no relative timelock).
17
+ *
18
+ * When set to 0xffffffff, BIP-68 relative timelocks are disabled.
19
+ * This is equivalent to Bitcoin's Sequence::MAX.
20
+ *
21
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
22
+ * @see Rust: bitcoin::Sequence::MAX
23
+ */
24
+ export declare const SEQUENCE_MAX = 4294967295;
25
+ /**
26
+ * P2WPKH script prefix (OP_0 + 20-byte push).
27
+ *
28
+ * Format: 0x00 (witness version 0) + 0x14 (20 bytes)
29
+ *
30
+ * @see BIP-141: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
31
+ */
32
+ export declare const P2WPKH_PREFIX = "0014";
33
+ /**
34
+ * P2TR script prefix (OP_1 + 32-byte push).
35
+ *
36
+ * Format: 0x51 (witness version 1 / OP_1) + 0x20 (32 bytes)
37
+ *
38
+ * @see BIP-341: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
39
+ */
40
+ export declare const P2TR_PREFIX = "5120";
41
+ /**
42
+ * All-zeros transaction ID (null/invalid reference).
43
+ *
44
+ * Used in tests to create dummy inputs that don't reference real transactions.
45
+ * Equivalent to Txid::all_zeros() in Rust.
46
+ *
47
+ * @see Rust: bitcoin::Txid::all_zeros()
48
+ */
49
+ export declare const NULL_TXID: Buffer<ArrayBuffer>;
50
+ /**
51
+ * Dummy transaction ID (filled with 0x01).
52
+ *
53
+ * Used to create distinct dummy transactions for claim outputs.
54
+ */
55
+ export declare const DUMMY_TXID_1: Buffer<ArrayBuffer>;
56
+ /**
57
+ * Dummy transaction ID (filled with 0x02).
58
+ *
59
+ * Used to create distinct dummy transactions for assert outputs.
60
+ */
61
+ export declare const DUMMY_TXID_2: Buffer<ArrayBuffer>;
62
+ /**
63
+ * All-ones transaction ID (invalid reference).
64
+ *
65
+ * Used in error handling tests to verify behavior with invalid txids.
66
+ */
67
+ export declare const INVALID_TXID: Buffer<ArrayBuffer>;
68
+ /**
69
+ * Test pegin amount: 100,000 satoshis (0.001 BTC).
70
+ *
71
+ * Represents the vault output value from a peg-in transaction.
72
+ * This is the amount locked in the vault that the depositor can later claim.
73
+ *
74
+ * Equivalent to Rust test constant in pegin_claim_graph.rs.
75
+ */
76
+ export declare const TEST_PEGIN_VALUE = 100000n;
77
+ /**
78
+ * Test claim output value: 50,000 satoshis (0.0005 BTC).
79
+ *
80
+ * Represents a claim transaction output that can be spent in payout.
81
+ * In production, claim transactions have 2 outputs for different spending paths.
82
+ */
83
+ export declare const TEST_CLAIM_VALUE = 50000n;
84
+ /**
85
+ * Test payout output value: 95,000 satoshis (0.00095 BTC).
86
+ *
87
+ * Calculated as: TEST_PEGIN_VALUE - 5,000 sats fee
88
+ * Represents the amount sent to recipient after deducting transaction fees.
89
+ */
90
+ export declare const TEST_PAYOUT_VALUE = 95000n;
91
+ /**
92
+ * Combined payout value with claim inputs: 145,000 satoshis (0.00145 BTC).
93
+ *
94
+ * Calculated as: TEST_PEGIN_VALUE + TEST_CLAIM_VALUE - 5,000 sats fee
95
+ * Used when payout transaction spends both pegin and claim outputs.
96
+ */
97
+ export declare const TEST_COMBINED_VALUE = 145000n;
98
+ /**
99
+ * Witness UTXO value for tests: 100,000 satoshis.
100
+ *
101
+ * Standard test value used for witnessUtxo in PSBT inputs.
102
+ */
103
+ export declare const TEST_WITNESS_UTXO_VALUE = 100000;
104
+ /**
105
+ * Output value after fees: 95,000 satoshis.
106
+ *
107
+ * Standard test value for PSBT outputs.
108
+ */
109
+ export declare const TEST_OUTPUT_VALUE = 95000;
110
+ /**
111
+ * Creates a dummy P2WPKH scriptPubKey for testing.
112
+ *
113
+ * Format: OP_0 <20-byte-hash>
114
+ * The hash is filled with a repeating character for easy identification in tests.
115
+ *
116
+ * @param fillByte - Hex character to repeat (0-f), defaults to "0"
117
+ * @returns P2WPKH scriptPubKey buffer
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * createDummyP2WPKH("0"); // 0x0014 + "0".repeat(40)
122
+ * createDummyP2WPKH("a"); // 0x0014 + "a".repeat(40)
123
+ * createDummyP2WPKH("f"); // 0x0014 + "f".repeat(40)
124
+ * ```
125
+ */
126
+ export declare function createDummyP2WPKH(fillByte?: string): Buffer;
127
+ /**
128
+ * Creates a dummy P2TR scriptPubKey using secp256k1 generator point.
129
+ *
130
+ * Format: OP_1 <32-byte-x-only-pubkey>
131
+ *
132
+ * @returns P2TR scriptPubKey buffer with generator point
133
+ *
134
+ * @see secp256k1 specification: https://en.bitcoin.it/wiki/Secp256k1
135
+ */
136
+ export declare function createDummyP2TR(): Buffer;
137
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,MAAO,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,SAAS,CAAC;AAIlC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,qBAAsB,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,YAAY,qBAAsB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,YAAY,qBAAsB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,YAAY,qBAAyB,CAAC;AAInD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,UAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SAAU,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,UAAW,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAIxC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,GAAE,MAAY,GAAG,MAAM,CAMhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAQxC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Test helpers and constants for PSBT primitive tests
3
+ *
4
+ * This module provides deterministic test keys and utilities for testing
5
+ * peg-in PSBT functionality. The keys are derived from simple secret keys
6
+ * to ensure reproducible test results.
7
+ *
8
+ * @module primitives/psbt/__tests__/helpers
9
+ */
10
+ /**
11
+ * Test public key constants derived from deterministic secret keys.
12
+ *
13
+ * These are valid secp256k1 x-only public keys (32 bytes, 64 hex chars)
14
+ */
15
+ export declare const TEST_KEYS: {
16
+ readonly DEPOSITOR: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
17
+ /** Vault provider (formerly claimer) */
18
+ readonly VAULT_PROVIDER: "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5";
19
+ /** Vault keeper 1 */
20
+ readonly VAULT_KEEPER_1: "f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9";
21
+ /** Vault keeper 2 */
22
+ readonly VAULT_KEEPER_2: "e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13";
23
+ /** Universal challenger 1 */
24
+ readonly UNIVERSAL_CHALLENGER_1: "2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4";
25
+ /** Universal challenger 2 */
26
+ readonly UNIVERSAL_CHALLENGER_2: "fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556";
27
+ };
28
+ /**
29
+ * Common test amounts used in peg-in scenarios (in satoshis)
30
+ */
31
+ export declare const TEST_AMOUNTS: {
32
+ /** Minimum dust amount (546 sats) */
33
+ readonly DUST: 546n;
34
+ /** Small test amount (1,000 sats) */
35
+ readonly SMALL: 1000n;
36
+ /** Small peg-in amount (50,000 sats) */
37
+ readonly PEGIN_SMALL: 50000n;
38
+ /** Standard peg-in amount (90,000 sats) */
39
+ readonly PEGIN: 90000n;
40
+ /** Medium peg-in amount (0.001 BTC = 100,000 sats) */
41
+ readonly PEGIN_MEDIUM: 100000n;
42
+ /** Large peg-in amount (0.01 BTC = 1,000,000 sats) */
43
+ readonly PEGIN_LARGE: 1000000n;
44
+ /** 1 BTC amount (100,000,000 sats) */
45
+ readonly ONE_BTC: 100000000n;
46
+ /** Maximum Bitcoin supply (21M BTC in sats) */
47
+ readonly MAX: 2100000000000000n;
48
+ };
49
+ /**
50
+ * Initialize WASM module for Node.js testing environment.
51
+ *
52
+ * This function loads the WASM binary from the workspace and initializes it
53
+ * properly for the test environment. It uses require.resolve() to find the
54
+ * WASM file reliably regardless of the workspace structure.
55
+ *
56
+ * **Note:** This should be called once in beforeAll() for each test suite.
57
+ *
58
+ * @returns Promise that resolves when WASM is initialized
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * describe("buildPeginPsbt", () => {
63
+ * beforeAll(async () => {
64
+ * await initializeWasmForTests();
65
+ * });
66
+ * // ... tests
67
+ * });
68
+ * ```
69
+ */
70
+ export declare function initializeWasmForTests(): Promise<void>;
71
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;GAIG;AACH,eAAO,MAAM,SAAS;;IAGpB,wCAAwC;;IAIxC,qBAAqB;;IAIrB,qBAAqB;;IAIrB,6BAA6B;;IAI7B,6BAA6B;;CAGrB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,qCAAqC;;IAGrC,qCAAqC;;IAGrC,wCAAwC;;IAGxC,2CAA2C;;IAG3C,sDAAsD;;IAGtD,sDAAsD;;IAGtD,sCAAsC;;IAGtC,+CAA+C;;CAEvC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAyB5D"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tests for buildPayoutPsbt and extractPayoutSignature primitive functions
3
+ *
4
+ * These tests verify the PSBT building and signature extraction logic for payout
5
+ * transactions in the Babylon vault protocol.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=payout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/payout.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for buildPeginPsbt primitive function
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=pegin.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pegin.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/psbt/__tests__/pegin.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,27 @@
1
+ import { ChallengeAssertConnectorParams } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for building a ChallengeAssert PSBT
4
+ */
5
+ export interface ChallengeAssertParams {
6
+ /** ChallengeAssert transaction hex (unsigned) from VP */
7
+ challengeAssertTxHex: string;
8
+ /** Prevouts for all inputs [{script_pubkey, value}] from VP (flat, one per input) */
9
+ prevouts: Array<{
10
+ script_pubkey: string;
11
+ value: number;
12
+ }>;
13
+ /** Per-input connector params (one per input/segment, determines the taproot script) */
14
+ connectorParamsPerInput: ChallengeAssertConnectorParams[];
15
+ }
16
+ /**
17
+ * Build unsigned ChallengeAssert PSBT.
18
+ *
19
+ * The ChallengeAssert transaction has 3 inputs (one per Assert output segment).
20
+ * Each input has its own taproot script derived from its connector params.
21
+ * The depositor signs all inputs.
22
+ *
23
+ * @param params - ChallengeAssert parameters
24
+ * @returns Unsigned PSBT hex ready for signing
25
+ */
26
+ export declare function buildChallengeAssertPsbt(params: ChallengeAssertParams): Promise<string>;
27
+ //# sourceMappingURL=challengeAssert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"challengeAssert.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/challengeAssert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,8BAA8B,EAGpC,MAAM,uCAAuC,CAAC;AAS/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,EAAE,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,wFAAwF;IACxF,uBAAuB,EAAE,8BAA8B,EAAE,CAAC;CAC3D;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA4DjB"}
@@ -0,0 +1,27 @@
1
+ import { PayoutConnectorParams } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for building a depositor Payout PSBT
4
+ */
5
+ export interface DepositorPayoutParams {
6
+ /** Payout transaction hex (unsigned) from VP */
7
+ payoutTxHex: string;
8
+ /** Prevouts for all inputs [{script_pubkey, value}] from VP */
9
+ prevouts: Array<{
10
+ script_pubkey: string;
11
+ value: number;
12
+ }>;
13
+ /** Parameters for the PeginPayout connector (depositor, VP, VKs, UCs, timelock) */
14
+ connectorParams: PayoutConnectorParams;
15
+ }
16
+ /**
17
+ * Build unsigned depositor Payout PSBT.
18
+ *
19
+ * The depositor's payout transaction has 2 inputs:
20
+ * - Input 0: PegIn:0 (vault UTXO) — depositor signs using PeginPayoutConnector payout script
21
+ * - Input 1: Assert:0 — NOT signed by depositor
22
+ *
23
+ * @param params - Depositor payout parameters
24
+ * @returns Unsigned PSBT hex ready for signing
25
+ */
26
+ export declare function buildDepositorPayoutPsbt(params: DepositorPayoutParams): Promise<string>;
27
+ //# sourceMappingURL=depositorPayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depositorPayout.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/depositorPayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,uCAAuC,CAAC;AAa/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,EAAE,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,mFAAmF;IACnF,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAwDjB"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * PSBT Builder Primitives
3
+ *
4
+ * Pure functions for building unsigned PSBTs for vault operations.
5
+ * These functions wrap the WASM implementation with a clean TypeScript API.
6
+ *
7
+ * Exports:
8
+ * - {@link buildPeginPsbt} - Create unfunded peg-in transaction
9
+ * - {@link buildPayoutPsbt} - Create payout PSBT for signing
10
+ * - {@link extractPayoutSignature} - Extract Schnorr signature from signed PSBT
11
+ * - {@link buildDepositorPayoutPsbt} - Create depositor's own Payout PSBT (depositor-as-claimer path)
12
+ * - {@link buildNoPayoutPsbt} - Create NoPayout PSBT per challenger (depositor-as-claimer path)
13
+ * - {@link buildChallengeAssertPsbt} - Create ChallengeAssert PSBT per challenger (depositor-as-claimer path)
14
+ *
15
+ * @module primitives/psbt
16
+ */
17
+ export { buildPeginPsbt } from './pegin';
18
+ export type { PeginParams, PeginPsbtResult } from './pegin';
19
+ export { buildPayoutPsbt, extractPayoutSignature } from './payout';
20
+ export type { PayoutParams, PayoutPsbtResult } from './payout';
21
+ export { buildDepositorPayoutPsbt } from './depositorPayout';
22
+ export type { DepositorPayoutParams } from './depositorPayout';
23
+ export { buildNoPayoutPsbt } from './noPayout';
24
+ export type { NoPayoutParams } from './noPayout';
25
+ export { buildChallengeAssertPsbt } from './challengeAssert';
26
+ export type { ChallengeAssertParams } from './challengeAssert';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { AssertPayoutNoPayoutConnectorParams } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for building a NoPayout PSBT
4
+ */
5
+ export interface NoPayoutParams {
6
+ /** NoPayout transaction hex (unsigned) from VP */
7
+ noPayoutTxHex: string;
8
+ /** Challenger's x-only public key (hex encoded) */
9
+ challengerPubkey: string;
10
+ /** Prevouts for all inputs [{script_pubkey, value}] from VP */
11
+ prevouts: Array<{
12
+ script_pubkey: string;
13
+ value: number;
14
+ }>;
15
+ /** Parameters for the Assert Payout/NoPayout connector */
16
+ connectorParams: AssertPayoutNoPayoutConnectorParams;
17
+ }
18
+ /**
19
+ * Build unsigned NoPayout PSBT.
20
+ *
21
+ * The NoPayout transaction is specific to each challenger.
22
+ * Input 0 is the one the depositor signs using the NoPayout taproot script path.
23
+ *
24
+ * @param params - NoPayout parameters
25
+ * @returns Unsigned PSBT hex ready for signing
26
+ */
27
+ export declare function buildNoPayoutPsbt(params: NoPayoutParams): Promise<string>;
28
+ //# sourceMappingURL=noPayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noPayout.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/noPayout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,mCAAmC,EAGzC,MAAM,uCAAuC,CAAC;AAS/C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,EAAE,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,0DAA0D;IAC1D,eAAe,EAAE,mCAAmC,CAAC;CACtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CA6DjB"}
@@ -0,0 +1,99 @@
1
+ import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for building an unsigned Payout PSBT
4
+ *
5
+ * Payout is used in the challenge path after Assert, when the claimer proves validity.
6
+ * Input 1 references the Assert transaction.
7
+ */
8
+ export interface PayoutParams {
9
+ /**
10
+ * Payout transaction hex (unsigned)
11
+ * This is the transaction that needs to be signed by the depositor
12
+ */
13
+ payoutTxHex: string;
14
+ /**
15
+ * Assert transaction hex
16
+ * Payout input 1 references Assert output 0
17
+ */
18
+ assertTxHex: string;
19
+ /**
20
+ * Peg-in transaction hex
21
+ * This transaction created the vault output that we're spending
22
+ */
23
+ peginTxHex: string;
24
+ /**
25
+ * Depositor's BTC public key (x-only, 64-char hex without 0x prefix)
26
+ */
27
+ depositorBtcPubkey: string;
28
+ /**
29
+ * Vault provider's BTC public key (x-only, 64-char hex)
30
+ */
31
+ vaultProviderBtcPubkey: string;
32
+ /**
33
+ * Vault keeper BTC public keys (x-only, 64-char hex)
34
+ */
35
+ vaultKeeperBtcPubkeys: string[];
36
+ /**
37
+ * Universal challenger BTC public keys (x-only, 64-char hex)
38
+ */
39
+ universalChallengerBtcPubkeys: string[];
40
+ /**
41
+ * CSV timelock in blocks for the PegIn output.
42
+ */
43
+ timelockPegin: number;
44
+ /**
45
+ * Bitcoin network
46
+ */
47
+ network: Network;
48
+ }
49
+ /**
50
+ * Result of building an unsigned payout PSBT
51
+ */
52
+ export interface PayoutPsbtResult {
53
+ /**
54
+ * Unsigned PSBT hex ready for signing
55
+ */
56
+ psbtHex: string;
57
+ }
58
+ /**
59
+ * Build unsigned Payout PSBT for depositor to sign.
60
+ *
61
+ * Payout is used in the **challenge path** when the claimer proves validity:
62
+ * 1. Vault provider submits Claim transaction
63
+ * 2. Challenge is raised during challenge period
64
+ * 3. Claimer submits Assert transaction to prove validity
65
+ * 4. Payout can be executed (references Assert tx)
66
+ *
67
+ * Payout transactions have the following structure:
68
+ * - Input 0: from PeginTx output0 (signed by depositor)
69
+ * - Input 1: from Assert output0 (NOT signed by depositor)
70
+ *
71
+ * @param params - Payout parameters
72
+ * @returns Unsigned PSBT ready for depositor to sign
73
+ *
74
+ * @throws If payout transaction does not have exactly 2 inputs
75
+ * @throws If input 0 does not reference the pegin transaction
76
+ * @throws If input 1 does not reference the assert transaction
77
+ * @throws If previous output is not found for either input
78
+ */
79
+ export declare function buildPayoutPsbt(params: PayoutParams): Promise<PayoutPsbtResult>;
80
+ /**
81
+ * Extract Schnorr signature from signed payout PSBT.
82
+ *
83
+ * This function supports two cases:
84
+ * 1. Non-finalized PSBT: Extracts from tapScriptSig field
85
+ * 2. Finalized PSBT: Extracts from witness data
86
+ *
87
+ * The signature is returned as a 64-byte hex string (128 hex characters)
88
+ * with any sighash flag byte removed if present.
89
+ *
90
+ * @param signedPsbtHex - Signed PSBT hex
91
+ * @param depositorPubkey - Depositor's public key (x-only, 64-char hex)
92
+ * @param inputIndex - Input index to extract signature from (default: 0)
93
+ * @returns 64-byte Schnorr signature (128 hex characters, no sighash flag)
94
+ *
95
+ * @throws If no signature is found in the PSBT
96
+ * @throws If the signature has an unexpected length
97
+ */
98
+ export declare function extractPayoutSignature(signedPsbtHex: string, depositorPubkey: string, inputIndex?: number): string;
99
+ //# sourceMappingURL=payout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/payout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,OAAO,EAEb,MAAM,uCAAuC,CAAC;AAc/C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,6BAA6B,EAAE,MAAM,EAAE,CAAC;IAExC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAqI3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,UAAU,SAAI,GACb,MAAM,CAsCR"}
@@ -0,0 +1,88 @@
1
+ import { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ /**
3
+ * Parameters for building an unsigned peg-in PSBT
4
+ */
5
+ export interface PeginParams {
6
+ /**
7
+ * Depositor's BTC public key (x-only, 64-char hex without 0x prefix)
8
+ */
9
+ depositorPubkey: string;
10
+ /**
11
+ * Vault provider's BTC public key (x-only, 64-char hex)
12
+ */
13
+ vaultProviderPubkey: string;
14
+ /**
15
+ * Array of vault keeper BTC public keys (x-only, 64-char hex)
16
+ */
17
+ vaultKeeperPubkeys: string[];
18
+ /**
19
+ * Array of universal challenger BTC public keys (x-only, 64-char hex)
20
+ */
21
+ universalChallengerPubkeys: string[];
22
+ /**
23
+ * CSV timelock in blocks for the PegIn output
24
+ */
25
+ timelockPegin: number;
26
+ /**
27
+ * Amount to peg in (in satoshis)
28
+ */
29
+ pegInAmount: bigint;
30
+ /**
31
+ * Amount in satoshis for the depositor's claim output
32
+ */
33
+ depositorClaimValue: bigint;
34
+ /**
35
+ * Bitcoin network
36
+ */
37
+ network: Network;
38
+ }
39
+ /**
40
+ * Result of building an unsigned peg-in PSBT
41
+ */
42
+ export interface PeginPsbtResult {
43
+ /**
44
+ * Unsigned transaction hex
45
+ *
46
+ * Note: This is an unfunded transaction with no inputs and one output (the pegin output).
47
+ * The caller is responsible for:
48
+ * - Selecting UTXOs to fund the transaction
49
+ * - Calculating transaction fees
50
+ * - Adding inputs to cover pegInAmount + fees
51
+ * - Adding a change output if needed
52
+ * - Creating and signing the PSBT via wallet
53
+ */
54
+ psbtHex: string;
55
+ /**
56
+ * Transaction ID (will change after adding inputs and signing)
57
+ */
58
+ txid: string;
59
+ /**
60
+ * Vault script pubkey hex
61
+ */
62
+ vaultScriptPubKey: string;
63
+ /**
64
+ * Vault output value (in satoshis)
65
+ */
66
+ vaultValue: bigint;
67
+ }
68
+ /**
69
+ * Build unsigned peg-in PSBT using WASM.
70
+ *
71
+ * This is a pure function that wraps the Rust WASM implementation.
72
+ * It creates an unfunded Bitcoin transaction with no inputs and one output
73
+ * (the peg-in output to the vault address).
74
+ *
75
+ * The returned transaction must be funded by the caller by:
76
+ * 1. Selecting appropriate UTXOs from the wallet
77
+ * 2. Calculating transaction fees based on selected inputs
78
+ * 3. Adding inputs to cover pegInAmount + fees
79
+ * 4. Adding a change output if the input value exceeds pegInAmount + fees
80
+ * 5. Creating a PSBT and signing it via the wallet
81
+ *
82
+ * @param params - Peg-in parameters
83
+ * @returns Unsigned PSBT and transaction details
84
+ *
85
+ * @throws If WASM initialization fails or parameters are invalid
86
+ */
87
+ export declare function buildPeginPsbt(params: PeginParams): Promise<PeginPsbtResult>;
88
+ //# sourceMappingURL=pegin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pegin.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/psbt/pegin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,OAAO,EACb,MAAM,uCAAuC,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,0BAA0B,EAAE,MAAM,EAAE,CAAC;IAErC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,eAAe,CAAC,CAmB1B"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for createPayoutScript primitive function
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=payout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tbv/core/primitives/scripts/__tests__/payout.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Script Primitives
3
+ *
4
+ * Pure functions for generating Bitcoin scripts for vault operations.
5
+ *
6
+ * @module primitives/scripts
7
+ */
8
+ export { createPayoutScript } from './payout';
9
+ export type { PayoutScriptParams, PayoutScriptResult } from './payout';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/primitives/scripts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}