@btc-vision/transaction 1.0.96 → 1.0.99

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 (477) hide show
  1. package/.babelrc +4 -7
  2. package/.prettierrc.json +11 -11
  3. package/CONTRIBUTING.md +71 -71
  4. package/LICENSE.md +62 -62
  5. package/README.md +76 -76
  6. package/browser/_version.d.ts +1 -1
  7. package/browser/bytecode/Compressor.d.ts +0 -1
  8. package/browser/crypto/crypto-browser.d.ts +1 -30
  9. package/browser/crypto/crypto.d.ts +0 -1
  10. package/browser/generators/AddressGenerator.d.ts +0 -1
  11. package/browser/generators/Generator.d.ts +0 -1
  12. package/browser/generators/builders/CalldataGenerator.d.ts +0 -1
  13. package/browser/generators/builders/DeploymentGenerator.d.ts +0 -1
  14. package/browser/generators/builders/MultiSignGenerator.d.ts +0 -1
  15. package/browser/index.js +1 -1
  16. package/browser/keypair/EcKeyPair.d.ts +0 -1
  17. package/browser/keypair/Wallet.d.ts +0 -1
  18. package/browser/signer/TweakedSigner.d.ts +0 -1
  19. package/browser/transaction/browser/BrowserSignerBase.d.ts +0 -1
  20. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +0 -1
  21. package/browser/transaction/builders/DeploymentTransaction.d.ts +0 -1
  22. package/browser/transaction/builders/InteractionTransaction.d.ts +0 -1
  23. package/browser/transaction/builders/MultiSignTransaction.d.ts +0 -1
  24. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +0 -1
  25. package/browser/transaction/builders/TransactionBuilder.d.ts +0 -1
  26. package/browser/transaction/builders/UnwrapSegwitTransaction.d.ts +0 -1
  27. package/browser/transaction/builders/UnwrapTransaction.d.ts +0 -1
  28. package/browser/transaction/builders/WrapTransaction.d.ts +0 -1
  29. package/browser/transaction/interfaces/ITransactionParameters.d.ts +0 -1
  30. package/browser/transaction/interfaces/Tap.d.ts +0 -1
  31. package/browser/transaction/shared/P2TR_MS.d.ts +0 -1
  32. package/browser/transaction/shared/TweakedTransaction.d.ts +0 -1
  33. package/browser/utils/BitcoinUtils.d.ts +0 -1
  34. package/browser/verification/TapscriptVerificator.d.ts +0 -1
  35. package/browser/wbtc/WrappedGenerationParameters.d.ts +0 -1
  36. package/build/bytecode/Compressor.d.ts +0 -1
  37. package/build/bytecode/Compressor.js +4 -4
  38. package/build/crypto/crypto.d.ts +0 -1
  39. package/build/generators/AddressGenerator.d.ts +0 -1
  40. package/build/generators/Generator.d.ts +0 -1
  41. package/build/generators/Generator.js +3 -5
  42. package/build/generators/builders/CalldataGenerator.d.ts +0 -1
  43. package/build/generators/builders/DeploymentGenerator.d.ts +0 -1
  44. package/build/generators/builders/{MultisignGenerator.d.ts → MultiSignGenerator.d.ts} +0 -1
  45. package/build/generators/builders/{MultisignGenerator.js → MultiSignGenerator.js} +1 -1
  46. package/build/keypair/EcKeyPair.d.ts +0 -1
  47. package/build/keypair/EcKeyPair.js +2 -2
  48. package/build/keypair/Wallet.d.ts +0 -1
  49. package/build/keypair/Wallet.js +0 -5
  50. package/build/metadata/ContractBaseMetadata.js +0 -1
  51. package/build/metadata/contracts/wBTC.js +3 -5
  52. package/build/metadata/tokens.js +27 -25
  53. package/build/signer/TweakedSigner.d.ts +0 -1
  54. package/build/transaction/browser/BrowserSignerBase.d.ts +0 -1
  55. package/build/transaction/browser/extensions/UnisatSigner.d.ts +0 -1
  56. package/build/transaction/browser/extensions/UnisatSigner.js +1 -6
  57. package/build/transaction/builders/DeploymentTransaction.d.ts +0 -1
  58. package/build/transaction/builders/DeploymentTransaction.js +25 -33
  59. package/build/transaction/builders/FundingTransaction.js +1 -3
  60. package/build/transaction/builders/InteractionTransaction.d.ts +0 -1
  61. package/build/transaction/builders/InteractionTransaction.js +2 -5
  62. package/build/transaction/builders/MultiSignTransaction.d.ts +0 -1
  63. package/build/transaction/builders/MultiSignTransaction.js +66 -73
  64. package/build/transaction/builders/SharedInteractionTransaction.d.ts +0 -1
  65. package/build/transaction/builders/SharedInteractionTransaction.js +20 -25
  66. package/build/transaction/builders/TransactionBuilder.d.ts +0 -1
  67. package/build/transaction/builders/TransactionBuilder.js +12 -21
  68. package/build/transaction/builders/UnwrapSegwitTransaction.d.ts +0 -1
  69. package/build/transaction/builders/UnwrapSegwitTransaction.js +4 -10
  70. package/build/transaction/builders/UnwrapTransaction.d.ts +0 -1
  71. package/build/transaction/builders/UnwrapTransaction.js +5 -11
  72. package/build/transaction/builders/WrapTransaction.d.ts +0 -1
  73. package/build/transaction/builders/WrapTransaction.js +5 -12
  74. package/build/transaction/interfaces/ITransactionParameters.d.ts +0 -1
  75. package/build/transaction/interfaces/Tap.d.ts +0 -1
  76. package/build/transaction/processor/PsbtTransaction.js +3 -4
  77. package/build/transaction/shared/P2TR_MS.d.ts +0 -1
  78. package/build/transaction/shared/TweakedTransaction.d.ts +0 -1
  79. package/build/transaction/shared/TweakedTransaction.js +11 -16
  80. package/build/utils/BitcoinUtils.d.ts +0 -1
  81. package/build/utxo/OPNetLimitedProvider.js +2 -3
  82. package/build/verification/TapscriptVerificator.d.ts +0 -1
  83. package/build/verification/TapscriptVerificator.js +1 -1
  84. package/build/wbtc/UnwrapGeneration.js +0 -2
  85. package/build/wbtc/WrappedGenerationParameters.d.ts +0 -1
  86. package/build/wbtc/WrappedGenerationParameters.js +0 -6
  87. package/cjs/package.json +3 -0
  88. package/docs/.nojekyll +1 -0
  89. package/docs/assets/highlight.css +43 -0
  90. package/docs/assets/icons.js +15 -0
  91. package/docs/assets/icons.svg +1 -0
  92. package/docs/assets/main.js +59 -0
  93. package/docs/assets/material-style.css +247 -0
  94. package/docs/assets/navigation.js +1 -0
  95. package/docs/assets/search.js +1 -0
  96. package/docs/assets/style.css +1412 -0
  97. package/docs/classes/AddressGenerator.html +177 -0
  98. package/docs/classes/AddressVerificator.html +177 -0
  99. package/docs/classes/BitcoinUtils.html +196 -0
  100. package/docs/classes/CalldataGenerator.html +213 -0
  101. package/docs/classes/Compressor.html +185 -0
  102. package/docs/classes/ContractBaseMetadata.html +182 -0
  103. package/docs/classes/CustomKeypair.html +189 -0
  104. package/docs/classes/DeploymentGenerator.html +201 -0
  105. package/docs/classes/DeploymentTransaction.html +465 -0
  106. package/docs/classes/EcKeyPair.html +280 -0
  107. package/docs/classes/FundingTransaction.html +425 -0
  108. package/docs/classes/Generator.html +199 -0
  109. package/docs/classes/InteractionTransaction.html +467 -0
  110. package/docs/classes/MultiSignGenerator.html +178 -0
  111. package/docs/classes/MultiSignTransaction.html +490 -0
  112. package/docs/classes/OPNetLimitedProvider.html +225 -0
  113. package/docs/classes/OPNetTokenAddressManager.html +182 -0
  114. package/docs/classes/P2TR_MS.html +186 -0
  115. package/docs/classes/PsbtTransaction.html +320 -0
  116. package/docs/classes/SharedInteractionTransaction.html +477 -0
  117. package/docs/classes/TapscriptVerificator.html +180 -0
  118. package/docs/classes/TransactionBuilder.html +423 -0
  119. package/docs/classes/TransactionFactory.html +230 -0
  120. package/docs/classes/TweakedSigner.html +181 -0
  121. package/docs/classes/TweakedTransaction.html +301 -0
  122. package/docs/classes/UnisatSigner.html +199 -0
  123. package/docs/classes/UnwrapGeneration.html +177 -0
  124. package/docs/classes/UnwrapTransaction.html +518 -0
  125. package/docs/classes/Wallet.html +204 -0
  126. package/docs/classes/WrapTransaction.html +509 -0
  127. package/docs/classes/WrappedGeneration.html +187 -0
  128. package/docs/classes/wBTC.html +190 -0
  129. package/docs/enums/ChainId.html +176 -0
  130. package/docs/enums/Consensus.html +204 -0
  131. package/docs/enums/Features.html +175 -0
  132. package/docs/enums/MessageType.html +176 -0
  133. package/docs/enums/OPNetNetwork.html +177 -0
  134. package/docs/enums/PSBTTypes.html +175 -0
  135. package/docs/enums/TransactionSequence.html +177 -0
  136. package/docs/enums/TransactionType.html +181 -0
  137. package/docs/enums/UnisatChainType.html +181 -0
  138. package/docs/enums/UnisatNetwork.html +177 -0
  139. package/docs/hierarchy.html +174 -0
  140. package/docs/index.html +215 -0
  141. package/docs/interfaces/Balance.html +177 -0
  142. package/docs/interfaces/BitcoinTransferResponse.html +178 -0
  143. package/docs/interfaces/BroadcastResponse.html +181 -0
  144. package/docs/interfaces/BroadcastTransactionOptions.html +176 -0
  145. package/docs/interfaces/BroadcastedTransaction.html +184 -0
  146. package/docs/interfaces/ConsensusConfig.html +182 -0
  147. package/docs/interfaces/ContractAddressVerificationParams.html +179 -0
  148. package/docs/interfaces/DeploymentResult.html +178 -0
  149. package/docs/interfaces/FetchUTXOParams.html +178 -0
  150. package/docs/interfaces/FetchUTXOParamsMultiAddress.html +178 -0
  151. package/docs/interfaces/FundingTransactionResponse.html +178 -0
  152. package/docs/interfaces/GenerationConstraints.html +182 -0
  153. package/docs/interfaces/IDeploymentParameters.html +186 -0
  154. package/docs/interfaces/IFundingTransactionParameters.html +186 -0
  155. package/docs/interfaces/IInteractionParameters.html +187 -0
  156. package/docs/interfaces/ITransactionParameters.html +184 -0
  157. package/docs/interfaces/ITweakedTransactionData.html +178 -0
  158. package/docs/interfaces/IUnwrapParameters.html +189 -0
  159. package/docs/interfaces/IWBTCUTXODocument.html +180 -0
  160. package/docs/interfaces/IWallet.html +181 -0
  161. package/docs/interfaces/IWrapParameters.html +190 -0
  162. package/docs/interfaces/MultiSignFromBase64Params.html +188 -0
  163. package/docs/interfaces/MultiSignParameters.html +188 -0
  164. package/docs/interfaces/OPNetTokenMetadata.html +179 -0
  165. package/docs/interfaces/PsbtInputExtended.html +194 -0
  166. package/docs/interfaces/PsbtOutputExtendedAddress.html +183 -0
  167. package/docs/interfaces/PsbtOutputExtendedScript.html +183 -0
  168. package/docs/interfaces/PsbtSignatureOptions.html +176 -0
  169. package/docs/interfaces/PsbtTransactionData.html +179 -0
  170. package/docs/interfaces/RawUTXOResponse.html +178 -0
  171. package/docs/interfaces/SharedInteractionParameters.html +187 -0
  172. package/docs/interfaces/TapLeafScript.html +177 -0
  173. package/docs/interfaces/ToSignInputAddress.html +178 -0
  174. package/docs/interfaces/ToSignInputPublicKey.html +178 -0
  175. package/docs/interfaces/TweakSettings.html +179 -0
  176. package/docs/interfaces/UTXO.html +178 -0
  177. package/docs/interfaces/Unisat.html +190 -0
  178. package/docs/interfaces/UnisatChainInfo.html +177 -0
  179. package/docs/interfaces/UnwrapResult.html +181 -0
  180. package/docs/interfaces/UnwrappedGenerationParameters.html +178 -0
  181. package/docs/interfaces/UpdateInput.html +175 -0
  182. package/docs/interfaces/VaultUTXOs.html +178 -0
  183. package/docs/interfaces/Web3Provider.html +180 -0
  184. package/docs/interfaces/WrapResult.html +179 -0
  185. package/docs/interfaces/WrappedGenerationParameters.html +184 -0
  186. package/docs/modules.html +289 -0
  187. package/docs/types/FromBase64Params.html +174 -0
  188. package/docs/types/IDeploymentParametersWithoutSigner.html +174 -0
  189. package/docs/types/IUnwrapParametersWithoutSigner.html +174 -0
  190. package/docs/types/IWrapParametersWithoutSigner.html +174 -0
  191. package/docs/types/InteractionParametersWithoutSigner.html +174 -0
  192. package/docs/types/PsbtOutputExtended.html +174 -0
  193. package/docs/types/ToSignInput.html +174 -0
  194. package/docs/variables/FACTORY_ADDRESS_FRACTAL.html +174 -0
  195. package/docs/variables/FACTORY_ADDRESS_REGTEST.html +174 -0
  196. package/docs/variables/FACTORY_ADDRESS_TESTNET.html +174 -0
  197. package/docs/variables/MOTO_ADDRESS_FRACTAL.html +174 -0
  198. package/docs/variables/MOTO_ADDRESS_REGTEST.html +174 -0
  199. package/docs/variables/MOTO_ADDRESS_TESTNET.html +174 -0
  200. package/docs/variables/OPNetConsensusConfig.html +174 -0
  201. package/docs/variables/OPNetMetadata.html +174 -0
  202. package/docs/variables/POOL_ADDRESS_FRACTAL.html +174 -0
  203. package/docs/variables/POOL_ADDRESS_REGTEST.html +174 -0
  204. package/docs/variables/POOL_ADDRESS_TESTNET.html +174 -0
  205. package/docs/variables/ROUTER_ADDRESS_FRACTAL.html +174 -0
  206. package/docs/variables/ROUTER_ADDRESS_REGTEST.html +174 -0
  207. package/docs/variables/ROUTER_ADDRESS_TESTNET.html +174 -0
  208. package/docs/variables/RoswellConsensus.html +174 -0
  209. package/docs/variables/WBTC_ADDRESS_FRACTAL.html +174 -0
  210. package/docs/variables/WBTC_ADDRESS_REGTEST.html +174 -0
  211. package/docs/variables/WBTC_ADDRESS_TESTNET.html +174 -0
  212. package/docs/variables/currentConsensus.html +174 -0
  213. package/docs/variables/currentConsensusConfig.html +174 -0
  214. package/docs/variables/version.html +174 -0
  215. package/gulpfile.js +49 -133
  216. package/package.json +112 -113
  217. package/src/bytecode/Compressor.ts +27 -27
  218. package/src/consensus/metadata/RoswellConsensus.ts +26 -26
  219. package/src/crypto/crypto.ts +1 -1
  220. package/src/generators/Generator.ts +75 -75
  221. package/src/generators/builders/MultiSignGenerator.ts +73 -73
  222. package/src/metadata/contracts/wBTC.ts +60 -60
  223. package/src/metadata/tokens.ts +135 -135
  224. package/src/network/ChainId.ts +6 -6
  225. package/src/opnet.ts +82 -82
  226. package/src/signer/TweakedSigner.ts +56 -56
  227. package/src/transaction/builders/DeploymentTransaction.ts +356 -356
  228. package/src/transaction/builders/MultiSignTransaction.ts +659 -659
  229. package/src/transaction/builders/UnwrapSegwitTransaction.ts +365 -365
  230. package/src/transaction/builders/UnwrapTransaction.ts +507 -507
  231. package/src/transaction/enums/TransactionType.ts +9 -9
  232. package/src/transaction/processor/PsbtTransaction.ts +173 -173
  233. package/src/transaction/shared/P2TR_MS.ts +42 -42
  234. package/src/transaction/shared/TweakedTransaction.ts +539 -539
  235. package/src/utils/BitcoinUtils.ts +96 -96
  236. package/tsconfig.base.json +27 -43
  237. package/tsconfig.json +15 -8
  238. package/tsconfig.webpack.json +22 -22
  239. package/EPOCH.md +0 -250
  240. package/VAULT_TARGET_CONSOLIDATION.md +0 -111
  241. package/browser/network/NetworkInformation.d.ts +0 -6
  242. package/browser/transaction/browser/BrowserSigner.d.ts +0 -9
  243. package/browser/transaction/builders/TapUnwarpTransaction.d.ts +0 -40
  244. package/browser/transaction/builders/UnwarpTransaction.d.ts +0 -34
  245. package/browser/utxo/UTXOManager.d.ts +0 -7
  246. package/build/Utils.d.ts +0 -0
  247. package/build/Utils.js +0 -1
  248. package/build/consensus/metadata/RoswsellConsensus.d.ts +0 -2
  249. package/build/consensus/metadata/RoswsellConsensus.js +0 -4
  250. package/build/contracts/ContractMetadataManager.d.ts +0 -0
  251. package/build/contracts/ContractMetadataManager.js +0 -1
  252. package/build/generators/OPNetAddressGenerator.d.ts +0 -0
  253. package/build/generators/OPNetAddressGenerator.js +0 -1
  254. package/build/generators/builders/DeploymentGeneratorV2.d.ts +0 -13
  255. package/build/generators/builders/DeploymentGeneratorV2.js +0 -57
  256. package/build/generators/builders/UnwrapGenerator.d.ts +0 -8
  257. package/build/generators/builders/UnwrapGenerator.js +0 -79
  258. package/build/keypair/interfaces/GeneratedWallet.d.ts +0 -5
  259. package/build/keypair/interfaces/GeneratedWallet.js +0 -1
  260. package/build/metadata/CommonContracts.d.ts +0 -6
  261. package/build/metadata/CommonContracts.js +0 -5
  262. package/build/metadata/ContractMetadataManager.d.ts +0 -1
  263. package/build/metadata/ContractMetadataManager.js +0 -9
  264. package/build/metadata/contracts/ContractBase.d.ts +0 -9
  265. package/build/metadata/contracts/ContractBase.js +0 -13
  266. package/build/metadata/contracts/ContractBaseMetadata.d.ts +0 -9
  267. package/build/metadata/contracts/ContractBaseMetadata.js +0 -13
  268. package/build/metadata/contracts/ContractMetadataManager.d.ts +0 -0
  269. package/build/metadata/contracts/ContractMetadataManager.js +0 -1
  270. package/build/network/NetworkConverter.d.ts +0 -0
  271. package/build/network/NetworkConverter.js +0 -14
  272. package/build/network/NetworkInformation.d.ts +0 -6
  273. package/build/network/NetworkInformation.js +0 -1
  274. package/build/scripts/Regtest.d.ts +0 -2
  275. package/build/scripts/Regtest.js +0 -15
  276. package/build/scripts/test.d.ts +0 -1
  277. package/build/scripts/test.js +0 -74
  278. package/build/signer/Regtest.d.ts +0 -2
  279. package/build/signer/Regtest.js +0 -15
  280. package/build/tests/Regtest.d.ts +0 -3
  281. package/build/tests/Regtest.js +0 -29
  282. package/build/tests/adaptPSBT.d.ts +0 -1
  283. package/build/tests/adaptPSBT.js +0 -44
  284. package/build/tests/btc/send.d.ts +0 -1
  285. package/build/tests/btc/send.js +0 -35
  286. package/build/tests/btc/transfer.d.ts +0 -1
  287. package/build/tests/btc/transfer.js +0 -35
  288. package/build/tests/createPairReg.d.ts +0 -1
  289. package/build/tests/createPairReg.js +0 -73
  290. package/build/tests/deploy/deployMoto.d.ts +0 -4
  291. package/build/tests/deploy/deployMoto.js +0 -89
  292. package/build/tests/deploy/deployPool.d.ts +0 -1
  293. package/build/tests/deploy/deployPool.js +0 -5
  294. package/build/tests/deploy/deployStep1.d.ts +0 -1
  295. package/build/tests/deploy/deployStep1.js +0 -5
  296. package/build/tests/deploy/deployStep2.d.ts +0 -1
  297. package/build/tests/deploy/deployStep2.js +0 -5
  298. package/build/tests/deploy/deployStep3.d.ts +0 -1
  299. package/build/tests/deploy/deployStep3.js +0 -5
  300. package/build/tests/deploy.d.ts +0 -1
  301. package/build/tests/deploy.js +0 -41
  302. package/build/tests/deployMotoRegStep1.d.ts +0 -1
  303. package/build/tests/deployMotoRegStep1.js +0 -85
  304. package/build/tests/deployReg.d.ts +0 -1
  305. package/build/tests/deployReg.js +0 -85
  306. package/build/tests/factory/createPairReg.d.ts +0 -1
  307. package/build/tests/factory/createPairReg.js +0 -13
  308. package/build/tests/gen.d.ts +0 -1
  309. package/build/tests/gen.js +0 -19
  310. package/build/tests/interaction.d.ts +0 -5
  311. package/build/tests/interaction.js +0 -62
  312. package/build/tests/massWrapReg.d.ts +0 -1
  313. package/build/tests/massWrapReg.js +0 -105
  314. package/build/tests/mineReg.d.ts +0 -1
  315. package/build/tests/mineReg.js +0 -19
  316. package/build/tests/moto/airdropToken.d.ts +0 -1
  317. package/build/tests/moto/airdropToken.js +0 -21
  318. package/build/tests/moto/airdropTokens.d.ts +0 -1
  319. package/build/tests/moto/airdropTokens.js +0 -60
  320. package/build/tests/moto/allowance.d.ts +0 -1
  321. package/build/tests/moto/allowance.js +0 -6
  322. package/build/tests/moto/approve.d.ts +0 -1
  323. package/build/tests/moto/approve.js +0 -10
  324. package/build/tests/moto/approveWBTC.d.ts +0 -1
  325. package/build/tests/moto/approveWBTC.js +0 -12
  326. package/build/tests/moto/balanceOf.d.ts +0 -1
  327. package/build/tests/moto/balanceOf.js +0 -12
  328. package/build/tests/moto/transfer.d.ts +0 -1
  329. package/build/tests/moto/transfer.js +0 -16
  330. package/build/tests/motoswap/airdropToken.d.ts +0 -11
  331. package/build/tests/motoswap/airdropToken.js +0 -36
  332. package/build/tests/motoswap/deployMoto.d.ts +0 -4
  333. package/build/tests/motoswap/deployMoto.js +0 -89
  334. package/build/tests/motoswap/deployMotoRegStep1.d.ts +0 -1
  335. package/build/tests/motoswap/deployMotoRegStep1.js +0 -91
  336. package/build/tests/motoswap/deployMotoRegStep2.d.ts +0 -1
  337. package/build/tests/motoswap/deployMotoRegStep2.js +0 -91
  338. package/build/tests/motoswap/deployPool.d.ts +0 -1
  339. package/build/tests/motoswap/deployPool.js +0 -5
  340. package/build/tests/motoswap/deployStep1.d.ts +0 -1
  341. package/build/tests/motoswap/deployStep1.js +0 -5
  342. package/build/tests/motoswap/deployStep2.d.ts +0 -1
  343. package/build/tests/motoswap/deployStep2.js +0 -5
  344. package/build/tests/motoswap/deployStep3.d.ts +0 -1
  345. package/build/tests/motoswap/deployStep3.js +0 -5
  346. package/build/tests/motoswap/interaction.d.ts +0 -3
  347. package/build/tests/motoswap/interaction.js +0 -63
  348. package/build/tests/motoswap/routerAddLiquidity.d.ts +0 -11
  349. package/build/tests/motoswap/routerAddLiquidity.js +0 -35
  350. package/build/tests/motoswap-router/addLiquidity.d.ts +0 -11
  351. package/build/tests/motoswap-router/addLiquidity.js +0 -36
  352. package/build/tests/motoswap-router/deployMoto.d.ts +0 -4
  353. package/build/tests/motoswap-router/deployMoto.js +0 -89
  354. package/build/tests/motoswap-router/deployPool.d.ts +0 -1
  355. package/build/tests/motoswap-router/deployPool.js +0 -5
  356. package/build/tests/motoswap-router/deployStep1.d.ts +0 -1
  357. package/build/tests/motoswap-router/deployStep1.js +0 -5
  358. package/build/tests/motoswap-router/deployStep2.d.ts +0 -1
  359. package/build/tests/motoswap-router/deployStep2.js +0 -5
  360. package/build/tests/motoswap-router/deployStep3.d.ts +0 -1
  361. package/build/tests/motoswap-router/deployStep3.js +0 -5
  362. package/build/tests/motoswap-router/getAmountsOut.d.ts +0 -5
  363. package/build/tests/motoswap-router/getAmountsOut.js +0 -34
  364. package/build/tests/motoswap-router/routerAddLiquidity.d.ts +0 -11
  365. package/build/tests/motoswap-router/routerAddLiquidity.js +0 -35
  366. package/build/tests/motoswap-router/swap.d.ts +0 -8
  367. package/build/tests/motoswap-router/swap.js +0 -24
  368. package/build/tests/multisign.d.ts +0 -1
  369. package/build/tests/multisign.js +0 -47
  370. package/build/tests/multisign2.d.ts +0 -1
  371. package/build/tests/multisign2.js +0 -27
  372. package/build/tests/pool/DecodePoolAddress.d.ts +0 -6
  373. package/build/tests/pool/DecodePoolAddress.js +0 -12
  374. package/build/tests/pool/decodeReserves.d.ts +0 -5
  375. package/build/tests/pool/decodeReserves.js +0 -13
  376. package/build/tests/pool/reserves.d.ts +0 -1
  377. package/build/tests/pool/reserves.js +0 -18
  378. package/build/tests/shared/Utils.d.ts +0 -2
  379. package/build/tests/shared/Utils.js +0 -14
  380. package/build/tests/shared/interaction.d.ts +0 -7
  381. package/build/tests/shared/interaction.js +0 -85
  382. package/build/tests/shared/tokens.d.ts +0 -6
  383. package/build/tests/shared/tokens.js +0 -5
  384. package/build/tests/stakeReg.d.ts +0 -1
  385. package/build/tests/stakeReg.js +0 -73
  386. package/build/tests/stakedReg.d.ts +0 -1
  387. package/build/tests/stakedReg.js +0 -28
  388. package/build/tests/test.d.ts +0 -1
  389. package/build/tests/test.js +0 -51
  390. package/build/tests/test2.d.ts +0 -1
  391. package/build/tests/test2.js +0 -73
  392. package/build/tests/testReg.d.ts +0 -1
  393. package/build/tests/testReg.js +0 -91
  394. package/build/tests/tokens.d.ts +0 -6
  395. package/build/tests/tokens.js +0 -5
  396. package/build/tests/totalRewardReg.d.ts +0 -1
  397. package/build/tests/totalRewardReg.js +0 -28
  398. package/build/tests/transfer.d.ts +0 -1
  399. package/build/tests/transfer.js +0 -74
  400. package/build/tests/transferReg.d.ts +0 -1
  401. package/build/tests/transferReg.js +0 -74
  402. package/build/tests/unStakeReg.d.ts +0 -1
  403. package/build/tests/unStakeReg.js +0 -72
  404. package/build/tests/unwrapReg.d.ts +0 -1
  405. package/build/tests/unwrapReg.js +0 -61
  406. package/build/tests/unwrapReg2.d.ts +0 -1
  407. package/build/tests/unwrapReg2.js +0 -56
  408. package/build/tests/unwrapRegSegwit.d.ts +0 -1
  409. package/build/tests/unwrapRegSegwit.js +0 -83
  410. package/build/tests/wbtc/approve.d.ts +0 -1
  411. package/build/tests/wbtc/approve.js +0 -6
  412. package/build/tests/wbtc/approveWBTC.d.ts +0 -1
  413. package/build/tests/wbtc/approveWBTC.js +0 -12
  414. package/build/tests/wbtc/massWrapReg.d.ts +0 -1
  415. package/build/tests/wbtc/massWrapReg.js +0 -105
  416. package/build/tests/wbtc/transfer.d.ts +0 -1
  417. package/build/tests/wbtc/transfer.js +0 -16
  418. package/build/tests/wbtc/transferReg.d.ts +0 -1
  419. package/build/tests/wbtc/transferReg.js +0 -16
  420. package/build/tests/wbtc/unStakeReg.d.ts +0 -1
  421. package/build/tests/wbtc/unStakeReg.js +0 -72
  422. package/build/tests/wbtc/unwrapReg.d.ts +0 -1
  423. package/build/tests/wbtc/unwrapReg.js +0 -60
  424. package/build/tests/wbtc/unwrapRegSegwit.d.ts +0 -1
  425. package/build/tests/wbtc/unwrapRegSegwit.js +0 -83
  426. package/build/tests/wbtc/withdrawalRequestReg.d.ts +0 -1
  427. package/build/tests/wbtc/withdrawalRequestReg.js +0 -71
  428. package/build/tests/wbtc/wrapReg.d.ts +0 -1
  429. package/build/tests/wbtc/wrapReg.js +0 -65
  430. package/build/tests/wbtc/wrapTest.d.ts +0 -1
  431. package/build/tests/wbtc/wrapTest.js +0 -66
  432. package/build/tests/withdrawalRequestReg.d.ts +0 -1
  433. package/build/tests/withdrawalRequestReg.js +0 -71
  434. package/build/tests/wrap.d.ts +0 -1
  435. package/build/tests/wrap.js +0 -65
  436. package/build/tests/wrapReg.d.ts +0 -1
  437. package/build/tests/wrapReg.js +0 -68
  438. package/build/tests/wrapTest.d.ts +0 -1
  439. package/build/tests/wrapTest.js +0 -66
  440. package/build/tests/wrapTestg.d.ts +0 -1
  441. package/build/tests/wrapTestg.js +0 -66
  442. package/build/tests/writers/allowance.d.ts +0 -3
  443. package/build/tests/writers/allowance.js +0 -10
  444. package/build/tests/writers/approve.d.ts +0 -4
  445. package/build/tests/writers/approve.js +0 -11
  446. package/build/transaction/TransactionBuilder.d.ts +0 -60
  447. package/build/transaction/TransactionBuilder.js +0 -244
  448. package/build/transaction/browser/BrowserSigner.d.ts +0 -11
  449. package/build/transaction/browser/BrowserSigner.js +0 -10
  450. package/build/transaction/browser/extensions/Unisat.d.ts +0 -54
  451. package/build/transaction/browser/extensions/Unisat.js +0 -11
  452. package/build/transaction/builders/DeploymentTransactionV2.d.ts +0 -36
  453. package/build/transaction/builders/DeploymentTransactionV2.js +0 -192
  454. package/build/transaction/builders/GenericTransaction.d.ts +0 -11
  455. package/build/transaction/builders/GenericTransaction.js +0 -23
  456. package/build/transaction/builders/TapUnwarpTransaction.d.ts +0 -37
  457. package/build/transaction/builders/TapUnwarpTransaction.js +0 -201
  458. package/build/transaction/builders/UnwarpSegwitTransaction.d.ts +0 -34
  459. package/build/transaction/builders/UnwarpSegwitTransaction.js +0 -184
  460. package/build/transaction/builders/UnwarpTransaction.d.ts +0 -35
  461. package/build/transaction/builders/UnwarpTransaction.js +0 -199
  462. package/build/transaction/interfaces/ITransactions.d.ts +0 -32
  463. package/build/transaction/interfaces/ITransactions.js +0 -1
  464. package/build/utxo/IUTXO.d.ts +0 -0
  465. package/build/utxo/IUTXO.js +0 -1
  466. package/build/utxo/OPNetUtils.d.ts +0 -7
  467. package/build/utxo/OPNetUtils.js +0 -47
  468. package/build/utxo/UTXOManager.d.ts +0 -7
  469. package/build/utxo/UTXOManager.js +0 -47
  470. package/build/wbtc/BroadcastResponse.d.ts +0 -0
  471. package/build/wbtc/BroadcastResponse.js +0 -1
  472. package/examples/Deploy.md +0 -188
  473. package/examples/Unwrap.md +0 -165
  474. package/examples/Wrap.md +0 -194
  475. package/tsconfig.cjs.json +0 -13
  476. /package/build/generators/{features.d.ts → Features.d.ts} +0 -0
  477. /package/build/generators/{features.js → Features.js} +0 -0
@@ -1,11 +0,0 @@
1
- import { ABICoder, BinaryWriter } from '@btc-vision/bsi-binary';
2
- const abiCoder = new ABICoder();
3
- const approveSelector = Number(`0x` + abiCoder.encodeSelector('approve'));
4
- export const MAX_UINT256 = 2n ** 256n - 1n;
5
- export function approve(spender, amount = MAX_UINT256) {
6
- const calldata = new BinaryWriter();
7
- calldata.writeSelector(approveSelector);
8
- calldata.writeAddress(spender);
9
- calldata.writeU256(amount);
10
- return Buffer.from(calldata.getBuffer());
11
- }
@@ -1,60 +0,0 @@
1
- /// <reference types="node" />
2
- import { Logger } from '@btc-vision/bsi-common';
3
- import { Network, Payment, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
4
- import { PsbtInputExtended, PsbtOutputExtended, UpdateInput } from './interfaces/Tap.js';
5
- import { TransactionType } from './enums/TransactionType.js';
6
- import { ITransactionParameters } from './interfaces/ITransactionParameters.js';
7
- import { Address } from '@btc-vision/bsi-binary';
8
- import { UTXO } from '../utxo/interfaces/IUTXO.js';
9
- export declare abstract class TransactionBuilder<T extends TransactionType> extends Logger {
10
- protected static readonly LOCK_LEAF_SCRIPT: Buffer;
11
- protected static readonly MINIMUM_DUST: bigint;
12
- abstract readonly type: T;
13
- readonly logColor: string;
14
- transactionFee: bigint;
15
- protected readonly transaction: Psbt;
16
- protected readonly inputs: PsbtInputExtended[];
17
- protected readonly updateInputs: UpdateInput[];
18
- protected readonly outputs: PsbtOutputExtended[];
19
- protected feeOutput: PsbtOutputExtended | null;
20
- protected signed: boolean;
21
- protected tapData: Payment | null;
22
- protected scriptData: Payment | null;
23
- protected totalInputAmount: bigint;
24
- protected readonly signer: Signer;
25
- protected readonly network: Network;
26
- protected readonly feeRate: number;
27
- protected readonly priorityFee: bigint;
28
- protected readonly utxos: UTXO[];
29
- protected to: Address | null;
30
- private _maximumFeeRate;
31
- protected constructor(parameters: ITransactionParameters);
32
- setDestinationAddress(address: Address): void;
33
- setMaximumFeeRate(feeRate: number): void;
34
- signTransaction(): string | null;
35
- getTransaction(): Transaction;
36
- getScriptAddress(): string;
37
- getTapAddress(): string;
38
- addInput(input: PsbtInputExtended): void;
39
- addOutput(output: PsbtOutputExtended): void;
40
- protected calculateTotalUTXOAmount(): bigint;
41
- protected calculateTotalVOutAmount(): bigint;
42
- protected addInputsFromUTXO(): void;
43
- protected witnessStackToScriptWitness(witness: Buffer[]): Buffer;
44
- protected internalInit(): void;
45
- protected abstract buildTransaction(to?: Address): void;
46
- protected generateScriptAddress(): Payment;
47
- protected generateTapData(): Payment;
48
- protected updateInput(input: UpdateInput): void;
49
- protected getWitness(): Buffer;
50
- protected getTapOutput(): Buffer;
51
- protected getInputs(): PsbtInputExtended[];
52
- protected getOutputs(): PsbtOutputExtended[];
53
- protected verifyUTXOValidity(): void;
54
- protected setFeeOutput(output: PsbtOutputExtended): void;
55
- protected abstract getSignerKey(): Signer;
56
- protected internalPubKeyToXOnly(): Buffer;
57
- protected signInputs(transaction: Psbt): void;
58
- private internalBuildTransaction;
59
- private estimateTransactionFees;
60
- }
@@ -1,244 +0,0 @@
1
- import { Logger } from '@btc-vision/bsi-common';
2
- import { initEccLib, opcodes, payments, Psbt, script, } from 'bitcoinjs-lib';
3
- import { varuint } from 'bitcoinjs-lib/src/bufferutils.js';
4
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
5
- import * as ecc from 'tiny-secp256k1';
6
- import { EcKeyPair } from '../keypair/EcKeyPair.js';
7
- initEccLib(ecc);
8
- export class TransactionBuilder extends Logger {
9
- static LOCK_LEAF_SCRIPT = script.compile([opcodes.OP_0]);
10
- static MINIMUM_DUST = 330n;
11
- logColor = '#785def';
12
- transactionFee = 0n;
13
- transaction;
14
- inputs = [];
15
- updateInputs = [];
16
- outputs = [];
17
- feeOutput = null;
18
- signed = false;
19
- tapData = null;
20
- scriptData = null;
21
- totalInputAmount;
22
- signer;
23
- network;
24
- feeRate;
25
- priorityFee;
26
- utxos;
27
- to = null;
28
- _maximumFeeRate = 1000000;
29
- constructor(parameters) {
30
- super();
31
- this.signer = parameters.signer;
32
- this.network = parameters.network;
33
- this.feeRate = parameters.feeRate;
34
- this.priorityFee = parameters.priorityFee;
35
- this.utxos = parameters.utxos;
36
- this.to = parameters.to;
37
- this.totalInputAmount = this.calculateTotalUTXOAmount();
38
- const totalVOut = this.calculateTotalVOutAmount();
39
- if (totalVOut < this.totalInputAmount) {
40
- throw new Error(`Vout value is less than the value to send`);
41
- }
42
- if (this.totalInputAmount < TransactionBuilder.MINIMUM_DUST) {
43
- throw new Error(`Value is less than the minimum dust`);
44
- }
45
- this.transaction = new Psbt({
46
- network: this.network,
47
- });
48
- }
49
- setDestinationAddress(address) {
50
- this.to = address;
51
- }
52
- setMaximumFeeRate(feeRate) {
53
- this._maximumFeeRate = feeRate;
54
- }
55
- signTransaction() {
56
- if (!this.to)
57
- throw new Error('Transaction must have a recipient');
58
- if (!EcKeyPair.verifyContractAddress(this.to, this.network)) {
59
- throw new Error('Invalid contract address. The contract address must be a taproot address.');
60
- }
61
- if (this.signed)
62
- throw new Error('Transaction is already signed');
63
- this.signed = true;
64
- this.buildTransaction(this.to);
65
- const builtTx = this.internalBuildTransaction(this.transaction);
66
- if (builtTx) {
67
- return this.transaction.extractTransaction(false).toHex();
68
- }
69
- throw new Error('Could not sign transaction');
70
- }
71
- getTransaction() {
72
- return this.transaction.extractTransaction(false);
73
- }
74
- getScriptAddress() {
75
- if (!this.scriptData || !this.scriptData.address) {
76
- throw new Error('Tap data is required');
77
- }
78
- return this.scriptData.address;
79
- }
80
- getTapAddress() {
81
- if (!this.tapData || !this.tapData.address) {
82
- throw new Error('Tap data is required');
83
- }
84
- return this.tapData.address;
85
- }
86
- addInput(input) {
87
- this.inputs.push(input);
88
- }
89
- addOutput(output) {
90
- this.outputs.push(output);
91
- }
92
- calculateTotalUTXOAmount() {
93
- let total = 0n;
94
- for (let utxo of this.utxos) {
95
- total += utxo.value;
96
- }
97
- return total;
98
- }
99
- calculateTotalVOutAmount() {
100
- let total = 0n;
101
- for (let utxo of this.utxos) {
102
- total += utxo.value;
103
- }
104
- return total;
105
- }
106
- addInputsFromUTXO() {
107
- for (let utxo of this.utxos) {
108
- const input = {
109
- hash: utxo.transactionId,
110
- index: utxo.outputIndex,
111
- witnessUtxo: {
112
- value: Number(utxo.value),
113
- script: Buffer.from(utxo.scriptPubKey.hex, 'hex'),
114
- },
115
- };
116
- this.addInput(input);
117
- }
118
- }
119
- witnessStackToScriptWitness(witness) {
120
- let buffer = Buffer.allocUnsafe(0);
121
- function writeSlice(slice) {
122
- buffer = Buffer.concat([buffer, Buffer.from(slice)]);
123
- }
124
- function writeVarInt(i) {
125
- const currentLen = buffer.length;
126
- const varintLen = varuint.encodingLength(i);
127
- buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
128
- varuint.encode(i, buffer, currentLen);
129
- }
130
- function writeVarSlice(slice) {
131
- writeVarInt(slice.length);
132
- writeSlice(slice);
133
- }
134
- function writeVector(vector) {
135
- writeVarInt(vector.length);
136
- vector.forEach(writeVarSlice);
137
- }
138
- writeVector(witness);
139
- return buffer;
140
- }
141
- internalInit() {
142
- this.verifyUTXOValidity();
143
- this.scriptData = payments.p2tr(this.generateScriptAddress());
144
- this.tapData = payments.p2tr(this.generateTapData());
145
- }
146
- generateScriptAddress() {
147
- return {
148
- internalPubkey: this.internalPubKeyToXOnly(),
149
- network: this.network,
150
- };
151
- }
152
- generateTapData() {
153
- return {
154
- internalPubkey: this.internalPubKeyToXOnly(),
155
- network: this.network,
156
- };
157
- }
158
- updateInput(input) {
159
- this.updateInputs.push(input);
160
- }
161
- getWitness() {
162
- if (!this.tapData || !this.tapData.witness) {
163
- throw new Error('Witness is required');
164
- }
165
- if (this.tapData.witness.length === 0) {
166
- throw new Error('Witness is empty');
167
- }
168
- return this.tapData.witness[this.tapData.witness.length - 1];
169
- }
170
- getTapOutput() {
171
- if (!this.tapData || !this.tapData.output) {
172
- throw new Error('Tap data is required');
173
- }
174
- return this.tapData.output;
175
- }
176
- getInputs() {
177
- return this.inputs;
178
- }
179
- getOutputs() {
180
- if (!this.feeOutput)
181
- throw new Error('Fee output is required');
182
- const outputs = [...this.outputs];
183
- outputs.push(this.feeOutput);
184
- return outputs;
185
- }
186
- verifyUTXOValidity() {
187
- for (let utxo of this.utxos) {
188
- if (!utxo.scriptPubKey) {
189
- throw new Error('Address is required');
190
- }
191
- }
192
- }
193
- setFeeOutput(output) {
194
- this.feeOutput = output;
195
- const fee = this.estimateTransactionFees();
196
- if (fee > BigInt(output.value)) {
197
- throw new Error('Insufficient funds');
198
- }
199
- this.feeOutput.value = this.feeOutput.value - Number(fee);
200
- }
201
- internalPubKeyToXOnly() {
202
- return toXOnly(this.signer.publicKey);
203
- }
204
- signInputs(transaction) {
205
- transaction.signAllInputs(this.getSignerKey());
206
- transaction.finalizeAllInputs();
207
- }
208
- internalBuildTransaction(transaction) {
209
- const inputs = this.getInputs();
210
- const outputs = this.getOutputs();
211
- transaction.setMaximumFeeRate(this._maximumFeeRate);
212
- transaction.addInputs(inputs);
213
- for (let i = 0; i < this.updateInputs.length; i++) {
214
- transaction.updateInput(i, this.updateInputs[i]);
215
- }
216
- transaction.addOutputs(outputs);
217
- try {
218
- this.signInputs(transaction);
219
- this.transactionFee = BigInt(transaction.getFee());
220
- return true;
221
- }
222
- catch (e) {
223
- const err = e;
224
- this.error(`[internalBuildTransaction] Something went wrong while getting building the transaction: ${err.stack}`);
225
- }
226
- return false;
227
- }
228
- estimateTransactionFees() {
229
- const fakeTx = new Psbt({
230
- network: this.network,
231
- });
232
- const builtTx = this.internalBuildTransaction(fakeTx);
233
- if (builtTx) {
234
- const tx = fakeTx.extractTransaction(false);
235
- const size = tx.virtualSize();
236
- const fee = this.feeRate * size + 1;
237
- this.log(`Transaction fee estimated to: ${fee} - ${fakeTx.getFeeRate()}`);
238
- return BigInt(Math.ceil(fee));
239
- }
240
- else {
241
- throw new Error(`Could not build transaction to estimate fee. Something went wrong while building the transaction.`);
242
- }
243
- }
244
- }
@@ -1,11 +0,0 @@
1
- import { Psbt, Transaction } from 'bitcoinjs-lib';
2
- import { Unisat } from './types/Unisat.js';
3
- declare global {
4
- interface Window {
5
- unisat?: Unisat;
6
- }
7
- }
8
- export declare abstract class BrowserSigner {
9
- signTransaction(transaction: Psbt): Promise<Transaction>;
10
- generateSigner(): Promise<void>;
11
- }
@@ -1,10 +0,0 @@
1
- export class BrowserSigner {
2
- async signTransaction(transaction) {
3
- if (!window) {
4
- throw new Error('BrowserSigner can only be used in a browser environment');
5
- }
6
- throw new Error('Not implemented');
7
- }
8
- async generateSigner() {
9
- }
10
- }
@@ -1,54 +0,0 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
- export declare enum UnisatNetwork {
3
- testnet = "testnet",
4
- mainnet = "livenet",
5
- regtest = "regtest"
6
- }
7
- export interface Balance {
8
- readonly confirmed: number;
9
- readonly unconfirmed: number;
10
- readonly total: number;
11
- }
12
- export declare enum MessageType {
13
- ecdsa = "ecdsa",
14
- bip322 = "bip322-simple"
15
- }
16
- interface ToSignInputBase {
17
- readonly index: number;
18
- readonly sighashTypes?: number[];
19
- readonly disableTweakSigner?: boolean;
20
- }
21
- export interface ToSignInputPublicKey extends ToSignInputBase {
22
- readonly publicKey: string;
23
- }
24
- export interface ToSignInputAddress extends ToSignInputBase {
25
- readonly address: Address;
26
- }
27
- export type ToSignInput = ToSignInputPublicKey | ToSignInputAddress;
28
- export interface PsbtSignatureOptions {
29
- readonly autoFinalized?: boolean;
30
- readonly toSignInputs?: ToSignInput[];
31
- }
32
- export interface Unisat {
33
- sendBitcoin(toAddress: Address, satoshis: number, options: {
34
- feeRate: number;
35
- }): Promise<string>;
36
- requestAccounts(): Promise<string[]>;
37
- getNetwork(): Promise<UnisatNetwork>;
38
- getAccounts(): Promise<string[]>;
39
- switchNetwork(network: UnisatNetwork): Promise<void>;
40
- getPublicKey(): Promise<string>;
41
- getBalance(): Promise<Balance>;
42
- signMessage(message: string, type?: MessageType): Promise<string>;
43
- pushTx(options: {
44
- rawtx: string;
45
- }): Promise<string>;
46
- signPsbt(psbtHex: string, psbtOptions: PsbtSignatureOptions): Promise<string>;
47
- signPsbts(psbtHex: string[], psbtOptions: PsbtSignatureOptions): Promise<string[]>;
48
- pushPsbt(psbtHex: string): Promise<string>;
49
- on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
50
- on(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
51
- removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
52
- removeListener(event: 'networkChanged', listener: (network: UnisatNetwork) => void): void;
53
- }
54
- export {};
@@ -1,11 +0,0 @@
1
- export var UnisatNetwork;
2
- (function (UnisatNetwork) {
3
- UnisatNetwork["testnet"] = "testnet";
4
- UnisatNetwork["mainnet"] = "livenet";
5
- UnisatNetwork["regtest"] = "regtest";
6
- })(UnisatNetwork || (UnisatNetwork = {}));
7
- export var MessageType;
8
- (function (MessageType) {
9
- MessageType["ecdsa"] = "ecdsa";
10
- MessageType["bip322"] = "bip322-simple";
11
- })(MessageType || (MessageType = {}));
@@ -1,36 +0,0 @@
1
- /// <reference types="node" />
2
- import { TransactionType } from '../enums/TransactionType.js';
3
- import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
4
- import { Payment, Psbt } from 'bitcoinjs-lib';
5
- import { TransactionBuilder } from './TransactionBuilder.js';
6
- import { TapLeafScript } from '../interfaces/Tap.js';
7
- import { Address } from '@btc-vision/bsi-binary';
8
- export declare class DeploymentTransactionV2 extends TransactionBuilder<TransactionType.DEPLOYMENT> {
9
- type: TransactionType.DEPLOYMENT;
10
- protected readonly _contractAddress: Address;
11
- protected tapLeafScript: TapLeafScript | null;
12
- private targetScriptRedeem;
13
- private leftOverFundsScriptRedeem;
14
- private readonly compiledTargetScript;
15
- private readonly scriptTree;
16
- private deploymentGenerator;
17
- private readonly contractSeed;
18
- private readonly bytecode;
19
- private readonly contractSigner;
20
- private readonly randomBytes;
21
- constructor(parameters: IDeploymentParameters);
22
- get contractAddress(): Address;
23
- get p2trAddress(): Address;
24
- getRndBytes(): Buffer;
25
- protected contractSignerXOnlyPubKey(): Buffer;
26
- protected buildTransaction(): Promise<void>;
27
- protected signInputs(transaction: Psbt): Promise<void>;
28
- protected generateScriptAddress(): Payment;
29
- protected generateTapData(): Payment;
30
- private getContractSeed;
31
- private customFinalizer;
32
- private getPubKeys;
33
- private generateRedeemScripts;
34
- private getLeafScript;
35
- private getScriptTree;
36
- }
@@ -1,192 +0,0 @@
1
- import { TransactionType } from '../enums/TransactionType.js';
2
- import { crypto as bitCrypto } from 'bitcoinjs-lib';
3
- import { TransactionBuilder } from './TransactionBuilder.js';
4
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
5
- import { EcKeyPair } from '../../keypair/EcKeyPair.js';
6
- import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
7
- import { Compressor } from '../../bytecode/Compressor.js';
8
- import { AddressGenerator } from '../../generators/AddressGenerator.js';
9
- import { DeploymentGeneratorV2 } from '../../generators/builders/DeploymentGeneratorV2.js';
10
- export class DeploymentTransactionV2 extends TransactionBuilder {
11
- type = TransactionType.DEPLOYMENT;
12
- _contractAddress;
13
- tapLeafScript = null;
14
- targetScriptRedeem = null;
15
- leftOverFundsScriptRedeem = null;
16
- compiledTargetScript;
17
- scriptTree;
18
- deploymentGenerator;
19
- contractSeed;
20
- bytecode;
21
- contractSigner;
22
- randomBytes;
23
- constructor(parameters) {
24
- super(parameters);
25
- this.bytecode = Compressor.compress(parameters.bytecode);
26
- if (!this.bytecode)
27
- throw new Error('Bytecode is required');
28
- this.randomBytes = parameters.randomBytes || BitcoinUtils.rndBytes();
29
- this.contractSeed = this.getContractSeed();
30
- this.contractSigner = EcKeyPair.fromSeedKeyPair(this.contractSeed, this.network);
31
- this.deploymentGenerator = new DeploymentGeneratorV2(this.internalPubKeyToXOnly(), this.contractSignerXOnlyPubKey(), this.network);
32
- this.compiledTargetScript = this.deploymentGenerator.compile(this.bytecode, this.randomBytes);
33
- this.scriptTree = this.getScriptTree();
34
- this.internalInit();
35
- this._contractAddress = AddressGenerator.generatePKSH(this.contractSeed, this.network);
36
- }
37
- get contractAddress() {
38
- return this._contractAddress;
39
- }
40
- get p2trAddress() {
41
- return this.to || this.getScriptAddress();
42
- }
43
- getRndBytes() {
44
- return this.randomBytes;
45
- }
46
- contractSignerXOnlyPubKey() {
47
- return toXOnly(this.contractSigner.publicKey);
48
- }
49
- async buildTransaction() {
50
- if (!this.to) {
51
- this.to = this.getScriptAddress();
52
- }
53
- const selectedRedeem = !!this.contractSigner
54
- ? this.targetScriptRedeem
55
- : this.leftOverFundsScriptRedeem;
56
- if (!selectedRedeem) {
57
- throw new Error('Left over funds script redeem is required');
58
- }
59
- if (!selectedRedeem.redeemVersion) {
60
- throw new Error('Left over funds script redeem version is required');
61
- }
62
- if (!selectedRedeem.output) {
63
- throw new Error('Left over funds script redeem output is required');
64
- }
65
- this.tapLeafScript = {
66
- leafVersion: selectedRedeem.redeemVersion,
67
- script: selectedRedeem.output,
68
- controlBlock: this.getWitness(),
69
- };
70
- this.addInputsFromUTXO();
71
- const amountSpent = this.getTransactionOPNetFee();
72
- this.addOutput({
73
- value: Number(amountSpent),
74
- address: this.to,
75
- });
76
- await this.addRefundOutput(amountSpent);
77
- }
78
- async signInputs(transaction) {
79
- if (!this.contractSigner) {
80
- await super.signInputs(transaction);
81
- return;
82
- }
83
- for (let i = 0; i < transaction.data.inputs.length; i++) {
84
- if (i === 0) {
85
- transaction.signInput(0, this.contractSigner);
86
- transaction.signInput(0, this.getSignerKey());
87
- transaction.finalizeInput(0, this.customFinalizer);
88
- }
89
- else {
90
- transaction.signInput(i, this.getSignerKey());
91
- transaction.finalizeInput(i);
92
- }
93
- }
94
- }
95
- generateScriptAddress() {
96
- return {
97
- internalPubkey: this.internalPubKeyToXOnly(),
98
- network: this.network,
99
- scriptTree: this.scriptTree,
100
- };
101
- }
102
- generateTapData() {
103
- const selectedRedeem = !!this.contractSigner
104
- ? this.targetScriptRedeem
105
- : this.leftOverFundsScriptRedeem;
106
- if (!selectedRedeem) {
107
- throw new Error('Left over funds script redeem is required');
108
- }
109
- if (!this.scriptTree) {
110
- throw new Error('Script tree is required');
111
- }
112
- return {
113
- internalPubkey: this.internalPubKeyToXOnly(),
114
- network: this.network,
115
- scriptTree: this.scriptTree,
116
- redeem: selectedRedeem,
117
- };
118
- }
119
- getContractSeed() {
120
- if (!this.bytecode) {
121
- throw new Error('Bytecode is required');
122
- }
123
- const deployerPubKey = this.internalPubKeyToXOnly();
124
- const salt = bitCrypto.hash256(this.randomBytes);
125
- const sha256OfBytecode = bitCrypto.hash256(this.bytecode);
126
- const buf = Buffer.concat([deployerPubKey, salt, sha256OfBytecode]);
127
- return bitCrypto.hash256(buf);
128
- }
129
- customFinalizer = (_inputIndex, input) => {
130
- if (!this.tapLeafScript) {
131
- throw new Error('Tap leaf script is required');
132
- }
133
- if (!input.tapScriptSig) {
134
- throw new Error('Tap script signature is required');
135
- }
136
- const chunks = this.compiledTargetScript.chunks
137
- .slice(0, this.compiledTargetScript.chunks.length)
138
- .reverse();
139
- const scriptSolution = [
140
- ...chunks,
141
- this.randomBytes,
142
- this.internalPubKeyToXOnly(),
143
- input.tapScriptSig[0].signature,
144
- input.tapScriptSig[1].signature,
145
- ];
146
- console.log('length', scriptSolution.length);
147
- const witness = scriptSolution
148
- .concat(this.tapLeafScript.script)
149
- .concat(this.tapLeafScript.controlBlock);
150
- return {
151
- finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness(witness),
152
- };
153
- };
154
- getPubKeys() {
155
- const pubkeys = [this.signer.publicKey];
156
- if (this.contractSigner) {
157
- pubkeys.push(this.contractSigner.publicKey);
158
- }
159
- return pubkeys;
160
- }
161
- generateRedeemScripts() {
162
- this.targetScriptRedeem = {
163
- pubkeys: this.getPubKeys(),
164
- output: this.compiledTargetScript.compiled,
165
- redeemVersion: 192,
166
- };
167
- this.leftOverFundsScriptRedeem = {
168
- pubkeys: this.getPubKeys(),
169
- output: this.getLeafScript(),
170
- redeemVersion: 192,
171
- };
172
- }
173
- getLeafScript() {
174
- return TransactionBuilder.LOCK_LEAF_SCRIPT;
175
- }
176
- getScriptTree() {
177
- if (!this.bytecode) {
178
- throw new Error('Contract bytecode is required');
179
- }
180
- this.generateRedeemScripts();
181
- return [
182
- {
183
- output: this.compiledTargetScript.compiled,
184
- version: 192,
185
- },
186
- {
187
- output: this.getLeafScript(),
188
- version: 192,
189
- },
190
- ];
191
- }
192
- }
@@ -1,11 +0,0 @@
1
- import { TransactionBuilder } from './TransactionBuilder.js';
2
- import { TransactionType } from '../enums/TransactionType.js';
3
- import { IFundingTransactionParameters } from '../interfaces/ITransactionParameters.js';
4
- import { Signer } from 'bitcoinjs-lib';
5
- export declare class FundingTransaction extends TransactionBuilder<TransactionType.FUNDING> {
6
- readonly type: TransactionType.FUNDING;
7
- protected childTransactionRequiredFees: bigint;
8
- constructor(parameters: IFundingTransactionParameters);
9
- protected buildTransaction(): void;
10
- protected getSignerKey(): Signer;
11
- }
@@ -1,23 +0,0 @@
1
- import { TransactionBuilder } from './TransactionBuilder.js';
2
- import { TransactionType } from '../enums/TransactionType.js';
3
- export class FundingTransaction extends TransactionBuilder {
4
- type = TransactionType.FUNDING;
5
- childTransactionRequiredFees;
6
- constructor(parameters) {
7
- super(parameters);
8
- this.childTransactionRequiredFees = parameters.childTransactionRequiredFees;
9
- this.internalInit();
10
- }
11
- buildTransaction() {
12
- this.addInputsFromUTXO();
13
- const amountSpent = this.getTransactionOPNetFee() + this.childTransactionRequiredFees;
14
- this.setFeeOutput({
15
- value: Number(amountSpent),
16
- address: this.to,
17
- });
18
- this.addRefundOutput(amountSpent);
19
- }
20
- getSignerKey() {
21
- return this.signer;
22
- }
23
- }